Ignore:
Timestamp:
07/24/12 10:24:52 (12 years ago)
Author:
eduardow
Message:

Ticket #2978 - Dificuldade no mapeamento de ACLs para ações de pastas compartilhadas.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/expressoMail1_2/inc/class.imap_functions.inc.php

    r6840 r6859  
    42814281        { 
    42824282                $this->ldap = new ldap_functions(); 
    4283  
    4284                 $return = array(); 
    42854283                $mbox_stream = $this->open_mbox(); 
    42864284                $mbox_acl = imap_getacl($mbox_stream, 'INBOX'); 
    42874285 
    4288                 $i = 0; 
     4286                $oldAcls = array('d' , 'c' , 'a');  
     4287        $newAcls = array('xte','ik', '');  
     4288 
     4289        $return = array();  
    42894290                foreach ($mbox_acl as $user => $acl) 
    42904291                { 
    4291                         if ($user != $this->username) 
    4292                         { 
    4293                                 $return[$i]['uid'] = $user; 
    4294                                 $return[$i]['cn'] = $this->ldap->uid2cn($user); 
    4295                         } 
    4296                         $i++; 
    4297                 } 
    4298                 return $return; 
    4299         } 
    4300  
    4301         function setacl($params) 
    4302         { 
    4303                 $old_users = $this->getacl(); 
    4304                 if (!count($old_users)) 
    4305                         $old_users = array(); 
    4306  
    4307                 $tmp_array = array(); 
    4308                 foreach ($old_users as $index => $user_info) 
     4292                                if($user == $this->username)   
     4293                            continue;  
     4294 
     4295                    //Compatibiliza acls no padrão antigo para o novo  
     4296                    $acl = str_replace($oldAcls, $oldAcls, $acl);  
     4297 
     4298                    $return[$user] = array(  
     4299                                    'cn' => $this->ldap->uid2cn($user) ,  
     4300                                    'acls' => $acl  
     4301                                    );  
     4302            }  
     4303            return $return;  
     4304    }  
     4305 
     4306    function setacl($params)  
     4307    {  
     4308            $old_users = $this->getacl();  
     4309            $new_users = unserialize($params['acls']);  
     4310 
     4311            $mbox_stream = $this->open_mbox();  
     4312            $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}";  
     4313            $mailboxes_list = imap_getmailboxes($mbox_stream, $serverString, "user".$this->imap_delimiter.$this->username."*");                  
     4314 
     4315            foreach ($new_users as $user => $value) {  
     4316                    if(isset($old_users[$user]) && $value['acls'] == $old_users[$user]['acls']) 
     4317                                        { 
     4318                                                        unset($old_users[$user]);  
     4319                            unset($new_users[$user]);  
     4320                    }  
     4321            }  
     4322 
     4323            foreach ($new_users as $user => $value) 
    43094324                { 
    4310                         $tmp_array[$index] = $user_info['uid']; 
    4311                 } 
    4312                 $old_users = $tmp_array; 
    4313  
    4314                 $users = unserialize($params['users']); 
    4315                 if (!count($users)) 
    4316                         $users = array(); 
    4317  
    4318                 //$add_share = array_diff($users, $old_users); 
    4319                 $remove_share = array_diff($old_users, $users); 
    4320  
    4321                 $mbox_stream = $this->open_mbox(); 
    4322  
    4323                 $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"; 
    4324                 $mailboxes_list = imap_getmailboxes($mbox_stream, $serverString, "user".$this->imap_delimiter.$this->username."*"); 
    4325  
    4326                 /*if (count($add_share)) 
     4325                        if (is_array($mailboxes_list))  
     4326            {  
     4327                foreach ($mailboxes_list as $key => $val)  
     4328                {  
     4329                    $folder = str_replace($serverString, "", imap_utf7_decode($val->name));  
     4330                    $folder = str_replace("&-", "&", $folder);  
     4331                    imap_setacl ($mbox_stream, $folder, "$user", $value['acls']);  
     4332 
     4333                }  
     4334            }  
     4335            if(isset($old_users[$user]))  
     4336                    unset($old_users[$user]);  
     4337            }  
     4338 
     4339            foreach ($old_users as $user => $value) 
    43274340                { 
    4328                         foreach ($add_share as $index=>$uid) 
    4329                         { 
    4330                         if (is_array($mailboxes_list)) 
    4331                         { 
    4332                         foreach ($mailboxes_list as $key => $val) 
    4333                         { 
    4334                         $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 
    4335                                                 imap_setacl ($mbox_stream, $folder, "$uid", "lrswipcda"); 
    4336                         } 
    4337                         } 
    4338                         } 
    4339                 }*/ 
    4340  
    4341                 if (count($remove_share)) 
    4342                 { 
    4343                         foreach ($remove_share as $index=>$uid) 
    4344                         { 
    4345                             if (is_array($mailboxes_list)) 
    4346                             { 
    4347                                 foreach ($mailboxes_list as $key => $val) 
    4348                                 { 
    4349                                     $folder = str_replace($serverString, "", imap_utf7_decode($val->name)); 
    4350                                     $folder = str_replace("&-", "&", $folder); 
    4351                                     imap_setacl ($mbox_stream, $folder, "$uid", ""); 
    4352                                 } 
    4353                             } 
    4354                         } 
    4355                 } 
     4341                        if (is_array($mailboxes_list))  
     4342            {  
     4343                foreach ($mailboxes_list as $key => $val)  
     4344                {  
     4345                    $folder = str_replace($serverString, "", imap_utf7_decode($val->name));  
     4346                    $folder = str_replace("&-", "&", $folder);  
     4347                    imap_setacl ($mbox_stream, $folder, "$user", "");  
     4348 
     4349                }  
     4350            }  
     4351            }  
     4352 
    43564353 
    43574354                return true; 
    43584355        } 
    43594356 
    4360         function getaclfromuser($params) 
    4361         { 
    4362                 $useracl = $params['user']; 
    4363                 $return = array(); 
    4364                 $mbox_stream = $this->open_mbox(); 
    4365                 if($params['getShared']){                
    4366                          $mbox_acl = imap_getacl($mbox_stream, 'user'.$this->imap_delimiter.$useracl);           
    4367                         foreach ($mbox_acl as $user => $acl) 
    4368                         { 
    4369                                 if (($user == $this->username) && ($user != $useracl)) 
    4370                                 { 
    4371                                         $return[$useracl] = $acl; 
    4372                                 } 
    4373                         }                         
    4374                 }else {  
    4375                         $mbox_acl = imap_getacl($mbox_stream, 'INBOX'); 
    4376                         foreach ($mbox_acl as $user => $acl) 
    4377                         { 
    4378                                 if (($user != $this->username) && ($user == $useracl)) 
    4379                                 { 
    4380                                         $return[$user] = $acl; 
    4381                                 } 
    4382                         } 
    4383                 } 
    4384                 if(count($return) == 0) 
    4385                                 $return[$useracl] = 'false'; 
    4386                                  
    4387                 return $return; 
    4388         } 
    43894357 
    43904358        function getacltouser($user, $decode = false) 
     
    44084376                else  
    44094377                    return ''; 
    4410         } 
    4411  
    4412  
    4413         function setaclfromuser($params) 
    4414         { 
    4415                 $user = $params['user']; 
    4416                 $acl = $params['acl']; 
    4417  
    4418                 $mbox_stream = $this->open_mbox(); 
    4419  
    4420                 $serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"; 
    4421                 $mailboxes_list = imap_getmailboxes($mbox_stream, $serverString, "user".$this->imap_delimiter.$this->username."*"); 
    4422  
    4423                 if (is_array($mailboxes_list)) 
    4424                 { 
    4425                         foreach ($mailboxes_list as $key => $val) 
    4426                         { 
    4427                                 $folder = str_replace($serverString, "", imap_utf7_encode($val->name)); 
    4428                                 $folder = str_replace("&-", "&", $folder); 
    4429                                 if (!imap_setacl ($mbox_stream, $folder, $user, $acl)) 
    4430                                 { 
    4431                                         $return = imap_last_error(); 
    4432                                 } 
    4433                         } 
    4434                 } 
    4435                 if (isset($return)) 
    4436                         return $return; 
    4437                 else 
    4438                         return true; 
    44394378        } 
    44404379 
Note: See TracChangeset for help on using the changeset viewer.