|
@@ -1,5 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
+require('tripal_project.admin.inc');
|
|
|
+
|
|
|
/**
|
|
|
* @file
|
|
|
* This file contains the basic functions needed for this drupal module.
|
|
@@ -28,74 +30,27 @@ function tripal_project_views_api() {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-/**
|
|
|
-* Implementation of hook_node_info()
|
|
|
-*
|
|
|
-* This node_info, is a simple node that describes the functionallity of the module. It specifies
|
|
|
-* that the title(Project Name) and body(Description) set to true so that they information can be
|
|
|
-* entered
|
|
|
-*
|
|
|
-*/
|
|
|
-function tripal_project_node_info() {
|
|
|
- return array(
|
|
|
- 'tripal_project' => array(
|
|
|
- 'name' => t('Project'),
|
|
|
- 'module' => 'tripal_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'),
|
|
|
- )
|
|
|
- );
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
-* 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.
|
|
|
-*
|
|
|
-* @parm &$node
|
|
|
-* The node that is created when the database is initialized
|
|
|
-*
|
|
|
-* @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
|
|
|
-*
|
|
|
-* @return $form
|
|
|
-* The information that was enterd allong with
|
|
|
-*
|
|
|
-*/
|
|
|
-function tripal_project_form(&$node, $form_state) {
|
|
|
-
|
|
|
- $type = node_get_types('type', $node);
|
|
|
-
|
|
|
- //define form elements for the node's title and body.
|
|
|
- $form['title'] = array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => check_plain($type->title_label),
|
|
|
- '#required' => TRUE,
|
|
|
- '#default_value' => $node->title,
|
|
|
- '#weight' => -5
|
|
|
- );
|
|
|
-
|
|
|
- // Putting body and filter elements to be adjacent them into a sub-array together
|
|
|
- $form['body_filter']['body'] = array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#title' => check_plain($type->body_label),
|
|
|
- '#default_value' => $node->body,
|
|
|
- '#required' => FALSE
|
|
|
- );
|
|
|
+ * Implements hook_menu
|
|
|
+ */
|
|
|
+function tripal_project_menu() {
|
|
|
+ $items[ 'admin/tripal/tripal_project' ]= array(
|
|
|
+ 'title' => t('Projects'),
|
|
|
+ 'page callback' => 'tripal_project_administration_description_page',
|
|
|
+ 'access arguments' => array('administer site configuration'),
|
|
|
+ 'type' => MENU_NORMAL_ITEM
|
|
|
+ );
|
|
|
+
|
|
|
+ $items[ 'admin/tripal/tripal_project/configuration' ]= array(
|
|
|
+ 'title' => t('Configuration'),
|
|
|
+ 'page callback' => 'tripal_project_configuration_page',
|
|
|
+ 'access arguments' => array('administer site configuration'),
|
|
|
+ 'type' => MENU_NORMAL_ITEM
|
|
|
+ );
|
|
|
|
|
|
- $form['body_filter']['filter'] = filter_form($node->format);
|
|
|
-
|
|
|
- return $form;
|
|
|
+ return $items;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Implements Hook_help()
|
|
|
*
|
|
@@ -120,7 +75,6 @@ function tripal_project_help($path, $arg) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Implements hook_perm()
|
|
|
*
|
|
@@ -136,7 +90,6 @@ function tripal_project_perm() {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Implements hook_access()
|
|
|
*
|
|
@@ -168,7 +121,7 @@ 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 tripal_project',$account)){
|
|
|
return FALSE;
|
|
|
}
|
|
|
if(user_access('edit own tripal_project',$account) &&
|
|
@@ -179,6 +132,80 @@ function tripal_project_access($op, $node, $account) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// SECTION: Node Functionality
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
+/**
|
|
|
+* Implementation of hook_node_info()
|
|
|
+*
|
|
|
+* This node_info, is a simple node that describes the functionallity of the module. It specifies
|
|
|
+* that the title(Project Name) and body(Description) set to true so that they information can be
|
|
|
+* entered
|
|
|
+*
|
|
|
+*/
|
|
|
+function tripal_project_node_info() {
|
|
|
+ return array(
|
|
|
+ 'tripal_project' => array(
|
|
|
+ 'name' => t('Project'),
|
|
|
+ 'module' => 'tripal_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'),
|
|
|
+ )
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+* 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.
|
|
|
+*
|
|
|
+* @parm &$node
|
|
|
+* The node that is created when the database is initialized
|
|
|
+*
|
|
|
+* @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
|
|
|
+*
|
|
|
+* @return $form
|
|
|
+* The information that was enterd allong with
|
|
|
+*
|
|
|
+*/
|
|
|
+function tripal_project_form(&$node, $form_state) {
|
|
|
+
|
|
|
+ $type = node_get_types('type', $node);
|
|
|
+
|
|
|
+ //define form elements for the node's title and body.
|
|
|
+ $form['title'] = array(
|
|
|
+ '#type' => 'textfield',
|
|
|
+ '#title' => check_plain($type->title_label),
|
|
|
+ '#required' => TRUE,
|
|
|
+ '#default_value' => $node->title,
|
|
|
+ '#weight' => -5
|
|
|
+ );
|
|
|
+
|
|
|
+ // Putting body and filter elements to be adjacent them into a sub-array together
|
|
|
+ $form['body_filter']['body'] = array(
|
|
|
+ '#type' => 'textarea',
|
|
|
+ '#title' => check_plain($type->body_label),
|
|
|
+ '#default_value' => $node->body,
|
|
|
+ '#required' => FALSE
|
|
|
+ );
|
|
|
+
|
|
|
+ $form['body_filter']['filter'] = filter_form($node->format);
|
|
|
+
|
|
|
+ // whether or not the project exists in chado
|
|
|
+ $form['project_id'] = array(
|
|
|
+ '#type' => 'value',
|
|
|
+ '#value' => FALSE,
|
|
|
+ );
|
|
|
+
|
|
|
+ return $form;
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* Implementation of hook_insert()
|
|
@@ -194,15 +221,17 @@ function tripal_project_insert($node) {
|
|
|
'description' => $node->body,
|
|
|
);
|
|
|
|
|
|
- //inserts info into chado table.
|
|
|
- $result = tripal_core_chado_insert('project',$values);
|
|
|
-
|
|
|
+ if (!$node->project_id) {
|
|
|
+ //inserts info into chado table.
|
|
|
+ $result = tripal_core_chado_insert('project',$values);
|
|
|
+ $node->project_id = $result['project_id'];
|
|
|
+ }
|
|
|
+
|
|
|
//inserts the row of vid,nid,project_id into the chado_project table
|
|
|
- db_query("INSERT INTO {chado_project} (vid, nid, project_id) VALUES (%d, %d, %d)", $node->vid, $node->nid, $result['project_id']);
|
|
|
+ db_query("INSERT INTO {chado_project} (vid, nid, project_id) VALUES (%d, %d, %d)", $node->vid, $node->nid, $node->project_id);
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* Implementation of hook_delete().
|
|
@@ -227,7 +256,6 @@ function tripal_project_delete($node) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Implements hook_update()
|
|
|
*
|
|
@@ -254,7 +282,6 @@ function tripal_project_update($node){
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Implementation of tripal_project_load().
|
|
|
*
|