/** * Method used to add a new project to the system. * * @return integer 1 if the update worked, -1 or -2 otherwise */ public static function insert() { if (Validation::isWhitespace($_POST['title'])) { return -2; } $stmt = 'INSERT INTO {{%project}} ( prj_created_date, 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_customer_backend, prj_workflow_backend ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )'; try { DB_Helper::getInstance()->query($stmt, array(Date_Helper::getCurrentDateGMT(), $_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['customer_backend'], $_POST['workflow_backend'])); } catch (DbException $e) { return -1; } $new_prj_id = DB_Helper::get_last_insert_id(); foreach ($_POST['users'] as $user) { if ($user == $_POST['lead_usr_id']) { $role_id = User::getRoleID('Manager'); } else { $role_id = User::getRoleID('Standard User'); } self::associateUser($new_prj_id, $user, $role_id); } foreach ($_POST['statuses'] as $sta_id) { Status::addProjectAssociation($sta_id, $new_prj_id); } Display_Column::setupNewProject($new_prj_id); // insert default timetracking categories Time_Tracking::addProjectDefaults($new_prj_id); return 1; }
/** * Method used to add a new project to the system. * * @access public * @return integer 1 if the update worked, -1 or -2 otherwise */ function insert() { global $HTTP_POST_VARS; if (Validation::isWhitespace($HTTP_POST_VARS["title"])) { return -2; } $stmt = "INSERT INTO\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project\n (\n prj_created_date,\n prj_title,\n prj_status,\n prj_lead_usr_id,\n prj_initial_sta_id,\n prj_outgoing_sender_name,\n prj_outgoing_sender_email,\n prj_remote_invocation,\n prj_customer_backend,\n prj_workflow_backend\n ) VALUES (\n '" . Date_API::getCurrentDateGMT() . "',\n '" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n '" . Misc::escapeString($HTTP_POST_VARS["status"]) . "',\n " . Misc::escapeInteger($HTTP_POST_VARS["lead_usr_id"]) . ",\n " . Misc::escapeInteger($HTTP_POST_VARS["initial_status"]) . ",\n '" . Misc::escapeString($HTTP_POST_VARS["outgoing_sender_name"]) . "',\n '" . Misc::escapeString($HTTP_POST_VARS["outgoing_sender_email"]) . "',\n '" . Misc::escapeString($HTTP_POST_VARS["remote_invocation"]) . "',\n '" . Misc::escapeString($HTTP_POST_VARS["customer_backend"]) . "',\n '" . Misc::escapeString($HTTP_POST_VARS["workflow_backend"]) . "'\n )"; $res = $GLOBALS["db_api"]->dbh->query($stmt); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return -1; } else { $new_prj_id = $GLOBALS["db_api"]->get_last_insert_id(); for ($i = 0; $i < count($HTTP_POST_VARS["users"]); $i++) { if ($HTTP_POST_VARS["users"][$i] == $HTTP_POST_VARS["lead_usr_id"]) { $role_id = User::getRoleID("Manager"); } else { $role_id = User::getRoleID("Standard User"); } Project::associateUser($new_prj_id, $HTTP_POST_VARS["users"][$i], $role_id); } foreach ($HTTP_POST_VARS['statuses'] as $sta_id) { Status::addProjectAssociation($sta_id, $new_prj_id); } Display_Column::setupNewProject($new_prj_id); return 1; } }
<?php // create database entries for all projects in the columns_to_display table // so all projects have fields that show up on the list issue page. include_once "../../../config.inc.php"; include_once APP_INC_PATH . "class.display_column.php"; include_once APP_INC_PATH . "class.project.php"; include_once APP_INC_PATH . "db_access.php"; $projects = Project::getAll(); foreach ($projects as $prj_id => $prj_title) { echo "Setting Display columns for {$prj_title}<br />"; Display_Column::setupNewProject($prj_id); } ?> Done. You can now control which columns are displayed on the list issues page through the administration page.