Projeto

Geral

Perfil

fix_logs_expressoAdmin.patch

Mauricio Luiz Viani, 22/12/2019 21:58 h

Baixar (5,79 KB)

Ver diferenças:

/tmp/expressoAdmin1_2/inc/class.shared_accounts.inc.php 2019-11-29 13:29:45.000000000 -0300
12 12
include_once('class.functions.inc.php');
13 13
include_once('class.ldap_functions.inc.php');
14 14
include_once('class.imap.inc.php');
15
include_once('class.db_functions.inc.php');
15 16
include_once(PHPGW_API_INC.'/class.aclmanagers.inc.php');
16 17
class shared_accounts
17 18
{
18 19
       var $functions;
19 20
       var $ldap_functions;
21
       var $db_functions;
20 22
       var $boemailadmin       = null;
21 23
       var $imap                       = null;
......
26 28
               $this->ldap_functions   = new ldap_functions;
27 29
               $this->functions                = new functions;
28 30
               $this->boemailadmin             = CreateObject('emailadmin.bo');
31
               $this->db_functions = new db_functions;
29 32
       }
30 33
       private function get_imap( $_profile, $_user)
......
99 103
                                       {
100 104
                                       if( isset($params['owners_acl']) && count($params['owners_acl']) > 0 )
101 105
                                       {
102
                                               $_result['status'] &= $this->setACLMailbox( $_imap, $params, "SAVE" );
106
                                               $_result['status'] &= $this->setACLMailbox( $_imap, $params, "SAVE", $params['uid'] );
103 107
                                       }
104 108
                                   }
105 109
                                   else
106 110
                                   {
107
                                       $_result['status'] &= $this->setACLMailbox( $_imap, array( "owners_acl" => "", "uid" => $params['uid'] ), "SAVE" );
111
                                       $_result['status'] &= $this->setACLMailbox( $_imap, array( "owners_acl" => "", "uid" => $params['uid'] ), "SAVE", $params['uid'] );
112

  
108 113
                                   }
109 114
                           }
110 115
                           else
......
132 137
                               $_result['status'] &= $_imap->create_mailbox( 'INBOX' . $_profile['imapDelimiter'] . $_profile['imapDefaultSentFolder'] );
138
                               $this->db_functions->write_log( 'created shared account',  $params['uid'] );
139

  
140

  
133 141
                               if( isset($params['owners_acl']) && count($params['owners_acl']) > 0 )
134 142
                               {
135
                                       $_result['status'] &= $this->setACLMailbox( $_imap, $params['owners_acl'], "CREATE" );
143
                                       $_result['status'] &= $this->setACLMailbox( $_imap, $params['owners_acl'], "CREATE", $params['uid'] );
144

  
136 145
                               }
137 146
                           }
138 147
                           else
......
147 156
               return $_result;
148 157
       }
149
       private function setACLMailbox( $imap, $params, $type )
158
       private function setACLMailbox( $imap, $params, $type, $uid )
150 159
       {
160

  
151 161
               $_result = true;
152 162
               $owners_acl = ( isset( $params['owners_acl'] ) ? $params['owners_acl'] : $params );
......
158 168
                       foreach( $owners_acl as $value )
159 169
                       {
160 170
                               $_result &= $imap->set_acl( 'INBOX', array( trim($value['user']) => trim($value['acl']) ) );
171
                                $this->db_functions->write_log( 'created: acl shared account',$uid.": ".trim($value['user'])."=>".trim($value['acl'])  );
172

  
161 173
                       }
162 174
               }
163 175
               else
......
181 193
                               foreach( $_acls_remove as $owner => $acl )
182 194
                               {
183 195
                                       $_result &= $imap->set_acl( 'INBOX', array( trim($owner) => '' ) );
196
                                       $this->db_functions->write_log( 'removed: acl shared account',$uid.": ".trim($owner)."=>".trim($acl)  );
184 197
                               }
185 198
                               /* Add ACLs */
186 199
                               foreach( $_acls_new as $owner => $acl )
187 200
                               {
188 201
                                       $_result &= $imap->set_acl( 'INBOX', array( trim($owner) => trim($acl) ) );
202
                                        $this->db_functions->write_log( 'added: acl shared account',$uid.": ".trim($owner)."=>".trim($acl)  );
189 203
                               }
190 204
                       }
191 205
                       else
......
197 211
                               foreach( $_acls_old as $owner => $acl )
198 212
                               {
199 213
                                       $_result &= $imap->set_acl( 'INBOX', array( trim($owner) => '' ) );
214
                                        $this->db_functions->write_log( 'removed: acl shared account',$uid.": ".trim($owner)."=>".trim($acl)  );
200 215
                               }
201 216
                               /* Add ACL only owner*/
......
297 314
               $_result        = $this->ldap_functions->delete_shared_account_data($params);
298
               if( $_result['status'] ){ $_result['status'] &= $_imap->delete_inbox(); }
315
               if( $_result['status'] )
316
               {
317
                       $_result['status'] &= $_imap->delete_inbox();
318
                       $this->db_functions->write_log( 'deleted shared account',  $params['uid'] );
319
               }
299 320
               return $_result;
300 321
           }
......
341 362
                       try
342 363
                       {
343 364
                               $_imap = $this->get_imap( $_profile, $_uid );
344

  
345 365
                               $_imap->empty_inbox();
366
                               $this->db_functions->write_log("inbox emptied", $params['uid']);
346 367
                       }
347 368
                       catch( Exception $e )
348 369
                       {