function ensure_project_exists($p_name, $p_description) { $t_project_id = project_get_id_by_name($p_name); if ($t_project_id !== false) { return $t_project_id; } return project_create('MantisBT', 'Mantis Bug Tracker', 50); }
/** * Add a new project. * * @param string $p_username The name of the user trying to access the versions. * @param string $p_password The password of the user. * @param Array $p_project A new ProjectData structure * @return integer the new project's project_id */ function mc_project_add($p_username, $p_password, $p_project) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!mci_has_administrator_access($t_user_id)) { return mci_soap_fault_access_denied($t_user_id); } if (!isset($p_project['name'])) { return new soap_fault('Client', '', 'Missing Field', 'Required Field Missing'); } else { $t_name = $p_project['name']; } if (isset($p_project['status'])) { $t_status = $p_project['status']; } else { $t_status = array('name' => 'development'); // development } if (isset($p_project['view_state'])) { $t_view_state = $p_project['view_state']; } else { $t_view_state = array('id' => VS_PUBLIC); } if (isset($p_project['enabled'])) { $t_enabled = $p_project['enabled']; } else { $t_enabled = true; } if (isset($p_project['description'])) { $t_description = $p_project['description']; } else { $t_description = ''; } if (isset($p_project['file_path'])) { $t_file_path = $p_project['file_path']; } else { $t_file_path = ''; } if (isset($p_project['inherit_global'])) { $t_inherit_global = $p_project['inherit_global']; } else { $t_inherit_global = true; } // check to make sure project doesn't already exist if (!project_is_name_unique($t_name)) { return new soap_fault('Client', '', 'Project name exists', 'The project name you attempted to add exists already'); } $t_project_status = mci_get_project_status_id($t_status); $t_project_view_state = mci_get_project_view_state_id($t_view_state); // project_create returns the new project's id, spit that out to webservice caller return project_create($t_name, $t_description, $t_project_status, $t_project_view_state, $t_file_path, $t_enabled, $t_inherit_global); }
/** * Add a new project. * * @param string $p_username The name of the user trying to access the versions. * @param string $p_password The password of the user. * @param Array $p_project A new ProjectData structure * @return integer the new project's project_id */ function mc_project_add($p_username, $p_password, $p_project) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return new soap_fault('Client', '', 'Access Denied', 'Username/password combination was incorrect'); } if (!mci_has_administrator_access($t_user_id)) { return new soap_fault('Client', '', 'Access Denied', 'User does not have administrator access'); } extract($p_project, EXTR_PREFIX_ALL, 'v'); /* if ( is_blank($v_name) ) return new soap_fault('Client', '', 'Mandatory field "name" was missing'); */ // check to make sure project doesn't already exist if (!project_is_name_unique($v_name)) { return new soap_fault('Client', '', 'Project name exists', 'The project name you attempted to add exists already'); } if (is_null($v_status)) { $v_status = array('name' => 'development'); // development } if (is_null($v_view_state)) { $v_view_state = array('id' => VS_PUBLIC); } if (is_null($v_enabled)) { $v_enabled = true; } $t_project_status = mci_get_project_status_id($v_status); $t_project_view_state = mci_get_project_view_state_id($v_view_state); // project_create returns the new project's id, spit that out to webservice caller return project_create($v_name, $v_description, $t_project_status, $t_project_view_state, $v_file_path, $v_enabled); }
require_api('project_api.php'); require_api('project_hierarchy_api.php'); form_security_validate('manage_proj_create'); auth_reauthenticate(); access_ensure_global_level(config_get('create_project_threshold')); $f_name = gpc_get_string('name'); $f_description = gpc_get_string('description'); $f_view_state = gpc_get_int('view_state'); $f_status = gpc_get_int('status'); $f_file_path = gpc_get_string('file_path', ''); $f_inherit_global = gpc_get_bool('inherit_global', 0); $f_inherit_parent = gpc_get_bool('inherit_parent', 0); $f_parent_id = gpc_get_int('parent_id', 0); if (0 != $f_parent_id) { project_ensure_exists($f_parent_id); } $t_project_id = project_create(strip_tags($f_name), $f_description, $f_status, $f_view_state, $f_file_path, true, $f_inherit_global); if ($f_view_state == VS_PRIVATE && false === current_user_is_administrator()) { $t_access_level = access_get_global_level(); $t_current_user_id = auth_get_current_user_id(); project_add_user($t_project_id, $t_current_user_id, $t_access_level); } if (0 != $f_parent_id) { project_hierarchy_add($t_project_id, $f_parent_id, $f_inherit_parent); } event_signal('EVENT_MANAGE_PROJECT_CREATE', array($t_project_id)); form_security_purge('manage_proj_create'); $t_redirect_url = 'manage_proj_page.php'; html_page_top(null, $t_redirect_url); html_operation_successful($t_redirect_url); html_page_bottom();
# along with Mantis. If not, see <http://www.gnu.org/licenses/>. # -------------------------------------------------------- # $Id: manage_proj_create.php,v 1.10.2.1 2007-10-13 22:33:33 giallu Exp $ # -------------------------------------------------------- require_once 'core.php'; $t_core_path = config_get('core_path'); require_once $t_core_path . 'project_hierarchy_api.php'; form_security_validate('manage_proj_create'); auth_reauthenticate(); access_ensure_global_level(config_get('create_project_threshold')); $f_name = gpc_get_string('name'); $f_description = gpc_get_string('description'); $f_view_state = gpc_get_int('view_state'); $f_status = gpc_get_int('status'); $f_file_path = gpc_get_string('file_path', ''); $t_project_id = project_create(strip_tags($f_name), $f_description, $f_status, $f_view_state, $f_file_path); if ($f_view_state == VS_PRIVATE && false === current_user_is_administrator()) { $t_access_level = access_get_global_level(); $t_current_user_id = auth_get_current_user_id(); project_add_user($t_project_id, $t_current_user_id, $t_access_level); } $f_parent_id = gpc_get_int('parent_id', 0); if (0 != $f_parent_id) { project_hierarchy_add($t_project_id, $f_parent_id); } form_security_purge('manage_proj_create'); $t_redirect_url = 'manage_proj_page.php'; html_page_top1(); html_meta_redirect($t_redirect_url); html_page_top2(); ?>