1 | <?php |
---|
2 | /** |
---|
3 | * ProjectManager - Constraints storage object |
---|
4 | * |
---|
5 | * @link http://www.egroupware.org |
---|
6 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
7 | * @package projectmanager |
---|
8 | * @copyright (c) 2005 by Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
---|
10 | * @version $Id: class.somilestones.inc.php 22355 2006-08-26 16:30:45Z ralfbecker $ |
---|
11 | */ |
---|
12 | |
---|
13 | include_once(PHPGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php'); |
---|
14 | |
---|
15 | /** |
---|
16 | * Milestones storage object of the projectmanager |
---|
17 | * |
---|
18 | * Tables: phpgw_pm_milestones |
---|
19 | */ |
---|
20 | class somilestones extends so_sql |
---|
21 | { |
---|
22 | /** |
---|
23 | * Constructor, calls the constructor of the extended class |
---|
24 | * |
---|
25 | * It is sufficent to give a ms_id, as they are unique |
---|
26 | * |
---|
27 | * @param int $pm_id pm_id of the project to use, default null |
---|
28 | * @param int $ms_id ms_id of the milestone to load, default null |
---|
29 | */ |
---|
30 | function somilestones($pm_id=null,$ms_id=null) |
---|
31 | { |
---|
32 | $this->so_sql('projectmanager','phpgw_pm_milestones'); |
---|
33 | |
---|
34 | if ((int) $ms_id) |
---|
35 | { |
---|
36 | $this->read($ms_id); |
---|
37 | $this->pm_id = $this->data['pm_id']; |
---|
38 | } |
---|
39 | if ((int) $pm_id) |
---|
40 | { |
---|
41 | $this->pm_id = (int) $pm_id; |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | /** |
---|
46 | * searches db for rows matching searchcriteria, reimplemented to automatic add $this->pm_id |
---|
47 | * |
---|
48 | * '*' and '?' are replaced with sql-wildcards '%' and '_' |
---|
49 | * |
---|
50 | * @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) |
---|
51 | * @param boolean $only_keys=true True returns only keys, False returns all cols |
---|
52 | * @param string $order_by='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) |
---|
53 | * @param string/array $extra_cols='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
---|
54 | * @param string $wildcard='' appended befor and after each criteria |
---|
55 | * @param boolean $empty=false False=empty criteria are ignored in query, True=empty have to be empty in row |
---|
56 | * @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together |
---|
57 | * @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num) |
---|
58 | * @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards |
---|
59 | * @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or |
---|
60 | * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! |
---|
61 | * @return array of matching rows (the row is an array of the cols) or False |
---|
62 | */ |
---|
63 | function &search($criteria,$only_keys=True,$order_by='ms_date',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='') |
---|
64 | { |
---|
65 | if (!$this->pm_id && !isset($criteria['pm_id']) && !isset($filter['pm_id'])) |
---|
66 | { |
---|
67 | $filter['pm_id'] = $this->pm_id; |
---|
68 | } |
---|
69 | return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join); |
---|
70 | } |
---|
71 | |
---|
72 | function &titles($keys=array()) |
---|
73 | { |
---|
74 | $milestones = array(); |
---|
75 | foreach((array)$this->search($keys,'ms_id,ms_date,ms_title') as $milestone) |
---|
76 | { |
---|
77 | if (!$milestone) continue; |
---|
78 | |
---|
79 | $milestones[$milestone['ms_id']] = date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$milestone['ms_date']). |
---|
80 | ': '.$milestone['ms_title']; |
---|
81 | } |
---|
82 | return $milestones; |
---|
83 | } |
---|
84 | } |
---|