| 1 |
<?php |
<?php |
| 2 |
// $Id: stormtimetracking.module,v 1.10.4.8 2008/07/23 14:27:04 robertogerola Exp $ |
// $Id: stormtimetracking.module,v 1.10.4.9 2008/07/23 19:37:50 robertogerola Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 106 |
return storm_rewrite_sql($sql, $where); |
return storm_rewrite_sql($sql, $where); |
| 107 |
} |
} |
| 108 |
|
|
| 109 |
function stormtimetracking_storm_rewrite_where_sql($query, $primary_table ='n', $account = NULL) { |
function stormtimetracking_storm_rewrite_where_sql($query, $primary_table, $account) { |
| 110 |
static $conds = array(); |
static $conds = array(); |
| 111 |
|
|
|
if (!$account) { |
|
|
global $user; |
|
|
$account = $user; |
|
|
} |
|
|
|
|
| 112 |
if ($conds[$account->uid]) { |
if ($conds[$account->uid]) { |
| 113 |
return $conds[$account->uid]; |
return $conds[$account->uid]; |
| 114 |
} |
} |
| 127 |
} |
} |
| 128 |
if (user_access('Storm timetracking: view of user organization', $account)) { |
if (user_access('Storm timetracking: view of user organization', $account)) { |
| 129 |
if ($cond) $cond .= ' OR '; |
if ($cond) $cond .= ' OR '; |
| 130 |
$cond .= 'stt1.organization_nid='. $account->stormorganization_nid; |
$cond .= ' stt1.organization_nid='. $account->stormorganization_nid; |
| 131 |
} |
} |
| 132 |
if ($cond) { |
if ($cond) { |
| 133 |
$cond = "WHEN 'stormtimetracking' THEN (SELECT IF($cond,1,0) FROM {stormtimetracking} stt1 WHERE stt1.vid=${primary_table}.vid) "; |
$cond = " WHEN 'stormtimetracking' THEN (SELECT IF($cond,1,0) FROM {stormtimetracking} stt1 WHERE stt1.vid=${primary_table}.vid) "; |
| 134 |
} |
} |
| 135 |
else { |
else { |
| 136 |
$cond = "WHEN 'stormtimetracking' THEN 0 "; |
$cond = " WHEN 'stormtimetracking' THEN 0 "; |
| 137 |
} |
} |
| 138 |
} |
} |
| 139 |
|
|
| 269 |
$node->trackingdate = time(); |
$node->trackingdate = time(); |
| 270 |
|
|
| 271 |
$today = _storm_gmtimestamp_without_time(time()); |
$today = _storm_gmtimestamp_without_time(time()); |
| 272 |
$s = 'SELECT MAX(stt.timeend) FROM {node} n LEFT JOIN {stormtimetracking} stt ON n.nid=stt.nid |
$s = 'SELECT MAX(stt.timeend) FROM {node} n LEFT JOIN {stormtimetracking} stt ON n.nid=stt.nid |
| 273 |
WHERE stt.trackingdate>=%d AND stt.trackingdate<=%d AND n.uid=%d'; |
WHERE stt.trackingdate>=%d AND stt.trackingdate<=%d AND n.uid=%d'; |
| 274 |
$timebegin = db_result(db_query($s, $today, $today, $node->uid)); |
$timebegin = db_result(db_query($s, $today, $today, $node->uid)); |
| 275 |
$node->timebegin = $timebegin; |
$node->timebegin = $timebegin; |
| 479 |
$node->duration = ($timeend['hour'] - $timebegin['hour'] + ($timeend['minute'] - $timebegin['minute']) / 60); |
$node->duration = ($timeend['hour'] - $timebegin['hour'] + ($timeend['minute'] - $timebegin['minute']) / 60); |
| 480 |
} |
} |
| 481 |
|
|
| 482 |
$s = "SELECT n.title |
$s = "SELECT n.title FROM {node} n INNER JOIN {stormorganization} o ON n.nid=o.nid |
|
FROM {node} n INNER JOIN {stormorganization} 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 FROM {node} n INNER JOIN {stormproject} p ON n.nid=p.nid |
|
FROM {node} n INNER JOIN {stormproject} p ON n.nid=p.nid |
|
| 489 |
WHERE type='stormproject' AND n.nid=%d"; |
WHERE type='stormproject' AND n.nid=%d"; |
| 490 |
$r = db_query($s, $node->project_nid); |
$r = db_query($s, $node->project_nid); |
| 491 |
$p = db_fetch_object($r); |
$p = db_fetch_object($r); |