1 | <?php |
---|
2 | /************************************************************************************************\ |
---|
3 | * Gerencia de projetos ageis * |
---|
4 | * by Rafael Raymundo da Silva (rafael2000@gmail.com) * |
---|
5 | * ----------------------------------------------------------------------------------------------* |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \***********************************************************************************************/ |
---|
11 | |
---|
12 | class solists{ |
---|
13 | |
---|
14 | var $db; |
---|
15 | var $projId; |
---|
16 | var $result; |
---|
17 | var $nameDesc; |
---|
18 | var $usrProj; |
---|
19 | |
---|
20 | public function solists(){ |
---|
21 | include_once('../phpgwapi/inc/class.db.inc.php'); |
---|
22 | $this->result = $GLOBALS['phpgw']->db; |
---|
23 | $this->result->query('SELECT * FROM phpgw_agile_projects',__LINE__,__FILE__); |
---|
24 | if($this->result->num_rows()) |
---|
25 | { |
---|
26 | $i=0; |
---|
27 | while ($this->result->next_record()) |
---|
28 | { |
---|
29 | $this->projId[$i] = array($this->result->f('proj_id')); |
---|
30 | $this->db[$i] = array( |
---|
31 | $this->result->f('proj_name'), |
---|
32 | $this->result->f('proj_owner'), |
---|
33 | $this->result->f('proj_description')); |
---|
34 | //print_r($this->db); |
---|
35 | $i++; |
---|
36 | } |
---|
37 | |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | public function soeditProject($projId){ |
---|
42 | include_once('../header.inc.php'); |
---|
43 | include_once('../phpgwapi/inc/class.db.inc.php'); |
---|
44 | |
---|
45 | $projId = addslashes($projId); |
---|
46 | |
---|
47 | $this->nameDesc = $GLOBALS['phpgw']->db; |
---|
48 | $this->usrProj = $GLOBALS['phpgw']->db; |
---|
49 | |
---|
50 | $this->nameDesc->query("SELECT proj_name, proj_description FROM phpgw_agile_projects WHERE proj_id=$projId",__LINE__,__FILE__); |
---|
51 | $this->usrProj->query("SELECT * FROM phpgw_agile_users_projects WHERE proj_id=$projId",__LINE__,__FILE__); |
---|
52 | } |
---|
53 | |
---|
54 | function quicksearch($params) |
---|
55 | { |
---|
56 | include_once("class.functions.inc.php"); |
---|
57 | $functions = new functions; |
---|
58 | |
---|
59 | $search_for = utf8_encode($params['search_for']); |
---|
60 | $field = $params['field']; |
---|
61 | $ID = $params['ID']; |
---|
62 | |
---|
63 | $search_for = explode(" ",$search_for); |
---|
64 | $aux=""; |
---|
65 | foreach ($search_for as $search) |
---|
66 | { |
---|
67 | if(!$aux) |
---|
68 | { |
---|
69 | $aux=$search; |
---|
70 | } |
---|
71 | else |
---|
72 | { |
---|
73 | if (strlen($search) > 2) |
---|
74 | { |
---|
75 | $aux=$aux."*".$search; |
---|
76 | } |
---|
77 | else |
---|
78 | { |
---|
79 | $aux=$aux." ".$search; |
---|
80 | } |
---|
81 | } |
---|
82 | } |
---|
83 | $search_for=$aux; |
---|
84 | |
---|
85 | $contacts_result = array(); |
---|
86 | $contacts_result['field'] = $field; |
---|
87 | $contacts_result['ID'] = $ID; |
---|
88 | |
---|
89 | // follow the referral |
---|
90 | $this->ldapConnect(true); |
---|
91 | |
---|
92 | if ($this->ds) |
---|
93 | { |
---|
94 | if (($field != 'null') && ($ID != 'null')) |
---|
95 | { |
---|
96 | $filter="(& (&(|(phpgwAccountType=u)(phpgwAccountType=g)(phpgwAccountType=l)(phpgwAccountType=i)(phpgwAccountType=s))(mail=*)) (|(cn=*$search_for*)(mail=*$search_for*)) (!(phpgwaccountvisible=-1)) )"; |
---|
97 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou"); |
---|
98 | } |
---|
99 | else |
---|
100 | { |
---|
101 | $filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )"; |
---|
102 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid", "employeeNumber", "ou"); |
---|
103 | } |
---|
104 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1); |
---|
105 | if(!$sr) |
---|
106 | return null; |
---|
107 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
108 | |
---|
109 | // Get user org dn. |
---|
110 | $user_dn = $_SESSION['phpgw_info']['expressomail']['user']['account_dn']; |
---|
111 | $user_sector_dn = ldap_explode_dn ( $user_dn, false ); |
---|
112 | array_shift($user_sector_dn); |
---|
113 | array_shift($user_sector_dn); |
---|
114 | $user_sector_dn = implode(",", $user_sector_dn); |
---|
115 | |
---|
116 | // New search only on user sector |
---|
117 | if ($count_entries > $this->max_result) |
---|
118 | { |
---|
119 | // Close old ldap conection |
---|
120 | ldap_close($this->ds); |
---|
121 | |
---|
122 | // Reopen a local ldap connection, following referral |
---|
123 | $this->ldapRootConnect(true); |
---|
124 | |
---|
125 | $sr= ldap_search($this->ds, $user_sector_dn, $filter, $justthese); |
---|
126 | if(!$sr) |
---|
127 | return null; |
---|
128 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
129 | |
---|
130 | if ($count_entries > $this->max_result){ |
---|
131 | $return = array(); |
---|
132 | $return['status'] = false; |
---|
133 | $return['error'] = "many results"; |
---|
134 | return $return; |
---|
135 | } |
---|
136 | else |
---|
137 | { |
---|
138 | $quickSearch_only_in_userSector = true; |
---|
139 | } |
---|
140 | } |
---|
141 | |
---|
142 | $info = ldap_get_entries($this->ds, $sr); |
---|
143 | |
---|
144 | $tmp = array(); |
---|
145 | $tmp_users_from_user_org = array(); |
---|
146 | |
---|
147 | if (!$quickSearch_only_in_userSector) { |
---|
148 | $catalogsNum=count($this->external_srcs); |
---|
149 | for ($i=0; $i<=count($this->external_srcs); $i++) { |
---|
150 | if ($this->external_srcs[$i]["quicksearch"]) { |
---|
151 | $this->ldapConnect(true,$i); |
---|
152 | $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; |
---|
153 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou"); |
---|
154 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); |
---|
155 | if(!$sr) |
---|
156 | return null; |
---|
157 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
158 | $search = ldap_get_entries($this->ds, $sr); |
---|
159 | for ($j=0; $j<$search["count"]; $j++) { |
---|
160 | $info[] = $search[$j]; |
---|
161 | } |
---|
162 | $info["count"] = count($info)-1; |
---|
163 | } |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | for ($i=0; $i<$info["count"]; $i++) |
---|
168 | { |
---|
169 | if ($quickSearch_only_in_userSector) |
---|
170 | { |
---|
171 | $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); |
---|
172 | } |
---|
173 | else |
---|
174 | { |
---|
175 | if (preg_match("/$user_sector_dn/i", $info[$i]['dn'])) |
---|
176 | { |
---|
177 | $tmp_users_from_user_org[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | $tmp[$info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]] = utf8_decode($info[$i]["cn"][0]); |
---|
182 | } |
---|
183 | } |
---|
184 | } |
---|
185 | natcasesort($tmp_users_from_user_org); |
---|
186 | natcasesort($tmp); |
---|
187 | |
---|
188 | if (($field != 'null') && ($ID != 'null')) |
---|
189 | { |
---|
190 | $i = 0; |
---|
191 | |
---|
192 | $tmp = array_merge($tmp, $tmp_users_from_user_org); |
---|
193 | natcasesort($tmp); |
---|
194 | |
---|
195 | foreach ($tmp as $info => $cn) |
---|
196 | { |
---|
197 | $contacts_result[$i] = array(); |
---|
198 | $contacts_result[$i]["cn"] = $cn; |
---|
199 | list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["mobile"], $contacts_result[$i]["uid"], $contacts_result[$i]["jpegphoto"], $contacts_result[$i]["employeenumber"], $contacts_result[$i]["ou"]) = split ('%', $info); |
---|
200 | $i++; |
---|
201 | } |
---|
202 | $contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector; |
---|
203 | } |
---|
204 | else |
---|
205 | { |
---|
206 | $options_users_from_user_org = ''; |
---|
207 | $options = ''; |
---|
208 | |
---|
209 | /* List of users from user org */ |
---|
210 | $i = 0; |
---|
211 | foreach ($tmp_users_from_user_org as $info => $cn) |
---|
212 | { |
---|
213 | $contacts_result[$i] = array(); |
---|
214 | $options_users_from_user_org .= $this->make_quicksearch_card($info, $cn); |
---|
215 | $i++; |
---|
216 | } |
---|
217 | |
---|
218 | /* List of users from others org */ |
---|
219 | foreach ($tmp as $info => $cn) |
---|
220 | { |
---|
221 | $contacts_result[$i] = array(); |
---|
222 | $options .= $this->make_quicksearch_card($info, $cn); |
---|
223 | $i++; |
---|
224 | } |
---|
225 | |
---|
226 | if ($quickSearch_only_in_userSector) |
---|
227 | { |
---|
228 | if ($options != '') |
---|
229 | { |
---|
230 | $head_option = |
---|
231 | '<tr class="quicksearchcontacts_unselected">' . |
---|
232 | '<td colspan="2" width="100%" align="center">' . |
---|
233 | str_replace("%1", $this->max_result,$this->functions->getLang('More than %1 results were found')) . '.<br>' . |
---|
234 | $this->functions->getLang('Showing only the results found in your organization') . '.'; |
---|
235 | '</td>' . |
---|
236 | '</tr>'; |
---|
237 | $contacts_result = $head_option . $options_users_from_user_org . $options; |
---|
238 | } |
---|
239 | else |
---|
240 | { |
---|
241 | $return = array(); |
---|
242 | $return['status'] = false; |
---|
243 | $return['error'] = "many results"; |
---|
244 | return $return; |
---|
245 | } |
---|
246 | } |
---|
247 | else |
---|
248 | { |
---|
249 | if (($options_users_from_user_org != '') && ($options != '')) |
---|
250 | { |
---|
251 | $head_option0 = |
---|
252 | '<tr class="quicksearchcontacts_unselected">' . |
---|
253 | '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . |
---|
254 | $this->functions->getLang('Users from your organization') . '</B> ['.count($tmp_users_from_user_org).']'; |
---|
255 | '</td>' . |
---|
256 | '</tr>'; |
---|
257 | |
---|
258 | $head_option1 = |
---|
259 | '<tr class="quicksearchcontacts_unselected">' . |
---|
260 | '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . |
---|
261 | $this->functions->getLang('Users from others organizations') . '</B> ['.count($tmp).']'; |
---|
262 | '</td>' . |
---|
263 | '</tr>'; |
---|
264 | } |
---|
265 | $contacts_result = $head_option0 . $options_users_from_user_org . $head_option1 . $options; |
---|
266 | } |
---|
267 | } |
---|
268 | } |
---|
269 | ldap_close($this->ds); |
---|
270 | return $contacts_result; |
---|
271 | } |
---|
272 | } |
---|