|
@@ -5,9 +5,9 @@ require('tripal_project.admin.inc');
|
|
|
/**
|
|
|
* @file
|
|
|
* This file contains the basic functions needed for this drupal module.
|
|
|
- * The drupal tripal_project module maps directly to the chado general module.
|
|
|
+ * The drupal tripal_project module maps directly to the chado general module.
|
|
|
*
|
|
|
- * For documentation regarding the Chado General module:
|
|
|
+ * For documentation regarding the Chado General module:
|
|
|
* @see http://gmod.org/wiki/Chado_General_Module
|
|
|
*/
|
|
|
|
|
@@ -23,7 +23,7 @@ require('tripal_project.admin.inc');
|
|
|
* for this module which then includes tripal_project.views.inc where all the
|
|
|
* views integration code is
|
|
|
*
|
|
|
- */
|
|
|
+ */
|
|
|
function tripal_project_views_api() {
|
|
|
return array(
|
|
|
'api' => 2.0,
|
|
@@ -39,15 +39,15 @@ function tripal_project_menu() {
|
|
|
'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
|
|
|
- );
|
|
|
-
|
|
|
+ );
|
|
|
+
|
|
|
return $items;
|
|
|
}
|
|
|
|
|
@@ -62,7 +62,7 @@ function tripal_project_perm() {
|
|
|
|
|
|
return array(
|
|
|
'access chado_projects',
|
|
|
- 'create chado_projects',
|
|
|
+ 'create chado_projects',
|
|
|
'edit own chado_projects'
|
|
|
);
|
|
|
}
|
|
@@ -76,10 +76,10 @@ function tripal_project_perm() {
|
|
|
* The operation that is to be performed
|
|
|
*
|
|
|
* @parm $node
|
|
|
- * The specific node that is to have the operation performed
|
|
|
+ * The specific node that is to have the operation performed
|
|
|
*
|
|
|
* @parm $account
|
|
|
- * The account of the user that is performing the operations
|
|
|
+ * The account of the user that is performing the operations
|
|
|
*
|
|
|
* @return
|
|
|
* True if a operation was performed
|
|
@@ -88,29 +88,29 @@ function tripal_project_perm() {
|
|
|
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 chado_projects', $account)){
|
|
|
+ if (!user_access('create chado_projects', $account)) {
|
|
|
return FALSE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 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 chado_projects',$account)){
|
|
|
+
|
|
|
+ if (!user_access('edit own chado_projects', $account)) {
|
|
|
return FALSE;
|
|
|
}
|
|
|
- if(user_access('edit own chado_projects',$account) &&
|
|
|
- $account->uid != $node->uid){
|
|
|
+ if (user_access('edit own chado_projects', $account) &&
|
|
|
+ $account->uid != $node->uid) {
|
|
|
return FALSE;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ($op == 'view') {
|
|
|
- if(!user_access('access chado_projects', $account)){
|
|
|
+ if (!user_access('access chado_projects', $account)) {
|
|
|
return FALSE;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
return NULL;
|
|
|
}
|
|
@@ -133,10 +133,10 @@ function tripal_project_node_info() {
|
|
|
'name' => t('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('Full Description'),
|
|
|
+ 'has_title' => TRUE,
|
|
|
+ 'title_label' => t('Project Name'),
|
|
|
+ 'had_body' => TRUE,
|
|
|
+ 'body_label' => t('Full Description'),
|
|
|
)
|
|
|
);
|
|
|
}
|
|
@@ -150,7 +150,7 @@ function tripal_project_node_info() {
|
|
|
* The initialized node
|
|
|
*
|
|
|
* @parm $form_state
|
|
|
-* The state of the form, that has the user entered information that is neccessary for adding
|
|
|
+* The state of the form, that has the user entered information that is neccessary for adding
|
|
|
* information to the project
|
|
|
*
|
|
|
* @return $form
|
|
@@ -174,15 +174,15 @@ function chado_project_form(&$node, $form_state) {
|
|
|
'#maxlength' => 255,
|
|
|
'#title' => 'Short Description',
|
|
|
'#default_value' => $node->project->description,
|
|
|
- );
|
|
|
-
|
|
|
+ );
|
|
|
+
|
|
|
$form['body_filter']['body'] = array(
|
|
|
'#type' => 'textarea',
|
|
|
'#title' => check_plain($type->body_label),
|
|
|
'#default_value' => $node->body,
|
|
|
);
|
|
|
$form['body_filter']['filter'] = filter_form($node->format);
|
|
|
-
|
|
|
+
|
|
|
// whether or not the project exists in chado
|
|
|
$form['project_id'] = array(
|
|
|
'#type' => 'value',
|
|
@@ -200,21 +200,21 @@ function chado_project_form(&$node, $form_state) {
|
|
|
*
|
|
|
*/
|
|
|
function chado_project_insert($node) {
|
|
|
-
|
|
|
- $values = array(
|
|
|
+
|
|
|
+ $values = array(
|
|
|
'name' => $node->title,
|
|
|
'description' => $node->description,
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
if (!$node->project_id) {
|
|
|
//inserts info into chado table.
|
|
|
- $result = tripal_core_chado_insert('project',$values);
|
|
|
+ $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
|
|
|
+ }
|
|
|
+
|
|
|
+ //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, $node->project_id);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -222,19 +222,19 @@ function chado_project_insert($node) {
|
|
|
* Implementation of hook_delete().
|
|
|
*
|
|
|
* @param $node
|
|
|
-* The node which is to be deleted, only chado project and chado_project need to be dealt with
|
|
|
+* 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 chado_project_delete($node) {
|
|
|
// Notice that we're matching all revision, by using the node's nid.
|
|
|
-
|
|
|
+
|
|
|
// Find the project to delete
|
|
|
$values = array(
|
|
|
'project_id' => $node->project->project_id,
|
|
|
);
|
|
|
- tripal_core_chado_delete('project',$values);
|
|
|
-
|
|
|
+ tripal_core_chado_delete('project', $values);
|
|
|
+
|
|
|
//deleteing in drupal chado_project table
|
|
|
db_query('DELETE FROM {chado_project} WHERE nid = %d', $node->nid);
|
|
|
|
|
@@ -248,20 +248,20 @@ function chado_project_delete($node) {
|
|
|
* pertaining to the specific project
|
|
|
*
|
|
|
*/
|
|
|
-function chado_project_update($node){
|
|
|
-
|
|
|
- // Find the project to update
|
|
|
- $match= array(
|
|
|
- 'project_id'=>$node->project_id,
|
|
|
- );
|
|
|
-
|
|
|
- // New values
|
|
|
- $values = array(
|
|
|
+function chado_project_update($node) {
|
|
|
+
|
|
|
+ // Find the project to update
|
|
|
+ $match= array(
|
|
|
+ 'project_id' => $node->project_id,
|
|
|
+ );
|
|
|
+
|
|
|
+ // New values
|
|
|
+ $values = array(
|
|
|
'name' => $node->title,
|
|
|
'description' => $node->description,
|
|
|
);
|
|
|
|
|
|
- $result = tripal_core_chado_update('project',$match,$values);
|
|
|
+ $result = tripal_core_chado_update('project', $match, $values);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -277,17 +277,17 @@ function chado_project_update($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));
|
|
|
-
|
|
|
- //assigning the project-Id to a variable
|
|
|
- $values = array(
|
|
|
- 'project_id' => $result->project_id,
|
|
|
+ //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));
|
|
|
+
|
|
|
+ //assigning the project-Id to a variable
|
|
|
+ $values = array(
|
|
|
+ 'project_id' => $result->project_id,
|
|
|
);
|
|
|
-
|
|
|
- //the current project set to the 'project' with the $values(project-Id)
|
|
|
- $node->project = tripal_core_generate_chado_var('project',$values);
|
|
|
-
|
|
|
+
|
|
|
+ //the current project set to the 'project' with the $values(project-Id)
|
|
|
+ $node->project = tripal_core_generate_chado_var('project', $values);
|
|
|
+
|
|
|
return $node;
|
|
|
|
|
|
}
|