Ignore:
Timestamp:
04/01/11 15:28:42 (13 years ago)
Author:
niltonneto
Message:

Ticket #1692 - Removido da class db_function todos os métodos não utilizados.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/reports/inc/class.db_functions.inc.php

    r3471 r3945  
    3939                return $result; 
    4040        } 
    41         /* 
    42         *       Reativa os usuários desabilitados por tempo inativo modificando o seu ultimo acesso para o dia atual. 
    43         */ 
    44         function reactivate_inactive_user($uidNumber) { 
    45                  
    46                 $sql = "select * from phpgw_access_log where account_id=$uidNumber order by li desc limit 1"; 
    47          
    48                 $this->db->query($sql); 
    49                 $this->db->next_record(); 
    50                 $linha = $this->db->row(); 
    51                 if(count($linha)>0) { 
    52                         $sql = "insert into phpgw_access_log (sessionid,loginid,ip,li,lo,account_id) values ('expirescontrol','".$linha["loginid"]."','0.0.0.0','".time()."','0','".$linha["account_id"]."')"; 
    53                          
    54                         $this->db->query($sql); 
    55                 } 
    56         } 
    57          
    58         function insert_log_inactive_user_control($uid,$uidNumber) { 
    59                         $sql = "insert into phpgw_access_log (sessionid,loginid,ip,li,lo,account_id) values ('expirescontrol','".$uid."','0.0.0.0','".time()."','0','".$uidNumber."')"; 
    60                          
    61                         $this->db->query($sql); 
    62         } 
    63  
    64         function copy_manager($params) 
    65         { 
    66                 $manager = $params['manager']; 
    67                 $new_manager = $params['new_manager']; 
    68                 $manager_info = $this->read_acl($manager); 
    69                  
    70                 //Escrevre no Banco a ACL do gerente 
    71                 $sql = "INSERT INTO phpgw_expressoadmin (manager_lid, context, acl) " 
    72                 . "VALUES('" . $new_manager . "','" . $manager_info[0]['context'] . "','" . $manager_info[0]['acl'] . "')"; 
    73                  
    74                 if (!$this->db->query($sql)) 
    75                 { 
    76                         echo lang('error in') . 'copy_manager: ' . pg_last_error(); 
    77                         return false; 
    78                 } 
    79                  
    80                 //Pesquisa no Banco e pega os valores dos apps. 
    81                 $sql = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $manager_info[0]['manager_lid'] . "' AND context = '" . $manager_info[0]['context'] . "'"; 
    82                 $this->db->query($sql); 
    83                 while($this->db->next_record()) 
    84                 { 
    85                         $aplications[] = $this->db->row(); 
    86                 } 
    87                  
    88                 //Escrevre no Banco as aplicações que o gerente tem direito de disponibilizar aos seus usuarios. 
    89                 for ($i=0; $i<count($aplications); $i++) 
    90                 { 
    91                         $sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) " 
    92                         . "VALUES('" . $new_manager . "','" . $manager_info[0]['context'] . "','" . $aplications[$i]['app'] . "')"; 
    93                         if (!$this->db->query($sql)) 
    94                         { 
    95                                 echo lang('error adding application to new manager') . ': '. pg_last_error(); 
    96                                 return false; 
    97                         } 
    98                 } 
    99                 return true; 
    100         } 
    101  
    102         function get_next_id($type) 
    103         { 
    104                 $return['status'] = true; 
    105                  
    106                 $current_config = $_SESSION['phpgw_info']['expresso']['expressoAdmin']; 
    107                  
    108                 if ($current_config['expressoAdmin_nextid_db_host'] != '') 
    109                 { 
    110                         $this->db->disconnect(); 
    111                         $host = $current_config['expressoAdmin_nextid_db_host']; 
    112                         $port = $current_config['expressoAdmin_nextid_db_port']; 
    113                         $name = $current_config['expressoAdmin_nextid_db_name']; 
    114                         $user = $current_config['expressoAdmin_nextid_db_user']; 
    115                         $pass = $current_config['expressoAdmin_nextid_db_password']; 
    116                          
    117                         $db = new db(); 
    118                         $db->Halt_On_Error = 'no'; 
    119                         $db->connect($name, $host, $port, $user, $pass, 'pgsql'); 
    120                 } 
    121                 else 
    122                 { 
    123                         $db = $this->db; 
    124                 } 
    125                  
    126                 // Busco o ID dos accounts 
    127                 $query_accounts_nextid = "SELECT id FROM phpgw_nextid WHERE appname = 'accounts'"; 
    128         if (!$db->query($query_accounts_nextid)) 
    129         { 
    130                 $return['status'] = false; 
    131                         $result['msg'] = lang('Problems running query on DB') . '.'; 
    132                         $db->disconnect(); 
    133                 return $return; 
    134         } 
    135         else 
    136         { 
    137                 $accounts_nextid = $db->Query_ID->fields[0]; 
    138         } 
    139                  
    140                 // Busco o ID dos groups 
    141                 $query_groups = "SELECT id FROM phpgw_nextid WHERE appname = 'groups'"; 
    142         if (!$db->query($query_groups)) 
    143         { 
    144                 $return['status'] = false; 
    145                         $result['msg'] = lang('Problems running query on DB') . '.'; 
    146                         $db->disconnect(); 
    147                 return $return; 
    148         } 
    149         else 
    150         { 
    151                 $groups_nextid = $db->Query_ID->fields[0]; 
    152         } 
    153  
    154                 //Retorna o maior dos ID's incrementado de 1 
    155                 if ($accounts_nextid >= $groups_nextid) 
    156                         $id = $accounts_nextid; 
    157                 else 
    158                         $id = $groups_nextid; 
    159                 $return['id'] = (int)($id + 1); 
    160                  
    161                  
    162                 // Atualizo o BD 
    163                 $query_update_id = "UPDATE phpgw_nextid set id = '" . $return['id'] . "' WHERE appname = '" . $type . "'"; 
    164                 if (!$db->query($query_update_id)) 
    165                 { 
    166                 $return['status'] = false; 
    167                         $result['msg'] = lang('Problems running query on DB') . '.'; 
    168                 } 
    169                 $db->disconnect(); 
    170                 return $return; 
    171         } 
    172          
    173         function add_user2group($gidnumber, $uidnumber) 
    174         { 
    175                 $query = "SELECT acl_location FROM phpgw_acl WHERE acl_appname = 'phpgw_group' AND acl_location = '" . $gidnumber . "' AND acl_account = '" . $uidnumber . "'"; 
    176                 if (!$this->db->query($query)) 
    177                 { 
    178                         $result['status'] = false; 
    179                         $result['msg'] = lang('Error on function') . " db_functions->add_user2group.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    180                         return $result; 
    181                 } 
    182                 while($this->db->next_record()) 
    183                         $user_in_group[] = $this->db->row(); 
    184                  
    185                 if (count($user_in_group) == 0) 
    186                 { 
    187                         $sql = "INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) " 
    188                         . "VALUES('phpgw_group','" . $gidnumber . "','" . $uidnumber . "','1')"; 
    189                         if (!$this->db->query($sql)) 
    190                         { 
    191                                 $result['status'] = false; 
    192                                 $result['msg'] = lang('Error on function') . " db_functions->add_user2group.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    193                                 return $result; 
    194                         } 
    195                 } 
    196                 $result['status'] = true; 
    197                 return $result; 
    198         } 
    199  
    200         function remove_user2group($gidnumber, $uidnumber) 
    201         { 
    202                 $query = "SELECT acl_location FROM phpgw_acl WHERE acl_appname = 'phpgw_group' AND acl_location = '" . $gidnumber . "' AND acl_account = '" . $uidnumber . "'"; 
    203                 if (!$this->db->query($query)) 
    204                 { 
    205                         $result['status'] = false; 
    206                         $result['msg'] = lang('Error on function') . " db_functions->remove_user2group.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    207                         return $result; 
    208                 } 
    209                 while($this->db->next_record()) 
    210                         $user_in_group[] = $this->db->row(); 
    211                  
    212                 if (count($user_in_group) > 0) 
    213                 { 
    214                         $sql = "DELETE FROM phpgw_acl WHERE acl_appname = 'phpgw_group' AND acl_location = '" . $gidnumber . "' AND acl_account = '".$uidnumber."'"; 
    215                         if (!$this->db->query($sql)) 
    216                         { 
    217                                 $result['status'] = false; 
    218                                 $result['msg'] = lang('Error on function') . " db_functions->remove_user2group.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    219                                 return $result; 
    220                         } 
    221                 } 
    222                 $result['status'] = true; 
    223                 return $result; 
    224         } 
    225  
    226         function add_pref_changepassword($uidnumber) 
    227         { 
    228                 $query = "SELECT * FROM phpgw_acl WHERE acl_appname = 'preferences' AND acl_location = 'changepassword' AND acl_account = '" . $uidnumber . "'"; 
    229                 if (!$this->db->query($query)) 
    230                 { 
    231                         $result['status'] = false; 
    232                         $result['msg'] = lang('Error on function') . " db_functions->add_pref_changepassword.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    233                         return $result; 
    234                 } 
    235                 while($this->db->next_record()) 
    236                         $user_pref_changepassword[] = $this->db->row(); 
    237                  
    238                 if (count($user_pref_changepassword) == 0) 
    239                 { 
    240                         $sql = "INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) " 
    241                         . "VALUES('preferences','changepassword','" . $uidnumber . "','1')"; 
    242                         if (!$this->db->query($sql)) 
    243                         { 
    244                                 $result['status'] = false; 
    245                                 $result['msg'] = lang('Error on function') . " db_functions->add_pref_changepassword.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    246                                 return $result; 
    247                         } 
    248                 } 
    249                 $result['status'] = true; 
    250                 return $result; 
    251         }        
    252  
    253         function remove_pref_changepassword($uidnumber) 
    254         { 
    255                 $query = "SELECT * FROM phpgw_acl WHERE acl_appname = 'preferences' AND acl_location = 'changepassword' AND acl_account = '" . $uidnumber . "'"; 
    256                 if (!$this->db->query($query)) 
    257                 { 
    258                         $result['status'] = false; 
    259                         $result['msg'] = lang('Error on function') . " db_functions->remove_pref_changepassword.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    260                         return $result; 
    261                 } 
    262                 while($this->db->next_record()) 
    263                         $user_pref_changepassword[] = $this->db->row(); 
    264                  
    265                 if (count($user_pref_changepassword) != 0) 
    266                 { 
    267                         $sql = "DELETE FROM phpgw_acl WHERE acl_appname = 'preferences' AND acl_location = 'changepassword' AND acl_account = '".$uidnumber."'"; 
    268                         if (!$this->db->query($sql)) 
    269                         { 
    270                                 $result['status'] = false; 
    271                                 $result['msg'] = lang('Error on function') . " db_functions->remove_pref_changepassword.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    272                                 return $result; 
    273                         } 
    274                 } 
    275                 $result['status'] = true; 
    276                 return $result; 
    277         }        
    278          
    279         function add_id2apps($id, $apps) 
    280         { 
    281                 $result['status'] = true; 
    282                 if ($apps) 
    283                 { 
    284                         foreach($apps as $app => $value) 
    285                         { 
    286                                 $query = "SELECT * FROM phpgw_acl WHERE acl_appname = '".$app."' AND acl_location = 'run' AND acl_account = '" . $id . "'"; 
    287                                 if (!$this->db->query($query)) 
    288                                 { 
    289                                         $result['status'] = false; 
    290                                         $result['msg'] = lang('Error on function') . " db_functions->add_id2apps.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    291                                         return $result; 
    292                                 } 
    293                                  
    294                                 while($this->db->next_record()) 
    295                                         $user_app[] = $this->db->row(); 
    296                                          
    297                                 if (count($user_app) == 0) 
    298                                 { 
    299                                         $sql = "INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) " 
    300                                         . "VALUES('".$app."','run','" . $id . "','1')"; 
    301                                                  
    302                                         if (!$this->db->query($sql)) 
    303                                         { 
    304                                                 $result['status'] = false; 
    305                                                 $result['msg'] = lang('Error on function') . " db_functions->add_id2apps.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    306                                                 return $result; 
    307                                         } 
    308                                         else 
    309                                         { 
    310                                                 $this->write_log("Added application","$id:$app");        
    311                                         } 
    312                                 } 
    313                         } 
    314                 } 
    315                 return $result; 
    316         } 
    317  
    318         function remove_id2apps($id, $apps) 
    319         { 
    320                 $result['status'] = true; 
    321                 if ($apps) 
    322                 { 
    323                         foreach($apps as $app => $value) 
    324                         { 
    325                                 $query = "SELECT acl_location FROM phpgw_acl WHERE acl_appname = '" . $app . "' AND acl_location = 'run' AND acl_account = '" . $id . "'"; 
    326                                  
    327                                 if (!$this->db->query($query)) 
    328                                 { 
    329                                         $result['status'] = false; 
    330                                         $result['msg'] = lang('Error on function') . " db_functions->remove_id2apps.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    331                                         return $result; 
    332                                 } 
    333                                 while($this->db->next_record()) 
    334                                         $user_in_group[] = $this->db->row(); 
    335                                  
    336                                 if (count($user_in_group) > 0) 
    337                                 { 
    338                                         $sql = "DELETE FROM phpgw_acl WHERE acl_appname = '" . $app . "' AND acl_location = 'run' AND acl_account = '".$id."'"; 
    339                                         if (!$this->db->query($sql)) 
    340                                         { 
    341                                                 $result['status'] = false; 
    342                                                 $result['msg'] = lang('Error on function') . " db_functions->remove_id2apps.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    343                                                 return $result; 
    344                                         } 
    345                                         else 
    346                                         { 
    347                                                 $this->write_log("Removed application from id","$id: $app");     
    348                                         } 
    349                                 } 
    350                         } 
    351                 } 
    352                 return $result; 
    353         } 
    354  
    355  
    356         function get_user_info($uidnumber) 
    357         { 
    358                 // Groups 
    359                 $query = "SELECT acl_location FROM phpgw_acl WHERE acl_appname = 'phpgw_group' AND acl_account = '".$uidnumber."'"; 
    360                 $this->db->query($query); 
    361                 while($this->db->next_record()) 
    362                         $user_app[] = $this->db->row(); 
    363                  
    364                 for ($i=0; $i<count($user_app); $i++) 
    365                         $return['groups'][] = $user_app[$i]['acl_location']; 
    366                  
    367                 // ChangePassword 
    368                 $query = "SELECT acl_rights FROM phpgw_acl WHERE acl_appname = 'preferences' AND acl_location = 'changepassword' AND acl_account = '".$uidnumber."'"; 
    369                 $this->db->query($query); 
    370                 while($this->db->next_record()) 
    371                         $changepassword[] = $this->db->row(); 
    372                 $return['changepassword'] = $changepassword[0]['acl_rights']; 
    373                  
    374                 // Apps 
    375                 $query = "SELECT acl_appname FROM phpgw_acl WHERE acl_account = '".$uidnumber."' AND acl_location = 'run'"; 
    376                 $this->db->query($query); 
    377                 while($this->db->next_record()) 
    378                         $user_apps[] = $this->db->row(); 
    379                          
    380                 if ($user_apps) 
    381                 {                        
    382                         foreach ($user_apps as $app) 
    383                         { 
    384                                 $return['apps'][$app['acl_appname']] = '1'; 
    385                         } 
    386                 } 
    387                  
    388                 return $return; 
    389         } 
    390          
    391         function get_group_info($gidnumber) 
    392         { 
    393                 // Apps 
    394                 $query = "SELECT acl_appname FROM phpgw_acl WHERE acl_account = '".$gidnumber."' AND acl_location = 'run'"; 
    395                 $this->db->query($query); 
    396                 while($this->db->next_record()) 
    397                         $group_apps[] = $this->db->row(); 
    398                  
    399                 if ($group_apps) 
    400                 {                        
    401                         foreach ($group_apps as $app) 
    402                         { 
    403                                 $return['apps'][$app['acl_appname']] = '1'; 
    404                         } 
    405                 } 
    406                  
    407                 // Members 
    408                 $query = "SELECT acl_account FROM phpgw_acl WHERE acl_appname = 'phpgw_group' AND acl_location = '" . $gidnumber . "'"; 
    409                  
    410                 $this->db->query($query); 
    411                 while($this->db->next_record()) 
    412                         $group_members[] = $this->db->row(); 
    413  
    414                 if ($group_members) 
    415                 { 
    416                         foreach ($group_members as $member) 
    417                         { 
    418                                 $return['members'][] = $member['acl_account']; 
    419                         } 
    420                 } 
    421                 else 
    422                         $return['members'] = array(); 
    423  
    424                 return $return; 
    425         } 
    426          
    427         function default_user_password_is_set($uid) 
    428         { 
    429                 $query = "SELECT uid FROM phpgw_expressoadmin_passwords WHERE uid = '" . $uid . "'"; 
    430                 $this->db->query($query); 
    431                 while($this->db->next_record()) 
    432                 { 
    433                         $userPassword[] = $this->db->row(); 
    434                 } 
    435                 if (count($userPassword) == 0) 
    436                         return false; 
    437                 else 
    438                         return true; 
    439         } 
    440          
    441         function set_user_password($uid, $password) 
    442         { 
    443                 $query = "SELECT uid FROM phpgw_expressoadmin_passwords WHERE uid = '" . $uid . "'"; 
    444                 $this->db->query($query); 
    445                 while($this->db->next_record()) 
    446                 { 
    447                         $user[] = $this->db->row(); 
    448                 } 
    449                 if (count($user) == 0) 
    450                 { 
    451                         $sql = "INSERT INTO phpgw_expressoadmin_passwords (uid, password) VALUES('".$uid."','".$password."')"; 
    452  
    453                         if (!$this->db->query($sql)) 
    454                         { 
    455                                 $result['status'] = false; 
    456                                 $result['msg'] = lang('Error on function') . " db_functions->set_user_password.\n" . lang('Server returns') . ': ' . pg_last_error(); 
    457                                 return $result; 
    458                         } 
    459                 } 
    460                 return true; 
    461         } 
    462          
    463         function get_user_password($uid) 
    464         { 
    465                 $query = "SELECT password FROM phpgw_expressoadmin_passwords WHERE uid = '" . $uid . "'"; 
    466                 $this->db->query($query); 
    467                 while($this->db->next_record()) 
    468                 { 
    469                         $userPassword[] = $this->db->row(); 
    470                 } 
    471                  
    472                 if (count($userPassword) == 1) 
    473                 { 
    474                         $sql = "DELETE FROM phpgw_expressoadmin_passwords WHERE uid = '" . $uid . "'"; 
    475                         $this->db->query($sql); 
    476                         return $userPassword[0]['password']; 
    477                 } 
    478                 else 
    479                         return false; 
    480         } 
    481          
    482         function delete_user($user_info) 
    483         { 
    484                 // AGENDA 
    485                 $this->db->query('SELECT cal_id FROM phpgw_cal WHERE owner ='.$user_info['uidnumber']); 
    486                 while($this->db->next_record()) 
    487                 { 
    488                         $ids[] = $this->db->row(); 
    489                 } 
    490                 if (count($ids)) 
    491                 { 
    492                         foreach($ids as $i => $id) 
    493                         { 
    494                                 $this->db->query('DELETE FROM phpgw_cal WHERE cal_id='.$id['cal_id']); 
    495                                 $this->db->query('DELETE FROM phpgw_cal_user WHERE cal_id='.$id['cal_id']); 
    496                                 $this->db->query('DELETE FROM phpgw_cal_repeats WHERE cal_id='.$id['cal_id']); 
    497                                 $this->db->query('DELETE FROM phpgw_cal_extra WHERE cal_id='.$id['cal_id']); 
    498                         } 
    499                 } 
    500                  
    501                 // CONTATOS pessoais e grupos. 
    502                 $this->db->query('SELECT id_contact FROM phpgw_cc_contact WHERE id_owner ='.$user_info['uidnumber']); 
    503                 while($this->db->next_record()) 
    504                 { 
    505                         $ids[] = $this->db->row(); 
    506                 } 
    507  
    508                 if (count($ids)) 
    509                 { 
    510                         foreach($ids as $i => $id_contact) 
    511                         { 
    512                                 $this->db->query('SELECT id_connection FROM phpgw_cc_contact_conns WHERE id_contact='.$id_contact['id_contact']); 
    513                                 while($this->db->next_record()) 
    514                                 { 
    515                                         $id_conns[] = $this->db->row(); 
    516                                 } 
    517                                 if (count($id_conns)) 
    518                                 { 
    519                                         foreach($id_conns as $j => $id_conn) 
    520                                         { 
    521                                                 $this->db->query('DELETE FROM phpgw_cc_connections WHERE id_connection='.$id_conn['id_connection']); 
    522                                                 $this->db->query('DELETE FROM phpgw_cc_contact_grps WHERE id_connection='.$id_conn['id_connection']); 
    523                                         } 
    524                                 } 
    525                                          
    526                                 $this->db->query('SELECT id_address FROM phpgw_cc_contact_addrs WHERE id_contact='.$id_contact['id_contact']); 
    527                                 while($this->db->next_record()) 
    528                                 { 
    529                                         $id_addresses[] = $$this->db->row(); 
    530                                 } 
    531                                 if (count($id_addresses)) 
    532                                 { 
    533                                         foreach($id_addresses as $j => $id_addrs) 
    534                                         { 
    535                                                 $this->db->query('DELETE FROM phpgw_cc_addresses WHERE id_address='.$id_addrs['id_address']); 
    536                                         } 
    537                                 } 
    538                                 $this->db->query('DELETE FROM phpgw_cc_contact WHERE id_contact='.$id_contact['id_contact']); 
    539                                 $this->db->query('DELETE FROM phpgw_cc_contact_conns WHERE id_contact='.$id_contact['id_contact']); 
    540                                 $this->db->query('DELETE FROM phpgw_cc_contact_addrs WHERE id_contact='.$id_contact['id_contact']); 
    541                         } 
    542                 } 
    543                 $this->db->query('DELETE FROM phpgw_cc_groups WHERE owner='.$user_info['uidnumber']); 
    544                          
    545                 // PREFERENCIAS 
    546                 $this->db->query('DELETE FROM phpgw_preferences WHERE preference_owner='.$user_info['uidnumber']); 
    547                          
    548                 // ACL 
    549                 $this->db->query('DELETE FROM phpgw_acl WHERE acl_account='.$user_info['uidnumber']); 
    550                  
    551                 // Corrigir 
    552                 $return['status'] = true; 
    553                 return $return; 
    554         } 
    555  
    556         function delete_group($gidnumber) 
    557         { 
    558                 // ACL 
    559                 $this->db->query('DELETE FROM phpgw_acl WHERE acl_location='.$gidnumber); 
    560                 $this->db->query('DELETE FROM phpgw_acl WHERE acl_account='.$gidnumber); 
    561                  
    562                 // Corrigir 
    563                 $return['status'] = true; 
    564                 return $return; 
    565         } 
    566          
    567         function write_log($action, $about) 
    568         { 
    569                 $sql = "INSERT INTO phpgw_expressoadmin_log (date, manager, action, userinfo) " 
    570                 . "VALUES('now','" . $_SESSION['phpgw_info']['expresso']['user']['account_lid'] . "','" . strtolower($action) . "','" . strtolower($about) . "')"; 
    571                  
    572                 if (!$this->db->query($sql)) 
    573                 { 
    574                         //echo pg_last_error(); 
    575                         return false; 
    576         } 
    577          
    578                 return true; 
    579         } 
    580          
    581         function get_sieve_info() 
    582         { 
    583                 $this->db->query('SELECT profileID,imapenablesieve,imapsieveserver,imapsieveport FROM phpgw_emailadmin'); 
    584                  
    585                 $i=0; 
    586                 while($this->db->next_record()) 
    587                 { 
    588                         $serverList[$i]['profileID']            = $this->db->f(0); 
    589                         $serverList[$i]['imapenablesieve']      = $this->db->f(1); 
    590                         $serverList[$i]['imapsieveserver']      = $this->db->f(2); 
    591                         $serverList[$i]['imapsieveport']        = $this->db->f(3); 
    592                         $i++; 
    593                 } 
    594                  
    595                 return $serverList; 
    596         } 
    597          
    598         function get_apps($account_lid) 
    599         { 
    600                 $this->db->query("SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '".$account_lid."'"); 
    601                  
    602                 while($this->db->next_record()) 
    603                 { 
    604                         $tmp = $this->db->row(); 
    605                         $availableApps[$tmp['app']] = 'run';  
    606                 } 
    607                          
    608                 return $availableApps; 
    609         } 
    610          
    611         function get_sambadomains_list() 
    612         { 
    613                 $query = "SELECT * FROM phpgw_expressoadmin_samba ORDER by samba_domain_name ASC";  
    614                 $this->db->query($query); 
    615                 while($this->db->next_record()) 
    616                         $result[] = $this->db->row(); 
    617                 return $result; 
    618         } 
    619          
    620         function exist_domain_name_sid($sambadomainname, $sambasid) 
    621         { 
    622                 $query = "SELECT * FROM phpgw_expressoadmin_samba WHERE samba_domain_name='$sambadomainname' OR samba_domain_sid='$sambasid'";  
    623                 $this->db->query($query); 
    624                 while($this->db->next_record()) 
    625                         $result[] = $this->db->row(); 
    626                  
    627                 if (count($result) > 0) 
    628                         return true; 
    629                 else 
    630                         return false; 
    631         } 
    632          
    633         function delete_sambadomain($sambadomainname) 
    634         { 
    635                 $this->db->query("DELETE FROM phpgw_expressoadmin_samba WHERE samba_domain_name='$sambadomainname'"); 
    636                 return; 
    637         } 
    638          
    639         function add_sambadomain($sambadomainname, $sambasid) 
    640         { 
    641                 $sql = "INSERT INTO phpgw_expressoadmin_samba (samba_domain_name, samba_domain_sid) VALUES('$sambadomainname','$sambasid')"; 
    642                 $this->db->query($sql); 
    643                 return; 
    644         } 
    645          
    646         function test_db_connection($params) 
    647         { 
    648                 $host = $params['host']; 
    649                 $port = $params['port']; 
    650                 $name = $params['name']; 
    651                 $user = $params['user']; 
    652                 $pass = $params['pass']; 
    653                  
    654                 $con_string = "host=$host port=$port dbname=$name user=$user password=$pass"; 
    655                 if ($db = pg_connect($con_string)) 
    656                 { 
    657                         pg_close($db); 
    658                         $result['status'] = true; 
    659                 } 
    660                 else 
    661                 { 
    662                         $result['status'] = false; 
    663                 } 
    664                          
    665                 return $result; 
    666         } 
    667          
    668         function manager_lid_exist($manager_lid) 
    669         { 
    670                 $query = "SELECT manager_lid FROM phpgw_expressoadmin WHERE manager_lid = '" . $manager_lid . "'"; 
    671                 $this->db->query($query); 
    672                 while($this->db->next_record()) 
    673                         $result[] = $this->db->row(); 
    674                 if (count($result) > 0) 
    675                         return true; 
    676                 else 
    677                         return false; 
    678         } 
    679          
    680         function create_manager($params, $manager_acl) 
    681         { 
    682                 //Escrevre no Banco a ACL do gerente 
    683                 $sql = "INSERT INTO phpgw_expressoadmin (manager_lid, context, acl) " 
    684                 . "VALUES('" . $params['ea_select_manager'] . "','" . $params['context'] . "','" . $manager_acl . "')"; 
    685                 $this->db->query($sql); 
    686                          
    687                 //Escrevre no Banco as aplicações que o gerente tem direito de disponibilizar aos seus usuarios. 
    688                 if (count($_POST['applications_list'])) 
    689                 { 
    690                         foreach($_POST['applications_list'] as $app=>$value) 
    691                         { 
    692                                 $sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) " 
    693                                 . "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $app . "')"; 
    694                                 $this->db->query($sql); 
    695                         } 
    696                 } 
    697                  
    698                 return; 
    699         } 
    700          
    701         function save_manager($params, $manager_acl) 
    702         { 
    703                 $params['manager_lid'] = $params['hidden_manager_lid']; 
    704                  
    705                 //Executa update na tabela para atualizar ACL 
    706                 $sql = "UPDATE phpgw_expressoadmin SET context = '" . $params['context'] . "',acl = '" . $manager_acl 
    707                 . "' WHERE manager_lid = '" . $params['manager_lid'] ."'"; 
    708                 $this->db->query($sql); 
    709                          
    710                 //Deleta as aplicações e adiciona as novas. 
    711                 //Deleta 
    712                 $sql = "DELETE FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $params['manager_lid'] . "'"; 
    713                 $this->db->query($sql); 
    714                                          
    715                 // Adiciona 
    716                 if (count($params['applications_list'])) 
    717                 { 
    718                         foreach($params['applications_list'] as $app=>$value) 
    719                         { 
    720                                 $sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) " 
    721                                 . "VALUES('" . $params['manager_lid'] . "','" . $params['context'] . "','" . $app . "')"; 
    722                                 $this->db->query($sql); 
    723                         } 
    724                 } 
    725                          
    726                 return; 
    727         } 
    728          
    72941} 
    73042?> 
Note: See TracChangeset for help on using the changeset viewer.