Example #1
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecurityAccessDeniedException
  */
 public static function chown()
 {
     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['user'])) {
                     $page_1_passed = true;
                 } else {
                     $page_1_passed = false;
                     $error = "You must select an user";
                 }
             } else {
                 $page_1_passed = false;
                 $error = "";
             }
             if ($page_1_passed == false) {
                 $template = new HTMLTemplate("project/admin/chown.html");
                 $paramquery = $_GET;
                 $paramquery['nextpage'] = "1";
                 $params = http_build_query($paramquery, '', '&');
                 $template->set_var("params", $params);
                 $template->set_var("error", $error);
                 $user_array = User::list_entries();
                 $result = array();
                 $counter = 0;
                 foreach ($user_array as $key => $value) {
                     $user = new User($value);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $user->get_username() . " (" . $user->get_full_name(false) . ")";
                     $counter++;
                 }
                 $template->set_var("option", $result);
                 $template->output();
             } else {
                 $paramquery = $_GET;
                 unset($paramquery['nextpage']);
                 $paramquery['run'] = "admin";
                 $params = http_build_query($paramquery);
                 if ($project->set_owner_id($_POST['user'])) {
                     Common_IO::step_proceed($params, "Change Project Owner", "Operation Successful", null);
                 } else {
                     Common_IO::step_proceed($params, "Change Project Owner", "Operation Failed", null);
                 }
             }
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }