Example #1
0
 /**
  * @param string $get_array
  * @throws SampleIDMissingException
  */
 public static function get_sample_menu($get_array)
 {
     global $user;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['sample_id']) {
         $sample_security = new SampleSecurity($_GET['sample_id']);
         if ($sample_security->is_access(1, false)) {
             $sample = new Sample($_GET['sample_id']);
             $template = new HTMLTemplate("sample/ajax/detail_menu.html");
             if ($sample->get_availability() == true) {
                 $template->set_var("new_status", "not available");
             } else {
                 $template->set_var("new_status", "available");
             }
             if ($sample->get_owner_id() == $user->get_user_id() or $user->is_admin() == true) {
                 $template->set_var("is_owner", true);
             } else {
                 $template->set_var("is_owner", false);
             }
             if ($user->is_admin() == true) {
                 $template->set_var("is_admin", true);
             } else {
                 $template->set_var("is_admin", false);
             }
             if ($sample_security->is_access(2)) {
                 $sample_template = new SampleTemplate($sample->get_template_id());
                 $current_requirements = $sample->get_requirements();
                 $result = array();
                 $counter = 0;
                 if (is_array($current_requirements) and count($current_requirements) >= 1) {
                     foreach ($current_requirements as $key => $value) {
                         switch ($value['element_type']) {
                             case "item":
                                 $paramquery = array();
                                 $paramquery['username'] = $_GET['username'];
                                 $paramquery['session_id'] = $_GET['session_id'];
                                 $paramquery['nav'] = "sample";
                                 $paramquery['sample_id'] = $_GET['sample_id'];
                                 require_once "core/modules/item/common/item_common.io.php";
                                 $menu_element_array = ItemCommonIO::get_menu_element($value, $key, $counter, $paramquery, "Sample", $_GET['sample_id']);
                                 $result = array_merge($result, $menu_element_array[0]);
                                 $counter = $menu_element_array[1];
                                 break;
                             case "extension":
                                 // Extension implementation in Sample
                                 break;
                         }
                     }
                 }
                 $template->set_var("action", $result);
             } else {
                 $template->set_var("action", "");
             }
             $move_paramquery = $_GET;
             $move_paramquery['run'] = "move";
             unset($move_paramquery['nextpage']);
             $move_params = http_build_query($move_paramquery, '', '&');
             $template->set_var("move_params", $move_params);
             $availability_paramquery = $_GET;
             $availability_paramquery['run'] = "set_availability";
             unset($availability_paramquery['nextpage']);
             $availability_params = http_build_query($availability_paramquery, '', '&');
             $template->set_var("availability_params", $availability_params);
             $rename_paramquery = $_GET;
             $rename_paramquery['run'] = "rename";
             unset($rename_paramquery['nextpage']);
             $rename_params = http_build_query($rename_paramquery, '', '&');
             $template->set_var("rename_params", $rename_params);
             $user_permissions_paramquery = $_GET;
             $user_permissions_paramquery['run'] = "admin_permission_user";
             unset($user_permissions_paramquery['nextpage']);
             $user_permissions_params = http_build_query($user_permissions_paramquery, '', '&');
             $template->set_var("user_permissions_params", $user_permissions_params);
             $ou_permissions_paramquery = $_GET;
             $ou_permissions_paramquery['run'] = "admin_permission_ou";
             unset($ou_permissions_paramquery['nextpage']);
             $ou_permissions_params = http_build_query($ou_permissions_paramquery, '', '&');
             $template->set_var("ou_permissions_params", $ou_permissions_params);
             $delete_paramquery = $_GET;
             $delete_paramquery['run'] = "delete";
             unset($delete_paramquery['nextpage']);
             $delete_params = http_build_query($delete_paramquery, '', '&');
             $template->set_var("delete_params", $delete_params);
             $add_subsample_paramquery = $_GET;
             $add_subsample_paramquery['run'] = "new_subsample";
             unset($add_subsample_paramquery['nextpage']);
             $add_subsample_params = http_build_query($add_subsample_paramquery, '', '&');
             $template->set_var("add_subsample_params", $add_subsample_params);
             $template->output();
         }
     } else {
         throw new SampleIDMissingException();
     }
 }
