Example #1
0
 public static function used_diskspace()
 {
     global $user;
     $user_data = new DataUserData($user->get_user_id());
     $user_filesize = $user_data->get_filesize();
     $user_quota = $user_data->get_quota();
     if ($user_quota != 0) {
         $diskspace_per = $user_filesize / $user_quota * 100;
         if ($diskspace_per == 0) {
             $diskspace_per_display = "(0%)";
         } else {
             $diskspace_per = floor($diskspace_per);
             if ($diskspace_per == 0) {
                 $diskspace_per_display = "(> 1%)";
             } else {
                 $diskspace_per_display = "(" . $diskspace_per . "%)";
             }
         }
         if (round($user_filesize / $user_quota * 100, 0) >= (int) Registry::get_value("data_quota_warning")) {
             $quotaWarn = " <img src='images/icons/notice.png' alt='W' />";
         } else {
             $quotaWarn = "";
         }
     } else {
         $quotaWarn = "";
         $diskspace_per_display = "";
     }
     $act_filesize = Convert::convert_byte_1024($user_filesize);
     $template = new HTMLTemplate("data/home/summary/used_diskspace.html");
     $template->set_var("used_diskspace", $act_filesize . " " . $diskspace_per_display . "" . $quotaWarn);
     return $template->get_string();
 }
Example #2
0
 public static function output($session_expired = false)
 {
     $auth = new Auth();
     $template = new HTMLTemplate("login_header.html");
     $template->output();
     if (is_numeric($_POST['language_id'])) {
         $template = new HTMLTemplate("base/login/login.html", null, $_POST['language_id']);
     } else {
         $template = new HTMLTemplate("base/login/login.html");
     }
     if ($_POST[username]) {
         $template->set_var("username", $_POST[username]);
     } else {
         $template->set_var("username", "");
     }
     if ($_POST[password]) {
         $template->set_var("password", $_POST[password]);
     } else {
         $template->set_var("password", "");
     }
     if ($session_expired === true) {
         $template->set_var("session_expired", "true");
     } else {
         $template->set_var("session_expired", "false");
     }
     $language_array = Language::list_languages();
     $result = array();
     $counter = 0;
     if (is_array($language_array)) {
         foreach ($language_array as $key => $value) {
             $language = new Language($value);
             $result[$counter]['option'] = $value;
             $result[$counter]['name'] = $language->get_full_name();
             if ($_POST['language_id'] == $value) {
                 $result[$counter]['selected'] = "selected='selected'";
             } else {
                 $result[$counter]['selected'] = "";
             }
             $counter++;
         }
     }
     $template->set_var("languages", $result);
     $template->set_var("product", constant("PRODUCT"));
     $template->set_var("product_version", constant("PRODUCT_VERSION"));
     $template->set_var("function", Registry::get_value("base_product_function"));
     $template->set_var("user", Registry::get_value("base_product_user"));
     $template->output();
 }
Example #3
0
 public static function system_info()
 {
     $template = new HTMLTemplate("base/system_info.html");
     $template->set_var("product", constant("PRODUCT"));
     $template->set_var("product_version", constant("PRODUCT_VERSION"));
     $product_user = Registry::get_value("base_product_user");
     $product_function = Registry::get_value("base_product_function");
     $template->set_var("product_user", $product_user);
     $template->set_var("product_function", $product_function);
     $paramquery = $_GET;
     $paramquery['run'] = "software_info";
     $params = http_build_query($paramquery, '', '&#38;');
     $template->set_var("sw_info_params", $params);
     $paramquery = $_GET;
     $paramquery['run'] = "license";
     $params = http_build_query($paramquery, '', '&#38;');
     $template->set_var("license_params", $params);
     $include_array = SystemHandler::list_includes();
     if (is_array($include_array) and count($include_array) >= 1) {
         $include_string = null;
         foreach ($include_array as $key => $value) {
             if (!$include_string) {
                 $include_string = $value['name'];
             } else {
                 $include_string = $include_string . ", " . $value['name'];
             }
         }
         $template->set_var("includes", $include_string);
     } else {
         $template->set_var("includes", "<span class='italic'>none</span>");
     }
     $module_array = SystemHandler::list_modules();
     if (is_array($module_array) and count($module_array) >= 1) {
         $module_string = null;
         foreach ($module_array as $key => $value) {
             if (!$module_string) {
                 $module_string = $value['name'];
             } else {
                 $module_string = $module_string . ", " . $value['name'];
             }
         }
         $template->set_var("modules", $module_string);
     } else {
         $template->set_var("modules", "<span class='italic'>none</span>");
     }
     $template->output();
 }
Example #4
0
 /**
  * @see CronInterface::run()
  */
 public static function run()
 {
     if (self::check() == true) {
         $last_run_daily_datetime = Registry::get_value("base_cron_last_run_daily_datetime");
         $last_run_weekly_datetime = Registry::get_value("base_cron_last_run_weekly_datetime");
         $last_run_daily_datetime_handler = new DatetimeHandler($last_run_daily_datetime);
         $last_run_weekly_datetime_handler = new DatetimeHandler($last_run_weekly_datetime);
         $current_datetime_handler = new DatetimeHandler(date("Y-m-d H:i:s"));
         if ($last_run_daily_datetime_handler->distance($current_datetime_handler) >= 86400) {
             $daily = true;
         } else {
             $daily = false;
         }
         if ($last_run_weekly_datetime_handler->distance($current_datetime_handler) >= 604800) {
             $weekly = true;
         } else {
             $weekly = false;
         }
         $cron_event = new CronEvent(self::$last_run_id, $daily, $weekly);
         $event_handler = new EventHandler($cron_event);
         if ($event_handler->get_success() == true) {
             if (self::$last_run_id + 1 > 256) {
                 Registry::set_value("base_cron_last_run_id", 1);
                 self::$last_run_id = 1;
             } else {
                 Registry::set_value("base_cron_last_run_id", self::$last_run_id + 1);
                 self::$last_run_id = self::$last_run_id + 1;
             }
             Registry::set_value("base_cron_last_run_datetime", date("Y-m-d H:i:s"));
             self::$last_run_datetime = date("Y-m-d H:i:s");
             if ($daily == true) {
                 Registry::set_value("base_cron_last_run_daily_datetime", date("Y-m-d H:i:s"));
             }
             if ($weekly == true) {
                 Registry::set_value("base_cron_last_run_weekly_datetime", date("Y-m-d H:i:s"));
             }
         }
     }
 }
Example #5
0
 /**
  * @see SecurityInterface::ip_error_count()
  * @return integer
  */
 public static function ip_error_count()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $lead_time = date("Y-m-d H:i:s", time() - (int) Registry::get_value("base_max_ip_lead_time"));
     return SystemLog::count_ip_failed_logins_with_begin($ip, $lead_time);
 }
