[2] | 1 | <?php |
---|
[2360] | 2 | |
---|
| 3 | /*************************************************************************** |
---|
| 4 | * Expresso Livre * |
---|
| 5 | * http://www.expressolivre.org * |
---|
| 6 | * -------------------------------------------- * |
---|
| 7 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 8 | * under the terms of the GNU General Public License as published by the * |
---|
| 9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 10 | * option) any later version. * |
---|
| 11 | \**************************************************************************/ |
---|
[2091] | 12 | if(!isset($_SESSION['phpgw_info']['expressomail']['server']['db_name'])) { |
---|
| 13 | include_once('./header.inc.php'); |
---|
| 14 | $_SESSION['phpgw_info']['expressomail']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name']; |
---|
| 15 | $_SESSION['phpgw_info']['expressomail']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host']; |
---|
| 16 | $_SESSION['phpgw_info']['expressomail']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port']; |
---|
| 17 | $_SESSION['phpgw_info']['expressomail']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user']; |
---|
| 18 | $_SESSION['phpgw_info']['expressomail']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass']; |
---|
| 19 | $_SESSION['phpgw_info']['expressomail']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type']; |
---|
| 20 | } |
---|
| 21 | else{ |
---|
| 22 | define('PHPGW_INCLUDE_ROOT','./'); |
---|
| 23 | define('PHPGW_API_INC','./phpgwapi/inc'); |
---|
| 24 | include_once(PHPGW_API_INC.'/class.db.inc.php'); |
---|
| 25 | } |
---|
[413] | 26 | include_once('class.dynamic_contacts.inc.php'); |
---|
[502] | 27 | |
---|
[2] | 28 | class db_functions |
---|
| 29 | { |
---|
| 30 | |
---|
| 31 | var $db; |
---|
| 32 | var $user_id; |
---|
[757] | 33 | var $related_ids; |
---|
[2] | 34 | |
---|
| 35 | function db_functions(){ |
---|
| 36 | $this->db = new db(); |
---|
| 37 | $this->db->Halt_On_Error = 'no'; |
---|
| 38 | $this->db->connect( |
---|
| 39 | $_SESSION['phpgw_info']['expressomail']['server']['db_name'], |
---|
| 40 | $_SESSION['phpgw_info']['expressomail']['server']['db_host'], |
---|
| 41 | $_SESSION['phpgw_info']['expressomail']['server']['db_port'], |
---|
| 42 | $_SESSION['phpgw_info']['expressomail']['server']['db_user'], |
---|
| 43 | $_SESSION['phpgw_info']['expressomail']['server']['db_pass'], |
---|
| 44 | $_SESSION['phpgw_info']['expressomail']['server']['db_type'] |
---|
| 45 | ); |
---|
| 46 | $this -> user_id = $_SESSION['phpgw_info']['expressomail']['user']['account_id']; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | // BEGIN of functions. |
---|
| 50 | function get_cc_contacts() |
---|
| 51 | { |
---|
| 52 | $result = array(); |
---|
[525] | 53 | $stringDropDownContacts = ''; |
---|
[757] | 54 | |
---|
| 55 | $query_related = $this->get_query_related('A.id_owner'); // field name for owner |
---|
[525] | 56 | |
---|
| 57 | // Traz os contatos pessoais e compartilhados |
---|
| 58 | $query = 'select A.names_ordered, C.connection_value from phpgw_cc_contact A, '. |
---|
| 59 | 'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. |
---|
| 60 | 'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. |
---|
[757] | 61 | 'and B.id_typeof_contact_connection = 1 and ('.$query_related.') group by '. |
---|
| 62 | 'A.names_ordered,C.connection_value order by lower(A.names_ordered)'; |
---|
| 63 | |
---|
[2] | 64 | if (!$this->db->query($query)) |
---|
| 65 | return null; |
---|
| 66 | while($this->db->next_record()) |
---|
| 67 | $result[] = $this->db->row(); |
---|
| 68 | |
---|
| 69 | if (count($result) != 0) |
---|
| 70 | { |
---|
| 71 | // Monta string |
---|
| 72 | foreach($result as $contact) |
---|
[1992] | 73 | $stringDropDownContacts = $stringDropDownContacts . urldecode(urldecode($contact['names_ordered'])). ';' . $contact['connection_value'] . ','; |
---|
[2] | 74 | //Retira ultima virgula. |
---|
| 75 | $stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1)); |
---|
| 76 | } |
---|
| 77 | else |
---|
| 78 | return null; |
---|
| 79 | |
---|
| 80 | return $stringDropDownContacts; |
---|
| 81 | } |
---|
[757] | 82 | // Get Related Ids for sharing contacts or groups. |
---|
| 83 | function get_query_related($field_name){ |
---|
| 84 | $query_related = $field_name .'='.$this -> user_id; |
---|
| 85 | // Only at first time, it gets all related ids... |
---|
| 86 | if(!$this->related_ids) { |
---|
| 87 | $query = 'select id_related from phpgw_cc_contact_rels where id_contact='.$this -> user_id.' and id_typeof_contact_relation=1'; |
---|
| 88 | if (!$this->db->query($query)){ |
---|
| 89 | return $query_related; |
---|
| 90 | } |
---|
| 91 | |
---|
[1738] | 92 | $result = array( ); |
---|
[757] | 93 | while($this->db->next_record()){ |
---|
| 94 | $row = $this->db->row(); |
---|
| 95 | $result[] = $row['id_related']; |
---|
| 96 | } |
---|
| 97 | if($result) |
---|
| 98 | $this->related_ids = implode(",",$result); |
---|
| 99 | } |
---|
| 100 | if($this->related_ids) |
---|
| 101 | $query_related .= ' or '.$field_name.' in ('.$this->related_ids.')'; |
---|
| 102 | |
---|
| 103 | return $query_related; |
---|
| 104 | } |
---|
[2] | 105 | function get_cc_groups() |
---|
| 106 | { |
---|
| 107 | // Pesquisa no CC os Grupos Pessoais. |
---|
| 108 | $stringDropDownContacts = ''; |
---|
| 109 | $result = array(); |
---|
[757] | 110 | $query_related = $this->get_query_related('owner'); // field name for 'owner' |
---|
| 111 | $query = 'select title, short_name, owner from phpgw_cc_groups where '.$query_related.' order by lower(title)'; |
---|
| 112 | |
---|
[2] | 113 | // Executa a query |
---|
| 114 | if (!$this->db->query($query)) |
---|
| 115 | return null; |
---|
| 116 | // Retorna cada resultado |
---|
| 117 | while($this->db->next_record()) |
---|
| 118 | $result[] = $this->db->row(); |
---|
[757] | 119 | |
---|
| 120 | // Se houver grupos .... |
---|
[2] | 121 | if (count($result) != 0) |
---|
[757] | 122 | { |
---|
| 123 | // Create Ldap Object, if exists related Ids for sharing groups. |
---|
| 124 | if($this->related_ids){ |
---|
| 125 | $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids']= array(); |
---|
| 126 | include_once("class.ldap_functions.inc.php"); |
---|
| 127 | $ldap = new ldap_functions(); |
---|
| 128 | } |
---|
[906] | 129 | $owneruid = ''; |
---|
[757] | 130 | foreach($result as $group){ |
---|
| 131 | // Searching uid (LDAP), if exists related Ids for sharing groups. |
---|
| 132 | // Save into user session. It will used before send mail (verify permission). |
---|
[1738] | 133 | if(!isset($_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']]) && isset($ldap)){ |
---|
[757] | 134 | $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']] = $ldap -> uidnumber2uid($group['owner']); |
---|
| 135 | } |
---|
| 136 | if($this->user_id != $group['owner']) |
---|
| 137 | $owneruid = "::".$_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids'][$group['owner']]; |
---|
[906] | 138 | else |
---|
| 139 | $owneruid = ''; |
---|
[757] | 140 | |
---|
| 141 | $stringDropDownContacts .= $group['title']. ';' . ($group['short_name'].$owneruid) . ','; |
---|
| 142 | } |
---|
[2] | 143 | //Retira ultima virgula. |
---|
| 144 | $stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1)); |
---|
| 145 | } |
---|
| 146 | else |
---|
[757] | 147 | return null; |
---|
[2] | 148 | return $stringDropDownContacts; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | function getContactsByGroupAlias($alias) |
---|
| 152 | { |
---|
[757] | 153 | list($alias,$uid) = explode("::",$alias); |
---|
| 154 | $cc_related_ids = $_SESSION['phpgw_info']['expressomail']['user']['cc_related_ids']; |
---|
| 155 | // Explode personal group, If exists related ids (the user has permission to send email). |
---|
| 156 | if(is_array($cc_related_ids) && $uid){ |
---|
| 157 | $owner = array_search($uid,$cc_related_ids); |
---|
| 158 | } |
---|
[2] | 159 | |
---|
| 160 | $query = "select C.id_connection, A.names_ordered, C.connection_value from phpgw_cc_contact A, ". |
---|
| 161 | "phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D,phpgw_cc_groups E where ". |
---|
| 162 | "A.id_contact = B.id_contact and B.id_connection = C.id_connection ". |
---|
| 163 | "and B.id_typeof_contact_connection = 1 and ". |
---|
[757] | 164 | "A.id_owner =".($owner ? $owner : $this->user_id)." and ". |
---|
[2] | 165 | "D.id_group = E.id_group and ". |
---|
[757] | 166 | "D.id_connection = C.id_connection and E.short_name = '".$alias."'"; |
---|
[2] | 167 | |
---|
| 168 | if (!$this->db->query($query)) |
---|
| 169 | { |
---|
| 170 | exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | $return = false; |
---|
| 174 | |
---|
| 175 | while($this->db->next_record()) |
---|
| 176 | { |
---|
| 177 | $return[] = $this->db->row(); |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | return $return; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | function getAddrs($array_addrs) { |
---|
| 184 | $array_addrs_final = array(); |
---|
| 185 | |
---|
| 186 | for($i = 0; $i < count($array_addrs); $i++){ |
---|
| 187 | $j = count($array_addrs_final); |
---|
| 188 | |
---|
| 189 | if(!strchr($array_addrs[$i],'@') |
---|
| 190 | && strchr($array_addrs[$i],'<') |
---|
| 191 | && strchr($array_addrs[$i],'>')) { |
---|
| 192 | |
---|
| 193 | $alias = substr($array_addrs[$i], strpos($array_addrs[$i],'<'), strpos($array_addrs[$i],'>')); |
---|
[757] | 194 | $alias = str_replace('<','', str_replace('>','',$alias)); |
---|
| 195 | |
---|
[2] | 196 | $arrayContacts = $this -> getContactsByGroupAlias($alias); |
---|
| 197 | |
---|
| 198 | if($arrayContacts) { |
---|
| 199 | foreach($arrayContacts as $index => $contact){ |
---|
| 200 | if($contact['names_ordered']) { |
---|
| 201 | $array_addrs_final[$j] = '"'.$contact['names_ordered'].'" <'.$contact['connection_value'].'>'; |
---|
| 202 | } |
---|
| 203 | else |
---|
| 204 | $array_addrs_final[$j] = $contact['connection_value']; |
---|
| 205 | |
---|
| 206 | $j++; |
---|
| 207 | } |
---|
| 208 | } |
---|
| 209 | } |
---|
| 210 | else |
---|
| 211 | $array_addrs_final[$j++] = $array_addrs[$i]; |
---|
| 212 | } |
---|
| 213 | return $array_addrs_final; |
---|
| 214 | } |
---|
| 215 | |
---|
[1939] | 216 | //Gera lista de contatos para ser gravado e acessado pelo expresso offline. |
---|
| 217 | function get_dropdown_contacts_to_cache() { |
---|
| 218 | return $this->get_dropdown_contacts(); |
---|
| 219 | } |
---|
| 220 | |
---|
[502] | 221 | function get_dropdown_contacts(){ |
---|
[2427] | 222 | |
---|
| 223 | $number_of_contacts = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts']; |
---|
| 224 | $use_dynamic_contacts = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']; |
---|
| 225 | // Free others requests |
---|
| 226 | session_write_close(); |
---|
| 227 | |
---|
[2] | 228 | $contacts = $this -> get_cc_contacts(); |
---|
| 229 | $groups = $this -> get_cc_groups(); |
---|
| 230 | |
---|
| 231 | if(($contacts) && ($groups)) |
---|
| 232 | $stringDropDownContacts = $contacts . ',' . $groups; |
---|
| 233 | elseif ((!$contacts) && (!$groups)) |
---|
| 234 | $stringDropDownContacts = ''; |
---|
| 235 | elseif (($contacts) && (!$groups)) |
---|
| 236 | $stringDropDownContacts = $contacts; |
---|
| 237 | elseif ((!$contacts) && ($groups)) |
---|
| 238 | $stringDropDownContacts = $groups; |
---|
[502] | 239 | |
---|
[2427] | 240 | if($number_of_contacts && $use_dynamic_contacts) { |
---|
[484] | 241 | $dynamic_contact = new dynamic_contacts(); |
---|
| 242 | $dynamic = $dynamic_contact->dynamic_contact_toString(); |
---|
[413] | 243 | if ($dynamic) |
---|
[484] | 244 | $stringDropDownContacts .= ($stringDropDownContacts ? ',' : '') . $dynamic; |
---|
| 245 | } |
---|
[2] | 246 | return $stringDropDownContacts; |
---|
| 247 | } |
---|
[27] | 248 | function getUserByEmail($params){ |
---|
| 249 | // Follow the referral |
---|
| 250 | $email = $params['email']; |
---|
| 251 | $query = 'select A.names_ordered, C.connection_name, C.connection_value, A.photo'. |
---|
| 252 | ' from phpgw_cc_contact A, phpgw_cc_contact_conns B, '. |
---|
| 253 | 'phpgw_cc_connections C where A.id_contact = B.id_contact'. |
---|
| 254 | ' and B.id_connection = C.id_connection and A.id_contact ='. |
---|
| 255 | '(select A.id_contact from phpgw_cc_contact A, phpgw_cc_contact_conns B,'. |
---|
| 256 | 'phpgw_cc_connections C where A.id_contact = B.id_contact'. |
---|
| 257 | ' and B.id_connection = C.id_connection and A.id_owner = '.$this -> user_id. |
---|
| 258 | ' and C.connection_value = \''.$email.'\') and '. |
---|
| 259 | 'C.connection_is_default = true and B.id_typeof_contact_connection = 2'; |
---|
| 260 | |
---|
| 261 | if (!$this->db->query($query)) |
---|
| 262 | return null; |
---|
| 263 | |
---|
| 264 | |
---|
| 265 | if($this->db->next_record()) { |
---|
| 266 | $result = $this->db->row(); |
---|
| 267 | |
---|
| 268 | $obj = array("cn" => $result['names_ordered'], |
---|
| 269 | "email" => $email, |
---|
| 270 | "type" => "personal", |
---|
| 271 | "telefone" => $result['connection_value']); |
---|
| 272 | |
---|
| 273 | if($result['photo']) |
---|
| 274 | $_SESSION['phpgw_info']['expressomail']['contact_photo'] = array($result['photo']); |
---|
| 275 | |
---|
| 276 | return $obj; |
---|
| 277 | } |
---|
| 278 | return $result; |
---|
| 279 | } |
---|
[413] | 280 | |
---|
| 281 | function get_dynamic_contacts() |
---|
| 282 | { |
---|
| 283 | // Pesquisa os emails e ultima inserção nos contatos dinamicos. |
---|
| 284 | if(!$this->db->select('phpgw_expressomail_contacts','data', |
---|
| 285 | 'id_owner ='.$this -> user_id, |
---|
| 286 | __LINE__,__FILE__)) |
---|
| 287 | { |
---|
| 288 | return $this->db->Error; |
---|
[502] | 289 | } |
---|
[413] | 290 | while($this->db->next_record()) |
---|
| 291 | { |
---|
| 292 | $result[] = $this->db->row(); |
---|
| 293 | } |
---|
[455] | 294 | if($result) foreach($result as $item) |
---|
[413] | 295 | { |
---|
| 296 | $contacts = unserialize($item['data']); |
---|
| 297 | } |
---|
| 298 | if (count($contacts) == 0) |
---|
| 299 | { |
---|
| 300 | return null; |
---|
| 301 | } |
---|
[484] | 302 | //Sort by email |
---|
| 303 | function cmp($a, $b) { return strcmp($a["email"], $b["email"]);} |
---|
| 304 | usort($contacts,"cmp"); |
---|
[413] | 305 | return $contacts; |
---|
| 306 | } |
---|
| 307 | function update_contacts($contacts=array()) |
---|
| 308 | { |
---|
| 309 | // Atualiza um email nos contatos dinamicos. |
---|
| 310 | if(!$this->db->update('phpgw_expressomail_contacts ','data=\''.serialize($contacts).'\'', |
---|
[1308] | 311 | 'id_owner ='.$this -> user_id, |
---|
| 312 | __LINE__,__FILE__)) |
---|
[413] | 313 | { |
---|
[1308] | 314 | return $this->db->Error; |
---|
[413] | 315 | } |
---|
[1308] | 316 | return $contacts; |
---|
[413] | 317 | } |
---|
[1308] | 318 | function update_preferences($params){ |
---|
| 319 | $string_serial = urldecode($params['prefe_string']); |
---|
| 320 | $string_serial = get_magic_quotes_gpc() ? $string_serial : addslashes($string_serial); |
---|
| 321 | $query = "update phpgw_preferences set preference_value = '".$string_serial."' where preference_app = 'expressoMail'". |
---|
| 322 | " and preference_owner = '".$this->user_id."'"; |
---|
| 323 | |
---|
| 324 | if (!$this->db->query($query)) |
---|
| 325 | return $this->db->error; |
---|
| 326 | else |
---|
| 327 | return array("success" => true); |
---|
| 328 | } |
---|
[413] | 329 | |
---|
| 330 | function insert_contact($contact) |
---|
| 331 | { |
---|
| 332 | $contacts[] = array( 'timestamp' => time(), |
---|
| 333 | 'email' => $contact ); |
---|
| 334 | |
---|
| 335 | // Insere um email nos contatos dinamicos. |
---|
| 336 | $query = 'INSERT INTO phpgw_expressomail_contacts (data, id_owner) ' . |
---|
| 337 | 'values ( \''.serialize($contacts).'\', '.$this->user_id.')'; |
---|
| 338 | |
---|
| 339 | if(!$this->db->query($query,__LINE__,__FILE__)) |
---|
| 340 | return $this->db->Error; |
---|
| 341 | return $contacts; |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | function remove_dynamic_contact($user_id,$line,$file) |
---|
| 345 | { |
---|
| 346 | $where = $user_id.' = id_owner'; |
---|
| 347 | $this->db->delete('phpgw_expressomail_contacts',$where,$line,$file); |
---|
| 348 | } |
---|
[673] | 349 | |
---|
| 350 | function import_vcard($params){ |
---|
| 351 | |
---|
| 352 | include_once('class.imap_functions.inc.php'); |
---|
| 353 | $objImap = new imap_functions(); |
---|
| 354 | $msg_number = $params['msg_number']; |
---|
| 355 | $idx_file = $params['idx_file']; |
---|
| 356 | $msg_part = $params['msg_part']; |
---|
| 357 | $msg_folder = $params['msg_folder']; |
---|
| 358 | $encoding = strtolower($params['encoding']); |
---|
| 359 | $fileContent = ""; |
---|
| 360 | |
---|
| 361 | if($msg_number && $msg_part && $msg_folder && (intval($idx_file == '0' ? '1' : $idx_file))) { |
---|
| 362 | $mbox_stream = $objImap->open_mbox($msg_folder); |
---|
| 363 | $fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID); |
---|
| 364 | include_once('class.imap_attachment.inc.php'); |
---|
| 365 | $imap_attachment = new imap_attachment(); |
---|
| 366 | $a = $imap_attachment->download_attachment($mbox_stream, $msg_number); |
---|
| 367 | $filename = $a[$idx_file]['name']; |
---|
| 368 | } |
---|
| 369 | else |
---|
| 370 | $filename = $idx_file; |
---|
| 371 | |
---|
| 372 | if($fileContent) { |
---|
| 373 | if($encoding == 'base64') |
---|
| 374 | $calendar = imap_base64($fileContent); |
---|
| 375 | else if($encoding == 'quoted-printable') |
---|
| 376 | $calendar = quoted_printable_decode($fileContent); |
---|
| 377 | else |
---|
| 378 | $calendar = $fileContent; |
---|
| 379 | } |
---|
[2116] | 380 | // It's necessary to access calendar method. |
---|
[2147] | 381 | include_once(PHPGW_INCLUDE_ROOT.'/header.inc.php'); |
---|
[673] | 382 | $uiicalendar = CreateObject("calendar.uiicalendar"); |
---|
| 383 | return $uiicalendar = $uiicalendar->import_from_mail($calendar); |
---|
| 384 | } |
---|
[1035] | 385 | |
---|
| 386 | function insert_certificate($email,$certificate,$serialnumber,$authoritykeyidentifier=null) |
---|
| 387 | { |
---|
| 388 | if(!$email || !$certificate || !$serialnumber || !$authoritykeyidentifier) |
---|
| 389 | return false; |
---|
| 390 | // Insere uma chave publica na tabela phpgw_certificados. |
---|
| 391 | $data = array ('email' => $email, |
---|
| 392 | 'chave_publica' => $certificate, |
---|
| 393 | 'serialnumber' => $serialnumber, |
---|
| 394 | 'authoritykeyidentifier' => $authoritykeyidentifier); |
---|
| 395 | |
---|
| 396 | if(!$this->db->insert('phpgw_certificados',$data,array(),__LINE__,__FILE__)){ |
---|
| 397 | return $this->db->Error; |
---|
| 398 | } |
---|
| 399 | return true; |
---|
| 400 | } |
---|
| 401 | |
---|
| 402 | function get_certificate($email=null) |
---|
| 403 | { |
---|
| 404 | if(!$email) return false; |
---|
| 405 | $result = array(); |
---|
| 406 | |
---|
| 407 | $where = array ('email' => $email, |
---|
| 408 | 'revogado' => 0, |
---|
| 409 | 'expirado' => 0); |
---|
| 410 | |
---|
| 411 | if(!$this->db->select('phpgw_certificados','chave_publica', $where, __LINE__,__FILE__)) |
---|
| 412 | { |
---|
| 413 | $result['dberr1'] = $this->db->Error; |
---|
| 414 | return $result; |
---|
| 415 | } |
---|
| 416 | $regs = array(); |
---|
| 417 | while($this->db->next_record()) |
---|
| 418 | { |
---|
| 419 | $regs[] = $this->db->row(); |
---|
| 420 | } |
---|
| 421 | if (count($regs) == 0) |
---|
| 422 | { |
---|
| 423 | $result['dberr2'] = ' Certificado nao localizado.'; |
---|
| 424 | return $result; |
---|
| 425 | } |
---|
| 426 | $result['certs'] = $regs; |
---|
| 427 | return $result; |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | function update_certificate($serialnumber=null,$email=null,$authoritykeyidentifier,$expirado,$revogado) |
---|
| 431 | { |
---|
| 432 | if(!$email || !$serialnumber) return false; |
---|
| 433 | if(!$expirado) |
---|
| 434 | $expirado = 0; |
---|
| 435 | if(!$revogado) |
---|
| 436 | $revogado = 0; |
---|
| 437 | |
---|
| 438 | $data = array ('expirado' => $expirado, |
---|
| 439 | 'revogado' => $revogado); |
---|
| 440 | |
---|
| 441 | $where = array ('email' => $email, |
---|
| 442 | 'serialnumber' => $serialnumber, |
---|
| 443 | 'authoritykeyidentifier' => $authoritykeyidentifier); |
---|
| 444 | |
---|
| 445 | if(!$this->db->update('phpgw_certificados',$data,$where,__LINE__,__FILE__)) |
---|
| 446 | { |
---|
| 447 | return $this->db->Error; |
---|
| 448 | } |
---|
| 449 | return true; |
---|
| 450 | } |
---|
| 451 | |
---|
[2] | 452 | } |
---|
[1037] | 453 | ?> |
---|