Example #1
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecurityAccessDeniedException
  */
 public static function quota()
 {
     global $project_security;
     if ($_GET['project_id']) {
         if ($project_security->is_access(7, false) == true) {
             $project_id = $_GET['project_id'];
             $project = new Project($project_id);
             if ($_GET['nextpage'] == 1) {
                 if (is_numeric($_POST['quota'])) {
                     $page_1_passed = true;
                 } else {
                     $page_1_passed = false;
                     $error = "You must enter a value";
                 }
             } else {
                 $page_1_passed = false;
                 $error = "";
             }
             if ($page_1_passed == false) {
                 $template = new HTMLTemplate("project/admin/quota.html");
                 $paramquery = $_GET;
                 $paramquery['nextpage'] = "1";
                 $params = http_build_query($paramquery, '', '&');
                 $template->set_var("params", $params);
                 $template->set_var("error", $error);
                 if ($_POST['name']) {
                     $template->set_var("quota", $_POST['quota']);
                 } else {
                     $template->set_var("quota", trim($project->get_quota()));
                 }
                 $template->output();
             } else {
                 $paramquery = $_GET;
                 unset($paramquery['nextpage']);
                 $paramquery['run'] = "admin";
                 $params = http_build_query($paramquery);
                 if ($project->set_quota($_POST['quota'])) {
                     Common_IO::step_proceed($params, "Change Quota", "Operation Successful", null);
                 } else {
                     Common_IO::step_proceed($params, "Change Quota", "Operation Failed", null);
                 }
             }
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
Example #2
0
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     if ($event_object instanceof UserDeletePrecheckEvent) {
         $project_array = self::list_user_related_projects($event_object->get_user_id(), false);
         if (is_array($project_array)) {
             if (count($project_array) >= 1) {
                 return false;
             }
         }
     }
     if ($event_object instanceof OrganisationUnitDeletePrecheckEvent) {
         $project_array = self::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array)) {
             if (count($project_array) >= 1) {
                 return false;
             }
         }
     }
     if ($event_object instanceof FileUploadPrecheckEvent) {
         $folder_id = $event_object->get_folder_id();
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             $project = new Project($project_id);
             $project_quota = $project->get_quota();
             $project_filesize = $project->get_filesize();
             $new_project_filesize = $project_filesize + $event_object->get_filesize();
             if ($project_quota <= $new_project_filesize and $project_quota != 0) {
                 return false;
             }
         }
     }
     if ($event_object instanceof FileUploadEvent) {
         $folder_id = $event_object->get_folder_id();
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             $project = new Project($project_id);
             $new_project_filesize = $project->get_filesize() + $event_object->get_filesize();
             if ($project->set_filesize($new_project_filesize) == false) {
                 return false;
             }
         }
     }
     if ($event_object instanceof FileDeleteEvent) {
         $folder_id = $event_object->get_folder_id();
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             $project = new Project($project_id);
             $new_project_filesize = $project->get_filesize() - $event_object->get_filesize();
             if ($project->set_filesize($new_project_filesize) == false) {
                 return false;
             }
         }
     }
     if ($event_object instanceof FileVersionDeleteEvent) {
         $folder_id = $event_object->get_folder_id();
         if (($project_id = ProjectFolder::get_project_id_by_folder_id($folder_id)) != null) {
             $project = new Project($project_id);
             $new_project_filesize = $project->get_filesize() - $event_object->get_filesize();
             if ($project->set_filesize($new_project_filesize) == false) {
                 return false;
             }
         }
     }
     return true;
 }
