Exemplo n.º 1
0
 /**
  * Method used to update the details of the project information.
  *
  * @return  integer 1 if the update worked, -1 otherwise
  */
 public static function update()
 {
     if (Validation::isWhitespace($_POST['title'])) {
         return -2;
     }
     $stmt = 'UPDATE
                 {{%project}}
              SET
                 prj_title=?,
                 prj_status=?,
                 prj_lead_usr_id=?,
                 prj_initial_sta_id=?,
                 prj_outgoing_sender_name=?,
                 prj_outgoing_sender_email=?,
                 prj_mail_aliases=?,
                 prj_remote_invocation=?,
                 prj_segregate_reporter=?,
                 prj_customer_backend=?,
                 prj_workflow_backend=?
              WHERE
                 prj_id=?';
     try {
         DB_Helper::getInstance()->query($stmt, array($_POST['title'], $_POST['status'], $_POST['lead_usr_id'], $_POST['initial_status'], $_POST['outgoing_sender_name'], $_POST['outgoing_sender_email'], $_POST['mail_aliases'], $_POST['remote_invocation'], $_POST['segregate_reporter'], $_POST['customer_backend'], $_POST['workflow_backend'], $_POST['id']));
     } catch (DbException $e) {
         return -1;
     }
     self::removeUserByProjects(array($_POST['id']), $_POST['users']);
     foreach ($_POST['users'] as $user) {
         if ($user == $_POST['lead_usr_id']) {
             self::associateUser($_POST['id'], $user, User::getRoleID('Manager'));
         } elseif (User::getRoleByUser($user, $_POST['id']) == '') {
             // users who are now being associated with this project should be set to 'Standard User'
             self::associateUser($_POST['id'], $user, User::getRoleID('Standard User'));
         }
     }
     $statuses = array_keys(Status::getAssocStatusList($_POST['id']));
     if (count($statuses) > 0) {
         Status::removeProjectAssociations($statuses, $_POST['id']);
     }
     foreach ($_POST['statuses'] as $sta_id) {
         Status::addProjectAssociation($sta_id, $_POST['id']);
     }
     return 1;
 }
Exemplo n.º 2
0
 /**
  * Method used to update the details of the project information.
  *
  * @access  public
  * @return  integer 1 if the update worked, -1 otherwise
  */
 function update()
 {
     global $HTTP_POST_VARS;
     if (Validation::isWhitespace($HTTP_POST_VARS["title"])) {
         return -2;
     }
     $stmt = "UPDATE\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project\n                 SET\n                    prj_title='" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n                    prj_status='" . Misc::escapeString($HTTP_POST_VARS["status"]) . "',\n                    prj_lead_usr_id=" . Misc::escapeInteger($HTTP_POST_VARS["lead_usr_id"]) . ",\n                    prj_initial_sta_id=" . Misc::escapeInteger($HTTP_POST_VARS["initial_status"]) . ",\n                    prj_outgoing_sender_name='" . Misc::escapeString($HTTP_POST_VARS["outgoing_sender_name"]) . "',\n                    prj_outgoing_sender_email='" . Misc::escapeString($HTTP_POST_VARS["outgoing_sender_email"]) . "',\n                    prj_remote_invocation='" . Misc::escapeString($HTTP_POST_VARS["remote_invocation"]) . "',\n                    prj_segregate_reporter='" . Misc::escapeString($HTTP_POST_VARS["segregate_reporter"]) . "',\n                    prj_customer_backend='" . Misc::escapeString($HTTP_POST_VARS["customer_backend"]) . "',\n                    prj_workflow_backend='" . Misc::escapeString($HTTP_POST_VARS["workflow_backend"]) . "'\n                 WHERE\n                    prj_id=" . Misc::escapeInteger($HTTP_POST_VARS["id"]);
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     } else {
         // START ETEL MODIFIED
         /* This is terrible right here:
                     Project::removeUserByProjects(array($HTTP_POST_VARS["id"]), $HTTP_POST_VARS["users"]);
                     for ($i = 0; $i < count($HTTP_POST_VARS["users"]); $i++) {
                         if ($HTTP_POST_VARS["users"][$i] == $HTTP_POST_VARS["lead_usr_id"]) {
                             Project::associateUser($HTTP_POST_VARS["id"], $HTTP_POST_VARS["users"][$i], User::getRoleID("Manager"));
                         } elseif (User::getRoleByUser($HTTP_POST_VARS["users"][$i], $HTTP_POST_VARS["id"]) == '') {
                             // users who are now being associated with this project should be set to 'Standard User'
                             Project::associateUser($HTTP_POST_VARS["id"], $HTTP_POST_VARS["users"][$i], User::getRoleID("Standard User"));
                         }
                     }
         			*/
         // END ETEL MODIFIED
         $statuses = array_keys(Status::getAssocStatusList($HTTP_POST_VARS["id"]));
         if (count($statuses) > 0) {
             Status::removeProjectAssociations($statuses, $HTTP_POST_VARS["id"]);
         }
         foreach ($HTTP_POST_VARS['statuses'] as $sta_id) {
             Status::addProjectAssociation($sta_id, $HTTP_POST_VARS["id"]);
         }
         return 1;
     }
 }
Exemplo n.º 3
0
 /**
  * Method used to remove a set of custom statuses.
  *
  * @access  public
  * @return  boolean
  */
 function remove()
 {
     global $HTTP_POST_VARS;
     $items = @implode(", ", Misc::escapeInteger($HTTP_POST_VARS["items"]));
     $stmt = "DELETE FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n                 WHERE\n                    sta_id IN ({$items})";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return false;
     } else {
         Status::removeProjectAssociations($HTTP_POST_VARS['items']);
         // also set all issues currently set to these statuses to status '0'
         $stmt = "UPDATE\n                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n                     SET\n                        iss_sta_id=0\n                     WHERE\n                        iss_sta_id IN ({$items})";
         $GLOBALS["db_api"]->dbh->query($stmt);
         return true;
     }
 }