Example #6
0
 /**
  * @see SessionInterface::check_all()
  * Checks all existing sessions; destroys them, if invalid
  */
 public static function check_all()
 {
     $session_array = Session_Access::list_entries();
     if (is_array($session_array) and count($session_array) >= 1) {
         foreach ($session_array as $key => $value) {
             $session_access = new Session_Access($value);
             $session_datetime = explode(" ", $session_access->get_datetime());
             $session_date = explode("-", $session_datetime[0]);
             $session_full_time = explode("+", $session_datetime[1]);
             $session_time = explode(":", $session_full_time[0]);
             $session_mktime = mktime($session_time[0], $session_time[1], $session_time[2], $session_date[1], $session_date[2], $session_date[0]);
             $current_mktime = time();
             $session_timeout = Registry::get_value("base_session_timeout");
             $max_session_mktime = $session_mktime + (int) $session_timeout;
             if ($current_mktime > $max_session_mktime) {
                 $session = new Session($value);
                 $session->destroy();
             }
         }
     }
 }
Example #7
0
 /**
  * @see ProjectInterface::create()
  * @param integer $organisation_unit_id
  * @param integer $parent_project_id
  * @param string $name
  * @param integer $owner_id
  * @param integer $template_id
  * @param string $description
  * @return integer
  * @throws ProjectCreateException
  * @throws ProjectCreateProjectExistsException
  * @throws ProjectCreateStatusException
  * @throws ProjectCreateFolderException
  * @throws ProjectCreateStatusFolderException
  * @throws ProjectCreateStatusSubFolderException
  * @throws ProjectCreateSupplementaryFolderException
  * @throws ProjectCreateDescriptionException
  * @throws ProjectCreateMasterDataException
  * @throws ProjectCreatePermissionUserException
  * @throws ProjectCreatePermissionLeaderException
  * @throws ProjectCreatePermissionGroupException
  * @throws ProjectCreatePermissionOrganisationUnitException
  * @throws ProjectCreatePermissionQualityManagerException
  */
 public function create($organisation_unit_id, $parent_project_id, $name, $owner_id, $template_id, $description)
 {
     global $transaction;
     if ($organisation_unit_id xor $parent_project_id) {
         if ($name and $owner_id and $template_id and $description and $this->project) {
             if ($organisation_unit_id) {
                 $organisation_unit = new OrganisationUnit($organisation_unit_id);
                 if ($organisation_unit->is_permission($owner_id)) {
                     if (self::exist_project_name($organisation_unit_id, null, $name) == true) {
                         throw new ProjectCreateProjectExistsException("Project already exists in this Organisation Unit");
                     }
                 } else {
                     throw new ProjectCreateException("Cannot access on this Organisation Unit");
                 }
             } else {
                 if (self::exist_project_name(null, $parent_project_id, $name) == true) {
                     throw new ProjectCreateProjectExistsException("Project already exists in this Project");
                 }
             }
             $transaction_id = $transaction->begin();
             $user = new User($owner_id);
             $project_user = new ProjectUserData($owner_id);
             $project_quota = $project_user->get_quota();
             // Create Project
             if (($project_id = $this->project->create($organisation_unit_id, $parent_project_id, $name, $owner_id, $template_id, $project_quota)) == null) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id, false);
                 }
                 throw new ProjectCreateException("Could not create Project in DB");
             } else {
                 self::__construct($project_id);
                 $project_template = new ProjectTemplate($template_id);
                 $project_all_status_array = $project_template->get_all_status();
                 $project_has_project_status = new ProjectHasProjectStatus_Access(null);
                 if ($project_has_project_status->create($project_id, $project_all_status_array[0]) != true) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateStatusException("Could not create status");
                 }
                 if ($organisation_unit_id) {
                     $base_folder_id = constant("PROJECT_FOLDER_ID");
                 } else {
                     $base_folder_id = ProjectFolder::get_folder_by_project_id($parent_project_id);
                 }
                 $base_folder = Folder::get_instance($base_folder_id);
                 $path = new Path($base_folder->get_path());
                 $path->add_element($project_id);
                 $project_folder = new ProjectFolder(null);
                 if (($folder_id = $project_folder->create($project_id, $base_folder_id)) == null) {
                     $project_folder->delete(true, true);
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateFolderException("Could not create main folder");
                 }
                 // Create Supplementary Folder
                 $supplementary_path = new Path($path->get_path_string());
                 $supplementary_path->add_element("supplementary");
                 $supplementary_folder = Folder::get_instance(null);
                 if ($supplementary_folder->create("supplementary", $folder_id, $supplementary_path->get_path_string(), $owner_id, null) == null) {
                     $project_folder->delete();
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateSupplementaryFolderException("Could not create supplementary folder");
                 }
                 // Status Folder
                 $folder_array = array();
                 foreach ($project_all_status_array as $key => $value) {
                     $project_status_array = $project_template->get_status_requirements($value);
                     if (is_array($project_status_array) and count($project_status_array) >= 1) {
                         foreach ($project_status_array as $status_key => $status_value) {
                             if (!in_array($value, $folder_array)) {
                                 array_push($folder_array, $value);
                             }
                         }
                     }
                 }
                 foreach ($folder_array as $key => $value) {
                     $projet_status_folder = new ProjectStatusFolder(null);
                     if (($status_folder_id = $projet_status_folder->create($project_id, $value)) == null) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreateStatusFolderException("Could not create status folder");
                     }
                     $project_status = new ProjectStatus($value);
                     $project_status_requirements = $project_template->get_status_requirements($value);
                     // Create Subfolder
                     $sub_folder_array = array();
                     foreach ($project_status_requirements as $sub_key => $sub_value) {
                         if (($sub_value['type'] == "file" or $sub_value['type'] == "value") and $sub_value['folder']) {
                             if (array_search(trim($sub_value['folder']), $sub_folder_array) === false) {
                                 array_push($sub_folder_array, trim($sub_value['folder']));
                             }
                         }
                     }
                     if (is_array($sub_folder_array) and count($sub_folder_array) >= 1) {
                         foreach ($sub_folder_array as $sub_key => $sub_value) {
                             $folder_name = strtolower(trim($sub_value));
                             $folder_name = str_replace(" ", "-", $folder_name);
                             $folder_path = new Path($projet_status_folder->get_path());
                             $folder_path->add_element($folder_name);
                             $sub_folder = Folder::get_instance(null);
                             if ($sub_folder->create($sub_value, $status_folder_id, $folder_path->get_path_string(), $user->get_user_id(), null) == null) {
                                 $project_folder->delete(true, true);
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id, false);
                                 }
                                 throw new ProjectCreateStatusSubFolderException("Could not create status sub folder");
                             }
                         }
                     }
                 }
                 // Create Project Description
                 $value = Value::get_instance(null);
                 if ($value->create($folder_id, $owner_id, 2, $description) == null) {
                     $project_folder->delete(true, true);
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateDescriptionException("Could not create description value");
                 }
                 $project_item = new ProjectItem($project_id);
                 $project_item->set_gid(1);
                 $project_item->set_status_id(1);
                 $project_item->set_item_id($value->get_item_id());
                 if ($project_item->link_item() == false) {
                     $project_folder->delete(true, true);
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateDescriptionException("Could not create description item link");
                 }
                 if ($project_item->set_required(true) == false) {
                     $project_folder->delete(true, true);
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateDescriptionException("Could not create description item role");
                 }
                 // Create Project Master Data
                 if ($this->template_data_array and is_numeric($this->template_data_type_id)) {
                     $value = Value::get_instance(null);
                     if ($value->create($folder_id, $owner_id, $this->template_data_type_id, $this->template_data_array) == null) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreateMasterDataException("Could not create master-data value");
                     }
                     $project_item = new ProjectItem($project_id);
                     $project_item->set_gid(1);
                     $project_item->set_status_id(1);
                     $project_item->set_item_id($value->get_item_id());
                     if ($project_item->link_item() == false) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreateMasterDataException("Could not create master-data item link");
                     }
                     if ($project_item->set_required(true) == false) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreateMasterDataException("Could not create master-data item role");
                     }
                 }
                 // Permissions
                 if ($organisation_unit_id) {
                     $organisation_unit = new OrganisationUnit($organisation_unit_id);
                     try {
                         $project_permission = new ProjectPermissionUser(null);
                         $project_permission->create($owner_id, $project_id, (int) Registry::get_value("project_user_default_permission"), null, 1);
                     } catch (ProjectPermissionUserException $e) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreatePermissionUserException("Could not create user/owner permission");
                     }
                     $leader_array = $organisation_unit->list_leaders();
                     if (is_array($leader_array) and count($leader_array) >= 1) {
                         foreach ($leader_array as $key => $value) {
                             try {
                                 $project_permission = new ProjectPermissionUser(null);
                                 $project_permission->create($value, $project_id, (int) Registry::get_value("project_leader_default_permission"), null, 2);
                             } catch (ProjectPermissionUserException $e) {
                                 $project_folder->delete(true, true);
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id, false);
                                 }
                                 throw new ProjectCreatePermissionLeaderException("Could not create leader permission");
                             }
                         }
                     }
                     try {
                         $project_permission = new ProjectPermissionOrganisationUnit(null);
                         $project_permission->create($organisation_unit_id, $project_id, (int) Registry::get_value("project_organisation_unit_default_permission"), null, 3);
                     } catch (ProjectPermissionOrganisationUnitException $e) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreatePermissionOrganisationUnitException("Could not create Organisation Unit permission");
                     }
                     $quality_manager_array = $organisation_unit->list_quality_managers();
                     if (is_array($quality_manager_array) and count($quality_manager_array) >= 1) {
                         foreach ($quality_manager_array as $key => $value) {
                             try {
                                 $project_permission = new ProjectPermissionUser(null);
                                 $project_permission->create($value, $project_id, (int) Registry::get_value("project_quality_manager_default_permission"), null, 5);
                             } catch (ProjectPermissionUserException $e) {
                                 $project_folder->delete(true, true);
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id, false);
                                 }
                                 throw new ProjectCreatePermissionQualityManagerException("Could not create quality-manager permission");
                             }
                         }
                     }
                     $group_array = $organisation_unit->list_groups();
                     if (is_array($group_array) and count($group_array) >= 1) {
                         foreach ($group_array as $key => $value) {
                             try {
                                 $project_permission = new ProjectPermissionGroup(null);
                                 $project_permission->create($value, $project_id, (int) Registry::get_value("project_group_default_permission"), null, 4);
                             } catch (ProjectPermissionGroupException $e) {
                                 $project_folder->delete(true, true);
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id, false);
                                 }
                                 throw new ProjectCreatePermissionGroupException("Could not create group permissions");
                             }
                         }
                     }
                 }
                 self::__construct($project_id);
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return $project_id;
             }
         } else {
             throw new ProjectCreateException("Needed values are missing");
         }
     } else {
         throw new ProjectCreateException("Project target is ambiguous");
     }
 }
