/[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.73, Fri Apr 3 22:08:39 2009 UTC revision 1.74, Fri May 29 16:21:56 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: versioncontrol_project.module,v 1.72 2009/03/21 02:33:50 jpetso Exp $  // $Id: versioncontrol_project.module,v 1.73 2009-04-03 22:08:39 jpetso Exp $
3  /**  /**
4   * @file   * @file
5   * Version Control / Project Node integration - Integrates project nodes   * Version Control / Project Node integration - Integrates project nodes
# Line 792  function versioncontrol_project_user($ty Line 792  function versioncontrol_project_user($ty
792   */   */
793  function versioncontrol_project_block($op = 'list', $delta = 0) {  function versioncontrol_project_block($op = 'list', $delta = 0) {
794    if ($op == 'list') {    if ($op == 'list') {
795      $blocks[0]['info'] = t('Most active projects');      $blocks = array();
796      $blocks[0]['cache'] = BLOCK_NO_CACHE;      $blocks['versioncontrol_project_site_active_projects'] = array(
797          'info' => t('Most active projects'),
798          'cache' => BLOCK_CACHE_GLOBAL,
799        );
800      return $blocks;      return $blocks;
801    }    }
802    else if ($op == 'view') {    else if ($op == 'view') {
803      if ($delta == 0) {      if ($delta == 'versioncontrol_project_site_active_projects') {
804        $interval = 7 * 24 * 60 * 60;        return versioncontrol_project_block_site_active_projects();
       $limit = 15;  
   
       $result = db_query_range('  
         SELECT n.nid, n.title, COUNT(projop.vc_op_id) as number_commits  
         FROM {versioncontrol_operations} op  
           INNER JOIN {versioncontrol_project_operations} projop  
             ON op.vc_op_id = projop.vc_op_id  
           INNER JOIN {node} n  
             ON projop.nid = n.nid  
         WHERE op.date >= %d AND op.type = %d AND n.status = 1  
         GROUP BY n.nid, n.title  
         ORDER BY number_commits DESC',  
         array(time() - $interval, VERSIONCONTROL_OPERATION_COMMIT),  
         0, $limit  
       );  
       $project_titles = array();  
   
       while ($project_stats = db_fetch_object($result)) {  
         $nid = $project_stats->nid;  
         $project_titles[] = l($project_stats->title, 'node/'. $nid);  
       }  
       if (!empty($project_titles)) {  
         $block = array(  
           'subject' => t('Most active projects'),  
           'content' => theme('item_list', $project_titles),  
         );  
         return $block;  
       }  
805      }      }
806    }    }
807  }  }
808    
809  /**  /**
810     * Implementation of hook_block($op='view') for the "active projects" block.
811     */
812    function versioncontrol_project_block_site_active_projects() {
813      $block = array();
814      $interval = 7 * 24 * 60 * 60;
815      $limit = 15;
816    
817      $result = db_query_range('
818        SELECT n.nid, n.title, COUNT(projop.vc_op_id) as number_commits
819        FROM {versioncontrol_operations} op
820          INNER JOIN {versioncontrol_project_operations} projop
821            ON op.vc_op_id = projop.vc_op_id
822          INNER JOIN {node} n
823            ON projop.nid = n.nid
824        WHERE op.date >= %d AND op.type = %d AND n.status = 1
825        GROUP BY n.nid, n.title
826        ORDER BY number_commits DESC',
827        array(time() - $interval, VERSIONCONTROL_OPERATION_COMMIT),
828        0, $limit
829      );
830      $project_titles = array();
831    
832      while ($project_stats = db_fetch_object($result)) {
833        $nid = $project_stats->nid;
834        $project_titles[] = l($project_stats->title, 'node/'. $nid);
835      }
836      if (!empty($project_titles)) {
837        $block = array(
838          'subject' => t('Most active projects'),
839          'content' => theme('item_list', $project_titles),
840        );
841      }
842      return $block;
843    }
844    
845    /**
846   * Implementation of hook_commitlog_constraints():   * Implementation of hook_commitlog_constraints():
847   * Provide a list of supported constraints and corresponding request attributes.   * Provide a list of supported constraints and corresponding request attributes.
848   */   */

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

  ViewVC Help
Powered by ViewVC 1.1.2