| 1 |
<?php |
<?php |
| 2 |
// $Id: storminvoiceitem.module,v 1.5.4.4 2008/07/23 14:27:03 robertogerola Exp $ |
// $Id: storminvoiceitem.module,v 1.5.4.5 2008/07/23 19:37:49 robertogerola Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 96 |
return storm_rewrite_sql($sql, $where); |
return storm_rewrite_sql($sql, $where); |
| 97 |
} |
} |
| 98 |
|
|
| 99 |
function storminvoiceitem_storm_rewrite_where_sql($query, $primary_table ='n', $account = NULL) { |
function storminvoiceitem_storm_rewrite_where_sql($query, $primary_table, $account) { |
| 100 |
static $conds = array(); |
static $conds = array(); |
| 101 |
|
|
|
if (!$account) { |
|
|
global $user; |
|
|
$account = $user; |
|
|
} |
|
|
|
|
| 102 |
if ($conds[$account->uid]) { |
if ($conds[$account->uid]) { |
| 103 |
return $conds[$account->uid]; |
return $conds[$account->uid]; |
| 104 |
} |
} |
| 113 |
|
|
| 114 |
$cond = ''; |
$cond = ''; |
| 115 |
if (user_access('Storm invoice item: view own', $account)) { |
if (user_access('Storm invoice item: view own', $account)) { |
| 116 |
$cond .= "${primary_table}.uid=". $account->uid; |
$cond .= " ${primary_table}.uid=". $account->uid; |
| 117 |
} |
} |
| 118 |
if ($cond) { |
if ($cond) { |
| 119 |
$cond = "WHEN 'storminvoiceitem' THEN (SELECT IF($cond,1,0) FROM {storminvoiceitem} sit1 WHERE sit1.vid=${primary_table}.vid) "; |
$cond = " WHEN 'storminvoiceitem' THEN (SELECT IF($cond,1,0) FROM {storminvoiceitem} sit1 WHERE sit1.vid=${primary_table}.vid) "; |
| 120 |
} |
} |
| 121 |
else { |
else { |
| 122 |
$cond = "WHEN 'storminvoiceitem' THEN 0 "; |
$cond = " WHEN 'storminvoiceitem' THEN 0 "; |
| 123 |
} |
} |
| 124 |
} |
} |
| 125 |
|
|