Loading includes/issue_node_add.inc +9 −3 Original line number Diff line number Diff line Loading @@ -60,9 +60,15 @@ function project_issue_pick_project_form($form, &$form_state, $node_type) { $form_state['node_type'] = $node_type; if (variable_get('project_selection_widget', 'select') == 'select') { // Fetch a list of all projects. $machine_names = array(); $projects = project_projects_select_options($machine_names); // Fetch a list of all projects with issue tracking enabled. $conditions = array( array( 'field' => 'field_project_has_issue_queue', 'column' => 'value', 'value' => 1, ), ); $projects = project_projects_select_options($conditions); if (empty($projects)) { drupal_set_message(t('You do not have access to any projects.'), 'error'); } Loading project_issue.module +35 −2 Original line number Diff line number Diff line Loading @@ -366,6 +366,26 @@ function project_issue_node_presave(stdClass $node) { } } /** * Checks whether a project has issue tracker enabled. * * @param int|object $project * Nid of the project or project object. * * @return bool|null * True or false if the nid given is a project, null otherwise. */ function _project_is_issue_tracker_enabled($project) { $project = is_numeric($project) ? node_load($project) : $project; if (project_node_is_project($project)) { return !empty($project->field_project_has_issue_queue) ? (bool) $project->field_project_has_issue_queue[LANGUAGE_NONE][0]['value'] : FALSE; } return NULL; } /** * Implements hook_form_BASE_FORM_ID_alter() for node_form(). * Loading Loading @@ -418,6 +438,10 @@ function project_issue_form_node_form_alter(&$form, &$form_state, $form_id) { if (!empty($form_state['node']->field_project[LANGUAGE_NONE][0]['target_id'])) { $project = node_load($form_state['node']->field_project[LANGUAGE_NONE][0]['target_id']); if (_project_is_issue_tracker_enabled($project) === FALSE) { drupal_set_message(t('Issues are not enabled for this project. You will not be able to submit this form.'), 'error'); } project_issue_set_breadcrumb($form_state['node'], $project); // Include the project_specific new issue help text on the create form. if (empty($form['#node']->nid)) { Loading Loading @@ -480,7 +504,11 @@ function project_issue_field_project_components_validate($element, &$form_state) function project_issue_field_project_validate($element, &$form_state) { // Always update the node entity saved in form_state in order to allow other // fields to be populated with correct values (e.g. 'field_issue_assigned'). $form_state['node']->field_project[LANGUAGE_NONE][0]['target_id'] = $form_state['values']['field_project'][LANGUAGE_NONE][0]['target_id']; $project_nid = $form_state['values']['field_project'][LANGUAGE_NONE][0]['target_id']; $form_state['node']->field_project[LANGUAGE_NONE][0]['target_id'] = $project_nid; if (_project_is_issue_tracker_enabled($project_nid) === FALSE) { form_set_error('field_project', t('Issues are not enabled for this project.')); } } /** Loading Loading @@ -1465,7 +1493,12 @@ function project_issue_query_result_links($project_arg = NULL) { $project = project_load($project_arg); $machine_name = $project->field_project_machine_name[LANGUAGE_NONE][0]['value']; if (_project_is_issue_tracker_enabled($project)) { $links['create'] = project_issue_get_create_link($project); } else { drupal_set_message(t('Issues are not enabled for this project.'), 'error'); } if (!$is_adv_search) { $links['search'] = [ 'title' => t('Advanced search'), Loading views/handlers/project_issue_handler_area_issue_create_child.inc +4 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,10 @@ class project_issue_handler_area_issue_create_child extends views_handler_area { // argument. $parent_nid = $this->view->argument['nid']->get_value(); if ($parent_project = node_load(node_load($parent_nid)->field_project[LANGUAGE_NONE][0]['target_id'])) { if ( ($parent_project = node_load(node_load($parent_nid)->field_project[LANGUAGE_NONE][0]['target_id'])) && (_project_is_issue_tracker_enabled($parent_project)) ) { return l( t('Add child issue'), 'node/add/project-issue/' . $parent_project->field_project_machine_name[LANGUAGE_NONE][0]['value'], Loading Loading
includes/issue_node_add.inc +9 −3 Original line number Diff line number Diff line Loading @@ -60,9 +60,15 @@ function project_issue_pick_project_form($form, &$form_state, $node_type) { $form_state['node_type'] = $node_type; if (variable_get('project_selection_widget', 'select') == 'select') { // Fetch a list of all projects. $machine_names = array(); $projects = project_projects_select_options($machine_names); // Fetch a list of all projects with issue tracking enabled. $conditions = array( array( 'field' => 'field_project_has_issue_queue', 'column' => 'value', 'value' => 1, ), ); $projects = project_projects_select_options($conditions); if (empty($projects)) { drupal_set_message(t('You do not have access to any projects.'), 'error'); } Loading
project_issue.module +35 −2 Original line number Diff line number Diff line Loading @@ -366,6 +366,26 @@ function project_issue_node_presave(stdClass $node) { } } /** * Checks whether a project has issue tracker enabled. * * @param int|object $project * Nid of the project or project object. * * @return bool|null * True or false if the nid given is a project, null otherwise. */ function _project_is_issue_tracker_enabled($project) { $project = is_numeric($project) ? node_load($project) : $project; if (project_node_is_project($project)) { return !empty($project->field_project_has_issue_queue) ? (bool) $project->field_project_has_issue_queue[LANGUAGE_NONE][0]['value'] : FALSE; } return NULL; } /** * Implements hook_form_BASE_FORM_ID_alter() for node_form(). * Loading Loading @@ -418,6 +438,10 @@ function project_issue_form_node_form_alter(&$form, &$form_state, $form_id) { if (!empty($form_state['node']->field_project[LANGUAGE_NONE][0]['target_id'])) { $project = node_load($form_state['node']->field_project[LANGUAGE_NONE][0]['target_id']); if (_project_is_issue_tracker_enabled($project) === FALSE) { drupal_set_message(t('Issues are not enabled for this project. You will not be able to submit this form.'), 'error'); } project_issue_set_breadcrumb($form_state['node'], $project); // Include the project_specific new issue help text on the create form. if (empty($form['#node']->nid)) { Loading Loading @@ -480,7 +504,11 @@ function project_issue_field_project_components_validate($element, &$form_state) function project_issue_field_project_validate($element, &$form_state) { // Always update the node entity saved in form_state in order to allow other // fields to be populated with correct values (e.g. 'field_issue_assigned'). $form_state['node']->field_project[LANGUAGE_NONE][0]['target_id'] = $form_state['values']['field_project'][LANGUAGE_NONE][0]['target_id']; $project_nid = $form_state['values']['field_project'][LANGUAGE_NONE][0]['target_id']; $form_state['node']->field_project[LANGUAGE_NONE][0]['target_id'] = $project_nid; if (_project_is_issue_tracker_enabled($project_nid) === FALSE) { form_set_error('field_project', t('Issues are not enabled for this project.')); } } /** Loading Loading @@ -1465,7 +1493,12 @@ function project_issue_query_result_links($project_arg = NULL) { $project = project_load($project_arg); $machine_name = $project->field_project_machine_name[LANGUAGE_NONE][0]['value']; if (_project_is_issue_tracker_enabled($project)) { $links['create'] = project_issue_get_create_link($project); } else { drupal_set_message(t('Issues are not enabled for this project.'), 'error'); } if (!$is_adv_search) { $links['search'] = [ 'title' => t('Advanced search'), Loading
views/handlers/project_issue_handler_area_issue_create_child.inc +4 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,10 @@ class project_issue_handler_area_issue_create_child extends views_handler_area { // argument. $parent_nid = $this->view->argument['nid']->get_value(); if ($parent_project = node_load(node_load($parent_nid)->field_project[LANGUAGE_NONE][0]['target_id'])) { if ( ($parent_project = node_load(node_load($parent_nid)->field_project[LANGUAGE_NONE][0]['target_id'])) && (_project_is_issue_tracker_enabled($parent_project)) ) { return l( t('Add child issue'), 'node/add/project-issue/' . $parent_project->field_project_machine_name[LANGUAGE_NONE][0]['value'], Loading