array( 'name' => t('Project'), 'module' => 'casetracker_basic_project', 'description' => t('Create a basic project for use with Case Tracker.'), 'help' => t('Create a basic project for use with Case Tracker.'), 'body_label' => t('Description'), ), 'casetracker_basic_case' => array( 'name' => t('Case'), 'module' => 'casetracker_basic_case', 'description' => t('Open a new case assigned to a particular project.'), 'help' => t('Open a new case assigned to a particular project.'), 'body_label' => t('Description'), ), ); } /** * Implementation of hook_form(). */ function casetracker_basic_project_form(&$node) { $form = array(); if (casetracker_is_project($node->type)) { $type = node_get_types('type', $node); $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => !empty($node->title) ? $node->title : NULL, '#weight' => -5); $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count); } return $form; } /** * Implementation of hook_form(). */ function casetracker_basic_case_form(&$node) { $form = array(); if (casetracker_is_case($node->type)) { $type = node_get_types('type', $node); $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => !empty($node->title) ? $node->title : NULL, '#weight' => -5); $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count); } return $form; } /** * Implementation of hook_access(). */ function casetracker_basic_project_access($op, $node, $account) { switch ($op) { case 'create': return user_access('create projects', $account); break; case 'update': case 'delete': if (user_access('edit own projects', $account) && ($account->uid == $node->uid)) { return TRUE; } break; } } /** * Implementation of hook_access(). */ function casetracker_basic_case_access($op, $node) { global $user; switch ($op) { case 'view': // we have to check if the OG module is installed, otherwise this will // overule the OG nodeaccess if (!module_exists('og')) { return user_access('access case tracker'); } // we check if the case isn't created by the current user or is // assigned to the current user, if so that user gets access elseif ( user_access('access case tracker') && 0 < (int)$user->uid && ((int)$node->casetracker->assign_to === (int)$user->uid || (int)$node->uid === (int)$user->uid) ) { return TRUE; } break; case 'create': return user_access('create cases'); case 'update': case 'delete': if (user_access('edit own cases') && ($user->uid == $node->uid)) { return TRUE; } break; } }