/[drupal]/contributions/modules/storm/stormexpense/stormexpense.module
ViewVC logotype

Diff of /contributions/modules/storm/stormexpense/stormexpense.module

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

revision 1.4.4.7, Mon Jul 28 14:24:43 2008 UTC revision 1.4.4.8, Fri Aug 1 08:15:09 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: stormexpense.module,v 1.4.4.6 2008/07/23 19:37:49 robertogerola Exp $  // $Id: stormexpense.module,v 1.4.4.7 2008/07/28 14:24:43 robertogerola Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 109  function stormexpense_access_sql($sql, $ Line 109  function stormexpense_access_sql($sql, $
109    return storm_rewrite_sql($sql, $where);    return storm_rewrite_sql($sql, $where);
110  }  }
111    
112  function stormexpense_storm_rewrite_where_sql($query, $primary_table ='n', $account = NULL) {  function stormexpense_storm_rewrite_where_sql($query, $primary_table, $account) {
113    static $conds = array();    static $conds = array();
114    
   if (!$account) {  
     global $user;  
     $account = $user;  
   }  
   
115    if ($conds[$account->uid]) {    if ($conds[$account->uid]) {
116      return $conds[$account->uid];      return $conds[$account->uid];
117    }    }
# Line 135  function stormexpense_storm_rewrite_wher Line 130  function stormexpense_storm_rewrite_wher
130      }      }
131      if (user_access('Storm expense view of user organization', $account)) {      if (user_access('Storm expense view of user organization', $account)) {
132        if ($cond) $cond .= ' OR ';        if ($cond) $cond .= ' OR ';
133        $cond .= 'sex1.organization_nid='. $account->stormorganization_nid;        $cond .= ' sex1.organization_nid='. $account->stormorganization_nid;
134      }      }
135      if ($cond) {      if ($cond) {
136        $cond = "WHEN 'stormexpense' THEN (SELECT IF($cond,1,0) FROM {stormexpense} sex1 WHERE sex1.vid=${primary_table}.vid) ";        $cond = " WHEN 'stormexpense' THEN (SELECT IF($cond,1,0) FROM {stormexpense} sex1 WHERE sex1.vid=${primary_table}.vid) ";
137      }      }
138      else {      else {
139        $cond = "WHEN 'stormexpense' THEN 0 ";        $cond = " WHEN 'stormexpense' THEN 0 ";
140      }      }
141    }    }
142    
# Line 483  function _stormexpense_beforesave(&$node Line 478  function _stormexpense_beforesave(&$node
478      $node->total = $node->amount + $node->vat;      $node->total = $node->amount + $node->vat;
479    }    }
480    
481    $s = "SELECT n.title    $s = "SELECT n.title FROM {node} AS n
482          FROM {node} AS n INNER JOIN {stormorganization} AS o ON n.nid=o.nid          INNER JOIN {stormorganization} AS o ON n.nid=o.nid
483          WHERE type='stormorganization' AND n.nid=%d";          WHERE type='stormorganization' AND n.nid=%d";
484    $r = db_query($s, $node->organization_nid);    $r = db_query($s, $node->organization_nid);
485    $o = db_fetch_object($r);    $o = db_fetch_object($r);
486    $node->organization_title = $o->title;    $node->organization_title = $o->title;
487    
488    $s = "SELECT n.title, p.organization_title    $s = "SELECT n.title, p.organization_title
489          FROM {node} n INNER JOIN {stormproject} p ON n.nid=p.nid          FROM {node} n INNER JOIN {stormproject} p ON n.nid=p.nid
490          WHERE type='stormproject' AND n.nid=%d";          WHERE type='stormproject' AND n.nid=%d";
491    $r = db_query($s, $node->project_nid);    $r = db_query($s, $node->project_nid);

Legend:
Removed from v.1.4.4.7  
changed lines
  Added in v.1.4.4.8

  ViewVC Help
Powered by ViewVC 1.1.2