Changeset 6848 for trunk/expressoMail1_2/inc/class.imap_functions.inc.php
- Timestamp:
- 07/23/12 14:28:41 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r6818 r6848 4281 4281 { 4282 4282 $this->ldap = new ldap_functions(); 4283 4284 $return = array();4285 4283 $mbox_stream = $this->open_mbox(); 4286 4284 $mbox_acl = imap_getacl($mbox_stream, 'INBOX'); 4287 4285 4288 $i = 0; 4286 $oldAcls = array('d' , 'c' , 'a'); 4287 $newAcls = array('xte','ik', ''); 4288 4289 $return = array(); 4289 4290 foreach ($mbox_acl as $user => $acl) 4290 4291 { 4291 if ($user != $this->username) 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']) 4292 4317 { 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) 4318 unset($old_users[$user]); 4319 unset($new_users[$user]); 4320 } 4321 } 4322 4323 foreach ($new_users as $user => $value) 4309 4324 { 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) 4327 4340 { 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 4356 4353 4357 4354 return true; 4358 4355 } 4359 4356 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 }4389 4357 4390 4358 function getacltouser($user, $decode = false) … … 4408 4376 else 4409 4377 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 else4438 return true;4439 4378 } 4440 4379
Note: See TracChangeset
for help on using the changeset viewer.