Example #3
0
 /**
  * @param string $get_array
  * @return string
  * @throws ProjectSecurityAccessDeniedException
  * @throws ProjectIDMissingException
  */
 public static function get_project_admin_menu($get_array)
 {
     global $user;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['project_id']) {
         $project = new Project($_GET['project_id']);
         $project_security = new ProjectSecurity($_GET['project_id']);
         $project_owner = new User($project->get_owner_id());
         $organisation_unit_id = $project->get_organisation_unit_id();
         $parent_project_id = $project->get_project_toid();
         if ($user->get_user_id() == $project->get_owner_id() or $project_security->is_access(2, false) == true or $project_security->is_access(3, false) == true or $project_security->is_access(4, false) == true or $project_security->is_access(5, false) == true or $project_security->is_access(6, false) == true or $project_security->is_access(7, false) == true) {
             if ($organisation_unit_id) {
                 $organisation_unit = new OrganisationUnit($organisation_unit_id);
                 $parent = $organisation_unit->get_name();
                 $parent_type = "Organisation Unit";
             } else {
                 $parent_project = new Project($parent_project_id);
                 $parent = $parent_project->get_name();
                 $parent_type = "Project";
             }
             $template = new HTMLTemplate("project/ajax/admin/menu.html");
             $template->set_var("name", $project->get_name());
             $template->set_var("owner", $project_owner->get_full_name(false));
             $template->set_var("parent", $parent);
             $template->set_var("parent_type", $parent_type);
             if ($user->is_admin()) {
                 $template->set_var("admin", true);
             } else {
                 $template->set_var("admin", false);
             }
             if ($project_security->is_access(7, false) == true or $project->get_owner_id() == $user->get_user_id()) {
                 $template->set_var("owner_permission", true);
             } else {
                 $template->set_var("owner_permission", false);
             }
             if ($project_security->is_access(6, false) == true) {
                 $template->set_var("delete", true);
             } else {
                 $template->set_var("delete", false);
             }
             if ($project_security->is_access(3, false) == true) {
                 $template->set_var("write", true);
             } else {
                 $template->set_var("write", false);
             }
             if ($project->get_current_status_id() == 0) {
                 $template->set_var("project_canceled", true);
             } else {
                 $template->set_var("project_canceled", false);
             }
             if ($project->get_deleted() == true) {
                 $template->set_var("project_deleted", true);
             } else {
                 $template->set_var("project_deleted", false);
             }
             if ($project->get_quota() == 0) {
                 $template->set_var("quota", "unlimited");
             } else {
                 $template->set_var("quota", Convert::convert_byte_1024($project->get_quota()));
             }
             $permission_paramquery = $_GET;
             $permission_paramquery['run'] = "admin_permission";
             unset($permission_paramquery['nextpage']);
             unset($permission_paramquery['sure']);
             $permission_params = http_build_query($permission_paramquery, '', '&#38;');
             $template->set_var("permission_params", $permission_params);
             $rename_paramquery = $_GET;
             $rename_paramquery['run'] = "admin_rename";
             unset($rename_paramquery['nextpage']);
             unset($rename_paramquery['sure']);
             $rename_params = http_build_query($rename_paramquery, '', '&#38;');
             $template->set_var("rename_params", $rename_params);
             $chown_paramquery = $_GET;
             $chown_paramquery['run'] = "admin_chown";
             unset($chown_paramquery['nextpage']);
             unset($chown_paramquery['sure']);
             $chown_params = http_build_query($chown_paramquery, '', '&#38;');
             $template->set_var("chown_params", $chown_params);
             $move_paramquery = $_GET;
             $move_paramquery['run'] = "admin_move";
             unset($move_paramquery['nextpage']);
             unset($move_paramquery['sure']);
             $move_params = http_build_query($move_paramquery, '', '&#38;');
             $template->set_var("move_params", $move_params);
             $chquota_paramquery = $_GET;
             $chquota_paramquery['run'] = "admin_quota";
             unset($chquota_paramquery['nextpage']);
             unset($chquota_paramquery['sure']);
             $chquota_params = http_build_query($chquota_paramquery, '', '&#38;');
             $template->set_var("chquota_params", $chquota_params);
             return $template->get_string();
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
Example #4
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecuriyAccessDeniedException
  */
 public static function detail()
 {
     global $project_security;
     if ($_GET['project_id']) {
         if ($project_security->is_access(1, false) == true) {
             $project = new Project($_GET['project_id']);
             $project_owner = new User($project->get_owner_id());
             $template = new HTMLTemplate("project/detail.html");
             $template->set_var("get_array", serialize($_GET));
             $template->set_var("title", $project->get_name());
             $template->set_var("owner", $project_owner->get_full_name(false));
             $create_datetime = new DatetimeHandler($project->get_datetime());
             $template->set_var("created_at", $create_datetime->get_datetime());
             $template->set_var("template", $project->get_template_name());
             $template->set_var("permissions", "");
             $template->set_var("size", Convert::convert_byte_1024($project->get_filesize()));
             $template->set_var("quota", Convert::convert_byte_1024($project->get_quota()));
             $owner_paramquery = array();
             $owner_paramquery['username'] = $_GET['username'];
             $owner_paramquery['session_id'] = $_GET['session_id'];
             $owner_paramquery['nav'] = "project";
             $owner_paramquery['run'] = "common_dialog";
             $owner_paramquery['dialog'] = "user_detail";
             $owner_paramquery['id'] = $project->get_owner_id();
             $owner_params = http_build_query($owner_paramquery, '', '&#38;');
             $template->set_var("owner_params", $owner_params);
             $template->output();
         } else {
             throw new ProjectSecurityAccessDeniedxception();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }