[debian-edu-commits] debian-edu/upstream/ 01/02: fix indentations, provide comment block for class_groupMail.inc
Mike Gabriel
sunweaver at debian.org
Thu Aug 27 10:18:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
sunweaver pushed a commit to branch master
in repository gosa-plugin-mailaddress.
commit 4df0a5be96a366abb04a69738fd1de3ad574310b
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Thu Aug 27 12:14:33 2015 +0200
fix indentations, provide comment block for class_groupMail.inc
---
admin/groups/mailaddress/class_groupMail.inc | 750 ++++++++++++++-------------
personal/mailaddress/class_mailAccount.inc | 671 ++++++++++++------------
2 files changed, 706 insertions(+), 715 deletions(-)
diff --git a/admin/groups/mailaddress/class_groupMail.inc b/admin/groups/mailaddress/class_groupMail.inc
index 9f30f7c..e95ff5e 100644
--- a/admin/groups/mailaddress/class_groupMail.inc
+++ b/admin/groups/mailaddress/class_groupMail.inc
@@ -1,61 +1,102 @@
<?php
-
-class mailgroup extends plugin
-{
+/*!
+ \brief mail plugin
+ \author Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+ \version 0.99.4
+ \date 2015.08.27
+
+ This class provides basic information on mail accounts. This plugin
+ has been derived from gosa-plugin-mail, but it is not used to
+ actually control mailservers. It is only used for allowing
+ mail information to be stored in LDAP.
+
+ This plugin actually breaks gosa-mail-account and is intended to be a
+ drop-in replacement for it in situations where it is only necessary
+ to store information in inetOrgPerson''s mail LDAP attribute description.
+
+Functions :
+
+ - mailgroup (&$config, $dn=NULL, $base_object=NULL)
+ - execute ()
+ - remove_from_parent ()
+ - save_object ()
+ - save ()
+ - check ()
+ - adapt_from_template ($dn,$skip=array())
+ - make_name ($attrs)
+ - getCopyDialog ()
+ - saveCopyDialog ()
+ - PrepareForCopyPaste ($source)
+ - plInfo ()
+ - multiple_execute ()
+ - init_multiple_support ($attrs,$all)
+ - multiple_save_object ()
+ - multiple_check ()
+ - get_multi_edit_values ()
+ - set_multi_edit_values ($attrs)
+ - addForwarder ($address)
+ - delForwarder ($addresses)
+ - addAlternate ($address)
+ - delAlternate ($addresses)
+
+ */
+class mailgroup extends plugin {
/* Multiple edit */
- var $gosaMailForwardingAddress_Some = array(); // Used in multiple edit
-
+ var $gosaMailForwardingAddress_Some=array ();
+ // Used in multiple edit
/* Default values */
- var $mail = ""; // Default mail address
- var $gosaMailAlternateAddress = array(); // Set default Alternate Mail Adresses to empty array
- var $gosaMailForwardingAddress = array(); // Forwarding also empty
+ var $mail="";
+ // Default mail address
+ var $gosaMailAlternateAddress=array ();
+ // Set default Alternate Mail Adresses to empty array
+ var $gosaMailForwardingAddress=array ();
+ // Forwarding also empty
/* Internal */
- var $view_logged = FALSE;
+ var $view_logged=FALSE;
/* GOsa mail account attributes filled with dummy values,
* required due to gosaMailAccount objectclass requirements.
*/
- var $gosaMailServer = "NULL";
- var $gosaMailDeliveryMode = "[ ]"; //
-
+ var $gosaMailServer="NULL";
+ var $gosaMailDeliveryMode="[ ]";
+ //
/* attribute list for save action */
- var $attributes= array( "mail", "gosaMailServer", "gosaMailDeliveryMode",
- "gosaMailAlternateAddress", "gosaMailForwardingAddress");
-
- var $objectclasses= array("gosaMailAccount");
- var $multiple_support = TRUE; // Not tested yet
+ var $attributes=array ("mail","gosaMailServer","gosaMailDeliveryMode","gosaMailAlternateAddress","gosaMailForwardingAddress");
- var $uid = "";
- var $cn ="";
+ var $objectclasses=array ("gosaMailAccount");
+ var $multiple_support=TRUE;
+ // Not tested yet
+ var $uid="";
+ var $cn="";
- function __construct (&$config, $dn= NULL, $base_object= NULL)
- {
- plugin::plugin($config, $dn);
+ function __construct (&$config,$dn=NULL,$base_object=NULL) {
+ plugin::plugin ($config,$dn);
/* Get attributes from parent object
*/
- foreach(array("uid","cn") as $attr){
- if(isset($this->parent->by_object['group']) && isset($this->parent->by_object['group']->$attr)){
- $this->$attr = $this->parent->by_object['group']->$attr;
- }elseif(isset($this->attrs[$attr])){
- $this->$attr = $this->attrs[$attr][0];
+ foreach (array ("uid","cn") as $attr) {
+ if (isset ($this->parent->by_object['group'])&&isset ($this->parent->by_object['group']->$attr)) {
+ $this->$attr=$this->parent->by_object['group']->$attr;
+ }
+ elseif (isset ($this->attrs[$attr])) {
+ $this->$attr=$this->attrs[$attr][0];
}
}
/* Remember account status
*/
- $this->initially_was_account = $this->is_account;
+ $this->initially_was_account=$this->is_account;
/* Initialize configured values
*/
- if($this->is_account){
+ if ($this->is_account) {
/* Load attributes containing arrays */
- foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
- $this->$val= array();
- if (isset($this->attrs["$val"]["count"])){
- for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
- array_push($this->$val, $this->attrs["$val"][$i]);
+ foreach (array ("gosaMailAlternateAddress","gosaMailForwardingAddress") as $val) {
+ $this->$val=array ();
+ if (isset ($this->attrs["$val"]["count"])) {
+ for ($i=0;$i<$this->attrs["$val"]["count"];$i++) {
+ array_push ($this->$val,$this->attrs["$val"][$i]);
}
}
}
@@ -63,34 +104,35 @@ class mailgroup extends plugin
}
- function execute()
- {
+ function execute () {
/* Call parent execute */
- plugin::execute();
+ plugin::execute ();
/* Log view */
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","groups/".get_class($this),$this->dn);
+ if ($this->is_account&&!$this->view_logged) {
+ $this->view_logged=TRUE;
+ new log ("view","groups/".get_class ($this),$this->dn);
}
/****************
Account status
****************/
- if(!$this->multiple_support_active){
+ if (!$this->multiple_support_active) {
- if(isset($_POST['modify_state'])){
- if($this->is_account && $this->acl_is_removeable()){
- $this->is_account= FALSE;
- }elseif(!$this->is_account && $this->acl_is_createable()){
- $this->is_account= TRUE;
+ if (isset ($_POST['modify_state'])) {
+ if ($this->is_account&&$this->acl_is_removeable ()) {
+ $this->is_account=FALSE;
+ }
+ elseif (!$this->is_account&&$this->acl_is_createable ()) {
+ $this->is_account=TRUE;
}
}
- if ($this->is_account){
- $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::featuresEnabled(_("Mail")));
- } else {
- $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::featuresDisabled(_("Mail")));
+ if ($this->is_account) {
+ $display=$this->show_disable_header (msgPool::removeFeaturesButton (_ ("Mail")),msgPool::featuresEnabled (_ ("Mail")));
+ }
+ else {
+ $display=$this->show_disable_header (msgPool::addFeaturesButton (_ ("Mail")),msgPool::featuresDisabled (_ ("Mail")));
return ($display);
}
}
@@ -99,68 +141,70 @@ class mailgroup extends plugin
Forward addresses
****************/
- if (isset($_POST['mailAddressSelect_cancel'])){
- $this->mailAddressSelect= FALSE;
- $this->dialog= FALSE;
+ if (isset ($_POST['mailAddressSelect_cancel'])) {
+ $this->mailAddressSelect=FALSE;
+ $this->dialog=FALSE;
}
- if (isset($_POST['mailAddressSelect_save'])){
- if($this->acl_is_writeable("gosaMailForwardingAddress")){
- $list = $this->mailAddressSelect->save();
- foreach ($list as $entry){
- $val = $entry['mail'][0];
- if (!in_array_strict($val, $this->gosaMailAlternateAddress) && $val != $this->mail){
- $this->addForwarder($val);
- $this->is_modified= TRUE;
+ if (isset ($_POST['mailAddressSelect_save'])) {
+ if ($this->acl_is_writeable ("gosaMailForwardingAddress")) {
+ $list=$this->mailAddressSelect->save ();
+ foreach ($list as $entry) {
+ $val=$entry['mail'][0];
+ if (!in_array_strict ($val,$this->gosaMailAlternateAddress)&&$val!=$this->mail) {
+ $this->addForwarder ($val);
+ $this->is_modified=TRUE;
}
}
- $this->mailAddressSelect= FALSE;
- $this->dialog= FALSE;
- } else {
- msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
+ $this->mailAddressSelect=FALSE;
+ $this->dialog=FALSE;
+ }
+ else {
+ msg_dialog::display (_ ("Error"),_ ("Please select an entry!"),ERROR_DIALOG);
}
}
- if($this->mailAddressSelect instanceOf mailAddressSelect){
- $used = array();
- $used['mail'] = array_values($this->gosaMailAlternateAddress);
- $used['mail'] = array_merge($used['mail'], array_values($this->gosaMailForwardingAddress));
- $used['mail'][] = $this->mail;
+ if ($this->mailAddressSelect instanceOf mailAddressSelect) {
+ $used=array ();
+ $used['mail']=array_values ($this->gosaMailAlternateAddress);
+ $used['mail']=array_merge ($used['mail'],array_values ($this->gosaMailForwardingAddress));
+ $used['mail'][]=$this->mail;
// Build up blocklist
- session::set('filterBlacklist', $used);
- return($this->mailAddressSelect->execute());
- }
-
- if (isset($_POST['add_forwarder'])){
- if ($_POST['forward_address'] != ""){
- $address= get_post('forward_address');
- $valid= FALSE;
- if (!tests::is_email($address)){
- if (!tests::is_email($address, TRUE)){
- if ($this->is_template){
- $valid= TRUE;
- } else {
- msg_dialog::display(_("Error"), msgPool::invalid(_("Mail address"),
- "","","your-address at your-domain.com"),ERROR_DIALOG);
+ session::set ('filterBlacklist',$used);
+ return ($this->mailAddressSelect->execute ());
+ }
+
+ if (isset ($_POST['add_forwarder'])) {
+ if ($_POST['forward_address']!="") {
+ $address=get_post ('forward_address');
+ $valid=FALSE;
+ if (!tests::is_email ($address)) {
+ if (!tests::is_email ($address,TRUE)) {
+ if ($this->is_template) {
+ $valid=TRUE;
+ }
+ else {
+ msg_dialog::display (_ ("Error"),msgPool::invalid (_ ("Mail address"),"","","your-address at your-domain.com"),ERROR_DIALOG);
}
}
- } elseif ($address == $this->mail
- || in_array_strict($address, $this->gosaMailAlternateAddress)) {
- msg_dialog::display(_("Error"),_("Cannot add primary address to the list of forwarders!") , ERROR_DIALOG);
- } else {
- $valid= TRUE;
}
- if ($valid){
- if($this->acl_is_writeable("gosaMailForwardingAddress")){
+ elseif ($address==$this->mail||in_array_strict ($address,$this->gosaMailAlternateAddress)) {
+ msg_dialog::display (_ ("Error"),_ ("Cannot add primary address to the list of forwarders!"),ERROR_DIALOG);
+ }
+ else {
+ $valid=TRUE;
+ }
+ if ($valid) {
+ if ($this->acl_is_writeable ("gosaMailForwardingAddress")) {
$this->addForwarder ($address);
- $this->is_modified= TRUE;
+ $this->is_modified=TRUE;
}
}
}
}
- if (isset($_POST['delete_forwarder'])){
- $this->delForwarder (get_post('forwarder_list'));
+ if (isset ($_POST['delete_forwarder'])) {
+ $this->delForwarder (get_post ('forwarder_list'));
}
@@ -168,37 +212,38 @@ class mailgroup extends plugin
Alternate addresses
****************/
- if (isset($_POST['add_alternate'])){
- $valid= FALSE;
- if (!tests::is_email(get_post('alternate_address'))){
- if ($this->is_template){
- if (!(tests::is_email(get_post('alternate_address'), TRUE))){
- msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),
- "","","your-domain at your-domain.com"), ERROR_DIALOG);
- } else {
- $valid= TRUE;
+ if (isset ($_POST['add_alternate'])) {
+ $valid=FALSE;
+ if (!tests::is_email (get_post ('alternate_address'))) {
+ if ($this->is_template) {
+ if (! (tests::is_email (get_post ('alternate_address'),TRUE))) {
+ msg_dialog::display (_ ("Error"),msgPool::invalid (_ ("Mail address"),"","","your-domain at your-domain.com"),ERROR_DIALOG);
+ }
+ else {
+ $valid=TRUE;
}
- } else {
- msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),
- "","","your-domain at your-domain.com"), ERROR_DIALOG);
}
- } else {
- $valid= TRUE;
+ else {
+ msg_dialog::display (_ ("Error"),msgPool::invalid (_ ("Mail address"),"","","your-domain at your-domain.com"),ERROR_DIALOG);
+ }
+ }
+ else {
+ $valid=TRUE;
}
- if ($valid && ($user= $this->addAlternate (get_post('alternate_address'))) != ""){
- $ui= get_userinfo();
- $addon= "";
- if ($user[0] == "!") {
- $addon= sprintf(_("Address is already in use by group '%s'."), mb_substr($user, 1));
- } else {
- $addon= sprintf(_("Address is already in use by user '%s'."), $user);
+ if ($valid&& ($user=$this->addAlternate (get_post ('alternate_address')))!="") {
+ $ui=get_userinfo ();
+ $addon="";
+ if ($user[0]=="!") {
+ $addon=sprintf (_ ("Address is already in use by group '%s'."),mb_substr ($user,1));
}
- msg_dialog::display(_("Error"), msgPool::duplicated(_("Mail address"))."<br><br><i>".
- "$addon</i>", ERROR_DIALOG);
+ else {
+ $addon=sprintf (_ ("Address is already in use by user '%s'."),$user);
+ }
+ msg_dialog::display (_ ("Error"),msgPool::duplicated (_ ("Mail address"))."<br><br><i>"."$addon</i>",ERROR_DIALOG);
}
}
- if (isset($_POST['delete_alternate']) && isset($_POST['alternates_list'])){
- $this->delAlternate (get_post('alternates_list'));
+ if (isset ($_POST['delete_alternate'])&&isset ($_POST['alternates_list'])) {
+ $this->delAlternate (get_post ('alternates_list'));
}
@@ -207,454 +252,429 @@ class mailgroup extends plugin
****************/
/* Load templating engine */
- $smarty= get_smarty();
- $smarty->assign("initially_was_account", $this->initially_was_account);
+ $smarty=get_smarty ();
+ $smarty->assign ("initially_was_account",$this->initially_was_account);
/* Assign acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation) {
- $smarty->assign($name."ACL",$this->getacl($name));
+ $tmp=$this->plInfo ();
+ foreach ($tmp['plProvidedAcls'] as $name=>$translation) {
+ $smarty->assign ($name."ACL",$this->getacl ($name));
}
- foreach($this->attributes as $name){
- $smarty->assign($name, set_post($this->$name));
+ foreach ($this->attributes as $name) {
+ $smarty->assign ($name,set_post ($this->$name));
}
/******
Multi edit support
******/
- foreach($this->attributes as $attr){
- if(in_array_strict($attr,$this->multi_boxes)){
- $smarty->assign("use_".$attr,TRUE);
- }else{
- $smarty->assign("use_".$attr,FALSE);
+ foreach ($this->attributes as $attr) {
+ if (in_array_strict ($attr,$this->multi_boxes)) {
+ $smarty->assign ("use_".$attr,TRUE);
+ }
+ else {
+ $smarty->assign ("use_".$attr,FALSE);
}
}
- $smarty->assign("Forward_all", set_post($this->gosaMailForwardingAddress));
- $smarty->assign("Forward_some", set_post($this->gosaMailForwardingAddress_Some));
- $smarty->assign("multiple_support",set_post($this->multiple_support_active));
+ $smarty->assign ("Forward_all",set_post ($this->gosaMailForwardingAddress));
+ $smarty->assign ("Forward_some",set_post ($this->gosaMailForwardingAddress_Some));
+ $smarty->assign ("multiple_support",set_post ($this->multiple_support_active));
- $display.= $smarty->fetch (get_template_path('mailaddress.tpl', TRUE, dirname(__FILE__)));
+ $display.=$smarty->fetch (get_template_path ('mailaddress.tpl',TRUE,dirname (__FILE__)));
return ($display);
}
/* remove object from parent */
- function remove_from_parent()
- {
- if(!$this->initially_was_account){
+ function remove_from_parent () {
+ if (!$this->initially_was_account) {
return;
}
/* Remove GOsa attributes */
- plugin::remove_from_parent();
+ plugin::remove_from_parent ();
/* Zero arrays */
- $this->attrs['gosaMailAlternateAddress'] = array();
- $this->attrs['gosaMailForwardingAddress']= array();
+ $this->attrs['gosaMailAlternateAddress']=array ();
+ $this->attrs['gosaMailForwardingAddress']=array ();
- $this->cleanup();
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->dn);
+ $this->cleanup ();
+ $ldap=$this->config->get_ldap_link ();
+ $ldap->cd ($this->dn);
$ldap->modify ($this->attrs);
- if (!$ldap->success()){
- msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+ if (!$ldap->success ()) {
+ msg_dialog::display (_ ("LDAP error"),msgPool::ldaperror ($ldap->get_error (),$this->dn,LDAP_MOD,get_class ()));
}
- new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ new log ("remove","groups/".get_class ($this),$this->dn,array_keys ($this->attrs),$ldap->get_error ());
/* Optionally execute a command after we''re done */
- $this->handle_post_events("remove");
+ $this->handle_post_events ("remove");
}
/* Save data to object */
- function save_object()
- {
- if (isset($_POST['mailedit'])){
+ function save_object () {
+ if (isset ($_POST['mailedit'])) {
/* Acquire updated mail address
*/
- if(isset($_POST['mail'])){
- $this->mail = get_post('mail');
+ if (isset ($_POST['mail'])) {
+ $this->mail=get_post ('mail');
}
- $mail = $this->mail;
- $gosaMailServer = $this->gosaMailServer;
- $gosaMailDeliveryMode = $this->gosaMailDeliveryMode;
+ $mail=$this->mail;
+ $gosaMailServer=$this->gosaMailServer;
+ $gosaMailDeliveryMode=$this->gosaMailDeliveryMode;
- plugin::save_object();
+ plugin::save_object ();
- if($this->initially_was_account && !$this->is_template) {
- $this->mail = $mail;
- $this->gosaMailServer = $gosaMailServer;
- $this->gosaMailDeliveryMode = $gosaMailDeliveryMode;
+ if ($this->initially_was_account&&!$this->is_template) {
+ $this->mail=$mail;
+ $this->gosaMailServer=$gosaMailServer;
+ $this->gosaMailDeliveryMode=$gosaMailDeliveryMode;
}
}
}
/* Save data to LDAP, depending on is_account we save or delete */
- function save()
- {
- $ldap= $this->config->get_ldap_link();
+ function save () {
+ $ldap=$this->config->get_ldap_link ();
/* Enforce lowercase mail address and trim whitespaces
*/
- $this->mail = trim(strtolower($this->mail));
+ $this->mail=trim (strtolower ($this->mail));
/* Call parents save to prepare $this->attrs */
- plugin::save();
+ plugin::save ();
/* Save arrays */
- $this->attrs['gosaMailAlternateAddress'] = $this->gosaMailAlternateAddress;
- $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
+ $this->attrs['gosaMailAlternateAddress']=$this->gosaMailAlternateAddress;
+ $this->attrs['gosaMailForwardingAddress']=$this->gosaMailForwardingAddress;
/* Save data to LDAP */
- $ldap->cd($this->dn);
- $this->cleanup();
+ $ldap->cd ($this->dn);
+ $this->cleanup ();
$ldap->modify ($this->attrs);
- if (!$ldap->success()){
- msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+ if (!$ldap->success ()) {
+ msg_dialog::display (_ ("LDAP error"),msgPool::ldaperror ($ldap->get_error (),$this->dn,LDAP_MOD,get_class ()));
}
- if($this->initially_was_account){
- new log("modify","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- new log("create","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ if ($this->initially_was_account) {
+ new log ("modify","groups/".get_class ($this),$this->dn,array_keys ($this->attrs),$ldap->get_error ());
+ }
+ else {
+ new log ("create","groups/".get_class ($this),$this->dn,array_keys ($this->attrs),$ldap->get_error ());
}
/* Optionally execute a command after we''re done */
- if ($this->initially_was_account == $this->is_account){
- if ($this->is_modified){
- $this->handle_post_events("modify");
+ if ($this->initially_was_account==$this->is_account) {
+ if ($this->is_modified) {
+ $this->handle_post_events ("modify");
}
- } else {
- $this->handle_post_events("add");
+ }
+ else {
+ $this->handle_post_events ("add");
}
}
/* Check formular input */
- function check()
- {
- if(!$this->is_account) return array();
- $ldap= $this->config->get_ldap_link();
+ function check () {
+ if (!$this->is_account)
+ return array ();
+ $ldap=$this->config->get_ldap_link ();
/* Call common method to give check the hook */
- $message= plugin::check();
+ $message=plugin::check ();
/* Mail address checks */
- $mail = $this->mail;
- if (empty($mail)){
- $message[]= msgPool::required(_("Mail address"));
- }elseif (!tests::is_email($mail)){
- if ($this->is_template){
- $message[]= msgPool::invalid(_("Mail address"),"","","{%cn}@your-domain.com");
- } else {
- $message[]= msgPool::invalid(_("Mail address"),"","","your-address at your-domain.com");
+ $mail=$this->mail;
+ if (empty ($mail)) {
+ $message[]=msgPool::required (_ ("Mail address"));
+ }
+ elseif (!tests::is_email ($mail)) {
+ if ($this->is_template) {
+ $message[]=msgPool::invalid (_ ("Mail address"),"","","{%cn}@your-domain.com");
+ }
+ else {
+ $message[]=msgPool::invalid (_ ("Mail address"),"","","your-address at your-domain.com");
}
}
/* Check if this mail address is already in use */
- $ldap->cd($this->config->current['BASE']);
- $filter = "(&(!(objectClass=gosaUserTemplate))(!(cn=".$this->cn."))".
- "(objectClass=gosaMailAccount)".
- "(|(mail=".$mail.")(alias=".$mail.")(gosaMailAlternateAddress=".$mail.")))";
- $ldap->search($filter,array("cn"));
- if ($ldap->count() != 0){
- $message[]= msgPool::duplicated(_("Mail address"));
+ $ldap->cd ($this->config->current['BASE']);
+ $filter="(&(!(objectClass=gosaUserTemplate))(!(cn=".$this->cn."))"."(objectClass=gosaMailAccount)"."(|(mail=".$mail.")(alias=".$mail.")(gosaMailAlternateAddress=".$mail.")))";
+ $ldap->search ($filter,array ("cn"));
+ if ($ldap->count ()!=0) {
+ $message[]=msgPool::duplicated (_ ("Mail address"));
}
return ($message);
}
/* Adapt from template, using 'dn' */
- function adapt_from_template($dn, $skip= array())
- {
- plugin::adapt_from_template($dn, $skip);
+ function adapt_from_template ($dn,$skip=array ()) {
+ plugin::adapt_from_template ($dn,$skip);
// Remove non ASCII charcters
- $this->mail= iconv('UTF-8', 'US-ASCII//TRANSLIT', $this->mail);
- $this->mail= preg_replace('/[^(\x20-\x7F)]*/','',$this->mail);
+ $this->mail=iconv ('UTF-8','US-ASCII//TRANSLIT',$this->mail);
+ $this->mail=preg_replace ('/[^(\x20-\x7F)]*/','',$this->mail);
// No spaces are allowed here
- $this->mail= preg_replace("/[ ]/","", $this->mail);
+ $this->mail=preg_replace ("/[ ]/","",$this->mail);
- foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
+ foreach (array ("gosaMailAlternateAddress","gosaMailForwardingAddress") as $val) {
- if (in_array_strict($val, $skip)){
+ if (in_array_strict ($val,$skip)) {
continue;
}
- $this->$val= array();
- if (isset($this->attrs["$val"]["count"])){
- for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
- $value= $this->attrs["$val"][$i];
- foreach (array("sn", "givenName", "uid") as $repl){
- if (preg_match("/%$repl/i", $value)){
- $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
+ $this->$val=array ();
+ if (isset ($this->attrs["$val"]["count"])) {
+ for ($i=0;$i<$this->attrs["$val"]["count"];$i++) {
+ $value=$this->attrs["$val"][$i];
+ foreach (array ("sn","givenName","uid") as $repl) {
+ if (preg_match ("/%$repl/i",$value)) {
+ $value=preg_replace ("/%$repl/i",$this->parent->$repl,$value);
}
// Remove non ASCII charcters and spaces
- $value= iconv('UTF-8', 'US-ASCII//TRANSLIT', $this->mail);
- $value= preg_replace('/[^(\x20-\x7F)]*/','',$this->mail);
- $value= preg_replace("/[ ]/","", $this->mail);
-
+ $value=iconv ('UTF-8','US-ASCII//TRANSLIT',$this->mail);
+ $value=preg_replace ('/[^(\x20-\x7F)]*/','',$this->mail);
+ $value=preg_replace ("/[ ]/","",$this->mail);
}
- array_push($this->$val, $value);
+ array_push ($this->$val,$value);
}
}
}
}
- function make_name($attrs)
- {
- $name= "";
- if (isset($attrs['sn'][0])){
- $name= $attrs['sn'][0];
- }
- if (isset($attrs['givenName'][0])){
- if ($name != ""){
- $name.= ", ".$attrs['givenName'][0];
- } else {
- $name.= $attrs['givenName'][0];
+ function make_name ($attrs) {
+ $name="";
+ if (isset ($attrs['sn'][0])) {
+ $name=$attrs['sn'][0];
+ }
+ if (isset ($attrs['givenName'][0])) {
+ if ($name!="") {
+ $name.=", ".$attrs['givenName'][0];
+ }
+ else {
+ $name.=$attrs['givenName'][0];
}
}
- if ($name != ""){
- $name.= " ";
+ if ($name!="") {
+ $name.=" ";
}
return ($name);
}
- function getCopyDialog()
- {
- if(!$this->is_account) return("");
-
- $smarty = get_smarty();
- $smarty->assign("gosaMailAlternateAddress", set_post($this->gosaMailAlternateAddress));
- $smarty->assign("gosaMailForwardingAddress", set_post($this->gosaMailForwardingAddress));
- $smarty->assign("mail", set_post($this->mail));
- $display= $smarty->fetch (get_template_path('paste_mailaddress.tpl', TRUE, dirname(__FILE__)));
- $ret = array();
- $ret['string'] = $display;
- $ret['status'] = "";
- return($ret);
+ function getCopyDialog () {
+ if (!$this->is_account)
+ return ("");
+
+ $smarty=get_smarty ();
+ $smarty->assign ("gosaMailAlternateAddress",set_post ($this->gosaMailAlternateAddress));
+ $smarty->assign ("gosaMailForwardingAddress",set_post ($this->gosaMailForwardingAddress));
+ $smarty->assign ("mail",set_post ($this->mail));
+ $display=$smarty->fetch (get_template_path ('paste_mailaddress.tpl',TRUE,dirname (__FILE__)));
+ $ret=array ();
+ $ret['string']=$display;
+ $ret['status']="";
+ return ($ret);
}
- function saveCopyDialog()
- {
- if(!$this->is_account) return;
+ function saveCopyDialog () {
+ if (!$this->is_account)
+ return;
/* Perform ADD / REMOVE ... for mail alternate / mail forwarding addresses
*/
- $this->execute();
- if(isset($_POST['mail'])){
- $this->mail = get_post('mail');
+ $this->execute ();
+ if (isset ($_POST['mail'])) {
+ $this->mail=get_post ('mail');
}
}
- function PrepareForCopyPaste($source)
- {
- plugin::PrepareForCopyPaste($source);
+ function PrepareForCopyPaste ($source) {
+ plugin::PrepareForCopyPaste ($source);
/* Reset alternate mail addresses */
- $this->gosaMailAlternateAddress = array();
+ $this->gosaMailAlternateAddress=array ();
}
/* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Mail"),
- "plDescription" => _("Group mail"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 10,
- "plSection" => array("administration"),
- "plCategory" => array("groups"),
- "plProvidedAcls"=> array(
- "mail" => _("Mail address"),
- "gosaMailAlternateAddress" => _("Alternate addresses"),
- "gosaMailForwardingAddress" => _("Forwarding addresses"))
- ));
+ static function plInfo () {
+ return (array ("plShortName"=>_ ("Mail"),"plDescription"=>_ ("Group mail"),"plSelfModify"=>FALSE,"plDepends"=>array (),"plPriority"=>10,"plSection"=>array ("administration"),"plCategory"=>array ("groups"),"plProvidedAcls"=>array ("mail"=>_ ("Mail address"),"gosaMailAlternateAddress"=>_ ("Alternate addresses"),"gosaMailForwardingAddress"=>_ ("Forwarding addresses"))));
}
- function multiple_execute()
- {
- return($this->execute());
+ function multiple_execute () {
+ return ($this->execute ());
}
- function init_multiple_support($attrs,$all)
- {
- plugin::init_multiple_support($attrs,$all);
+ function init_multiple_support ($attrs,$all) {
+ plugin::init_multiple_support ($attrs,$all);
- $this->gosaMailForwardingAddress = array();
- if(isset($attrs['gosaMailForwardingAddress'])){
- for($i = 0 ; $i < $attrs['gosaMailForwardingAddress']['count'] ; $i++){
- $this->gosaMailForwardingAddress[] = $attrs['gosaMailForwardingAddress'][$i];
+ $this->gosaMailForwardingAddress=array ();
+ if (isset ($attrs['gosaMailForwardingAddress'])) {
+ for ($i=0;$i<$attrs['gosaMailForwardingAddress']['count'];$i++) {
+ $this->gosaMailForwardingAddress[]=$attrs['gosaMailForwardingAddress'][$i];
}
}
- $this->gosaMailForwardingAddress_Some = array();
- if(isset($all['gosaMailForwardingAddress'])){
- for($i = 0 ; $i < $all['gosaMailForwardingAddress']['count'] ; $i++){
- if(!in_array_strict($all['gosaMailForwardingAddress'][$i],$this->gosaMailForwardingAddress)){
- $this->gosaMailForwardingAddress_Some[] = $all['gosaMailForwardingAddress'][$i];
+ $this->gosaMailForwardingAddress_Some=array ();
+ if (isset ($all['gosaMailForwardingAddress'])) {
+ for ($i=0;$i<$all['gosaMailForwardingAddress']['count'];$i++) {
+ if (!in_array_strict ($all['gosaMailForwardingAddress'][$i],$this->gosaMailForwardingAddress)) {
+ $this->gosaMailForwardingAddress_Some[]=$all['gosaMailForwardingAddress'][$i];
}
}
}
}
- function multiple_save_object()
- {
- if(isset($_POST['multiple_mail_group_posted'])){
- plugin::multiple_save_object();
+ function multiple_save_object () {
+ if (isset ($_POST['multiple_mail_group_posted'])) {
+ plugin::multiple_save_object ();
}
}
- function multiple_check()
- {
- $message = plugin::multiple_check();
+ function multiple_check () {
+ $message=plugin::multiple_check ();
/* Mail address checks */
- $mail_pattern = $this->mail;
+ $mail_pattern=$this->mail;
- if (!empty($mail_pattern)){
- if ((!tests::is_email($mail_pattern, TRUE)) || (!preg_match('/^.*{%cn}.*@.*$/i', $mail_pattern))){
- $message[]= msgPool::invalid(_("Mail address pattern"),"","","{%cn}@your-domain.com")."<br><br><br>"._("Please make use of the {%cn} placeholder for the group part of the mail address.");
+ if (!empty ($mail_pattern)) {
+ if ( (!tests::is_email ($mail_pattern,TRUE))|| (!preg_match ('/^.*{%cn}.*@.*$/i',$mail_pattern))) {
+ $message[]=msgPool::invalid (_ ("Mail address pattern"),"","","{%cn}@your-domain.com")."<br><br><br>"._ ("Please make use of the {%cn} placeholder for the group part of the mail address.");
}
}
- return($message);
+ return ($message);
}
/* Return selected values for multiple edit */
- function get_multi_edit_values()
- {
- $ret = plugin::get_multi_edit_values();
- $ret['Forward_some'] = $this->gosaMailForwardingAddress_Some;
- $ret['Forward_all'] = $this->gosaMailForwardingAddress;
- $ret['mail'] = $this->mail;
- return($ret);
+ function get_multi_edit_values () {
+ $ret=plugin::get_multi_edit_values ();
+ $ret['Forward_some']=$this->gosaMailForwardingAddress_Some;
+ $ret['Forward_all']=$this->gosaMailForwardingAddress;
+ $ret['mail']=$this->mail;
+ return ($ret);
}
- function set_multi_edit_values($attrs)
- {
- $forward = array();
- foreach($attrs['Forward_some'] as $addr){
- if(in_array_strict($addr,$this->gosaMailForwardingAddress)){
- $forward[] = $addr;
+ function set_multi_edit_values ($attrs) {
+ $forward=array ();
+ foreach ($attrs['Forward_some'] as $addr) {
+ if (in_array_strict ($addr,$this->gosaMailForwardingAddress)) {
+ $forward[]=$addr;
}
}
- foreach($attrs['Forward_all'] as $addr){
- $forward[] = $addr;
+ foreach ($attrs['Forward_all'] as $addr) {
+ $forward[]=$addr;
}
/* Replace placeholders in mail address patterns */
- $mail_pattern = $attrs['mail'];
+ $mail_pattern=$attrs['mail'];
- if($mail_pattern) {
- $value= $this->cn;
- if (preg_match("/{%cn}/", $mail_pattern)){
- $attrs['mail']= str_replace("{%cn}", $value, $mail_pattern);
+ if ($mail_pattern) {
+ $value=$this->cn;
+ if (preg_match ("/{%cn}/",$mail_pattern)) {
+ $attrs['mail']=str_replace ("{%cn}",$value,$mail_pattern);
}
/* Add mail account data, if object is not in account state, yet
*/
- if(!$this->is_account && $this->acl_is_createable()){
- $this->is_account= TRUE;
+ if (!$this->is_account&&$this->acl_is_createable ()) {
+ $this->is_account=TRUE;
}
- } else {
- $mail = $this->mail;
+ }
+ else {
+ $mail=$this->mail;
}
- plugin::set_multi_edit_values($attrs);
+ plugin::set_multi_edit_values ($attrs);
- if(!$mail_pattern){
- $this->mail= $mail;
+ if (!$mail_pattern) {
+ $this->mail=$mail;
}
- $this->gosaMailForwardingAddress = $forward;
+ $this->gosaMailForwardingAddress=$forward;
}
/*! \brief Add given mail address to the list of forwarders.
*/
- function addForwarder($address)
- {
- if(empty($address)) return;
- $this->gosaMailForwardingAddress[]= $address;
- $this->gosaMailForwardingAddress= array_unique($this->gosaMailForwardingAddress);
+ function addForwarder ($address) {
+ if (empty ($address))
+ return;
+ $this->gosaMailForwardingAddress[]=$address;
+ $this->gosaMailForwardingAddress=array_unique ($this->gosaMailForwardingAddress);
/* Update multiple edit values too */
- if($this->multiple_support_active){
- $this->gosaMailForwardingAddress_Some=
- array_remove_entries (array($address),$this->gosaMailForwardingAddress_Some);
+ if ($this->multiple_support_active) {
+ $this->gosaMailForwardingAddress_Some=array_remove_entries (array ($address),$this->gosaMailForwardingAddress_Some);
}
sort ($this->gosaMailForwardingAddress);
reset ($this->gosaMailForwardingAddress);
- $this->is_modified= TRUE;
+ $this->is_modified=TRUE;
}
/*! \brief Removes the given mail address from the forwarders
*/
- function delForwarder($addresses)
- {
- if(empty($addresses)) return;
- $this->gosaMailForwardingAddress= array_remove_entries ($addresses,
- $this->gosaMailForwardingAddress);
+ function delForwarder ($addresses) {
+ if (empty ($addresses))
+ return;
+ $this->gosaMailForwardingAddress=array_remove_entries ($addresses,$this->gosaMailForwardingAddress);
/* Update multiple edit values too */
- if($this->multiple_support_active){
- $this->gosaMailForwardingAddress_Some = array_remove_entries ($addresses,
- $this->gosaMailForwardingAddress_Some);
+ if ($this->multiple_support_active) {
+ $this->gosaMailForwardingAddress_Some=array_remove_entries ($addresses,$this->gosaMailForwardingAddress_Some);
}
- $this->is_modified= TRUE;
+ $this->is_modified=TRUE;
}
/*! \brief Add given mail address to the list of alternate adresses ,
. check if this mal address is used, skip adding in this case
*/
- function addAlternate($address)
- {
- if(empty($address)) continue;
- $ldap= $this->config->get_ldap_link();
+ function addAlternate ($address) {
+ if (empty ($address))
+ continue;
+ $ldap=$this->config->get_ldap_link ();
- $address= strtolower($address);
+ $address=strtolower ($address);
/* Is this address already assigned in LDAP? */
$ldap->cd ($this->config->current['BASE']);
- $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)".
- "(gosaMailAlternateAddress=$address)))", array("cn", "uid"));
+ $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))",array ("cn","uid"));
- if ($ldap->count() > 0){
- $attrs= $ldap->fetch ();
- if (!isset($attrs["uid"])) {
+ if ($ldap->count ()>0) {
+ $attrs=$ldap->fetch ();
+ if (!isset ($attrs["uid"])) {
return ("!".$attrs["cn"][0]);
}
return ($attrs["uid"][0]);
}
/* Add to list of alternates */
- if (!in_array_strict($address, $this->gosaMailAlternateAddress)){
- $this->gosaMailAlternateAddress[]= $address;
+ if (!in_array_strict ($address,$this->gosaMailAlternateAddress)) {
+ $this->gosaMailAlternateAddress[]=$address;
}
sort ($this->gosaMailAlternateAddress);
reset ($this->gosaMailAlternateAddress);
- $this->is_modified= TRUE;
+ $this->is_modified=TRUE;
return ("");
}
@@ -662,14 +682,12 @@ class mailgroup extends plugin
/*! \brief Removes the given mail address from the alternate addresses
*/
- function delAlternate($addresses)
- {
- if(!count($addresses)) return;
- $this->gosaMailAlternateAddress= array_remove_entries ($addresses,
- $this->gosaMailAlternateAddress);
- $this->is_modified= TRUE;
+ function delAlternate ($addresses) {
+ if (!count ($addresses))
+ return;
+ $this->gosaMailAlternateAddress=array_remove_entries ($addresses,$this->gosaMailAlternateAddress);
+ $this->is_modified=TRUE;
}
-
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/personal/mailaddress/class_mailAccount.inc b/personal/mailaddress/class_mailAccount.inc
index b812965..b7da47a 100644
--- a/personal/mailaddress/class_mailAccount.inc
+++ b/personal/mailaddress/class_mailAccount.inc
@@ -3,7 +3,7 @@
\brief mail plugin
\author Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
\version 0.99.4
- \date 2015.08.04
+ \date 2015.08.27
This class provides basic information on mail accounts. This plugin
has been derived from gosa-plugin-mail, but it is not used to
@@ -26,429 +26,402 @@ Functions :
- getCopyDialog()
- saveCopyDialog()
- multiple_execute()
+ - multiple_check()
+ - get_multi_edit_values () {
+ - set_multi_edit_values ($attrs) {
- plInfo()
-
*/
-class mailAccount extends plugin
-{
- /* Definitions */
- var $plHeadline = "Mail Address";
- var $plDescription = "Manage user mail address";
- var $view_logged = FALSE;
- var $is_account = FALSE;
- var $initially_was_account = FALSE;
-
- /* GOsa mail attributes */
- var $mail = "";
-
- /* GOsa mail account attributes filled with dummy values,
- * required due to gosaMailAccount objectclass requirements.
- */
- var $gosaMailServer = "NULL";
- var $gosaMailDeliveryMode = "[ ]";
-
- /* Used LDAP attributes && classes */
- var $attributes= array(
- "mail",
- "gosaMailServer",
- "gosaMailDeliveryMode",
- );
- var $objectclasses= array("gosaMailAccount");
- var $multiple_support = TRUE;
-
- var $uid = "";
- var $cn = "";
-
-
- /*! \brief Initialize the mailAccount
- */
- function __construct (&$config, $dn= NULL)
- {
- plugin::plugin($config,$dn);
-
- /* Get attributes from parent object
- */
- foreach(array("uid","cn") as $attr){
- if(isset($this->parent->by_object['group']) && isset($this->parent->by_object['group']->$attr)){
- $this->$attr = &$this->parent->by_object['group']->$attr;
- }elseif(isset($this->attrs[$attr])){
- $this->$attr = $this->attrs[$attr][0];
- }
- }
+class mailAccount extends plugin {
+ /* Definitions */
+ var $plHeadline="Mail Address";
+ var $plDescription="Manage user mail address";
+ var $view_logged=FALSE;
+ var $is_account=FALSE;
+ var $initially_was_account=FALSE;
+
+ /* GOsa mail attributes */
+ var $mail="";
- /* Remember account status
+ /* GOsa mail account attributes filled with dummy values,
+ * required due to gosaMailAccount objectclass requirements.
*/
- $this->initialy_was_account = $this->is_account;
+ var $gosaMailServer="NULL";
+ var $gosaMailDeliveryMode="[ ]";
- }
+ /* Used LDAP attributes && classes */
+ var $attributes=array ("mail","gosaMailServer","gosaMailDeliveryMode",);
+ var $objectclasses=array ("gosaMailAccount");
+ var $multiple_support=TRUE;
- function execute()
- {
+ var $uid="";
+ var $cn="";
- /* Call parent execute */
- $display = plugin::execute();
- /* Log view */
- if ($this->is_account && !$this->view_logged) {
- $this->view_logged = TRUE;
- new log ("view", "users/".get_class($this), $this->dn);
+ /*! \brief Initialize the mailAccount
+ */
+ function __construct (&$config,$dn=NULL) {
+ plugin::plugin ($config,$dn);
+
+ /* Get attributes from parent object
+ */
+ foreach (array ("uid","cn") as $attr) {
+ if (isset ($this->parent->by_object['group'])&&isset ($this->parent->by_object['group']->$attr)) {
+ $this->$attr=&$this->parent->by_object['group']->$attr;
+ }
+ elseif (isset ($this->attrs[$attr])) {
+ $this->$attr=$this->attrs[$attr][0];
+ }
+ }
+
+ /* Remember account status
+ */
+ $this->initialy_was_account=$this->is_account;
}
- /****************
- Account status
- ****************/
+ function execute () {
- if(isset($_POST['modify_state'])){
- if($this->is_account && $this->acl_is_removeable()){
- $this->is_account= FALSE;
- }elseif(!$this->is_account && $this->acl_is_createable()){
- $this->is_account= TRUE;
- }
- }
+ /* Call parent execute */
+ $display=plugin::execute ();
- if (!$this->multiple_support_active) {
- if (!$this->is_account && $this->parent === NULL){
- $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".
- msgPool::noValidExtension(_("Mail Address"))."</b>";
- $display.= back_to_main();
- return ($display);
- }
- if ($this->parent !== NULL){
- if ($this->is_account){
- $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::featuresEnabled(_("Mail")));
- } else {
- $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::featuresDisabled(_("Mail")));
- return ($display);
+ /* Log view */
+ if ($this->is_account&&!$this->view_logged) {
+ $this->view_logged=TRUE;
+ new log ("view","users/".get_class ($this),$this->dn);
}
- }
- }
-/* if(isset($_POST['edit_apply'])){
- if(isset($_POST['mail'])){
- $this->mail = get_post('mail');
- }
- }
-*/
- /****************
- SMARTY- Assign smarty variables
- ****************/
- $smarty = get_smarty();
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $transl){
- $smarty->assign("$name"."ACL", $this->getacl($name));
- }
- foreach($this->attributes as $attr){
- $smarty->assign($attr,set_post($this->$attr));
- }
+ /****************
+ Account status
+ ****************/
+
+ if (isset ($_POST['modify_state'])) {
+ if ($this->is_account&&$this->acl_is_removeable ()) {
+ $this->is_account=FALSE;
+ }
+ elseif (!$this->is_account&&$this->acl_is_createable ()) {
+ $this->is_account=TRUE;
+ }
+ }
- $smarty->assign("multiple_support",$this->multiple_support_active);
- if($this->multiple_support-active){
- $smarty->assign("multi_mail",array_slice($this->multi_attrs_all['mail'],1));
- }
- return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if (isset($_POST['mailAccountTab'])){
-
- /* Acquire updated mail address
- */
- if(isset($_POST['mail'])){
- $this->mail = get_post('mail');
- }
-
- /* Save ldap attributes */
- $mail = $this->mail;
- $gosaMailServer = $this->gosaMailServer;
- $gosaMailDeliveryMode = $this->gosaMailDeliveryMode;
- plugin::save_object();
- if($this->initially_was_account && !$this->is_template) {
- $this->mail = $mail;
- $this->gosaMailServer = $gosaMailServer;
- $this->gosaMailDeliveryMode = $gosaMailDeliveryMode;
- }
- }
- }
+ if (!$this->multiple_support_active) {
+ if (!$this->is_account&&$this->parent===NULL) {
+ $display="<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".msgPool::noValidExtension (_ ("Mail Address"))."</b>";
+ $display.=back_to_main ();
+ return ($display);
+ }
+ if ($this->parent!==NULL) {
+ if ($this->is_account) {
+ $display=$this->show_disable_header (msgPool::removeFeaturesButton (_ ("Mail")),msgPool::featuresEnabled (_ ("Mail")));
+ }
+ else {
+ $display=$this->show_enable_header (msgPool::addFeaturesButton (_ ("Mail")),msgPool::featuresDisabled (_ ("Mail")));
+ return ($display);
+ }
+ }
+ }
+ /* if(isset($_POST['edit_apply'])){
+ if(isset($_POST['mail'])){
+ $this->mail = get_post('mail');
+ }
+ }
+ */
+ /****************
+ SMARTY- Assign smarty variables
+ ****************/
+ $smarty=get_smarty ();
+
+ $tmp=$this->plInfo ();
+ foreach ($tmp['plProvidedAcls'] as $name=>$transl) {
+ $smarty->assign ("$name"."ACL",$this->getacl ($name));
+ }
+ foreach ($this->attributes as $attr) {
+ $smarty->assign ($attr,set_post ($this->$attr));
+ }
- /*! \brief Removes the mailAccount extension from ldap
- */
- function remove_from_parent()
- {
- /* Cancel if there's nothing to do here */
- if (!$this->initially_was_account){
- return;
+ $smarty->assign ("multiple_support",$this->multiple_support_active);
+ if ($this->multiple_support-active) {
+ $smarty->assign ("multi_mail",array_slice ($this->multi_attrs_all['mail'],1));
+ }
+ return ($display.$smarty->fetch (get_template_path ("generic.tpl",TRUE,dirname (__FILE__))));
}
- // Do NOT remove the mail attribute while it is used in the Fax Account.
- if(isset($this->parent->by_object['gofaxAccount'])){
- $fax = $this->parent->by_object['gofaxAccount'];
- // Fax delivery to the mail account is activated, keep the mail attribute.
- if($fax->goFaxDeliveryMode & 32){
- $this->attributes = array_remove_entries(array('mail'), $this->attributes) ;
+ /* Save data to object */
+ function save_object () {
+ if (isset ($_POST['mailAccountTab'])) {
+
+ /* Acquire updated mail address
+ */
+ if (isset ($_POST['mail'])) {
+ $this->mail=get_post ('mail');
+ }
+
+ /* Save ldap attributes */
+ $mail=$this->mail;
+ $gosaMailServer=$this->gosaMailServer;
+ $gosaMailDeliveryMode=$this->gosaMailDeliveryMode;
+ plugin::save_object ();
+ if ($this->initially_was_account&&!$this->is_template) {
+ $this->mail=$mail;
+ $this->gosaMailServer=$gosaMailServer;
+ $this->gosaMailDeliveryMode=$gosaMailDeliveryMode;
+ }
}
}
- /* Remove GOsa attributes */
- plugin::remove_from_parent();
- $this->cleanup();
+ /*! \brief Removes the mailAccount extension from ldap
+ */
+ function remove_from_parent () {
+ /* Cancel if there's nothing to do here */
+ if (!$this->initially_was_account) {
+ return;
+ }
- @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
- $ldap= $this->config->get_ldap_link();
- $ldap->cd($this->dn);
- $ldap->modify ($this->attrs);
+ // Do NOT remove the mail attribute while it is used in the Fax Account.
+ if (isset ($this->parent->by_object['gofaxAccount'])) {
+ $fax=$this->parent->by_object['gofaxAccount'];
- /* Add "view" to logging class */
- new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- if (!$ldap->success()){
- msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
- }
+ // Fax delivery to the mail account is activated, keep the mail attribute.
+ if ($fax->goFaxDeliveryMode&32) {
+ $this->attributes=array_remove_entries (array ('mail'),$this->attributes);
+ }
+ }
- /* Optionally execute a command after we are done */
- $this->handle_post_events("remove",array("uid" => $this->uid));
- }
+ /* Remove GOsa attributes */
+ plugin::remove_from_parent ();
+ $this->cleanup ();
- /*! \brief Save the mailAccount settings to the ldap database.
- */
- function save()
- {
+ @DEBUG (DEBUG_LDAP,__LINE__,__FUNCTION__,__FILE__,$this->attributes,"Save");
+ $ldap=$this->config->get_ldap_link ();
+ $ldap->cd ($this->dn);
+ $ldap->modify ($this->attrs);
- $ldap= $this->config->get_ldap_link();
+ /* Add "view" to logging class */
+ new log ("remove","users/".get_class ($this),$this->dn,array_keys ($this->attrs),$ldap->get_error ());
+ if (!$ldap->success ()) {
+ msg_dialog::display (_ ("LDAP error"),msgPool::ldaperror ($ldap->get_error (),$this->dn,LDAP_MOD,get_class ()));
+ }
- if($this->initially_was_account){
- $this->mail = trim(strtolower($this->mail));
+ /* Optionally execute a command after we are done */
+ $this->handle_post_events ("remove",array ("uid"=>$this->uid));
}
- /* Call parents save to prepare $this->attrs */
- plugin::save();
- $this->attrs['mail'] = $this->mail;
- $this->attrs['gosaMailServer'] = $this->gosaMailServer;
- $this->attrs['gosaMailDeliveryMode'] = $this->gosaMailDeliveryMode;
+ /*! \brief Save the mailAccount settings to the ldap database.
+ */
+ function save () {
- /* Save data to LDAP */
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
+ $ldap=$this->config->get_ldap_link ();
- if (!$ldap->success()){
- msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
- }
+ if ($this->initially_was_account) {
+ $this->mail=trim (strtolower ($this->mail));
+ }
- /* Log last action */
- if($this->initially_was_account){
- new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
+ /* Call parents save to prepare $this->attrs */
+ plugin::save ();
- /* Optionally execute a command after we are done */
- if ($this->initially_was_account == $this->is_account){
- if ($this->is_modified){
- $this->handle_post_events("modify", array("uid" => $this->uid));
- }
- } else {
- $this->handle_post_events("add", array("uid" => $this->uid));
- }
- }
+ $this->attrs['mail']=$this->mail;
+ $this->attrs['gosaMailServer']=$this->gosaMailServer;
+ $this->attrs['gosaMailDeliveryMode']=$this->gosaMailDeliveryMode;
+ /* Save data to LDAP */
+ $ldap->cd ($this->dn);
+ $this->cleanup ();
+ $ldap->modify ($this->attrs);
- /*! \brief Check given values
- */
- function check()
- {
- if(!$this->is_account) {
- return (array());
- }
+ if (!$ldap->success ()) {
+ msg_dialog::display (_ ("LDAP error"),msgPool::ldaperror ($ldap->get_error (),$this->dn,LDAP_MOD,get_class ()));
+ }
- $ldap= $this->config->get_ldap_link();
+ /* Log last action */
+ if ($this->initially_was_account) {
+ new log ("modify","users/".get_class ($this),$this->dn,array_keys ($this->attrs),$ldap->get_error ());
+ }
+ else {
+ new log ("create","users/".get_class ($this),$this->dn,array_keys ($this->attrs),$ldap->get_error ());
+ }
- /* Call common method to give check the hook */
- $message= plugin::check();
+ /* Optionally execute a command after we are done */
+ if ($this->initially_was_account==$this->is_account) {
+ if ($this->is_modified) {
+ $this->handle_post_events ("modify",array ("uid"=>$this->uid));
+ }
+ }
+ else {
+ $this->handle_post_events ("add",array ("uid"=>$this->uid));
+ }
+ }
- /* Mail address checks */
- $mail = $this->mail;
- if (empty($mail)){
- if ($this->is_template) {
- $message[]= msgPool::required(_("Mail address"))."<br><br><b>"._("Examples").":</b> <i>{%givenName}.{%sn}@your-domain.com</i> "._("or")." <i>{%uid}@your-domain.com</i>";
- } else {
- $message[]= msgPool::required(_("Mail address"));
- }
- }
+ /*! \brief Check given values
+ */
+ function check () {
+ if (!$this->is_account) {
+ return (array ());
+ }
- if ($this->is_template){
- if (!tests::is_email($mail, TRUE)){
- $message[]= msgPool::invalid(_("Mail address"),"","","{%givenName}.{%sn}@your-domain.com");
- }
- } else {
- if (!tests::is_email($mail)){
- $message[]= msgPool::invalid(_("Mail address"),"","","your-address at your-domain.com");
- }
- }
+ $ldap=$this->config->get_ldap_link ();
- /* Check if this mail address is already in use */
- $ldap->cd($this->config->current['BASE']);
- $filter = "(&(!(objectClass=gosaUserTemplate))(!(uid=".$this->uid."))".
- "(objectClass=gosaMailAccount)".
- "(|(mail=".$mail.")(alias=".$mail.")(gosaMailAlternateAddress=".$mail.")))";
- $ldap->search($filter,array("uid", "cn"));
- if ($ldap->count() != 0){
- $entry= $ldap->fetch();
- $addon= "";
- if (!isset($entry['uid'])) {
- $addon= sprintf(_("Address is already in use by group '%s'."), $entry['cn'][0]);
- } else {
- $addon= sprintf(_("Address is already in use by user '%s'."), $entry['uid'][0]);
- }
- $message[]= msgPool::duplicated(_("Mail address"))."<br><br><i>$addon</i>";
- }
+ /* Call common method to give check the hook */
+ $message=plugin::check ();
- return($message);
- }
+ /* Mail address checks */
+ $mail=$this->mail;
+ if (empty ($mail)) {
+ if ($this->is_template) {
+ $message[]=msgPool::required (_ ("Mail address"))."<br><br><b>"._ ("Examples").":</b> <i>{%givenName}.{%sn}@your-domain.com</i> "._ ("or")." <i>{%uid}@your-domain.com</i>";
+ }
+ else {
+ $message[]=msgPool::required (_ ("Mail address"));
+ }
+ }
- /*! \brief Adapt from template, using 'dn'
- */
- function adapt_from_template($dn, $skip= array())
- {
- plugin::adapt_from_template($dn, $skip);
+ if ($this->is_template) {
+ if (!tests::is_email ($mail,TRUE)) {
+ $message[]=msgPool::invalid (_ ("Mail address"),"","","{%givenName}.{%sn}@your-domain.com");
+ }
+ }
+ else {
+ if (!tests::is_email ($mail)) {
+ $message[]=msgPool::invalid (_ ("Mail address"),"","","your-address at your-domain.com");
+ }
+ }
- $this->mail= strtolower(rewrite($this->mail));
+ /* Check if this mail address is already in use */
+ $ldap->cd ($this->config->current['BASE']);
+ $filter="(&(!(objectClass=gosaUserTemplate))(!(uid=".$this->uid."))"."(objectClass=gosaMailAccount)"."(|(mail=".$mail.")(alias=".$mail.")(gosaMailAlternateAddress=".$mail.")))";
+ $ldap->search ($filter,array ("uid","cn"));
+ if ($ldap->count ()!=0) {
+ $entry=$ldap->fetch ();
+ $addon="";
+ if (!isset ($entry['uid'])) {
+ $addon=sprintf (_ ("Address is already in use by group '%s'."),$entry['cn'][0]);
+ }
+ else {
+ $addon=sprintf (_ ("Address is already in use by user '%s'."),$entry['uid'][0]);
+ }
+ $message[]=msgPool::duplicated (_ ("Mail address"))."<br><br><i>$addon</i>";
+ }
- // Remove non ASCII charcters
- $this->mail= iconv('UTF-8', 'US-ASCII//TRANSLIT', $this->mail);
- $this->mail= preg_replace('/[^(\x20-\x7F)]*/','',$this->mail);
+ return ($message);
+ }
- // No spaces are allowed here
- $this->mail = preg_replace("/[ ]/","", $this->mail);
- }
+ /*! \brief Adapt from template, using 'dn'
+ */
+ function adapt_from_template ($dn,$skip=array ()) {
+ plugin::adapt_from_template ($dn,$skip);
- /*! \brief Creates the mail part for the copy & paste dialog
- */
- function getCopyDialog()
- {
- if(!$this->is_account) return("");
- $smarty = get_smarty();
- $smarty->assign("mail",$this->mail);
+ $this->mail=strtolower (rewrite ($this->mail));
- $str = $smarty->fetch(get_template_path("copypaste.tpl",TRUE, dirname(__FILE__)));
+ // Remove non ASCII charcters
+ $this->mail=iconv ('UTF-8','US-ASCII//TRANSLIT',$this->mail);
+ $this->mail=preg_replace ('/[^(\x20-\x7F)]*/','',$this->mail);
- $ret = array();
- $ret['status'] = "";
- $ret['string'] = $str;
- return($ret);
- }
+ // No spaces are allowed here
+ $this->mail=preg_replace ("/[ ]/","",$this->mail);
+ }
- /*! \brief save_object for copy&paste vars
- */
- function saveCopyDialog()
- {
- if(!$this->is_account) return;
+ /*! \brief Creates the mail part for the copy & paste dialog
+ */
+ function getCopyDialog () {
+ if (!$this->is_account)
+ return ("");
+ $smarty=get_smarty ();
+ $smarty->assign ("mail",$this->mail);
+
+ $str=$smarty->fetch (get_template_path ("copypaste.tpl",TRUE,dirname (__FILE__)));
+
+ $ret=array ();
+ $ret['status']="";
+ $ret['string']=$str;
+ return ($ret);
+ }
- if(isset($_POST['mail'])){
- $this->mail = get_post('mail');
- }
- }
- function multiple_execute()
- {
- return($this->execute());
- }
+ /*! \brief save_object for copy&paste vars
+ */
+ function saveCopyDialog () {
+ if (!$this->is_account)
+ return;
- function multiple_check()
- {
- $message = plugin::multiple_check();
+ if (isset ($_POST['mail'])) {
+ $this->mail=get_post ('mail');
+ }
+ }
- if(empty($this->gosaMailServer) && in_array_strict("gosaMailServer",$this->multi_boxes)){
- $message[]= msgPool::noserver(_("Mail"));
+ function multiple_execute () {
+ return ($this->execute ());
}
- /* Mail address checks */
- $mail_pattern = $this->mail;
+ function multiple_check () {
+ $message=plugin::multiple_check ();
- if (!empty($mail_pattern)){
- if ((!tests::is_email($mail_pattern, TRUE)) || (!preg_match('/^.*({%uid}|{%givenName}|{%sn}|{%cn}).*@.*$/i', $mail_pattern))){
- $message[]= msgPool::invalid(_("Mail address pattern"),"","","{%givenName}.{%sn}@your-domain.com")."<br><br><br>"._("Please make use of placeholders for the user part of the mail address.");
+ if (empty ($this->gosaMailServer)&&in_array_strict ("gosaMailServer",$this->multi_boxes)) {
+ $message[]=msgPool::noserver (_ ("Mail"));
}
- }
- return($message);
- }
-
- function get_multi_edit_values()
- {
- $ret = plugin::get_multi_edit_values();
- $ret['mail'] = $this->mail;
- return $ret;
- }
-
- function set_multi_edit_values($attrs)
- {
- /* Replace placeholders in mail address patterns */
- $mail_pattern = $attrs['mail'];
-
- if($mail_pattern){
- foreach (array("sn", "givenName", "uid") as $repl){
- $value= $this->$repl;
- if (preg_match("/{%$repl}/", $mail_pattern)){
- $attrs['mail']= str_replace("{%$repl}", $value, $mail_pattern);
- $mail_pattern=$attrs['mail'];
+
+ /* Mail address checks */
+ $mail_pattern=$this->mail;
+
+ if (!empty ($mail_pattern)) {
+ if ( (!tests::is_email ($mail_pattern,TRUE))|| (!preg_match ('/^.*({%uid}|{%givenName}|{%sn}|{%cn}).*@.*$/i',$mail_pattern))) {
+ $message[]=msgPool::invalid (_ ("Mail address pattern"),"","","{%givenName}.{%sn}@your-domain.com")."<br><br><br>"._ ("Please make use of placeholders for the user part of the mail address.");
+ }
}
- }
-
- /* Add mail account data, if object is not in account state, yet
- */
- if(!$this->is_account && $this->acl_is_createable()){
- $this->is_account= TRUE;
- }
- } else {
- $mail = $this->mail;
+ return ($message);
}
- plugin::set_multi_edit_values($attrs);
+ function get_multi_edit_values () {
+ $ret=plugin::get_multi_edit_values ();
+ $ret['mail']=$this->mail;
+ return $ret;
+ }
+
+ function set_multi_edit_values ($attrs) {
+ /* Replace placeholders in mail address patterns */
+ $mail_pattern=$attrs['mail'];
+
+ if ($mail_pattern) {
+ foreach (array ("sn","givenName","uid") as $repl) {
+ $value=$this->$repl;
+ if (preg_match ("/{%$repl}/",$mail_pattern)) {
+ $attrs['mail']=str_replace ("{%$repl}",$value,$mail_pattern);
+ $mail_pattern=$attrs['mail'];
+ }
+ }
+
+ /* Add mail account data, if object is not in account state, yet
+ */
+ if (!$this->is_account&&$this->acl_is_createable ()) {
+ $this->is_account=TRUE;
+ }
+ }
+ else {
+ $mail=$this->mail;
+ }
- if(!$mail_pattern){
- $this->mail = $mail;
+ plugin::set_multi_edit_values ($attrs);
+
+ if (!$mail_pattern) {
+ $this->mail=$mail;
+ }
}
- }
-
-
- /*! \brief ACL settings
- */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Mail"),
- "plDescription" => _("User Mail Address"),
- "plSelfModify" => TRUE,
- "plDepends" => array("user"), // This plugin depends on
- "plPriority" => 4, // Position in tabs
- "plSection" => array("personal" => _("My account")),
- "plCategory" => array("users"),
- "plOptions" => array(),
-
- "plRequirements"=> array(
- 'onFailureDisablePlugin' => array(get_class())
- ),
-
- "plProvidedAcls" => array(
- "mail" => _("Mail address"),
- ),
- ));
- }
+ /*! \brief ACL settings
+ */
+ static function plInfo () {
+ return (array ("plShortName"=>_ ("Mail"),"plDescription"=>_ ("User Mail Address"),"plSelfModify"=>TRUE,"plDepends"=>array ("user"),// This plugin depends on
+ "plPriority"=>4,// Position in tabs
+ "plSection"=>array ("personal"=>_ ("My account")),"plCategory"=>array ("users"),"plOptions"=>array (),"plRequirements"=>array ('onFailureDisablePlugin'=>array (get_class ())),"plProvidedAcls"=>array ("mail"=>_ ("Mail address"),),));
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/gosa-plugin-mailaddress.git
More information about the debian-edu-commits
mailing list