*/
class macro extends plugin
{
- /*! CLI vars */
- var $cli_summary= "Handling of GOsa's macro object";
- /*! CLI vars */
- var $cli_description= "Some longer text\nfor help";
- /*! CLI vars */
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/*! Macro attributes, */
var $generate_error= "";
var $goFonHomeServers = array(); // Contains all available asterisk database server
+ var $is_new = FALSE;
+
//! The Konstructor
/*! Konstructor, load class with attributes of the given dn*/
function macro ($config, $dn= NULL, $parent= NULL)
/* Edit or new one ?*/
if ($this->dn == "new"){
+ $this->is_new = TRUE;
if(isset($_SESSION['CurrentMainBase'])){
$this->base = $_SESSION['CurrentMainBase'];
}else{
$r_current = @mysql_pconnect($Server['SERVER'],$Server['LOGIN'],$Server['PASSWORD']);
$db_current = @mysql_select_db($Server['DB'],$r_current);
$res = @mysql_query($query,$r_current);
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query");
if(!$res){
gosa_log(@mysql_error($r_current));
- return(sprintf(_("Removing marco from '%s' failed. Check GOsa log for mysql error."),$Server['SERVER']));
+ return(sprintf(_("Removing macro from '%s' failed. Check GOsa log for mysql error."),$Server['SERVER']));
}
@mysql_close($r_current);
}
* Remove comments introduced by ;
* Skip empty lines
*/
- $s_linestr = preg_replace ("/^.*=\> /","",$s_linestr);
- $s_linestr = preg_replace("/;.*$/","",$s_linestr) ;
$s_linestr = trim($s_linestr);
+ $s_linestr = preg_replace("/;.*$/","",$s_linestr) ;
+ $s_linestr = preg_replace ("/^.*=\> /","",$s_linestr);
+
if(empty($s_linestr)){
continue;
}
$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(_("More than one '(' is currently not supported. Line : '%s'."),$i_linenum));
- }
- if(substr_count($s_linestr,")") >1 ){
- return(sprintf(_("More than one ')' is currently not supported. Line : '%s'."),$i_linenum));
- }
+# 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(_("More than one '(' is currently not supported. Line : '%s'."),$i_linenum));
+# }
+# if(substr_count($s_linestr,")") >1 ){
+# return(sprintf(_("More than one ')' is currently not supported. Line : '%s'."),$i_linenum));
+# }
+
/* Check if there is an application given */
if(empty($tmp[1])){
return(sprintf(_("There is no application given in line : '%s'."),$i_linenum));
- }
+ }
/* Check if there is an extension given */
if(empty($tmp[0])){
return(sprintf(_("There is no extension type given in line : '%s'."),$i_linenum));
- }
+ }
/* Create extension entry for current line
* and add this line to an array that will be inserted
$exten = addslashes($tmp[0]);
$prio = addslashes($tmp[1]);
$app = addslashes(preg_replace("/\(.*\).*$/","",$tmp[2]));
- $para = addslashes(preg_replace("/^.*\(/","",$tmp[2]));
- $para = preg_replace("/\).*$/","",$para);
+ $para = addslashes(preg_replace("/^[^(]*\((.*)\)[^)]*$/", "$1", $tmp[2]));
$sql.= " ('".$context."','".$exten."','".$prio."','".$app."','".$para."'),";
}
$db = @mysql_select_db($cfg['DB'],$r_con);
$query = preg_replace("/%TABLENAME%/",$cfg['EXT_TABLE'],$sql);
$res = @mysql_query($query,$r_con);
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query");
if(!$res){
gosa_log(@mysql_error($r_con));
return(sprintf(_("Insert of new macro failed for server '%s'."),$cfg['SERVER']));
plugin::save_object();
/* The cn can't be changed if this entry is not new */
- if($this->dn!= "new"){
+ if(!$this->is_new){
$this->cn = $this->orig_cn;
}
}
}
}
-
- /* Macro content must be smaller than 100 lines */
- if(count(split("\n",$this->goFonMacroContent))>100){
- $message[] = _("Makro length must be lower than 100 lines");
- }
-
return $message;
}
$str = $this->remove_from_database(true);
if($str){
print_red($str);
+ return false;
}
}else{
- print_red(_("Could not remove the macro entry from asterisk databases. Please check your asterisk database configurations and remove this entry from database manually, if necessary."));
+ print_red(_("Could not remove the macro entry from asterisk databases. Please check your asterisk database configurations."));
+ return false;
}
/* Remove phone macro */
/* Delete references to object groups */
$ldap->cd ($this->config->current['BASE']);
- $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
+ $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".@LDAP::prepare4filter($this->dn)."))", array("cn"));
while ($ldap->fetch()){
$og= new ogroup($this->config, $ldap->getDN());
unset($og->member[$this->dn]);
/*! Save to LDAP */
function save()
{
- /* Post checks */
- $this->execute();
-
plugin::save();
unset($this->attrs['base']);