/[drupal]/contributions/modules/versioncontrol_project/versioncontrol_project.module
ViewVC logotype

Diff of /contributions/modules/versioncontrol_project/versioncontrol_project.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.74, Fri May 29 16:21:56 2009 UTC revision 1.75, Fri May 29 16:22:23 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: versioncontrol_project.module,v 1.73 2009-04-03 22:08:39 jpetso Exp $  // $Id: versioncontrol_project.module,v 1.74 2009/05/29 16:21:56 jpetso Exp $
3  /**  /**
4   * @file   * @file
5   * Version Control / Project Node integration - Integrates project nodes   * Version Control / Project Node integration - Integrates project nodes
# Line 10  Line 10 
10   * Copyright 2007, 2008, 2009 by Jakob Petsovits ("jpetso", http://drupal.org/user/56020)   * Copyright 2007, 2008, 2009 by Jakob Petsovits ("jpetso", http://drupal.org/user/56020)
11   */   */
12    
13  // The nid used for project/item associations in {versioncontrol_project_items}  /**
14  // that have been checked, but are not associated to any project.   * The nid used for project/item associations in {versioncontrol_project_items}
15  // Useful for keeping track of which items have been checked and which haven't.   * that have been checked, but are not associated to any project.
16     * Useful for keeping track of which items have been checked and which haven't.
17     */
18  define('VERSIONCONTROL_PROJECT_NID_NONE', 0);  define('VERSIONCONTROL_PROJECT_NID_NONE', 0);
19    
20    /**
21     * @name Project relation constraints
22     * Allowed values for use with the 'project_relation' constraint in
23     * versioncontrol_get_operations() queries.
24     */
25    //@{
26    define('VERSIONCONTROL_PROJECT_ASSOCIATED',           1);
27    define('VERSIONCONTROL_PROJECT_ASSOCIATED_PUBLISHED', 2);
28    //@}
29    
30    
31  /**  /**
32   * Implementation of hook_boot():   * Implementation of hook_boot():
# Line 735  function versioncontrol_project_develope Line 747  function versioncontrol_project_develope
747    }    }
748    
749    $project = $node->versioncontrol_project;    $project = $node->versioncontrol_project;
750    $constraints = array('nids' => array($project['nid']));    $constraints = array(
751    return theme('versioncontrol_user_statistics', $constraints);      'types' => array(VERSIONCONTROL_OPERATION_COMMIT),
752        'nids' => array($project['nid']),
753      );
754      return theme('versioncontrol_user_statistics', $constraints, array(
755        'order_by' => array('date'),
756      ));
757  }  }
758    
759  /**  /**
# Line 848  function versioncontrol_project_block_si Line 865  function versioncontrol_project_block_si
865   */   */
866  function versioncontrol_project_commitlog_constraints() {  function versioncontrol_project_commitlog_constraints() {
867    return array(    return array(
868      'maintainer_uids' => array('single' => 'maintainer', 'multiple' => 'maintainers'),      'maintainer_uids'  => array('single' => 'maintainer', 'multiple' => 'maintainers'),
869      'nids'            => array('single' => 'nid',        'multiple' => 'nids'),      'nids'             => array('single' => 'nid',        'multiple' => 'nids'),
870        'project_relation' => array('single' => 'project-relation'),
871    );    );
872  }  }
873    
# Line 860  function versioncontrol_project_commitlo Line 878  function versioncontrol_project_commitlo
878   */   */
879  function versioncontrol_project_versioncontrol_operation_constraint_info() {  function versioncontrol_project_versioncontrol_operation_constraint_info() {
880    return array(    return array(
881      'nids' => array(),      'nids' => array('join callback' => 'versioncontrol_project_table_project_operations_join'),
882        'project_relation' => array(
883          'join callback' => 'versioncontrol_project_table_project_operations_join',
884          'cardinality' => VERSIONCONTROL_CONSTRAINT_SINGLE,
885        ),
886    );    );
887  }  }
888    
# Line 904  function versioncontrol_project_operatio Line 926  function versioncontrol_project_operatio
926      $placeholders[] = '%d';      $placeholders[] = '%d';
927      $params[] = $nid;      $params[] = $nid;
928    }    }
929      $and_constraints[] = $tables['versioncontrol_project_operations']['alias'] .'.nid
930                            IN ('. implode(',', $placeholders) .')';
931    }
932    
933    /**
934     * Filter operations by associated project node status.
935     */
936    function versioncontrol_project_operation_constraint_project_relation($constraint, &$tables, &$and_constraints, &$params) {
937      $and_constraints[] = $tables['versioncontrol_project_operations']['alias'] .'.nid <> %d';
938      $params[] = VERSIONCONTROL_PROJECT_NID_NONE;
939    
940      if ($constraint == VERSIONCONTROL_PROJECT_ASSOCIATED_PUBLISHED) {
941        versioncontrol_project_table_project_node_join($tables);
942        $and_constraints[] = $tables['versioncontrol_project_node']['alias'] .'.status = 1';
943      }
944    }
945    
946    /**
947     * Take an existing @p $tables array and add the table join for
948     * {versioncontrol_project_operations}. Only meant to be used within a
949     * constraint construction callback.
950     */
951    function versioncontrol_project_table_project_operations_join(&$tables) {
952    if (!isset($tables['versioncontrol_project_operations'])) {    if (!isset($tables['versioncontrol_project_operations'])) {
953      $tables['versioncontrol_project_operations'] = array(      $tables['versioncontrol_project_operations'] = array(
954        'alias' => 'projop',        'alias' => 'projop',
955        'join_on' => $tables['versioncontrol_operations']['alias'] .'.vc_op_id = projop.vc_op_id',        'join_on' => $tables['versioncontrol_operations']['alias'] .'.vc_op_id = projop.vc_op_id',
956      );      );
957    }    }
958    $and_constraints[] = $tables['versioncontrol_project_operations']['alias'] .'.nid  }
959                          IN ('. implode(',', $placeholders) .')';  
960    /**
961     * Take an existing @p $tables array and add the table joins for
962     * {versioncontrol_project_operations} and {node}. Only meant to be used within
963     * a constraint construction callback.
964     */
965    function versioncontrol_project_table_project_node_join(&$tables) {
966      if (!isset($tables['versioncontrol_project_node'])) {
967        versioncontrol_project_table_project_operations_join($tables);
968    
969        $tables['versioncontrol_project_node'] = array(
970          'real_table' => 'node',
971          'alias' => 'projnode',
972          'join_on' => $tables['versioncontrol_project_operations']['alias'] .'.nid = projnode.nid',
973        );
974      }
975  }  }
976    
977    

Legend:
Removed from v.1.74  
changed lines
  Added in v.1.75

  ViewVC Help
Powered by ViewVC 1.1.2