1 | <?php |
---|
2 | |
---|
3 | //Definindo Constantes |
---|
4 | require_once ROOTPATH . '/modules/catalog/constants.php'; |
---|
5 | |
---|
6 | use prototype\api\Config as Config; |
---|
7 | |
---|
8 | /** |
---|
9 | * Métodos que são chamados conforme definições no arquivo contact.ini & contactGroup.ini |
---|
10 | * |
---|
11 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
12 | * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) |
---|
13 | * @sponsor Caixa Econômica Federal |
---|
14 | * @author José Vicente Tezza Jr. e Gustavo Pereira dos Santos Stabelini |
---|
15 | * @return Métodos que são chamados conforme definições no arquivo contact.ini & contactGroup.ini |
---|
16 | * @access public |
---|
17 | * */ |
---|
18 | |
---|
19 | class CatalogDBMapping { |
---|
20 | |
---|
21 | |
---|
22 | public function findConnections(&$uri, &$params, &$criteria, $original) { |
---|
23 | |
---|
24 | if(count($params)>0 && isset($params[0]['id'])){ |
---|
25 | $params_count = count($params); |
---|
26 | for($i=0; $i < $params_count; ++$i){ |
---|
27 | //Retorna o telefone e o e-mail padrao de um determinado contato |
---|
28 | $sql = ' SELECT phpgw_cc_contact_conns.id_typeof_contact_connection as type, phpgw_cc_connections.connection_value as value ' |
---|
29 | .'FROM phpgw_cc_contact_conns ' |
---|
30 | .'JOIN phpgw_cc_connections ' |
---|
31 | .'ON (phpgw_cc_connections.id_connection = phpgw_cc_contact_conns.id_connection) ' |
---|
32 | .'WHERE phpgw_cc_contact_conns.id_contact = ' . $params[$i]['id'] . ' AND ' |
---|
33 | .'phpgw_cc_connections.connection_is_default = TRUE '; |
---|
34 | |
---|
35 | $array = Controller::service('PostgreSQL')->execResultSql($sql); |
---|
36 | if(count($array)>0){ |
---|
37 | foreach($array as $connection){ |
---|
38 | switch($connection['type']){ |
---|
39 | case TYPE_EMAIL : $params[$i][INDEX_EMAIL] = $connection['value']; break; |
---|
40 | case TYPE_TELEPHONE : $params[$i][INDEX_TELEPHONE] = $connection['value']; break; |
---|
41 | default : $params[$i][INDEX_EMAIL] = $params[$i][INDEX_TELEPHONE] = ''; |
---|
42 | } |
---|
43 | |
---|
44 | } |
---|
45 | } |
---|
46 | else{ |
---|
47 | $params[$i][INDEX_EMAIL] = $params[$i][INDEX_TELEPHONE] = ''; |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | public function findGroupConnections(&$uri, &$params, &$criteria, $original) { |
---|
54 | |
---|
55 | if(count($params)>0 && isset($params[0]['id'])){ |
---|
56 | $z = 0; |
---|
57 | $count = count($params); |
---|
58 | for($i=0; $i < $count; ++$i){ |
---|
59 | //Retorna o telefone e o e-mail padrao de um determinado contato |
---|
60 | $sql = 'SELECT contato.names_ordered as name, contato.id_contact as id, conexao.connection_value as value ' |
---|
61 | .'FROM phpgw_cc_groups grupo ' |
---|
62 | .'JOIN phpgw_cc_contact_grps grupo_contato ' |
---|
63 | .'ON (grupo.id_group = grupo_contato.id_group) ' |
---|
64 | .'JOIN phpgw_cc_connections conexao ' |
---|
65 | .'ON (grupo_contato.id_connection = conexao.id_connection) ' |
---|
66 | .'JOIN phpgw_cc_contact_conns conexaoCon ' |
---|
67 | .'ON (conexao.id_connection = conexaoCon.id_connection) ' |
---|
68 | .'JOIN phpgw_cc_contact contato ' |
---|
69 | .'ON (contato.id_contact = conexaoCon.id_contact) ' |
---|
70 | .'WHERE grupo.id_group = ' . $params[$i]['id'] . ' AND ' |
---|
71 | .'conexao.connection_is_default = TRUE'; |
---|
72 | |
---|
73 | $array = Controller::service('PostgreSQL')->execResultSql($sql); |
---|
74 | |
---|
75 | if(count($array)>0){ |
---|
76 | $params[$i]['contacts'][$z] = array(); |
---|
77 | foreach($array as $connection){ |
---|
78 | $params[$i]['contacts'][$z]['id'] = $connection['id']; |
---|
79 | $params[$i]['contacts'][$z]['name'] = $connection['name']; |
---|
80 | $params[$i]['contacts'][$z][INDEX_EMAIL] = $connection['value']; |
---|
81 | ++$z; |
---|
82 | } |
---|
83 | } |
---|
84 | else{ |
---|
85 | $params[$i]['contacts'] = null; |
---|
86 | } |
---|
87 | } |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | } |
---|
92 | |
---|
93 | ?> |
---|