diff --git a/gosa-plugins/gofon/gofon/macro/class_gofonMacro.inc b/gosa-plugins/gofon/gofon/macro/class_gofonMacro.inc
index 08f2e0b9cb50521912be04f58e3be325a9c5eb63..640665faf7fb983a6fbf523228bd8d02196223bf 100644 (file)
var $attributes = array("cn","base", "description","displayName","goFonMacroContent","goFonMacroVisible");
var $view_logged = FALSE;
var $orig_cn = "";
+ var $orig_base = "";
+ var $orig_dn = "";
/*! Objectclasses that this calls handles */
var $objectclasses = array("top", "goFonMacro");
}
} else {
$this->orig_cn=$this->cn;
- $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+ $this->base= preg_replace ("/^[^,]+,".normalizePreg(get_ou("macroou"))."/i", "", $this->dn);
}
/* Check server configurations
unset($this->goFonHomeServers[0]);
}
}
+
+ $this->orig_base = $this->base;
+ $this->orig_dn = $this->dn;
}
{
/* Check if mysql extension is available */
if(!is_callable("mysql_pconnect")){
- return(sprintf(_("Missing %s PHP extension!"), "mysql"));
+ return(msgPool::missingext("php-mysql"));
}
/********************
$r_current = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
if(!$r_current){
new log("debug","gofonmacro/".get_class($this),"",array(),@mysql_error($r_current));
- return (sprintf(_("Cannot connect to %s database on server '%s'!"), "GOfon", $cfg_Current['SERVER']));
+ return ( msgPool::dbconnect("GOfon",@mysql_error(),$cfg_Current['SERVER']));
}
$db_current = @mysql_select_db($cfg_Current['DB'],$r_current);
if(!$db_current){
new log("debug","gofonmacro/".get_class($this),"",array(),@mysql_error($r_current));
mysql_close($r_current);
- return (sprintf(_("Cannot select %s database on server '%s'!"), "GOfon", $cfg_Current['SERVER']));
+ return ( msgPool::dbselect("GOfon",@mysql_error(),$cfg_Current['DB']));
}
}
}
@DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query");
if(!$res){
new log("debug","gofonmacro/".get_class($this),"",array(),@mysql_error($r_current));
- return(sprintf(_("Cannot remove macro from '%s'!"),$Server['SERVER']));
+ return ( msgPool::dbquery("GOfon",@mysql_error($r_current),$Server['SERVER']));
}
@mysql_close($r_current);
}
*/
$tmp = split(",", $s_linestr,3);
- /* Check if there are exactly 2 , */
-# if(substr_count($s_linestr,",") !=2){
-# return(sprintf(_("More than two ',' given in line : '%s'. Remember that parameters are seperated by '|'."),$i_linenum));
-# }
/* Multiple () are not supproted currently ... */
if(substr_count($s_linestr,"(") >1 ){
return(sprintf(_("Not supported multiple brace in line %s!"),$i_linenum));
@DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query");
if(!$res){
new log("debug","gofonmacro/".get_class($this),"",array(),@mysql_error($r_con));
- return(sprintf(_("Cannot insert new macro on server '%s'!"),$cfg['SERVER']));
}
@mysql_close($r_con);
}
$message= plugin::check();
if(!count($this->goFonHomeServers)){
- $message[] = _("There is currently no asterisk server defined!");
+ $message[] = msgPool::noserver(_("GOfon"));
}
/* Check if insert/replace is possible and all servers are available */
$ldap = $this->config->get_ldap_link();
$ldap->search("(&(objectClass=goFonMacro)(cn=".$this->cn."))",array("cn"));
if($ldap->count()>0){
- $message[]= _("Name is already in use!");
+ $message[]= msgPool::duplicated(_("Name"));
}
}
/* Check if display name is set */
if(empty($this->displayName)){
- $message[] = _("Display name is not set!");
+ $message[] = msgPool::required(_("Name"));
}
/* CN is restricted to 20 chars */
if(strlen("Makro-".$this->cn)>20 ){
if(empty($this->goFonMacroContent)){
$message[] = _("Macro is empty!");
}
+
+ /* Check if we are allowed to create or move this object
+ */
+ if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+ $message[] = msgPool::permCreate();
+ }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+ $message[] = msgPool::permMove();
+ }
+
return $message;
}
return false;
}
}else{
- msg_dialog::display(_("Configuration error"), _("There is currently no asterisk server defined!"), WARNING_DIALOG);
+ msg_dialog::display(_("Configuration error"), msgPool::noserver(_("GOfon")), WARNING_DIALOG);
return false;
}
/* Remove phone macro */
$ldap->rmDir($this->dn);
new log("remove","gofonmacro/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of goFonMacro/generic account with dn '%s' failed!"),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+ }
/* Delete references to object groups */
$ldap->cd ($this->config->current['BASE']);
$og= new ogroup($this->config, $ldap->getDN());
unset($og->member[$this->dn]);
$og->save ();
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of goFonMacro/generic account with dn '%s' failed!"),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+ }
}
}
$ldap->add($this->attrs);
$this->handle_post_events("add");
}
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of goFonMacro/generic account with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+ }
/* Log last action */
if($this->initially_was_account){