Example #8
0
 /**
  * @see ServiceInterface::start()
  * @return boolean
  */
 public function start()
 {
     if ($this->service and $this->service_id) {
         $java_vm = Registry::get_value("base_java_vm");
         if ($java_vm) {
             $binary_access = new BaseBinary_Access($this->service->get_binary_id());
             $file = constant("BIN_DIR") . "/" . $binary_access->get_path() . "/" . $binary_access->get_file();
             $cmd = "start /B " . $java_vm . " -jar " . $file . " " . $this->service_id;
             if (($handle = popen($cmd, "r")) !== false) {
                 pclose($handle);
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 /**
  * @see ProjectSecurityInterface::change_organisation_unit_permission()
  * @param integer $organisation_unit_id
  * @return bool
  * @throws ProjectSecurityChangeException
  */
 public function change_organisation_unit_permission($organisation_unit_id)
 {
     global $transaction;
     if (is_numeric($organisation_unit_id)) {
         $transaction_id = $transaction->begin();
         $organisation_unit = new OrganisationUnit($organisation_unit_id);
         $project_permission_ou_group_array = ProjectPermission::list_entries_by_project_id_and_intention($this->project_id, 4);
         if (is_array($project_permission_ou_group_array) and count($project_permission_ou_group_array) >= 1) {
             foreach ($project_permission_ou_group_array as $key => $value) {
                 try {
                     $project_permission = ProjectPermission::get_instance($value);
                     $project_permission->delete() == false;
                 } catch (ProjectPermissionException $e) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectSecurityChangeException();
                 }
             }
         }
         $project_permission_array = ProjectPermission::list_entries_by_project_id_and_intention($this->project_id, 3);
         if (count($project_permission_array) > 0 and is_numeric($project_permission_array[0])) {
             $project_permission = ProjectPermission::get_instance($project_permission_array[0]);
             if (($return_value = $project_permission->set_organisation_unit_id($organisation_unit_id)) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectSecurityChangeException();
             }
         } else {
             try {
                 $project_permission = new ProjectPermissionOrganisationUnit(null);
                 $return_value = $project_permission->create($organisation_unit_id, $this->project_id, (int) Registry::get_value("project_organisation_unit_default_permission"), null, 3);
             } catch (ProjectPermissionOrganisationUnitException $e) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectSecurityChangeException();
             }
         }
         $group_array = $organisation_unit->list_groups();
         if (is_array($group_array) and count($group_array) >= 1) {
             foreach ($group_array as $key => $value) {
                 try {
                     $project_permission = new ProjectPermissionGroup(null);
                     $project_permission->create($value, $this->project_id, (int) Registry::get_value("project_group_default_permission"), null, 4);
                 } catch (ProjectPermissionGroupException $e) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectSecurityChangeException();
                 }
             }
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         return $return_value;
     } else {
         throw new ProjectSecurityChangeException("Missing Information");
     }
 }
Example #10
0
 /**
  * @param integer $page
  * @return string
  * @throws BaseAssistantRequestPageNotExistsException
  */
 public static function get_content($page)
 {
     global $session, $user;
     switch ($page) {
         case "1":
             $sample_organ_unit = $session->read_value("SAMPLE_ORGANISATION_UNIT");
             $template = new HTMLTemplate("sample/new_sample_page_1.html");
             $result = array();
             $counter = 0;
             $organisation_unit_array = OrganisationUnit::list_entries();
             foreach ($organisation_unit_array as $key => $value) {
                 $organisation_unit = new OrganisationUnit($value);
                 if ($organisation_unit->is_permission($user->get_user_id()) and $organisation_unit->get_stores_data() == true) {
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $organisation_unit->get_name();
                     if ($sample_organ_unit == $value) {
                         $result[$counter]['selected'] = "selected";
                     } else {
                         $result[$counter]['selected'] = "";
                     }
                     $result[$counter]['disabled'] = "";
                     $counter++;
                 }
             }
             if (!$result) {
                 $result[$counter]['value'] = "0";
                 $result[$counter]['content'] = "NO ORGANISATION UNIT FOUND!";
                 $result[$counter]['selected'] = "";
                 $result[$counter]['disabled'] = "disabled='disabled'";
             }
             $template->set_var("option", $result);
             return $template->get_string();
             break;
         case "2":
             $sample_template = $session->read_value("SAMPLE_TEMPLATE");
             $type_array = $session->read_value("SAMPLE_ITEM_TYPE_ARRAY");
             $template = new HTMLTemplate("sample/new_sample_page_2.html");
             if (!is_array($type_array) or count($type_array) == 0) {
                 $type_array = null;
             }
             $result = array();
             $counter = 0;
             $sample_template_array = SampleTemplate::list_entries();
             if (is_array($sample_template_array)) {
                 foreach ($sample_template_array as $key => $value) {
                     if ($type_array == null or in_array($value, $type_array)) {
                         $sample_sub_template = new SampleTemplate($value);
                         $result[$counter]['value'] = $value;
                         $result[$counter]['content'] = $sample_sub_template->get_name();
                         if ($sample_template == $value) {
                             $result[$counter]['selected'] = "selected";
                         } else {
                             $result[$counter]['selected'] = "";
                         }
                         $result[$counter]['disabled'] = "";
                         $counter++;
                     }
                 }
             } else {
                 $result[$counter]['value'] = "0";
                 $result[$counter]['content'] = "NO TEMPLATES FOUND!";
                 $result[$counter]['selected'] = "";
                 $result[$counter]['disabled'] = "disabled='disabled'";
             }
             $template->set_var("option", $result);
             if ($session->is_value("ADD_ITEM_TEMP_KEYWORDS_" . $_GET['idk_unique_id']) == true) {
                 $template->set_var("keywords", $session->read_value("ADD_ITEM_TEMP_KEYWORDS_" . $_GET['idk_unique_id']));
             } else {
                 $template->set_var("keywords", "");
             }
             if ($session->is_value("ADD_ITEM_TEMP_DESCRIPTION_" . $_GET['idk_unique_id']) == true) {
                 $template->set_var("description", $session->read_value("ADD_ITEM_TEMP_DESCRIPTION_" . $_GET['idk_unique_id']));
             } else {
                 $template->set_var("description", "");
             }
             return $template->get_string();
             break;
         case "3":
             $sample_template = $session->read_value("SAMPLE_TEMPLATE");
             $sample_name = $session->read_value("SAMPLE_NAME");
             $sample_manufacturer = $session->read_value("SAMPLE_MANUFACTURER_ID");
             $sample_manufacturer_name = $session->read_value("SAMPLE_MANUFACTURER_NAME");
             $sample_location = $session->read_value("SAMPLE_LOCATION");
             $sample_expiry = $session->read_value("SAMPLE_EXPIRY");
             $sample_expiry_warning = $session->read_value("SAMPLE_EXPIRY_WARNING");
             $sample_description = $session->read_value("SAMPLE_DESCRIPTION");
             $sample_template_obj = new SampleTemplate($sample_template);
             $information_fields = $sample_template_obj->get_information_fields();
             $template = new HTMLTemplate("sample/new_sample_page_3.html");
             if ($information_fields['manufacturer']['name'] and $information_fields['manufacturer']['requirement'] != "optional") {
                 $template->set_var("check_manufacturer", true);
             } else {
                 $template->set_var("check_manufacturer", false);
             }
             if ($information_fields['expiry']['name'] and $information_fields['expiry']['requirement'] != "optional") {
                 $template->set_var("check_expiry", true);
             } else {
                 $template->set_var("check_expiry", false);
             }
             if ($information_fields['location']['name'] and $information_fields['location']['requirement'] != "optional") {
                 $template->set_var("check_location", true);
             } else {
                 $template->set_var("check_location", false);
             }
             if ($sample_name) {
                 $template->set_var("name", $sample_name);
             } else {
                 $template->set_var("name", "");
             }
             if ($information_fields['manufacturer']['name']) {
                 require_once "core/modules/manufacturer/io/manufacturer.io.php";
                 $template->set_var("show_manufacturer", true);
                 $template->set_var("manufacturer_html", ManufacturerIO::dialog());
             } else {
                 $template->set_var("show_manufacturer", false);
                 $template->set_var("manufacturer_html", "");
             }
             if ($information_fields['expiry']['name']) {
                 $template->set_var("show_expiry", true);
             } else {
                 $template->set_var("show_expiry", false);
             }
             if ($information_fields['location']['name']) {
                 $template->set_var("show_location", true);
                 $result = array();
                 $counter = 0;
                 $sample_location_array = Location::list_entries();
                 if (is_array($sample_location_array) and count($sample_location_array) >= 1) {
                     foreach ($sample_location_array as $key => $value) {
                         $sample_location_obj = new Location($value);
                         $result[$counter]['value'] = $value;
                         $result[$counter]['content'] = $sample_location_obj->get_name(true);
                         if ($sample_location == $value) {
                             $result[$counter]['selected'] = "selected";
                         } else {
                             $result[$counter]['selected'] = "";
                         }
                         $counter++;
                     }
                 } else {
                     $result[$counter]['value'] = "0";
                     $result[$counter]['content'] = "NO LOCATIONS FOUND!";
                 }
                 $template->set_var("location", $result);
             } else {
                 $template->set_var("show_location", false);
             }
             if ($sample_manufacturer) {
                 $template->set_var("manufacturer", $sample_manufacturer);
             } else {
                 $template->set_var("manufacturer", "");
             }
             if ($sample_manufacturer_name) {
                 $template->set_var("manufacturer_name", $sample_manufacturer_name);
             } else {
                 $template->set_var("manufacturer_name", "");
             }
             if ($sample_expiry) {
                 $template->set_var("expiry", $sample_expiry);
             } else {
                 $template->set_var("expiry", "");
             }
             if ($sample_expiry_warning) {
                 $template->set_var("expiry_warning", $sample_expiry_warning);
             } else {
                 $template->set_var("expiry_warning", (int) Registry::get_value("sample_default_expiry_warning"));
             }
             if ($sample_description) {
                 $template->set_var("desc", $sample_description);
             } else {
                 $template->set_var("desc", "");
             }
             return $template->get_string();
             break;
         case "4":
             $sample_add_role = $session->read_value("SAMPLE_ADD_ROLE");
             $sample_add_item_holder_class = $session->read_value("SAMPLE_ADD_ITEM_HOLDER_CLASS");
             $sample_add_item_holder_id = $session->read_value("SAMPLE_ADD_ITEM_HOLDER_ID");
             $sample_template = $session->read_value("SAMPLE_TEMPLATE");
             $sample_template_data_type = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE");
             $sample_template_data_type_id = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE_ID");
             $sample_template_data_array = $session->read_value("SAMPLE_TEMPLATE_DATA_ARRAY");
             $sample_template_obj = new SampleTemplate($sample_template);
             $required_array = $sample_template_obj->get_required_requirements();
             if (is_array($required_array) and count($required_array) >= 1) {
                 $value_type_id = 0;
                 $sample_count = 0;
                 $is_value = false;
                 $is_sample = false;
                 foreach ($required_array as $key => $value) {
                     if ($value['xml_element'] == "item") {
                         if ($value['type'] == "value") {
                             $is_value = true;
                         } elseif ($value['type'] == "parentsample") {
                             $is_sample = true;
                             $sample_count++;
                         }
                     }
                     if ($value['xml_element'] == "type" and !$value['close'] and $is_value == true) {
                         $value_type_id = $value['id'];
                     }
                 }
                 if ($is_value == true xor $is_sample == true) {
                     if ($is_value == true) {
                         $template = new HTMLTemplate("sample/new_sample_page_4_value.html");
                         require_once "core/modules/data/io/value_form.io.php";
                         $value_form_io = new ValueFormIO(null, $value_type_id, null, $sample_template_data_array);
                         $value_form_io->set_field_class("SampleCreateAssistantField");
                         $template->set_var("content", $value_form_io->get_content());
                         $template->set_var("template_data_type_id", $value_type_id);
                         return $template->get_string();
                     } else {
                         $template = new HTMLTemplate("sample/new_sample_page_4_sample.html");
                         if ($sample_count > 0) {
                             $result = array();
                             if ($sample_add_role == "item" and is_numeric($sample_add_item_holder_id) and class_exists($sample_add_item_holder_class)) {
                                 $item_holder_list_sql = $sample_add_item_holder_class::get_item_list_sql($sample_add_item_holder_id);
                                 if ($item_holder_list_sql) {
                                     $sample_array = Sample::list_samples_by_item_sql_list($item_holder_list_sql);
                                 } else {
                                     $sample_array = Sample::list_user_related_samples($user->get_user_id());
                                 }
                             } else {
                                 $sample_array = Sample::list_user_related_samples($user->get_user_id());
                             }
                             for ($i = 0; $i <= $sample_count - 1; $i++) {
                                 $result[$i]['id'] = $i + 1;
                                 if ($sample_template_data_type == "sample") {
                                     if ($sample_template_data_array['sample-' . $result[$i]['id'] . '']) {
                                         $selected_id = $sample_template_data_array['sample-' . $result[$i]['id'] . ''];
                                     }
                                 }
                                 if (is_array($sample_array) and count($sample_array) >= 1) {
                                     $counter = 0;
                                     foreach ($sample_array as $key => $value) {
                                         $sample = new Sample($value);
                                         $result[$i][$counter]['value'] = $value;
                                         $result[$i][$counter]['content'] = $sample->get_name();
                                         if ($selected_id == $value) {
                                             $result[$i][$counter]['selected'] = "selected";
                                         } else {
                                             $result[$i][$counter]['selected'] = "";
                                         }
                                         $counter++;
                                     }
                                 } else {
                                     $result[$i][0]['value'] = 0;
                                     $result[$i][0]['content'] = "You have no samples";
                                     $result[$i][0]['selected'] = "";
                                 }
                                 unset($selected_id);
                             }
                             $template->set_var("sample", $result);
                         }
                         return $template->get_string();
                     }
                 } else {
                     $template = new HTMLTemplate("sample/new_sample_page_4_error.html");
                     return $template->get_string();
                 }
             } else {
                 $template = new HTMLTemplate("sample/new_sample_page_4_error.html");
                 return $template->get_string();
             }
             break;
         case "5":
             $sample_organ_unit = $session->read_value("SAMPLE_ORGANISATION_UNIT");
             $sample_template = $session->read_value("SAMPLE_TEMPLATE");
             $sample_name = $session->read_value("SAMPLE_NAME");
             $sample_manufacturer = $session->read_value("SAMPLE_MANUFACTURER_ID");
             $sample_manufacturer_name = $session->read_value("SAMPLE_MANUFACTURER_NAME");
             $sample_location = $session->read_value("SAMPLE_LOCATION");
             $sample_expiry = $session->read_value("SAMPLE_EXPIRY");
             $sample_expiry_warning = $session->read_value("SAMPLE_EXPIRY_WARNING");
             $sample_description = $session->read_value("SAMPLE_DESCRIPTION");
             $template = new HTMLTemplate("sample/new_sample_page_5.html");
             $organisation_unit = new OrganisationUnit($sample_organ_unit);
             $template->set_var("sample_organisation_unit", $organisation_unit->get_name());
             $sample_template_obj = new SampleTemplate($sample_template);
             $template->set_var("sample_template", $sample_template_obj->get_name());
             $template->set_var("sample_name", $sample_name);
             if ($sample_manufacturer) {
                 $template->set_var("sample_manufacturer", $sample_manufacturer_name);
             } else {
                 $template->set_var("sample_manufacturer", false);
             }
             if ($sample_location) {
                 $sample_location_obj = new Location($sample_location);
                 $template->set_var("sample_location", $sample_location_obj->get_name(true));
             } else {
                 $template->set_var("sample_location", false);
             }
             if ($sample_expiry) {
                 $template->set_var("sample_date_of_expiry", $sample_expiry);
             } else {
                 $template->set_var("sample_date_of_expiry", false);
             }
             if ($sample_desc) {
                 $sample_desc_display = str_replace("\n", "<br />", $sample_desc);
                 $template->set_var("sample_description", $sample_desc_display);
             } else {
                 $template->set_var("sample_description", "<span class='italic'>None</span>");
             }
             return $template->get_string();
             break;
         default:
             throw new BaseAssistantRequestedPageNotExistsException();
             break;
     }
 }
Example #11
0
 /**
  * Main Controller for reqeusts via index.php
  * @throws BaseModuleControllerClassNotFoundException
  * @throws BaseModuleControllerFileNotFoundException
  */
 public static function io()
 {
     global $session, $user, $transaction;
     $template = new HTMLTemplate("index_header.html");
     if (!isset($GLOBALS['fatal_error'])) {
         $unique_id = uniqid();
         $css_directory = constant("WWW_DIR") . "/css";
         if (file_exists($css_directory)) {
             $css_directory_array = scandir($css_directory);
             if (is_array($css_directory_array)) {
                 $index_css = "";
                 foreach ($css_directory_array as $key => $value) {
                     if (strpos(strrev($value), "ssc.") === 0 and strpos(strrev($value), "ssc.gubed") === false and $value != "main.css") {
                         if (is_file($css_directory . "/" . $value)) {
                             if (constant("AVOID_CSS_CACHE") == true) {
                                 $index_css .= "<link rel='stylesheet' type='text/css' href='css/" . $value . "?" . $unique_id . "' title='Style' />\n";
                             } else {
                                 $index_css .= "<link rel='stylesheet' type='text/css' href='css/" . $value . "' title='Style' />\n";
                             }
                         }
                     }
                 }
             }
             $template->set_var("INDEX_CSS", $index_css);
         }
         $index_js = "";
         $js_lib_directory = constant("WWW_DIR") . "/js/lib";
         if (file_exists($js_lib_directory)) {
             $js_lib_directory_array = scandir($js_lib_directory);
             if (is_array($js_lib_directory_array)) {
                 $index_js = "";
                 foreach ($js_lib_directory_array as $key => $value) {
                     if (strpos(strrev($value), "sj.") === 0) {
                         if (is_file($js_lib_directory . "/" . $value)) {
                             if (constant("AVOID_JS_CACHE") == true) {
                                 $index_js .= "<script type='text/javascript' src='js/lib/" . $value . "?" . $unique_id . "'></script>\n";
                             } else {
                                 $index_js .= "<script type='text/javascript' src='js/lib/" . $value . "'></script>\n";
                             }
                         }
                     }
                 }
             }
         }
         $js_modules_directory = constant("WWW_DIR") . "/js/modules";
         if (file_exists($js_modules_directory)) {
             $js_modules_directory_array = scandir($js_modules_directory);
             if (is_array($js_modules_directory_array)) {
                 foreach ($js_modules_directory_array as $key => $value) {
                     if (strpos(strrev($value), "sj.") === 0) {
                         if (is_file($js_modules_directory . "/" . $value)) {
                             if (constant("AVOID_JS_CACHE") == true) {
                                 $index_js .= "<script type='text/javascript' src='js/modules/" . $value . "?" . $unique_id . "'></script>\n";
                             } else {
                                 $index_js .= "<script type='text/javascript' src='js/modules/" . $value . "'></script>\n";
                             }
                         }
                     }
                 }
             }
         }
         if ($index_js) {
             $template->set_var("INDEX_JS", $index_js);
         } else {
             $template->set_var("INDEX_JS", " ");
         }
     } else {
         $template->set_var("INDEX_CSS", "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/base.css\" title=\"Style\" />\n<link rel=\"stylesheet\" type=\"text/css\" href=\"css/login.css\" title=\"Style\" />");
         $template->set_var("INDEX_JS", "");
     }
     if (!isset($GLOBALS['fatal_error'])) {
         $template->set_var("INDEX_TITLE", Registry::get_value("base_html_title"));
         if (Cron::check() == true) {
             $template->set_var("CRON", true);
         } else {
             $template->set_var("CRON", false);
         }
         $template->output();
         $max_ip_errors = (int) Registry::get_value("base_max_ip_failed_logins");
         if (!is_numeric($max_ip_errors) or $max_ip_errors < 3) {
             $max_ip_errors = 3;
         }
         if (Security::ip_error_count() < $max_ip_errors) {
             $session_valid_array = $session->is_valid();
             if ($session_valid_array[0] === true) {
                 $template = new HTMLTemplate("main_header.html");
                 $sub_menu = array();
                 $module_dialog_array = ModuleDialog::list_dialogs_by_type("base_user_lists");
                 if (is_array($module_dialog_array) and count($module_dialog_array) >= 1) {
                     foreach ($module_dialog_array as $key => $value) {
                         $paramquery['username'] = $_GET['username'];
                         $paramquery['session_id'] = $_GET['session_id'];
                         $paramquery['nav'] = "base";
                         $paramquery['run'] = "base_user_lists";
                         $paramquery['dialog'] = $value['internal_name'];
                         $params = http_build_query($paramquery, '', '&#38;');
                         $temp_array = array();
                         $temp_array['params'] = $params;
                         $temp_array['title'] = Language::get_message($value['language_address'], "dialog");
                         array_push($sub_menu, $temp_array);
                         unset($temp_array);
                     }
                 }
                 $template->set_var("sub_menu", $sub_menu);
                 $my_profile_paramquery['username'] = $_GET['username'];
                 $my_profile_paramquery['session_id'] = $_GET['session_id'];
                 $my_profile_paramquery['nav'] = "base";
                 $my_profile_paramquery['run'] = "user_profile";
                 $my_profile_params = http_build_query($my_profile_paramquery, '', '&#38;');
                 $template->set_var("my_profile_params", $my_profile_params);
                 $system_messages_paramquery['username'] = $_GET['username'];
                 $system_messages_paramquery['session_id'] = $_GET['session_id'];
                 $system_messages_paramquery['nav'] = "base";
                 $system_messages_paramquery['run'] = "sysmsg";
                 $system_messages_params = http_build_query($system_messages_paramquery, '', '&#38;');
                 $template->set_var("system_messages_params", $system_messages_params);
                 $about_paramquery['username'] = $_GET['username'];
                 $about_paramquery['session_id'] = $_GET['session_id'];
                 $about_paramquery['nav'] = "base";
                 $about_paramquery['run'] = "system_info";
                 $about_params = http_build_query($about_paramquery, '', '&#38;');
                 $template->set_var("about_params", $about_params);
                 $template->set_var("username", $user->get_full_name(true));
                 $header_search_paramquery['username'] = $_GET['username'];
                 $header_search_paramquery['session_id'] = $_GET['session_id'];
                 $header_search_paramquery['nav'] = "base.search";
                 $header_search_paramquery['run'] = "header_search";
                 $header_search_paramquery['nextpage'] = "1";
                 $header_search_params = http_build_query($header_search_paramquery, '', '&#38;');
                 $template->set_var("header_search_params", $header_search_params);
                 $template->set_var("header_search_current_module", $_GET['nav']);
                 $template->output();
                 try {
                     // Navigation
                     require_once "base/io/navigation.io.php";
                     Navigation_IO::main();
                     Navigation_IO::left();
                     $template = new HTMLTemplate("content_header.html");
                     $template->output();
                     if ($session->read_value("must_change_password") == true) {
                         require_once "core/modules/base/io/user.io.php";
                         UserIO::change_password_on_login();
                     } else {
                         if ($_GET['nav']) {
                             $module_controller_array = SystemHandler::get_module_controller($_GET['nav']);
                             $module_controller_path = "core/modules/" . $module_controller_array['path'];
                             if (file_exists($module_controller_path)) {
                                 require_once $module_controller_path;
                                 if (class_exists($module_controller_array['class'])) {
                                     $module_controller_array['class']::io_handler($module_controller_array['alias']);
                                 } else {
                                     throw new BaseModuleControllerClassNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleControllerFileNotFoundException();
                             }
                         } else {
                             include "core/modules/base/io/home.io.php";
                         }
                     }
                 } catch (DatabaseQueryFailedException $e) {
                     $transaction->force_rollback();
                     $error_io = new Error_IO($e);
                     $error_io->display_error();
                 } catch (BaseException $e) {
                     $error_io = new Error_IO($e);
                     $error_io->display_error();
                 }
                 $template = new HTMLTemplate("content_footer.html");
                 $template->output();
                 $template = new HTMLTemplate("main_footer.html");
                 $template->output();
             } else {
                 require_once "base/io/login.io.php";
                 if ($session_valid_array[1] === true) {
                     Login_IO::output(true);
                 } else {
                     Login_IO::output(false);
                 }
             }
         } else {
             Error_IO::security_out_of_box_error("Your IP was blocked by server!");
         }
     } else {
         $template->set_var("INDEX_TITLE", "Open-LIMS");
         $template->output();
         Error_IO::fatal_error($GLOBALS['fatal_error']);
     }
     $template = new HTMLTemplate("index_footer.html");
     $template->output();
 }
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     if ($event_object instanceof UserDeleteEvent) {
         if (ProjectPermission_Access::delete_by_user_id($event_object->get_user_id()) == false) {
             return false;
         }
     }
     if ($event_object instanceof GroupDeleteEvent) {
         if (ProjectPermission_Access::delete_by_group_id($event_object->get_group_id()) == false) {
             return false;
         }
     }
     if ($event_object instanceof OrganisationUnitDeleteEvent) {
         if (ProjectPermission_Access::delete_by_organisation_unit_id($event_object->get_organisation_unit_id()) == false) {
             return false;
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitLeaderCreateEvent) {
         $project_array = Project::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array) and count($project_array) >= 1) {
             $project_permission = new ProjectPermissionUser(null);
             foreach ($project_array as $key => $value) {
                 if ($project_permission->create($event_object->get_leader_id(), $value, (int) Registry::get_value("project_leader_default_permission"), null, 2) == null) {
                     return false;
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitLeaderDeleteEvent) {
         $project_array = Project::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array) and count($project_array) >= 1) {
             foreach ($project_array as $key => $value) {
                 $permission_array = self::list_entries_by_project_id_and_intention_and_user_id($value, 2, $event_object->get_leader_id());
                 if (is_array($permission_array) and count($permission_array) >= 1) {
                     foreach ($permission_array as $permission_key => $permission_value) {
                         $project_permission = self::get_instance($permission_value);
                         if ($project_permission->delete() == false) {
                             return false;
                         }
                     }
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitQualityManagerCreateEvent) {
         $project_array = Project::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array) and count($project_array) >= 1) {
             $project_permission = new ProjectPermissionUser(null);
             foreach ($project_array as $key => $value) {
                 if ($project_permission->create($event_object->get_quality_manager_id(), $value, (int) Registry::get_value("project_quality_manager_default_permission"), null, 5) == null) {
                     return false;
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitQualityManagerDeleteEvent) {
         $project_array = Project::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array) and count($project_array) >= 1) {
             foreach ($project_array as $key => $value) {
                 $permission_array = self::list_entries_by_project_id_and_intention_and_user_id($value, 5, $event_object->get_quality_manager_id());
                 if (is_array($permission_array) and count($permission_array) >= 1) {
                     foreach ($permission_array as $permission_key => $permission_value) {
                         $project_permission = self::get_instance($permission_value);
                         if ($project_permission->delete() == false) {
                             return false;
                         }
                     }
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitGroupCreateEvent) {
         $project_array = self::list_system_setted_projects_by_organisation_id($event_object->get_organisation_unit_id());
         if (is_array($project_array) and count($project_array) >= 1) {
             foreach ($project_array as $key => $value) {
                 $project_permission = new ProjectPermissionGroup(null);
                 if ($project_permission->create($event_object->get_group_id(), $value, (int) Registry::get_value("project_group_default_permission"), null, 4) == null) {
                     return false;
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitGroupDeleteEvent) {
         $project_array = self::list_system_setted_projects_by_organisation_id($event_object->get_organisation_unit_id());
         if (is_array($project_array) and count($project_array) >= 1) {
             foreach ($project_array as $key => $value) {
                 $project_permission_array = ProjectPermission::list_entries_by_project_id_and_intention_and_group_id($value, 4, $event_object->get_group_id());
                 if (is_array($project_permission_array) and count($project_permission_array) >= 1) {
                     foreach ($project_permission_array as $sub_key => $sub_value) {
                         $project_permission = self::get_instance($sub_value);
                         if ($project_permission->delete() == false) {
                             return false;
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
Example #13
0
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     if ($event_object instanceof FileDeleteEvent) {
         $file_version_array = FileVersion_Access::list_entries_by_toid($event_object->get_file_id());
         if (is_array($file_version_array)) {
             foreach ($file_version_array as $key => $value) {
                 if (self::delete_file_version_entries($value) == false) {
                     return false;
                 }
             }
         }
     }
     if ($event_object instanceof FileVersionDeleteEvent) {
         if (self::delete_file_version_entries($event_object->get_file_version_id()) == false) {
             return false;
         }
     }
     if ($event_object instanceof CronEvent) {
         if ($event_object->get_daily() == true) {
             $max_cached_images = (int) Registry::get_value("data_max_cached_images");
             $outdated_files = FileImageCache_Access::get_outdated_files_by_number($max_cached_images);
             if (is_array($outdated_files) and count($max_cached_images) >= 1) {
                 foreach ($outdated_files as $key => $value) {
                     if (file_exists(constant("BASE_DIR") . "/filesystem/temp/" . $value['file_version_id'] . "-" . $value['width'] . "-" . $value['height'] . ".jpg")) {
                         if (unlink(constant("BASE_DIR") . "/filesystem/temp/" . $value['file_version_id'] . "-" . $value['width'] . "-" . $value['height'] . ".jpg") == false) {
                             return false;
                         }
                     } elseif (file_exists(constant("BASE_DIR") . "/filesystem/temp/" . $value['file_version_id'] . "-" . $value['width'] . "-" . $value['height'] . ".png")) {
                         if (unlink(constant("BASE_DIR") . "/filesystem/temp/" . $value['file_version_id'] . "-" . $value['width'] . "-" . $value['height'] . ".png") == false) {
                             return false;
                         }
                     }
                     $file_image_cache = new FileImageCache_Access($value['id']);
                     if ($file_image_cache->delete() == false) {
                         return false;
                     }
                 }
             }
         }
     }
     return true;
 }
Example #14
0
<?php

/**
 * @package data
 * @version 0.4.0.0
 * @author Roman Konertz <konertz@open-lims.org>
 * @copyright (c) 2008-2014 by Roman Konertz
 * @license GPLv3
 * 
 * This file is part of Open-LIMS
 * Available at http://www.open-lims.org
 * 
 * This program is free software;
 * you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
 * version 3 of the License.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, see <http://www.gnu.org/licenses/>.
 */
/**
 * 
 */
$product_user = Registry::get_value("base_product_user");
$product_function = Registry::get_value("base_product_function");
define("LOGIN_FOOTER", "" . constant("PRODUCT") . ", version: " . constant("PRODUCT_VERSION") . ", " . $product_function . ", " . $product_user . " " . "<br />This is free software; It comes with ABSOLUTELY NO WARRANTY." . "<br />by R. Konertz, B. Tunggal, L. Eichinger et al.; 2008-2011");
Example #15
0
 /**
  * @see UserInterface::create()
  * @param string $username
  * @param string $gener
  * @param string $title
  * @param string $forename
  * @param string $surname
  * @param string $mail
  * @param bool $can_change_password
  * @param bool $must_change_password
  * @param bool $disabled
  * @return string Generated User Password
  * @throws UserCreationFailedException
  * @throws UserAlreadyExistException
  */
 public function create($username, $gender, $title, $forename, $surname, $mail, $can_change_password, $must_change_password, $disabled)
 {
     global $transaction;
     if ($this->user) {
         if ($username and $gender and $forename and $surname and $mail) {
             $transaction_id = $transaction->begin();
             if (self::exist_username($username) == true) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new UserAlreadyExistException("", 2);
             }
             $password = self::generate_password();
             if (($user_id = $this->user->create($username, md5(sha1($password)))) != null) {
                 $user_admin_setting = new UserAdminSetting_Access(null);
                 if ($user_admin_setting->create($user_id) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new UserCreationFailedException("", 1);
                 }
                 $user_profile_setting = new UserRegionalSetting_Access(null);
                 if ($user_profile_setting->create($user_id, 1, Registry::get_value("base_timezone_id"), true, true, "jS M Y", "dd.mm.yyyy", 1, "metric", "din", null, null, "comma", "dot", "T F S") == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new UserCreationFailedException("", 1);
                 }
                 if ($can_change_password == true) {
                     $user_admin_setting->set_can_change_password(true);
                 } else {
                     $user_admin_setting->set_can_change_password(false);
                 }
                 if ($must_change_password == true) {
                     $user_admin_setting->set_must_change_password(true);
                 } else {
                     $user_admin_setting->set_must_change_password(false);
                 }
                 if ($disabled == true) {
                     $user_admin_setting->set_user_locked(true);
                 } else {
                     $user_admin_setting->set_user_locked(false);
                 }
                 if ($this->user_profile->create($user_id, $gender, $title, $forename, $surname, $mail) == null) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new UserCreationFailedException("", 1);
                 }
                 self::__construct($user_id);
                 $group = new Group(10);
                 if ($group->create_user_in_group($user_id) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new UserCreationFailedException("", 1);
                 }
                 $user_create_event = new UserCreateEvent($user_id);
                 $event_handler = new EventHandler($user_create_event);
                 if ($event_handler->get_success() == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new UserCreationFailedException("", 1);
                 } else {
                     $transaction->commit($transaction_id);
                 }
                 return $password;
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new UserCreationFailedException("", 1);
             }
         } else {
             throw new UserCreationFailedException("", 1);
         }
     } else {
         throw new UserCreationFailedException("", 1);
     }
 }
Example #16
0
 /**
  * @see RegionalInterface::get_timezone_id()
  * @return integer
  */
 public function get_timezone_id()
 {
     if ($this->user_regional_setting) {
         $timezone_id = $this->user_regional_setting->get_timezone_id();
         if (is_numeric($timezone_id)) {
             return $timezone_id;
         } else {
             return Registry::get_value("base_timezone_id");
         }
     } else {
         return Registry::get_value("base_timezone_id");
     }
 }
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     if ($event_object instanceof UserCreateEvent) {
         $project_user_data_access = new ProjectUserData_Access(null);
         if ($project_user_data_access->create($event_object->get_user_id(), (int) Registry::get_value("project_user_default_quota")) == false) {
             return false;
         }
     }
     if ($event_object instanceof UserDeleteEvent) {
         $project_user_data_access = new ProjectUserData_Access($event_object->get_user_id());
         if ($project_user_data_access->delete() == false) {
             return false;
         }
     }
     return true;
 }