Example #2
0
 /**
  * @param string $get_array
  * @return string
  * @throws ProjectIDMissingException
  */
 public static function get_project_menu($get_array)
 {
     global $project_security;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['project_id']) {
         $project = new Project($_GET['project_id']);
         $folder_id = ProjectStatusFolder::get_folder_by_project_id_and_project_status_id($_GET['project_id'], $project->get_current_status_id());
         $template = new HTMLTemplate("project/ajax/detail_menu.html");
         switch ($project->is_next_status_available()) {
             case 0:
                 if ($project->get_current_status_id() == 0) {
                     $template->set_var("proceed", 3);
                 } else {
                     $template->set_var("proceed", 4);
                 }
                 break;
             case 1:
                 if ($project_security->is_access(3, false) == true) {
                     if ($project->is_current_status_fulfilled()) {
                         $template->set_var("proceed", 1);
                     } else {
                         $template->set_var("proceed", 2);
                     }
                 }
                 break;
             case 2:
                 if ($project_security->is_access(3, false) == true) {
                     if ($project->is_current_status_fulfilled()) {
                         $template->set_var("proceed", 5);
                     } else {
                         $template->set_var("proceed", 6);
                     }
                 }
                 break;
             default:
                 $template->set_var("proceed", 7);
                 break;
         }
         $template->set_var("next_status_name", $project->get_next_status_name());
         if ($project_security->is_access(3, false) == true) {
             $project_template = new ProjectTemplate($project->get_template_id());
             $current_status_requirements = $project->get_current_status_requirements($project->get_current_status_id());
             $result = array();
             $counter = 0;
             if (is_array($current_status_requirements) and count($current_status_requirements) >= 1) {
                 foreach ($current_status_requirements as $key => $value) {
                     switch ($value['element_type']) {
                         case "item":
                             $paramquery = array();
                             $paramquery['username'] = $_GET['username'];
                             $paramquery['session_id'] = $_GET['session_id'];
                             $paramquery['nav'] = "project";
                             $paramquery['project_id'] = $_GET['project_id'];
                             require_once "core/modules/item/common/item_common.io.php";
                             $menu_element_array = ItemCommonIO::get_menu_element($value, $key, $counter, $paramquery, "Project", $_GET['project_id']);
                             $result = array_merge($result, $menu_element_array[0]);
                             $counter = $menu_element_array[1];
                             break;
                         case "extension":
                             $paramquery = array();
                             $paramquery['username'] = $_GET['username'];
                             $paramquery['session_id'] = $_GET['session_id'];
                             $paramquery['nav'] = "project";
                             $paramquery['run'] = "extension";
                             $paramquery['project_id'] = $_GET['project_id'];
                             $paramquery['extension'] = $value['extension'];
                             $paramquery['retrace'] = Retrace::create_retrace_string();
                             $params = http_build_query($paramquery, '', '&');
                             $result[$counter]['name'] = "Run " . $value['name'];
                             $result[$counter]['depends'] = false;
                             $result[$counter]['params'] = $params;
                             if ($value['fulfilled'] == 1) {
                                 if ($value['occurrence'] == "multiple") {
                                     $result[$counter]['type'] = "link";
                                     $result[$counter]['image'] = "add_extension_done";
                                 } else {
                                     $result[$counter]['type'] = false;
                                     $result[$counter]['image'] = "add_extension_done_na";
                                 }
                             } elseif ($value['fulfilled'] == 0) {
                                 if ($value['occurrence'] == "multiple") {
                                     $result[$counter]['type'] = "link";
                                     $result[$counter]['image'] = "add_extension_wait";
                                 } else {
                                     $result[$counter]['type'] = false;
                                     $result[$counter]['image'] = "add_extension_wait_na";
                                 }
                             } else {
                                 $result[$counter]['type'] = "link";
                                 $result[$counter]['image'] = "add_extension";
                             }
                             if ($value['requirement'] == "optional" and $value['fulfilled'] != 0) {
                                 $result[$counter]['name'] = $result[$counter]['name'] . " (optional)";
                             }
                             $counter++;
                             break;
                     }
                 }
             }
             if ($counter > 0) {
                 $template->set_var("status_action", $result);
             }
             $template->set_var("write", true);
         } else {
             $template->set_var("write", false);
         }
         $paramquery = array();
         $paramquery['username'] = $_GET['username'];
         $paramquery['session_id'] = $_GET['session_id'];
         $paramquery['nav'] = "project";
         $paramquery['run'] = "common_dialog";
         $paramquery['folder_id'] = ProjectFolder::get_supplementary_folder($_GET['project_id']);
         $paramquery['dialog'] = "file_add";
         $paramquery['retrace'] = Retrace::create_retrace_string();
         unset($paramquery['nextpage']);
         $supplementary_params = http_build_query($paramquery, '', '&');
         $template->set_var("supplementary_params", $supplementary_params);
         $log_paramquery = $_GET;
         $log_paramquery['run'] = "log_add";
         unset($log_paramquery['nextpage']);
         $log_params = http_build_query($log_paramquery, '', '&');
         $template->set_var("log_params", $log_params);
         $add_task_paramquery = $_GET;
         $add_task_paramquery['run'] = "add_task";
         unset($add_task_paramquery['nextpage']);
         $add_task_params = http_build_query($add_task_paramquery, '', '&');
         $template->set_var("add_task_params", $add_task_params);
         $show_tasks_paramquery = $_GET;
         $show_tasks_paramquery['run'] = "show_tasks";
         unset($show_tasks_paramquery['nextpage']);
         $show_tasks_params = http_build_query($show_tasks_paramquery, '', '&');
         $template->set_var("show_tasks_params", $show_tasks_params);
         $subproject_paramquery = $_GET;
         $subproject_paramquery['run'] = "new_subproject";
         unset($subproject_paramquery['nextpage']);
         $subproject_params = http_build_query($subproject_paramquery, '', '&');
         $template->set_var("add_subproject_params", $subproject_params);
         $template->output();
     } else {
         throw new ProjectIDMissingException();
     }
 }