Browse Source

Project: Changed from tripal_project to chado_project -now consistent w/ other tripal modules

Lacey Sanderson 13 years ago
parent
commit
90892714d3

+ 1 - 2
base/tripal_project/tripal_project.admin.inc

@@ -76,12 +76,11 @@ function tripal_project_sync_all_projects () {
     
     // create node
     $new_node = new stdClass();
-    $new_node->type = 'tripal_project';
+    $new_node->type = 'chado_project';
     $new_node->uid = $user->uid;
     $new_node->title = $project[0]->name;
     $new_node->project_id = $project_id;
     $new_node->description = $project[0]->description;
-    $new_node->project_name = $project[0]->name;
     node_validate($new_node);
     $errors = form_get_errors();
     if(!$errors){

+ 44 - 69
base/tripal_project/tripal_project.module

@@ -51,30 +51,6 @@ function tripal_project_menu() {
   return $items;
 }
 
-/**
- *  Implements Hook_help()
- *
- *  This function simply states, in HTML tags, the creator of the the module and the contact	
- *  for the programmer
- *
- *  @parm $path
- *    The absolute path of the module and help information
- *
- *  @parm $arg
- *    The argument
- */
-function tripal_project_help($path, $arg) {
-
-  switch ($path) {
-  
-    case 'admin/help#tripal_project':
-      
-      return '<p>'. t('Module created by:Chad Krilow (e-mail:cnk046@mail.usask.ca)') .'</p>';
-			
-			break;
-  }
-}
-
 /**
  * Implements hook_perm()
  *
@@ -85,8 +61,9 @@ function tripal_project_help($path, $arg) {
 function tripal_project_perm() {
 
   return array(
-    'create tripal_project', 
-    'edit own tripal_project'
+    'access chado_projects',
+    'create chado_projects', 
+    'edit own chado_projects'
   );
 }
 
@@ -108,12 +85,12 @@ function tripal_project_perm() {
  *    True if a operation was performed
  *
  */
-function tripal_project_access($op, $node, $account) {
+function chado_project_access($op, $node, $account) {
 
   if ($op == 'create') {
   
     // Only users with permission to do so may create this node type.
-    if(!user_access('create tripal_project', $account)){
+    if(!user_access('create chado_projects', $account)){
       return FALSE;
     }
   }
@@ -121,14 +98,20 @@ function tripal_project_access($op, $node, $account) {
   // Users who create a node may edit or delete it later, assuming they have the necessary permissions.
   if ($op == 'update' || $op == 'delete') {
   
-    if(!user_access('edit own tripal_project',$account)){
+    if(!user_access('edit own chado_projects',$account)){
        return FALSE;
     }
-    if(user_access('edit own tripal_project',$account) &&
+    if(user_access('edit own chado_projects',$account) &&
        $account->uid != $node->uid){
       return FALSE;
     }
   }
+  
+  if ($op == 'view') {
+    if(!user_access('access chado_projects', $account)){
+      return FALSE;
+    }  
+  }
   return NULL;
 }
 
@@ -146,14 +129,14 @@ function tripal_project_access($op, $node, $account) {
 */
 function tripal_project_node_info() {
   return array(
-    'tripal_project' => array(
+    'chado_project' => array(
       'name' => t('Project'),
-      'module' => 'tripal_project',
+      'module' => 'chado_project',
       'description' => t('A module for interfacing the GMOD chado database with Drupal, providing viewing of projects'),
     	'has_title' => TRUE,
     	'title_label' =>t('Project Name'),
     	'had_body' => TRUE,
-    	'body_label' =>t('Description'),
+    	'body_label' =>t('Full Description'),
     )
   );
 }
@@ -161,22 +144,21 @@ function tripal_project_node_info() {
 /**
 * Implementation of hook_form().
 *
-*  This form takes the Project Title infromation and the Project description from the user. It 
-*  then puts the infromation into the Chado_project database table.
+*  This form takes the Project Title information and description from the user.
 *
 *  @parm &$node
-*    The node that is created when the database is initialized
+*    The initialized node
 *
 *  @parm $form_state
-*    The state of the form, that has the user entered information that is neccessary for, setting
-*    up the database of the project
+*    The state of the form, that has the user entered information that is neccessary for adding 
+*    information to the project
 *
 *  @return $form
-*    The information that was enterd allong with   
+*    An array as described by the Drupal Form API
 *
 */
-function tripal_project_form(&$node, $form_state) {
-  
+function chado_project_form(&$node, $form_state) {
+
   $type = node_get_types('type', $node);
 
   $form['title'] = array(
@@ -187,16 +169,11 @@ function tripal_project_form(&$node, $form_state) {
     '#weight' => -5
   );
 
-  $form['project_name'] = array(
-    '#type' => 'textfield',
-    '#maxlength' => 255,
-    '#title' => 'Project Name',
-  );
-
   $form['description'] = array(
     '#type' => 'textfield',
     '#maxlength' => 255,
     '#title' => 'Short Description',
+    '#default_value' => $node->project->description,
   ); 
   
   $form['body_filter']['body'] = array(
@@ -209,7 +186,7 @@ function tripal_project_form(&$node, $form_state) {
   // whether or not the project exists in chado
   $form['project_id'] = array(
     '#type' => 'value',
-    '#value' => FALSE,
+    '#value' => ($node->project->project_id) ? $node->project->project_id : FALSE,
   );
 
   return $form;
@@ -219,14 +196,14 @@ function tripal_project_form(&$node, $form_state) {
 * Implementation of hook_insert()
 *
 *  @parm $node
-*    Then node that has the information stored within, accessed given the node-Id
+*    Then node that has the information stored within, accessed given the nid
 *
 */
-function tripal_project_insert($node) {
+function chado_project_insert($node) {
 		
 	$values =  array(
      'name' => $node->title,
-     'description' => $node->body,
+     'description' => $node->description,
    );
    
    if (!$node->project_id) {
@@ -245,18 +222,17 @@ function tripal_project_insert($node) {
 * Implementation of hook_delete().
 *
 * @param $node
-* The node which is to be deleted, automagically by Drupal Black Box
+* The node which is to be deleted, only chado project and chado_project need to be dealt with 
+* since the drupal node is deleted automagically
 *
 */
-function tripal_project_delete($node) {
+function chado_project_delete($node) {
   // Notice that we're matching all revision, by using the node's nid.
   
+  // Find the project to delete
   $values =  array(
-     'name' => $node->title,
-     'description' => $node->body,
+     'project_id' => $node->project->project_id,
    );
-  
-  //deleting row in chado table
   tripal_core_chado_delete('project',$values);
   
   //deleteing in drupal chado_project table
@@ -268,39 +244,38 @@ function tripal_project_delete($node) {
 * Implements hook_update()
 *
 * @param $node
-*  The node which is to have its containing information updated when the user modifys information
+*  The node which is to have its containing information updated when the user modifies information
 *  pertaining to the specific project
 *
 */
-function tripal_project_update($node){
-	
-	$result = db_fetch_object(db_query('SELECT * FROM {chado_project} WHERE nid=%d AND vid=%d',$node->nid, $node->vid));
+function chado_project_update($node){
 	
+	// Find the project to update
 	$match= array(
-		'project_id'=>$result->project_id,
+		'project_id'=>$node->project_id,
 	);
 	
+	// New values
 	$values =  array(
     'name' => $node->title,
-    'description' => $node->body,
+    'description' => $node->description,
   );
-   
-  //selects:$table, $match, $value when updating 
+
   $result = tripal_core_chado_update('project',$match,$values);
 
 }
 
 /**
-* Implementation of tripal_project_load().
+* Implementation of node_load().
 *
 * @param $node
-*   The node that is to have its containing infromation loaded
+*   The node that is to have its containing information loaded
 *
 * @return $node
-*   The node, containing the loaded project with the current node-Id
+*   The node, containing the loaded project with the current nid
 *
 */
-function tripal_project_load($node) {
+function chado_project_load($node) {
 
 	//selecting the coresponding table information
 	$result = db_fetch_object(db_query('SELECT * FROM {chado_project} WHERE nid=%d AND vid=%d',$node->nid, $node->vid));