From: cajus Date: Wed, 12 Dec 2007 11:33:27 +0000 (+0000) Subject: Starting move X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7f7f21906eb6121c29823abbf96461733d642509;p=gosa.git Starting move git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8099 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/README b/README deleted file mode 100644 index 8508057a0..000000000 --- a/README +++ /dev/null @@ -1,52 +0,0 @@ -GOsa2.1 README -============== - -* Information - -GOsa is a LDAP administration frontend for user administration. It -is NO GENERIC frontend to dictionary servers. Informations are stored -in the way the underlying conecpts suppose them to be stored (i.e. -people accounts are stored in "ou=people" subtrees, etc.) This can -be configured marginally. - -Complete setups applying Kerberos, AFS, LDAP, Mail, Proxy and Fax setups -are not trivial at all. You should be familiar with these components and -with your UNIX installation, of cause. This file is (and will not be) -an introduction to any of these components. See INSTALL for a quick -overview about what to do, to get the things up and running. A complete -GOsa infrastructure howto is work in progress and not released yet. - - -* Translations - -GOsa is not available in your native language? Just take the message.po -file out of the locales directory and put your translations into the -msgstr fields. You may look at the de/LC_MESSAGES for the way how it -works. - -If you're ready with that, create a directory for your language using -the ISO shortcuts (i.e. es for spain) with a subdirectory LC_MESSAGES. -Put your messages.po in there and run "msgfmt messages.po" from that -directory. Make sure your apache has locale support or, in case of debian, -that the specific locale will be generated (via dpkg-reconfigure locales). - -You may want your translations to be included in the main GOsa repository, -then just send the .po file to me. - - -* NOTES - -You'll need php-cups (http://www.cups.org) and php-krb5 (pear) in order -to get full functionality. To make shared folders work in a proper way, -you either need a recent PHP or a patched one for the get_acl functions -(see contrib/patches). Basically GOsa will run without these. - -Be sure that 'gosaUserTemplates' are not able to log into your server, -since they may have no password set. Example configs can be found in -the contrib directory. - -Have fun! - ---- -Cajus Pollmeier - diff --git a/README.safemode b/README.safemode deleted file mode 100644 index e43434059..000000000 --- a/README.safemode +++ /dev/null @@ -1,14 +0,0 @@ -In order to run GOsa in PHP's safe mode, these changes in your php.ini -have been tested: - -magic_quotes_qpc = On -allow_url_fopen = No -register_globals = Off -safe_mode = On -safe_mode_include_dir = "/usr/share/gosa:/var/spool/gosa" -safe_mode_exec_dir = "/usr/lib/gosa" -safe_mode_allowed_env_vars = PHP_,LANG -open_basedir = "/etc/gosa:/var/spool/gosa:/var/cache/gosa:/usr/share/gosa:/tmp" -include_path = ".:/usr/share/php:/usr/share/gosa:/var/spool/gosa:/usr/share/gosa/safe_bin" -disable_functions = system, shell_exec, passthru, phpinfo, show_source - diff --git a/gosa-core/README b/gosa-core/README new file mode 100644 index 000000000..8508057a0 --- /dev/null +++ b/gosa-core/README @@ -0,0 +1,52 @@ +GOsa2.1 README +============== + +* Information + +GOsa is a LDAP administration frontend for user administration. It +is NO GENERIC frontend to dictionary servers. Informations are stored +in the way the underlying conecpts suppose them to be stored (i.e. +people accounts are stored in "ou=people" subtrees, etc.) This can +be configured marginally. + +Complete setups applying Kerberos, AFS, LDAP, Mail, Proxy and Fax setups +are not trivial at all. You should be familiar with these components and +with your UNIX installation, of cause. This file is (and will not be) +an introduction to any of these components. See INSTALL for a quick +overview about what to do, to get the things up and running. A complete +GOsa infrastructure howto is work in progress and not released yet. + + +* Translations + +GOsa is not available in your native language? Just take the message.po +file out of the locales directory and put your translations into the +msgstr fields. You may look at the de/LC_MESSAGES for the way how it +works. + +If you're ready with that, create a directory for your language using +the ISO shortcuts (i.e. es for spain) with a subdirectory LC_MESSAGES. +Put your messages.po in there and run "msgfmt messages.po" from that +directory. Make sure your apache has locale support or, in case of debian, +that the specific locale will be generated (via dpkg-reconfigure locales). + +You may want your translations to be included in the main GOsa repository, +then just send the .po file to me. + + +* NOTES + +You'll need php-cups (http://www.cups.org) and php-krb5 (pear) in order +to get full functionality. To make shared folders work in a proper way, +you either need a recent PHP or a patched one for the get_acl functions +(see contrib/patches). Basically GOsa will run without these. + +Be sure that 'gosaUserTemplates' are not able to log into your server, +since they may have no password set. Example configs can be found in +the contrib directory. + +Have fun! + +--- +Cajus Pollmeier + diff --git a/gosa-core/README.safemode b/gosa-core/README.safemode new file mode 100644 index 000000000..e43434059 --- /dev/null +++ b/gosa-core/README.safemode @@ -0,0 +1,14 @@ +In order to run GOsa in PHP's safe mode, these changes in your php.ini +have been tested: + +magic_quotes_qpc = On +allow_url_fopen = No +register_globals = Off +safe_mode = On +safe_mode_include_dir = "/usr/share/gosa:/var/spool/gosa" +safe_mode_exec_dir = "/usr/lib/gosa" +safe_mode_allowed_env_vars = PHP_,LANG +open_basedir = "/etc/gosa:/var/spool/gosa:/var/cache/gosa:/usr/share/gosa:/tmp" +include_path = ".:/usr/share/php:/usr/share/gosa:/var/spool/gosa:/usr/share/gosa/safe_bin" +disable_functions = system, shell_exec, passthru, phpinfo, show_source + diff --git a/gosa-core/plugins/addons/addressbook/address_edit.tpl b/gosa-core/plugins/addons/addressbook/address_edit.tpl new file mode 100644 index 000000000..8b51230f8 --- /dev/null +++ b/gosa-core/plugins/addons/addressbook/address_edit.tpl @@ -0,0 +1,274 @@ + + + + + + + + +
+ + + + + X + +
+ + + + + + + + +
+

+ +  {t}Personal{/t} +

+ + + + + + + + + + + + +
+ , + + +{render acl=$snACL} + , +{/render} +{render acl=$givenNameACL} + +{/render} + +
+ + +{render acl=$initialsACL} + +{/render} +
+ + +{render acl=$titleACL} + +{/render} +
+
+

+ +  {t}Private{/t} +

+ + + + + + + + + + + + + + + + + +
+ +
+
+
+{render acl=$homePostalAddressACL} + +{/render} +
+ + +{render acl=$homePhoneACL} + +{/render} +
+ + +{render acl=$mobileACL} + +{/render} +
+ + +{render acl=$mailACL} + +{/render} +
+
+

+ +  {t}Organizational{/t} +

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + +{render acl=$oACL} + +{/render} +
+ + +{render acl=$ouACL} + +{/render} +
+ + +{render acl=$lACL} + +{/render} +
+ + +{render acl=$postalCodeACL} + +{/render} +
+ + +{render acl=$stACL} + +{/render} +
+
+ + + + + + + + + + + + + + + + + +
+ +
+
+
+{render acl=$postalAddressACL} + +{/render} +
+ + +{render acl=$telephoneNumberACL} + +{/render} +
+ + +{render acl=$facsimileTelephoneNumberACL} + +{/render} +
+ + +{render acl=$pagerACL} + +{/render} +
+
+
+ +

+ + +

+ +
+ + diff --git a/gosa-core/plugins/addons/addressbook/address_info.tpl b/gosa-core/plugins/addons/addressbook/address_info.tpl new file mode 100644 index 000000000..3bb3a2242 --- /dev/null +++ b/gosa-core/plugins/addons/addressbook/address_info.tpl @@ -0,0 +1,196 @@ + + + + + + + + + +
{$storage_info} + + X +
+ + + + + + + + + + +
+

+ + {t}Personal{/t} +

+ + + + + + + + + + + + + + +
+ {t}Name{/t} + + {$info_sn}, {$info_givenName} +
+ {t}Initials{/t} + + {$info_initials} +
+ {t}Personal title{/t} + + {$info_title} +
+ +
+ +

+ + {t}Private{/t} +

+ + + + + + + + + + + + + + + + + + +
+ {t}Address{/t} + + {$info_homePostalAddress} +
+ {t}Phone{/t} + + {$info_homePhone} +
+ {t}Mobile{/t} + + {$info_mobile} +
+ {t}Email{/t} + + {$info_mail} +
+ +
+ +

+ + {t}Organizational{/t} +

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ {t}Company{/t} + + {$info_o} +
+ {t}Department{/t} + + {$info_ou} +
+ {t}City{/t} + + {$info_l} +
+ {t}Postal code{/t} + + {$info_postalCode} +
+ {t}Country{/t} + + {$info_st} +
+ +
+ + + + + + + + + + + + + + + + + + +
+ {t}Address{/t} + + {$info_postalAddress} +
+ {t}Phone{/t} + + {$info_telephoneNumber} +
+ {t}FAX{/t} + + {$info_facsimileTelephoneNumber} +
+ {t}Pager{/t} + + {$info_pager} +
+
+ +
+ +
diff --git a/gosa-core/plugins/addons/addressbook/class_addressbook.inc b/gosa-core/plugins/addons/addressbook/class_addressbook.inc new file mode 100644 index 000000000..67bb3455e --- /dev/null +++ b/gosa-core/plugins/addons/addressbook/class_addressbook.inc @@ -0,0 +1,835 @@ +config= &$config; + + /* Check if there is a special ldap-sub-tree specified, instead of dc=addressbook, */ + $aoc = $this->config->search("addressbook", "LDAP_OBJECT_CLASS",array('menu')); + if ($aoc != ""){ + $this->abobjectclass = $aoc; + } + + /* Get global filter config */ + if (!is_global("phonefilter")){ + $ui = get_userinfo(); + $base = get_base_from_people($ui->dn); + $phonefilter= array( + "search_base" => $base, + "organizational" => "checked", + "global" => "checked", + "search_for" => "*", + "object_type" => "*"); + register_global("phonefilter", $phonefilter); + } + + $this->ui = get_userinfo(); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $smarty= get_smarty(); + + /* Prevent empty variables for smarty */ + foreach($this->attributes as $atr) { + $smarty->assign($atr,""); + } + + /* Save formular information */ + $phonefilter= get_global("phonefilter"); + foreach( array("search_for", "search_base", "object_type") as $type){ + if (isset($_POST[$type])){ + $phonefilter[$type]= $_POST[$type]; + } + $this->$type= $phonefilter[$type]; + } + if (isset($_POST['search_base'])){ + foreach( array("organizational", "global") as $type){ + if (isset($_POST[$type])){ + $phonefilter[$type]= "checked"; + } else { + $phonefilter[$type]= ""; + } + } + } + + /* Search string */ + $s= $phonefilter['search_for']; + if ($s == "") { + $s= "*"; + } + if (isset($_GET['search'])){ + $s= validate(mb_substr($_GET['search'], 0, 1, "UTF8"))."*"; + if ($s == "**"){ + $s= "*"; + } + $this->search_for= $s; + $phonefilter['search_for']= $s; + } + register_global("phonefilter", $phonefilter); + + /* Assign create acl */ + $acl = $this->get_entry_acls($this->abobjectclass.",".$phonefilter['search_base']); + $smarty->assign("internal_createable", preg_match("/c/",$acl)); + $smarty->assign("internal_removeable", preg_match("/d/",$acl)); + $smarty->assign("internal_editable", preg_match("/w/",$acl)); + + /* Perform actions with CTI hook */ + if (isset($_GET['target']) + && isset($_GET['dial']) + && isset($this->config->current['CTIHOOK'])){ + + $dialmode= $_GET['dial']; + if ($dialmode == "telephoneNumber" || + $dialmode == "mobile" || + $dialmode == "homePhone"){ + + /* Get target */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat(base64_decode($_GET['target']), array('telephoneNumber', 'mobile', 'homePhone')); + $attrs= $ldap->fetch(); + if (isset($attrs["$dialmode"])){ + $target= $attrs[$dialmode][0]; + } else { + $target= ""; + } + + /* Get source */ + $ui= get_userinfo(); + $ldap->cat($ui->dn, array('telephoneNumber')); + $attrs= $ldap->fetch(); + if (isset($attrs["telephoneNumber"])){ + $source= $attrs['telephoneNumber'][0]; + } else { + $source= ""; + } + + /* Save to session */ + $_SESSION['source']= $source; + $_SESSION['target']= $target; + + /* Perform call */ + if ($target != "" && $source != ""){ + $smarty->assign("phone_image", get_template_path('images/phone.png')); + $smarty->assign("dial_info", sprintf(_("Dial from %s to %s now?"), "".$source."", "".$target."")); + return($smarty->fetch(get_template_path('dial.tpl', TRUE))); + return; + } else { + print_red (_("You have no personal phone number set. Please change that in order to perform direct dials.")); + } + } + + } + + /* Finally dial */ + if (isset($_POST['dial']) && isset($_SESSION['source']) && isset($_SESSION['target'])){ + exec ($this->config->current['CTIHOOK']." '".$_SESSION['source']."' '".$_SESSION['target']."'", $dummy, $retval); + unset($_SESSION['source']); + unset($_SESSION['target']); + } + + + /* Delete entry? */ + if (isset($_POST['delete_entry_confirm'])){ + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + + $acl = $this->get_entry_acls($this->dn); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir ($this->dn); + new log("remove","addressbook/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of addressbook entry '%s' failed."),$this->dn)); + new log("remove","addressbook/".get_class($this),$this->dn,array(),"Address book object'".$this->dn."' has been removed"); + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this entry!")); + new log("remove","addressbook/".get_class($this),$this->dn,array(),"Warning: '".$this->ui->uid."' tried to trick address book deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + + /* Clean up */ + if (isset($_SESSION['saved_start'])){ + $_GET['start']= $_SESSION['saved_start']; + } + unset($_SESSION['show_info']); + unset($_SESSION['saved_start']); + } + + + /* Delete entry? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + } + + + /* Save address entry? */ + if (isset($_POST['save'])){ + $this->save_object(); + $this->storage_base= $_POST['storage_base']; + + /* Perform checks */ + $message= $this->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $this->save(); + + /* Clean up */ + if (isset($_SESSION['saved_start'])){ + $_GET['start']= $_SESSION['saved_start']; + } + $_SESSION['show_info']= $this->dn; + unset($_SESSION['saved_start']); + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + + /* Close info window */ + if (isset($_GET['close']) || isset($_POST['cancel'])){ + if (isset($_SESSION['saved_start'])){ + $_GET['start']= $_SESSION['saved_start']; + } + unset($_SESSION['show_info']); + unset($_SESSION['saved_start']); + } + + + /* Start address book edit mode? */ + if (isset($_GET['global'])){ + if (!isset($_SESSION['saved_start']) && isset($_GET['start'])){ + $_SESSION['saved_start']= $_GET['start']; + } + switch ($_GET['global']){ + case "add": + $this->dn= "new"; + $this->orig_cn= ""; + + /* Clean values */ + foreach ($this->attributes as $name){ + $this->$name= ""; + } + $this->saved_attributes= array(); + $this->storage_base= $this->config->current["BASE"]; + break; + + case "edit": + /* Clean values */ + foreach ($this->attributes as $name){ + $this->$name= ""; + } + $this->dn= $_SESSION['show_info']; + $this->load(); + $this->orig_cn= $this->cn; + break; + case "remove": + $this->dn= $_SESSION['show_info']; + $this->load(); + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl = $this->get_entry_acls($this->dn); + if(preg_match("/d/",$acl)){ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + $ui= get_userinfo(); + add_lock ($this->dn, $ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the entry %s."), $this->dn)); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the user isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this entry!")); + } + } + $_SESSION['show_info']= "ADD"; + } + + + /* Open info window */ + if (isset($_GET['show'])){ + if (!isset($_SESSION['saved_start'])){ + $_SESSION['saved_start']= $_GET['start']; + } + $this->dn = base64_decode($_GET['show']); + $this->view_logged =FALSE; + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","addressbook/".get_class($this),$this->dn); + } + $_SESSION['show_info']= base64_decode($_GET['show']); + } + + + /* Get ldap link / build filter */ + $ldap= $this->config->get_ldap_link(); + $this->telephone_list= array (); + + + /* Assemble bases + (Depending on checkboxes, we search for organisational entries or seperated + adressbook entries within dc=adressbook, ) */ + $bases= array(); + $filter= ""; + if ($phonefilter['global'] == "checked"){ + $bases[]= preg_replace("/".$this->config->current['BASE']."/", $this->abobjectclass.",".$this->config->current['BASE'], $this->search_base); + } else { + $filter= '(objectClass=gosaAccount)'; + } + if ($phonefilter['organizational'] == "checked"){ + $bases[]= $this->search_base; + } + + + /* Only display those entries that have at least on of this attributes set */ + $must_have_this = array("telephoneNumber","facsimileTelephoneNumber","mobile","homePhone","mail"); + + /* Requested attributes in ldap search */ + $attributes = array("sn", "givenName", "telephoneNumber", "facsimileTelephoneNumber", "mobile", "homePhone", "uid", "mail", "cn"); + + /* Create attribute filter part */ + $attribute_filter = ""; + foreach($attributes as $att){ + $attribute_filter .= "(".$att."=".$s.")"; + } + + /* Walk through bases an check for usable entries */ + foreach ($bases as $base){ + + $ldap->cd ($base); + + if ($phonefilter['object_type'] == '*'){ + $ldap->search ( + "(&(objectClass=person)$filter(!(objectClass=gosaUserTemplate))". // Skip templates etc .. + "(!(uid=*$))". // Skip entries with ...$ as uid + "(|".$attribute_filter."))" + ,$attributes); + } else { + $ldap->search ("(&$filter(!(uid=*$))(!(objectClass=gosaUserTemplate))". //array + "(".$phonefilter['object_type']."=$s))", $attributes); + } + + /* Walk through LDAP results */ + while ($attrs= $ldap->fetch()){ + + /* prevent empty vaiables */ + foreach($this->attributes as $atr) { + if(!isset($attrs[$atr][0])) { + $attrs[$atr][0] = ""; + } + } + + /* Check if page number was posted */ + if(!isset($_GET['start'])) { + $_GET['start']=""; + } + + /* Check if at least one attribute is specified */ + $skip = false; + + foreach($must_have_this as $attr) { + if(isset($attrs[$attr][0]) && !empty($attrs[$attr][0])){ + $skip =false; + break; + } + } + + /* Skip all attributes that we are not allowed to read */ + $any = false; + foreach($attributes as $attr){ + + $acls = $this->get_entry_acls($attrs['dn'],$attr); + if(!preg_match("/r/",$acls)){ + $attrs[$attr][0] = ""; + }else{ + $any = true; + } + } + + /* Only show lines that have set any mail or phone informations */ + if(!$skip && $any){ + + $this->telephone_list[$attrs['sn'][0].$attrs['dn']]= + + " + ". + $attrs['sn'][0].", ".$attrs['givenName'][0]. + " +   + + ".$attrs['telephoneNumber'][0]." + +   + + ".$attrs['facsimileTelephoneNumber'][0]." +   + + ".$attrs['mobile'][0]." + +   + + ".$attrs['homePhone'][0]." + +   + + + \"vcf\" + "; + + + if(preg_match("/r/",$this->get_entry_acls($attrs['dn'],"mail"))){ + if (isset($attrs['mail'][0]) && !empty($attrs['mail'][0])){ + $dest= sprintf(_("Send mail to %s"), $attrs['mail'][0]); + $this->telephone_list[$attrs['sn'][0].$attrs['dn']].= + + "". + "\"vcf\""; + } + } + $this->telephone_list[$attrs['sn'][0].$attrs['dn']].= " "; + } + } + error_reporting(E_ALL | E_STRICT); + } + + /* Sort up list */ + ksort ($this->telephone_list); + reset ($this->telephone_list); + + /* Fill template variables */ + $smarty->assign("search_for", $this->search_for); + $smarty->assign("object_type", $this->object_type); + + $this->base = $phonefilter['search_base']; + $smarty->assign("deplist", $this->get_allowed_bases()); + $smarty->assign("depselect", $this->search_base); + $smarty->assign("global", $phonefilter['global']); + $smarty->assign("organizational", $phonefilter['organizational']); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("obj_image", get_template_path('images/list_ogroup.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info.png')); + $smarty->assign("actionimage", get_template_path('images/action.png')); + $smarty->assign("launchimage", get_template_path('images/launch.png')); + + /* Generate alphabet */ + $alphabet= generate_alphabet(); + + /* Build list output */ + $output= ""; + $mod= 0; + + + /* View detailed infos */ + $smarty->assign("show_info", ""); + if (isset($_SESSION['show_info'])){ + + $range= 4; + $smarty->assign("show_info", "1"); + $smarty->assign("url", "main.php?plug=".validate($_GET['plug'])."&close=1"); + + $tmp = $this->plInfo(); + + if(isset($_POST['storage_base'])){ + $this->storage_base = $_POST['storage_base']; + } + + switch ($_SESSION['show_info']){ + + case "ADD": + + $a_bases = $this->get_allowed_bases(); + + if(!isset($a_bases[$this->storage_base])){ + $base = key($this->get_allowed_bases()); + $this->storage_base = $base; + } + + $smarty->assign ('storage_base', $this->storage_base); + $smarty->assign ('address_info', get_template_path('address_edit.tpl', TRUE)); + + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->get_entry_acls($this->abobjectclass.",".$base,$name)); + } + break; + + default: + $smarty->assign ('address_info', get_template_path('address_info.tpl', TRUE)); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->get_entry_acls($this->dn,$name)); + } + break; + } + + /* Fill variables from LDAP */ + if ($_SESSION['show_info'] != "ADD"){ + $ldap->cat($_SESSION['show_info'], $this->attributes); + $info= $ldap->fetch(); + } + foreach ($this->attributes as $name){ + + /* Skip entries we are not allowed to read */ + if(!preg_match("/r/",$this->get_entry_acls($this->dn,$name))){ + $smarty->assign("info_$name", ""); + }else + + if ($_SESSION['show_info'] != "ADD" && isset($info["$name"][0])){ + error_reporting(0); + /* Special treatment for phone attributes */ + if ($name == "mobile" || + $name == "homePhone" || + $name == "telephoneNumber"){ + $smarty->assign("info_$name", + "".$info["$name"][0].""); + } else { + $smarty->assign("info_$name", preg_replace("/\n/", "
", $info["$name"][0])); + } + error_reporting(E_ALL | E_STRICT); + } elseif ($_SESSION['show_info'] == "ADD" && isset($this->$name)) { + $smarty->assign("info_$name", $this->$name); + } else { + $smarty->assign("info_$name", "-"); + } + } + if (preg_match("/,".$this->abobjectclass.",/", $_SESSION['show_info'])){ + $storage= _("global addressbook"); + $smarty->assign("internal", 0); + } else { + $storage= _("user database"); + $smarty->assign("internal", 1); + } + if ($_SESSION['show_info'] != "ADD"){ + $smarty->assign("storage_info", sprintf(_("Contact stored in '%s'"), $storage)); + } else { + $smarty->assign("storage_info", _("Creating new entry in")); + } + } else { + + + if(isset($_POST['EntryPerPage'])){ + $this->range = $_POST['EntryPerPage']; + } + $range = $this->range; + $smarty->assign("internal", 1); + } + if (isset($_GET['start'])){ + $this->start= validate($_GET['start']); + } + foreach ($this->telephone_list as $val){ + if ($mod < $this->start) { + $mod++; + continue; + } + if ($mod >= ($this->start + $range)){ + $mod++; + break; + } + if ( ($mod++) & 1){ + $col= "style=\"background-color: #ECECEC;\""; + } else { + $col= "style=\"background-color: #F5F5F5;\""; + } + $output.= "\n$val\n"; + } + + $smarty->assign("search_result", $output); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", $alphabet); + if($range < 20){ + $smarty->assign("range_selector", range_selector(count($this->telephone_list), $this->start, $range)); + }else{ + $smarty->assign("range_selector", range_selector(count($this->telephone_list), $this->start, $range, "EntryPerPage")); + } + $tmp= array("*" => _("All"), "sn" => _("Name"), "givenName" => _("Given name"), + "telephoneNumber" => _("Work phone"), "mobile" => _("Cell phone"), + "homePhone" => _("Home phone"), "uid" => _("User ID")); + natsort($tmp); + $smarty->assign("objlist", $tmp); + + /* Show main page */ + $smarty->assign ('personal_image', get_template_path('images/addr_personal.png')); + $smarty->assign ('home_image', get_template_path('images/addr_home.png')); + $smarty->assign ('company_image', get_template_path('images/addr_company.png')); + $smarty->assign ('add_image', get_template_path('images/editpaste.png')); + $smarty->assign ('edit_image', get_template_path('images/edit.png')); + $smarty->assign ('delete_image', get_template_path('images/editdelete.png')); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + + /* save attributes depending on acls */ + $acl = $this->get_entry_acls($this->dn,$attr); + + if(preg_match("/w/",$acl)){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + + } + } + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* must: sn, givenName */ + if ($this->sn == ""){ + $message[]= _("The required field 'Name' is not set."); + return ($message); + } + if ($this->givenName == ""){ + $message[]= _("The required field 'Given name' is not set."); + return ($message); + } + + /* Check for valid name definition */ + if (preg_match ("/[\\\\]/", $this->sn)){ + $message[]= _("The field 'Name' contains invalid characters."); + } + if (preg_match ("/[\\\\]/", $this->givenName)){ + $message[]= _("The field 'Given name' contains invalid characters."); + } + + /* Check phone numbers */ + if (!is_phone_nr($this->homePhone)){ + $message[]= _("The field 'Phone' contains an invalid phone number."); + } + if (!is_phone_nr($this->telephoneNumber)){ + $message[]= _("The field 'Phone' contains an invalid phone number."); + } + if (!is_phone_nr($this->facsimileTelephoneNumber)){ + $message[]= _("The field 'Fax' contains an invalid phone number."); + } + if (!is_phone_nr($this->mobile)){ + $message[]= _("The field 'Mobile' contains an invalid phone number."); + } + if (!is_phone_nr($this->pager)){ + $message[]= _("The field 'Pager' contains an invalid phone number."); + } + + /* Check for reserved characers */ + if (preg_match ('/[,+"<>;]/', $this->givenName)){ + $message[]= _("The field 'Given name' contains invalid characters."); + } + if (preg_match ('/[,+"<>;]/', $this->sn)){ + $message[]= _("The field 'Name' contains invalid characters."); + } + + /* Check mail */ + if (!is_email($this->mail)){ + $message[]= _("Please enter a valid email address in 'Primary address' field."); + } + + /* Assemble cn/dn */ + $this->cn= $this->givenName." ".$this->sn; + if ($this->orig_cn != $this->cn || $this->storage_base != $this->orig_storage_base){ + $this->new_dn= $this->create_unique_dn("cn", preg_replace("/,*".$this->config->current['BASE']."$/", "", $this->storage_base).",".$this->abobjectclass.",".$this->config->current['BASE']); + if ($this->new_dn == "none"){ + $message[]= _("Cannot create a unique DN for your entry. Please fill more formular fields."); + return ($message); + } + } else { + $this->new_dn= $this->dn; + } + + return ($message); + } + + + function load() + { + /* Load base attributes */ + plugin::plugin ($this->config, $this->dn); + $this->view_logged = FALSE; + $this->storage_base= preg_replace('/^[^,]+,/', '', preg_replace('/'.$this->abobjectclass.',/', '', $this->dn)); + } + + + function save() + { + /* First use parents methods to do some basic fillup in $this->attrs */ + plugin::save (); + + $this->attrs['cn']= $this->cn; + $this->attrs['displayName']= $this->givenName." ".$this->sn; + + /* Move entry if it got another name... */ + if ($this->dn != "new" && $this->dn != $this->new_dn){ + $this->move($this->dn, $this->new_dn); + } + $this->dn= $this->new_dn; + + /* Save data. Using 'modify' implies that the entry is already present, use 'add' for + new entries. So do a check first... */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat ($this->dn,array('dn')); + if ($ldap->fetch()){ + $mode= "modify"; + } else { + $mode= "add"; + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + } + + /* Finally write data with selected 'mode' */ + $ldap->cd ($this->dn); + $this->cleanup(); + $ldap->$mode ($this->attrs); + if (show_ldap_error($ldap->get_error(), sprintf(_("Removing of addressbook entry '%s' failed."),$this->dn))){ + return (1); + } + + if($mode == "add"){ + new log("create","addressbook/".get_class($this),$this->dn, array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("modify","addressbook/".get_class($this),$this->dn, array_keys($this->attrs),$ldap->get_error()); + } + } + + + /* Return entry acls */ + function get_entry_acls($dn,$attr = "") + { + $acls = ""; + + /* Use addressbook acls */ + if(preg_match("/".normalizePreg($this->abobjectclass)."/",$dn)) { + $dn = preg_replace("/".normalizePreg($this->abobjectclass).",/","",$dn); + $acls = $this->ui->get_permissions($dn,"addressbook/addressbook",$attr); + } + + /* Use Organizational Person acls */ + else{ + $acls = $this->ui->get_permissions($dn,"users/user",$attr); + } + + return($acls); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Addressbook"), + "plDescription" => _("Addressbook entry acls"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("addons" => _("Addons")), + "plCategory" => array("addressbook" => array("objectClass" => "inetOrgPerson", "description" => _("Addressbook"))), + + "plProvidedAcls" => array( + "sn" => _("Surename"), + "givenName" => _("Given name"), + "telephoneNumber" => _("Telefon number"), + "facsimileTelephoneNumber" => _("Fax number"), + "mobile" => _("Mobile number"), + "homePhone" => _("Home phone number"), + "uid" => _("User identification"), + "mail" => _("Mail address"), + "pager" => _("Pager"), + "o" => _("Organization"), + "ou" => _("Department"), + "l" => _("Location"), + "postalAddress" => _("Postal address"), + "postalCode" => _("Postal address"), + "st" => _("State"), + "initials" => _("Initials"), + "title" => _("Title"), + "homePostalAddress" => _("Home postal address"), + "cn" => _("Common name")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/addressbook/contents.tpl b/gosa-core/plugins/addons/addressbook/contents.tpl new file mode 100644 index 000000000..004e3d2ae --- /dev/null +++ b/gosa-core/plugins/addons/addressbook/contents.tpl @@ -0,0 +1,127 @@ + + + + + +
+ + + + + + + + + + + + + + {$search_result} +
{t}Name{/t}{t}Phone{/t}{t}Fax{/t}{t}Mobile{/t}{t}Private{/t}{t}Contact{/t}
+ + + + + +
{$range_selector}
+ + {if $show_info eq 1} + {include file=$address_info} + {/if} + +
+
+

[i]{t}Information{/t}

+
+
+

+ {t}The telephone list plugin provides list and search facilities for the people in your site. You may want to specify the asterisk [*] like in 'Go*us' to find 'Gonicus'. Use the filters below to narrow down your search.{/t} +

+
+
+
+

[a]{t}Actions{/t}

+
+
+

+{if $internal_createable} +   + {t}Add entry{/t}
+{/if} + +{if $internal eq 0} + {if $internal_editable} +   + {t}Edit entry{/t}
+ {/if} + {if $internal_removeable} +   + {t}Remove entry{/t}
+ {/if} +{/if} +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + +
+{t}Show organizational entries{/t}
+ {t}Show addressbook entries{/t}
+
+ + + + + + +
+ + + +
+ + + + + +
+ + + +
+ + + + + +
+ + +
+ {$apply} +
+
+ + + diff --git a/gosa-core/plugins/addons/addressbook/dial.tpl b/gosa-core/plugins/addons/addressbook/dial.tpl new file mode 100644 index 000000000..b10b8db88 --- /dev/null +++ b/gosa-core/plugins/addons/addressbook/dial.tpl @@ -0,0 +1,15 @@ + + + + + + + + +
+
 
+ {$dial_info} +
 
+   + +
diff --git a/gosa-core/plugins/addons/addressbook/main.inc b/gosa-core/plugins/addons/addressbook/main.inc new file mode 100644 index 000000000..dbfd76022 --- /dev/null +++ b/gosa-core/plugins/addons/addressbook/main.inc @@ -0,0 +1,41 @@ +set_acl_base($ui->dn); + $_SESSION['addressbook']->set_acl_category("addressbook"); + unset($_SESSION['show_info']); + } + $addressbook= $_SESSION['addressbook']; + + /* Execute formular */ + $display= $addressbook->execute (); + $display.= "\n"; + + /* Page header*/ + $display= print_header(get_template_path('images/addressbook.png'), _("Address book")).$display; + + /* Store changes in session */ + $_SESSION['addressbook']= $addressbook; +} +?> diff --git a/gosa-core/plugins/addons/addressbook/remove.tpl b/gosa-core/plugins/addons/addressbook/remove.tpl new file mode 100644 index 000000000..ba3768537 --- /dev/null +++ b/gosa-core/plugins/addons/addressbook/remove.tpl @@ -0,0 +1,18 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}This includes all addressbook data in this entry. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ +   + +

+ diff --git a/gosa-core/plugins/addons/bugsubmitter/class_bugsubmitter.inc b/gosa-core/plugins/addons/bugsubmitter/class_bugsubmitter.inc new file mode 100644 index 000000000..c9dbebda4 --- /dev/null +++ b/gosa-core/plugins/addons/bugsubmitter/class_bugsubmitter.inc @@ -0,0 +1,8 @@ +Bugsubmitter"; +} + +?> diff --git a/gosa-core/plugins/addons/bugsubmitter/main.inc b/gosa-core/plugins/addons/bugsubmitter/main.inc new file mode 100644 index 000000000..82efded1d --- /dev/null +++ b/gosa-core/plugins/addons/bugsubmitter/main.inc @@ -0,0 +1,5 @@ + diff --git a/gosa-core/plugins/addons/godfs/class_dfsManagment.inc b/gosa-core/plugins/addons/godfs/class_dfsManagment.inc new file mode 100644 index 000000000..913b2707e --- /dev/null +++ b/gosa-core/plugins/addons/godfs/class_dfsManagment.inc @@ -0,0 +1,263 @@ +config = &$config; + $this->ui = &$ui; + + } + + /* Execute is the function all plugins need. It fills the plugin with life and produces the output. */ + function execute() { + + /* Normally you would react to user input here. */ + plugin::execute(); + + $action = ""; + $s_action= ""; + $options = ""; + $regex = ""; + + $icon = 'folder.gif'; + $expandedIcon = 'folder-expanded.gif'; + $base = get_base_from_people($this->ui->dn); + $smarty= get_smarty(); + + foreach ($_POST as $key => $val) { + # delete + if (preg_match("/dfs_del.*/", $key)) { + $s_action = "del"; + $s_entry = preg_replace("/dfs_".$s_action."_/i", "", $key); + $s_entry = preg_replace("/_.*$/", "", $s_entry); + $s_entry = base64_decode($s_entry); + # edit + } elseif (preg_match("/dfs_edit.*/", $key)) { + $s_action = "edit"; + $s_entry = preg_replace("/dfs_".$s_action."_/i", "", $key); + $s_entry = preg_replace("/_.*$/", "", $s_entry); + $s_entry = base64_decode($s_entry); + # new + } elseif (preg_match("/dfs_new.*/", $key)) { + $s_action = "new"; + # back + } elseif (preg_match("/dfs_back.*/", $key)) { + $s_action = "back"; + # home + } elseif (preg_match("/dfs_home.*/", $key)) { + $s_action = "home"; + # root + } elseif (preg_match("/dfs_root.*/", $key)) { + $s_action = "root"; + } + } + + $tree = new HTML_TreeMenu(); + + if ((isset($_GET['act'])) && ($_GET['act'] == "edit_entry")) { + $s_action = "edit"; + $dfs_share = $_GET['id']; + } + + # new + if ($s_action == "new") { + $this->dn = "new"; + $this->dfstab = new dfstabs($this->config, $this->config->data['TABS']['DFSTABS'], $this->dn); + } + + # edit + if (($_SERVER['REQUEST_METHOD'] == "POST") || ($_SERVER['REQUEST_METHOD'] == "GET")) { + if ($s_action == "edit") { + + $this->dn = $dfs_share; + + if (($user = get_lock($this->dn)) != "") { + return (gen_locked_message ($user, $this->dn)); + } else { + add_lock ($this->dn, $this->ui->dn); + } + + $this->acl = get_permissions($this->dn, $this->ui->subtreeACL); + + $this->dfstab = new dfstabs($this->config, $this->config->data['TABS']['DFSTABS'], $this->dn); + $this->dfstab->set_acl($this->acl); + $this->dfstab->save_object(); + $_SESSION['objectinfo']= $this->dn; + } + } + + # save pressed + if (isset($_POST['edit_finish'])) { + $this->dfstab->last = $this->dfstab->current; + $this->dfstab->save_object(); + #$disp = $this->by_object['']; + #var_dump($disp); + + $message = $this->dfstab->check(); + + # any errors? + if (count($message) == 0) { + # write to ldap + $this->dfstab->save(); + } else { + show_errors($message); + } + } + + # cancel pressed + if (isset($_POST['edit_cancel'])) { + del_lock ($_SESSION['objectinfo']); + unset ($this->dfstab); + $this->dfstab = NULL; + $this->dn = ""; + unset($_SESSION['objectinfo']); + } + + # delete pressed + if (isset($_POST['edit_delete'])) { + + # get the current values + $this->sambasharename = $_POST['sambaShareName']; + $this->sharedescription = $_POST['description']; + $this->fileserver = $_POST['fileserver']; + $this->share = $_POST['fileservershare']; + $this->loc = $_POST['location']; + + $base = get_base_from_people($this->ui->dn); + $ou = get_ou("DFS"); + $this->basedn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->basedn); + $ldap->rmdir($this->basedn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of DFS share with dn '%s' failed."),$this->dn)); + + del_lock ($_SESSION['objectinfo']); + unset ($this->dfstab); + $this->dfstab = NULL; + $this->dn = ""; + unset($_SESSION['objectinfo']); + } + + # generate main page no tabs + + $ldap = $this->config->get_ldap_link(); + + $ou = get_ou("DFS"); + + $ldap->cd("$ou$base"); + $ldap->search(("ou=*"), array("dn")); + + if ($ldap->count() == 0) { + $message[] = _("No DFS entries found"); + show_errors ($message); + } else { + $have_tree= false; + while ($dfs = $ldap->fetch()) { + if (preg_match("/^ou=DFS.*/", $dfs["dn"])) { + $dfs_root_node = new HTML_TreeNode(array('text' => "DFS", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => false)); + $have_tree= true; + } elseif ($have_tree) { + preg_match("/^ou=(.*),/U", $dfs["dn"], $reg); + $loc = $reg[1]; + $node = $dfs_root_node->addItem(new HTML_TreeNode(array('text' => "$loc", 'icon' => $icon, 'expandedIcon' => $expandedIcon))); + + $sub_node_ldap = $this->config->get_ldap_link(); + $sub_node_ldap->cd("ou=$loc, $ou$base"); + $sub_node_ldap->search("(objectclass=sambaShare)", array("sambaShareName", "description", "documentLocation")); + + while ($dfs_loc = $sub_node_ldap->fetch()) { + $share_name = $dfs_loc["sambaShareName"][0]; + $desc = $dfs_loc["description"][0]; + $srv_loc = preg_replace("/msdfs:/", "", $dfs_loc["documentLocation"][0]); + #$srv_loc = preg_replace("/\\/", "\\\\", $srv_loc); + $link = "main.php\?plug=".$_GET['plug']."\&id=$loc\/$share_name\&act=edit_entry"; + $share_node = &$node->addItem(new HTML_TreeNode(array('text' => "$share_name - $desc", 'link' => "$link", 'icon' => $icon, 'expandedIcon' => $expandedIcon))); + $srv_loc_node = &$share_node->addItem(new HTML_TreeNode(array('text' => "$srv_loc", 'icon' => $icon, 'expandedIcon' => $expandedIcon))); + } + } + } + } + + $tree->addItem($dfs_root_node); + + // Create the presentation class + $treeMenu = new HTML_TreeMenu_DHTML($tree, array('images' => 'images', 'defaultClass' => 'treeMenuDefault')); + $tree_html = $treeMenu->toHTML(); + + if ($this->dfstab === NULL) { + + if (($message = check_sizelimit()) != "") { + return ($message); + } + + $listhead = "
". + "  ". + "  ". + "  ". + "  ". + _("Base")." ". + "  
"; + + + /* Use the smarty templating engine here... */ + + $smarty->assign('tree', $tree_html); + $smarty->assign('search_image', get_template_path('images/search.png')); + $smarty->assign('infoimage', get_template_path('images/info.png')); + $smarty->assign('launchimage', get_template_path('images/launch.png')); + $smarty->assign('alphabet', generate_alphabet()); + $smarty->assign('hint', print_sizelimit_warning()); + $smarty->assign('apply', apply_filter()); + $smarty->assign('dfshead', $listhead); + + /* Let smarty fetch and process the page. Always seperate PHP and HTML as much as + you can. */ + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + /* TABS */ + + $display = $this->dfstab->execute(); + + $display .= "

\n"; + $display .= " \n"; + $display .= " \n"; + $display .= " \n"; + $display .= " \n"; + $display .= " \n"; + $display .= " \n"; + $display .= "
\n"; + $display .= " \n"; + $display .= "  \n"; + $display .= " \n"; + $display .= "
\n"; + $display .= "

\n"; + + return ($display); + + } + + function remove_lock() { + if (isset($this->dn)) { + del_lock ($this->dn); + } + } + +} +?> diff --git a/gosa-core/plugins/addons/godfs/class_dfsgeneric.inc b/gosa-core/plugins/addons/godfs/class_dfsgeneric.inc new file mode 100644 index 000000000..12a2ed2df --- /dev/null +++ b/gosa-core/plugins/addons/godfs/class_dfsgeneric.inc @@ -0,0 +1,223 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Needed values and lists */ + var $base = ""; + var $cn = ""; + + /* attribute list for save action */ + var $attributes = array(); + var $objectclasses = array(); + + function dfsgeneric(&$config, $dn) { + plugin::plugin($config, $dn); + $this->dn = $dn; + $this->orig_dn = $dn; + } + + function execute() { + /* Call parent execute */ + plugin::execute(); + + $smarty= get_smarty(); + + if (($this->dn == "new") || ($this->dn == "")) { + $smarty->assign("sambasharename", ""); + $smarty->assign("sharedescription", ""); + $smarty->assign("fileserver", ""); + $smarty->assign("fileservershare", ""); + $smarty->assign("location", ""); + $smarty->assign("dfsdescription", ""); + } else { + $ldap = $this->config->get_ldap_link(); + + $base = get_base_from_people($this->dn); + $ou = get_ou("DFS"); + + $tmp = preg_split('/\//', $this->dn, 2); + $this->loc = $tmp[0]; + $this->sambasharename = $tmp[1]; + + $ldap->cd("$ou $base"); + $ldap->search(("ou=$this->loc"), array("description")); + $dfs_desc = $ldap->fetch(); + $this->dfsdescription = $dfs_desc['description'][0]; + + $ldap->cd("ou=$this->loc, $ou $base"); + $ldap->search("(&(sambaShareName=$this->sambasharename)(objectclass=sambaShare))", array("description", "documentLocation")); + + $details = $ldap->fetch(); + $this->sharedescription = $details['description'][0]; + $tmp = preg_split('/\\\\/', $details['documentLocation'][0], 2); + + $this->fileserver = preg_replace("/msdfs:/", "", $tmp[0]); + $this->share = preg_replace("/\\\/", "", $tmp[1]); + + #var_dump($this->dn); + #echo "
\n"; + + /* Fill array */ + #$this->reload(); + $smarty->assign("sambasharename", $this->sambasharename); + $smarty->assign("sharedescription", $this->sharedescription); + $smarty->assign("fileserver", $this->fileserver); + $smarty->assign("fileservershare", $this->share); + $smarty->assign("location", $this->loc); + $smarty->assign("dfsdescription", $this->dfsdescription); + } + + /* Show main page */ + return ($smarty->fetch (get_template_path('generic.tpl', TRUE))); + #, dirname(__FILE__)))); + } + + function check() + { + plugin::check(); + $message = array(); + + ## permission + #if (chkacl($this->acl, "create") != "") { + # $message[] = _("You have no premissions to create a dfs share."); + #} + + # existance + + $ldap = $this->config->get_ldap_link(); + $base = get_base_from_people($this->ui->dn); + $ou = get_ou("DFS"); + $dn_explode = explode("/", $this->dn); + $sub_ou = $dn_explode[0]; + $sambaShareName = $dn_explode[1] . "/" . $dn_explode[2] . "/" . $dn_explode[3]; + $dn = "sambaShareName=$sambaShareName,ou=$sub_ou,$ou$base"; + $ldap->cat($dn); + $attrs = $ldap->fetch(); + + if ($this->orig_dn == "new" && !($attrs == FALSE)) { + $message[] = _("Dfs share already exists."); + } elseif ($this->orig_dn != $this->dn && !($attrs == FALSE)) { + $message[] = _("Dfs share already exists."); + } + + if ($this->dn == "new" || $this->dn == "") { + $this->sambasharename = $_POST['sambaShareName']; + $this->sharedescription = $_POST['description']; + $this->fileserver = $_POST['fileserver']; + $this->share = $_POST['fileservershare']; + $this->loc = $_POST['location']; + } + + # required fields set? + if ($this->sambasharename == "") { + $message[] = _("Required Field \"Name of dfs Share\" is not set."); + } + if ($this->sharedescription == "") { + $message[] = _("Required Field \"Description\" is not set."); + } + if ($this->fileserver == "") { + $message[] = _("Required Field \"Fileserver\" is not set."); + } + if ($this->share == "") { + $message[] = _("Required Field \"Share on fileserver\" is not set."); + } + if ($this->loc == "") { + $message[] = _("Required Field \"Location\" is not set."); + } + + return $message; + } + + function save() { + + plugin::save(); + + # get the current values + $this->sambasharename = $_POST['sambaShareName']; + $this->sharedescription = $_POST['description']; + $this->fileserver = $_POST['fileserver']; + $this->share = $_POST['fileservershare']; + $this->loc = $_POST['location']; + + # set the attribs + $this->attrs["sambaShareName"] = "$this->sambasharename,ou=$this->loc,$ou$base"; + $this->attrs["objectClass"][] = "top"; + $this->attrs["objectClass"][] = "SambaShare"; + $this->attrs["objectClass"][] = "extensibleObject"; + $this->attrs["sambaShareName"] = $this->sambasharename; + $this->attrs["description"] = $this->sharedescription; + $this->attrs["documentLocation"] = "msdfs:$this->fileserver\\\\$this->share"; + + $ldap = $this->config->get_ldap_link(); + + if ($this->dn == "new" || $this->dn == "") { + echo "new
\n"; + $base = get_base_from_people($this->ui->dn); + $ou = get_ou("DFS"); + $this->basedn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; + $ldap->cd($this->basedn); + $ldap->add($this->attrs); + } else { + # try to find entry + $base = get_base_from_people($this->ui->dn); + $ou = get_ou("DFS"); + #$dn_explode = explode("/", $this->sambasharename); + #$sub_ou = $dn_explode[0]; + #$sambaShareName = $dn_explode[1] . "/" . $dn_explode[2] . "/" . $dn_explode[3]; + $dn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; + $ldap->cat($dn); + $attrs = $ldap->fetch(); + + $this->basedn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; + $ldap->cd($this->basedn); + $nr = count($attrs); + + if (count($attrs)) { + # modify if found + $ldap->modify($this->attrs); + } else { + # add + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving dfs/generic with dn '%s' failed."),$this->basedn)); + } + } + + function save_object() { + #if (isset($_POST['base'])) { + plugin::save_object(); + #echo "base = ".$_POST['base']."
\n"; + #} +# if (chkacl($this->acl, "create") == "") { + $this->base = $_POST['base']; +# } + } + + function delete() { + + plugin::delete(); + + # get the current values + $this->sambasharename = $_POST['sambaShareName']; + $this->sharedescription = $_POST['description']; + $this->fileserver = $_POST['fileserver']; + $this->share = $_POST['fileservershare']; + $this->loc = $_POST['location']; + + $base = get_base_from_people($this->ui->dn); + $ou = get_ou("DFS"); + $this->basedn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; + echo "BASEDN: $this->basedn
\n"; + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->basedn); + $ldap->rmdir($this->basedn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing dfs/generic with dn '%s' failed."),$this->basedn)); + } + + } + diff --git a/gosa-core/plugins/addons/godfs/contents.tpl b/gosa-core/plugins/addons/godfs/contents.tpl new file mode 100644 index 000000000..e5f2206ab --- /dev/null +++ b/gosa-core/plugins/addons/godfs/contents.tpl @@ -0,0 +1,54 @@ + + + + + + + +
+
+

+ {t}DFS Shares{/t} {$hint} +

+
+
+ {$dfshead} +
+
+
+ {$tree} + +
+
+
+

[i]{t}Information{/t}

+
+
+

+ {t}This menu allows you to create, delete and edit selected dfs shares. Having a large numbers of dfs shares, you might prefer the range selectors on top of the dfs share list.{/t} +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + +
+ + + +
+ {$apply} +
+
+ + diff --git a/gosa-core/plugins/addons/godfs/generic.tpl b/gosa-core/plugins/addons/godfs/generic.tpl new file mode 100644 index 000000000..4f3ded4d2 --- /dev/null +++ b/gosa-core/plugins/addons/godfs/generic.tpl @@ -0,0 +1,52 @@ + + + + + + +
+

{t}DFS Properties{/t}

+ + + + + + + + + + + + + + + + + + +
{$must}
{$must}
{$must}
{$must}
+ +
+   + +

{t}DFS Location{/t}

+ + + + + + + + + + +
{$must}
+ +
+ + + diff --git a/gosa-core/plugins/addons/godfs/main.inc b/gosa-core/plugins/addons/godfs/main.inc new file mode 100644 index 000000000..56fc3c0e4 --- /dev/null +++ b/gosa-core/plugins/addons/godfs/main.inc @@ -0,0 +1,42 @@ +remove_lock(); + del_lock($ui->dn); + sess_del('dfsManagment'); + } + } else { + # create dfsManagment object + if (!isset($_SESSION['dfsManagment']) || + (isset($_GET['reset']) && $_GET['reset'] == 1)) { + $_SESSION['dfsManagment'] = new dfsManagment($config, $_SESSION['ui']); + } + $dfsManagment = $_SESSION['dfsManagment']; + $output = $dfsManagment->execute(); + + # do we have to reset + if (isset($_GET['reset']) && $_GET['reset'] == 1) { + del_lock ($ui->dn); + sess_del('dfsManagment'); + } + + # create page header + if (isset($_SESSION['objectinfo'])) { + $display = print_header(get_template_path('images/dfs.png'), + _("Distributed File System Administration"), + "\"\" ".$_SESSION['objectinfo']); + } else { + $display = print_header(get_template_path('images/dfs.png'), + _("Distributed File System Administration")); + } + + $display.= $output; + + # show page + $_SESSION['dfsManagment'] = $dfsManagment; + } + +?> diff --git a/gosa-core/plugins/addons/godfs/tabs_dfs.inc b/gosa-core/plugins/addons/godfs/tabs_dfs.inc new file mode 100644 index 000000000..ef5950ebe --- /dev/null +++ b/gosa-core/plugins/addons/godfs/tabs_dfs.inc @@ -0,0 +1,39 @@ +base = $this->by_object['dfsManagment']->base; + } + + #function save_object() { + # if (isset($_POST['base'])) { + # plugin::save_object(); + # } else { + # $this->base = $_POST['base']; + # } + #} + + + + + function check($ignore_account= FALSE) { + return (tabs::check(TRUE)); + } + + function save($ignore_account= FALSE) + { + $baseobject = $this->by_object['dfsManagment']; + return tabs::save(TRUE); + } + + function del() { + $baseobject = $this->by_object['dfsManagment']; + return tabs::delete(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/addons/gotomasses/class_divListMasses.inc b/gosa-core/plugins/addons/gotomasses/class_divListMasses.inc new file mode 100644 index 000000000..f32f76b51 --- /dev/null +++ b/gosa-core/plugins/addons/gotomasses/class_divListMasses.inc @@ -0,0 +1,170 @@ +parent = $parent; + $this->ui = get_userinfo(); + $this->SetSummary(_("List of system deployment tasks")); + $this->SetHeadpageMode(); + $this->EnableCloseButton(FALSE); + $this->EnableSaveButton(FALSE); + $this->SetInformation(_("This menu allows you to add, remove and change the properties of system deployment tasks.")); + + foreach($this->parent->get_actions() as $name => $desc){ + $this->$name = TRUE; + $this->AddCheckBox($name,sprintf(_("Display entries with action %s."),$desc), + sprintf(_("Display entries with action %s."),$desc),TRUE); + } + $plug = $_GET['plug']; + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>""._("#")."", + "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>""._("Target")." / ". + ""._("Task")."")); + $this->AddHeader(array("string"=>""._("Schedule")."", + "attach"=>"style='width:100px;'")); + $this->AddHeader(array("string"=>""._("Type")."", + "attach"=>"style='width:80px;'")); + $this->AddHeader(array("string"=>_("Action"), + "attach"=>"style='border-right:0px;width:120px;'")); + } + + function GenHeader() + { + + /* Display add button if allowed */ + $header = "
"; + if($this->parent->acl_is_createable()){ + $header .= " "; + } + + /* Display add button if allowed */ + if($this->parent->acl_is_removeable()){ + $header .= " "; + } + + /* Add priority options */ + if(preg_match("/w/",$this->parent->getacl(""))){ + $header .= " "; + $header .= " "; + $header .= " "; + $header .= " "; + } + $header .= "
"; + + /* Create divlist */ + $this->SetListHeader($header); + + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + + function setEntries($tasks) + { + /* Create edit link */ + $plug = $_GET['plug']; + $edit_link = "
%str%
"; + + /* Create action filter array, to sort out those actions we do not want to see */ + $allowed_action = array(); + foreach($this->parent->get_actions() as $name => $desc){ + if($this->$name){ + $allowed_action[] = $name; + } + } + + $colors[0] = "#DDDDDD"; + $colors[1] = "#EEEEEE"; + $c_keys = array(); + $last_c = 0; + if($this->parent->sort_dir=="down"){ + $last_c = !$last_c; + } + + foreach($tasks as $key => $task){ + + /* Skip unchecked actions */ + if(!in_array($task['Action'],$allowed_action)){ + continue; + } + + /* Handle coloring */ + $color=""; + if($this->parent->sort_by == "TaskID"){ + if(!in_array($task['TASK_ID'],$c_keys)){ + $c_keys[] = $task['TASK_ID']; + $last_c = !$last_c; + } + $color = "background-color: ".$colors[$last_c]; + } + + /* Create actions */ + $id = $task['ID']; + $queue_pos = $task['Queue_Position']; + $prio_actions = " "; + $prio_actions.= " "; + $prio_actions.= " "; + $prio_actions.= " "; + $action = ""; + if($this->parent->acl_is_removeable()){ + $action.= ""; + } + + $display = preg_replace(array("/%id%/","/%str%/"),array($id,$this->parent->target_to_string($task)),$edit_link); + $display2= $this->parent->get_additional_entry_informations($task); + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;".$color."'"); + $field0a= array("string" => $queue_pos ,"attach" => "style='width:20px;".$color."'"); + $field1 = array("string" => $display, + "attach" => "style='".$color."'"); + $field1a= array("string" => $display2, + "attach" => "style='".$color.";width:80px;'"); + $field2 = array("string" => $this->parent->time_to_string($task),"attach" => "style='".$color.";width:100px;'"); + $field3 = array("string" => $this->parent->action_to_string($task),"attach" => "style='".$color.";width:80px;'"); + $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'"); + $this->AddElement(array($field0,$field0a,$field1,$field1a,$field2,$field3,$field4)); + } + } + + + function Save() + { + MultiSelectWindow :: Save(); + } + + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow :: save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/gotomasses/class_goto_task.inc b/gosa-core/plugins/addons/gotomasses/class_goto_task.inc new file mode 100644 index 000000000..d53a4c2b4 --- /dev/null +++ b/gosa-core/plugins/addons/gotomasses/class_goto_task.inc @@ -0,0 +1,485 @@ +parent = &$parent; + + /* Intialize plugin */ + $this->config = &$config; + if(count($data)){ + $tmp = $this->get_array_values(); + foreach($this->attributes as $attr){ + if(!isset($data[$attr])){ + trigger_error("Missing parameter: '".$attr."' for goto_task contruction."); + }else{ + $this->$attr = $data[$attr]; + } + } + }else{ + $this->new = TRUE; + } + + if(!empty($this->Zone) && !preg_match("/^\"\"$/",$this->Zone)){ + $this->configure_dns = TRUE; + } + if(!empty($this->Section) && !preg_match("/^\"\"$/",$this->Section)){ + $this->configure_dhcp = TRUE; + } + + /* Set dns and dhcp attributes */ + foreach(getAvailableZones($this->config) as $zone){ + $name = preg_replace("#^[^/]+/#","",$zone); + $this->Zones[$name] = $zone; + } + $this->Sections = $this->get_dhcp_sections(); + + /* Create ogroup select list */ + $this->OGroups = array("\"\"" => "["._("Keep current")."]"); + $this->OGroups = array_merge($this->OGroups,$this->parent->get_object_groups()); + + /* Prepare list of available actions */ + $this->Actions = $this->parent->get_actions(); + } + + + function execute() + { + /******** + * Handle Posts + ********/ + + /* Handle Target options */ + foreach($_POST as $name => $value){ + if(preg_match("/^remove_/",$name)){ + $value = preg_replace("/^remove_([0-9]*)_(x|y)$/i","\\1",$name); + if(isset($this->Target[$value]) && $this->Action != "initial_install"){ + unset($this->Target[$value]); + }elseif(isset($this->Initial_Target[$value]) && $this->Action == "initial_install"){ + unset($this->Initial_Target[$value]); + } + } + } + + if($this->Action != "initial_install"){ + + /* Add target */ + if($this->ID == 0 && isset($_POST['add_target']) && !empty($_POST['target_text'])){ + $target = get_post("target_text"); + if($this->is_valid_target($target) && !in_array($target,$this->Target)){ + $this->Target[] = $target; + }else{ + print_red(_("You must specify a valid MAC address or host name.")); + } + } + }else{ + + /* Add target */ + if($this->ID ==0 && isset($_POST['add_target']) && !empty($_POST['task_MAC'])){ + $MAC = $_POST['task_MAC']; + $NAME= ""; + $IP = ""; + $DNS = ""; + $DHCP = ""; + if(isset($_POST['task_Name'])){ + $NAME = $_POST['task_Name']; + } + if(isset($_POST['task_IP']) && is_ip($_POST['task_IP'])){ + $IP = $_POST['task_IP']; + } + if(isset($_POST['configure_dns']) && isset($_POST['Zone']) && isset($this->Zones[$_POST['Zone']])){ + $DNS = $_POST['Zone']; + } + if(isset($_POST['configure_dhcp']) && isset($_POST['Section']) && isset($this->Sections[$_POST['Section']])){ + $DHCP = $_POST['Section']; + } + if(is_mac($MAC)){ + $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME); + } + } + } + + /* Add via csv */ + if($this->ID == 0 && isset($_FILES['import_file'])){ + $file = $_FILES['import_file']['tmp_name']; + if(file_exists($file) && is_readable($file)){ + $str =""; + $fp = fopen($file,"r"); + while(!feof($fp)){ + $line = fgets($fp,512); + $tmp = preg_split("/(,|;)/",$line); + + $MAC = $IP = $NAME; + if(isset($tmp[0])){ + $MAC = trim($tmp[0]); + } + if(isset($tmp[1])){ + $IP = trim($tmp[1]); + } + if(isset($tmp[2])){ + $NAME = trim($tmp[2]); + } + if(is_mac($MAC)){ + $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME); + } + } + } + } + + /******** + * Add target from list + ********/ + + /* If add from list is was requsted, display this list */ + if(isset($_POST['add_from_list'])){ + $this->dialog = new target_list($this->config,$this->Target); + } + + /* Save selected objects as target */ + if(isset($_POST['SaveMultiSelectWindow']) && is_object($this->dialog)){ + $this->dialog->save_object(); + $ret = $this->dialog->save(); + foreach($ret as $entry){ + $this->Target[] = $entry['cn'][0]; + } + $this->dialog = FALSE; + } + + /* Cancel object listing */ + if(isset($_POST['CloseMultiSelectWindow'])){ + $this->dialog = FALSE; + } + + /* Display object Listing */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + /******** + * Display this plugin + ********/ + + $divlist = new divlist("goto_task"); +# $divlist->SetPluginMode(); + $divlist->setHeight(200); + $divlist->SetWidth("100%"); + $divlist->SetEntriesPerPage(0); + + $acl_target = $this->parent->getacl("Target"); + if(preg_match("/w/i",$acl_target)){ + $field_del = array("string" => "" , + "attach" => "style='width:44px;border-right:0px;'"); + }else{ + $field_del = array("string" => "", + "attach" => "style='width:44px;border-right:0px;'"); + } + + /* Add entries to divlist */ + if($this->Action == "initial_install"){ + $divlist->SetHeader(array( + array("string" => _("Target systems") ,"attach" => "style='width:120px;'"), + array("string" => _("IP") , "attach" => "style='width:90px;'"), + array("string" => _("Name") , "attach" => "style='width:150px;'"), + array("string" => _("Actions") , "attach" => "style='width:44px;border-right:0px;text-align:right;'"))); + foreach($this->Initial_Target as $key => $target){ + $field1 = array("string" => $target['MAC'] ,"attach" => "style='width:120px;'"); + $field2 = array("string" => $target['IP'] ,"attach" => "style='width:90px;'"); + $field3 = array("string" => $target['NAME'] ,"attach" => "style='width:150px;'"); + $divlist->AddEntry(array($field1,$field2,$field3,preg_replace("/%KEY%/",$key,$field_del))); + } + }else{ + $divlist->SetHeader(array( + array("string" => "Target", "attach" => "style=''"), + array("string" => "Actions" , "attach" => "style='width:44px;border-right:0px;text-align:right;'"))); + foreach($this->Target as $key => $target){ + $field1 = array("string" => $target); + $divlist->AddEntry(array($field1,preg_replace("/%KEY%/",$key,$field_del))); + } + } + + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL", $this->parent->getacl($attr)); + $smarty->assign($attr,$this->$attr); + } + + $smarty->assign("Zones", $this->Zones); + $smarty->assign("Sections", $this->Sections); + + $smarty->assign("ID",$this->ID); + + $smarty->assign("Zone", $this->Zone); + $smarty->assign("Section", $this->Section); + + $smarty->assign("configure_dhcp", $this->configure_dhcp); + $smarty->assign("configure_dns", $this->configure_dns); + + $tmp = $this->get_array_values(); + $smarty->assign("JS" , $_SESSION['js']); + $smarty->assign("Minutes" , $tmp['Minute']); + $smarty->assign("Hours" , $tmp['Hour']); + $smarty->assign("Days" , $tmp['Day']); + $smarty->assign("Months" , $tmp['Month']); + $smarty->assign("Weekdays", $tmp['Weekday']); + $smarty->assign("OGroups" , $this->OGroups); + $smarty->assign("Actions" , $this->Actions); + $smarty->assign("Target_list" , $divlist->DrawList()); + $smarty->assign("new" , $this->new); + return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE))); + } + + + function create_tree($arr,$base,$current = "") + { + $ret = array(); + foreach($arr as $r => $name){ + $base_part = str_replace($base,"",$r); + if(preg_match("/^[a-z]*=".normalizePreg($name)."(|,)$/i",$base_part)){ + $ret[$r] = $current.$name; + $tmp = $this->create_tree($arr,$r,$current.". "); + foreach($tmp as $sub_key => $sub_name){ + $ret[$sub_key] = $sub_name; + } + } + } + return($ret); + } + + + + function get_dhcp_sections() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=dhcpService)",array("dhcpPrimaryDN")); + + $tmp = array(); + $tmp2 = array(); + + $dhcp_dns = array(); + while($attr = $ldap->fetch()){ + $dhcp_dns[$attr['dn']] = $attr['dhcpPrimaryDN'][0]; + } + + foreach($dhcp_dns as $key => $pri_dns){ + $ldap->cat($pri_dns,array("cn")); + $tmp = $ldap->fetch(); + $dhcp_dns[$key] = $tmp['cn'][0]; + } + + foreach($dhcp_dns as $dn => $cn){ + $ldap->cd($dn); + $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpGroup)". + "(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork))",array("cn")); + $tmp = array(); + while($attr = $ldap->fetch()){ + $tmp[$attr['dn']] = $attr['cn'][0]; + } + $tmp2 = $this->create_tree($tmp,preg_replace("/^[^,]+,/i","",$dn),"(".$cn.") "); + } + $ret = array(); + foreach($tmp2 as $key => $label){ + $ret[$tmp[$key]] = $label; + } + return($ret); + } + + + /* check given values */ + function check() + { + $message = plugin::check(); + $tmp = array( + "OGroup" => _("Object group") ,"Minute" => _("Minute"), + "Hour" => _("Hour") ,"Day" => _("Day"), + "Month" => _("Month") ,"Weekday"=> _("Week day"), + "Action" => _("Action") ,"Comment"=> _("Description")); + + foreach($tmp as $name => $desc){ + if(empty($this->$name) && $this->$name != 0){ + $message[] = sprintf(_("The given value for attribute '%s' is invalid."),$desc); + } + } + if(count($this->Target) == 0 && $this->Action != "initial_install"){ + $message[] = sprintf(_("You must specify at least one target")); + } + if(count($this->Initial_Target) == 0 && $this->Action == "initial_install"){ + $message[] = sprintf(_("You must specify at least one target")); + } + return($message); + } + + + /* Map acl function, to be able to use plugin::save_object() */ + function acl_is_writeable($attribute,$skip_write = FALSE) + { + return($this->parent->acl_is_writeable($attribute,$skip_write)); + } + + + function save_object() + { + if(isset($_POST['goto_task_posted'])){ + + if($this->Action == "initial_install"){ + if(isset($_POST['configure_dns'])){ + $this->configure_dns = TRUE; + if(isset($_POST['Zone'])){ + $this->Zone = get_post("Zone"); + } + }else{ + $this->Zone = "\"\""; + $this->configure_dns = FALSE; + } + + if(isset($_POST['configure_dhcp'])){ + $this->configure_dhcp = TRUE; + if(isset($_POST['Section'])){ + $this->Section = get_post("Section"); + } + }else{ + $this->configure_dhcp = FALSE; + $this->Section = "\"\""; + } + } + plugin::save_object(); + } + } + + + /* Check if given target is vald. + * It must either be a valid MAC address or an existing object group + */ + function is_valid_target($str) + { + if(is_mac($str)){ + return(TRUE); + }else{ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClassgosaGroupOfNames)(cn=".$str."))",array("cn")); + if($ldap->count()){ + return(TRUE); + } + } + } + + function save() + { + $tmp = array(); + foreach($this->attributes as $attr){ + $tmp[$attr] = $this->$attr; + } + + if($this->Action != "initial_install" || !$this->configure_dns){ + $tmp['Zone'] = "\"\""; + } + if($this->Action != "initial_install" || !$this->configure_dhcp){ + $tmp['Section'] = "\"\""; + } + return($tmp); + } + + + /* Return values for listboxes. + */ + function get_array_values() + { + $ret = array(); + + /* Create minute array */ + $Minute = array( "*" => "*", + "*/1" => "*/1", + "*/3" => "*/3", + "*/5" => "*/5", + "*/10" => "*/10", + "*/15" => "*/15", + "*/30" => "*/30", + "*/45" => "*/45", + "*/60" => "*/60"); + for($i = 0; $i < 60 ; $i ++){ + $Minute[$i] = $i; + } + + /* Create hour array */ + $Hour = array( "*" => "*"); + for($i = 1 ; $i < 24 ; $i ++ ){ + $Hour["*/".$i] = "*/".$i; + } + for($i = 0 ; $i < 24 ; $i ++ ){ + $Hour[$i] = $i; + } + + /* Create hour array */ + $Day = array( "*" => "*"); + for($i = 1 ; $i < 32 ; $i ++ ){ + $Day["*/".$i] = "*/".$i; + } + for($i = 1 ; $i < 32 ; $i ++ ){ + $Day[$i] = $i; + } + + /* Create month array */ + $Month = array( "*" => "*"); + for($i = 1 ; $i <= 12 ; $i ++ ){ + $Month["*/".$i] = "*/".$i; + } + for($i = 1 ; $i <= 12 ; $i ++ ){ + $Month[$i] = $i; + } + + /* Create week day array */ + $Weekday = array( "*" => "*"); + for($i = 1 ; $i <= 7 ; $i ++ ){ + $Weekday["*/".$i] = "*/".$i; + } + for($i = 0 ; $i <= 7 ; $i ++ ){ + $Weekday[$i] = $i; + } + + foreach(array("Minute","Weekday","Hour","Day","Month") as $var){ + $ret[$var] = $$var; + } + return($ret); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc new file mode 100644 index 000000000..adf221859 --- /dev/null +++ b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc @@ -0,0 +1,431 @@ +config= &$config; + $this->divlist = new divListMasses($this->config,$this); + $this->o_queue = new hostActionQueue(&$config); + } + + + function execute() + { + $smarty = get_smarty(); + /************ + * Handle posts + ************/ + + $s_entry = $s_action = ""; + $arr = array( + "/^prio_top_/" => "prio_top", + "/^prio_increase_/" => "prio_increase", + "/^prio_decrease_/" => "prio_decrease", + "/^prio_bottom_/" => "prio_bottom", + + "/^multiple_prio_top_/" => "mprio_top", + "/^multiple_prio_increase_/" => "mprio_increase", + "/^multiple_prio_decrease_/" => "mprio_decrease", + "/^multiple_prio_bottom_/" => "mprio_bottom", + + "/^edit_task_/"=>"edit","/^remove_task_/"=>"remove", + "/^new_task_/"=>"new_task","/^remove_multiple_task_/" => "remove_multiple"); + foreach($arr as $regex => $action){ + foreach($_POST as $name => $value){ + if(preg_match($regex,$name)){ + $s_action = $action; + $s_entry = preg_replace($regex,"",$name); + $s_entry = preg_replace("/_(x|y)$/","",$s_entry); + } + } + } + + /* Edit posted from list link */ + if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){ + $s_action = "edit"; + $s_entry = $_GET['id']; + } + + /************ + * REMOVE + ************/ + + if(preg_match("/^mprio_/",$s_action) || preg_match("/^prio_/",$s_action)){ + + switch($s_action){ + case 'mprio_top' : foreach($this->list_get_selected_items() as $id ){ + $this->o_queue->max_entry_priority($id); + } + break; + case 'mprio_increase' : foreach($this->list_get_selected_items() as $id ){ + $this->o_queue->increase_entry_priority($id); + } + break; + case 'mprio_decrease' : foreach($this->list_get_selected_items() as $id ){ + $this->o_queue->decrease_entry_priority($id); + } + break; + case 'mprio_bottom' : foreach($this->list_get_selected_items() as $id ){ + $this->o_queue->min_entry_priority($id); + } + break; + case 'prio_top' : $this->o_queue->max_entry_priority($s_entry);break; + case 'prio_increase' : $this->o_queue->increase_entry_priority($s_entry);break; + case 'prio_decrease' : $this->o_queue->decrease_entry_priority($s_entry);break; + case 'prio_bottom' : $this->o_queue->min_entry_priority($s_entry);break; + default : trigger_error("Undefined priority setting used."); + } + if($this->o_queue->is_error()){ + print_red($this->o_queue->get_error()); + } + } + + /************ + * REMOVE + ************/ + + /* Remove multiple */ + if($s_action == "remove_multiple" || $s_action == "remove"){ + + if(!$this->acl_is_removeable()){ + print_red(_("You are not allowed to remove a task.")); + }else{ + + if($s_action == "remove"){ + $ids = array($s_entry); + }else{ + $ids = $this->list_get_selected_items(); + } + + + $this->ids_to_remove = $ids; + $tmp = ""; + foreach($this->ids_to_remove as $key => $id){ + if($this->o_queue->id_exists($id)){ + $task = $this->o_queue->get_entry($id); + $tmp.= "\n".$this->target_to_string($task); + }else{ + unset($this->ids_to_remove[$key]); + } + } + $smarty->assign("multiple", TRUE); + $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),"
".$tmp."
")); + $this->current = $s_entry; + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + /* Remove specified tasks */ + if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){ + foreach($this->ids_to_remove as $id){ + if($this->o_queue->id_exists($id)){ + $this->o_queue->remove_entry($id); + } + } + $this->save(); + } + + /* Remove aborted */ + if(isset($_POST['delete_cancel'])){ + $this->ids_to_remove = array();; + } + + + /************ + * EDIT + ************/ + + /* Edit selected entry */ + if($s_action == "edit"){ + $entry = $this->o_queue->get_entry($s_entry); + if($entry){ + $this->dialog = new goto_task($this->config,$this,$entry); + $this->current = $s_entry; + } + } + + /* New entry */ + if($s_action== "new_task" && $this->acl_is_createable()){ + $this->dialog = new goto_task($this->config,$this); + $this->current = -1; + } + + /* Close dialog */ + if(isset($_POST['close_goto_task'])){ + $this->dialog = FALSE; + $this->current = -1; + } + + /* Close dialog */ + if((isset($_POST['save_goto_task']) || isset($_POST['apply_goto_task'])) && is_object($this->dialog) ){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + + if($this->o_queue->id_exists($this->current)){ + $this->o_queue->update_entry($this->current,$this->dialog->save()); + }else{ + $tmp = $this->dialog->save(); + $tmp2= array(); + $targets =$tmp['Target']; + foreach($targets as $target){ + $tmp['Target'] = array($target); + $tmp2[] = $tmp; + } + if(!$this->o_queue->add_multiple($tmp2)){ + print_red($this->o_queue->get_error()); + } + } + if(!isset($_POST['apply_goto_task'])){ + $this->dialog = FALSE; + $this->current = -1; + } + $this->save(); + } + } + + /* Display dialogs if currently opened */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + /************ + * Handle Divlist + ************/ + + $this->divlist->execute(); + $this->divlist->SetEntries($this->get_queue_entries()); + $str = + ""; + return($str.$this->divlist->Draw()); + } + + + function get_queue_entries() + { + if(!$this->o_queue->load()){ + print_red("ERROR:".$this->o_queue->get_error()); + return(array()); + } + + $queue_pos = 1; + $tasks = array(); + $ret = array(); + while($entry = $this->o_queue->fetch()){ + $task = $entry['TASK_ID']; + if(!isset($tasks[$task])){ + $tasks[$task] = dechex(rand(100,240)).dechex(rand(100,240)).dechex(rand(100,240)); + } + $entry['Queue_Position'] = $queue_pos; + $entry['color'] = $tasks[$task]; + $ret[]= $entry; + $queue_pos ++; + } + + /* Sort entries */ + $simple_map = array("QueuePosition" => "Queue_Position", + "Action" => "Action", + "TaskID" => "TASK_ID"); + $sort_arr = array(); + if(isset($simple_map[$this->sort_by])){ + foreach($ret as $id => $entry){ + $sort_arr[$entry[$simple_map[$this->sort_by]]][] = $id; + } + } + if($this->sort_by == "TargetName"){ + foreach($ret as $id => $entry){ + $name = $this->target_to_string($entry); + $sort_arr[$name][] = $id; + } + } + if($this->sort_by == "Schedule"){ + foreach($ret as $id => $entry){ + $name = $entry['Minute'].$entry['Hour'].$entry['Day'].$entry['Month'].$entry['Weekday']; + $sort_arr[$name][] = $id; + } + } + if($this->sort_dir == "up"){ + ksort($sort_arr); + }else{ + krsort($sort_arr); + } + $ret2 = array(); + foreach($sort_arr as $key => $entries){ + foreach($entries as $entry_id){ + $ret2[] = $ret[$entry_id]; + } + } + return($ret2); + } + + + function get_additional_entry_informations($data) + { + $i = rand(0,3); + if($i == 0){ + return("
 
"); + } + if($i == 1){ + return("Failed"); + } + if($i == 1){ + return("OK"); + } + return("-"); + } + + + function target_to_string($data) + { + $ret = ""; + if($data['Action'] == "initial_install"){ + foreach($data['Initial_Target'] as $target){ + $ret .= $target['MAC'].", "; + } + }else{ + foreach($data['Target'] as $target){ + $ret .= $target.", "; + } + } + return(preg_replace("/, $/","",$ret)); + } + + + function time_to_string($data) + { + return($data['Minute']." ".$data['Hour']." ".$data['Day']." ".$data['Month']." ".$data['Weekday']); + } + + + function action_to_string($data) + { + $tmp = $this->get_actions(); + if(isset($tmp[$data['Action']])){ + return($tmp[$data['Action']]); + }else{ + return(_("Unknown")); + } + } + + + function save_object() + { + $this->divlist->save_object(); + $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID"); + if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){ + $sort = $_GET['sort']; + if($this->sort_by == $sort){ + if($this->sort_dir == "up"){ + $this->sort_dir = "down"; + }else{ + $this->sort_dir = "up"; + } + } + $this->sort_by = $sort; + } + } + + + /* Return list of object groups */ + function get_object_groups() + { + $ret = array(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn")); + while($attrs = $ldap->fetch()){ + $ret[$attrs['cn'][0]] = $attrs['cn'][0]; + } + return($ret); + } + + + function save() + { + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + function get_actions() + { + /* Prepare list of available actions */ + $actions = array( "reboot" => _("Reboot"), + "localboot" => _("Localboot"), + "halt" => _("Halt system"), + "initial_install" => _("Initial installation"), + "update" => _("Update"), + "reinstall" => _("(Re)Install"), + "rescan" => _("Rescan"), + "wake" => _("Wake"), + "memcheck" => _("Memory check")); + return($actions); + } + + + static function plInfo() + { + return (array( + "plShortName" => _("System mass deployment"), + "plDescription" => _("Provide a mechanism to automatically activate a set of systems"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("addon"), + "plCategory" => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))), + "plProvidedAcls" => array("Comment" => _("Description"), + "Action" => _("Action"), + "Day" => _("Day"), + "Minute" => _("Minute"), + "Hour" => _("Hour"), + "Month" => _("Month"), + "Weekday" => _("Week day"), + "Target" => _("Target")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/gotomasses/class_target_list.inc b/gosa-core/plugins/addons/gotomasses/class_target_list.inc new file mode 100644 index 000000000..6ecd300ef --- /dev/null +++ b/gosa-core/plugins/addons/gotomasses/class_target_list.inc @@ -0,0 +1,303 @@ +AddCheckBox */ + var $ogroups ; + var $servers ; + var $workstations ; + + + /* Subsearch checkbox */ + var $SubSearch ; + var $IPMatch ; + var $parent ; + var $ui ; + + + function target_list(&$config,$Targets_used) + { + MultiSelectWindow::MultiSelectWindow($config, "Targetselection", array("ogroup","gotomasses")); + + $this->Targets_used = $Targets_used; + + $this->SetInformation( _("Select the target objects for your scheduled action.")); + $this->SetTitle( _("Available targets")); + $this->SetSummary( _("Available targets")); + $this->SetHeadpageMode(FALSE); + + /* set Page header */ + $chk = ""; + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Object name"), "attach" => "style=''")); + + /* Text ,Value, Name, Is selected */ + $this->AddCheckBox("ogroups", _("Select to see object groups"), _("Show object groups"), true); + $this->AddCheckBox("servers", _("Select to see servers") , _("Show servers"), true); + $this->AddCheckBox("workstations", _("Select to see workstations"),_("Show workstations"), true); + + /* Add SubSearch checkbox */ + $this->AddCheckBox(SEPERATOR); + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + $this->AddCheckBox("IPMatch", _("Select to search for a specific IP range only"), _("Match IP range"), false); + + /* Name,Text,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true); + $this->AddRegex ("IP_start", _("IP range start"), "0.0.0.0" , true); + $this->AddRegex ("IP_end", _("IP range end"), "255.255.255.255" , true); + $this->EnableAplhabet(TRUE); + } + + + function GenHeader() + { + $options= ""; + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("ogroups"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get copy & paste icon */ + $acls = $ui->get_permissions($this->selectedBase,"ogroups/ogroup"); + $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* Add department selector */ + $listhead .= _("Base")." ". + "  "; + $listhead .=""; + + $this->SetListHeader($listhead); + } + + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + $this->reload(); + $this->SetEntries($this->list); + return($this->Draw()); + } + + + function SetEntries($list) + { + /* Add Copy & Paste buttons if copy&paste is enabled + */ + // Defining Links + $linkopen = "
%s"; + $editlink = "%s"; + + $ui = get_userinfo(); + + // Assigning ogroups + foreach($list as $key => $val){ + + if(in_array($val['cn'][0],$this->Targets_used) || + isset($val['macAddress'][0]) && in_array($val['macAddress'][0],$this->Targets_used)) continue; + + $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; + if(!isset($val['description'][0])){ + $desc = ""; + }else{ + $desc = " - [ ".$val['description'][0]." ]"; + } + if(!isset($val['ipHostNumber'][0])){ + $desc.= ""; + }else{ + $desc.= " - ".$val['ipHostNumber'][0].""; + } + + + $img ="Hmm"; + if(in_array("goServer",$val['objectClass'])){ + $img = ""._("Server").""; + }elseif(in_array("gotoWorkstation",$val['objectClass'])){ + $img = ""._("Workstation").""; + }elseif(in_array("gosaGroupOfNames",$val['objectClass'])){ + $img = ""._("Object group").""; + } + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => $img, + "attach" => "style='text- align:center;width: 20px;'"); + $field2 = array("string" => $val['cn'][0].$desc, + "attach" => "style='border-right:0px;' ".$title); + + $this->AddElement(array($field0,$field1,$field2)); + } + } + + + function save() + { + $ret = array(); + $items = $this->list_get_selected_items(); + foreach($items as $item){ + $ret[] = $this->list[$item]; + } + return($ret); + } + + + function save_object() + { + MultiSelectWindow::save_object(); + } + + + function reload() + { + /* Set base for all searches && initialise some vars */ + $this->list= array(); + $base = $this->selectedBase; + $filter = ""; + $Regex = $this->Regex; + $IP_start = $this->IP_start; + $IP_end = $this->IP_end; + + if($this->IPMatch){ + if(!is_ip($IP_start)){ + print_red(_("Please specify a valid IP range.")); + return; + } + if(!is_ip($IP_end)){ + print_red(_("Please specify a valid IP range.")); + return; + } + } + + + $chk = array( + "ogroups" => "(&(objectClass=gosaGroupOfNames)(|(gosaGroupObjects=*S*)(gosaGroupObjects=*W*)))" , + "servers" => "(objectClass=goServer)" , + "workstations" => "(objectClass=gotoWorkstation)"); + + /* Create filter */ + foreach($chk as $chkBox => $FilterPart){ + if($this->$chkBox){ + $filter .= $FilterPart; + } + } + $filter= "(&(cn=".$Regex.")(|".$filter."))"; + + if($this->SubSearch){ + $res= get_list($filter, array("ogroups","workstations","servers"), $base, + array("cn","objectClass","gosaGroupObjects","ipHostNumber","description"), GL_SIZELIMIT | GL_SUBSEARCH); + }else{ + $res= get_list($filter, "ogroups", get_groups_ou().$base, + array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT ); + $res= array_merge($res,get_list($filter, "workstation", "ou=workstations,ou=systems,".$base, + array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT )); + $res= array_merge($res,get_list($filter, "server", "ou=servers,ou=systems,".$base, + array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT )); + } + + $this->list= $res; + ksort ($this->list); + reset ($this->list); + $tmp=array(); + foreach($this->list as $tkey => $val ){ + + if($this->IPMatch){ + if(isset($val['ipHostNumber'][0])){ + if(is_ip_range($IP_start,$val['ipHostNumber'][0]) && is_ip_range($val['ipHostNumber'][0],$IP_end)){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + } + }else{ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + } + ksort($tmp); + $this->list=array(); + foreach($tmp as $val){ + $this->list[]=$val; + } + reset ($this->list); + } + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/gotomasses/goto_task.tpl b/gosa-core/plugins/addons/gotomasses/goto_task.tpl new file mode 100644 index 000000000..f841a4fd8 --- /dev/null +++ b/gosa-core/plugins/addons/gotomasses/goto_task.tpl @@ -0,0 +1,235 @@ + + + + + + + + +
+

{t}Generic{/t}

+
+ + + + + + + + + + {if $Action == "initial_install"} + + + + + + + + + {/if} +
+ {t}Description{/t} + + {render acl=$CommentACL} + + {/render} +
+ {t}Object group membership{/t} + + {render acl=$OGroupACL} + + {/render} +
+ + + +
+ + + +
+
+ + + + + +
+ {t}Action{/t} + + {render acl=$ActionACL} + + {/render} + {if !$JS} + + {/if} +
+ +
+{if $Action == "initial_install"} +{if $ID == 0} +

 

+ + + + + + + + + + + +
+

{t}Systems{/t}

+
+ + + + +
+ {render acl=$TargetACL} + {$Target_list} + {/render} +
+
+ + + + + + + + + + + + + +
{t}MAC address{/t}{$must} + +
{t}Name{/t} + +
{t}IP address{/t} + + {render acl=$TargetACL} + + {/render} +
+
+ + + + + + + + +
{t}CVS import from file{/t}
+   +
+ + + {render acl=$TargetACL} + + {/render} +
+
+{/if} +{else} +

 

+ + + + + + + +
+

{t}Schedule{/t}

+
+ {t}Minute{/t} + {render acl=$MinuteACL} + + {/render} + {t}Hour{/t} + {render acl=$HourACL} + + {/render} + {t}Day{/t} + {render acl=$DayACL} + + {/render} + {t}Month{/t} + {render acl=$MonthACL} + + {/render} + {t}Week day{/t} + {render acl=$WeekdayACL} + + {/render} +
+{if $ID == 0} +

 

+ + + + + + + +
+

{t}Target systems{/t}

+
+ + + + +
+ {render acl=$TargetACL} + {$Target_list} + {/render} +
+ {render acl=$TargetACL} + + {/render} + {render acl=$TargetACL} + + {/render} + {render acl=$TargetACL} + + {/render} + +
+{/if} +{/if} +

 

+ +

+ +{if !$new} + +{/if} + +

diff --git a/gosa-core/plugins/addons/gotomasses/main.inc b/gosa-core/plugins/addons/gotomasses/main.inc new file mode 100644 index 000000000..abe913f4b --- /dev/null +++ b/gosa-core/plugins/addons/gotomasses/main.inc @@ -0,0 +1,55 @@ +set_acl_category("gotomasses"); + + /* Check root dn and user dn for acl informations */ + $_SESSION['gotomasses']->set_acl_base($config->current['BASE']); + if($_SESSION['gotomasses']->getacl("") == ""){ + $_SESSION['gotomasses']->set_acl_base($ui->dn); + } + + /* Check if we have acl on our own base */ + if($_SESSION['gotomasses']->getacl("") == ""){ + $_SESSION['gotomasses']->set_acl_base(dn2base($ui->dn)); + } + + + } + $gotomasses= $_SESSION['gotomasses']; + + /* Execute formular */ + $display= $gotomasses->save_object(); + if(isset($_POST['save_gotomass_changes'])){ + $gotomasses->save(); + } + $display= $gotomasses->execute (); + + /* Page header*/ + $display= print_header(get_template_path('images/system.png'), _("System deployment")).$display; + + /* Store changes in session */ + $_SESSION['gotomasses']= $gotomasses; +} diff --git a/gosa-core/plugins/addons/gotomasses/remove.tpl b/gosa-core/plugins/addons/gotomasses/remove.tpl new file mode 100644 index 000000000..023142f97 --- /dev/null +++ b/gosa-core/plugins/addons/gotomasses/remove.tpl @@ -0,0 +1,21 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+{if $multiple} + +{else} + +{/if} + +

+ diff --git a/gosa-core/plugins/addons/ldapmanager/class_csvimport.inc b/gosa-core/plugins/addons/ldapmanager/class_csvimport.inc new file mode 100644 index 000000000..66131ca21 --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/class_csvimport.inc @@ -0,0 +1,508 @@ +config= &$config; + + $this->ui = get_userinfo(); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","all/".get_class($this),$this->dn); + } + + /* initiate smarty */ + $smarty= get_smarty(); + $smarty->assign("selectedattrs",array(0=>"")); + $smarty->assign("data",array(0=>"")); + $smarty->assign("head",array(0=>"")); + $smarty->assign("sorted",0); + $smarty->assign("fileup",0); + + /* Get the LDAP link, to generate the Export */ + $ldap = $this->config->get_ldap_link(); + + $arrtemplates = array(); + $tempvar =0; + + /* Array to fill in Formfields */ + $arrtemplates[$tempvar] = "None"; + if(!is_array($this->csvinfo)){ + $this->csvinfo=array(); + } + + /* Set Usertemplate information and get all Attribute from userclass */ + unset ($this->csvinfo['arrtemplates']); + unset ($this->csvinfo['arrtempls']); + + /* Generate Template Array, Attribute Array */ + if(!isset($this->csvinfo['arrtempls'])){ + + /* Generating attributes */ + $attrs = @get_class_vars("user"); + $this->csvinfo['attr'] = $attrs['attributes']; + + /* Attach the choise none to discard a csv col */ + $new = array(); + $new[0]="none"; + $new[1]="userPassword"; + for($c = 0; $c < count($this->csvinfo['attr']);$c++){ + $new[$c+2]=$this->csvinfo['attr'][$c]; + } + + $this->csvinfo['attr'] = $new; + + /* Search all Templates */ + $this->csvinfo['templates'] = $ldap->search("(objectClass=gosaUserTemplate)",array("*")); + + /* Array to handle selected Form fiels */ + $this->csvinfo['arrtempls'][$tempvar]['name'] = ""; + $this->csvinfo['arrtempls'][$tempvar]['dn'] = ""; + + $this->csvinfo['arrtemplates'][]="None"; + + while($temp = $ldap->fetch($this->csvinfo['templates'])){ + $tempvar ++; + $this->csvinfo['arrtemplates'][$tempvar] = $temp['sn'][0]." - ".$this->config->idepartments[preg_replace("/^[^,]+,".get_people_ou()."/i", "", $temp['dn'])]; + $this->csvinfo['arrtempls'] [$tempvar]['name'] = $temp['sn'][0]; + $this->csvinfo['arrtempls'] [$tempvar]['dn'] = $temp['dn']; + } + } + + $arr_temp = array_flip($this->csvinfo['attr']); + $this->csvinfo['arr_selected']= array($arr_temp['uid'],$arr_temp['sn'],$arr_temp['givenName'],$arr_temp['userPassword']); + + $smarty->assign("templates",$this->csvinfo['arrtemplates']); + $smarty->assign("attrs",$this->csvinfo['attr']); + + /* Check permissions for import */ + $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all"); + if(!preg_match("/w/",$acl)){ + if(isset($_POST['userfile']) || isset($_POST['sorted']) || isset($_POST['fileup'])){ + print_red(_("You've no permission to do CSV imports.")); + } + return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE))); + } + + /* If the given dat from the csv File are sorted by the attributes */ + if(isset($_POST['sorted'])) { + + /* Template Handling */ + $smarty->assign("fileup",TRUE); + $smarty->assign("sorted",TRUE); + + for($i = 0 ; $i < $this->csvinfo['rows'];$i++){ + /* Preparing given Data */ + $this->csvinfo['sorteddata'][$i]=array(); + + /* Go through every col */ + for($a = 0; $a <= ($this->csvinfo['cols']); $a ++) { + /* Append a status col at last, to show possibly errors */ + if($a==($this->csvinfo['cols'])){ + $this->csvinfo['sorteddata'][$i]["status"]="-"; + } else { + $cc = ($i * ($this->csvinfo['cols']))+$a; + + /* If theres a Attribut given for this col */ + if(!empty($_POST[('row'.($a))])) { + $this->csvinfo['sorteddata'][$i][$this->csvinfo['attr'][$_POST[('row'.($a))]]]=$this->csvinfo['data'][($cc)]; + } + } + } + } + + /* aleast one entry */ + $rowcnt=0; + if(isset($this->csvinfo['sorteddata'])){ + $rowcnt ++; + + /* Set the col count */ + $tblcolcount= count ($this->csvinfo['cols']); + + /* entrie count */ + $tbl_entries= count ($this->csvinfo['count']); + + /* row count */ + $tbl_rows = $tbl_entries / $tblcolcount; + + /* No error occurred */ + $failing = FALSE; + + /* For every row */ + for($i = 0; $i < $this->csvinfo['rows']; $i++){ + + /* Get elemenet */ + $dat = $this->csvinfo['sorteddata'][$i]; + + /* If not all needed vars set .... */ + if( ( empty($dat['sn']))||( empty($dat['givenName']))||( empty($dat['uid']))|| + (!isset($dat['sn']))||(!isset($dat['givenName']))||(!isset($dat['uid']))){ + + /* Output Error */ + + print_red (_("Need 'sn','givenName' and 'uid' to create user.")); + } else { + + /* Register usertab to trigger edit dialog */ + $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], 'new'); + $keys = array_keys($dat); + + + /* Set all submitted vars */ + if(is_array($keys)) + foreach($keys as $key) { + if($key != "status"){ + $this->usertab->$key = $dat[$key]; + } + } + + /* Initialize template */ + if($this->csvinfo['tplid']!=0){ + $this->usertab->adapt_from_template($this->csvinfo['arrtempls'][$this->csvinfo['tplid']]['dn']); + $this->usertab->save_object(); + } else { + + /* Reset vars */ + if(is_array($keys)) + foreach($keys as $key) { + if($key != "status"){ + $this->usertab->by_object['user']->$key = $dat[$key]; + } + } + } + + // Setting user Password + if((isset($dat['userPassword']))&&(!empty($dat['userPassword']))) + $password = $dat['userPassword']; + else + { + $rand_str=""; + $feed = "0123456789abcdefghijklmnopqrstuvwxyz"; + for ($i=0; $i < 8; $i++) + { + $rand_str .= substr($feed, rand(0, strlen($feed)-1), 1); + } + $password = $rand_str; + } + + /* Insert in the LDAP tree */ + if(count($this->usertab->check())) { + show_errors($this->usertab->check()); + $this->csvinfo['sorteddata'][$i]['status']=""._("failed").""; + $failing = $i+1; + break; + } else { + $this->csvinfo['sorteddata'][$i]['status']=_("ok"); + $this->usertab->save(); + change_password($this->usertab->dn,$password); + } + } + } + + $pointsbefore = FALSE; + $pointsafter = FALSE; + + /* Get Attributs for Tableheadline */ + $this->csvinfo['colsstr'] = array(); + for($i =0; $i <= $this->csvinfo['cols']; $i++) { + if(!empty($_POST[('row'.$i)])){ + $this->csvinfo['colsstr'][$i] = $this->csvinfo['attr'][$_POST[('row'.$i)]]; + } + } + + /*Create array with data for the template */ + if($failing == FALSE){ + + $dataouts= array(); + for($i =1; $i <= $this->csvinfo['shownrowscount']; $i++) { + if(is_array($this->csvinfo['sorteddata'][($i-1)])){ + foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){ + $dataouts[]=$dat; + } + } + } + + if($this->csvinfo['rows']> $this->csvinfo['shownrowscount']){ + $pointsafter = TRUE; + } + } else { + $pointsbefore = TRUE; + $pointsafter = TRUE; + + $begin = $failing -3; + + if($begin <0) { + $begin =0; + $pointsbefore = FALSE; + } + + $end = $failing + 2; + + if($end > $this->csvinfo['rows']) { + $end = $this->csvinfo['rows']+1; + $pointsafter = FALSE; + } + $this->csvinfo['shownrowscount']=$end - $begin; + + if($this->csvinfo['shownrowscount']> $this->csvinfo['rows'])$this->csvinfo['shownrowscount']=$this->csvinfo['rows']; + + $dataouts = array(); + for($i =$begin; $i <= $end; $i++) { + if(is_array($this->csvinfo['sorteddata'][($i-1)])){ + foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){ + $dataouts[]=$dat; + } + } + } + } + $tmparr2 = $this->csvinfo['colsstr']; + $tmparr2[]=_("status"); + + /* Error? */ + if ($failing){ + print_red(sprintf(_("An Error Occured while inserting entry %s - process aborted"), $failing)); + } + $smarty->assign("error",$failing); + + /* Set vars to smarty */ + $smarty->assign("cols",count($tmparr2)); + $smarty->assign("anz" ,$this->csvinfo['count']); + $smarty->assign("rows",$this->csvinfo['shownrowscount']); + + + $cnt = 0 ; + $tmp2 = $tmp3 = array(); + if(is_array($dataouts)) + foreach($dataouts as $tmp){ + $tmp2[] = $tmp; + $cnt ++ ; + if($cnt >= count($tmparr2)){ + $tmp3[] = $tmp2; + $tmp2= array(); + $cnt = 0; + } + } + $smarty->assign("head",$tmparr2); + $smarty->assign("data",$tmp3); + + /* Set other vars */ + $smarty->assign("i",1); + $smarty->assign("ie",0); + $smarty->assign("tplid",$this->csvinfo['tplid']); + + $smarty->assign("pointsafter",$pointsafter); + $smarty->assign("pointsbefore",$pointsbefore); + } else { + /* Set Template ID */ + $tplid = $_POST['tplid']; + + + $smarty->assign("tpl",$arrtemplates[$tplid]); + print_red (_("Nothing to import!")); + } + + /* If theres a File uploaded */ + } else { + /* Check if theres a file uploaded */ + if(!empty($_FILES['userfile']['name'])){ + + $handle = NULL; + + if((!isset($_FILES['userfile']['name']))||(!isset($_POST['fileup']))) + { + print_red(_("There is no file uploaded.")); + $smarty->assign("LDIFError",TRUE); + } + elseif(!$_FILES['userfile']['size'] > 0 ) + { + print_red(_("The specified file is empty.")); + $smarty->assign("LDIFError",TRUE); + } + /* Is there a tmp file, which we can use ? */ + elseif(!file_exists($_FILES['userfile']['tmp_name'])) + { + print_red(_("There is no file uploaded.")); + $smarty->assign("LDIFError",TRUE); + } + elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r")) + { + print_red(_("There is no file uploaded.")); + $smarty->assign("LDIFError",TRUE); + } + else + { + $smarty->assign("fileup",TRUE); + $str = ""; + + + /* Reading content */ + while(!feof($handle)) { + $str .= fread($handle,1024); + } + + $lines = split("\n",$str); + $anz = 0; + $rest = 0; + $data = array(); + + /* check colum count */ + if(is_array($lines)) + foreach($lines as $line) { + /* continue if theres a comment */ + if(substr(trim($line),0,1)=="#"){ + continue; + } + + $line= str_replace ("\t","",$line); + $cells = split(",",$line ) ; + + if(count($cells)> $anz ){ + $anz = count($cells); + } + } + + /* At least one entry */ + if($anz >1) { + + /* Generate array with outpu info */ + if(is_array($lines)) + foreach($lines as $line) { + $rest = 0; + $cnt = 0; + + /* dont use comments or empty lines */ + if((substr(trim($line),0,1)=="#")||(empty($line))){ + continue; + } + + /* replace \t to , */ + $line= str_replace ("\t" ,"" ,$line); + + /* get all elements */ + $cells = split(",",$line ) ; + + /* attach all elements to data array */ + if(is_array($cells)) + foreach($cells as $cell) { + if(!empty($cell)) { + $cnt++; + $data[]=trim($cell); + } + } + + /* cell count less than anz, attach some empty fields */ + if(($cnt != $anz)&&(!empty($cnt))) { + $rest = $anz - $cnt; + for($i = 0 ; $i < $rest ; $i ++){ + $data[] = " "; + } + } + } + + unset($this->csvinfo['sorteddata']); + unset($this->csvinfo['colsstr']); + unset($this->csvinfo['sorteddata']); + + $this->csvinfo['cols'] = $anz; + $this->csvinfo['data'] = array(); + $this->csvinfo['data'] = $data; + $this->csvinfo['count'] = count($this->csvinfo['data']); + + if($this->csvinfo['count']> (6* $this->csvinfo['cols'])) { + /* only show 6 rows in ouptuttablei */ + $datouttemp = array_chunk($this->csvinfo['data'],(6* $this->csvinfo['cols'])); + $this->csvinfo['dataout']=$datouttemp[0]; + $this->csvinfo['shownrowscount'] = 6; + } else { + $this->csvinfo['shownrowscount'] = (count($this->csvinfo['data']))/$this->csvinfo['cols']; + $this->csvinfo['dataout']= $this->csvinfo['data']; + } + + $this->csvinfo['tplid'] = $_POST['template']; + $this->csvinfo['templatestr'] = $this->csvinfo['arrtemplates' ][$this->csvinfo['tplid']]; + $this->csvinfo['count'] = count($this->csvinfo['data']); + $this->csvinfo['rows'] = (count($this->csvinfo['data'])/$anz); + + $i = 0; + $tmp = $tmp2= array(); + if(is_array($this->csvinfo['dataout'])) + foreach($this->csvinfo['dataout'] as $dat){ + $tmp[]= $dat; + $i++; + if($i >=$this->csvinfo['cols']){ + $i = 0; + $tmp2[] = $tmp; + $tmp = array(); + } + + } + + /* Set Templateid */ + $smarty->assign("tplid",$this->csvinfo['tplid']); + + /* Set Template */ + $smarty->assign("tpl",$this->csvinfo['templatestr']); + + /* Temp var 1 */ + $smarty->assign("ia",1); + + /* Temp var 2 */ + $smarty->assign("i",0); + + /* Num rows */ + $smarty->assign("rows",$this->csvinfo['shownrowscount']); + + + for($i = 0 ; $i < $anz; $i ++) + $this->csvinfo['arr_selected'][]="0"; + + $smarty->assign("selectedattrs",$this->csvinfo['arr_selected']); + + /* Entrie count5 */ + $smarty->assign("anz",$this->csvinfo['cols']); + + /* Array with data */ + $smarty->assign("data",$tmp2); + + @fclose($handle); + } else { + $smarty->assign("tpl",$this->csvinfo['attr'][$_POST['template']]); + $smarty->assign("LDIFError",TRUE); + $smarty->assign("fileup",FALSE); + print_red(_("The selected file does not contain any CSV Data...")); + } + } + } + } + + /* Show main page */ + return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE))); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/ldapmanager/class_export.inc b/gosa-core/plugins/addons/ldapmanager/class_export.inc new file mode 100644 index 000000000..aa988a312 --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/class_export.inc @@ -0,0 +1,125 @@ +config= &$config; + $this->ui = get_userinfo(); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","all/".get_class($this),$this->dn); + } + + /* Set government mode */ + $smarty= get_smarty(); + + $smarty->assign("type",FALSE); + $smarty->assign("depselectivbb",""); + + // fill in old vars in the Export form + if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){ + $smarty->assign("single",$_POST['single']); + $smarty->assign("type","single"); + $dn = $_POST['single']; + } + if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){ + $smarty->assign("depselectfull",$_POST['selfull']); + $smarty->assign("type","full"); + $dn = $_POST['selfull']; + } else { + $smarty->assign("depselectfull", ""); + } + if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){ + $smarty->assign("depselectivbb",$_POST['selivbb']); + $smarty->assign("type","ivbb"); + $dn = $_POST['selivbb']; + } else { + $smarty->assign("depselectivbb", ""); + } + + // Set values for optionlist in form + $bases = array(); + $acl_bases = $this->ui->get_module_departments("all"); + foreach($this->config->idepartments as $base_dn => $name){ + if(in_array_ics($base_dn,$acl_bases)){ + $bases[$base_dn] = $name; + } + } + $smarty->assign("deplist", $bases); + + // Get the LDAP link, to generate the Export + $ldap = $this->config->get_ldap_link(); + + if ($this->config->current['GOVERNMENTMODE'] == 'true'){ + $smarty->assign ("govmode", "true"); + } else { + $smarty->assign ("govmode", "false"); + } + + $smarty->assign("LDIFError",FALSE); + + if(isset($dn)) + { + if(!($ldap->dn_exists($dn) && $dn != "")){ + $smarty->assign("LDIFError",TRUE); + print_red (_("Error while exporting the requested entries!")); + } + } + + /* check alcs for given dn */ + $acls =""; + if(isset($dn)){ + $acls = $this->ui->get_permissions($dn,"all/all"); + } + if((!preg_match("/r/",$acls)) && (isset($dn))){ + + /* Show error msg */ + print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn))); + + /* Show main page */ + $smarty->assign("LDIFError",TRUE); + $smarty->assign("para",""); + }else{ + + // Export a single LDAP entry + if(isset($_POST['sfrmgetsingle'])) + { + $smarty->assign("para","?ivbb=2&dn=".base64_encode($_POST['single'])); + } + elseif(isset($_POST['sfrmgetfull'])) + { + $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull'])); + } + elseif(isset($_POST['sfrmgetivbb'])) + { + $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb'])); + } + } + + /* Show main page */ + return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE))); + } +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/ldapmanager/class_exportxls.inc b/gosa-core/plugins/addons/ldapmanager/class_exportxls.inc new file mode 100644 index 000000000..3331cbacd --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/class_exportxls.inc @@ -0,0 +1,142 @@ +config= &$config; + + $this->ui = get_userinfo(); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","all/".get_class($this),$this->dn); + } + + $dn = $this->config->current['BASE']; + + /* Set government mode */ + $smarty= get_smarty(); + $smarty->assign("type",FALSE); + $smarty->assign("depselectivbb",""); + + if(!isset($_POST['selfull'])) $_POST['selfull'] = "Somehow not posted"; + + /* Check permissions for export */ + // fill in old vars in the Export form + if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){ + $smarty->assign("single",$_POST['single']); + $smarty->assign("type","single"); + $a=$_POST['single']; + $b=$_POST['selfull']; + + } + if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){ + $smarty->assign("depselectfull",$_POST['selfull']); + $smarty->assign("type","full"); + $dn = $_POST['selfull']; + } else { + $smarty->assign("depselectfull", ""); + } + if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){ + $smarty->assign("depselectivbb",$_POST['selivbb']); + $smarty->assign("type","ivbb"); + $dn = $_POST['selivbb']; + } else { + $smarty->assign("depselectivbb", ""); + } + + // Set values for optionlist in form + $bases = array(); + $acl_bases = $this->ui->get_module_departments("all"); + foreach($this->config->idepartments as $base_dn => $name){ + if(in_array_ics($base_dn,$acl_bases)){ + $bases[$base_dn] = $name; + } + } + $smarty->assign("deplist", $bases); + $smarty->assign("choicelist",array( get_people_ou() =>"users" , + "ou=groups," =>"groups" , + "ou=systems," =>"computers", + "ou=servers,ou=systems," =>"servers", + "dc=addressbook," =>"addressbook")); + + // Get the LDAP link, to generate the Export + $ldap = $this->config->get_ldap_link(); + + if ($this->config->current['GOVERNMENTMODE'] == 'true'){ + $smarty->assign ("govmode", "true"); + } else { + $smarty->assign ("govmode", "false"); + } + + $smarty->assign("LDIFError",FALSE); + + if(isset($dn)) + { + if(!($ldap->dn_exists($dn) && $dn != "")){ + $smarty->assign("LDIFError",TRUE); + print_red (_("Error while exporting the requested entries!")); + } + } + + /* check alcs for given dn */ + $acls =""; + if(isset($dn)){ + $acls = $this->ui->get_permissions($dn,"all/all"); + } + + if(!preg_match("/r/",$acls) && (isset($_POST['sfrmgetsingle']) || isset($_POST['sfrmgetfull']) || isset($_POST['sfrmgetivbb']))){ + + /* Show error msg */ + print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn))); + + /* Show main page */ + $smarty->assign("LDIFError",TRUE); + $smarty->assign("para",""); + }else{ + + // Export a single LDAP entry + if(isset($_POST['sfrmgetsingle'])) + { + $smarty->assign("para","?ivbb=2&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull'])); + } + elseif(isset($_POST['sfrmgetfull'])) + { + $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull'])); + } + elseif(isset($_POST['sfrmgetivbb'])) + { + $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb'])); + } + } + + /* Show main page */ + return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE))); + } + +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/ldapmanager/class_import.inc b/gosa-core/plugins/addons/ldapmanager/class_import.inc new file mode 100644 index 000000000..71edbb2a2 --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/class_import.inc @@ -0,0 +1,120 @@ +config= &$config; + + $this->ui = get_userinfo(); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","all/".get_class($this),$this->dn); + } + + /* Set government mode */ + $smarty= get_smarty(); + + // Get the LDAP link, to generate the Export + $ldap = $this->config->get_ldap_link(); + + $smarty->assign("LDIFError",FALSE); + $smarty->assign("type",FALSE); + + /* Get acls */ + $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all"); + + /* Import requested check file and acls */ + if((isset($_FILES['userfile']['name']))&&(isset($_POST['fileup']))){ + + /* Check acls */ + if(!preg_match("/w/",$acl)){ + print_red(_("You need full access to all objects, to execute the import command.")); + }else{ + + $smarty->assign("type","importfile"); + $handle = NULL; + + // Check if there is a file submitted + if(!$_FILES['userfile']['size'] > 0 ) + { + print_red(_("The specified file is empty.")); + $smarty->assign("LDIFError",TRUE); + } + + // Is there a tmp file, which we can use ? + elseif(!file_exists($_FILES['userfile']['tmp_name'])) + { + print_red(_("There is no file uploaded.")); + $smarty->assign("LDIFError",TRUE); + + } + + // Can we open the tmp file, for reading + elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r")) + { + print_red(_("There is no file uploaded.")); + $smarty->assign("LDIFError",TRUE); + } + else + { + // Everything just fine :) + $str = ""; + + // Reading content + while(!feof($handle)) + { + $str .= fread($handle,1024); + } + @fclose($handle); + + // Should we use Overwrite ? + if(!empty($_POST['overwrite'])) $overwrite = true; else $overwrite = false;; + if(!empty($_POST['cleanup'])) $cleanup = true; else $cleanup = false; + + $ErrorStr=""; + $check = $ldap->import_complete_ldif($str,$ErrorStr,$overwrite,$cleanup); + + if($check == INSERT_OK ) + $smarty->assign("LDIFError",FALSE); + else + $smarty->assign("LDIFError",TRUE); + + switch($check) + { + case INSERT_OK : break; + case ALREADY_EXISTING_ENTRY : print_red($ErrorStr); break; + case UNKNOWN_TOKEN_IN_LDIF_FILE : print_red($ErrorStr);break; + + default : print_red(_("Unknown Error"));break; + } + } + } + } + return ($smarty->fetch (get_template_path('contentimport.tpl', TRUE))); + } +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/ldapmanager/class_ldif.inc b/gosa-core/plugins/addons/ldapmanager/class_ldif.inc new file mode 100644 index 000000000..3451f8179 --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/class_ldif.inc @@ -0,0 +1,52 @@ +ldif= new ldiftab($config, $config->data['TABS']['LDIFTAB'], ""); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Show main page */ + return ($this->ldif->execute()); + } + + /* Return plugin informations for acl handling + #FIXME You can only read attributes within this report plugin */ + static function plInfo() + { + return (array( + "plShortName" => _("Ldap manager"), + "plDescription" => "Dummy entry for menu creation functions, later", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("addon"), + "plCategory" => array("ldapmanager" => array("objectClass" => "none", "description" => _("Ldap manager addon"))), + + "plProvidedAcls" => array() + )); + } + + + +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/ldapmanager/contentcsv.tpl b/gosa-core/plugins/addons/ldapmanager/contentcsv.tpl new file mode 100644 index 000000000..fbfdfef0b --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/contentcsv.tpl @@ -0,0 +1,118 @@ +

+ {t}The CSV import plugin provides methods to generate user accounts from a file containing Comma Seperated Values. The administrator can decide which columns should be transfered to which attribute. Note that you must have at least the UID, GIVENNAME and SURENAME set.{/t} +

+

 

+ +{if $fileup != TRUE} + + + + + + + + + + +
+ + + + +
+ + + +
+{elseif $sorted != FALSE} + + +
+ {if $error == FALSE} + {t}All entries have been written to the LDAP database successfully.{/t} + {else} + {t}Oups. There was an error during the import of your data.{/t} + {/if} + +{t}Here is the status report for the import:{/t} +
+
+ + + + + {foreach from=$head item=h} + + {/foreach} + + {if $pointsbefore == TRUE} + + + + {/if} + + {foreach from=$data item=row key=key} + + {foreach from=$data[$key] item=col key=key2} + + {/foreach} + + {/foreach} + {if $pointsafter == TRUE} + + + + {/if} + +
+ {$h} +
+ ... +
+ {$data[$key][$key2]} +
+ ... +
+ +{else} +
{t}Selected Template{/t}: {$tpl} +
+
+ + + {foreach from=$data[0] item=item key=key} + + {/foreach} + + {foreach from=$data item=val key=key} + + {foreach from=$data[$key] item=val2 key=key2} + + {/foreach} + + {/foreach} + +
+ +
+ {$data[$key][$key2]}  +
+ + +{/if} +

+{if $fileup != TRUE} + +{else} +{if $sorted == FALSE} + +{else} + +{/if} +{/if} +

+ diff --git a/gosa-core/plugins/addons/ldapmanager/contentexport.tpl b/gosa-core/plugins/addons/ldapmanager/contentexport.tpl new file mode 100644 index 000000000..5cd2301d9 --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/contentexport.tpl @@ -0,0 +1,73 @@ +{if $LDIFError != FALSE || $type == FALSE} +

+ {t}The LDIF export plugin provides methods to download a complete snapshot of the running LDAP directory as ldif. You may save these files for backup purpose or when initializing a new server.{/t} +

+

 

+ + + + + + + + + + + + + +{if $govmode eq "true"} + + + + + +{/if} +
+ + + + + +
+ + + + + +
+ + + + + +
+ + +{else} + + +
+

{t}Export successful{/t}

+
+
+ + {t}Click here to save the LDAP Export {/t} + + +
+
+
+
+ +
+{/if} +

+   +

+ + diff --git a/gosa-core/plugins/addons/ldapmanager/contentexportxls.tpl b/gosa-core/plugins/addons/ldapmanager/contentexportxls.tpl new file mode 100644 index 000000000..bb115c7b5 --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/contentexportxls.tpl @@ -0,0 +1,76 @@ +{if $LDIFError != FALSE || $type == FALSE} +

+ {t}The XLS export plugin provides methods to download a complete snapshot of the running LDAP directory as xls. You may save these files for documentation.{/t} +

+

 

+ + + + + + + + + + + + + +{if $govmode eq "true"} + + + + + +{/if} +
+ + + {**} + + + +
+ + + + + +
+ + + + + +
+ + +{else} + + +
+

{t}Export successful{/t}

+
+
+ + {t}Click here to save the LDAP Export to a xls file{/t} + + +
+
+
+
+ +
+{/if} +

+   +

+ + diff --git a/gosa-core/plugins/addons/ldapmanager/contentimport.tpl b/gosa-core/plugins/addons/ldapmanager/contentimport.tpl new file mode 100644 index 000000000..b7d5afc8d --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/contentimport.tpl @@ -0,0 +1,52 @@ +{if $type == FALSE || $LDIFError != FALSE} +

+ {t}The LDIF import plugin provides methods to upload a set of entries to your running LDAP directory as ldif. You may use this to add new or modify existing entries. Remember that GOsa will not check your ldifs for GOsa conformance.{/t} +

+ +

 

+ + + + + + + + + + + + + +
+ + + + + +
+   + + + {t}Modify existing objects, keep untouched attributes{/t}
+ {t}Overwrite existing objects, all not listed attributes will be removed{/t} +
+   + + + +
+{else} + +
+

{t}Import successful{/t}

+
+ +
+ +
+ +{/if} +

+ +

+ diff --git a/gosa-core/plugins/addons/ldapmanager/main.inc b/gosa-core/plugins/addons/ldapmanager/main.inc new file mode 100644 index 000000000..696c14add --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/main.inc @@ -0,0 +1,39 @@ +set_acl_category("logview"); + } + $ldif= $_SESSION['ldif']; + + /* Execute formular */ + $display= $ldif->execute (); + $display.= "\n"; + + /* Page header*/ + $display= print_header(get_template_path('images/ldif.png'), _("LDAP manager")).$display; + + /* Store changes in session */ + $_SESSION['ldif']= $ldif; +} +?> diff --git a/gosa-core/plugins/addons/ldapmanager/tabs_ldif.inc b/gosa-core/plugins/addons/ldapmanager/tabs_ldif.inc new file mode 100644 index 000000000..2f6b70f0d --- /dev/null +++ b/gosa-core/plugins/addons/ldapmanager/tabs_ldif.inc @@ -0,0 +1,24 @@ + diff --git a/gosa-core/plugins/addons/logview/class_gosa_logview.inc b/gosa-core/plugins/addons/logview/class_gosa_logview.inc new file mode 100644 index 000000000..87d234a4d --- /dev/null +++ b/gosa-core/plugins/addons/logview/class_gosa_logview.inc @@ -0,0 +1,398 @@ +config= &$config; + $this->ui = get_userinfo(); + + /* Restore last filter settings */ + foreach(array("action","server","time","regex") as $attr){ + if(isset($_SESSION['logview']['gosa_log'][$attr])){ + $this->$attr = $_SESSION['logview']['gosa_log'][$attr]; + } + } + + $tz = get_default_timezone(); + $this->timezone_offset = $tz['value'] * 60 * 60 ; + + $ldap = $this->config->get_ldap_link(); + $ldap->search("(&(objectClass=person)(uid=*))",array("uid","dn")); + while($attrs = $ldap->fetch()){ + $this->uid_map[$attrs['dn']] = $attrs['uid'][0]; + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","logview/".get_class($this),$this->dn); + } + + /* Time interval */ + $date_select = array( + "0" => _("one hour"), "1" => _("6 hours"), + "2" => _("12 hours"), "3" => _("24 hours"), + "4" => _("2 days"), "5" => _("one week"), + "6" => _("2 weeks"), "7" => _("one month")); + + + $time = time(); + $date_select_ = array( + "0" => $time - 3600, + "1" => $time - 21600, + "2" => $time - 43200, + "3" => $time - 86400, + "4" => $time - 172800, + "5" => $time - 604800, + "6" => $time - 1209600, + "7" => $time - 2419200); + + $smarty= get_smarty(); + $smarty->assign("search_result", ""); + $smarty->assign("plug", "?plug=".validate($_GET['plug'])); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("time_image", get_template_path('images/time.png')); + $smarty->assign("server_image", get_template_path('images/server.png')); + $smarty->assign("log_image", get_template_path('images/log_warning.png')); + $smarty->assign("ruleset_image", get_template_path('images/edit.png')); + $smarty->assign("launchimage", get_template_path('images/launch.png')); + $smarty->assign("date_select", $date_select); + $smarty->assign("actions", array()); + $smarty->assign("direction", "up"); + $smarty->assign("mode0", ""); + $smarty->assign("mode1", ""); + $smarty->assign("mode2", ""); + $smarty->assign("mode3", ""); + $smarty->assign("mode4", ""); + $smarty->assign("mode5", ""); + $smarty->assign("mode6", ""); + + /* Assign select option content */ + foreach( array("server", "action", "time", "regex") as $type){ + $smarty->assign("$type", $this->$type); + } + + /**** + * Check if defined servers + * and mysql extension + ****/ + if (!isset($this->config->data['SERVERS']['LOGGING']) || !count($this->config->data['SERVERS']['LOGGING'])){ + print_red (_("No GOsa LOG servers defined!")); + return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); + } + + if(!is_callable("mysql_connect")){ + print_red(_("There is no mysql extension available, please check your php setup.")); + return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); + } + + /**** + * Get Configurations + ****/ + $list_of_servers = $this->config->data['SERVERS']['LOGGING']; + $servers = array(); + foreach($list_of_servers as $servername => $data){ + $servers[$servername] = $servername; + } + $smarty->assign("servers", $servers); + + /* Set a default server, if there is currently no valid server selected */ + if(empty($this->server) || !in_array($this->server,$servers)){ + $this->server = key($servers); + } + + /**** + * Connect to currently selected server + ****/ + $cfg = $list_of_servers[$this->server]; + $link = @mysql_pconnect($this->server, $cfg['USER'], $cfg['PWD']); + if ($link === FALSE){ + print_red(_("Can't connect to log database, no logs can be shown!")); + new log("debug","logview","",array(),@mysql_error()); + return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); + } + + /* check of log database is available */ + if (! @mysql_select_db($cfg['DB'])){ + print_red(_("Can't select log database for log generation!")); + new log("debug","logview","",array(),@mysql_error()); + return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); + } + + + /**** + * Get all action types + ****/ + + $actions = array("!ALL" => _("All")); + $query = "SELECT distinct(action) FROM gosa_log;"; + $res = @mysql_query($query); + while($attrs = @mysql_fetch_assoc($res)){ + $actions[$attrs['action']] = $attrs['action']; + } + + + /**** + * Check Acls + ****/ + + $ui = get_userinfo(); + $dn = $list_of_servers[$this->server]['DN']; + $acls = $ui->get_permissions($dn,"server/gosaLogServer","viewEntries"); + + if(!preg_match("/r/",$acls)){ + $res = " + + "._("You have insufficient permissions to view syslog entries.")." + + "; + + /* Show main page */ + $smarty->assign("range_selector", ""); + $smarty->assign("search_result", $res); + return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); + } + + + /**** + * Query stuff + ****/ + $res= ""; + $cfg = $list_of_servers[$this->server]; + $link = @mysql_pconnect($this->server, $cfg['USER'], $cfg['PWD']); + + /* Test connection object && create up query string */ + if ($link === FALSE){ + print_red(_("Can't connect to log database, no logs can be shown!")); + new log("debug","logview","",array(),@mysql_error()); + } else { + + if (! @mysql_select_db($cfg['DB'])){ + print_red(_("Can't select log database for log generation!")); + new log("debug","logview","",array(),@mysql_error()); + } else { + + /* Prepare order setting */ + if ($this->sort_direction == "down"){ + $desc= "DESC"; + $sort_sign = "\/"; + } else { + $desc= ""; + $sort_sign = "/\"; + } + + /* Get start time */ + $start = $date_select_[$this->time]; + + /* Prepare search filter */ + $sql_regex =trim(preg_replace("/\*/","%",$this->regex)); + $sql_regex = "%".trim($sql_regex,"%")."%"; + + /* Create search filter */ + $query_base= "FROM gosa_log WHERE timestamp >= $start "; + + /* Append action filter */ + if($this->action != "!ALL"){ + $query_base .=" AND action like '".$this->action."' "; + } + + /* Append search filter */ + if($sql_regex != "%%"){ + $query_base .=" AND ( result like '".$sql_regex."' OR user like '".$sql_regex."') "; + } + + /* Get number of entries */ + $query= "SELECT COUNT(`user`) ".$query_base.";"; + $result = mysql_query($query); + if(!$result){ + new log("debug","logview","",array(),@mysql_error()); + } + $line= mysql_fetch_array($result, MYSQL_ASSOC); + $count= $line['COUNT(`user`)']; + if ($count > 25){ + $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage")); + } else { + $smarty->assign("range_selector", ""); + } + + /* Query results that will be displayed */ + $query= "SELECT * ".$query_base." ORDER BY ".$this->fields[$this->sort]." ".$desc." LIMIT ".$this->start.",".$this->range.";"; + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query"); + $result = @mysql_query($query); + if(!$result){ + new log("debug","logview","",array(),@mysql_error()); + } + + /* Display results */ + $mod= 0; + + /* Add entries to result str */ + while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){ + + /* Toggle background color */ + if ( ($mod++) & 1){ + $col= "background-color: #ECECEC;"; + } else { + $col= "background-color: #F5F5F5;"; + } + + $base = ", ".substr($this->config->current['BASE'],0,5)."..."; + + if(isset($this->uid_map[$line['user']])){ + $user = $this->uid_map[$line['user']]; + }else{ + $user = preg_replace("/,".normalizePreg($this->config->current['BASE'])."/",$base,$line['user']); + } + $object = preg_replace("/,".normalizePreg($this->config->current['BASE'])."/",$base,$line['object']); + + $res.=" \n"; + $res.=" ".$line['action'].""; + $res.=" ".date("H:i:s d.m.Y",($line['timestamp'] + $this->timezone_offset)).""; + $res.=" ".preg_replace("/,/",", ",$user).""; + $res.=" ".$line['objecttype'].""; + $res.=" ".preg_replace("/,/",", ",$object).""; + $res.=" ".$line['result'].""; +# if($line['repeated'] == 1){ +# $res.=" -"; +# }else{ +# $res.=" ".($line['repeated']-1).""; +# } + $res.=" \n"; + } + mysql_close($link); + $smarty->assign("mode".$this->sort, $sort_sign); + $smarty->assign("search_result", $res); + } + } + + $smarty->assign("regex", $this->regex); + $smarty->assign("server",$this->server); + $smarty->assign("servers",$servers); + $smarty->assign("action",$this->action); + $smarty->assign("actions",$actions); + $smarty->assign("date_select", $date_select); + + $smarty->assign("direction", $this->sort_direction); + + /* Show main page */ + return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); + } + + + function save_object() + { + if(isset($_POST['gosa_log_contents_posted'])){ + + /* Get submitted range */ + if(isset($_POST['EntriesPerPage'])){ + if(is_numeric($_POST['EntriesPerPage'])){ + $this->range = $_POST['EntriesPerPage']; + } + } + + /* Get actual select boxe values */ + $logfilter_changed = FALSE; + foreach( array("server", "action","time","regex") as $type){ + if(isset($_POST[$type])){ + $this->$type = $_POST[$type]; + } + } + + /* Filter regex values */ + if ($this->regex == ""){ + $this->regex= '*'; + } else { + $new = preg_replace('/\*\**/', '*', $this->regex); + $this->regex= $new; + } + + /* Set start value */ + if (isset($_GET['start'])){ + $this->start= (int)$_GET['start']; + } + + /* Reset page number if filter has changed */ + if ($logfilter_changed > 0){ + $this->start= 0; + } + + /* Adapt sorting */ + if (isset($_GET['sort'])){ + + if($_GET['direction'] == "up"){ + $this->sort_direction = "down"; + }else{ + $this->sort_direction = "up"; + } + + $this->sort= (int)$_GET['sort']; + if ($this->sort < 0 || $this->sort > count($this->fields)){ + $this->sort= 0; + } + } + + /* Save attributes in Sessiob, so we are able to recontruct filter on plugin reload */ + $_SESSION['logview']['gosa_log'] = array(); + foreach(array("action","server","time","regex") as $attr){ + $_SESSION['logview']['gosa_log'][$attr] = $this->$attr; + } + + } + } + + + /* Return plugin informations for acl handling + #FIXME You can only read attributes within this report plugin + static function plInfo() + { + return (array( + "plShortName" => _("Log view"), + "plDescription" => _("Log view addon"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("addon"), + "plCategory" => array("logview" => array("objectClass" => "none", "description" => _("System logs"))), + + "plProvidedAcls" => array() + )); + } + */ +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/logview/class_logview.inc b/gosa-core/plugins/addons/logview/class_logview.inc new file mode 100644 index 000000000..8716ee7e9 --- /dev/null +++ b/gosa-core/plugins/addons/logview/class_logview.inc @@ -0,0 +1,415 @@ +config= &$config; + + /* Get global filter config */ + if (!is_global("logfilter")){ + $logfilter= array( + "time" => "1", + "log_level" => "!All", + "host" => "!All", + "regex" => "*"); + + register_global("logfilter", $logfilter); + } + + $this->ui = get_userinfo(); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","logview/".get_class($this),$this->dn); + } + + $logfilter= get_global("logfilter"); + $smarty= get_smarty(); + $smarty->assign("search_result", ""); + $smarty->assign("plug", "?plug=".validate($_GET['plug'])); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("time_image", get_template_path('images/time.png')); + $smarty->assign("server_image", get_template_path('images/server.png')); + $smarty->assign("log_image", get_template_path('images/log_warning.png')); + $smarty->assign("ruleset_image", get_template_path('images/edit.png')); + $smarty->assign("launchimage", get_template_path('images/launch.png')); + $smarty->assign("hostlist", $this->hostlist); + $smarty->assign("loglevellist", $this->loglevellist); + $smarty->assign("tilist", $this->tilist); + $smarty->assign("mode0", ""); + $smarty->assign("mode1", ""); + $smarty->assign("mode2", ""); + $smarty->assign("mode3", ""); + + /* Assign select option content */ + foreach( array("host", "log_level", "time", "regex") as $type){ + $smarty->assign("$type", $logfilter[$type]); + } + + /* Test connection to log database */ + if (!isset($this->config->data['SERVERS']['LOG'])){ + print_red (_("No LOG servers defined!")); + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + + }elseif(!is_callable("mysql_connect")){ + print_red(_("There is no mysql extension available, please check your php setup.")); + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + + }else{ + + /* Cehck connection informations */ + $cfg= $this->config->data['SERVERS']['LOG']; + + /* Open link to database and check if it is valid */ + $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); + if ($link === FALSE){ + print_red(_("Can't connect to log database, no logs can be shown!")); + new log("debug","logview","",array(),@mysql_error()); + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + /* check of log database is available */ + if (! @mysql_select_db("gomon")){ + print_red(_("Can't select log database for log generation!")); + new log("debug","logview","",array(),@mysql_error()); + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + /* Get Host list, if still empty */ + if(count($this->hostlist) == 0){ + + /* Query database and check results */ + $query= "SELECT DISTINCT host FROM golog LIMIT 200;"; + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query"); + $result = @mysql_query($query); + if ($result === false){ + print_red(_("Query for log database failed!. Requesting host names failed.")); + new log("debug","logview","",array(),@mysql_error()); + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + /* Add hostnames to list */ + while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){ + $this->hostlist[$line['host']]= $line['host']; + } + $this->hostlist['!All']= _("All"); + ksort($this->hostlist); + $smarty->assign("hostlist", $this->hostlist); + } + + /* Get log level list */ + if(count($this->loglevellist) == 0){ + + /* Try to get all used log level types */ + $query= "SELECT DISTINCT log_level FROM golog LIMIT 200;"; + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query"); + $result = @mysql_query($query); + if ($result === false){ + new log("debug","logview","",array(),@mysql_error()); + print_red(_("Query for log database failed!")); + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + /* Add each etry to log level list */ + while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){ + $this->loglevellist[$line['log_level']]= $line['log_level']; + } + $this->loglevellist['!All']= _("All"); + ksort($this->loglevellist); + $smarty->assign("loglevellist", $this->loglevellist); + } + } + + /* Set list of available time sequences */ + if(count($this->tilist) == 0){ + + /* Time interval */ + $this->tilist= array("0" => _("one hour"), "1" => _("6 hours"), + "2" => _("12 hours"), "3" => _("24 hours"), + "4" => _("2 days"), "5" => _("one week"), + "6" => _("2 weeks"), "7" => _("one month")); + $smarty->assign("tilist", $this->tilist); + } + + $smarty->assign("regex", $logfilter['regex']); + + + /* Get acls */ + + $tmp_cat_bases = $this->ui->get_module_departments("logview"); + $all_acls = ""; + foreach($tmp_cat_bases as $acl_base){ + $all_acls .= $this->ui->get_permissions($acl_base,"logview/logview"); + } + if(count($tmp_cat_bases) == 0 || !preg_match("/r/",$all_acls)){ + $res = " + + "._("You have insufficient permissions to view syslog entries.")." + + "; + + /* Show main page */ + $smarty->assign("range_selector", ""); + $smarty->assign("search_result", $res); + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + /* Query stuff */ + $res= ""; + $cfg = $this->config->data['SERVERS']['LOG']; + $tmp = set_error_handler('dummy_error_handler'); + $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); + set_error_handler($tmp); + + /* Test connection object && create up query string */ + if ($link === FALSE){ + print_red(_("Can't connect to log database, no logs can be shown!")); + new log("debug","logview","",array(),@mysql_error()); + } else { + if (! @mysql_select_db("gomon")){ + print_red(_("Can't select log database for log generation!")); + new log("debug","logview","",array(),@mysql_error()); + } else { + + /* Assemble time query */ + switch ($logfilter['time']){ + case '0': + $start= date ("YmdHis", time() - 3600); + break; + ;; + case '1': + $start= date ("YmdHis", time() - 21600); + break; + ;; + case '2': + $start= date ("YmdHis", time() - 43200); + break; + ;; + case '3': + $start= date ("YmdHis", time() - 86400); + break; + ;; + case '4': + $start= date ("YmdHis", time() - 172800); + break; + ;; + case '5': + $start= date ("YmdHis", time() - 604800); + break; + ;; + case '6': + $start= date ("YmdHis", time() - 1209600); + break; + ;; + case '7': + $start= date ("YmdHis", time() - 2419200); + break; + ;; + } + + /* Assemble log level query */ + if ($logfilter['log_level'] == '!All'){ + $ll= ""; + } else { + $ll= "AND log_level='".$logfilter['log_level']."'"; + } + if ($logfilter['host'] == '!All'){ + $hf= ""; + } else { + $hf= "AND host='".$logfilter['host']."'"; + } + + /* Order setting */ + if ($this->sort_direction == "down"){ + $desc= "DESC"; + $sort_sign = "\\/"; + } else { + $desc= ""; + $sort_sign="/\\"; + } + $end= date ("YmdHis"); + $query_base= " FROM + golog + WHERE + message like '".preg_replace("/\*/","%",$logfilter['regex'])."' + $ll + $hf + AND + time_stamp <= $end AND time_stamp >= $start"; + + /* Get number of entries */ + $query= "SELECT COUNT(*)".$query_base.";"; + $result = @mysql_query($query); + if(!$result){ + new log("debug","logview","",array(),@mysql_error()); + } + $line= mysql_fetch_array($result, MYSQL_ASSOC); + $count= $line['COUNT(*)']; + if ($count > 25){ + $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage")); + } else { + $smarty->assign("range_selector", ""); + } + + /* Query results */ + $query= "SELECT *".$query_base." ORDER BY ".$this->fields[$this->sort]." $desc LIMIT ".$this->start.",".$this->range.";"; + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query"); + $result = @mysql_query($query); + if(!$result){ + new log("debug","logview","",array(),@mysql_error()); + } + /* Display results */ + $mod= 0; + + /* Add entries to result str */ + while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){ + + /* Toggle background color */ + if ( ($mod++) & 1){ + $col= "background-color: #ECECEC;"; + } else { + $col= "background-color: #F5F5F5;"; + } + + $res.=" \n"; + $res.=" + \"".$line['log_level']."\" + "; + $res.=" ". + $line['host']." + "; + $res.=" ". + $line['time_stamp']." + "; + $res .= "". + $line['message']." + "; + $res.=" \n"; + } + mysql_close($link); + $smarty->assign("mode".$this->sort, $sort_sign); + $smarty->assign("host", $logfilter['host']); + $smarty->assign("log_level", $logfilter['log_level']); + + $smarty->assign("search_result", $res); + } + } + + /* Show main page */ + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + + function save_object() + { + /* Get submitted range */ + if(isset($_POST['EntriesPerPage'])){ + if(is_numeric($_POST['EntriesPerPage'])){ + $this->range = $_POST['EntriesPerPage']; + } + } + + /* Save data */ + $logfilter= get_global("logfilter"); + + /* Get actual select boxe values */ + $logfilter_changed = 0; + foreach( array("host", "time", "log_level", "regex") as $type){ + + /* Set new value and test if value has changed */ + $last[$type] = $logfilter[$type]; + if (isset($_POST[$type])){ + $logfilter[$type]= $_POST[$type]; + } + + if ($last[$type] != $logfilter[$type]){ + $logfilter_changed = 1; + } + } + + /* Filter regex values */ + if ($logfilter['regex'] == ""){ + $logfilter['regex']= '%'; + } else { + $new = preg_replace('/\*\**/', '*', $logfilter['regex']); + $logfilter['regex']= $new; + } + + /* Store filter values */ + register_global("logfilter", $logfilter); + + /* Set start value */ + if (isset($_GET['start'])){ + $this->start= (int)$_GET['start']; + } + + /* Reset page number if filter has changed */ + if ($logfilter_changed > 0){ + $this->start= 0; + } + + /* Adapt sorting */ + if (isset($_GET['sort'])){ + if ($this->sort == (int)$_GET['sort']){ + if ($this->sort_direction == "down"){ + $this->sort_direction= "up"; + } else { + $this->sort_direction= "down"; + } + } + $this->sort= (int)$_GET['sort']; + if ($this->sort < 0 || $this->sort > 3){ + $this->sort= 0; + } + } + } + + + /* Return plugin informations for acl handling + #FIXME You can only read attributes within this report plugin */ + static function plInfo() + { + return (array( + "plShortName" => _("Log view"), + "plDescription" => _("Log view addon"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("addon"), + "plCategory" => array("logview" => array("objectClass" => "none", "description" => _("System logs"))), + + "plProvidedAcls" => array() + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/logview/contents.tpl b/gosa-core/plugins/addons/logview/contents.tpl new file mode 100644 index 000000000..9a03544f3 --- /dev/null +++ b/gosa-core/plugins/addons/logview/contents.tpl @@ -0,0 +1,105 @@ +
+

[F]{t}Filter{/t}

+
+
+ + + + + + + + + + + + +
+ + + + + + + + + +
  + +
  + +
+
+   + + + + + + + + + + +
  + +
 
+
+   + + + + + + +
+ +
+
+
+ +
+ +{if $search_result ne ""} + + + + + + + + {$search_result} +
{t}Level{/t} {$mode0}{t}Hostname{/t} {$mode1}{t}Date{/t} {$mode2}{t}Message{/t} {$mode3}
+ + + + + +
{$range_selector}
+ +{else} + {t}Search returned no results...{/t} +{/if} + + + diff --git a/gosa-core/plugins/addons/logview/gosa_log_contents.tpl b/gosa-core/plugins/addons/logview/gosa_log_contents.tpl new file mode 100644 index 000000000..5d71d8103 --- /dev/null +++ b/gosa-core/plugins/addons/logview/gosa_log_contents.tpl @@ -0,0 +1,107 @@ +
+

[F]{t}Filter{/t}

+
+
+ + + + + + + + + + + + +
+ + + + + + + + + +
  + +
  + +
+
+   + + + + + + + + + + +
  + +
 
+
+   + + + + + + +
+ +
+
+
+ +
+ +{if $search_result ne ""} + + + + + + + + + + {$search_result} +
{t}Action{/t} {$mode0}{t}Date{/t} {$mode1}{t}User{/t} {$mode2}{t}Object type{/t} {$mode3}{t}Object{/t} {$mode4}{t}Message{/t} {$mode5}
+ + + + + +
{$range_selector}
+ +{else} + {t}Search returned no results...{/t} +{/if} + + + diff --git a/gosa-core/plugins/addons/logview/main.inc b/gosa-core/plugins/addons/logview/main.inc new file mode 100644 index 000000000..9ecb3161d --- /dev/null +++ b/gosa-core/plugins/addons/logview/main.inc @@ -0,0 +1,39 @@ +data['TABS']['LOGTABS'],""); + } + $log_tabs= $_SESSION['log_tabs']; + + /* Execute formular */ +# $display= $log_tabs->save_object(); + $display= $log_tabs->execute (); + $display.= "\n"; + + /* Page header*/ + $display= print_header(get_template_path('images/logview.png'), _("System log view")).$display; + + /* Store changes in session */ + $_SESSION['log_tabs']= $log_tabs; +} +?> diff --git a/gosa-core/plugins/addons/logview/tabs_log.inc b/gosa-core/plugins/addons/logview/tabs_log.inc new file mode 100644 index 000000000..bb855d28b --- /dev/null +++ b/gosa-core/plugins/addons/logview/tabs_log.inc @@ -0,0 +1,24 @@ + diff --git a/gosa-core/plugins/addons/mailqueue/class_mailqueue.inc b/gosa-core/plugins/addons/mailqueue/class_mailqueue.inc new file mode 100644 index 000000000..6b1e6e46e --- /dev/null +++ b/gosa-core/plugins/addons/mailqueue/class_mailqueue.inc @@ -0,0 +1,418 @@ +config = &$config; + if (isset($this->config->current['MAILQUEUESCRIPTPATH'])){ + $this->mailQueueScript = $this->config->current['MAILQUEUESCRIPTPATH']; + } + + if(isset($this->config->data['MAIN']['MAILQUEUESCRIPTPATH'])){ + $this->mailQueueScript = $this->config->data['MAIN']['MAILQUEUESCRIPTPATH']; + } + + $this->Server = "all"; + } + + + function pass_cmd($str) + { +// print_red($str); + return(shell_exec($str)); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","mailqueue/".get_class($this),$this->dn); + } + + if(isset($_POST['EntriesPerPage'])){ + $this->range = $_POST['EntriesPerPage']; + } + + $smarty= get_smarty(); + $error =false; + + if(empty($this->mailQueueScript)){ + print_red(_("Please check your 'gosa.conf', there is no 'MAILQUEUESCRIPTPATH' specified.")); + $error = true; + }else{ + + /* If we have more than one server selected (all), + create a string with all servers separated by ', ' + */ + if($this->Server=="all"){ + $se = $this->getServer(); + + unset($se['all']); + $se_str = ""; + foreach($se as $server) { + $se_str .= $server." "; + } + }else{ + /* We have only one server selected */ + $se_str = $this->Server; + } + + /* Check all post that will effect all entries */ + $only_once = true; + foreach(array("unhold_all","hold_all","del_all","requeue_all") as $attr){ + foreach($_POST as $name => $value){ + if((preg_match("/".$attr."/",$name))&&($only_once)){ + if(!$this->acl_is_readable($attr)){ + $only_once = false; + print_red(sprintf(_("You do not have permission to execute the command '%s' on the mailqueue."),$attr)); + }else{ + $only_once = false; + $act = preg_replace("/_.*$/i","",$attr); + $r_cmd = preg_replace("/%action/" , $act ,$this->mailQueueScript); + $r_cmd = preg_replace("/%server/" , $se_str ,$r_cmd); + $r_cmd = preg_replace("/%id/" , "ALL" ,$r_cmd); + if($this->pass_cmd($r_cmd)==false){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + } + } + } + } + } + + /* Check single entry manipulation posts */ + $only_once = true; + + /* act specifies the command to execute */ + if(isset($_GET['act'])){ + $opt = $_GET['act']; + + /* The option to exec should be one of these */ + if(in_array($opt,array("unhold","hold","del","requeue","query","header"))){ + $only_once = false; + + if(!$this->acl_is_readable($opt)){ + print_red(sprintf(_("You do not have permission to execute the command '%s' on the mailqueue."),$opt)); + }else{ + /* Create cmd */ + $r_cmd = preg_replace("/%action/" , $opt ,$this->mailQueueScript); + $r_cmd = preg_replace("/%server/" , $this->Server ,$r_cmd); + $r_cmd = preg_replace("/%id/" , $_GET['id'] ,$r_cmd); + + /* Execute cmd */ + if(!$str = $this->pass_cmd($r_cmd)){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + }else{ + + /* Special handling for option='header' */ + if($opt == "header"){ + + /* Create table which displays the header informations */ + $this->disp_header ="\n"; + foreach(split("\n",$str) as $line){ + $line = trim($line); + if(empty($line)) { + continue; + } + $this->disp_header .= "\n"; + $tmp0 = preg_replace("/:.*$/","",$line); + $tmp1 = preg_replace("/^.*:/","",$line); + $this->disp_header .= "\n"; + $this->disp_header .= "\n"; + } + $this->disp_header .= "\n
".$tmp0."".$tmp1."
"; + } + } + } + } + } + + + /* Back is posted from the header display page */ + if(isset($_POST['back'])){ + $this->disp_header = false; + } + + /* If there is a header in disp_header, then display it */ + if($this->disp_header){ + $smarty->assign("header",$this->disp_header); + return ($smarty->fetch (get_template_path('header.tpl', TRUE))); + } + + /* tell smarty to display the search results*/ + $smarty->assign("all_ok" , "true"); + + /* A single server is selected */ + if($this->Server != "all"){ + + /* Create Query cmd */ + $q_cmd = preg_replace("/%action/" ,"query" ,$this->mailQueueScript); + $q_cmd = preg_replace("/%server/" ,$this->Server,$q_cmd); + $q_cmd = preg_replace("/%id/" ,"all" ,$q_cmd); + + if(!$this->acl_is_readable("query")){ + print_red(sprintf(_("You do not have permission to execute the command '%s' on the mailqueue."),"query")); + $mailQueueParser = new parseMailQueue("",$this->Server); + }else{ + + /* Only display this if the query cmd is executeable */ + if($str = @$this->pass_cmd ($q_cmd)){ + /* Parse returned data */ + $mailQueueParser = new parseMailQueue($str,$this->Server); + }else{ + /* On error/ no return value / false return value */ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$q_cmd)); + $error = true; + } + } + }else{ + $mailQueueParser = NULL; + foreach($this->getServer() as $ServerID=>$ServerName){ + + /* Don't query the server named all :) */ + if($ServerID == "all") continue; + + /* Prepare query cmd */ + $q_cmd = preg_replace("/%action/" ,"query" ,$this->mailQueueScript); + $q_cmd = preg_replace("/%server/" ,$ServerName ,$q_cmd); + $q_cmd = preg_replace("/%id/" ,"ALL" ,$q_cmd); + + + if(!$this->acl_is_readable("query")){ + print_red(sprintf(_("You do not have permission to execute the command '%s' on the mailqueue."),"query")); + $mailQueueParser = new parseMailQueue("",$this->Server); + }else{ + + /* Shell exec this cmd */ + if($str = @$this->pass_cmd ($q_cmd)){ + + /* If there is no parser available, create one */ + if($mailQueueParser === NULL){ + $mailQueueParser = new parseMailQueue($str,$ServerID); + }else{ + $mailQueueParser->parseAdditionalQueue($str,$ServerID); + } + /* On error/ no return value / false return value */ + }else{ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$q_cmd)); + $error = true; + } + } + } + } + + /* Check for existing servers + objectClass=goMailServer is required at least for one server. + Else display error */ + $server = $this->getServer(); + if((count($server) == 1 ) && (isset($server['all']))){ + print_red(_("There are no mail server specified.")); + $error = true; + } + + if(!$error){ + + /* Filter data with the given */ + $mailQueueParser->OrderBy($this->OrderBy,$this->SortType); + $mailQueueParser->OnlyDaysAgo($this->Time); + $mailQueueParser->CreateDate(); + + if($this->Stat == "hold"){ + $mailQueueParser->Search(true,array("Hold"),true); + } + if($this->Stat == "unhold"){ + $mailQueueParser->Search(false,array("Hold"),true); + } + if($this->Stat == "active"){ + $mailQueueParser->Search(true,array("Active"),true); + } + if($this->Stat == "nonactive"){ + $mailQueueParser->Search(false,array("Active"),true); + } + + $mailQueueParser->Search($this->Search,array("MailID","Size","Sender","Recipient","Error","Arrival")); + + /* */ + $entries = $mailQueueParser->GetAll(); + + if(count($entries) ==0 ){ + $smarty->assign("all_ok",false); + } + + $smarty->assign("entries" , array_slice($entries,$this->Page,$this->range)); + $smarty->assign("plug" , "?plug=".$_GET['plug']); + $smarty->assign("r_stats" , $this->getStats()); + $smarty->assign("stats" , array_flip($this->getStats())); + $smarty->assign("stat" , $this->Stat); + $smarty->assign("p_server" , $this->Server); + $smarty->assign("p_servers" , $this->getServer()); + $smarty->assign("p_serverKeys" , array_flip($this->getServer())); + $smarty->assign("p_time" , $this->Time); + $smarty->assign("p_times" , $this->getTimes()); + $smarty->assign("p_timeKeys" , array_flip($this->getTimes())); + $smarty->assign("search_for" , $this->Search); + $smarty->assign("range_selector", range_selector(count($entries), $this->Page, $this->range,"EntriesPerPage")); + $smarty->assign("OrderBy" , $this->OrderBy); + + /* Display sort arrow */ + if($this->SortType == "up"){ + $smarty->assign("SortType",""._("up").""); + }else{ + $smarty->assign("SortType",""._("down").""); + } + } + } + + /* In case of an error */ + if($error){ + $smarty->assign("all_ok" , "false"); + $smarty->assign("r_stats" , $this->getStats()); + $smarty->assign("stats" , array_flip($this->getStats())); + $smarty->assign("stat" , $this->Stat); + $smarty->assign("plug" , "?plug=".$_GET['plug']); + $smarty->assign("p_server" , $this->Server); + $smarty->assign("p_servers" , $this->getServer()); + $smarty->assign("p_serverKeys" , array_flip($this->getServer())); + $smarty->assign("p_time" , $this->Time); + $smarty->assign("p_times" , $this->getTimes()); + $smarty->assign("p_timeKeys" , array_flip($this->getTimes())); + $smarty->assign("search_for" , $this->Search); + $smarty->assign("OrderBy" , $this->OrderBy); + } + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + + /* return selectable server */ + function getServer() + { + $ret= array("all"=>_("All")); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=goMailServer)",array("cn")); + while($tmp = $ldap->fetch()){ + $ret[$tmp['cn'][0]]= $tmp['cn'][0]; + } + return($ret); + } + + + /* Return selectable times*/ + function getTimes() + { + $ret = array(); + $ret['nolimit']=_("no limit"); + foreach(array(1,2,4,8,12,24,36,48) as $i){ + if($i == 1){ + $ret[$i] = $i." "._("hour"); + }else{ + $ret[$i] = $i." "._("hours"); + } + } + return($ret); + } + + + /* Save post values*/ + function save_object($save_current= FALSE) + { + if(isset($_POST['p_server'])){ + $this->Server = $_POST['p_server']; + } + if(isset($_POST['p_time'])){ + $this->Time = $_POST['p_time']; + } + if(isset($_POST['search_for'])){ + $this->Search = $_POST['search_for']; + } + if(isset($_POST['Stat'])){ + $this->Stat = $_POST['Stat']; + } + if((isset($_GET['start']))&&(is_numeric($_GET['start']))&&($_GET['start']>=0)){ + $this->Page = $_GET['start']; + } + + if((isset($_GET['sort']))&&(!empty($_GET['sort']))){ + $old = $this->OrderBy; + $this->OrderBy = $_GET['sort']; + if($this->OrderBy == $old) + { + if($this->SortType== "up"){ + $this->SortType = "down"; + }else{ + $this->SortType = "up"; + } + } + } + + } + + /* Return stats */ + function getStats() + { + return(array( + "all" =>_("All"), + "hold" =>_("Hold"), + "unhold" =>_("Un hold"), + "active" =>_("Active"), + "nonactive" =>_("Not active") + )); + } + + /* Return plugin informations for acl handling + #FIXME You can only read attributes within this report plugin */ + static function plInfo() + { + return (array( + "plShortName" => _("Mailqueue"), + "plDescription" => _("Mailqueue addon"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("addon"), + "plCategory" => array("mailqueue" => array("objectClass" => "none", "description" => _("Mail queue addon"))), + + "plProvidedAcls" => array( + "unhold_all" => _("Unhold all messages"), + "hold_all" => _("Hold all messages"), + "del_all" => _("Delete all messages"), + "requeue_all" => _("Requeue all messages"), + "unhold" => _("Unhold message"), + "hold" => _("Hold message"), + "del" => _("Delete message"), + "requeue" => _("Requeue message"), + "query" => _("Gathering queue data"), + "header" => _("Get header information") + ) + )); + } + + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/mailqueue/class_parseMailQueue.inc b/gosa-core/plugins/addons/mailqueue/class_parseMailQueue.inc new file mode 100644 index 000000000..b510cb3a7 --- /dev/null +++ b/gosa-core/plugins/addons/mailqueue/class_parseMailQueue.inc @@ -0,0 +1,237 @@ +s_dataToParse = $s_data; + $this->a_parsedData = array(); + $this->_parse($s_data,$server); + } + + + /* Remove all entries which are older than the last x hours + */ + function OnlyDaysAgo($str) + { + /* Get current time */ + $cur = time(); + + /* Only perform this filter, if the given parameter is valid */ + if((is_numeric($str))&&($str != 0)){ + + /* hours are given as parameter */ + $cur = $cur - ($str*(60*60)); + + /* Remove old entries */ + foreach($this->a_parsedData as $key => $data){ + if($data['Arrival'] < $cur){ + unset($this->a_parsedData[$key]); + } + } + } + } + + + /* Only keep entries that contains the $filter + * in any of the given $fields + */ + function Search($filter,$fields,$bool = false) + { + /* Go through all entries */ + foreach($this->a_parsedData as $key => $data){ + + /* not found yet */ + $found = false; + + foreach($fields as $attr){ + if(($bool)&&($data[$attr]==$filter)){ + $found = true; + }elseif(preg_match("/".str_replace("*",".*",$filter)."/i",$data[$attr])){ + $found= true; + } + } + + /* if nothing found, delete this entry */ + if($found == false){ + unset($this->a_parsedData[$key]); + } + } + } + + /* Convert date from timestamp to human readable */ + function CreateDate() + { + foreach($this->a_parsedData as $key => $data){ + $this->a_parsedData[$key]['Arrival'] = date("d.m.Y H:i:s",$data['Arrival']); + } + } + + /* Order by specified field */ + function OrderBy($str = "Arrival",$type = "up" ) + { + $tmp = array(); + /* If the given field is not valid */ + if(!in_array($str,array("MailID","Size","Sender","Recipient","Arrival","Error","Server"))){ + return(false); + } + + /* Size need special handling, cause it contains numbers + */ + if($str == "Size"){ + foreach($this->a_parsedData as $data){ + $struse = ""; + for($i = strlen($data['Size']); $i < 10 ; $i++ ){ + $struse .="0"; + } + $struse .= $data[$str].$data['MailID'].$data['Server']; + $tmp[$struse]= $data; + } + }else{ + foreach($this->a_parsedData as $data){ + $tmp[strtolower($data[$str]).$data['MailID']."-".$data['Server']]= $data; + } + } + ksort($tmp); + if($type != "up"){ + $tmp = array_reverse($tmp); + } + $this->a_parsedData = array(); + foreach($tmp as $data){ + $this->a_parsedData[$data['MailID']."-".$data['Server']] = $data; + } + return(true); + } + + function GetAll() + { + return($this->a_parsedData); + } + + /* Checks if the given MailID exists */ + function IDExists($id) + { + foreach($this->a_parsedData as $entry){ + if($entry['MailID'] == $id) return(true); + } + return(false); + } + + function parseAdditionalQueue($str, $server) + { + $this->_parse($str, $server); + } + + /* This function parses the given data + * it creates an array with all given queue entries + */ + function _parse($str, $server) + { + $i = 0; // Temp var + $entries = array(); // Contains an array with the raw data for every single entry + $s_tmp = ""; // Buffer + + $s_mailID = ""; // Queue ID + $s_Size = ""; // Mail size + $s_Arrival = ""; // Arrival time + $s_Sender = ""; // Sender + $s_Recipient = ""; // Recipient + $s_Error = ""; // Occured error + + /* Remove header + */ + $this->s_dataToParse = preg_replace("/^.*------\n/","",$str); + + /* Create array with single entries + */ + $entries = split("\n\n",$this->s_dataToParse); + + /* The last entry in this array is not realy an valid entry, its some kind of status. + * It would be something like this : -- 795 Kbytes in 124 Requests. + */ + $this->i_count = (count($entries))-1; + + for($i = 0 ; $i < $this->i_count; $i ++ ){ + + while(strstr($entries[$i]," ")){ + $entries[$i] = str_replace(" "," ",$entries[$i]); + } + + $s_buffer = split("\n",preg_replace("/[\\n\\r\\t]/s","\n",$entries[$i])); + + /* Get mailID */ + $tmp = split(" ",$s_buffer[0]); + + /* Get values */ + $s_mailID = $tmp[0]; + $s_Size = $tmp[1]; + $s_Sender = $tmp[6]; + + /* Parse time */ + $tmp3 = split(":",$tmp[5]); + $tmp2 = strtotime($tmp[4]." ".$tmp[3]." ".date("Y")); + $s_Arrival= mktime($tmp3[0],$tmp3[1],$tmp3[2],date("d",$tmp2),date("m",$tmp2),date("Y",$tmp2)); + + $s_Error = $s_buffer[1]; + $s_Recipient = $s_buffer[2]; + + /* + * The message is in the active queue, i.e. the message is + selected for delivery. + + ! The message is in the hold queue, i.e. no further deliv-delivery + ery attempt will be made until the mail is taken off + hold. + */ + + $s_Hold = false; + if(preg_match("/\!/",$s_mailID)){ + $s_mailID = preg_replace("/\!/","",$s_mailID); + $s_Hold = "true"; + } + + $s_Active = false; + if(preg_match("/\*/",$s_mailID)){ + $s_mailID = preg_replace("/\*/","",$s_mailID); + $s_Active = true; + } + + /* Append data */ + $this->a_parsedData[$s_mailID."-".$server]['Server'] = $server; + $this->a_parsedData[$s_mailID."-".$server]['MailID'] = $s_mailID; + $this->a_parsedData[$s_mailID."-".$server]['Size'] = $s_Size; + $this->a_parsedData[$s_mailID."-".$server]['Arrival'] = $s_Arrival; + $this->a_parsedData[$s_mailID."-".$server]['Sender'] = $s_Sender; + $this->a_parsedData[$s_mailID."-".$server]['Recipient'] = $s_Recipient; + $this->a_parsedData[$s_mailID."-".$server]['Hold'] = $s_Hold; + $this->a_parsedData[$s_mailID."-".$server]['Active'] = $s_Active; + $this->a_parsedData[$s_mailID."-".$server]['Error'] = $this->_parseError($s_Error); + } + return($this->a_parsedData); + } + + /* Parse Error part of the entry */ + function _parseError($str) + { + $str = trim(preg_replace("/[()]/","",$str)); + $tmp2 = split(":",$str); + $tmp = array_reverse($tmp2); + $err = preg_replace("/#.*$/","",$tmp[0]); + $text = preg_replace("/said$/i","",trim($tmp2[0])); + return($err); + } + +} + + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/mailqueue/contents.tpl b/gosa-core/plugins/addons/mailqueue/contents.tpl new file mode 100644 index 000000000..139bcd481 --- /dev/null +++ b/gosa-core/plugins/addons/mailqueue/contents.tpl @@ -0,0 +1,130 @@ +
 
+
+

[F]Filter

+
+
+
+ + + + + +
+ {t}Search{/t} +  {t}Search for{/t} + +  in + + {t}with status{/t} : + +  {t}within the last{/t}  + +   + +   + + + + +
+
+
+
+ + +{if $all_ok != "true"} +{t}Search returned no results{/t}... +{else} + + + + + + + + + + + + + +{counter start=0 assign=i start=1} +{foreach from=$entries item=val key=key} + + {if ($i%2)== 0 } + + {else} + + {/if} + + + + + + + + + + {counter} +{/foreach} +
{t}ID{/t} {if $OrderBy == "MailID"} {$SortType}{/if}{t}Server{/t} {if $OrderBy == "Server"} {$SortType}{/if}{t}Size{/t} {if $OrderBy == "Size"} {$SortType}{/if}{t}Arrival{/t} {if $OrderBy == "Arrival"} {$SortType}{/if}{t}Sender{/t} {if $OrderBy == "Sender"} {$SortType}{/if}{t}Recipient{/t} {if $OrderBy == "Recipient"}{$SortType}{/if}{t}Error{/t} {if $OrderBy == "Error"} {$SortType}{/if} 
+ + {if $entries[$key].Active == true} + {t}Active{/t} + {/if} + + {$entries[$key].MailID} + + {$entries[$key].Server} + {$entries[$key].Size} + {$entries[$key].Arrival} + {$entries[$key].Sender} + {$entries[$key].Recipient}{$entries[$key].Error} + + {t}delete{/t} + + {if $entries[$key].Hold == true} + + {t}unhold{/t} + + {else} + + {t}hold{/t} + + {/if} + + {t}requeue{/t} + + + {t}header{/t} + +
+ + + + + +
{$range_selector}
+

 

+ +{/if} + + diff --git a/gosa-core/plugins/addons/mailqueue/header.tpl b/gosa-core/plugins/addons/mailqueue/header.tpl new file mode 100644 index 000000000..eeb8bcfbc --- /dev/null +++ b/gosa-core/plugins/addons/mailqueue/header.tpl @@ -0,0 +1,6 @@ +{$header} + +

 

+
+ +
diff --git a/gosa-core/plugins/addons/mailqueue/main.inc b/gosa-core/plugins/addons/mailqueue/main.inc new file mode 100644 index 000000000..09bbe568c --- /dev/null +++ b/gosa-core/plugins/addons/mailqueue/main.inc @@ -0,0 +1,47 @@ +set_acl_category("mailqueue"); + + /* Check root dn and user dn for acl informations */ + $_SESSION['mailqueue']->set_acl_base($config->current['BASE']); + if($_SESSION['mailqueue']->getacl("") == ""){ + $_SESSION['mailqueue']->set_acl_base($ui->dn); + } + } + $mailqueue= $_SESSION['mailqueue']; + + /* Execute formular */ + $mailqueue->save_object(); + $display= $mailqueue->execute (); + $display.= "\n"; + + /* Page header*/ + $display= print_header(get_template_path('images/mailqueue.png'), _("Mail queue")).$display; + + /* Store changes in session */ + $_SESSION['mailqueue']= $mailqueue; +} +?> diff --git a/gosa-core/plugins/addons/notifications/class_msgplug.inc b/gosa-core/plugins/addons/notifications/class_msgplug.inc new file mode 100644 index 000000000..edbab55ee --- /dev/null +++ b/gosa-core/plugins/addons/notifications/class_msgplug.inc @@ -0,0 +1,258 @@ +config= &$config; + $ui= get_userinfo(); + $tag= $ui->gosaUnitTag; + + /* Preset values */ + $this->targets= array("user" => _("Users"), "group" => _("Groups")); + asort($this->targets); + + $res = get_list("(objectClass=gosaAccount)", "users", $this->config->current['BASE'],array('uid', 'cn'),GL_SUBSEARCH); + foreach($res as $key => $attrs){ + $this->users['U:'.$attrs['uid'][0]]= $attrs['cn'][0].' ['.$attrs['uid'][0].']'; + } + ksort($this->users); + + $res = get_list("(objectClass=posixGroup)", "groups", $this->config->current['BASE'],array('cn','description')); + foreach($res as $key => $attrs){ + $dsc= ""; + if (isset($attrs['description'][0])){ + $dsc= $attrs['description'][0]; + } + $this->groups['G:'.$attrs['cn'][0]]= $attrs['cn'][0].' ['.$dsc.']'; + } + ksort($this->users); + + + /* Load templates */ + if (isset($this->config->current['NOTIFYDIR'])){ + $dir= $this->config->current['NOTIFYDIR']; + if (is_dir($dir) && is_readable($dir)){ + + /* Look for files and build the vacation array */ + $dh= opendir($dir); + while ($file = readdir($dh)){ + $description= $this->parse_notification("$dir/$file"); + if ($description != ""){ + $this->templates["$dir/$file"]= $description; + } + } + closedir($dh); + } + + /* Enable templates if there are some... */ + if (count($this->templates)){ + $this->show_templates= true; + } + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","msgplug/".get_class($this),$this->dn); + } + + /* Send message? */ + if (isset($_POST['send']) && $this->acl_is_writeable("notify")){ + + /* Do we have recipients? */ + if (count($this->recipients)){ + + /*Permissions ok? */ + if (!$this->acl_is_writeable('notify')){ + print_red(_("You have no permissions to send a message!")); + } else { + $cmd= $this->config->search("msgplug", "NOTIFY_COMMAND",array('menu')); + if ($cmd == ""){ + print_red(_("No NOTIFY_COMMAND definition found in your gosa.conf")); + } else { + $parameters= base64_encode($this->nmessage) ." "; + foreach ($this->recipients as $key => $value){ + $parameters.= "$key "; + } + exec ("$cmd $parameters", $dummy, $retval); + if ($retval != 0){ + print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); + } + $this->finalized= true; + } + } + } else { + print_red(_("Please specify at least one recipient to send a message!")); + } + } + + /* Bounce back to the original dialog */ + if (isset($_POST['continue'])){ + $this->finalized= false; + } + + /* Add to list? */ + if (isset($_POST['add']) && isset($_POST['source']) && $this->acl_is_writeable("notify")){ + foreach ($_POST['source'] as $key){ + if ($this->target == 'user'){ + if(isset($this->users[$key])){ + $this->recipients[$key]= $this->users[$key]; + } + } + if ($this->target == 'group'){ + if(isset($this->groups[$key])){ + $this->recipients[$key]= $this->groups[$key]; + } + } + } + ksort($this->recipients); + } + + /* Remove from list? */ + if (isset($_POST['del']) && isset($_POST['recipient'])){ + foreach ($_POST['recipient'] as $key){ + unset($this->recipients[$key]); + } + } + + /* Import message? */ + if (isset($_POST["import_template"]) && isset($this->templates[$_POST["nmessage_template"]])){ + $contents= ""; + $lines= file($_POST["nmessage_template"]); + foreach ($lines as $line){ + if (!preg_match('/^DESC:/', $line)){ + $contents.= $line; + } + } + + /* Replace attributes */ + $ui= get_userinfo(); + $contents= preg_replace('/%self/', $ui->cn, $contents); + + /* Save message */ + $this->nmessage= htmlspecialchars($contents); + } + + $smarty= get_smarty(); + + /* Assign possible target types */ + $smarty->assign("targets", $this->targets); + foreach ($this->attributes as $attr){ + $smarty->assign($attr, $this->$attr); + } + + /* Generate list */ + $tmp= array(); + foreach (array("user" => "users", "group" => "groups") as $field => $arr){ + if ($this->target == $field){ + foreach ($this->$arr as $key => $value){ + if (!isset($this->recipients[$key])){ + $tmp[$key]= $value; + } + } + } + } + $smarty->assign('sources', $tmp); + $smarty->assign('recipients', $this->recipients); + + /* Assign ACL */ + $smarty->assign('nmessageACL', $this->getacl("notify")); + + /* Handle templates */ + $smarty->assign('show_templates', $this->show_templates?"true":"false"); + $smarty->assign('message_templates', $this->templates); + $smarty->assign('template', $this->template); + $smarty->assign('finished', $this->finalized?"true":"false"); + + /* Show main page */ + return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); + } + + + function parse_notification($file) + { + $desc= ""; + + if (is_file($file)){ + $fh = fopen($file, "r"); + $line= fgets($fh, 256); + + if (!preg_match('/^DESC:/', $line)){ + print_red (_("No DESC tag in message file:")." $file"); + return $desc; + } + fclose ($fh); + + $desc= trim(preg_replace('/^DESC:\s*/', '', $line)); + } + + return $desc; + } + + + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Notification"), + "plDescription" => _("Notification plugin"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 89, + "plSection" => array("addon"), + "plCategory" => array("msgplug" => array("objectClass" => "none", "description" => _("Notification plugin"))), + + "plProvidedAcls" => array( + "notify" => _("Allow sending notifications") + ) + )); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/addons/notifications/contents.tpl b/gosa-core/plugins/addons/notifications/contents.tpl new file mode 100644 index 000000000..689869613 --- /dev/null +++ b/gosa-core/plugins/addons/notifications/contents.tpl @@ -0,0 +1,80 @@ +{if $finished eq "false"} +

{t}Notification target{/t}

+ + + + + + + + + + + + +
+ {t}Use target from{/t} + + {if $javascript eq 'false'}{/if}

+
+ +
+ {t}Available recipients{/t}
+ +
+ +

+ +
+ {t}Recipients{/t}
+ +
+ + +

 

+

{t}Message{/t}

+{render acl=$nmessageACL} + +{/render} + +{if $show_templates eq "true"} + + +{/if} + +

 

+
+{render acl=$nmessageACL} + +{/render} +
+ + + + +{else} +

{t}Notification send!{/t}

+

 

+
+{t}Your message has been sent successfully. Press the continue button to get back to the notification plugin.{/t} +

 

+
+ +
+{/if} diff --git a/gosa-core/plugins/addons/notifications/main.inc b/gosa-core/plugins/addons/notifications/main.inc new file mode 100644 index 000000000..c73698541 --- /dev/null +++ b/gosa-core/plugins/addons/notifications/main.inc @@ -0,0 +1,51 @@ +set_acl_category("msgplug"); + + /* Check root dn and user dn for acl informations */ + $_SESSION['msgplug']->set_acl_base($config->current['BASE']); + if($_SESSION['msgplug']->getacl("") == ""){ + $_SESSION['msgplug']->set_acl_base($ui->dn); + } + } + $msgplug= $_SESSION['msgplug']; + + /* save changes back to object */ + if (isset ($_POST['target'])){ + $msgplug->save_object (); + } + + /* Execute formular */ + $display= $msgplug->execute (); + $display.= "\n"; + + /* Page header*/ + $display= print_header(get_template_path('images/notifications.png'), _("Notifications")).$display; + + /* Store changes in session */ + $_SESSION['msgplug']= $msgplug; +} +?> diff --git a/gosa-core/plugins/admin/acl/acl_role.tpl b/gosa-core/plugins/admin/acl/acl_role.tpl new file mode 100644 index 000000000..17a2704b7 --- /dev/null +++ b/gosa-core/plugins/admin/acl/acl_role.tpl @@ -0,0 +1,78 @@ +{if $dialogState eq 'head'} + +

{t}Assigned ACLs for current entry{/t}

+ + + + + + + + + + + + + +
+ {t}Name{/t} + +{render acl=$cnACL} + +{/render} +
+ {t}Description{/t} + +{render acl=$descriptionACL} + +{/render} +
+ {t}Base{/t} + +{render acl=$baseACL} + +{/render} + +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} + +
+{$aclList} + + +{/if} + +{if $dialogState eq 'create'} +

{t}ACL type{/t}  {if $javascript eq 'false'}{/if}

+ +

 

+ + +

{t}List of available ACL categories{/t}

+{$aclList} + +

 

+
+ +   + +
+{/if} + +{if $dialogState eq 'edit'} + +

{$headline}

+ +{$aclSelector} + +

 

+
+ +   + +
+{/if} + diff --git a/gosa-core/plugins/admin/acl/class_aclManagement.inc b/gosa-core/plugins/admin/acl/class_aclManagement.inc new file mode 100644 index 000000000..fd784ed0b --- /dev/null +++ b/gosa-core/plugins/admin/acl/class_aclManagement.inc @@ -0,0 +1,656 @@ + + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +class aclManagement extends plugin +{ + /* Plugin definitions */ + var $plHeadline = "ACLs"; + var $plDescription = "This does something"; + + /* Dialog attributes */ + var $acltabs = NULL; + var $ui = NULL; + var $acl = ""; + var $DivListACL = NULL; + + var $CopyPasteHandler; + var $start_pasting_copied_objects = FALSE; + + function aclManagement(&$config, &$ui) + { + /* Save configuration for internal use */ + $this->config = &$config; + $this->ui = &$ui; + + /* Copy & Paste enabled ?*/ + if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + + /* Creat dialog object */ + $this->DivListACL = new divListACL($this->config,$this); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $_SESSION['LOCK_VARS_TO_USE'] = array("/^list/","/^id_/","/^list_acl_role_del/","/^list_acl_del/"); + + $smarty = get_smarty(); // Smarty instance + $s_action = ""; // Contains the action to be taken + $s_entry = ""; // The value for s_action + + /* Edit entry button pressed? */ + if( isset($_GET['act']) && $_GET['act'] == "list_edit_entry" ){ + $s_action= "edit"; + $s_entry= validate($_GET['id']); + } + + /* Edit entry button pressed? */ + if( isset($_GET['act']) && $_GET['act'] == "list_edit_role" ){ + $s_action= "edit_role"; + $s_entry= validate($_GET['id']); + } + + $types = array( + "del" =>"^list_acl_del", + "edit" =>"^list_acl_edit", + "del_role" =>"^list_acl_role_del", + "edit_role" =>"^list_acl_role_edit", + "copy" =>"^copy", + "cut" =>"^cut", + "copy_multiple"=> "^multiple_copy_objects", + "cut_multiple" => "^multiple_cut_objects", + "editPaste" =>"^editPaste", + "addrole" =>"^new_acl_role"); + + /* Test relevant POST values */ + foreach($_POST as $key => $val){ + + /* Get every possible POST combination and set s_action/s_entry accordingly */ + foreach($types as $act => $name){ + + if (preg_match("/".$name.".*/", $key)){ + $s_action= $act; + $s_entry= preg_replace("/".$name."_/i", "", $key); + } + } + } + + /* Remove coordinate prefix from POST, required by some browsers */ + $s_entry= preg_replace("/_.$/", "", $s_entry); + + /* Seperate possibly encoded tab and entry, default to tab "acl" */ + if(preg_match("/.*-.*/", $s_entry)){ + $s_tab= preg_replace("/^[^-]*-/i", "" ,$s_entry); + $s_entry= preg_replace("/-[^-]*$/i", "", $s_entry); + }else{ + $s_tab= "generic"; + } + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "new_acl_role"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + /******************** + Copy & Paste Handling ... + ********************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /******************** + * Add new Role entry + ********************/ + + if(($s_action == "addrole") && (!isset($this->acltabs->config))){ + + /* Get 'dn' from posted acl, must be unique */ + $this->dn= "new"; + + /* Check permissions */ + if(preg_match("/c/",$this->ui->get_permissions($this->DivListACL->selectedBase,"acl/acl"))){ + + /* Register acltabs to trigger edit dialog */ + $this->acltabs= new aclroletab($this->config, NULL,$this->dn); + $this->acltabs->set_acl_base($this->DivListACL->selectedBase); + }else{ + print_red(_("You are not allowed to create a new role.")); + } + } + + /******************** + Edit existing entry + ********************/ + + if (($s_action=="edit" || $s_action=="edit_role") && (!isset($this->acltabs->config))){ + + /* Get 'dn' from posted acl, must be unique */ + $this->dn= $this->list[trim($s_entry)]['dn']; + + /* Check permissions */ + if(preg_match("/r/",$this->ui->get_permissions($this->dn,"acl/acl"))){ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($acl= get_lock($this->dn)) != ""){ + return(gen_locked_message ($acl, $this->dn)); + } + + /* Lock the current entry, so everyone will get the above dialog */ + add_lock ($this->dn, $this->ui->dn); + + /* Register acltabs to trigger edit dialog */ + if($s_action=="edit_role"){ + $this->acltabs= new aclroletab($this->config, NULL,$this->dn); + $this->acltabs-> set_acl_base($this->dn); + }else{ + $this->acltabs= new acltab($this->config, NULL,$this->dn); + $this->acltabs-> set_acl_base($this->dn); + } + + /* Set ACL and move DN to the headline */ + $_SESSION['objectinfo']= $this->dn; + }else{ + print_red(_("You are not allowed to edit this acl.")); + } + } + + + /******************** + Edit canceled + ********************/ + if(isset($_POST['delete_lock'])){ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + /* Reset all relevant data, if we get a _cancel request */ + if (isset($_POST['edit_cancel'])){ + if (isset($this->acltabs)){ + del_lock ($this->dn); + unset ($this->acltabs); + } + $this->acltabs= NULL; + unset ($_SESSION['objectinfo']); + } + + + /******************** + Delete entry requested, display confirm dialog + ********************/ + + /* Remove acl was requested */ + if ($s_action=="del_role"){ + + /* Get 'dn' from posted acl */ + $this->dn= $this->list[trim($s_entry)]['dn']; + + /* Check permissions */ + if(preg_match("/d/",$this->ui->get_permissions($this->dn,"aclroles/aclrole"))){ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($acl= get_lock($this->dn)) != ""){ + return(gen_locked_message ($acl, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the acl %s."), @LDAP::fix($this->dn))); + $smarty->assign("is_role",true); + + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the acl isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this acl!")); + } + } + + + /******************** + Delete entry confirmed + ********************/ + + /* Confirmation for deletion has been passed. Acl should be deleted. */ + if (isset($_POST['delete_acl_role_confirmed'])){ + + /* Check permissions */ + if(preg_match("/d/",$this->ui->get_permissions($this->dn,"aclroles/aclrole"))){ + + /* Delete request is permitted, perform LDAP action */ + $this->acltabs= new aclroletab($this->config, NULL,$this->dn); + $this->acltabs->delete(); + unset ($this->acltabs); + $this->acltabs= NULL; + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this acl role!")); + + if(isset($this->ui->uid)){ + new log("security","aclroles/".get_class($this),$this->dn,array(),"Warning: '".$this->ui->uid."' tried to trick acl role deletion."); + } + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + /******************** + Delete entry requested, display confirm dialog + ********************/ + + /* Remove acl was requested */ + if ($s_action=="del"){ + + /* Get 'dn' from posted acl */ + $this->dn= $this->list[trim($s_entry)]['dn']; + + /* Check permissions */ + if(preg_match("/d/",$this->ui->get_permissions($this->dn,"acl/acl"))){ + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($acl= get_lock($this->dn)) != ""){ + $_SESSION['LOCK_VARS_TO_USE'] = array("/^list_acl_edit/","/^list_acl_del/","/^id_/"); + return(gen_locked_message ($acl, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the acl %s."), @LDAP::fix($this->dn))); + $smarty->assign("is_role",false); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the acl isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this acl!")); + } + } + + + /******************** + Delete entry confirmed + ********************/ + + /* Confirmation for deletion has been passed. Acl should be deleted. */ + if (isset($_POST['delete_acl_confirm'])){ + + /* Check permissions */ + if(preg_match("/d/",$this->ui->get_permissions($this->dn,"acl/acl"))){ + + /* Delete request is permitted, perform LDAP action */ + $this->acltabs= new acl($this->config, NULL,$this->dn); + $this->acltabs->remove_from_parent(); + unset ($this->acltabs); + $this->acltabs= NULL; + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this acl!")); + + if(isset($this->ui->uid)){ + new log("security","aclroles/".get_class($this),$this->dn,array(),"Warning: '".$this->ui->uid."' tried to trick acl role deletion."); + + } + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + /******************** + Delete entry Canceled + ********************/ + + /* Delete acl canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + } + + + /******************** + Edit entry finished (Save) + ********************/ + + /* Finish acl edit is triggered by the tabulator dialog, so + the acl wants to save edited data. Check and save at this + point. */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->acltabs->config))){ + + /* Check tabs, will feed message array */ + $this->acltabs->save_object(); + $message= $this->acltabs->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + /* Save acl data to ldap */ + if($this->acltabs->save() == 1){ + return; + } + + if (!isset($_POST['edit_apply'])){ + + /* ACl has been saved successfully, remove lock from LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + + unset ($this->acltabs); + $this->acltabs= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /******************** + Display subdialog + ********************/ + + + /* Show tab dialog if object is present */ + if(isset($this->acltabs->config)){ + + /* Save object */ + $this->acltabs->save_object(); + $display= $this->acltabs->execute(); + + /* Don't show buttons if tab dialog requests this */ + if(isset($this->acltabs)){ + + /* Skip displaying save/cancel if there is a sub dialog open */ + if (!isset($this->acltabs->dialog) || !$this->acltabs->dialog){ + $display.= "

\n"; +// $display.= "\n"; + $display.= " \n"; + + /* Skip Apply if it is a new entry */ + #if ($this->dn != "new"){ + # $display.= "\n"; + # $display.= " \n"; + #} + + // $display.= "\n"; + $display.= "

"; + } + } + return ($display); + } + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListACL->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Return rendered main page */ + /* Display dialog with system list */ + $this->DivListACL->parent = $this; + $this->DivListACL->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListACL->SubSearch){ + $this->DivListACL->AddDepartments($this->DivListACL->selectedBase,3,1); + } + $this->reload(); + $this->DivListACL->setEntries($this->list); + return($this->DivListACL->Draw()); + } + + + function reload() + { + /* Get divlist informations from filter part */ + $Regex = $this->DivListACL -> Regex; + $SubSearch = $this->DivListACL -> SubSearch; + $base = $this->DivListACL -> selectedBase; + $Attrs = array("ou","cn","description","gosaAclEntry","objectClass"); + $res = array(); + $tmp = array(); // Will contain temporary results + $ldap = $this->config->get_ldap_link(); + $Filter = "(&(objectClass=gosaACL)(gosaAclEntry=*)(|(cn=".$Regex.")(ou=".$Regex.")))"; + $FilterRoles= "(&(objectClass=gosaRole)(|(cn=".$Regex.")(ou=".$Regex.")))"; + + /* Fetch following structures, this will be used if !$SubSearch */ + $fetch_this = array( + "ME" => array("TYPE" => "cat" , "FLAGS" => GL_SIZELIMIT ,"BASE"=>""), + "SYSTEMS" => array("TYPE" => "search" , "FLAGS" => GL_SIZELIMIT | GL_SUBSEARCH ,"BASE"=>"ou=systems,"), + "APPS" => array("TYPE" => "search" , "FLAGS" => GL_SIZELIMIT | GL_SUBSEARCH ,"BASE"=>"ou=apps,"), + "PEOPLE" => array("TYPE" => "search" , "FLAGS" => GL_SIZELIMIT | GL_SUBSEARCH ,"BASE"=>get_people_ou()), + "GROUPS" => array("TYPE" => "search" , "FLAGS" => GL_SIZELIMIT | GL_SUBSEARCH ,"BASE"=>get_groups_ou())); + + /* Subsearch ? */ + if($SubSearch){ + + /* Get all object in this base */ + $Flags = GL_SIZELIMIT | GL_SUBSEARCH; + $fetch_base = $base; + $tmp = get_list($Filter, "acl", $fetch_base, $Attrs, $Flags); + $tmp2 = get_list($FilterRoles, "acl", $fetch_base, $Attrs, $Flags); + foreach($tmp as $entry){ + $res[] = $entry; + } + foreach($tmp2 as $entry){ + $res[] = $entry; + } + + }else{ + + $tmp_roles = get_list($FilterRoles, "acl", "ou=aclroles,".$base, $Attrs,GL_SIZELIMIT); + + foreach($tmp_roles as $entry){ + $res[] = $entry; + } + + /* Walk through all possible bases */ + foreach($fetch_this as $type => $data){ + + /* Get requried attributes */ + $Flags = $data['FLAGS']; + $fetch_base = $data['BASE'].$base; + $Type = $data['TYPE']; + + /* Check if method is cat or search */ + if($Type == "search"){ + $tmp = get_list($Filter, "acl", $fetch_base, $Attrs, $Flags); + foreach($tmp as $entry){ + $res[] = $entry; + } + }else{ + $ldap->cat($fetch_base,$Attrs); + $attrs = $ldap->fetch(); + if($attrs && isset($attrs['gosaAclEntry'])){ + $re2 = preg_replace("/\*/",".*",$Regex); + + if(!isset($attrs['ou']) && !isset($attrs['cn'])){ + $namingAttr= preg_replace("/^[^=]*+=([^,]*),.*$/","\\1",$fetch_base); + if(preg_match("/".$re2."/i",$namingAttr)){ + $res[] = $attrs; + } + }elseif( (isset($attrs['cn'][0]) && preg_match("/".$re2."/i",$attrs['cn'][0])) + ||(isset($attrs['ou'][0]) && preg_match("/".$re2."/i",$attrs['ou'][0]))){ + $res[] = $attrs; + } + } + } + } + } + $this->list = $res; + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->list[$s_entry]['dn']; + + if(isset($this->list[$s_entry]['objectClass']) && in_array("gosaRole",$this->list[$s_entry]['objectClass'])){ + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"aclroletab","ACLROLETAB","aclroles"); + } + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->list[$id]['dn']; + + if(isset($this->list[$id]['objectClass']) && in_array("gosaRole",$this->list[$id]['objectClass'])){ + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","aclroletab","ACLROLETAB","aclroles"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","aclroletab","ACLROLETAB","aclroles"); + } + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListACL->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + function remove_lock() + { + /* Remove acl lock if a DN is marked as "currently edited" */ + if (isset($this->acltabs->dn)){ + del_lock ($this->acltabs->dn); + } + } + + + function save_object() + { + /* Handle divlist filter && department selection*/ + if(!is_object($this->acltabs)){ + $this->DivListACL->save_object(); + } + } + + /* A set of disabled and therefore overloaded functions. They are + not needed in this class. */ + function remove_from_parent() { } + function check() { } + + function save() { + echo "SAVE ACL"; + } + + function adapt_from_template($dn) { } + function password_change_needed() { } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array()); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/acl/class_aclRole.inc b/gosa-core/plugins/admin/acl/class_aclRole.inc new file mode 100644 index 000000000..18bf440dc --- /dev/null +++ b/gosa-core/plugins/admin/acl/class_aclRole.inc @@ -0,0 +1,686 @@ +dn == "new"){ + $this->base = $_SESSION['CurrentMainBase']; + }else{ + $this->base = preg_replace("/^[^,]+,[^,]+,/","",$this->dn); + new log("view","aclroles/".get_class($this),$this->dn); + } + + /* Load ACL's */ + $this->gosaAclTemplate= array(); + if (isset($this->attrs["gosaAclTemplate"])){ + for ($i= 0; $i<$this->attrs["gosaAclTemplate"]['count']; $i++){ + $acl= $this->attrs["gosaAclTemplate"][$i]; + $this->gosaAclTemplate= array_merge($this->gosaAclTemplate, $this->explodeACL($acl)); + } + } + ksort($this->gosaAclTemplate); + + /* Extract available categories from plugin info list */ + $tmp= get_global('plist'); + $plist= $tmp->info; + $oc = array(); + foreach ($plist as $class => $acls){ + + /* Only feed categories */ + if (isset($acls['plCategory'])){ + + /* Walk through supplied list and feed only translated categories */ + foreach($acls['plCategory'] as $idx => $data){ + + /* Non numeric index means -> base object containing more informations */ + if (preg_match('/^[0-9]+$/', $idx)){ + if (!isset($this->ocMapping[$data])){ + $this->ocMapping[$data]= array(); + $this->ocMapping[$data][]= '0'; + } + $this->ocMapping[$data][]= $class; + } else { + if (!isset($this->ocMapping[$idx])){ + $this->ocMapping[$idx]= array(); + $this->ocMapping[$idx][]= '0'; + } + $this->ocMapping[$idx][]= $class; + $this->aclObjects[$idx]= $data['description']; + + /* Additionally filter the classes we're interested in in "self edit" mode */ + if (is_array($data['objectClass'])){ + foreach($data['objectClass'] as $objectClass){ + if (in_array_ics($objectClass, $oc)){ + $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription']; + break; + } + } + } else { + if (in_array_ics($data['objectClass'], $oc)){ + $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription']; + } + } + } + + } + } + } + $this->aclObjects['all']= '* '._("All categories"); + $this->ocMapping['all']= array('0' => 'all'); + + /* Sort categories */ + asort($this->aclObjects); + + /* Fill acl types */ + $this->aclTypes= array( "reset" => _("Reset ACLs"), + "one" => _("One level"), + "base" => _("Current object"), + "sub" => _("Complete subtree"), + "psub" => _("Complete subtree (permanent)")); + asort($this->aclTypes); + + /* Finally - we want to get saved... */ + $this->is_account= TRUE; + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* Check if selected base is valid */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + $tmp= get_global('plist'); + $plist= $tmp->info; + + /* Handle posts */ + if (isset($_POST['new_acl'])){ + $this->dialogState= 'create'; + $this->dialog= TRUE; + $this->currentIndex= count($this->gosaAclTemplate); + $this->loadAclEntry(TRUE); + } + + $new_acl= array(); + $aclDialog= FALSE; + $firstedit= FALSE; + foreach($_POST as $name => $post){ + + /* Actions... */ + if (preg_match('/^acl_edit_.*_x/', $name)){ + $this->dialogState= 'create'; + $firstedit= TRUE; + $this->dialog= TRUE; + $this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name); + $this->loadAclEntry(); + continue; + } + if (preg_match('/^acl_del_.*_x/', $name)){ + unset($this->gosaAclTemplate[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]); + continue; + } + + if (preg_match('/^cat_edit_.*_x/', $name)){ + $this->aclObject= preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name); + $this->dialogState= 'edit'; + foreach ($this->ocMapping[$this->aclObject] as $oc){ + if (isset($this->aclContents[$oc])){ + $this->savedAclContents[$oc]= $this->aclContents[$oc]; + } + } + continue; + } + if (preg_match('/^cat_del_.*_x/', $name)){ + $idx= preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name); + foreach ($this->ocMapping[$idx] as $key){ + unset($this->aclContents["$idx/$key"]); + } + continue; + } + + /* Sorting... */ + if (preg_match('/^sortup_.*_x/', $name)){ + $index= preg_replace('/^sortup_([0-9]+).*$/', '\1', $name); + if ($index > 0){ + $tmp= $this->gosaAclTemplate[$index]; + $this->gosaAclTemplate[$index]= $this->gosaAclTemplate[$index-1]; + $this->gosaAclTemplate[$index-1]= $tmp; + } + continue; + } + if (preg_match('/^sortdown_.*_x/', $name)){ + $index= preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name); + if ($index < count($this->gosaAclTemplate)-1){ + $tmp= $this->gosaAclTemplate[$index]; + $this->gosaAclTemplate[$index]= $this->gosaAclTemplate[$index+1]; + $this->gosaAclTemplate[$index+1]= $tmp; + } + continue; + } + + /* ACL saving... */ + if (preg_match('/^acl_.*_[^xy]$/', $name)){ + $aclDialog= TRUE; + list($dummy, $object, $attribute, $value)= split('_', $name); + + /* Skip for detection entry */ + if ($object == 'dummy') { + continue; + } + + /* Ordinary ACLs */ + if (!isset($new_acl[$object])){ + $new_acl[$object]= array(); + } + if (isset($new_acl[$object][$attribute])){ + $new_acl[$object][$attribute].= $value; + } else { + $new_acl[$object][$attribute]= $value; + } + } + } + + /* Only be interested in new acl's, if we're in the right _POST place */ + if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){ + + foreach ($this->ocMapping[$this->aclObject] as $oc){ + unset($this->aclContents[$oc]); + unset($this->aclContents[$this->aclObject.'/'.$oc]); + if (isset($new_acl[$oc])){ + $this->aclContents[$oc]= $new_acl[$oc]; + } + if (isset($new_acl[$this->aclObject.'/'.$oc])){ + $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc]; + } + } + } + + /* Save new acl in case of base edit mode */ + if (1 == 0 && $this->aclType == 'base' && !$firstedit){ + $this->aclContents= $new_acl; + } + + /* Cancel new acl? */ + if (isset($_POST['cancel_new_acl'])){ + $this->dialogState= 'head'; + $this->dialog= FALSE; + if ($this->wasNewEntry){ + unset ($this->gosaAclTemplate[$this->currentIndex]); + } + } + + /* Store ACL in main object? */ + if (isset($_POST['submit_new_acl'])){ + $this->gosaAclTemplate[$this->currentIndex]['type']= $this->aclType; + $this->gosaAclTemplate[$this->currentIndex]['members']= $this->recipients; + $this->gosaAclTemplate[$this->currentIndex]['acl']= $this->aclContents; + $this->dialogState= 'head'; + $this->dialog= FALSE; + } + + /* Cancel edit acl? */ + if (isset($_POST['cancel_edit_acl'])){ + $this->dialogState= 'create'; + foreach ($this->ocMapping[$this->aclObject] as $oc){ + if (isset($this->savedAclContents[$oc])){ + $this->aclContents[$oc]= $this->savedAclContents[$oc]; + } + } + } + + /* Save edit acl? */ + if (isset($_POST['submit_edit_acl'])){ + $this->dialogState= 'create'; + } + + /* Add acl? */ + if (isset($_POST['add_acl']) && $_POST['aclObject'] != ""){ + $this->dialogState= 'edit'; + $this->savedAclContents= array(); + foreach ($this->ocMapping[$this->aclObject] as $oc){ + if (isset($this->aclContents[$oc])){ + $this->savedAclContents[$oc]= $this->aclContents[$oc]; + } + } + } + + /* Save common values */ + foreach (array("aclType", "aclObject", "target") as $key){ + if (isset($_POST[$key])){ + $this->$key= validate($_POST[$key]); + } + } + + /* Create templating instance */ + $smarty= get_smarty(); + + $smarty->assign("bases", $this->get_allowed_bases()); + $smarty->assign("base_select", $this->base); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + if ($this->dialogState == 'head'){ + /* Draw list */ + $aclList= new divSelectBox("aclList"); + $aclList->SetHeight(350); + + /* Fill in entries */ + foreach ($this->gosaAclTemplate as $key => $entry){ + $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:100px'"); + $field2= array("string" => $this->assembleAclSummary($entry)); + $action= ""; + $action.= ""; + $action.= ""; + $action.= ""; + + $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'"); + $aclList->AddEntry(array($field1, $field2, $field3)); + } + + $smarty->assign("aclList", $aclList->DrawList()); + } + + if ($this->dialogState == 'create'){ + /* Draw list */ + $aclList= new divSelectBox("aclList"); + $aclList->SetHeight(450); + + /* Add settings for all categories to the (permanent) list */ + foreach ($this->aclObjects as $section => $dsc){ + $summary= ""; + foreach($this->ocMapping[$section] as $oc){ + if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) && + $this->aclContents[$oc][0] != ""){ + + $summary.= "$oc, "; + continue; + } + if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"]) && isset($this->aclContents["$section/$oc"][0]) && + $this->aclContents["$section/$oc"][0] != ""){ + + $summary.= "$oc, "; + continue; + } + if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){ + $summary.= "$oc, "; + } + } + + /* Set summary... */ + if ($summary == ""){ + $summary= ''._("No ACL settings for this category").''; + } else { + $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary)); + } + + $field1= array("string" => $dsc, "attach" => "style='width:140px'"); + $field2= array("string" => $summary); + $action= ""; + $action.= ""; + $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px'"); + $aclList->AddEntry(array($field1, $field2, $field3)); + } + + $smarty->assign("aclList", $aclList->DrawList()); + $smarty->assign("aclType", $this->aclType); + $smarty->assign("aclTypes", $this->aclTypes); + $smarty->assign("target", $this->target); + + if ($this->aclType == 'base'){ + $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects)); + } + } + + if ($this->dialogState == 'edit'){ + $smarty->assign('headline', sprintf(_("Edit ACL for '%s', scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType])); + + /* Collect objects for selected category */ + foreach ($this->ocMapping[$this->aclObject] as $idx => $class){ + if ($idx == 0){ + continue; + } + $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription']; + } + if ($this->aclObject == 'all'){ + $aclObjects['all']= _("All objects in current subtree"); + } + $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects)); + } + + /* Show main page */ + $smarty->assign("dialogState", $this->dialogState); + + /* Assign cn and decription if this is a role */ + foreach(array("cn","description") as $name){ + $smarty->assign($name,$this->$name); + } + return ($smarty->fetch (get_template_path('acl_role.tpl',dirname(__FILE__)))); + } + + function sort_by_priority($list) + { + $tmp= get_global('plist'); + $plist= $tmp->info; + asort($plist); + $newSort = array(); + + foreach($list as $name => $translation){ + $na = preg_replace("/^.*\//","",$name); + if (!isset($plist[$na]['plPriority'])){ + $prio= 0; + } else { + $prio= $plist[$na]['plPriority'] ; + } + + $newSort[$name] = $prio; + } + + asort($newSort); + + $ret = array(); + foreach($newSort as $name => $prio){ + $ret[$name] = $list[$name]; + } + return($ret); + } + + function loadAclEntry($new= FALSE) + { + /* New entry gets presets... */ + if ($new){ + $this->aclType= 'sub'; + $this->recipients= array(); + $this->aclContents= array(); + } else { + $acl= $this->gosaAclTemplate[$this->currentIndex]; + $this->aclType= $acl['type']; + $this->recipients= $acl['members']; + $this->aclContents= $acl['acl']; + } + + $this->wasNewEntry= $new; + } + + + function aclPostHandler() + { + if (isset($_POST['save_acl'])){ + $this->save(); + return TRUE; + } + + return FALSE; + } + + + function save() + { + /* Assemble ACL's */ + $tmp_acl= array(); + foreach ($this->gosaAclTemplate as $prio => $entry){ + $final= ""; + $members= ""; + if (isset($entry['members'])){ + foreach ($entry['members'] as $key => $dummy){ + $members.= base64_encode(preg_replace('/^.:/', '', $key)).','; + } + } + $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members); + + /* ACL's if needed */ + if ($entry['type'] != "reset" && $entry['type'] != "role"){ + $acl= ":"; + if (isset($entry['acl'])){ + foreach ($entry['acl'] as $object => $contents){ + + /* Only save, if we've some contents in there... */ + if (count($contents)){ + $acl.= $object.";"; + + foreach($contents as $attr => $permission){ + + /* First entry? Its the one for global settings... */ + if ($attr == '0'){ + $acl.= $permission; + } else { + $acl.= '#'.$attr.';'.$permission; + } + + } + $acl.= ','; + } + + } + } + $final.= preg_replace('/,$/', '', $acl); + } + + $tmp_acl[]= $final; + } + + /* Call main method */ + plugin::save(); + + /* Finally (re-)assign it... */ + $this->attrs["gosaAclTemplate"]= $tmp_acl; + + /* Remove acl from this entry if it is empty... */ + if (!count($tmp_acl)){ + /* Remove attribute */ + if ($this->initially_was_account){ + $this->attrs["gosaAclTempalte"]= array(); + } else { + if (isset($this->attrs["gosaAclTemplate"])){ + unset($this->attrs["gosaAclTemplate"]); + } + } + } + + /* Do LDAP modifications */ + $ldap= $this->config->get_ldap_link(); + + /* Check if object already exists */ + $ldap->cat($this->dn); + if($ldap->count()){ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","aclroles/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","aclroles/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving ACLs with dn '%s' failed."),$this->dn)); + + /* Refresh users ACLs */ + $ui= get_userinfo(); + $ui->loadACL(); + $_SESSION['ui']= $ui; + } + + + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $serach_for = "*:role:".base64_encode($this->dn).":*"; + $ldap->search ("(&(objectClass=gosaACL)(gosaAclEntry=".$serach_for."))",array('dn','cn','sn','givenName','uid')); + $all_names = ""; + + + $cnt = 3; + while(($attrs = $ldap->fetch()) && $cnt){ + $name = $attrs['dn']; + $name = preg_replace("/[ ]/"," ",$name); + $name = "'".$name."'"; + $all_names .= $name.", "; + $cnt --; + } + + if(!empty($all_names)){ + $all_names = preg_replace("/, $/","",$all_names); + if(!$cnt){ + $all_names .= ", ..."; + } + $all_names = "".$all_names.""; + print_red(sprintf(_("This role can't be removed while it is in use. Follwing objects are using this role %s"),$all_names)); + return; + } + + $ldap->rmDir($this->dn); + new log("remove","aclroles/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of aclRole with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove"); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + show_ldap_error($ldap->get_error(), sprintf(_("Removing aclRole from objectgroup '%s' failed"), $og->dn)); + } + } + + + function save_object() + { + plugin::save_object(); + if(isset($_POST['acl_role_posted'])){ + + /* Get base selection */ + if(isset($_POST['base'])){ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$_POST['base']])){ + $this->base = $_POST['base']; + } + } + } + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("cn",$this->cn); + $str = $smarty->fetch(get_template_path("paste_role.tpl",TRUE,dirname(__FILE__))); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $source_o = new aclrole($this->config,$source['dn']); + $this->gosaAclTemplate = $source_o->gosaAclTemplate; + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Role"), + "plDescription" => _("ACL roles"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("admin"), + "plCategory" => array("aclroles" => array("objectClass" => "gosaRole", "description" => _("Acl roles"))), + + "plProvidedAcls" => array( + "cn" => _("Name"), + "base" => _("Base"), + "description" => _("Description")) + )); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/acl/class_divListACL.inc b/gosa-core/plugins/admin/acl/class_divListACL.inc new file mode 100644 index 000000000..7da993633 --- /dev/null +++ b/gosa-core/plugins/admin/acl/class_divListACL.inc @@ -0,0 +1,306 @@ +parent = &$parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of acl")); + $this->SetSummary(_("List of acls")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to edit and delete selected acls.")); + + $this->EnableAplhabet (true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col */ + $this->action_col_size = 120; + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>" ", "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>_("Summary"))); + $this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:".$this->action_col_size."px;border-right:0px;text-align:right;'")); + + /* Set dynamically filter checkboxes */ + $this->set_filter_objectclasses(); + + /* Add SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false); + + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Display acls matching"),"*" , true); + } + + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + $Copy_Paste = ""; + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("acl"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Allow copy & paste for roles */ + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"acl"); + $acl = $ui->get_permissions($this->selectedBase,"acl/acl"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + $listhead .= + _("Base")." ". + "  "; + + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Role")."|new_acl_role|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $str = $this->get_snapshot_header(TRUE) ; + if(!empty($str)){ + $s .= "..|---|\n"; + $s .= $str; + } + } + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + } + + /* so some basic settings */ + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + + foreach($list as $key => $acl_entry){ + + /* Get copy & paste icon */ + $acl = $this->ui->get_permissions($acl_entry['dn'],"acl/acl"); + $acl_all = $this->ui->has_complete_category_acls($acl_entry['dn'],"acl"); + $action = ""; + + if(in_array("gosaRole",$acl_entry['objectClass'])){ + + /* Role handling */ + $editlink = "%s"; + $list_left_icon = ""._("Role").""; + $cn = htmlentities(utf8_decode($acl_entry['cn'][0])) ; + + if(isset($acl_entry['description'][0])){ + $cn .= " [".$acl_entry['description'][0]."]"; + } + + /* Add copy & paste handler */ + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $action.= " "; + $action.= " "; + } + + /* Add actions depending on acls */ + if(preg_match("/r/", $acl)){ + $action.= ""; + } + + /* Add snapshot functionality */ + if(preg_match("/(c.*w|w.*c)/", $acl_all)){ + $action.= $this->GetSnapShotActions($acl_entry['dn']); + } + + if(preg_match("/d/", $acl)){ + $action.= ""; + } + }else{ + + /* Acl handling */ + $editlink = "%s"; + $list_left_icon = ""._("Acl").""; + $cn = htmlentities(utf8_decode($acl_entry['dn'])); + + /* Add actions depending on acls */ + if(preg_match("/r/", $acl)){ + $action.= ""; + } + if(preg_match("/d/", $acl)){ + $action.= ""; + } + } + + if(in_array("gosaRole",$acl_entry['objectClass'])){ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + }else{ + $field0 = array("string" => "", "attach" => "style='width:20px;'"); + } + + /* Cutted objects should be displayed in light grey */ + $display = $cn; + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $acl_entry['dn']) { + $display = "".$display.""; + break; + } + } + } + + $field1 = array("string" => $list_left_icon, "attach"=> "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display)." ","attach" => ""); + $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:right;width:".$this->action_col_size."px;border-right:0px;'"); + $this->AddElement(array($field0,$field1,$field2,$field3)); + } + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + } + + + /* Add some additional checkboxes to the filter part, this should be generated dynamically. */ + function set_filter_objectclasses() + { + } + + /* Return objectClass names used in filter part */ + function get_filter_objectclasses() + { + return(array("gosaAccount","gosaDepartment")); + } + + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/acl/main.inc b/gosa-core/plugins/admin/acl/main.inc new file mode 100644 index 000000000..bea89a962 --- /dev/null +++ b/gosa-core/plugins/admin/acl/main.inc @@ -0,0 +1,57 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('macl'); + } +} else { + $display= "No headpage yet for this module"; + + /* Create usermanagement object on demand */ +if (!isset($_SESSION['macl']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['macl']= new aclManagement($config, $ui); + } + $macl= $_SESSION['macl']; + + /* Show and save dialog */ + $macl->save_object(); + $output= $macl->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/acl.png'), _("ACL management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/acl.png'), _("ACL management")); + } + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('macl'); + } + + $display.= $output; + $_SESSION['macl']= $macl; +} +?> diff --git a/gosa-core/plugins/admin/acl/paste_role.tpl b/gosa-core/plugins/admin/acl/paste_role.tpl new file mode 100644 index 000000000..41f45775f --- /dev/null +++ b/gosa-core/plugins/admin/acl/paste_role.tpl @@ -0,0 +1,10 @@ + + + + + +
+ {t}Name{/t} + + +
diff --git a/gosa-core/plugins/admin/acl/remove.tpl b/gosa-core/plugins/admin/acl/remove.tpl new file mode 100755 index 000000000..0b5323df4 --- /dev/null +++ b/gosa-core/plugins/admin/acl/remove.tpl @@ -0,0 +1,23 @@ +
+ {t}Warning{/t} +
+

+ {$info} + {t}This includes all system and setup informations. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+{if $is_role} + +   + +{else} + +   + +{/if} +

diff --git a/gosa-core/plugins/admin/acl/tabs_acl.inc b/gosa-core/plugins/admin/acl/tabs_acl.inc new file mode 100644 index 000000000..db87979fa --- /dev/null +++ b/gosa-core/plugins/admin/acl/tabs_acl.inc @@ -0,0 +1,70 @@ + "acl" , "NAME" => _("Acl"))); + + /* Save dn */ + $this->dn= $dn; + $this->config= $config; + + $baseobject= NULL; + + foreach ($data as $tab){ + $this->by_name[$tab['CLASS']]= $tab['NAME']; + + + if ($baseobject === NULL){ + if($tab['CLASS'] == "acl"){ + $baseobject= new $tab['CLASS']($this->config, $this, $this->dn); + }else{ + $baseobject= new $tab['CLASS']($this->config,$this->dn); + } + $this->by_object[$tab['CLASS']]= $baseobject; + } else { + if($tab['CLASS'] == "acl"){ + $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config,$this,$this->dn, $baseobject); + }else{ + $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject); + } + } + + $this->by_object[$tab['CLASS']]->parent= &$this; + $this->by_object[$tab['CLASS']]->set_acl_category("acl"); + + /* Initialize current */ + if ($this->current == ""){ + $this->current= $tab['CLASS']; + } + } + } + + function save($ignore_account= FALSE) + { + $ret= tabs::save(); + return $ret; + } + + function save_object($ignore_account= FALSE) + { + tabs::save_object(); + } + + function execute() + { + $display= tabs::execute(); + if(!$this->by_object['acl']->dialog){ + $display.= "

\n"; + $display.= " \n"; + $display.= "  \n"; + $display.= " \n"; + $display.= "

"; + } + return($display); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/acl/tabs_acl_role.inc b/gosa-core/plugins/admin/acl/tabs_acl_role.inc new file mode 100644 index 000000000..b1132357d --- /dev/null +++ b/gosa-core/plugins/admin/acl/tabs_acl_role.inc @@ -0,0 +1,61 @@ + "aclrole" , "NAME" => _("ACL Templates"))); + tabs::tabs($config, $data, $dn,"acl"); + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['aclrole']; + + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $new_dn= 'cn='.$baseobject->cn.",ou=aclroles,".$baseobject->base; + + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['aclrole']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + $ret= tabs::save(); + + /* Fix tagging if needed */ + $baseobject->dn= $new_dn; + $baseobject->handle_object_tagging(); + + return $ret; + } + + function save_object($ignore_account= FALSE) + { + tabs::save_object(); + } + + function execute() + { + $display= tabs::execute(); + if(!$this->by_object['aclrole']->dialog){ + $display.= "

\n"; + $display.= " \n"; + $display.= "  \n"; + $display.= " \n"; + $display.= "

"; + } + return($display); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/applications/class_applicationGeneric.inc b/gosa-core/plugins/admin/applications/class_applicationGeneric.inc new file mode 100644 index 000000000..22fcf10be --- /dev/null +++ b/gosa-core/plugins/admin/applications/class_applicationGeneric.inc @@ -0,0 +1,569 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* application attributes */ + var $cn= ""; + var $description= ""; + var $base= ""; + var $gosaApplicationExecute= ""; + var $gosaApplicationName= ""; + var $gosaApplicationFlags= ""; + var $gosaApplicationIcon= ""; + var $gotoLogonScript =""; + var $iconData; + var $view_logged = FALSE; + + /* Headpage attributes */ + var $last_sorting= "invalid"; + var $applications= array(); + + /* attribute list for save action */ + var $attributes= array("cn", "description", "gosaApplicationExecute", "gosaApplicationName","gosaApplicationIcon", + "gosaApplicationFlags","gotoLogonScript"); + var $objectclasses= array("top", "gosaApplication"); + + var $isReleaseApplikation = false; + + function application (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)) { + if(!preg_match("/^ou=apps,/",$_SESSION['appfilter']['release'])){ + $this->isReleaseApplikation = true; + } + } + + /* Load icon */ + $ldap= $config->get_ldap_link(); + if ($dn != 'new'){ + $this->iconData= $ldap->get_attribute($dn, "gosaApplicationIcon"); + $this->saved_attributes['gosaApplicationIcon'] = $this->iconData; + } + if ($this->iconData == ""){ + $this->set_picture(""); + } + $_SESSION['binary']= $this->iconData; + $_SESSION['binarytype']= "image/jpeg"; + $this->gosaApplicationIcon= $this->iconData; + + /* This is always an account */ + $this->is_account= TRUE; + + if ($this->dn == "new"){ + if(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['CurrentMainBase']; + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + + if($this->isReleaseApplikation){ + $this->base = preg_replace("/^.*,ou=apps,/","",$this->dn); + }else{ + $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn); + } + } + } + + + function generateTemplate() + { + $str= "# This code is part of GOsa (https://gosa.gonicus.de)\n#\n"; + + $values = array(); + $names = array(); + if($this->parent->by_object['applicationParameters']->is_account){ + $names = $this->parent->by_object['applicationParameters']->option_name; + $values = $this->parent->by_object['applicationParameters']->option_value; + } + + if (count($names)){ + $str .="# This plugin handles these environment variables:\n"; + } else { + $str .="# This plugin handles no environment variables.\n"; + } + + foreach($names as $index => $name){ + + // Fix length + for($i = strlen($name) ; $i < 30 ; $i++){ + $name= $name." "; + } + if((isset($values[$index]))&&(!empty($values[$index]))){ + $str.= "# ".$name."\t(e.g. '".$values[$index]."')\n"; + }else{ + $str.= "# ".$name."\t("._("no example").")\n"; + } + } + $str .= "#\n". + "# Don't remove the following tag, it is used for header update.\n". + "### END HEADER ###"; + + return($str); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","application/".get_class($this),$this->dn); + } + + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Do we represent a valid group? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' is no application.").""; + return ($display); + } + + /* Download requested */ + foreach($_POST as $name => $value){ + if(preg_match("/^downloadScript/",$name)){ + $_SESSION['binary'] = $this->gotoLogonScript; + $_SESSION['binarytype'] = "octet-stream"; + $_SESSION['binaryfile'] = $this->cn.".gosaApplication"; + header("location: getbin.php "); + exit(); + } + } + + /* Reassign picture data, sometimes its corrupt cause we started a download of application scripts */ + $_SESSION['binary'] = $this->iconData; + $_SESSION['binarytype'] = "image/jpeg"; + + $smarty->assign("rand", rand(0, 10000)); + $head = $this->generateTemplate(); + $this->gotoLogonScript= $this->generateTemplate().preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript); + + if((isset($_POST['upLoad']))&&(isset($_FILES['ScriptFile']))){ + $str = file_get_contents($_FILES['ScriptFile']['tmp_name']); + $this->gotoLogonScript = $str; + } + + /* Fill templating stuff */ + $smarty->assign("cn", $this->cn); + $smarty->assign("bases", $this->get_allowed_bases()); + if ($this->dn == "new"){ + $smarty->assign("selectmode", ""); + $smarty->assign("namemode", ""); + } else { + $smarty->assign("namemode", "readonly"); + $smarty->assign("selectmode", "disabled"); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* Just allow selection valid bases */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Get random number for pictures */ + srand((double)microtime()*1000000); + $smarty->assign("rand", rand(0, 10000)); + + /* Variables */ + foreach(array("description", "gosaApplicationExecute", "gosaApplicationName","cn") as $val){ + $smarty->assign($val, $this->$val); + } + + /* Checkboxes */ + foreach (array("G" => "exec_for_groupmembers", "O" => "overwrite_config", + "L" => "place_on_kicker", + "D" => "place_on_desktop", "M" => "place_in_startmenu") as $key => $val){ + if (preg_match("/$key/", $this->gosaApplicationFlags)){ + $smarty->assign("$val", "checked"); + } else { + $smarty->assign("$val", ""); + } + } + + $smarty->assign("isReleaseApplikation" , $this->isReleaseApplikation); + $smarty->assign("gotoLogonScript",htmlentities($this->gotoLogonScript, ENT_COMPAT, 'UTF-8')); + $smarty->assign("base_select", $this->base); + /* Show main page */ + return($smarty->fetch (get_template_path('generic.tpl', TRUE))); + } + + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + $ldap->rmDir($this->dn); + new log("remove","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of application with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove"); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + show_ldap_error($ldap->get_error(), sprintf(_("Removing application from objectgroup '%s' failed"), $og->dn)); + } + $ldap->search ("(&(objectClass=posixGroup)(gosaMemberApplication=".$this->cn."))", array("cn")); + while ($attrs= $ldap->fetch()){ + $ag= new appgroup($this->config, $ldap->getDN()); + $ag->removeApp($this->cn); + $ag->save (); + show_ldap_error($ldap->get_error(), sprintf(_("Removing application from group '%s' failed"), $ag->dn)); + } + + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['cn'])){ + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + /* Save attributes */ + parent::save_object(); + + /* Save application flags */ + $flag= ""; + if (isset($_POST['exec_for_groupmembers']) && $_POST['exec_for_groupmembers'] == 1){ + $flag.= "G"; + } + if (isset($_POST['place_on_desktop']) && $_POST['place_on_desktop'] == 1){ + $flag.= "D"; + } + if (isset($_POST['place_on_kicker']) && $_POST['place_on_kicker'] == 1){ + $flag.= "L"; + } + if (isset($_POST['place_in_startmenu']) && $_POST['place_in_startmenu'] == 1){ + $flag.= "M"; + } + if (isset($_POST['overwrite_config']) && $_POST['overwrite_config'] == 1){ + $flag.= "O"; + } + if ($this->acl_is_writeable("gosaApplicationFlags")){ + $this->gosaApplicationFlags= "[$flag]"; + } + + /* Remove current picture */ + if(isset($_POST['remove_picture'])){ + $this->set_picture(""); + } + + /* Check for picture upload */ + if (isset($_FILES['picture_file']['name']) && $_FILES['picture_file']['name'] != ""){ + + if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) { + print_red (_("The specified picture has not been uploaded correctly.")); + } + + if (!function_exists("imagick_blob2image")){ + /* Get temporary file name for conversation */ + $fname = tempnam ("/tmp", "GOsa"); + + /* Open file and write out photoData */ + $fp = fopen ($fname, "w"); + fwrite ($fp, $_FILES['picture_file']['tmp_name']); + fclose ($fp); + + /* Build conversation query. Filename is generated automatically, so + we do not need any special security checks. Exec command and save + output. For PHP safe mode, you'll need a configuration which respects + image magick as executable... */ + $query= "convert -size 48x48 $fname -resize 48x48 +profile \"*\" -"; + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $query, "Execute"); + + /* Read data written by convert */ + $output= ""; + $sh= popen($query, 'r'); + while (!feof($sh)){ + $output.= fread($sh, 4096); + } + pclose($sh); + + unlink($fname); + } else { + + /* Load the new uploaded Photo */ + if(!$handle = imagick_ReadImage($_FILES['picture_file']['tmp_name'])){ + print_red(_("Can't access uploaded image.")); + } + + /* Resizing image to 147x200 and blur */ + if(!imagick_resize($handle,48,48,IMAGICK_FILTER_GAUSSIAN,0)){ + print_red(_("Uploaded image could not be resized, possilby the image magick extension is missing.")); + } + + /* Converting image to JPEG */ + if(!imagick_convert($handle,"PNG")) { + print_red(_("Could not convert image to png, possilby the image magick extension is missing.")); + } + + if(!imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){ + print_red(sprintf(_("Could not save uploaded image to %s."),$_FILES['picture_file']['tmp_name'])); + } + + imagick_free($handle); + } + + /* Activate new picture */ + $this->set_picture($_FILES['picture_file']['tmp_name']); + } + + if(!$this->isReleaseApplikation){ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + } + } + } + + + /* Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(!preg_match("#^/#",$this->gosaApplicationExecute)){ + $message[]=(_("Specified execute path must start with '/'.")); + } + + /* Permissions for that base? */ + if ($this->base != ""){ + $new_dn= "cn=".$this->cn.",ou=apps,".$this->base; + } else { + $new_dn= $this->dn; + } + + + if($this->dn == "new"){ + $this->set_acl_base($this->base); + } + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= _("Required field 'Name' is not filled."); + } + + if(preg_match("/[^a-z0-9]/",$this->cn)) { + $message[]=_("Invalid character in application name. Only a-z 0-9 are allowed."); + } + + if ($this->gosaApplicationExecute == ""){ + $message[]= _("Required field 'Execute' is not filled."); + } + + /* Check for existing application */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current["BASE"]); + + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if((!empty($tmp)) && (isset($_SESSION['appfilter']['release']))){ + $baseDn = str_replace($this->config->current['BASE'],$this->base,$_SESSION['appfilter']['release']); + $baseDn = preg_replace("/ou=apps,.*/","ou=apps,".$this->base,$_SESSION['appfilter']['release']); + $ldap->ls("(&(objectClass=gosaApplication)(cn=".$this->cn."))",$baseDn,array("cn")); + if($ldap->count()){ + $attrs = $ldap->fetch(); + if($this->dn != $attrs['dn']) { + $message[]= _("There's already an application with this 'Name'."); + } + } + }else{ + $ldap->ls("(&(objectClass=gosaApplication)(cn=".$this->cn."))","ou=apps,".$this->base,array("cn")); + if ($ldap->count()){ + $attrs = $ldap->fetch(); + if($this->dn != $attrs['dn']) { + $message[]= _("There's already an application with this 'Name'."); + } + } + } + return $message; + } + + + /* Save to LDAP */ + function save() + { + /* Get application script without header part, to check if we must save the script itself */ + $script = preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript); + + plugin::save(); + $this->attrs["gosaApplicationIcon"]= $this->gosaApplicationIcon; + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('dn')); + + $a= $ldap->fetch(); + if (count($a)){ + + /* Remove gotoLogonScript if it is empty */ + if(empty($script)) { + $this->attrs['gotoLogonScript'] = array(); + } + + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + $this->handle_post_events("modify"); + new log("modify","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } else { + + /* Remove gotoLogonScript if it is empty */ + if(empty($script)) { + unset($this->attrs['gotoLogonScript']); + } + + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("add"); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of application with dn '%s' failed."),$this->dn)); + } + + function set_picture($filename) + { + if (!is_file($filename)){ + $filename= "./images/default_icon.png"; + $this->gosaApplicationIcon= "*removed*"; + } + + if (file_exists($filename)){ + $fd = fopen ($filename, "rb"); + $this->iconData= fread ($fd, filesize ($filename)); + $_SESSION['binary']= $this->iconData; + $_SESSION['binarytype']= "image/jpeg"; + $this->gosaApplicationIcon= $this->iconData; + + fclose ($fd); + } + } + + function getCopyDialog() + { + $vars = array("cn"); + + $str ="

"._("Application settings")."

+ + + + + +
". + _("Application name"). + " + +
"; + $ret = array(); + $ret['status'] = ""; + $ret['string'] = $str; + return($ret); + } + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + $source_o = new application($this->config,$source['dn']); + $this->gosaApplicationIcon = $source_o->gosaApplicationIcon; + } + + + /* Return plugin informations for acl handling + #FIXME FAIscript seams to ununsed within this class... */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Application generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("application" => array("description" => _("Application"), + "objectClass" => "gosaApplication")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "base" => _("Base"), + "description" => _("Description"), + "gosaApplicationExecute" => _("Execute"), + "gosaApplicationName" => _("Name"), + "gosaApplicationIcon" => _("Icon"), + "gosaApplicationFlags" => _("Flag"), + "gotoLogonScript" => _("Script content"), + + "exec_for_groupmembers" => _("Only executable for members"), // G + "place_on_desktop" => _("Place icon on members desktop"), // D + "place_on_kicker" => _("Place entry in members launch bar"), // L + "place_in_startmenu" => _("Place entry in members startmenu"), // M + "overwrite_config" => _("Replace user configuration on startup")) // O + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/applications/class_applicationManagement.inc b/gosa-core/plugins/admin/applications/class_applicationManagement.inc new file mode 100644 index 000000000..69a4c0f48 --- /dev/null +++ b/gosa-core/plugins/admin/applications/class_applicationManagement.inc @@ -0,0 +1,645 @@ +config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + return(true); + } + return(false); + } + + function applicationManagement (&$config, &$ui) + { + /* Save configuration for internal use */ + $this->config = &$config; + $this->ui = &$ui; + + /* Check if copy & paste is activated */ + if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + + /* Creat dialog object */ + $this->DivListApplication = new divListApplication($this->config,$this); + + if($this->IsReleaseManagementActivated()){ + /* Check if we should enable the release selection */ + $this->enableReleaseManagement = true; + + /* Hide SubSearch checkbox */ + $this->DivListApplication->DisableCheckBox("SubSearch"); + } + } + + function getReleases($base) + { + $ldap = $this->config->get_ldap_link(); + $dn = "ou=apps,".$base; + $ret = array(); + $ret ["ou=apps,".$base] = "/"; + + $ldap->cd($dn); + $ldap->search("objectClass=organizationalUnit",array("ou")); + + while($attrs = $ldap->fetch()){ + $str = str_replace($dn,"",$attrs['dn']); + $tmp = array_reverse( split("ou=",$str)); + $str = ""; + foreach($tmp as $val){ + $val = trim(preg_replace("/,/","",$val)); + if(empty($val)) break; + $str .= "/".$val; + } + if(!empty($str)){ + $ret[$attrs['dn']]= preg_replace("/^\//","",$str); + } + } + asort($ret); + return($ret); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + + /**************** + Variable init + ****************/ + + /* These vars will be stored if you try to open a locked app, + to be able to perform your last requests after showing a warning message */ + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^appl_edit_/","/^appl_del_/","/^item_selected/","/^remove_multiple_applications/"); + + $smarty = get_smarty(); // Smarty instance + $s_action = ""; // Contains the action to proceed + $s_entry = ""; // The value for s_action + $base_back = ""; // The Link for Backbutton + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/appl_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/appl_".$s_action."_/i","",$key); + // Post for edit + }elseif(preg_match("/appl_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/appl_".$s_action."_/i","",$key); + // Post for new + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + // Post for new + }elseif(preg_match("/^appl_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/^remove_multiple_applications/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^multiple_copy_groups/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_groups/",$key)){ + $s_action = "cut_multiple"; + } + } + + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + + $s_entry = preg_replace("/_.$/","",$s_entry); + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "appl_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + /**************** + Copy & Paste handling + ****************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + /**************** + Create a new app + ****************/ + + /* New application? */ + if ($s_action=="new"){ + + /* By default we set 'dn' to 'new', all relevant plugins will + react on this. */ + $this->dn= "new"; + + /* Create new usertab object */ + $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application"); + $this->apptabs->set_acl_base($this->DivListApplication->selectedBase); + } + + + /**************** + Edit entry canceled + ****************/ + + /* Cancel dialogs */ + if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ + del_lock ($this->apptabs->dn); + unset ($this->apptabs); + $this->apptabs= NULL; + unset ($_SESSION['objectinfo']); + } + + + /**************** + Edit entry finished + ****************/ + + /* Finish apps edit is triggered by the tabulator dialog, so + the user wants to save edited data. Check and save at this + point. */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->apptabs->config))){ + + /* Check tabs, will feed message array */ + $this->apptabs->last= $this->apptabs->current; + $this->apptabs->save_object(); + $message= $this->apptabs->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + /* Save data data to ldap */ + $this->apptabs->set_release($this->DivListApplication->selectedRelease); + $this->apptabs->save(); + + if (!isset($_POST['edit_apply'])){ + /* Application has been saved successfully, remove lock from + LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + unset ($this->apptabs); + $this->apptabs= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /**************** + Edit entry + ****************/ + + /* User wants to edit data? */ + if (($s_action=="edit") && (!isset($this->apptabs->config))){ + + /* Get 'dn' from posted 'applist', must be unique */ + $this->dn= $this->applications[$s_entry]['dn']; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so everyone will get the + above dialog */ + add_lock ($this->dn, $this->ui->dn); + + /* Register apptabs to trigger edit dialog */ + $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application"); + $this->apptabs->set_acl_base($this->dn); + $_SESSION['objectinfo']= $this->dn; + } + + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->applications[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $smarty->assign("intro", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); + } else { + $smarty->assign("intro", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); + } + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_application_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $ui = get_userinfo(); + $acl = $ui->get_permissions($dn ,"application/application"); + if (preg_match('/d/', $acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn,"application"); + $this->apptabs->set_acl_base($dn); + $this->apptabs->delete (); + unset ($this->apptabs); + $this->apptabs= NULL; + + } else { + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this application!")); + new log("security","application/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_application_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + /**************** + Delete app + ****************/ + + /* Remove user was requested */ + if ($s_action == "del"){ + + /* Get 'dn' from posted 'uid' */ + $this->dn= $this->applications[$s_entry]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->dn ,"application/application"); + + if(preg_match("/d/",$acl)){ + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return (gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty= get_smarty(); + $smarty->assign("intro", sprintf(_("You're about to delete the application '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); + return($smarty->fetch (get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the user isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this application!")); + } + } + + + /**************** + Delete app confirmed + ****************/ + + /* Confirmation for deletion has been passed. Group should be deleted. */ + if (isset($_POST['delete_app_confirm'])){ + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->dn ,"application/application"); + + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $this->dn,"application"); + $this->apptabs->set_acl_base($this->dn); + $this->apptabs->delete (); + unset ($this->apptabs); + $this->apptabs= NULL; + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this application!")); + new log("security","application/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + /**************** + Delete app canceled + ****************/ + + /* Delete application canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + /* Show tab dialog if object is present */ + if (($this->apptabs) && (isset($this->apptabs->config))){ + $display= $this->apptabs->execute(); + + /* Don't show buttons if tab dialog requests this */ + if (!$this->apptabs->by_object[$this->apptabs->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + return ($display); + } + + + /**************** + Dialog display + ****************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListApplication->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases($base))){ + return($str); + } + + /* Display dialog with system list */ + $this->DivListApplication->parent = $this; + $this->DivListApplication->execute(); + $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase,3,1); + $this->reload(); + $this->DivListApplication->setEntries($this->applications); + return($this->DivListApplication->Draw()); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases(){ + if($this->DivListApplication->selectedRelease == "main"){ + return(array($this->DivListApplication->selectedBase)); + }else{ + return(array($this->DivListApplication->selectedRelease)); + } + } + + + function reload() + { + $this->applications= array(); + + /* Set base for all searches */ + $base = $this->DivListApplication->selectedBase; + $release = $this->DivListApplication->selectedRelease; + $Regex = $this->DivListApplication->Regex; + $SubSearch = $this->DivListApplication->SubSearch; + $Flags = GL_NONE | GL_SIZELIMIT; + $Filter = "(&(cn=".$Regex.")(objectClass=gosaApplication))"; + $tmp = array(); + $Releases = $this->getReleases($base); + + if(!$this->enableReleaseManagement){ + $use_base = "ou=apps,".$base; + }else{ + if(isset($Releases[$release])){ + $use_base = $release; + }else{ + $use_base = "ou=apps,".$base; + } + } + + if($SubSearch){ + $Flags |= GL_SUBSEARCH; + } + + $res= get_list($Filter, "application", $use_base, array("cn","description","dn","objectClass"), $Flags); + foreach ($res as $val){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; + } + + ksort($tmp); + $this->applications=array(); + foreach($tmp as $val){ + $this->applications[]=$val; + } + reset ($this->applications); + } + + function remove_from_parent() + { + /* Optionally execute a command after we're done */ + $this->postremove(); + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->applications[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"apptabs","APPSTABS","application"); + } + + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->applications[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","apptabs","APPSTABS","application"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","apptabs","APPSTABS","application"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListApplication->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + /* Save to LDAP */ + function save() + { + /* Optionally execute a command after we're done */ + $this->postcreate(); + } + + function remove_lock() + { + if (isset($this->apptabs->dn)){ + del_lock ($this->apptabs->dn); + } + } + + function save_object() { + $this->DivListApplication->save_object(); + } + + function check() {} + function adapt_from_template($dn) {} + function password_change_needed() {} +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/applications/class_applicationParameters.inc b/gosa-core/plugins/admin/applications/class_applicationParameters.inc new file mode 100644 index 000000000..9f11eb6b9 --- /dev/null +++ b/gosa-core/plugins/admin/applications/class_applicationParameters.inc @@ -0,0 +1,248 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Parameters */ + var $option_name= array(); + var $option_value= array(); + + /* attribute list for save action */ + var $attributes= array("gosaApplicationParameter"); + var $objectclasses= array(); + + var $CopyPasteVars = array("option_name","option_value"); + + function applicationParameters (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $this->gosaApplicationParameter = array(); + + if (isset($this->attrs['gosaApplicationParameter'])){ + $this->is_account= TRUE; + for ($i= 0; $i<$this->attrs['gosaApplicationParameter']['count']; $i++){ + $option= preg_replace('/^[^:]+:/', '', + $this->attrs['gosaApplicationParameter'][$i]); + $name= preg_replace('/:.*$/', '', + $this->attrs['gosaApplicationParameter'][$i]); + $this->option_name[$i]= $name; + $this->option_value[$i]= $option; + } + } else { + $this->is_account= FALSE; + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Show tab dialog headers */ + $display= ""; + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove options"), + _("This application has options. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Create options"), + _("This application has options disabled. You can enable them by clicking below.")); + $this->parent->by_object['application']->generateTemplate(); + return ($display); + } + } + + /* Add option to list */ + if (isset($_POST['add_option'])){ + $i= count($this->option_name); + $this->option_name[$i]= ""; + $this->option_value[$i]= ""; + } + + /* Remove value from list */ + for ($i= 0; $ioption_name); $i++){ + if (isset($_POST["remove$i"])){ + $k= 0; + $on= array(); + $ov= array(); + for ($j= 0; $joption_name); $j++){ + if ($j != $i){ + $on[$k]= $this->option_name[$j]; + $ov[$k]= $this->option_value[$j]; + $k++; + } + } + $this->option_name= $on; + $this->option_value= $ov; + break; + } + } + + /* Generate list of attributes */ + if (count($this->option_name) == 0){ + $this->option_name[]= ""; + $this->option_value[]= ""; + } + + + $acl = $this->getacl("gosaApplicationParameter") ; + $table= ""; + if (count ($this->option_name)){ + + for ($i= 0; $i < count($this->option_name); $i++){ + $name = $this->option_name[$i]; + $value= $this->option_value[$i]; + + $tag = ""; + if(!preg_match("/w/",$acl)){ + $tag = " disabled "; + } + + if(!preg_match("/r/",$acl)){ + $name = ""; + $value= ""; + } + + $table.="". + " ". + " ". + " ". + ""; + } + } + $table.= "
"._("Variable").""._("Default value")."
". + " ". + " ". + " ". + "
". + "
". + " ". + "
"; + $table.=""; + + /* Show main page */ + $smarty= get_smarty(); + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $smarty->assign("table", $table); + $display.= $smarty->fetch(get_template_path('parameters.tpl', TRUE)); + $this->parent->by_object['application']->generateTemplate(); + return ($display); + } + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + + /* Zero attributes */ + $this->attrs= array(); + $this->attrs['gosaApplicationParameter']= array(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of application parameters with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove'); + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['option0'])){ + for ($i= 0; $ioption_name); $i++){ + $this->option_name[$i]= $_POST["option$i"]; + $this->option_value[$i]= ""; + if ($_POST["value$i"] != ""){ + $this->option_value[$i]= $_POST["value$i"]; + } + } + } + } + + + /* Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Check for valid option names */ + for ($i= 0; $ioption_name); $i++){ + if (!preg_match ("/^[a-z0-9_]+$/i", $this->option_name[$i])){ + $message[]= sprintf(_("Value '%s' specified as option name is not valid."), + $this->option_name[$i]); + } + } + + return $message; + } + + + /* Save to LDAP */ + function save() + { + /* Generate values */ + $this->attrs= array(); + if (count($this->option_name) == 0){ + $this->attrs['gosaApplicationParameter']= array(); + } else { + for ($i= 0; $ioption_name); $i++){ + $this->attrs['gosaApplicationParameter'][]= $this->option_name[$i]. + ":".$this->option_value[$i]; + } + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of application parameters with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('modify'); + } + + /* Return plugin informations for acl handling +#FIXME FAIscript seams to ununsed within this class... */ + static function plInfo() + { + return (array( + "plShortName" => _("Parameter"), + "plDescription" => _("Parameter configuration"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("application"), + + "plProvidedAcls"=> array( + "gosaApplicationParameter" => _("Application parameter settings")) + )); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/applications/class_divListApplication.inc b/gosa-core/plugins/admin/applications/class_divListApplication.inc new file mode 100755 index 000000000..15b09c6d7 --- /dev/null +++ b/gosa-core/plugins/admin/applications/class_divListApplication.inc @@ -0,0 +1,321 @@ +selectedRelease = "ou=apps,".$_SESSION['CurrentMainBase']; + + $this->parent = &$parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of Applications")); + $this->SetSummary(_("This table displays all applications in the selected tree.")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to add, edit and remove selected applications. You may want to use the range selector on top of the application listbox, when working with a large number of applications.")); + + $this->EnableAplhabet(true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* set Page header */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Application name")." / "._("Department"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); + + /* Add SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Display users matching"),"*" , true); + } + + function AddUserBoxToFilter($position){ + $str = ""; + if(($position == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){ + $smarty = get_smarty(); + $smarty->assign("selectedRelease",$this->selectedRelease); + $smarty->assign("branchimage","images/branch.png"); + $smarty->assign("releases",$this->AvailableReleases); + $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE)); + } + return($str); + } + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("application"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get acls */ + $ui = get_userinfo(); + $acl = $ui->get_permissions("cn=dummy,".$this->selectedBase,"application/application"); + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"application"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* And the rest, a base selection box */ + $listhead .= _("Base")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Application")."|appl_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + + $this->SetListHeader($listhead); + } + + /* so some basic settings */ + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + $this->AvailableReleases = $this->parent->getReleases($this->selectedBase); + } + + function setEntries($list) + { + /******************** + Variable init + ********************/ + + /* Create links */ + $linkopen = "%s"; + $editlink = "%s"; + $userimg = "User"; + $applimg = "A"; + $empty = ""; + + /* set Page header */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /******************** + Attach objects + ********************/ + + $ui = get_userinfo(); + foreach($list as $key => $val){ + + $acl = $ui->get_permissions($val['dn'],"application/application"); + $acl_all= $ui->has_complete_category_acls($val['dn'],"application"); + + /* Create action icons */ + $actions= ""; + + /* Add Copy & Paste icon */ + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + /* Only add cut icon, if we are allowed to move this user */ + if(preg_match("/m/",$acl)){ + $actions.= " "; + + $actions.= " "; + } + } + + /* Add edit icon */ + $actions.= ""; + + + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions.= $this->GetSnapShotActions($val['dn']); + } + + /* If we are allowed to remove the application account, display remove icon */ + if(preg_match("/d/",$acl)){ + $actions.= ""; + }else{ + $actions.= " "; + } + + $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; + + if(!isset($val['description'][0])){ + $desc = ""; + }else{ + $desc = " - [ ".$val['description'][0]." ]"; + } + + /* Cutted objects should be displayed in light grey */ + $display = $val['cn'][0].$desc; + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => sprintf($applimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); + $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + $this->AddElement(array($field0,$field1,$field2,$field3)); + } + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_apps = count($list); + + $num_app_str = _("Number of listed applications"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_app_str." ".$num_apps."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + } + + function Save() + { + MultiSelectWindow::Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + $_SESSION['appfilter']['release'] = $this->selectedRelease; + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/applications/generic.tpl b/gosa-core/plugins/admin/applications/generic.tpl new file mode 100644 index 000000000..b50ed7eb8 --- /dev/null +++ b/gosa-core/plugins/admin/applications/generic.tpl @@ -0,0 +1,152 @@ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+{render acl=$cnACL} + +{/render} +
+{render acl=$gosaApplicationNameACL} + +{/render} +
+{render acl=$gosaApplicationExecuteACL} + +{/render} +
+{render acl=$descriptionACL} + +{/render} +
+{render acl=$baseACL} + +{/render} +{if !$isReleaseApplikation} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +{/if} +
+
+   + + + + + + +
+ +
+ +
+  
+ + +{render acl=$gosaApplicationIconACL} + +{/render} +{render acl=$gosaApplicationIconACL} + +{/render} +{render acl=$gosaApplicationIconACL} + +{/render} +
+
+ +

 

+ +

{t}Options{/t} {t}Options{/t}

+ + + + + +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Only executable for members{/t} +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Replace user configuration on startup{/t} +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Place icon on members desktop{/t} +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Place entry in members startmenu{/t} +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Place entry in members launch bar{/t} +
+ +

 

+ + + + + +
+

{t}Script{/t} {t}Script{/t}

+{render acl=$gotoLogonScriptACL} + +{/render} +{render acl=$gotoLogonScriptACL} + +{/render} +{render acl=$gotoLogonScriptACL} + +{/render} + +
+ +
+ + + diff --git a/gosa-core/plugins/admin/applications/main.inc b/gosa-core/plugins/admin/applications/main.inc new file mode 100644 index 000000000..2df737788 --- /dev/null +++ b/gosa-core/plugins/admin/applications/main.inc @@ -0,0 +1,55 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('applicationManagement'); + } +} else { + /* Create applicationManagement object on demand */ + if (!isset($_SESSION['applicationManagement']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['applicationManagement']= new applicationManagement ($config, $_SESSION['ui']); + } + $applicationManagement= $_SESSION['applicationManagement']; + $applicationManagement->save_object(); + $output= $applicationManagement->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/application.png'), _("Application management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/application.png'), _("Application management")); + } + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('applicationManagement'); + } + + /* Show and save dialog */ + $display.= $output; + $_SESSION['applicationManagement']= $applicationManagement; +} + +?> diff --git a/gosa-core/plugins/admin/applications/parameters.tpl b/gosa-core/plugins/admin/applications/parameters.tpl new file mode 100644 index 000000000..57c221971 --- /dev/null +++ b/gosa-core/plugins/admin/applications/parameters.tpl @@ -0,0 +1,2 @@ +{$table} +
diff --git a/gosa-core/plugins/admin/applications/release_select.tpl b/gosa-core/plugins/admin/applications/release_select.tpl new file mode 100755 index 000000000..d58738f05 --- /dev/null +++ b/gosa-core/plugins/admin/applications/release_select.tpl @@ -0,0 +1,16 @@ +
+
+

[F]{t}Branches{/t}

+
+
+ + + + +
+ {t}Current release{/t}  + +
+
diff --git a/gosa-core/plugins/admin/applications/remove.tpl b/gosa-core/plugins/admin/applications/remove.tpl new file mode 100644 index 000000000..8598ed857 --- /dev/null +++ b/gosa-core/plugins/admin/applications/remove.tpl @@ -0,0 +1,23 @@ +
+  {t}Warning{/t} +
+

+ {$intro} + {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-core/plugins/admin/applications/tabs_application.inc b/gosa-core/plugins/admin/applications/tabs_application.inc new file mode 100644 index 000000000..059e68335 --- /dev/null +++ b/gosa-core/plugins/admin/applications/tabs_application.inc @@ -0,0 +1,62 @@ +addSpecialTabs(); + } + + function set_release($newRelease) + { + $this->Release= preg_replace('/,ou=apps,.*$/', '', $newRelease); + if ($this->Release != ""){ + $this->Release= ",".$this->Release; + } + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['application']; + + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if((!empty($tmp)) && (isset($_SESSION['appfilter']['release']))){ + if(!$baseobject->isReleaseApplikation){ + $new_dn= "cn=".$baseobject->cn.",ou=apps,".$baseobject->base; + }else{ + $new_dn ="cn=".$baseobject->cn.",".$_SESSION['appfilter']['release']; + } + }else{ + $new_dn= "cn=".$baseobject->cn.",ou=apps,".$baseobject->base; + } + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['application']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + tabs::save(); + + /* Fix tagging if needed */ + $baseobject->dn= $this->dn; + $baseobject->handle_object_tagging(); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc new file mode 100644 index 000000000..668da2f7a --- /dev/null +++ b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc @@ -0,0 +1,610 @@ +is_account= TRUE; + $this->ui= get_userinfo(); + $this->dn= $dn; + $this->orig_dn= $dn; + $this->orig_ou= $this->ou; + $this->config= $config; + + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + if(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['CurrentMainBase']; + }else{ + $this->base= dn2base($ui->dn); + } + } else { + $this->base= preg_replace ("/^[^,]+,/", "", $this->dn); + } + + $this->orig_base = $this->base; + + /* Is administrational Unit? */ + if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){ + $this->is_administrational_unit= true; + $this->initially_was_tagged = true; + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","department/".get_class($this),$this->dn); + } + + /* Reload departments */ + $this->config->get_departments($this->dn); + $this->config->make_idepartments(); + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Hide all departments, that are subtrees of this department */ + $bases = $this->get_allowed_bases(); + if(($this->dn == "new")||($this->dn == "")){ + $tmp = $bases; + }else{ + $tmp = array(); + foreach($bases as $dn=>$base){ + $fixed = str_replace("/","\\",$this->dn); + /* Only attach departments which are not a subtree of this one */ + if(!preg_match("/".$fixed."/",$dn)){ + $tmp[$dn]=$base; + } + } + } + $smarty->assign("bases", $tmp); + + foreach ($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + $smarty->assign("base_select", $this->base); + + /* Set admin unit flag */ + $smarty->assign("UnitTagDiabled",$this->UnitTagDiabled); + if(!$this->UnitTagDiabled){ + if ($this->is_administrational_unit) { + $smarty->assign("unitTag", "checked"); + } else { + $smarty->assign("unitTag", ""); + } + } + + return($smarty->fetch (get_template_path('generic.tpl', TRUE))); + } + + function clear_fields() + { + $this->dn = ""; + $this->base = ""; + + foreach ($this->attributes as $val){ + $this->$val= ""; + } + } + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->recursive_remove(); + new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of department with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove'); + } + + function must_be_tagged() + { + return $this->must_be_tagged; + } + + function am_i_moved() + { + return $this->rec_cpy; + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['dep_generic_posted'])){ + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + /* Set new base if allowed */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + + /* Save tagging flag */ + if(!$this->UnitTagDiabled){ + if ($this->acl_is_writeable("unitTag")){ + if (isset($_POST['unitTag'])){ + $this->is_administrational_unit= true; + } else { + $this->is_administrational_unit= false; + } + } + } + } + } + + + /* Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Check for presence of this department */ + $ldap= $this->config->get_ldap_link(); + $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn')); + if ($this->orig_dn == "new" && $ldap->count()){ + $message[]= _("Department with that 'Name' already exists."); + } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){ + $message[]= _("Department with that 'Name' already exists."); + } + + /* All required fields are set? */ + if ($this->ou == ""){ + $message[]= _("Required field 'Name' is not set."); + } + if ($this->description == ""){ + $message[]= _("Required field 'Description' is not set."); + } + + if(is_department_name_reserved($this->ou,$this->base)){ + $message[]= sprintf(_("The field 'Name' contains the reserved word '%s'. Please choose another name."),$this->ou); + } + + if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){ + $message[]= _("The field 'Name' contains invalid characters."); + } + if (!is_phone_nr($this->telephoneNumber)){ + $message[]= _("The field 'Phone' contains an invalid phone number."); + } + if (!is_phone_nr($this->facsimileTelephoneNumber)){ + $message[]= _("The field 'Fax' contains an invalid phone number."); + } + + return $message; + } + + + /* Save to LDAP */ + function save() + { + $ldap= $this->config->get_ldap_link(); + + if(!$this->UnitTagDiabled){ + + /* Add tag objects if needed */ + if ($this->is_administrational_unit){ + + /* If this wasn't tagged before add oc an reset unit tag */ + if(!$this->initially_was_tagged){ + $this->objectclasses[]= "gosaAdministrativeUnit"; + $this->gosaUnitTag= ""; + + /* It seams that this method is called twice, + set this to true. to avoid adding this oc twice */ + $this->initially_was_tagged = true; + } + + if ($this->gosaUnitTag == ""){ + + /* It's unlikely, but check if already used... */ + $try= 5; + $ldap->cd($this->config->current['BASE']); + while ($try--){ + + /* Generate microtime stamp as tag */ + list($usec, $sec)= explode(" ", microtime()); + $time_stamp= preg_replace("/\./", "", $sec.$usec); + + $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag")); + if ($ldap->count() == 0){ + break; + } + } + if($try == 0) { + print_red(_("Fatal error: Can't find an unused tag to mark the administrative unit!")); + return; + } + $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec); + } + } + } + plugin::save(); + + if(!$this->UnitTagDiabled){ + + /* Remove tag information if needed */ + if (!$this->is_administrational_unit){ + $tmp= array(); + + /* Remove gosaAdministrativeUnit from this plugin */ + $has_unit_tag= false; + foreach($this->attrs['objectClass'] as $oc){ + if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){ + $tmp[]= $oc; + } + if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){ + $has_unit_tag= true; + } + } + $this->attrs['objectClass']= $tmp; + + if(!$has_unit_tag && isset($this->attrs['gosaUnitTag'])){ + $this->attrs['gosaUnitTag']= array(); + } + $this->gosaUnitTag = ""; + } + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('dn')); + $a= $ldap->fetch(); + $ldap->cd($this->dn); + + if (count($a)){ + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events('modify'); + } else { + $ldap->add($this->attrs); + $this->handle_post_events('add'); + new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of department with dn '%s' failed."),$this->dn)); + + + if(!$this->UnitTagDiabled){ + /* The parameter forces only to set must_be_tagged, and don't touch any objects + This will be done later */ + $this->tag_objects(true); + + /* Fix tagging if needed */ + if (!$this->is_administrational_unit){ + $this->handle_object_tagging(); + } + } + + /* Optionally execute a command after we're done */ + $this->postcreate(); + return(false); + } + + + function ShowMoveFrame() + { + $smarty = get_smarty(); + $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove"); + $smarty->assign("message","As soon as the move operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog."); + $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)); + return($display); + } + + function ShowTagFrame() + { + $smarty = get_smarty(); + $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment"); + $smarty->assign("message","As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog."); + $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)); + return($display); + } + + /* Tag objects to have the gosaAdministrativeUnitTag */ + function tag_objects($OnlySetTagFlag = false) + { + if(!$OnlySetTagFlag){ + $smarty= get_smarty(); + /* Print out html introduction */ + echo ' + + + + + + + + '; + echo "

".sprintf(_("Tagging '%s'."),"".@LDAP::fix($this->dn)."")."

"; + } + + $add= $this->is_administrational_unit; + $len= strlen($this->dn); + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + if ($add){ + $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='. + $this->gosaUnitTag.')))', array('dn')); + } else { + $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn')); + } + + while ($attrs= $ldap->fetch()){ + + /* Skip self */ + if ($attrs['dn'] == $this->dn){ + continue; + } + + /* Check for confilicting administrative units */ + $fix= true; + foreach ($this->config->adepartments as $key => $tag){ + /* This one is shorter than our dn, its not relevant... */ + if ($len >= strlen($key)){ + continue; + } + + /* This one matches with the latter part. Break and don't fix this entry */ + if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){ + $fix= false; + break; + } + } + + /* Fix entry if needed */ + if ($fix){ + if($OnlySetTagFlag){ + $this->must_be_tagged =true; + return; + } + $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE ); + } + } + if(!$OnlySetTagFlag){ + echo '

 

'; + echo "
+
+
"; + } + } + + + /* Move/Rename complete trees */ + function recursive_move($src_dn, $dst_dn,$force = false) + { + /* If force == false prepare to recursive move this object from src to dst + on the next call. */ + if(!$force){ + $this->rec_cpy = true; + $this->rec_src = $src_dn; + $this->rec_dst = $dst_dn; + }else{ + + /* If this is called, but not wanted, abort */ + if(!$this->rec_cpy){ + return; + } + + $src_dn = $this->rec_src; + $dst_dn = $this->rec_dst; + + /* Print header to have styles included */ + $smarty= get_smarty(); + + echo ' + + + + + + + + '; + echo "

".sprintf(_("Moving '%s' to '%s'"),"".@LDAP::fix($src_dn)."","".@LDAP::fix($dst_dn)."")."

"; + + + /* Check if the destination entry exists */ + $ldap= $this->config->get_ldap_link(); + + /* Check if destination exists - abort */ + $ldap->cat($dst_dn, array('dn')); + if ($ldap->fetch()){ + trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.", + E_USER_WARNING); + echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."
"; + return (FALSE); + } + + /* Perform a search for all objects to be moved */ + $objects= array(); + $ldap->cd($src_dn); + $ldap->search("(objectClass=*)", array("dn")); + while($attrs= $ldap->fetch()){ + $dn= $attrs['dn']; + $objects[$dn]= strlen($dn); + } + + /* Sort objects by indent level */ + asort($objects); + reset($objects); + + /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */ + foreach ($objects as $object => $len){ + + + $src= str_replace("\\","\\\\",$object); + $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object); + $dst= str_replace($src_dn,$dst_dn,$object); + + echo ""._("Object").": ".@LDAP::fix($src)."
"; + + $this->update_acls($object, $dst,TRUE); + + if (!$this->copy($src, $dst)){ + echo "
".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."
"; + return (FALSE); + } + echo "" ; + flush(); + } + + /* Remove src_dn */ + $ldap->cd($src_dn); + $ldap->recursive_remove(); + $this->dn = $this->rec_dst; + $this->rec_src = $this->rec_dst = ""; + $this->rec_cpy =false; + + echo '

 

'; + + echo "
+
+
"; + + echo "" ; + echo ""; + + return (TRUE); + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array("plShortName" => _("Generic"), + "plDescription" => _("Departments"), + "plSelfModify" => FALSE, + "plPriority" => 0, + "plDepends" => array(), + "plSection" => array("admin"), + "plCategory" => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))), + + "plProvidedAcls" => array( + "description" => _("Description"), + "c" => _("Country"), + "base" => _("Base"), + "l" => _("Location"), + "telephoneNumber" => _("Telephone"), + "ou" => _("Department name"), + "businessCategory" => _("Category"), + "st" => _("State"), + "postalAddress" => _("Address"), + "gosaUnitTag" => _("Administrative settings"), + "facsimileTelephoneNumber" => _("Fax")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/departments/class_departmentManagement.inc b/gosa-core/plugins/admin/departments/class_departmentManagement.inc new file mode 100644 index 000000000..e2db188d1 --- /dev/null +++ b/gosa-core/plugins/admin/departments/class_departmentManagement.inc @@ -0,0 +1,535 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Headpage attributes */ + var $last_dep_sorting= "invalid"; + var $departments= array(); + var $deptabs= NULL; + + /* attribute list for save action */ + var $attributes= array(); + var $objectclasses= array(); + + /* Vars to handle operations after saving the department + Recursive move && tagging */ + var $ObjectInSaveMode = false; // Is true, if current object wasn't saved right now + var $ObjectTaggingRequested = false; // Object must be tagged, an iframe will be shown. + var $RecursiveRemoveRequested = false; // Is true, if this object must be moved, an iframe will be displayed in this case + + function departmentManagement (&$config, &$ui) + { + $this->ui= &$ui; + $this->dn= ""; + $this->config= &$config; + $this->DivListDepartment = new divListDepartment($this->config,$this); + } + + function execute() + { + global $config; + + /* Call parent execute */ + plugin::execute(); + + /*************** + Var init + ***************/ + + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^dep_edit_.*/","/^dep_del_.*/","/^item_selected/","/^remove_multiple_departments/"); + + /* Reload departments */ + $smarty = get_smarty(); + $display = ""; + $s_action = ""; // Will contain an action, like del or edit + $s_entry = ""; // The entry name for edit delete -... + + + /*************** + Check posts + ***************/ + + // Check Post action + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/dep_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/dep_".$s_action."_/i","",$key); + $s_entry = preg_replace("/_.*$/","",$s_entry); + $s_entry = base64_decode($s_entry); + // Post for edit + }elseif(preg_match("/dep_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/dep_".$s_action."_/i","",$key); + $s_entry = preg_replace("/_.*$/","",$s_entry); + $s_entry = base64_decode($s_entry); + // Post for new + }elseif(preg_match("/^remove_multiple_departments/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/dep_new.*/",$key)){ + $s_action="new"; + } + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "dep_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + + /*************** + Create a new department + ***************/ + + /* New Entry if Posted action (s_action) == new + */ + if ($s_action=="new"){ + $this->dn= "new"; + $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $this->dn,"department"); + $this->deptabs->set_acl_base($this->DivListDepartment->selectedBase); + } + + + /*************** + Edit entry + ***************/ + + /* Edit Entry if Posted action (s_action) == edit + * The entry which will be edited is defined in $s_entry + */ + if (( $s_action=="edit") && (!isset($this->deptabs->config))){ + $this->dn= $this->config->departments[trim($s_entry)]; + + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so everyone will get the above dialog */ + add_lock ($this->dn, $this->ui->dn); + + /* Register deptabs to trigger edit dialog */ + $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $this->dn,"department"); + $this->deptabs->set_acl_base($this->dn); + + $_SESSION['objectinfo']= $this->dn; + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + + if(count($ids)){ + foreach($ids as $id){ + $id = base64_decode($id); + $dn = $this->config->departments[$id]; + + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $smarty->assign("info", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); + } else { + $smarty->assign("info", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); + } + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_department_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + $acl = $this->ui->get_permissions($dn,"department/department"); + if (preg_match('/d/', $acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $dn,"department"); + $this->deptabs->set_acl_base(); + $this->deptabs->delete (); + $this->deptabs = NULL; + } else { + print_red (_("You have no permission to remove this department.")); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_department_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /*************** + Delete entry + ***************/ + + /* Delete Entry if Posted action (s_action) == del + * The entry which will be deleted is defined in $s_entry + */ + if ($s_action =="del"){ + $this->dn= $this->config->departments[trim($s_entry)]; + + /* check acls */ + $acl = $this->ui->get_permissions($this->dn,"department/department"); + if(preg_match("/d/",$acl)){ + + /* Check locking */ + if (($user= get_lock($this->dn)) != ""){ + $_SESSION['dn']= $this->dn; + return(gen_locked_message($user, $this->dn)); + } else { + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); + $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE)); + return ($display); + } + }else{ + print_red (_("You have no permission to remove this department.")); + } + } + + + /*************** + Delete department confirmed + ***************/ + + /* If department deletion is accepted ... + * Finally delete department + */ + if (isset($_POST['delete_department_confirm'])){ + + /* check acls */ + $acl = $this->ui->get_permissions($this->dn,"department/department"); + if(preg_match("/d/",$acl)){ + $this->remove_from_parent(); + } else { + print_red (_("You have no permission to remove this department.")); + } + } + + + /*************** + Edit department finished + ***************/ + + if ((isset($_POST['edit_finish'])) && (isset($this->deptabs->config)) && !isset($_POST['dep_move_confirm'])){ + $this->deptabs->save_object(); + $obj = $this->deptabs->by_object['department']; + if($obj->orig_dn != "new"){ + if($obj->orig_ou != $obj->ou || $obj->base != $obj->orig_base){ + return($smarty->fetch(get_template_path("dep_move_confirm.tpl",TRUE))); + } + } + } + + /* Save changes */ + if ((isset($_POST['edit_finish'])|| isset($_POST['dep_move_confirm'])) && (isset($this->deptabs->config))){ + + /* Check tabs, will feed message array */ + $message= $this->deptabs->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + $this->deptabs->save(true); + global $config; + $config->get_departments(); + $config->make_idepartments(); + $this->config = $config; + + /* This object must be tagged, so set ObjectTaggingRequested to true */ + if($this->deptabs->by_object['department']->must_be_tagged()){ + $this->ObjectTaggingRequested = true; + } + + /* Get recursive move is required, set RecursiveRemoveRequested to true */ + if($this->deptabs->by_object['department']->am_i_moved()){ + $this->RecursiveRemoveRequested = true; + } + + /* This var indicated that there is an object which isn't saved right now. */ + $this->ObjectInSaveMode = true; + + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /*************** + Handle Tagging (Return output for an iframe) + ***************/ + + /* This department must be tagged (Is called from iframe, generates output)*/ + if(isset($_GET['TagDepartment'])){ + $this->deptabs->by_object['department']->tag_objects(); + exit(); + } + + + /*************** + Handle recursive move (Return output for an iframe) + ***************/ + + /* initiate recursive remove (Is called from iframe, generates output)*/ + if(isset($_GET['PerformRecMove'])){ + $this->deptabs->by_object['department']->recursive_move("","",true); + $this->DivListDepartment->selectedBase = $this->deptabs->by_object['department']->dn; + exit(); + } + + + /*************** + Return iframes, which call tagging / recusrsive move + ***************/ + + /* While one of these vars below isset, we must return an iframe, + to perform requested operation */ + if($this->ObjectTaggingRequested){ + $this->ObjectTaggingRequested = false; + return($this->deptabs->by_object['department']->ShowTagFrame()); + } + if($this->RecursiveRemoveRequested){ + $this->RecursiveRemoveRequested = false; + return($this->deptabs->by_object['department']->ShowMoveFrame()); + } + + + /*************** + In case of tagging/moving the object wasn't deleted, do it know + ***************/ + + /* If there is an unsaved object and all operations are done + remove locks & save object tab & unset current object */ + if($this->ObjectInSaveMode && (!$this->RecursiveRemoveRequested) && (!$this->ObjectTaggingRequested)){ + $this->deptabs->save(); + $this->config->get_departments(); + $this->ObjectInSaveMode = false; + if ($this->dn != "new"){ + del_lock ($this->dn); + } + unset ($this->deptabs); + $this->deptabs= NULL; + unset ($_SESSION['objectinfo']); + } + + + /*************** + Dialog canceled + ***************/ + + /* User canceled edit oder delete + * Cancel dialog + */ + if (isset($_POST['edit_cancel']) || isset($_POST['delete_cancel']) || isset($_POST['delete_department_confirm'])){ + del_lock ($this->dn); + unset($this->depdabs); + $this->deptabs= NULL; + unset ($_SESSION['objectinfo']); + } + + /* Headpage or normal plugin screen? */ + if ($this->deptabs !== NULL){ + + /* Show main page (tabs) */ + $display= $this->deptabs->execute(); + if (!$this->deptabs->by_object[$this->deptabs->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + $display.= "\n"; + $display.= "

"; + } + return ($display); + }else{ + /* Display dialog with group list */ + $this->DivListDepartment->parent = $this; + $this->DivListDepartment->execute(); + $this->reload(); + $this->DivListDepartment->DepartmentsAdded = true; + $this->DivListDepartment->setEntries($this->departments); + return($this->DivListDepartment->Draw()); + } + } + + + function reload() + { + /* Vairaible init */ + $base = $this->DivListDepartment->selectedBase; + $base_back = preg_replace("/^[^,]+,/","",$base); + $Regex = $this->DivListDepartment->Regex; + + // Create Array to Test if we have a valid back button + $tmp = $_SESSION['config']->idepartments; + + // In case of a valid back button create entry + if(isset($tmp[$base_back])){ + $tmp2 ['dn'] = convert_department_dn($base_back); + + // If empty always go to top + if(empty($tmp2['dn'])){ + $tmp2['dn']="/"; + } + $tmp2 ['description'][0] = ".. "._("Back"); + $result[$tmp[$base_back]]=$tmp2; + } + + if($this->DivListDepartment->SubSearch){ + $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))", + "department", $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH); + }else{ + $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))", + "department", $base, array("ou", "description"), GL_SIZELIMIT ); + } + + $this->departments= array(); + + /* Add current base to the list of available departments, but only if its naming attribute is 'ou' */ + if(preg_match("/^ou=/",$base)){ + $this->departments [ convert_department_dn($base) ] = "."; + } + + foreach ($res as $key => $value){ + + /* Don't display base as entry on subsearch */ + if(($value['dn'] == $base) && ($this->DivListDepartment->SubSearch)){ + continue; + } + + $cdn= convert_department_dn($value['dn']); + + /* Append to dep list */ + if(isset($value["description"][0])){ + $this->departments[$cdn]= get_sub_department($cdn)." - [".$value["description"][0]."]"; + }else{ + $this->departments[$cdn]= get_sub_department($cdn);//$value["description"][0]; + } + } + natcasesort ($this->departments); + reset ($this->departments); + } + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->recursive_remove(); + + /* Optionally execute a command after we're done */ + $this->postremove(); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[a-z0-9\\/\=]*$/i",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + function remove_lock() + { + if (isset($this->dn)){ + del_lock ($this->dn); + } + } + + function save_object() + { + /* reload department */ + $this->config->get_departments(); + + $this->config->make_idepartments(); + $this->DivListDepartment->config= $this->config; + $this->DivListDepartment->save_object(); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/departments/class_divListDepartment.inc b/gosa-core/plugins/admin/departments/class_divListDepartment.inc new file mode 100755 index 000000000..b1f642dbf --- /dev/null +++ b/gosa-core/plugins/admin/departments/class_divListDepartment.inc @@ -0,0 +1,228 @@ +parent = &$parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of departments")); + $this->SetSummary(_("List of departments")); + $this->EnableAplhabet (true); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to create, delete and edit selected departments. Having a large number of departments, you might prefer the range selectors on top of the department list.")); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string"=>_("Department name"), "attach" => "style=''")); + $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")); + + + /* Add SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching department names"), "*" , true); + } + + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("department"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Generate list head */ + $ui = get_userinfo(); + $acl = $ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/department"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + $listhead .= + " "._("Base")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Department")."|dep_new|\n"; + } + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + $linkopen = "%s"; + + $ui = get_userinfo(); + foreach($list as $key => $val) { + + $actions= ""; + + $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department"); + if(preg_match("/r/",$acl)){ + $actions.= ""; + } + + if(preg_match("/c/",$acl)){ + $actions.= ""; + } + + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + + /* check if this department contains sub-departments + Display different image in this case + */ + $non_empty=""; + $nkey= normalizePreg($key); + foreach($this->config->departments as $keyd=>$vald ){ + if(preg_match('/$nkey\/.*/',$keyd)){ + $non_empty="full"; + } + } + + $title = preg_replace('/ /', ' ', @LDAP::fix($this->config->departments[$key])); + + if($val == "."){ + $field01 = array("string" => " ", + "attach" => "style='width:20px;'"); + }else{ + $field01 = array("string" => "" , + "attach" => "style='width:20px;'"); + } + + $field0 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); + $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'"); + $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align: + right;'"); + + $this->AddElement( array($field01,$field0,$field1,$field2)); + } + + /* Create summary string for list footer */ + $num_deps=count($list); + $num_dep_str = _("Number of listed departments"); + $str = "".$num_dep_str." ".$num_deps."    "; + $this->set_List_Bottom_Info($str); + + } + function Save() + { + MultiSelectWindow::Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/departments/dep_iframe.tpl b/gosa-core/plugins/admin/departments/dep_iframe.tpl new file mode 100644 index 000000000..396cf2cf0 --- /dev/null +++ b/gosa-core/plugins/admin/departments/dep_iframe.tpl @@ -0,0 +1,21 @@ +

{t}Processing the requested operation{/t}

+{$message} +
+
+
+ +
+ + diff --git a/gosa-core/plugins/admin/departments/dep_move_confirm.tpl b/gosa-core/plugins/admin/departments/dep_move_confirm.tpl new file mode 100644 index 000000000..9338b7611 --- /dev/null +++ b/gosa-core/plugins/admin/departments/dep_move_confirm.tpl @@ -0,0 +1,19 @@ +
+  {t}Warning{/t} - {t}You are currently moving/renaming this department.{/t} +
+

+{t}Modifying a departments naming attribute 'ou' or base may corrupt acls and snapshot entries for all entire objects.{/t} +

+

+{t}GOsa can NOT fix this for you, yet.{/t} +

+

+{t}Before you confirm this action, ensure that everything will be as expected, possibly the best solution is a backup.{/t} +

+ +

+ +   + +

+ diff --git a/gosa-core/plugins/admin/departments/generic.tpl b/gosa-core/plugins/admin/departments/generic.tpl new file mode 100644 index 000000000..7e353be8c --- /dev/null +++ b/gosa-core/plugins/admin/departments/generic.tpl @@ -0,0 +1,132 @@ + + + + + + +
+

{t}Properties{/t}

+ + + + + + + + + + + + + + + + + + + + + + +
{$must} +{render acl=$ouACL} + +{/render} +
{$must} +{render acl=$descriptionACL} + +{/render} +
+{render acl=$businessCategoryACL} + +{/render} +

{$must} +{render acl=$baseACL} + +{/render} + +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+ +
+   + +

{t}Location{/t}

+ + + + + + + + + + + + + + + + + + + + + +
+{render acl=$stACL} + +{/render} +
+{render acl=$lACL} + +{/render} +
+{render acl=$postalAddressACL} + +{/render} +
+{render acl=$telephoneNumberACL} + +{/render} +
+{render acl=$facsimileTelephoneNumberACL} + +{/render} +
+ +
+ + +{if !$UnitTagDiabled} + + + +

 

+ + + + + +
+

{t}Administrative settings{/t}

+{render acl=$gosaUnitTagACL} + +{/render} +
+ +{/if} + + + diff --git a/gosa-core/plugins/admin/departments/main.inc b/gosa-core/plugins/admin/departments/main.inc new file mode 100644 index 000000000..5db627873 --- /dev/null +++ b/gosa-core/plugins/admin/departments/main.inc @@ -0,0 +1,57 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('department'); + } +} else { + /* Create usermanagement object on demand */ + if (!isset($_SESSION['department']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['department']= new departmentManagement($config, $ui); + } + $department= $_SESSION['department']; + + /* Show and save dialog */ + $department->save_object(); + $output= $department->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/department.png'), _("Department management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/department.png'), _("Department management")); + } + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('department'); + } + + $display.= $output; + $_SESSION['department']= $department; + $config = $department->config; +} + +?> diff --git a/gosa-core/plugins/admin/departments/remove.tpl b/gosa-core/plugins/admin/departments/remove.tpl new file mode 100644 index 000000000..e4e075aa3 --- /dev/null +++ b/gosa-core/plugins/admin/departments/remove.tpl @@ -0,0 +1,24 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}This includes 'all' accounts, systems, etc. in this subtree. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-core/plugins/admin/departments/tabs_department.inc b/gosa-core/plugins/admin/departments/tabs_department.inc new file mode 100644 index 000000000..cf04bd29b --- /dev/null +++ b/gosa-core/plugins/admin/departments/tabs_department.inc @@ -0,0 +1,52 @@ +base= $this->by_object['department']->base; + + /* Add references/acls/snapshots */ + $this->addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['department']; + $ou= preg_replace('/,/', '\,', $baseobject->ou); + $new_dn= @LDAP::convert('ou='.$ou.','.$baseobject->base); + + if($ignore_account){ + if ($this->dn != $new_dn && $this->dn != "new"){ + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ + /* Prepare to be moved */ + $baseobject->recursive_move($this->dn, $new_dn); + $this->by_object['department'] = $baseobject; + return; + } + } + } + $this->dn= $new_dn; + $baseobject->dn= $this->dn; + $this->by_object['department']= $baseobject; + return(tabs::save(TRUE)); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/devices/class_deviceGeneric.inc b/gosa-core/plugins/admin/devices/class_deviceGeneric.inc new file mode 100644 index 000000000..095adf7f3 --- /dev/null +++ b/gosa-core/plugins/admin/devices/class_deviceGeneric.inc @@ -0,0 +1,241 @@ +is_account = TRUE; + + /* Set class values */ + if(isset($this->attrs['gotoHotplugDevice'][0])){ + $tmp = preg_split("/\|/",$this->attrs['gotoHotplugDevice'][0]); + $this->cn = $this->attrs['cn'][0]; + $this->description= $tmp[0]; + $this->dev_id = $tmp[1]; + $this->serial = $tmp[2]; + $this->vendor = $tmp[3]; + } + + $this->orig_cn = $this->cn; + + /* Set Base */ + if ($this->dn == "new"){ + if(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['CurrentMainBase']; + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->base =preg_replace ("/^[^,]+,ou=devices,/","",$this->dn); + } + } + + + public function execute() + { + $smarty = get_smarty(); + $smarty->assign("base",$this->base); + $smarty->assign("bases",$this->get_allowed_bases()); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + foreach($this->posts as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("deviceGeneric.tpl",TRUE,dirname(__FILE__)))); + } + + + public function check() + { + $message = plugin::check(); + + if(empty($this->cn)||(preg_match("/[^a-z0-9]/i",$this->cn))){ + $message[]=_("Please specify a valid name. Only 0-9 a-Z is allowed."); + } + if(preg_match("/[^a-z0-9!\"?.,;:-_\(\) ]/i",$this->description)){ + $message[]=_("Invalid character in description. Please specify a valid description."); + } + + /* Skip serial check if vendor and product id are given */ + if(preg_match("/^\s+$/i",$this->dev_id)){ + $message[]=_("Please specify a valid iSerial."); + } + if(empty($this->serial) || !$this->is_2byteHex($this->serial)){ + $message[]=_("Please specify a valid vendor ID. (2 byte hex like '0xFFFF')"); + } + if(empty($this->vendor) || !$this->is_2byteHex($this->vendor)){ + $message[]=_("Please specify a valid product ID. (2 byte hex like '0xFFFF')"); + } + + /* Check if entry already exists */ + if($this->cn != $this->orig_cn){ + $ldap = $this->config->get_ldap_link(); + $ldap->search("(&(objectClass=gotoDevice)(cn=".$this->cn."*))",array("cn")); + if($ldap->count()){ + $message[]=_("An Entry with this name already exists."); + } + } + + return($message); + } + + + public function save_object() + { + if(isset($_POST['deviceGeneric_posted'])){ + plugin::save_object(); + + if(isset($_POST['base'])){ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[get_post("base")])){ + $this->base = get_post("base"); + } + } + + foreach($this->posts as $post){ + if(isset($_POST[$post])){ + $this->$post = get_post($post); + } + } + } + } + + + public function remove_from_parent() + { + plugin::remove_from_parent(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDeviceDN=".$this->dn."))",array("cn","gotoHotplugDeviceDN")); + $skip = FALSE; + $str =""; + $cnt = 3; + while($cnt && $attrs = $ldap->fetch()){ + $skip =TRUE; + $str .= $attrs['cn'][0].", "; + $cnt --; + } + if($skip){ + $str = preg_replace("/, $/","",$str); + if($cnt == 0){ + $str .= "..."; + } + print_red(sprintf(_("Can't remove the device '%s' it is still in use be this user(s) : %s"),$this->cn,$str)); + }else{ + $ldap->rmdir_recursive($this->dn); + } + } + + + public function save() + { + plugin::save(); + + $this->attrs['gotoHotplugDevice'] = ""; + foreach($this->posts as $post){ + $this->attrs['gotoHotplugDevice'] .= $this->$post."|"; + } + $this->attrs['gotoHotplugDevice'] = preg_replace("/\|$/","",$this->attrs['gotoHotplugDevice']); + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error(),_("Device could not be saved.")); + } + + + /* check if given str in like this 0xffff*/ + function is_2byteHex($str) + { + return !strlen($str) || preg_match("/^(0x|x|)[a-f0-9][a-f0-9][a-f0-9][a-f0-9]/i",$str); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + $source_o = new deviceGeneric($this->config,$source['dn']); + foreach($this->CopyPasteVars as $post){ + $this->$post = $source_o->$post; + } + } + + + /* Return a dialog with all fields that must be changed, + if we want to copy this entry */ + function getCopyDialog() + { + $str = ""; + $smarty = get_smarty(); + $smarty->assign("cn", $this->cn); + $str = $smarty->fetch(get_template_path("paste_deviceGeneric.tpl",TRUE,dirname(__FILE__))); + + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + /* Save all */ + function saveCopyDialog() + { + $attrs = array("cn"); + foreach($attrs as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + + + /* Return plugin informations for acl handling */ + public static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Device generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("devices" => array("description" => _("Devices"), + "objectClass" => "gotoHotplugDevice")), + "plProvidedAcls"=> array( + "cn" => _("Name")) + )); + + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/devices/class_deviceManagement.inc b/gosa-core/plugins/admin/devices/class_deviceManagement.inc new file mode 100644 index 000000000..dbdfc0fb4 --- /dev/null +++ b/gosa-core/plugins/admin/devices/class_deviceManagement.inc @@ -0,0 +1,554 @@ +ui = get_userinfo(); + + /* Check if copy & paste is activated */ + if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + + /* Creat dialog object */ + $this->DivListDevices = new divListDevices($this->config,$this); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /**************** + Variable init + ****************/ + + /* These vars will be stored if you try to open a locked device, + to be able to perform your last requests after showing a warning message */ + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^device_edit_/", + "/^device_del_/","/^item_selected/","/^remove_multiple_devices/"); + + $smarty = get_smarty(); // Smarty instance + $s_action = ""; // Contains the action to proceed + $s_entry = ""; // The value for s_action + $base_back = ""; // The Link for Backbutton + + /* Test Posts */ + foreach($_POST as $key => $val){ + + if(preg_match("/device_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/device_".$s_action."_/i","",$key); + }elseif(preg_match("/device_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/device_".$s_action."_/i","",$key); + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + }elseif(preg_match("/^device_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/^remove_multiple_devices/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^multiple_copy_devices/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_devices/",$key)){ + $s_action = "cut_multiple"; + } + } + + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + + $s_entry = preg_replace("/_.$/","",$s_entry); + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "device_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + /**************** + Copy & Paste handling + ****************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + /**************** + Create a new device type + ****************/ + + /* New device type? */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->DivListDevices->selectedBase,"devices/deviceGeneric"); + if (($s_action=="new") && preg_match("/c/",$acl)){ + + /* By default we set 'dn' to 'new', all relevant plugins will + react on this. */ + $this->dn= "new"; + + /* Create new usertab object */ + $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $this->dn,"devices"); + $this->devicetabs->set_acl_base($this->DivListDevices->selectedBase); + } + + + /**************** + Edit entry canceled + ****************/ + + /* Cancel dialogs */ + if (isset($_POST['edit_cancel']) && is_object($this->devicetabs)){ + del_lock ($this->devicetabs->dn); + unset ($this->devicetabs); + $this->devicetabs= NULL; + unset ($_SESSION['objectinfo']); + } + + + /**************** + Edit entry finished + ****************/ + + /* Finish device edit is triggered by the tabulator dialog, so + the user wants to save edited data. Check and save at this point. */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->devicetabs->config))){ + + /* Check tabs, will feed message array */ + $this->devicetabs->save_object(); + $message= $this->devicetabs->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + /* Save data data to ldap */ +# $this->devicetabs->set_release($this->DivListDevices->selectedRelease); + $this->devicetabs->save(); + + if (!isset($_POST['edit_apply'])){ + /* device type has been saved successfully, remove lock from LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + unset ($this->devicetabs); + $this->devicetabs= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /**************** + Edit entry + ****************/ + + /* User wants to edit data? */ + if (($s_action=="edit") && (!isset($this->devicetabs->config))){ + + /* Get 'dn' from posted 'devicelist', must be unique */ + $this->dn= $this->devices[$s_entry]['dn']; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so everyone will get the + above dialog */ + add_lock ($this->dn, $this->ui->dn); + + + /* Register devicetabs to trigger edit dialog */ + $this->devicetabs= new devicetabs($this->config,$this->config->data['TABS']['DEVICETABS'], $this->dn,"devices"); + $this->devicetabs->set_acl_base($this->dn); + $_SESSION['objectinfo']= $this->dn; + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->devices[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $smarty->assign("intro", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); + } else { + $smarty->assign("intro", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); + } + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_device_confirm'])){ + + $ui = get_userinfo(); + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $acl = $ui->get_permissions($dn,"devices/deviceGeneric"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $dn,"devices"); + $this->devicetabs->set_acl_base($dn); + $this->devicetabs->delete (); + unset ($this->devicetabs); + $this->devicetabs= NULL; + + } else { + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this device type!")); + new log("security","devices/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_device_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /**************** + Delete device type + ****************/ + + /* Remove user was requested */ + if ($s_action == "del"){ + + /* Get 'dn' from posted 'uid' */ + $this->dn= $this->devices[$s_entry]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->dn,"devices/deviceGeneric"); + if (preg_match("/d/",$acl)){ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return (gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty= get_smarty(); + $smarty->assign("intro", sprintf(_("You're about to delete the device '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); + return($smarty->fetch (get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the user isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this device!")); + } + } + + + /**************** + Delete device confirmed + ****************/ + + /* Confirmation for deletion has been passed. Group should be deleted. */ + if (isset($_POST['delete_device_confirm'])){ + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->dn,"devices/deviceGeneric"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $this->dn,"devices"); + $this->devicetabs->set_acl_base($this->dn); + $this->devicetabs->delete (); + unset ($this->devicetabs); + $this->devicetabs= NULL; + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this device!")); + new log("security","devices/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + /**************** + Delete device canceled + ****************/ + + /* Delete device canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + /* Show tab dialog if object is present */ + if (($this->devicetabs) && (isset($this->devicetabs->config))){ + $display= $this->devicetabs->execute(); + + /* Don't show buttons if tab dialog requests this */ + if (!$this->devicetabs->by_object[$this->devicetabs->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + return ($display); + } + + + /**************** + Dialog display + ****************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListDevices->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Display dialog with system list */ + $this->DivListDevices->parent = $this; + $this->DivListDevices->execute(); + $this->DivListDevices->AddDepartments($this->DivListDevices->selectedBase,3,1); + $this->reload(); + $this->DivListDevices->setEntries($this->devices); + return($this->DivListDevices->Draw()); + + } + + function save_object() { + $this->DivListDevices->save_object(); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array("ou=devices,".$this->DivListDevices->selectedBase)); + } + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->devices[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"devicetabs","DEVICETABS","devices"); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->devices[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","devicetabs","DEVICETABS","devices"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","devicetabs","DEVICETABS","devices"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListDevices->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + + function reload() + { + /* Set base for all searches */ + $base = $this->DivListDevices->selectedBase; + $Regex = $this->DivListDevices->Regex; + $SubSearch = $this->DivListDevices->SubSearch; + $Flags = GL_NONE | GL_SIZELIMIT; + $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=gotoDevice))"; + $tmp = array(); + + /* In case of subsearch, add the subsearch flag */ + if($SubSearch){ + $Flags |= GL_SUBSEARCH; + }else{ + $base ="ou=devices,".$base; + } + + /* Get results and create index */ + $res= get_list($Filter, "devices", $base, array("cn","description","dn","objectClass"), $Flags); + foreach ($res as $val){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; + } + + /* sort entries */ + ksort($tmp); + $this->devices=array(); + foreach($tmp as $val){ + $this->devices[]=$val; + } + reset ($this->devices); + } + + function remove_lock() + { + if (isset($this->devicetabs->dn)){ + del_lock ($this->devicetabs->dn); + } + } + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + function remove_from_parent() + { + /* This cannot be removed... */ + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/devices/class_divListDevices.inc b/gosa-core/plugins/admin/devices/class_divListDevices.inc new file mode 100755 index 000000000..fb09fe8c8 --- /dev/null +++ b/gosa-core/plugins/admin/devices/class_divListDevices.inc @@ -0,0 +1,303 @@ +parent = &$parent; + $this->ui = get_userinfo(); + + /* set Page header */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /* Set list strings */ + $this->SetTitle (_("List of defined devices")); + $this->SetSummary (_("List of defined devices")); + $this->SetInformation (_("This menu allows you to add, edit and remove selected devices. You may want to use the range selector on top of the device listbox, when working with a large number of devices.")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->EnableAplhabet(true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Device name")." / "._("Department"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); + + /* Add SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Display devices matching"),"*" , true); + } + + + /* Create list header, with create / copy & paste etc*/ + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments($this->module); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get acls */ + $ui = get_userinfo(); + $acl = $ui->get_permissions("cn=dummy,ou=devices,".$this->selectedBase,"devices/deviceGeneric"); + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"devices") ; + + + /* If this is true we add an additional seperator. Just look a few lines below */ + $listhead = MultiSelectWindow::get_default_header(); + + /* And at least add a department selection box */ + $listhead .= _("Base")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Device")."|device_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + + $this->SetListHeader($listhead); + } + + + /* Some basic settings */ + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + + function setEntries($list) + { + /******************** + Variable init + ********************/ + + /* Create links */ + $linkopen = "%s"; + $editlink = "%s"; + $userimg = "User"; + $deviceimg = "A"; + $empty = ""; + + /* set Page header */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /******************** + Attach objects + ********************/ + + foreach($list as $key => $val){ + + $ui = get_userinfo(); + $acl = $ui->get_permissions($val['dn'],"devices/deviceGeneric"); + $acl_all = $ui->has_complete_category_acls($val['dn'],"devices") ; + + /* Create action icons */ + $actions = ""; + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions .= $this->GetSnapShotActions($val['dn']); + } + + /* Get copy Paste icons */ + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions.= " "; + $actions.= " "; + } + + $actions.= ""; + + /* Add delete button */ + if(preg_match("/d/",$acl)){ + $actions.= ""; + }else{ + $actions.= " "; + } + + $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; + + if(!isset($val['description'][0])){ + $desc = ""; + }else{ + $desc = " - [ ".$val['description'][0]." ]"; + } + + /* Cutted objects should be displayed in light grey */ + $display = $val['cn'][0].$desc; + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => sprintf($deviceimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); + $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + $this->AddElement(array($field0,$field1,$field2,$field3)); + } + + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_objs = count($list); + + $num_obj_str = _("Number of listed devices"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + } + + function Save() + { + MultiSelectWindow::Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/devices/deviceGeneric.tpl b/gosa-core/plugins/admin/devices/deviceGeneric.tpl new file mode 100644 index 000000000..59f7b9c18 --- /dev/null +++ b/gosa-core/plugins/admin/devices/deviceGeneric.tpl @@ -0,0 +1,66 @@ + +

{t}Devices{/t}

+ + + + +
+ + + + + + + + + + + + + +
+ + +
{$must} + + +
+ + +
+
+ + + + + + + + + + + + + + +
{$must} + + +  
{$must} + + +
{$must} + + +
+
+ + + + diff --git a/gosa-core/plugins/admin/devices/main.inc b/gosa-core/plugins/admin/devices/main.inc new file mode 100755 index 000000000..92f901dd3 --- /dev/null +++ b/gosa-core/plugins/admin/devices/main.inc @@ -0,0 +1,57 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('DeviceManagement'); + } +} else { + + /* Create DeviceManagement object on demand */ + if (!isset($_SESSION['DeviceManagement']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['DeviceManagement']= new deviceManagement ($config); + } + + /* Get object */ + $DeviceManagement= $_SESSION['DeviceManagement']; + $DeviceManagement->save_object(); + $output= $DeviceManagement->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/devices.png'), _("Device management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/devices.png'), _("Device management")); + } + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('DeviceManagement'); + } + + /* Show and save dialog */ + $display.= $output; + $_SESSION['DeviceManagement']= $DeviceManagement; +} +?> diff --git a/gosa-core/plugins/admin/devices/paste_deviceGeneric.tpl b/gosa-core/plugins/admin/devices/paste_deviceGeneric.tpl new file mode 100644 index 000000000..44d688246 --- /dev/null +++ b/gosa-core/plugins/admin/devices/paste_deviceGeneric.tpl @@ -0,0 +1,25 @@ + +

{t}Devices{/t}

+ + + + +
+ + + + + +
{$must} + + +
+
+ + + + diff --git a/gosa-core/plugins/admin/devices/remove.tpl b/gosa-core/plugins/admin/devices/remove.tpl new file mode 100755 index 000000000..643056cd3 --- /dev/null +++ b/gosa-core/plugins/admin/devices/remove.tpl @@ -0,0 +1,23 @@ +
+  {t}Warning{/t} +
+

+ {$intro} + {t}This may be used by several users/groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-core/plugins/admin/devices/tabs_devices.inc b/gosa-core/plugins/admin/devices/tabs_devices.inc new file mode 100755 index 000000000..9cb2e9017 --- /dev/null +++ b/gosa-core/plugins/admin/devices/tabs_devices.inc @@ -0,0 +1,43 @@ +addSpecialTabs(); + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['deviceGeneric']; + $new_dn= "cn=".$baseobject->cn.",ou=devices,".$baseobject->base; + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['deviceGeneric']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + tabs::save(); + + /* Fix tagging if needed */ + $baseobject->dn= $this->dn; + $baseobject->handle_object_tagging(); + $this->by_object['deviceGeneric'] = $baseobject; + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/askClassName.tpl b/gosa-core/plugins/admin/fai/askClassName.tpl new file mode 100644 index 000000000..7975e1052 --- /dev/null +++ b/gosa-core/plugins/admin/fai/askClassName.tpl @@ -0,0 +1,89 @@ +
+ {$headline} +
+
+

+{t}Adding a new class to the FAI management, requires a class name. You have to specify a unique class name for unique types of FAI classes, while you can use the same class name for different types of FAI classes. In the laste case, FAI will automatically enclose all these different class types to one unique class name.{/t} +
+
+

+

+
+{t}Please use one of the following methods to choose the name for the new FAI class.{/t} +
+
+

+
+ + + + + + +
+ + + + + + + + + +
+ + +

{t}Enter FAI class name manually{/t}

+
  + {t}Class name{/t}  +
+
+
+
+ + + + + + + + + + +
+ + +

{t}Choose FAI class name from a list of existing classes{/t}

+
  + {t}Class name{/t}  +
+
+
+
+ + +

 

+ + + diff --git a/gosa-core/plugins/admin/fai/branch_selector.tpl b/gosa-core/plugins/admin/fai/branch_selector.tpl new file mode 100644 index 000000000..addb5a7a2 --- /dev/null +++ b/gosa-core/plugins/admin/fai/branch_selector.tpl @@ -0,0 +1,42 @@ +
+
+

[F]{t}Branches{/t}

+
+
+ + + + +
+ {t}Current release{/t}  + +
+ + + + +
+ {if $allow_create} + + {t}Create new branch{/t} +
+ + {t}Create new locked branch{/t} + {else} + {t}Branch{/t} + {t}Create new branch{/t} +
+ {t}Freeze{/t} + {t}Create new locked branch{/t} + {/if} + + {if $selectedBranch != "main" && $allow_remove} +
+ + {t}Delete current release{/t} + {/if} +
+
+ diff --git a/gosa-core/plugins/admin/fai/class_askClassName.inc b/gosa-core/plugins/admin/fai/class_askClassName.inc new file mode 100644 index 000000000..4225869cc --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_askClassName.inc @@ -0,0 +1,172 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); + + var $objectClass = false; + var $forbidden = array(); + var $ClassName = ""; + var $ClassAlreadyExists = false; + + function askClassName (&$config,$dn,$ui,$objectClass) + { + $this->ui = $ui; + $this->objectClass = $objectClass; + plugin::plugin ($config, $dn); + if(!isset($_SESSION['CurrentMainBase'])){ + $_SESSION['CurrentMainBase'] = $this->config->current['BASE']; + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $display= ""; + + /* The faifilter contais + * The base for all fai objects + */ + $faifilter = $_SESSION['faifilter']; + + /* First search for every ou, in given fai base + * With a second search detect all object that belong to the different ous. + */ + + $base = "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + if($faifilter['branch'] != "main"){ + $base = $faifilter['branch']; + } + $ldap = $this->config->get_ldap_link(); + + $res= get_list("(&(objectClass=organizationalUnit)(!(objectClass=FAIbranch)))", "fai", $base, + array("cn","description","objectClass"), GL_SIZELIMIT ); + + $delete = array(); + $used = array(); + foreach($res as $objecttypes){ + $res2= get_list("(objectClass=*)", "fai", $objecttypes['dn'], + array("cn","description","objectClass","FAIclass","FAIstate"), GL_SIZELIMIT | GL_CONVERT ); + foreach($res2 as $object){ + + /* skip class names with this name */ + if(in_array($this->objectClass,$object['objectClass']) || in_array("FAIprofile",$object['objectClass'])){ + if(isset($object['FAIstate'][0]) && preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + $delete[] = $object['cn'][0]; + } + + /* Skip profiles */ + if(!in_array("FAIprofile",$object['objectClass'])){ + if(isset($object['cn'])){ + $used[$object['cn'][0]]= $object['cn'][0]; + } + } + } + } + + /* Create headline + * Depending on the object type we want to create, a different headline will be shown + */ + switch($this->objectClass) { + case "FAIpartitionTable": $str =_("Create new FAI object - partition table.");break; + case "FAIpackageList" : $str =_("Create new FAI object - package bundle.");break; + case "FAIscript" : $str =_("Create new FAI object - script bundle.");break; + case "FAIvariable" : $str =_("Create new FAI object - variable bundle.");break; + case "FAIhook" : $str =_("Create new FAI object - hook bundle.");break; + case "FAIprofile" : $str =_("Create new FAI object - profile.");break; + case "FAItemplate" : $str =_("Create new FAI object - template.");break; + default : $str =_("Create new FAI object");break; + } + $smarty->assign("headline",$str); + + /* Save forbidden class names + */ + $this->forbidden = $delete; + + /* Delete all class names which already have this type of object + */ + foreach($delete as $del){ + unset($used[$del]); + } + + /* if there is no class name which is missing for this type + * of objectClass, we only can create a new one, disable selectBox + */ + if(count ($used)==0){ + $smarty->assign("ClassNamesAvailable", " disabled "); + $smarty->assign("grey", 'style="color:#C0C0C0"'); + }else{ + $smarty->assign("ClassNamesAvailable", ""); + $smarty->assign("grey", ""); + } + ksort($used); + $smarty->assign("ClassNames", $used); + $smarty->assign("ClassName", $this->ClassName); + $display.= $smarty->fetch(get_template_path('askClassName.tpl', TRUE)); + return($display); + } + + /* Get posts and set class name + */ + function save_object() + { + if(isset($_POST['classSelector']) && $_POST['classSelector'] == 1 + && isset($_POST['edit_continue'])){ + $this->ClassName = $_POST['UseTextInputName']; + $this->ClassAlreadyExists = true; + } + + if(isset($_POST['classSelector']) && $_POST['classSelector'] == 2 + && isset($_POST['edit_continue'])){ + $this->ClassAlreadyExists = false; + $this->ClassName = $_POST['SelectedClass']; + } + } + + /* Check given class name + */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if($this->ClassName != preg_replace("/ /","",trim($this->ClassName))){ + $message[] = _("Spaces are not allowed within class names."); + } + + if(empty($this->ClassName)){ + $message[]=_("The given class name is empty."); + } + + if(in_array($this->ClassName,$this->forbidden)){ + $message[]=_("The specified class name is already in use for this object type."); + } + + return ($message); + } + + + /* Return the class name */ + function save() + { + return($this->ClassName); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_divListFai.inc b/gosa-core/plugins/admin/fai/class_divListFai.inc new file mode 100644 index 000000000..b15485c82 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_divListFai.inc @@ -0,0 +1,419 @@ +parent = $parent; + $this->ui = get_userinfo(); + + /* Set default base */ + if(!isset($_SESSION['CurrentMainBase'])){ + $_SESSION['CurrentMainBase'] = $this->config->current['BASE']; + } + $this->selectedBase = $_SESSION['CurrentMainBase']; + + /* Set list strings */ + $this->SetTitle(_("List of FAI classes")); + $this->SetSummary(_("This table displays all FAI classes in the selected tree.")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to create, delete and edit FAI classes.")); + + $this->EnableAplhabet (true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 80; +# if($this->parent->snapshotEnabled()){ +# $action_col_size += 32; +# } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Name of FAI class"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Class type"), "attach" => "style='width:200px;'")); + $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); + + $this->AddCheckBox("ShowProfiles" , _("Display FAI profile objects") ,_("Show profiles") ,true); + $this->AddCheckBox("ShowTemplates" , _("Display FAI template objects") ,_("Show templates") ,true); + $this->AddCheckBox("ShowScripts" , _("Display FAI scripts") ,_("Show scripts") ,true); + $this->AddCheckBox("ShowHooks" , _("Display FAI hooks") ,_("Show hooks") ,true); + $this->AddCheckBox("ShowVariables" , _("Display FAI variables") ,_("Show variables") ,true); + $this->AddCheckBox("ShowPackages" , _("Display FAI packages") ,_("Show packages") ,true); + $this->AddCheckBox("ShowPartitions" , _("Display FAI partitions") ,_("Show partitions") ,true); + + /* Add SubSearch checkbox */ + //$this->AddCheckBox(SEPERATOR); + //$this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Display users matching"),"*" , true); + } + + function AddUserBoxToFilter($position) + { + $str = ""; + if($position == 2){ + + /* Check if there are post commands available for fai management. + * If not, grey out freeze/branch and release remove buttons. + */ + $r = $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs')); + $c = $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs')); + + $smarty = get_smarty(); + $smarty->assign("allow_create", $c); + $smarty->assign("allow_remove", $r); + $smarty->assign("selectedBranch",$this->selectedBranch); + $smarty->assign("branchimage","images/branch.png"); + $smarty->assign("branches",$this->AvailableBranches); + $plug_id = 0; + if(isset($_GET['plug'])){ + $plug_id = $_GET['plug']; + } + $smarty->assign("plug_id",$plug_id); + $str = $smarty->fetch(get_template_path('branch_selector.tpl', TRUE)); + } + return($str); + } + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("fai"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Add seperator */ + $add_sep = false; + + /* Get complete fai acls, to be able to check if we must show or hide the snapshot abilities */ + $acl_all = $ui->has_complete_category_acls($this->selectedBase,$this->module); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* Add additional seperator */ + if($add_sep){ + $listhead .="  "; + } + + $listhead .= _("Base")." ". + "  "; + + + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + $acl = $ui->get_permissions($this->selectedBase,"fai/faiProfile"); + if(preg_match("/c/",$acl)){ + $s.= "...|". + " "._("Profile")."|Create_profile|\n"; + } + + /* Append create icons for each fai component */ + $arr = array( + array("images/fai_new_partitionTable.png" , _("Partition table") ,"Create_partition" , _("PT") , "faiPartitionTable"), + array("images/fai_new_script.png" , _("Scripts") ,"Create_script" , _("S") , "faiScript"), + array("images/fai_new_hook.png" , _("Hooks") ,"Create_hook" , _("H") , "faiHook"), + array("images/fai_new_variable.png" , _("Variables") ,"Create_variable" , _("V") , "faiVariable"), + array("images/fai_new_template.png" , _("Templates ") ,"Create_template" , _("I") , "faiTemplate"), + array("images/fai_new_packages.png" , _("Package list") ,"Create_package" , _("PK") , "faiPackage")); + + foreach($arr as $ar){ + $acl = $ui->get_permissions($this->selectedBase,"fai/".$ar[4]); + if(preg_match("/c/",$acl)){ + $s.= "...|". + " ".$ar[1]."|".$ar[2]."|\n"; + } + } + + /* Multiple options */ + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + } + + /* Add copy & paste icons, currently disabled, this ability is not implemeneted yet */ + if(preg_match("/(c.*w|w.*c)/",$acl_all) && isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler){ + $s .= "..|---|\n"; + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + +# /* Add snapshot icons, if we are allowed to write and create the complete fai module ($ui->has_complete_category_acls) */ +# if(preg_match("/(c.*w|w.*c)/",$acl_all)){ +# if($this->parent->snapshotEnabled()){ +# $s .= "..|---|\n"; +# $s .= $this->get_snapshot_header(TRUE); +# } +# } + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + } + + /* so some basic settings */ + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + $this->AvailableBranches = $this->parent->getBranches(); + } + + function setEntries($list) + { + /******************** + Variable init + ********************/ + + $objects = array( + "FAIpartitionTable" => array("IMG"=> "images/fai_partitionTable.png", "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"), + "FAIpackageList" => array("IMG"=> "images/fai_packages.png", "NAME"=>_("Package list") , "KZL"=> "PL", "VAR"=>"ShowPackages"), + "FAIscript" => array("IMG"=> "images/fai_script.png", "NAME"=>_("Scripts") , "KZL"=> "S", "VAR"=>"ShowScripts"), + "FAIvariable" => array("IMG"=> "images/fai_variable.png", "NAME"=>_("Variables") , "KZL"=> "V", "VAR"=>"ShowVariables"), + "FAIhook" => array("IMG"=> "images/fai_hook.png", "NAME"=>_("Hooks"), "KZL"=> "H", "VAR"=>"ShowHooks"), + "FAIprofile" => array("IMG"=> "images/fai_profile.png", "NAME"=>_("Profile") , "KZL"=> "P", "VAR"=>"ShowProfiles"), + "FAItemplate" => array("IMG"=> "images/fai_template.png", "NAME"=>_("Templates") , "KZL"=> "T", "VAR"=>"ShowTemplates")); + + $editlink ="%NAME%"; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 80; +# if($this->parent->snapshotEnabled()){ +# $action_col_size += 32; +# } + + /******************** + Attach objects + ********************/ + + $cnts = array(); + foreach($objects as $key => $data){ + $cnts[$key] = 0; + } + + foreach($list as $key => $value){ + $info = ""; + $img = ""; + $type = $value['type']; + $abort =false; + + $cnts[$type] ++; + + if(isset($objects[$type])){ + $img = "".$objects[$type]["; + $info = $objects[$type]['NAME']; + $var = $objects[$type]['VAR']; + }else{ + $img = ""; + $info = ""; + $var = ""; + } + + if((isset($value['description']))&&(!empty($value['description']))){ + $desc= " [".$value['description']."]"; + }else{ + $desc= ""; + } + + /* Add copy & cut icons */ + $ui = get_userinfo(); + $action =""; + $acl_all = $ui->has_complete_category_acls($this->selectedBase,$this->module); + if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){ + $action .= " "; + $action.= " "; + } + + if($value['FAIstate'] == "freeze"){ + $action.= "F"; + $action.= ""; + }else{ + $action.= ""; + +# if(preg_match("/(c)/",$value['acl']) && preg_match("/(w)/",$value['acl'])){ +# $action.= $this->GetSnapShotActions($value['dn']);; +# } + + if(preg_match("/d/",$value['acl'])){ + $action.= ""; + } + } + + /* Cutted objects should be displayed in light grey */ + $display = $value['cn'].$desc; + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $value['dn']) { + $display = "".$display.""; + break; + } + } + } + $edi = $editlink; + $acti = $action; + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/","/%TITLE%/"),array($key,$display,preg_replace('/ /', ' ', @LDAP::fix($value['dn']))),$edi) , "attach" => "style=''"); + $field3 = array("string" => $info, "attach" => "style='width:200px;'"); + $field4 = array("string" => preg_replace("/%KEY%/",$key,$acti) , "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); + } + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + + $profile_str = _("Number of listed profiles"); + $partition_str = _("Number of listed partitions"); + $script_str = _("Number of listed scripts"); + $hook_str = _("Number of listed hooks"); + $variable_str = _("Number of listed variables"); + $template_str = _("Number of listed templates"); + $package_str = _("Number of listed packages"); + $dep_str = _("Number of listed departments"); + + $str = "".$profile_str." ".$cnts['FAIprofile']."    "; + $str.= "".$partition_str." ".$cnts['FAIpartitionTable']."    "; + $str.= "".$script_str." ".$cnts['FAIscript']."    "; + $str.= "".$hook_str." ".$cnts['FAIhook']."    "; + $str.= "".$variable_str." ".$cnts['FAIvariable']."    "; + $str.= "".$template_str." ".$cnts['FAItemplate']."    "; + $str.= "".$package_str." ".$cnts['FAIpackageList']."    "; + $str.= "".$dep_str." ".$num_deps."    "; + $this->set_List_Bottom_Info($str); + } + + function Save() + { + MultiSelectWindow::Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + $_SESSION['faifilter']['branch'] = $this->selectedBranch; + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiHook.inc b/gosa-core/plugins/admin/fai/class_faiHook.inc new file mode 100644 index 000000000..ce60202a3 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiHook.inc @@ -0,0 +1,608 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIhook"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAIhookEntry"; + var $subClasses = array("top","FAIclass","FAIhookEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = "faiHookEntry"; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description","FAItask"); + var $sub_Load_Later = array("FAIscript"); + var $sub64coded = array(); + var $subBinary = array("FAIscript"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $SubObjects = array(); // All leafobjects of this object + var $view_logged = FALSE; + var $FAIstate = ""; + var $ui; + + function faiHook (&$config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + */ + if($dn != "new"){ + $this->dn =$dn; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $attrs_to_search = $this->subAttributes; + $attrs_to_search[] = "FAIstate"; + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))", $attrs_to_search); + + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + /* Set status for save management */ + $objects = array(); + $objects['status'] = "FreshLoaded"; + $objects['dn'] = $object['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $this->SubObjects[$objects['cn']] = $objects; + } + } + $this->ui = get_userinfo(); + } + + + /* Reload some attributes */ + function get_object_attributes($object,$attributes) + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($object['dn'],$attributes); + $tmp = $ldap->fetch(); + + foreach($attributes as $attrs){ + if(isset($tmp[$attrs][0])){ + $var = $tmp[$attrs][0]; + + /* Check if we must decode some attributes */ + if(in_array_ics($attrs,$this->sub64coded)){ + $var = base64_decode($var); + } + + /* check if this is a binary entry */ + if(in_array_ics($attrs,$this->subBinary)){ + $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0); + } + + /* Fix slashes */ + $var = addslashes($var); + $object[$attrs] = $var; + } + } + return($object); + } + + + function acl_base_for_current_object($dn) + { + if($dn == "new"){ + if($this->dn == "new"){ + $dn= $_SESSION['CurrentMainBase']; + }else{ + $dn = $this->dn; + } + } + return($dn); + } + + + function getUsedFAItask($cn) + { + $ret = array(); + foreach($this->SubObjects as $name => $class){ + if($class['cn'] == $cn){ + continue; + } + if($class['status'] != "delete"){ + $ret[$class['FAItask']] = $class['FAItask']; + } + } + return($ret); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","fai/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* New Listhandling + */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^editscript_/",$name)&&($once)){ + $once = false; + $entry = preg_replace("/^editscript_/","",$name); + $entry = base64_decode(preg_replace("/_.*/","",$entry)); + + $obj = $this->SubObjects[$entry]; + if($obj['status'] == "FreshLoaded"){ + $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); + } + + $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); + $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn'])); + $this->dialog->set_acl_category("fai"); + + $_SESSION['objectinfo'] = $obj['dn']; + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + if(preg_match("/^deletescript_/",$name)&&($once)){ + $entry = preg_replace("/^deletescript_/","",$name); + $entry = base64_decode(preg_replace("/_.*/","",$entry)); + + $dn = $this->acl_base_for_current_object($this->SubObjects[$entry]['dn']); + $acl = $this->ui -> get_permissions($dn,"fai/faiScriptEntry") ; + + if(preg_match("/d/",$acl)){ + $once = false; + + $status = $this->SubObjects[$entry]['status']; + if($status == "edited" || $status == "FreshLoaded"){ + $this->SubObjects[$entry]['status']= "delete"; + }else{ + unset($this->SubObjects[$entry]); + } + } + } + } + + /* Edit entries via GET */ + if(isset($_GET['act']) && isset($_GET['id'])){ + if($_GET['act'] == "edit" && isset($this->SubObjects[$_GET['id']])){ + $obj = $this->SubObjects[$_GET['id']]; + if($obj['status'] == "FreshLoaded"){ + $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); + } + $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); + $this->dialog->acl = $this->acl; + $_SESSION['objectinfo'] = $obj['dn']; + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + } + + ///// Ende new list handling + + /* Add new sub object */ + if(isset($_POST['AddSubObject'])){ + + $c_dn = $this->acl_base_for_current_object($this->dn); + $this->dialog= new $this->subClassName($this->config,"new"); + $this->dialog->set_acl_base($c_dn); + $this->dialog->set_acl_category("fai"); + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + + + /* Save Dialog */ + if(isset($_POST['SaveSubObject'])){ + + /* Perform post check*/ + $this->dialog->save_object(); + + /* Get messages */ + $msgs = $this->dialog->check(); + + /* print errors */ + if(count($msgs)>0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + + /* Get return object */ + $obj = $this->dialog->save(); + if(isset($obj['remove'])){ + + $old_stat = $this->SubObjects[$obj['remove']['from']]['status']; + + /* Depending on status, set new status */ + if($old_stat == "edited" || $old_stat == "FreshLoaded"){ + $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; + }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + unset($this->SubObjects[$obj['remove']['from']]); + } + $obj['status'] = "new"; + $this->SubObjects[$obj['remove']['to']] = $obj; + unset($this->SubObjects[$obj['remove']['to']]['remove']); + }else{ + if($obj['status'] == "FreshLoaded"){ + $obj['status'] = "edited"; + } + $this->SubObjects[$obj['cn']]=$obj; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + } + + /* Sort entries */ + $tmp = $keys = array(); + foreach($this->SubObjects as $key => $entry){ + $keys[$key]=$key; + } + natcasesort($keys); + foreach($keys as $key){ + $tmp[$key]=$this->SubObjects[$key]; + } + $this->SubObjects = $tmp; + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + + /* Print dialog if $this->dialog is set */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return($display); + } + + + + /* Divlist added 28.02.2006 + Containing FAIscripts + */ + + $divlist = new divSelectBox("FAIhooks"); + $divlist->setHeight(400); + + foreach($this->getList(true) as $key => $name){ + + $dn= $this->acl_base_for_current_object($name['dn']); + $acl = $this->ui->get_permissions($dn,"fai/faiHookEntry") ; + $act = ""; + + /* Check if this object is freezed, in this case hide the delete icon */ + if($this->FAIstate == "freeze"){ + $act .= ""; + }else{ + $act .= ""; + if(preg_match("/d/",$acl)){ + $act .=""; + } + } + + /* Check if we are allowed to use the export button for this object */ + $s_acl = $this->ui->get_permissions($dn,"fai/faiHookEntry","FAIscript") ; + if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){ + $down = ""; + }else{ + $down = " + "._("Download")." + "; + } + + /* Check if we are allowed to view the object */ + $s_acl = $this->ui->get_permissions($dn,"fai/faiHookEntry","cn") ; + if(preg_match("/r/",$s_acl)){ + + $edit_link = "".$name['name'].""; + $divlist->AddEntry(array( array("string"=>$edit_link), + array("string"=>$down , "attach" => "style='width:20px;'"), + array("string"=>str_replace("%s",base64_encode($key),$act), + "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); + } + } + $smarty->assign("Entry_divlist",$divlist->DrawList()); + /* Divlist creation complete + */ + + $smarty->assign("SubObjects",$this->getList()); + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + }else{ + $smarty->assign($attrs,($this->$attrs)); + } + } + + $tmp = $this->plInfo(); + + $c_dn = $this->acl_base_for_current_object($this->dn); + $smarty->assign("sub_object_is_addable", preg_match("/c/",$this->ui->get_permissions($c_dn,"fai/faiHookEntry")) && $this->FAIstate!="freeze"); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $display.= $smarty->fetch(get_template_path('faiHook.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList($use_dns=false){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + if($use_dns){ + if((isset($obj['description']))&&(!empty($obj['description']))){ + $a_return[$obj['cn']]['name']= $obj['cn']." [".stripslashes($obj['description'])."]"; + }else{ + $a_return[$obj['cn']]['name']= $obj['cn']; + } + $a_return[$obj['cn']]['dn']= $obj['dn']; + }else{ + if((isset($obj['description']))&&(!empty($obj['description']))){ + $a_return[$obj['cn']]= $obj['cn']." [".stripslashes($obj['description'])."]"; + }else{ + $a_return[$obj['cn']]= $obj['cn']; + } + } + } + } + return($a_return); + } + + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $this->dn; + } + + prepare_to_save_FAI_object($use_dn,array(),true); + + new log("remove","fai/".get_class($this),$use_dn,$this->attributes); + + foreach($this->SubObjects as $name => $obj){ +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $obj['dn']; + } + prepare_to_save_FAI_object($use_dn,array(),true); + } + $this->handle_post_events("remove"); + } + + + /* Save data to object + */ + function save_object() + { + if((isset($_POST['FAIhook_posted'])) && ($this->FAIstate != "freeze")){ + plugin::save_object(); + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + } + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + prepare_to_save_FAI_object($this->dn,$this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/hook with dn '%s' failed."),$this->dn)); + + if($this->initially_was_account){ + new log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + new log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + + /* Do object tagging */ + $this->handle_object_tagging(); + + $ldap->cd($this->dn); + + /* Prepare FAIscriptEntry to write it to ldap + * First sort array. + * Because we must delete old entries first. + * After deletion, we perform add and modify + */ + $Objects = array(); + + /* We do not need to save untouched objects */ + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "FreshLoaded"){ + unset($this->SubObjects[$name]); + } + } + + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "delete"){ + $Objects[$name] = $obj; + } + } + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] != "delete"){ + $Objects[$name] = $obj; + } + } + + foreach($Objects as $name => $obj){ + + foreach($this->sub64coded as $codeIt){ + $obj[$codeIt]=base64_encode(stripslashes($obj[$codeIt])); + } + + $tmp = array(); + $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); + foreach($attributes as $attrs){ + if(empty($obj[$attrs])){ + $obj[$attrs] = array(); + } + if(!is_array($obj[$attrs])){ + $tmp[$attrs] = stripslashes($obj[$attrs]); + }else{ + $tmp[$attrs] = $obj[$attrs]; + } + } + + $tmp['objectClass'] = $this->subClasses; + + $sub_dn = "cn=".$obj['cn'].",".$this->dn; + + if($obj['status']=="new"){ + $ldap->cat($sub_dn,array("objectClass")); + if($ldap->count()){ + $obj['status']="edited"; + } + } + + /* Check if gosaAdministrativeUnitTag is required as object class */ + if($obj['status'] == "edited"){ + $ldap->cat($sub_dn,array("objectClass")); + $attrs = $ldap->fetch(); + if(isset($attrs['objectClass'])){ + if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ + $tmp['objectClass'][] = "gosaAdministrativeUnitTag"; + } + } + } + + if($obj['status'] == "delete"){ + prepare_to_save_FAI_object($sub_dn,array(),true); + $this->handle_post_events("remove"); + }elseif($obj['status'] == "edited"){ + prepare_to_save_FAI_object($sub_dn,$tmp); + $this->handle_post_events("modify"); + }elseif($obj['status']=="new"){ + prepare_to_save_FAI_object($sub_dn,$tmp); + $this->handle_post_events("add"); + } + $this->handle_object_tagging($sub_dn, $this->gosaUnitTag); + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($source['dn']); + + $attrs_to_search = $this->subAttributes; + $attrs_to_search[] = "FAIstate"; + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + /* Set status for save management */ + $objects = array(); + $objects['status'] = "edited"; + $objects['dn'] = $object['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); + + $this->SubObjects[$objects['cn']] = $objects; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Hook"), + "plDescription" => _("FAI hook"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 20, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name")." ("._("Read only").")", + "description" => _("Description")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiHookEntry.inc b/gosa-core/plugins/admin/fai/class_faiHookEntry.inc new file mode 100644 index 000000000..84b326e71 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiHookEntry.inc @@ -0,0 +1,206 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("cn","description","FAIscript","FAItask"); + var $objectclasses= array(); + + var $orig_cn = ""; + var $tasks = array("chboot", "configure", "debconf", "extrbase", "faiend", "finish", + "install", "instsoft", "mirror", "mountdisks", "partition", "prepareapt", + "savelog", "softupdate", "sysinfo","updatebase"); + var $dn = ""; + var $cn = ""; + var $FAItask = "chboot"; + var $FAIscript = ""; + var $description = ""; + var $status = "new"; + var $parent = NULL; + var $FAIstate = ""; + + function faiHookEntry (&$config, $dn= NULL,$object=false) + { + plugin::plugin ($config, $dn); + if($dn != "new"){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = $name; + $this->$oname=$value; + } + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + }elseif(is_array($object)){ + if(count($object)){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = $name; + $this->$oname=$value; + } + }else{ + + $this->status = "new"; + $this->orig_cn = false; + } + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + if(isset($_POST['ImportUpload'])){ + if(($_FILES['ImportFile']['error']!=0)){ + print_red(_("Please select a valid file.")); + }else + if(($_FILES['ImportFile']['size']==0)){ + print_red(_("Selected file is empty.")); + }else{ + $str = utf8_encode(file_get_contents($_FILES['ImportFile']['tmp_name'])); + $this->FAIscript = $str; + } + } + + /* Create download button*/ + if($this->dn != "new" && $this->acl_is_readable("FAIscript")){ + $smarty->assign("DownMe"," + "._("Download")." + "); + }else{ + $smarty->assign("DownMe",""); + } + + $used_tasks = $this->parent->getUsedFAItask($this->cn); + $tasks = $this->tasks; + foreach($this->tasks as $id => $task){ + if(in_array($task,$used_tasks)){ + unset($tasks[$id]); + } + } + $smarty->assign("tasks", $tasks); + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,(stripslashes($this->$attrs))); + }else{ + $smarty->assign($attrs,($this->$attrs)); + } + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $acl = $this->getacl($name); + if($this->FAIstate == "freezed"){ + $acl = preg_replace("/w/","",$acl); + } + $smarty->assign($name."ACL",$acl); + } + + if(get_magic_quotes_gpc()){ + $smarty->assign("FAIscript" , htmlentities(stripslashes($this->FAIscript))); + }else{ + $smarty->assign("FAIscript" , htmlentities($this->FAIscript)); + } + $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ + foreach($this->attributes as $attrs){ + if($this->acl_is_writeable($attrs)){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + }else{ + $this->$attrs = ""; + } + } + } + } + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ + $message[] =_("There is already a hook with the given name."); + } + + if(empty($this->FAIscript)) { + $message[]=_("Please enter a value for script."); + } + + if(empty($this->cn)){ + $message[] = _("Please enter a name."); + } + + return ($message); + } + + function save() + { + $tmp=array(); + foreach($this->attributes as $attrs){ + $tmp[$attrs] = $this->$attrs; + } + + /* Strip out dos newlines */ + $tmp['FAIscript']= strtr($this->FAIscript, array("\x0D" => "")); + + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ + $tmp['remove']['from'] = $this->orig_cn; + $tmp['remove']['to'] = $tmp['cn']; + } + + $tmp['dn'] = $this->dn; + $tmp['status'] = $this->status; + return($tmp); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Hook entry"), + "plDescription" => _("FAI hook entry"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 21, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name"), + "description" => _("Description"), + "FAItask" => _("Task"), + "FAIscript" => _("FAI script")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiManagement.inc b/gosa-core/plugins/admin/fai/class_faiManagement.inc new file mode 100644 index 000000000..b9c027110 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiManagement.inc @@ -0,0 +1,1156 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Headpage attributes */ + var $lock_type = ""; // should be branch/freeze + var $lock_name = ""; + var $lock_dn = ""; + + /* attribute list for save action */ + var $attributes = array("lock_type","lock_name","lock_dn"); // Attributes Managed by this plugin + var $objectclasses= array(); // ObjectClasses which the attributes are related to + var $dialog = array(); // This object contains every dialog we have currently opened + + var $objects = array(); // This array contains all available objects shown in divlist + var $is_dialog = false; + + var $dispNewBranch= false; + var $dispNewFreeze= false; + + var $DivListFai; + var $start_pasting_copied_objects = FALSE; + var $CopyPasteHandler = FALSE; + var $base = ""; + + /* construction/reconstruction + */ + function faiManagement (&$config, $ui) + { + /* Set defaults */ + $this->dn = ""; + $this->config = $config; + $this->ui = $ui; + + /* Creat dialog object */ + $this->DivListFai = new divListFai($this->config,$this); + + /* Copy & Paste handler */ + if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){ + $this->CopyPasteHandler= new CopyPasteHandler($this->config); + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Initialise vars and smarty */ + $smarty = get_smarty(); + $smarty->assign("BranchName",""); + + $display = ""; + $s_action = ""; + $s_entry = ""; + + /* If an entry was locked, these vars will be stored in a session to allow direct edit */ + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit_entry$/","/^id$/","/^entry_edit_/","/^entry_delete_/","/^item_selected/","/^remove_multiple_fai_objects/"); + + + /**************** + Handle posts + ****************/ + + /* Check ImageButton posts + * Create new tab ich new_xx is posted + */ + $posts = array( "/remove_branch/"=>"remove_branch", "/branch_branch/"=>"branch_branch", + "/freeze_branch/"=>"freeze_branch", "/create_partition/i"=>"new_partition", + "/create_script/i"=>"new_script", "/create_hook/i"=>"new_hook", + "/create_variable/i"=>"new_variable", "/create_template/i"=>"new_template", + "/create_package/i"=>"new_package", "/create_profile/i"=>"new_profile", + "/edit_continue/"=>"select_class_name_finished", + "/^multiple_copy_fai/" => "copy_multiple", + "/^multiple_cut_fai/" => "cut_multiple", + "/^copy/" => "copy", + "/^cut/" => "cut", + "/^remove_multiple_fai_objects/" => "del_multiple"); + + foreach($_POST as $name => $value){ + foreach($posts as $reg => $act ){ + if(preg_match($reg,$name)){ + $s_action = $act; + $s_entry = ltrim(preg_replace($reg,"",$name),"_"); + $s_entry = preg_replace("/_.*$/","",$s_entry); + } + } + if(preg_match("/^entry_edit_.*/",$name)){ + $s_entry = preg_replace("/^entry_edit_/","",$name); + $s_entry = preg_replace("/_.*$/","",$s_entry); + $s_action = "edit"; + }elseif(preg_match("/^entry_delete_.*/",$name)){ + $s_entry = preg_replace("/^entry_delete_/","",$name); + $s_entry = preg_replace("/_.*$/","",$s_entry); + $s_action = "delete"; + } + } + + if(isset($_GET['edit_entry'])){ + $s_entry = $_GET['edit_entry']; + $s_action = "edit"; + } + + if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){ + $s_action = "freeze_branch"; + } + if(isset($_GET['act']) && $_GET['act'] == "branch_branch"){ + $s_action = "branch_branch"; + } + if(isset($_GET['act']) && $_GET['act'] == "remove_branch"){ + $s_action = "remove_branch"; + } + + if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){ + $this->dispNewBranch = false; + $this->dispNewFreeze = false; + } + + + $type_acl_mapping = array( + "FAIpartitionTable" => "faiPartitionTable", + "FAIpackageList" => "faiPackage", + "FAIscript" => "faiScript", + "FAIvariable" => "faiVariable", + "FAIhook" => "faiHook", + "FAIprofile" => "faiProfile", + "FAItemplate" => "faiTemplate"); + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){ + $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);; + $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']); + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + /******************** + Copy & Paste + ********************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /**************** + Delete confirme dialog + ****************/ + + if ($s_action=="delete"){ + + /* Get 'dn' from posted termlinst */ + $this->dn= $this->objects[$s_entry]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]); + if(preg_match("/d/",$acl)){ + + /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the user isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this component!")); + } + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $this->dns = array(); + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->objects[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $smarty->assign("warning", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); + } else { + $smarty->assign("warning", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); + } + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_fai_object_confirm'])){ + + /* Find out more about the object type */ + $ldap = $this->config->get_ldap_link(); + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $ldap->cat($dn, array('objectClass')); + $attrs = $ldap->fetch(); + $type = $this->get_type($attrs); + + $acl = $this->ui->get_permissions($dn,"fai/".$type[1]); + if(preg_match("/d/",$acl)){ + + $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai"); + $this->dialog->set_acl_base($dn); + $this->dialog->by_object[$type[1]]->remove_from_parent (); + unset ($this->dialog); + $this->dialog= FALSE; + $to_del = clean_up_releases($dn); + save_release_changes_now(); + + foreach($to_del as $dn){ + $ldap->rmdir_recursive($dn); + } + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this component!")); + new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_fai_object_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /**************** + Delete aborted + ****************/ + + /* Delete canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + } + + + /**************** + Delete confirmed + ****************/ + + /* Deltetion was confirmed, so delete this entry + */ + if (isset($_POST['delete_terminal_confirm'])){ + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + + /* Find out more about the object type */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('objectClass')); + if($ldap->count()){ + $attrs = $ldap->fetch(); + $type = $this->get_type($attrs); + + $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]); + if(preg_match("/d/",$acl)){ + + $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai"); + $this->dialog->set_acl_base($this->dn); + $this->dialog->by_object[$type[1]]->remove_from_parent (); + unset ($this->dialog); + $this->dialog= FALSE; + $to_del = clean_up_releases($this->dn); + save_release_changes_now(); + + foreach($to_del as $dn){ + $ldap->rmdir_recursive($dn); + } + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this component!")); + new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + }else{ + print_red(sprintf(_("Object could not be deleted '%s', object does not exist."),$this->dn)); + } + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + /**************** + Edit entry + ****************/ + + if(($s_action == "edit") && (!isset($this->dialog->config))){ + $entry = $this->objects[$s_entry]; + $a_setup = $this->get_type($entry); + $this->dn = $entry['dn']; + + /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + add_lock ($this->dn, $this->ui->dn); + + $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai"); + $this->dialog->set_acl_base($this->dn); + $this->is_dialog = true; + + if($entry['FAIstate'] == "freeze"){ + #$this->dialog->set_acl(array("*none*")) ; + echo "Dawn it is freezed."; + } + $_SESSION['objectinfo'] = $this->dn; + } + + + /* Branch handling + 09.01.2006 + */ + + /**************** + Remove branch + ****************/ + + /* Remove branch + */ + if($s_action == "remove_branch"){ + $base= $this->DivListFai->selectedBranch; + + /* Check if we have a post remove method configured + * else skip this operation. (Skip:Button in the ui should be disabled in this case too) + */ + if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){ + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + if($this->acl_is_removeable()){ + + $smarty->assign("info", sprintf(_("You're about to delete a fai branch / freeze '%s'."), $this->DivListFai->selectedBranch)); + return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE))); + } else { + print_red (_("You are not allowed to delete this release!")); + } + } + } + + + /**************** + Remove branch confirmed + ****************/ + + if(isset($_POST['delete_branch_confirm'])){ + + /* Check if we have a post remove method configured + * else skip this operation. (Skip:Button in the ui should be disabled in this case too) + */ + if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){ + + $bb = $this->DivListFai->selectedBranch; + if(!isset($ldap)){ + $ldap = $this->config->get_ldap_link(); + } + + $br = $this->getBranches(); + + if(isset($br[$bb]) && $this->acl_is_removeable()){ + $name = $br[$bb]; + $ldap->cd($bb); + $ldap->recursive_remove(); + $ldap->cd(preg_replace('/,ou=fai,ou=configs,ou=systems,/', ',ou=apps,', $bb)); + $ldap->recursive_remove(); + $this->DivListFai->selectedBranch = "main"; + + /* Post remove */ + $this->lock_name = $name; + $this->lock_dn = $bb; + $this->postremove(); + + new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed"); + } + } + } + + + /**************** + Create a new branch "insert Name" + ****************/ + + if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){ + $_SESSION['LASTPOST'] = $_POST; + + if($this->dispNewBranch){ + $type = "branch"; + }else{ + $type = "freeze"; + } + + /* Check branch name */ + $name = $_POST['BranchName']; + $is_ok = true; + $smarty->assign("BranchName",$name); + $base= "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; + + /* Check used characters */ + if(preg_match("/[^0-9a-z \ö\ä\ü\.-_:,]/i",$name)){ + if($type == "branch"){ + print_red(_("Specified branch name is invalid.")); + }else{ + print_red(_("Specified freeze name is invalid.")); + } + $is_ok = false; + } + + /* Check if this name is already in use */ + if(!$this->CheckNewBranchName($_POST['BranchName'],$this->DivListFai->selectedBranch)){ + print_red(_("This name is already in use.")); + $is_ok = false; + } + + if($is_ok){ + $_SESSION['LASTPOST']['base'] = $base; + $_SESSION['LASTPOST']['type'] = $type; + $smarty->assign("iframe", true); + $smarty->assign("plugID", $_GET['plug']); + $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__))); + return($display); + } + } + + + /**************** + Create a new branch + ****************/ + + if(isset($_GET['PerformBranch'])){ + + if(!$this->acl_is_createable()){ + print_red(_("You are not allowed to create a new branch.")); + }else{ + + /* Create it know */ + $this->dispNewBranch = false; + $this->dispNewFreeze = false; + $base = $_SESSION['LASTPOST']['base']; + $_POST = $_SESSION['LASTPOST']; + $name = $_POST['BranchName']; + + $type = $_SESSION['LASTPOST']['type']; + $ldap = $this->config->get_ldap_link(); + + $baseToUse = $base; + if($this->DivListFai->selectedBranch != "main" ){ + $baseToUse = $this->DivListFai->selectedBranch; + } + + /* Create new Release name to be able to set faidebianRelease for FAIpackageList */ + + $CurrentReleases = $this->getBranches(); + $NewReleaseName = $name; + if(isset($CurrentReleases[$this->DivListFai->selectedBranch])) { + if($this->DivListFai->selectedBranch != "main"){ + $NewReleaseName = $CurrentReleases[$this->DivListFai->selectedBranch]."/".$name; + $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName); + }else{ + $NewReleaseName = $name; + } + } + + $appsrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,",$baseToUse); + $appdst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,","ou=".$name.",".$baseToUse) ; + + $mimesrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=mime,",$baseToUse); + $mimedst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=mime,","ou=".$name.",".$baseToUse) ; + + /* Check if source depeartments exist */ + foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){ + $ldap->cd($this->config->current['BASE']); + $ldap->cat($dep); + if(!$ldap->count()){ + $ldap->create_missing_trees($dep); + } + } + + /* Print header to have styles included */ + echo ' + + + + + + + + '; + + new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created"); + + /* Duplicate applications + */ + $ldap->cat($appsrc,array("dn")) ; + if($ldap->count()){ + $ldap->cd ($appdst); + $ldap->recursive_remove(); + $ldap->cd ($this->config->current['BASE']); + $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true); + } + + /* Duplicate mime types + */ + $ldap->cat($mimesrc,array("dn")) ; + if($ldap->count()){ + $ldap->cd ($mimedst); + $ldap->recursive_remove(); + $ldap->cd ($this->config->current['BASE']); + $ldap->copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true); + } + + $attr = array(); + $attr['objectClass'] = array("organizationalUnit","FAIbranch"); + $attr['ou'] = $name; + $attr['FAIstate'] = $type; + $ldap->cd($this->config->current['BASE']); + $ldap->cd("ou=".$name.",".$baseToUse); + $ldap->cat("ou=".$name.",".$baseToUse); + if($ldap->count()){ + $ldap->modify($attr); + }else{ + $ldap->add($attr); + } + + /* Duplicate fai objects + */ + // $ldap->cd ("ou=".$name.",".$baseToUse); + // $ldap->recursive_remove(); + // $ldap->cd ($this->config->current['BASE']); + // $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true); + + echo "
+
+
"; + + echo "" ; + + /* Print footer to have valid html */ + echo ""; + + $this->dispNewFreeze = false; + + /* Postcreate */ + + /* Assign possible attributes */ + $this->lock_type = $type; + $this->lock_name = $name; + $this->lock_dn = $baseToUse; + $this->postcreate(); + exit(); + } + } + + /**************** + Display dialog to enter new Branch name + ****************/ + + /* Check if we have a post create method configured + * else skip this operation. (Skip:Button in the ui should be disabled in this case too) + */ + if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){ + if(($s_action == "branch_branch")||($this->dispNewBranch)){ + if(!$this->acl_is_createable()){ + print_red(_("You are not allowed to create a new branch.")); + }else{ + $this->dispNewBranch=true; + $smarty->assign("iframe",false); + $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__))); + return($display); + } + } + } + + + /**************** + Display dialog to enter new Freeze name + ****************/ + + /* Check if we have a post create method configured + * else skip this operation. (Skip:Button in the ui should be disabled in this case too) + */ + if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){ + if(($s_action == "freeze_branch")||($this->dispNewFreeze)){ + if(!$this->acl_is_createable()){ + print_red(_("You are not allowed to create a new branch.")); + }else{ + $this->dispNewFreeze = true; + $smarty->assign("iframe",false); + $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__))); + return($display); + } + } + } + + + /**************** + Create a new object + ****************/ + + $types = array( "new_partition" => "FAIpartitionTable", + "new_script" => "FAIscript", + "new_hook" => "FAIhook", + "new_variable" => "FAIvariable", + "new_template" => "FAItemplate", + "new_package" => "FAIpackageList"); + + if(isset($types[$s_action])){ + $acl = $this->ui->get_permissions($this->DivListFai->selectedBase,"fai/".$type_acl_mapping[$types[$s_action]]); + if(preg_match("/c/",$acl)){ + $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]); + }else{ + print_red(sprintf(_("You are not allowed to create a new '%s' object."),$types[$s_action])); + } + } + + /* New Profile */ + if($s_action == "new_profile"){ + $this->dn = "new" ; + + $acl = $this->ui->get_permissions($this->DivListFai->selectedBase,"fai/faiProfile"); + if(preg_match("/c/",$acl)){ + $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile"))); + $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai"); + $this->dialog->set_acl_base($this->base); + + $this->is_dialog = false; + }else{ + print_red(sprintf(_("You are not allowed to create a new '%s' object."),"FAIprofile")); + } + } + + + /**************** + Get from ask class name dialog + ****************/ + + if($s_action == "select_class_name_finished"){ + $this->dialog->save_object(); + if(count($this->dialog->check())!=0){ + foreach($this->dialog->check() as $msg){ + print_red($msg); + } + }elseif(isset($this->dialog->objectClass)){ + $this->dn = "new" ; + $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass))); + $name = $this->dialog->save(); + + if(class_exists($a_setup[0])){ + $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai"); + $this->dialog->set_acl_base($this->base); + $this->dialog->by_object[$a_setup[1]]->cn = $name; + $this->is_dialog = true; + } + } + } + + + /**************** + Cancel dialogs + ****************/ + + if(isset($_POST['edit_cancel'])){ + unset($this->dialog); + $this->dialog=FALSE; + $this->is_dialog = false; + unset($_SESSION['objectinfo']); + del_lock ($this->dn); + } + + + /**************** + Save sub dialogs + ****************/ + + /* This check if the given tab could be saved + * If it was possible to save it, remove dialog object. + * If it wasn't possible, show errors and keep dialog. + */ + if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){ + $this->dialog->save_object(); + $msgs= $this->dialog->check(); + if(count($msgs)!=0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $this->dialog->save(); + save_release_changes_now(); + if (!isset($_POST['edit_apply'])){ + del_lock ($this->dn); + unset($this->dialog); + $this->dialog=FALSE; + $this->is_dialog=false; + unset($_SESSION['objectinfo']); + } + } + } + + + /**************** + Display currently open dialog + ****************/ + + /* If dialog is set, but $this->is_dialog==false, then + * only the "abort" button is shown, this are dialogs that must not be saved. + * If is_dialog == true, we are currently editing tab objects. + * Here we need both, save and cancel + */ + + if(is_object($this->dialog)){ + $display .= $this->dialog->execute(); + /* Don't show buttons if tab dialog requests this */ + + if(isset($this->dialog->current)){ + + $obj = $this->dialog->by_object[$this->dialog->current]; + + if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){ + + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + }elseif(!isset($this->dialog->current)){ + $display.= "

\n"; + $display.= " "; + $display.= "\n"; + $display.= "

"; + } + }else{ + $display.= "

\n"; + $display.= " "; + $display.= "\n"; + $display.= "

"; + + } + return($display); + } + + + /**************** + Dialog display + ****************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListFai->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Display dialog with system list */ + $this->DivListFai->parent = $this; + $this->DivListFai->execute(); + $this->DivListFai->AddDepartments($this->DivListFai->selectedBase,4,1); + $this->reload(); + $this->DivListFai->setEntries($this->objects); + return($this->DivListFai->Draw()); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + $tmp = array(); + $types = array("hooks","scripts","disk","packages","profiles","templates","variables"); + foreach($types as $type){ + if($this->DivListFai->selectedBranch == "main"){ + $tmp[] = "ou=".$type.",ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; + }else{ + $tmp[] = "ou=".$type.",".$this->DivListFai->selectedBranch; + } + } + return($tmp); + } + + + /* Get available branches for current base */ + function getBranches($base = false,$prefix = "") + { + $ret = array("/"=>"main"); + $ldap = $this->config->get_ldap_link(); + if(!$base){ + $base= $_SESSION['CurrentMainBase']; + } + $tmp = get_all_releases_from_base($base,true); + foreach($tmp as $dn => $name){ + $ret[$name]=$dn; + } + ksort($ret); + $ret = array_flip($ret); + + return ($ret); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + /* reload list of objects */ + function reload() + { + /* Variable initialisation */ + $str = ""; + $Regex = $this->DivListFai->Regex; + $this->objects = array(); + + /* Get base */ + $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; + if($this->DivListFai->selectedBranch != "main"){ + $br = $this->getBranches(); + if(isset($br[$this->DivListFai->selectedBranch])){ + $base = $this->DivListFai->selectedBranch; + }else{ + $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; + } + } + $this->base = $base; + $this->set_acl_base($this->base); + + $this->lock_type = get_release_tag(get_release_dn($base)); + + /* Create a new list of FAI object + * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... + */ + $ObjectTypes = array( + "FAIpartitionTable" => array("OU"=>"ou=disk," , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"), + "FAIpackageList" => array("OU"=>"ou=packages," , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"), + "FAIscript" => array("OU"=>"ou=scripts," , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"), + "FAIvariable" => array("OU"=>"ou=variables," , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"), + "FAIhook" => array("OU"=>"ou=hooks," , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"), + "FAIprofile" => array("OU"=>"ou=profiles," , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"), + "FAItemplate" => array("OU"=>"ou=templates," , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate")); + + $filter = ""; + foreach($ObjectTypes as $key => $data){ + if($this->DivListFai->$data['CHKBOX']){ + $filter.= "(objectClass=".$key.")"; + } + } + $filter = "(&(|".$filter.")(cn=$Regex))"; + + /* Get resolved release dependencies */ + $tmp = get_all_objects_for_given_base($base,$filter); + + /* Ge listed ldap objects */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + foreach($tmp as $entry){ + + /* Get some more informations about the object */ + $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass")); + $object = $ldap->fetch(); + + /* Walk through possible types */ + foreach($ObjectTypes as $type => $rest){ + + $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']); + + if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){ + + /* Prepare object */ + unset($object['objectClass']['count']); + if(!isset($object['description'][0])){ + $object['description'][0]=""; + } + + /* Clean up object informations */ + $obj = array(); + $obj['cn'] = $object['cn'][0]; + $obj['dn'] = $object['dn']; + $obj['acl'] = $acl; + $obj['description'] = $object['description'][0]; + $obj['objectClass'] = $object['objectClass']; + + /* Append type to this string, to be able to check if the selected + * entry is of type 'freeze' or 'branch' + */ + if(!isset($object['FAIstate'])){ + $obj['FAIstate'] = $this->lock_type; + }else{ + $obj['FAIstate'] = $object['FAIstate'][0]; + } + + $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj; + $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type; + } + } + } + + ksort($this->objects); + reset ($this->objects); + + /* use numeric index, thats a bit more secure */ + $tmp0 = array(); + foreach($this->objects as $obj){ + $tmp0[]= $obj; + } + $this->objects = array(); + $this->objects = $tmp0; + } + + function remove_lock() + { + if (isset($this->dn)){ + del_lock ($this->dn); + } + } + + function get_type($array){ + if(in_array("FAIpartitionTable",$array['objectClass'])){ + return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS")); + } + if(in_array("FAIscript",$array['objectClass'])){ + return(array("tabsScript","faiScript","FAISCRIPTTABS")); + } + if(in_array("FAItemplate",$array['objectClass'])){ + return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS")); + } + if(in_array("FAIhook",$array['objectClass'])){ + return(array("tabsHook","faiHook","FAIHOOKTABS")); + } + if(in_array("FAIvariable",$array['objectClass'])){ + return(array("tabsVariable","faiVariable","FAIVARIABLETABS")); + } + if(in_array("FAIprofile",$array['objectClass'])){ + return(array("tabsProfile","faiProfile","FAIPROFILETABS")); + } + + if(in_array("FAIpackageList",$array['objectClass'])){ + return(array("tabsPackage","faiPackage","FAIPACKAGETABS")); + } + } + + function CheckNewBranchName($name,$base) + { + $f = $this->DivListFai->selectedBranch; + if($name == ""){ + return(false); + }elseif(in_array($name,$this->getBranches($f))) { + return(false); + }elseif(is_department_name_reserved($name,$base)){ + return(false); + } + return(true); + } + + function save_object() + { + $this->DivListFai->save_object(); + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + $base = $this->DivListFai->selectedBranch; + if($base == "main"){ + $base = $this->DivListFai->selectedBase; + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $entry = $this->objects[$s_entry]; + $a_setup = $this->get_type($entry); + $dn = $entry['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + + /* Cleanup object queue */ + $entry = $this->objects[$id]; + $a_setup = $this->get_type($entry); + $dn = $entry['dn']; + + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$base); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + save_release_changes_now(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("FAI releases"), + "plDescription" => _("FAI release management"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("fai"=> array("description" => _("FAI"), + "objectClass" => "FAIclass")), + "plProvidedAcls"=> array())); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiPackage.inc b/gosa-core/plugins/admin/fai/class_faiPackage.inc new file mode 100644 index 000000000..bcd5eaaf6 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiPackage.inc @@ -0,0 +1,670 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description","FAIpackage","FAIdebianRelease","FAIdebianSection", "FAIinstallMethod"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIpackageList","FAIrepository"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = ""; + var $subClasses = array("top","FAIclass","FAIscriptEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = ""; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description"); + var $sub64coded = array(); + + var $ConfiguredPackages = array(); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $SubObjects = array(); // All leafobjects of this object + + var $FAIdebianRelease = ""; // The selected release + var $FAIdebianSection = array(); // selected section + var $FAIinstallMethod = "aptitude"; // hard coded + var $mirror = ""; // selected mirror + + var $servers = array(); // All available servers + var $releases = array(); // All possible releases + var $sections = array(); // All section types + + var $list = NULL; + + var $mirrors = array(); // The combination of server/release/section + var $confDir = ""; + var $usedPackages = array(); + var $buffer = NULL; + var $strID =""; + var $newDialogShown =false; + + var $FAIstate = ""; + var $view_logged = FALSE; + var $base; + + var $FAIinstallMethods = array( "install", "ninstall", "remove", + "dselect-upgrade", "taskinst", "taskrm", + "hold", "clean", "aptitude", "aptitude-r", + "pending", "dpkgc" ); + + + function faiPackage (&$config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. + */ + if($dn != "new"){ + $this->dn =$dn; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + } + + if(isset($this->attrs['FAIpackage'])){ + unset($this->attrs['FAIpackage']['count']); + foreach($this->attrs['FAIpackage'] as $pkg){ + $this->usedPackages[$pkg] = $pkg; + } + ksort($this->usedPackages); + }else{ + $this->usedPackages = array(); + } + + if($dn != "new"){ + + /* Create one filter with all package names, + instead of calling $ldap->search for every single package + */ + $PackageFilter = ""; + foreach($this->usedPackages as $name){ + $PackageFilter .= "(FAIpackage=".$name.")"; + } + $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))"; + + /* Search for configuration objects */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate")); + + /* Walk through configurations and append them to our list of ConfiguredPackages */ + while($attr = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$attr['FAIstate'][0])){ + continue; + } + } + + $tmp =array(); + $tmp['Name'] = $attr['FAIvariable'][0]; + $tmp['Type'] = $attr['FAIvariableType'][0]; + + if (isset($attr['FAIvariableContent'][0])){ + if(!in_array($attr['FAIvariableType'],array("multiselect"))){ + $tmp['Value'] = $attr['FAIvariableContent'][0]; + }else{ + $content = array(); + unset($attr['FAIvariableContent']['count']); + foreach($attr['FAIvariableContent'] as $attr){ + $tmp['Value'][] = $attr; + } + } + $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp; + } + } + } + + if (isset($this->attrs['FAIdebianSection']['count'])){ + unset($this->attrs['FAIdebianSection']['count']); + } + if((isset($this->attrs['FAIdebianSection']))&&(is_array($this->attrs['FAIdebianSection']))){ + $this->FAIdebianSection = array(); + foreach($this->attrs['FAIdebianSection'] as $sec){ + $this->FAIdebianSection[$sec]=$sec; + } + } + + if((isset($this->attrs['FAIdebianSection']))&&(is_string($this->attrs['FAIdebianSection']))){ + $this->FAIdebianSection=array($this->attrs['FAIdebianSection']=>$this->attrs['FAIdebianSection']) ; + } + $this->confDir = CONFIG_DIR."/fai/"; + $this->FAIpackage = array(); + + + $methods = array(); + foreach($this->FAIinstallMethods as $method){ + $methods[$method] = $method; + } + $this->FAIinstallMethods = $methods; + /* Check if we exist already - no need to ask for revisions, etc. then */ + if ($this->dn != "new"){ + $this->newDialogShown= true; + } + + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","fai/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $smarty->assign( "FAIinstallMethods", $this->FAIinstallMethods ); + + if(!$this->is_account){ + + /* Assemble release name */ + $tmp= preg_replace('/,ou=fai,ou=configs,ou=systems,.*$/', '', $_SESSION['faifilter']['branch']); + $tmp= preg_replace('/ou=/', '', $tmp); + $rev= array_reverse(split(',', $tmp)); + $this->FAIdebianRelease= ""; + foreach ($rev as $part){ + $this->FAIdebianRelease.= "/$part"; + } + $this->FAIdebianRelease= preg_replace('#^/#', '', $this->FAIdebianRelease); + + /* Assemble sections */ + $repos= $this->getServerInfos(); + if(isset($repos[$this->FAIdebianRelease])){ + $this->FAIdebianSection= $repos[$this->FAIdebianRelease]; + $this->FAIdebianSection= array_unique($this->FAIdebianSection); + } + + /* Assign Repository settings*/ + $this->is_account = true; + } + + /* Assign variables */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + /* Generate package list */ + $this->list= $this->genPkgs(); + + /* + was pressed to open the package dialog */ + if(isset($_POST['Addpkg']) && $this->acl_is_writeable("FAIpackage")){ + $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->list,$this->usedPackages); + $this->is_dialog =true; + } + + /* Delte selected package */ + if(isset($_POST['Delpkg']) && $this->acl_is_writeable("FAIpackage")){ + if($this->FAIstate != "freeze"){ + foreach($_POST['usedPackages'] as $del){ + if(isset($this->usedPackages[$del])){ + unset($this->usedPackages[$del]); + } + } + } + } + + /* Abort package selection dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->dialog = false; + $this->is_dialog=false; + } + + /* attach new packages */ + if(isset($_POST['SaveSubObject'])) { + if($this->FAIstate != "freeze"){ + $this->dialog->save_object(); + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msgs){ + print_red($msgs); + } + }else{ + $use = $this->dialog->save(); + $this->usedPackages = $use; + $this->dialog = false; + $this->is_dialog=false; + ksort($this->usedPackages); + } + }else{ + $this->dialog = false; + $this->is_dialog=false; + } + } + + /* Configuration dialog open*/ + if((isset($_POST['Conpkg']))&&(isset($_POST['usedPackages']))&&(!empty($_POST['usedPackages'][0])) && $this->acl_is_writeable("FAIdebconfInfo")){ + $path = CONFIG_DIR."/fai/".$this->FAIdebianRelease."/debconf.d"; + $pkg_config = array(); + $pkg = $_POST['usedPackages'][0]; + + if(isset($this->ConfiguredPackages[$pkg])){ + $pkg_config = $this->ConfiguredPackages[$pkg]; + } + + $this->dialog = new faiPackageConfiguration($this->config, $this->dn,$pkg, $path, $pkg_config); + $this->is_dialog =true; + } + + /* Configuration dialog open*/ + if($this->FAIstate != "freeze" && $this->acl_is_writeable("FAIpackage")){ + if((isset($_POST['Markpkg']))&&(isset($_POST['usedPackages']))&&(!empty($_POST['usedPackages']))){ + foreach($_POST['usedPackages'] as $pkg){ + if (isset($this->usedPackages[$pkg])){ + unset($this->usedPackages[$pkg]); + if (preg_match('/^-/', $pkg)){ + $pkg= preg_replace('/^-/', '', $pkg); + } else { + $pkg= preg_replace('/^/', '-', $pkg); + } + $this->usedPackages[$pkg]= $pkg; + } + } + } + } + + /* Save Configuration */ + if(isset($_POST['SaveObjectConfig'])){ + if($this->FAIstate != "freeze"){ + $this->ConfiguredPackages= array_merge($this->ConfiguredPackages,$this->dialog->save()); + } + $this->dialog = false; + $this->is_dialog=false; + } + + /* cancel configuration */ + if(isset($_POST['CancelObjectConfig'])){ + $this->dialog = false; + $this->is_dialog=false; + } + + /* Display dialog */ + if($this->is_dialog){ + return $this->dialog->execute(); + } + + /* Assign section to smarty */ + $strsec = ""; + foreach($this->FAIdebianSection as $sec){ + $strsec .= $sec." "; + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/",$this->FAIstate))); + } + + $smarty->assign("releases",$this->releases); + $smarty->assign("release" ,$this->FAIdebianRelease); + $smarty->assign("sections",$this->sections); + $smarty->assign("section" ,$strsec); + $smarty->assign("usedPackages",$this->printUsedPackages()); + $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); + return($display); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $this->dn; + } + + prepare_to_save_FAI_object($use_dn,array(),true); + + new log("remove","fai/".get_class($this),$use_dn,$this->attributes); + + foreach($this->ConfiguredPackages as $pkgname => $attrs){ + foreach($attrs as $name => $attr){ + $pkgdn = "FAIvariable=".$name.",".$this->dn; +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $pkgdn); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $pkgdn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $obj['dn']; + } + prepare_to_save_FAI_object($use_dn,array(),true); + } + } + $this->handle_post_events("remove"); + } + + + /* Save data to object + */ + function save_object() + { + if($this->FAIstate == "freeze") return; + plugin::save_object(); + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(count($this->usedPackages)==0){ + $message[]=_("Please select a least one Package."); + } + + if((empty($this->FAIdebianRelease))||(empty($this->FAIdebianSection))){ + $message[]=_("Please choose a valid combination for your repository setup."); + } + + return ($message); + } + + function printUsedPackages(){ + $a_ret=array(); + if(is_array($this->usedPackages)) { + foreach($this->usedPackages as $usedName){ + + $config = 0; + + foreach($this->ConfiguredPackages as $name => $value){ + if($name == $usedName){ + $config ++; + } + } + + $c_str =""; + if($config){ + $c_str = " - "._("package is configured"); + } + + /* Adapt used name if we're marked for removal */ + $dsc= ""; + if (preg_match('/^-/', $usedName)){ + $dsc= " - "._("Package marked for removal"); + // Generally a bad idea here, because the toggel triggers on -, not on ! + //$usedName= preg_replace('/^-/', '! ', $usedName); + }else{ + $usedName2= $usedName; + } + + if(isset($this->list[$usedName][1])){ + $a_ret[$usedName] = $usedName2." [".$this->list[$usedName][1]."]".$c_str.$dsc; + }else{ + $a_ret[$usedName] = $usedName2.$c_str.$dsc; + } + } + } + return($a_ret); + } + + function genPkgs() + { + /* Generate a list off available packages for this mirror, section and release + */ + /* Only read this file if it wasn't read before */ + if($this->buffer === NULL){ + $this->buffer=array(); + $a_ret = array(); + foreach($this->FAIdebianSection as $sec){ + $strID= CONFIG_DIR."/fai/".$this->FAIdebianRelease."/".$sec; + + if(!is_file($strID)){ + print_red(sprintf(_("Package file '%s' does not exist."),$strID)); + unset($this->buffer); + return(array()); + } + $fp = fopen($strID,"r"); + + /* Parse every line and create an array */ + while(!feof($fp)){ + $str= fgets($fp,512); + $stra= split("\|",$str); + if(count($stra)==4){ + $a_ret[$stra[0]] = $stra; + } + } + fclose($fp); + /* Save our Data, to avoid reading it again */ + } + $this->buffer = $a_ret; + ksort($a_ret); + return($a_ret); + }else{ + return $this->buffer; + } + } + + + /* Save to LDAP */ + function save() + { + + /* Assemble release name */ + if($this->FAIdebianRelease == "ClearFromCopyPaste"){ + $tmp= preg_replace('/,ou=fai,ou=configs,ou=systems,.*$/', '', $_SESSION['faifilter']['branch']); + $tmp= preg_replace('/ou=/', '', $tmp); + $rev= array_reverse(split(',', $tmp)); + $this->FAIdebianRelease= ""; + foreach ($rev as $part){ + $this->FAIdebianRelease.= "/$part"; + } + $this->FAIdebianRelease= preg_replace('#^/#', '', $this->FAIdebianRelease); + } + + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $this->attrs['FAIpackage'] = array(); + foreach($this->usedPackages as $pkg => $obj){ + $this->attrs['FAIpackage'][] = $pkg; + } + + $this->attrs['FAIdebianSection'] = array(); + foreach($this->FAIdebianSection as $sec){ + $this->attrs['FAIdebianSection'][] = $sec; + } + + prepare_to_save_FAI_object($this->dn,$this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/package list with dn '%s' failed."),$this->dn)); + + if($this->initially_was_account){ + new log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + new log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + + /* Do object tagging */ + $this->handle_object_tagging(); + $ldap->cd($this->dn); + + /* Save Package configurations */ + foreach($this->ConfiguredPackages as $pkgname => $attrs){ + foreach($attrs as $name => $attr){ + + $pkgattrs = array(); + + foreach($attr as $n=>$v){ + if(empty($v)) $v = array(); + } + + /* Set attributes */ + $pkgattrs['objectClass'][] = "FAIdebconfInfo"; + + $pkgattrs['FAIpackage'] = $pkgname; + $pkgattrs['FAIvariable'] = $name; + $pkgattrs['FAIvariableType'] = $attr['Type']; + $pkgattrs['FAIvariableContent'] = $attr['Value']; + $pkgdn = "FAIvariable=".$name.",".$this->dn; + + /* cehck if object already exists */ + $ldap->cat($pkgdn,array("objectClass")); + + /* Workaround for missing "gosaAdministrativeUnitTag" */ + $attrs = $ldap->fetch(); + if((isset($attrs['objectClass'])) && (in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass']))){ + $pkgattrs['objectClass'][] = "gosaAdministrativeUnitTag"; + } + + if(in_array($pkgattrs['FAIvariableType'],array("boolean","multiselect","password","select","string","text"))){ + prepare_to_save_FAI_object($pkgdn,$pkgattrs); + } + + /* Handle tagging */ + $this->handle_object_tagging($pkgdn, $this->gosaUnitTag); + } + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Package"), + "plDescription" => _("FAI Package list"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 28, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name"), + "description" => _("Description"), + "FAIpackage" => _("Packages"), + "FAIdebianSection" => _("Section")." ("._("Readonly").")", + "FAIinstallMethod" => _("Install Method"), + "FAIdebconfInfo" => _("Package configuration"), + "FAIdebianRelease" => _("Release")." ("._("Readonly").")") + )); + } + + + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + if(isset($source['FAIstate'][0])){ + $this->FAIstate = $source['FAIstate'][0]; + } + + $this->FAIdebianRelease = "ClearFromCopyPaste"; + + if(isset($source['FAIpackage'])){ + unset($source['FAIpackage']['count']); + foreach($source['FAIpackage'] as $pkg){ + $this->usedPackages[$pkg] = $pkg; + } + ksort($this->usedPackages); + }else{ + $this->usedPackages = array(); + } + + if((isset($source['FAIdebianSection']))&&(is_array($source['FAIdebianSection']))){ + $this->FAIdebianSection = array(); + for($i = 0 ; $i < $source['FAIdebianSection']['count'] ; $i ++){ + $this->FAIdebianSection[$source['FAIdebianSection'][$i]]=$source['FAIdebianSection'][$i]; + } + } + + /* Create one filter with all package names, + instead of calling $ldap->search for every single package + */ + $PackageFilter = ""; + foreach($this->usedPackages as $name){ + $PackageFilter .= "(FAIpackage=".$name.")"; + } + $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))"; + + /* Search for configuration objects */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($source['dn']); + $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate")); + + /* Walk through configurations and append them to our list of ConfiguredPackages */ + while($attr = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$attr['FAIstate'][0])){ + continue; + } + } + + $tmp =array(); + $tmp['Name'] = $attr['FAIvariable'][0]; + $tmp['Type'] = $attr['FAIvariableType'][0]; + + if (isset($attr['FAIvariableContent'][0])){ + if(!in_array($attr['FAIvariableType'],array("multiselect"))){ + $tmp['Value'] = $attr['FAIvariableContent'][0]; + }else{ + $content = array(); + unset($attr['FAIvariableContent']['count']); + foreach($attr['FAIvariableContent'] as $attr){ + $tmp['Value'][] = $attr; + } + } + $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp; + } + } + } + + + function getServerInfos() + { + $ret = array(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=FAIrepositoryServer)",array("*")); + while($attrs = $ldap->fetch()){ + if(isset($attrs['FAIrepository'])){ + for($i =0 ; $i < $attrs['FAIrepository']['count']; $i++){ + $obj = $attrs['FAIrepository'][$i]; + $tmp = split("\|",$obj); + if(count($tmp)==4){ + foreach(split(",",$tmp[3]) as $sec){ + if(!empty($sec)){ + $ret[$tmp[2]][] = $sec; + } + } + } + } + } + } + return($ret); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiPackageConfiguration.inc b/gosa-core/plugins/admin/fai/class_faiPackageConfiguration.inc new file mode 100644 index 000000000..18f3e2b6c --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiPackageConfiguration.inc @@ -0,0 +1,84 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array(); + + var $Debconf_handle = NULL; + var $pkg_config ; + var $obj; + + function faiPackageConfiguration (&$config, $dn= NULL,$obj,$path,$pkg_config) + { + plugin::plugin ($config, $dn); + $this->obj = $obj; + $this->Debconf_handle = new debconf(); + $this->Debconf_handle->set_template_directory($path); + $this->Debconf_handle->set_package($this->obj); + $this->Debconf_handle->set_language(preg_replace('/_.*$/', '', get_browser_language())); + + if( $this->Debconf_handle->load() ) { + $this->pkg_config = $pkg_config; + + foreach($this->pkg_config as $var){ + $this->Debconf_handle->SetDefault($var['Name'],$var['Value']); + } + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + $smarty->assign("headline", sprintf(_("Debconf information for package '%s'"), $this->obj)); + + $this->Debconf_handle->PostCheck(); + + $smarty->assign("Config",$this->Debconf_handle->get_dialog()); + + $display.= $smarty->fetch(get_template_path('faiPackageConfiguration.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + function save() + { + $this->Debconf_handle->PostCheck(); + $pkgs = $this->Debconf_handle->template; + + $tmp = array(); + foreach($pkgs as $pkg){ + $tmp[$this->obj][$pkg['Name']]['Value']= $pkg['Default']; + $tmp[$this->obj][$pkg['Name']]['Name'] = $pkg['Name']; + $tmp[$this->obj][$pkg['Name']]['Type'] = $pkg['Type']; + } + return($tmp); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiPackageEntry.inc b/gosa-core/plugins/admin/fai/class_faiPackageEntry.inc new file mode 100644 index 000000000..1b22ba869 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiPackageEntry.inc @@ -0,0 +1,200 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array(); + var $objectclasses= array(); + var $pkgs = array(); + + var $buffer = array(); + var $categories = array(); + var $searchStrPKG = ""; + var $selected = array(); + + /* Array with available class names */ + var $FAIAllclasses = array(); + + function faiPackageEntry (&$config, $dn= NULL,$pkgs,$selected=array()) + { + plugin::plugin ($config, $dn); + + $this->pkgs=$pkgs; + + if(isset($_SESSION['searchStrPKG'])){ + $this->searchStrPKG=$_SESSION['searchStrPKG']; + } + $this->selected=$selected; + + $this->searchStrPKG= _("Please enter your search string here"); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + $divlist = new divlist("PackageEntry"); + $divlist->SetPluginMode(); + $divlist->SetSummary(_("This list displays all assigned package names for this repository settings.")); + $divlist->SetEntriesPerPage(0); + $divlist->SetHeight("650px;"); + $divlist->SetHeader(array(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), + array("string" => "Name", "attach" => "style='width:180px;'"), + array("string" => "Version", "attach" ), + array("string" => "Description", "attach" => "style='width:240px;border-right:0px;text-align:left;'"))); + + if(isset($_GET['search'])){ + $this->searchStrPKG= $_GET['search']."*"; + } + + $pkgs= $this->pkgs; + + unset($this->categories); + foreach($pkgs as $name => $entry){ + $cat = $entry[2]; + if(!empty($cat)){ + if(!isset($this->categories[$cat])){ + $this->categories[$cat] = true; + } + if(isset($_POST['chkchange'])){ + $this->searchStrPKG = $_POST['searchStrPKG']; + if(isset($_POST['CAT'.$cat])){ + $this->categories[$cat]=true; + }else{ + $this->categories[$cat]=false; + } + } + } + } + + $this->searchStrPKG = preg_replace("/^\+/","",$this->searchStrPKG); + if(empty($this->searchStrPKG)){ + $this->searchStrPKG = "*"; + } + + @ksort($this->categories); + +$CHKS = ""; + $i = 0; + if(is_array($this->categories)) + foreach($this->categories as $cat => $selected){ + if($i == 3){ + $CHKS .=""; + $i = 0; + } + $i ++ ; + if($selected){ + $CHKS .=""; + }else{ + $CHKS .=""; + } + } + $CHKS .= "
 ".$cat."  ".$cat." 
"; + + + foreach($_POST as $name => $value){ + if(preg_match("/^wasonpage_/i",$name)){ + $name = preg_replace("/^wasonpage_/","",$name); + $n =base64_decode($name); + + if(isset($_POST['use_'.$name])){ + $this->selected[$n] = $n; + }else{ + if(isset($this->selected[$n])){ + unset($this->selected[$n]); + } + } + + } + } + + /* Prepare search filter */ + $search_str = preg_replace("/\\\\\*/",".*",normalizePreg($this->searchStrPKG)); + + $cnt = 0; + foreach($pkgs as $pkg){ + if($cnt > 200) { + print_red(sprintf(_("Your specified search string '%s' returned too many results. Only the first 200 entries are shown, to keep the memory usage low."),$this->searchStrPKG)); + break; + } + if((preg_match("/^".$search_str."/i",$pkg[0]))|| + (preg_match("/^".$search_str."/i",$pkg[3]))){ + if($this->categories[$pkg[2]]){ + if(in_array($pkg[0],$this->selected)){ + $check = " checked "; + }else{ + $check = ""; + } + $cnt ++ ; + $chkbox = " + "; + $divlist->AddEntry(array(array("string"=>$chkbox, "attach" => "style='text-align:center;width:20px;'"), + array("string"=>$pkg[0], "attach" => "style='width:180px;'"), + array("string"=>htmlentities($pkg[1])), + array("string"=>htmlentities($pkg[3]), "attach" => "style='width:221px;border-right:0px;text-align:left;'"))); + } + } + } + + $_SESSION['searchStrPKG'] = $this->searchStrPKG; + $smarty->assign("CHKS" , $CHKS); + $smarty->assign("searchStrPKG" , $this->searchStrPKG); + $smarty->assign("faihead" , ""); + $smarty->assign("failist" , $divlist->DrawList()); + $smarty->assign("infoimage" , get_template_path('images/info.png')); + $smarty->assign("launchimage" , get_template_path('images/launch.png')); + $smarty->assign("alphabet" , generate_alphabet()); + $smarty->assign("apply" , apply_filter(TRUE)); + $smarty->assign("search_image" , get_template_path('images/search.png')); + + $display.= $smarty->fetch(get_template_path('faiPackageEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + foreach($_POST as $name => $value){ + if(preg_match("/^wasonpage_/i",$name)){ + $name = preg_replace("/^wasonpage_/","",$name); + $n =base64_decode($name); + if(isset($_POST['use_'.$name])){ + $this->selected[$n] = $n; + }else{ + if(isset($this->selected[$n])){ + unset($this->selected[$n]); + } + } + + } + } + + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + function save() + { + return($this->selected); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiPartitionTable.inc b/gosa-core/plugins/admin/fai/class_faiPartitionTable.inc new file mode 100644 index 000000000..216d6c3ed --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiPartitionTable.inc @@ -0,0 +1,621 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("cn","description"); + var $objectclasses = array("top","FAIclass","FAIpartitionTable"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $disks = array(); // All defined Disks + var $is_dialog = false; // specifies which buttons will be shown to save or abort + + var $FAIstate = ""; + var $ui; + + var $view_logged = FALSE; + + function faiPartitionTable (&$config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + $this->acl ="#all#"; + + $this->ui = get_userinfo(); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read disks from ldap ... and then the partition definitions for the disks. + */ + if($dn != "new"){ + $this->dn =$dn; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + /* Read all disks from ldap taht are defined fot this partition table + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))",array("*")); + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + $this->disks[$object['cn'][0]]['status'] = "edited"; + $this->disks[$object['cn'][0]]['dn'] = $object['dn']; + $this->disks[$object['cn'][0]]['cn'] = $object['cn'][0]; + if(isset($object['description'][0])){ + $this->disks[$object['cn'][0]]['description'] = $object['description'][0]; + }else{ + $this->disks[$object['cn'][0]]['description'] = ""; + } + $this->disks[$object['cn'][0]]['partitions'] = array(); + } + + /* read all partitions for each disk + */ + foreach($this->disks as $name => $disk){ + $ldap->cd ($disk['dn']); + $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))",array("*")); + while($partition = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($partition['FAIstate'][0])){ + if(preg_match("/removed$/",$partition['FAIstate'][0])){ + continue; + } + } + + /* remove count ... from ldap result + */ + foreach($partition as $key=>$val){ + if((is_numeric($key))||($key=="count")||($key=="dn")){ + unset($partition[$key]); + }else{ + $partition[$key] = $val[0]; + } + } + + /* Append fetched partitions + */ + $partition['status']="edited"; + $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; + } + } + } + ksort($this->disks); + } + + + function acl_base_for_current_object($dn) + { + if($dn == "new"){ + if($this->dn == "new"){ + $dn= $_SESSION['CurrentMainBase']; + }else{ + $dn = $this->dn; + } + } + return($dn); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","fai/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add Disk to this Partitionset + * This code adds a new HDD to the disks + * A new Dialog will be opened + */ + if(isset($_POST['AddDisk'])){ + $usedDiskNames =array(); + foreach($this->disks as $key=>$disk){ + $usedDiskNames[]= $key; + } + $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); + $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn)); + $this->dialog->set_acl_category("fai"); + $this->dialog->FAIstate = $this->FAIstate; + $this->is_dialog = true; + } + + /* Edit disk. + * Open dialog which allows us to edit the selected entry + */ + + if($this->dn != "new"){ + $_SESSION['objectinfo']= $this->dn; + } + + if((isset($_POST['EditDisk']))&&(isset($_POST['disks']))){ + $usedDiskNames =array(); + $Udisk = $_POST['disks'][0]; + if(isset($this->disks[$Udisk])){ + + foreach($this->disks as $key=>$disk){ + if($key != $Udisk){ + $usedDiskNames[]= $key; + } + } + + /* Set object info string, which will be displayed in plugin info line */ + if(isset($this->disks[$Udisk]['dn'])){ + $_SESSION['objectinfo'] = $this->disks[$Udisk]['dn']; + $dn = $this->disks[$Udisk]['dn']; + }else{ + $_SESSION['objectinfo'] = ""; + $dn = "new"; + } + + $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); + $this->dialog->set_acl_base($this->acl_base_for_current_object($dn)); + $this->dialog->set_acl_category("fai"); + $this->dialog->FAIstate = $this->FAIstate; + + $this->is_dialog = true; + } + } + + /* Edit aborted, close dialog, without saving anything + */ + if(isset($_POST['CancelDisk'])){ + unset($this->dialog); + $this->dialog = FALSE; + $this->is_dialog=false; + } + + /* Dialog saved + * Save given data from Dialog, if no error is occurred + */ + if(isset($_POST['SaveDisk'])){ + + if($this->FAIstate != "freeze"){ + $this->dialog->save_object(); + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msg){ + print_red($msg); + } + }else{ + $disk = $this->dialog->save(); + if(isset($disk['rename'])){ + if($this->disks[$disk['rename']['from']]['status']=="edited"){ + $this->disks[$disk['rename']['from']]['status']="delete"; + }else{ + unset($this->disks[$disk['rename']['from']]); + } + + foreach($disk['partitions'] as $key => $val){ + if($disk['partitions'][$key]['status']!="delete"){ + $disk['partitions'][$key]['status']= "new"; + } + } + + $disk['status']="new"; + $disk['cn']= $disk['rename']['to']; + } + + $this->disks[$disk['cn']]=$disk; + unset($this->dialog); + $this->dialog = FALSE; + $this->is_dialog=false; + ksort($this->disks); + } + }else{ + $this->dialog = FALSE; + $this->is_dialog=false; + } + } + + /* Delete selected disk drive from list + * Assign delete status for all its partitions + */ + if((isset($_POST['DelDisk']))&&(!empty($_POST['disks']))){ + if($this->FAIstate != "freeze"){ + foreach($_POST['disks'] as $disk) { + + if(isset($this->disks[$disk])){ + if($this->disks[$disk]['status']=="edited"){ + $this->disks[$disk."-delete"]=$this->disks[$disk]; + unset($this->disks[$disk]); + $disk = $disk."-delete"; + $this->disks[$disk]['status']="delete"; + foreach($this->disks[$disk]['partitions'] as $name => $value ){ + if($value['status']=="edited"){ + $this->disks[$disk]['partitions'][$name]['status']="delete"; + }else{ + unset($this->disks[$disk]['partitions'][$name]); + } + } + }else{ + unset($this->disks[$disk]); + } + } + } + } + } + + /* Display dialog if one is defined + */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + /* Assign all attributes to smarty engine + */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + if($this->$attrs){ + $smarty->assign($attrs."CHK"," "); + }else{ + $smarty->assign($attrs."CHK"," disabled "); + } + } + + $dn = $this->acl_base_for_current_object($this->dn); + $smarty->assign("sub_object_is_addable", + preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiPartitionTableEntry")) && + !preg_match("/freeze/",$this->FAIstate)); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + $disks = $this->getDisks(); + $smarty->assign("disks" ,$disks); + $display.= $smarty->fetch(get_template_path('faiPartitionTable.tpl', TRUE)); + return($display); + } + + function getDisks(){ + /* Return all available disks for this partition table + * Return in listBox friendly array + */ + $a_return = array(); + foreach($this->disks as $key => $disk){ + + $dn = "new"; + if(isset($obj['dn'])){ + $dn = $obj['dn']; + } + $dn = $this->acl_base_for_current_object($dn); + $acl = $this->ui->get_permissions($dn,"fai/faiPartitionTableEntry"); + if(preg_match("/(r|w)/",$acl)) { + + if($disk['status'] != "delete"){ + $cnt=0; + foreach($disk['partitions'] as $val){ + if($val['status']!="delete"){ + $cnt ++; + } + } + if(!empty($disk['description'])){ + if($cnt == 1){ + $a_return[$key]= $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition"), $cnt); + }else{ + $a_return[$key]= $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition(s)"), $cnt); + } + }else{ + if($cnt == 1){ + $a_return[$key]= $disk['cn'].", ".sprintf(_("%s partition"), $cnt); + }else{ + $a_return[$key]= $disk['cn'].", ".sprintf(_("%s partition(s)"), $cnt); + } + } + } + } + } + return($a_return); + } + + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $this->dn; + } + + prepare_to_save_FAI_object($use_dn,array(),true); + + new log("remove","fai/".get_class($this),$use_dn,$this->attributes); + + foreach($this->disks as $disk){ + + $disk_dn = "cn=".$disk['cn'].",".$this->dn; +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $disk_dn); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $disk_dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $disk_dn; + } + prepare_to_save_FAI_object($use_dn,array(),true); + + foreach($disk['partitions'] as $key => $partition){ + + $partition_dn= "FAIpartitionNr=".$partition['FAIpartitionNr'].",".$disk_dn; +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $partition_dn); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $partition_dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $disk_dn; + } + prepare_to_save_FAI_object($use_dn,array(),true); + } + } + } + + + /* Save data to object + */ + function save_object() + { + if($this->FAIstate == "freeze") return; + plugin::save_object(); + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + + plugin::save(); + /* Save current settings. + * 1 : We must save the partition table, with its description and cn + * 2 : Append Disk with cn and description. + * 3 : Save partitions for each disk + */ + + $ldap = $this->config->get_ldap_link(); + + prepare_to_save_FAI_object($this->dn,$this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/partition table with dn '%s' failed."),$this->dn)); + + if($this->initially_was_account){ + new log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + new log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + + /* Do object tagging */ + $this->handle_object_tagging(); + + /* Sort entries, because we must delete entries with status="delete" first */ + $order = array(); + foreach($this->disks as $key => $disk){ + if($disk['status'] == "delete"){ + $order[$key] = $disk; + } + } + foreach($this->disks as $key => $disk){ + if($disk['status'] != "delete"){ + $order[$key] = $disk; + } + } + + /* Append all disks to ldap */ + foreach($order as $cn=>$disk){ + $disk_dn = "cn=".$disk['cn'].",".$this->dn; + $disk_attrs['cn'] = $disk['cn']; + $disk_attrs['description'] = $disk['description']; + $disk_attrs['objectClass'] = array("top","FAIclass","FAIpartitionDisk"); + + if($disk['status']=="new"){ + $ldap->cat($disk_dn,array("objectClass")); + if($ldap->count()){ + $disk['status']="edited"; + } + } + + /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for disks */ + $ldap->cat($disk_dn,array("objectClass")); + $attrs = $ldap->fetch(); + if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ + $disk_attrs['objectClass'][] = "gosaAdministrativeUnitTag"; + } + + if($disk['status'] == "delete"){ + prepare_to_save_FAI_object($disk_dn,array(),true); + $this->handle_post_events("remove"); + }elseif($disk['status'] == "edited"){ + prepare_to_save_FAI_object($disk_dn,$disk_attrs); + $this->handle_post_events("modify"); + }elseif($disk['status']=="new"){ + prepare_to_save_FAI_object($disk_dn,$disk_attrs); + $this->handle_post_events("add"); + } + + $this->handle_object_tagging($disk_dn, $this->gosaUnitTag); + + if($disk['status']!="delete") + /* Add all partitions */ + foreach($disk['partitions'] as $key => $partition){ + $partition_attrs = array(); + + foreach($partition as $key => $value){ + if(!empty($value)){ + $partition_attrs[$key]=$value; + }else{ + unset($partition_attrs[$key]); + } + } + + $partition_dn= "FAIpartitionNr=".$partition_attrs['FAIpartitionNr'].",".$disk_dn; + $partition_attrs['objectClass']= array("top","FAIclass","FAIpartitionEntry"); + $partition_attrs['cn']= $partition_attrs['FAIpartitionNr']; + + unset($partition_attrs['status']); + unset($partition_attrs['old_cn']); + + if($partition['status']=="new"){ + $ldap->cat($partition_dn,array("objectClass")); + if($ldap->count()){ + $partition['status']="edited"; + } + } + + if((!isset($partition['FAImountPoint']))||(empty($partition['FAImountPoint']))){ + $partition_attrs['FAImountPoint']="swap"; + } + + /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for partitions */ + $ldap->cat($partition_dn,array("objectClass")); + $attrs = $ldap->fetch(); + if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ + $partition_attrs['objectClass'][] = "gosaAdministrativeUnitTag"; + } + + if($partition['status'] == "delete"){ + prepare_to_save_FAI_object($partition_dn,array(),true); + $this->handle_post_events("remove"); + }elseif($partition['status'] == "edited"){ + prepare_to_save_FAI_object($partition_dn,$partition_attrs); + $this->handle_post_events("modify"); + }elseif($partition['status']=="new"){ + prepare_to_save_FAI_object($partition_dn,$partition_attrs); + $this->handle_post_events("add"); + } + + $this->handle_object_tagging($partition_dn, $this->gosaUnitTag); + } + } + $this->handle_post_events("add"); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + /* Get FAIstate + */ + if(isset($source['FAIstate'][0])){ + $this->FAIstate = $source['FAIstate'][0]; + } + + /* Read all disks from ldap taht are defined fot this partition table + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($source['dn']); + $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))",array("*")); + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + $this->disks[$object['cn'][0]]['status'] = "edited"; + $this->disks[$object['cn'][0]]['dn'] = $object['dn']; + $this->disks[$object['cn'][0]]['cn'] = $object['cn'][0]; + if(isset($object['description'][0])){ + $this->disks[$object['cn'][0]]['description'] = $object['description'][0]; + }else{ + $this->disks[$object['cn'][0]]['description'] = ""; + } + $this->disks[$object['cn'][0]]['partitions'] = array(); + } + + /* read all partitions for each disk + */ + foreach($this->disks as $name => $disk){ + $ldap->cd ($disk['dn']); + $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))",array("*")); + while($partition = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($partition['FAIstate'][0])){ + if(preg_match("/removed$/",$partition['FAIstate'][0])){ + continue; + } + } + + /* remove count ... from ldap result + */ + foreach($partition as $key=>$val){ + if((is_numeric($key))||($key=="count")||($key=="dn")){ + unset($partition[$key]); + }else{ + $partition[$key] = $val[0]; + } + } + + /* Append fetched partitions + */ + $partition['status']="edited"; + $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; + } + } + ksort($this->disks); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Partition table"), + "plDescription" => _("FAI partition table"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 26, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name")." ("._("Read only").")", + "description" => _("Description")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiPartitionTableEntry.inc b/gosa-core/plugins/admin/fai/class_faiPartitionTableEntry.inc new file mode 100644 index 000000000..431157c26 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiPartitionTableEntry.inc @@ -0,0 +1,516 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("DISKcn","DISKdescription"); + var $objectclasses= array(); + + var $DISKcn = ""; + var $DISKdescription = ""; + + var $partitions = array(); + var $UsedAttrs = array(); + var $is_edit = false; + var $old_cn = ""; + var $status = "new"; + var $deletePartitions = array(); + + var $FAIstate = ""; + + function faiPartitionTableEntry (&$config, $dn= NULL,$usedDiskNames=array(),$disk=false) + { + plugin::plugin ($config, $dn); + $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", + "FAImountOptions","FAIfsOptions","FAIpartitionFlags"); + + /* Default status is new */ + $this->status = "new"; + + /* We want to edit an entry */ + if($disk){ + + /* Set disk status */ + $this->status = $disk['status']; + + /* Walk through partitions */ + foreach($disk['partitions'] as $name => $values){ + + /* If a partition is already marked as delete, attach it to deletePartitions only. */ + if($values['status'] == "delete"){ + unset($disk['partitions'][$name]); + $this->deletePartitions[]=$values; + }else{ + + /* Set status, to know which partition must be deleted from ldap + new : Neu partition entry // save + edited : Update partition entry in ldap + deleted: Remove partition from ldap + */ + + /* If status is not new, set to edit mode. + * New means that this partition currently wasn't saved to ldap. + */ + if($disk['partitions'][$name]['status']!="new"){ + $disk['partitions'][$name]['status']="edited"; + } + + $disk['partitions'][$name]['old_cn']= $disk['partitions'][$name]['cn']; + + /* Assign empty attributes, if attribute is missing */ + foreach($this->UsedAttrs as $attr){ + if(!isset($values[$attr])){ + $disk['partitions'][$name][$attr]=""; + } + } + + if (preg_match('/^_/', $disk['partitions'][$name]['FAIfsType'])){ + $disk['partitions'][$name]['FAIfsType']= preg_replace('/^_/', '', $disk['partitions'][$name]['FAIfsType']); + $disk['partitions'][$name]['FAIencrypted']= true; + } else { + $disk['partitions'][$name]['FAIencrypted']= false; + } + } + } + + /* Set default attributes */ + $this->DISKcn = $disk['cn']; + $this->DISKdescription = $disk['description']; + $this->partitions = $disk['partitions']; + $this->is_edit = true; + $this->old_cn = $disk['cn']; + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $s_action = ""; + $s_entry = ""; + $display = ""; + + /* Assign values + * And Checkbox selection + */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + if($this->$attrs){ + $smarty->assign($attrs."CHK"," "); + }else{ + $smarty->assign($attrs."CHK"," disabled "); + } + } + + /* Check all Posts if there is something usefull for us, + * For example : Delete is posted as Delete_1 + * The number specifies the index we want to delete + */ + foreach($_POST as $name => $value){ + if((preg_match("/Delete_.*/",$name)) && $this->acl_is_removeable()){ + $tmp = split("_",$name); + $s_action = "remove"; + $s_entry = $tmp[1]; + } + } + + /* To remove a partition we unset the index posted. + * We must sort the index again, else we possibly got problems + * with partitions order. + */ + if($s_action == "remove" && $this->acl_is_removeable()){ + if($this->partitions[$s_entry]['status'] == "edited"){ + $this->deletePartitions[$s_entry]= $this->partitions[$s_entry]; + $this->deletePartitions[$s_entry]['FAIpartitionNr']=$s_entry; + unset($this->partitions[$s_entry]); + }else{ + unset($this->partitions[$s_entry]); + } + $tmp= array(); + foreach($this->partitions as $part){ + $tmp[count($tmp)+1]=$part; + } + $this->partitions = $tmp; + } + + /* To add a partitions we only append an empty + * array to the already defined partitions. + */ + if(isset($_POST['AddPartition']) && $this->acl_is_createable()){ + foreach($this->UsedAttrs as $attr){ + $tmp[$attr] = ""; + } + $tmp["old_cn"] = ""; + $tmp["FAIencrypted"] = FALSE; + $tmp['status']="new"; + $this->partitions[count($this->partitions)+1]=$tmp; + } + + /* $setup contains a table with the partitions. + */ + $smarty->assign("setup", $this->generateParts()); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + $tmp = $this->plInfo(); + $sacl = ""; + foreach($tmp['plProvidedAcls'] as $name => $translated){ + + $acl = $this->getacl($name); + $sacl .= $acl; + if($this->FAIstate == "freezed"){ + $acl = preg_replace("/w/","",$acl); + } + $smarty->assign($name."ACL",$acl); + } + $smarty->assign("allowSave",$sacl); + + $smarty->assign("sub_object_is_createable",$this->acl_is_createable()); + + /* Fetch template and show the result + */ + $display.= $smarty->fetch(get_template_path('faiPartitionTableEntry.tpl', TRUE)); + return($display); + } + + function generateParts() + { + /* Define Arrays with allowed syntax */ + $PartitionTypes = array("primary"=>_("primary"),"logical"=>_("logical")); + $FAIfsTypes = array("ext2","ext3","xfs","swap","reiser","dosfat16","winfat32"); + + /* Display Header */ + $str = ""; + if (count($this->partitions)){ + $str .= ""; + $str .= ""._("Type").""; + $str .= ""._("FS type").""; + $str .= ""._("Mount point").""; + $str .= ""._("Size in MB").""; + $str .= ""._("Mount options").""; + $str .= ""._("FS option").""; + $str .= ""._("Preserve").""; + $str .= ""._("Encrypted").""; + $str .= " "; + $str .= ""; + } + + /* Walk through all defined partitions. + * Create a new row for each partition and append it to + * the header defined above. + * To be able to check the posts later, we append a key to each single postfield. like cn_1 ... cn_2 + */ + foreach($this->partitions as $key => $part){ + + $dis = ""; + if($part['FAIpartitionFlags'] == "preserve"){ + $dis = " disabled "; + } + + $disableALL = ""; + if($this->FAIstate =="freeze"){ + $disableALL = " disabled "; + } + + if($part['status']!="delete"){ + + /* Generate Partition select box + */ + $PartitionType = ""; + if($this->acl_is_writeable("FAIpartitionType")){ + $PartitionType = ""; + }elseif($this->acl_is_readable("FAIpartitionType")){ + $PartitionType = $part['FAIpartitionType']; + } + + + /* Generate fsType select box + */ + $FAIfsType= ""; + if($this->acl_is_writeable("FAIfsType")){ + $FAIfsType= ""; + }elseif($this->acl_is_readable("FAIfsType")){ + $FAIfsType = $part['FAIfsType']; + } + + foreach(array("FAImountPoint","FAIpartitionSize","FAImountOptions","FAIfsOptions") as $attr){ + $$attr = ""; + if($this->acl_is_writeable($attr)){ + $$attr = ""; + + }elseif($this->acl_is_readable($attr)){ + $$attr = $part[$attr]; + } + } + + + $str .= "\n"; + $str .= "\n".$PartitionType.""; + $str .= "\n".$FAIfsType.""; + $str .= "\n".$FAImountPoint.""; + $str .= "\n".$FAIpartitionSize.""; + $str .= "\n".$FAImountOptions.""; + $str .= "\n".$FAIfsOptions.""; + + $changeState = "onClick=\"changeState('FAImountPoint_".$key."') ; ". + "changeState('FAIpartitionSize_".$key."') ; ". + "changeState('FAImountOptions_".$key."') ; ". + "changeState('FAIfsType_".$key."') ; ". + "changeState('FAIfsOptions_".$key."') ; \""; + + if($this->acl_is_writeable("FAIpartitionFlags")){ + if($part['FAIpartitionFlags']!=false){ + $str .= "\n"; + }else{ + $str .= "\n"; + } + if($part['FAIencrypted']!=false){ + $str .= "\n"; + }else{ + $str .= "\n"; + } + }else{ + if($part['FAIpartitionFlags']!=false){ + $str .= ""._("False").""; + }else{ + $str .= ""._("True").""; + } + if($part['FAIencrypted']!=false){ + $str .= ""._("False").""; + }else{ + $str .= ""._("True").""; + } + } + if($this->acl_is_removeable()){ + $str .= "\n"; + }else{ + $str .= "\n"; + } + $str .= "\n"; + } + } + + if(!empty($str)){ + $str = "".$str."
"; + } + return($str); + + } + + function save() + { + $tmp = array(); + $tmp['cn'] = $this->DISKcn; + + /* Attach partitions */ + foreach($this->partitions as $key=>$val) { + if (isset($this->partitions[$key]['FAIencrypted']) && $this->partitions[$key]['FAIencrypted']){ + unset ($this->partitions[$key]['FAIencrypted']); + $this->partitions[$key]['FAIfsType']= "_".$this->partitions[$key]['FAIfsType']; + } + $this->partitions[$key]['FAIpartitionNr']=$key; + } + + /* Attach deleted */ + foreach($this->deletePartitions as $key=>$val) { + $this->partitions[$key."-delete"]=$val; + $this->partitions[$key."-delete"]['status']="delete"; + } + + $tmp['description'] = $this->DISKdescription; + $tmp['partitions'] = $this->partitions; + $tmp['status'] = $this->status; + + /* If hdd name has changed, tell partitionTable to rename it */ + if(($this->is_edit)&&($this->old_cn != $this->DISKcn)){ + $tmp['rename']['from'] = $this->old_cn; + $tmp['rename']['to'] = $this->DISKcn; + } + return($tmp); + } + + + /* Save data to object */ + function save_object() + { + + + if((isset($_POST['TableEntryFrameSubmitted'])) && ($this->FAIstate != "freeze") ){ + plugin::save_object(); + + foreach($this->partitions as $key => $part){ + foreach($this->UsedAttrs as $attrs){ + + if($this->acl_is_writeable($attrs)){ + + if(isset($_POST[$attrs."_".$key])){ + $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key]; + }else{ + $this->partitions[$key][$attrs] = false; + } + } + } + + if($this->acl_is_writeable("FAIencrypted")){ + + if(isset($_POST["FAIencrypted_".$key])){ + $this->partitions[$key]["FAIencrypted"] = $_POST["FAIencrypted_".$key]; + }else{ + $this->partitions[$key]["FAIencrypted"] = false; + } + } + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Check for an empty disk name */ + if(empty($this->DISKcn)){ + $message[] = _("Please specify a valid disc name."); + } + + /* check every partition. + * if there is an invalid value defined, append an errorstr to message + */ + + /* Array that contain every partitionname mountpoint etc already assigned */ + $alreadyUsed = array(); + foreach($this->UsedAttrs as $attrs){ + $alreadyUsed[$attrs] = array(); + } + + foreach($this->partitions as $key => $part){ + + /* Skip all checks, if preserve is set */ + if($part['FAIpartitionFlags'] == "preserve"){ + $this->partitions[$key]['FAIfsType'] = "preserve"; + $this->partitions[$key]['FAIpartitionSize'] = "preserve"; + continue; + } + + if((in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint']))&&($part['FAIfsType']!="swap")){ + $message[]=sprintf(_("please enter a unique mount point for partition %s"),($key)); + } + + if($part['FAIfsType']!="swap" && $part['FAImountPoint'] != "-"){ + if((empty($part['FAImountPoint']))||(!((preg_match("/^\/.*/",$part['FAImountPoint']))||(preg_match("/^swap$/",$part['FAImountPoint']))))){ + $message[]=sprintf(_("Please enter a valid mount point for partition %s." ),($key)); + } + } + if($part['FAIfsType'] == "swap"){ + if(in_array($part['FAIfsType'],$alreadyUsed['FAIfsType'])){ + $message[]=sprintf(_("File system type 'swap' is already used, change file system type for partition %s."),$key); + } + } + if(($part['FAIfsType'] == "swap")&&(!empty($part['FAImountPoint']))&&($part['FAImountPoint']!="swap")){ + $message[]=_("Please use 'swap' as mount point, if 'swap' is used as fs-type."); + } + + $tmp = split("-",$part['FAIpartitionSize']); + switch (count($tmp)){ + case 0: + $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key)); + break; + case 1: + if (!is_id(is_id($tmp[0])) &&(!empty($tmp[1]))){ + $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key)); + } + break; + + case 2: + if((!is_id($tmp[0]))&&(!is_id($tmp[1])) &&(!empty($tmp[1]))){ + $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); + }elseif($tmp[0]>=$tmp[1]){ + $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); + } + break; + + default: + $message[]=sprintf(_("Please enter a range for partition size for partition %s."),($key)); + } + + foreach($this->UsedAttrs as $attrs){ + $alreadyUsed[$attrs][$key] = $part[$attrs]; + } + } + + $cnt = 0; + foreach($this->partitions as $key => $part){ + if($part['FAIpartitionType'] == "primary"){ + $cnt ++ ; + } + } + if($cnt > 3){ + $message[] = _("You have more than 3 primary partition table entries in your configuration, please check your configuration twice."); + } + + return ($message); + } + + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Partition table entry"), + "plDescription" => _("FAI partition table entry"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 27, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "DISKcn" => _("Name"), + "DISKdescription" => _("Description"), + "FAIpartitionType" => _("Partition type"), + "FAIpartitionNr" => _("Partition no."), + "FAIfsType" => _("File system type"), + "FAImountPoint" => _("Mount point"), + "FAIpartitionSize" => _("Partition size"), + "FAImountOptions" => _("Mount options"), + "FAIfsOptions" => _("File system options"), + "FAIencrypted" => _("File system encryption"), + "FAIpartitionFlags" => _("Partition flags")) + )); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiProfile.inc b/gosa-core/plugins/admin/fai/class_faiProfile.inc new file mode 100644 index 000000000..4b5daea9b --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiProfile.inc @@ -0,0 +1,501 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description","FAIclass"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIprofile"); + + /* Specific attributes */ + var $old_cn = ""; + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $FAIclass = ""; // Classnames used for this profile + var $FAIclasses = array(); // Contains classname seperated in an array + var $FAIAllclasses = array(); // Contains all possible Classnames + var $ui ; + var $FAIstate = ""; + var $view_logged = FALSE; + + function faiProfile(&$config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + $ldap=$this->config->get_ldap_link(); + + $this->ui = get_userinfo(); + + /* Parse ldap attribute to get all assigned classes */ + $tmp = split(" ",$this->FAIclass); + $tmp2 = array(); + foreach($tmp as $class){ + if(!empty($class)){ + $tmp2[trim($class)] = trim($class); + } + } + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + /* Sort assigned classes */ + if(is_array($tmp2)){ + foreach($tmp2 as $class){ + $this->FAIclasses[$class]=$class; + } + } + + $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTable","FAIpackageList"); + + /* Build filter */ + $filter= ""; + foreach ($categories as $cat){ + $filter.= "(objectClass=$cat)"; + } + + /* Get ldap connection */ + $base = $_SESSION['CurrentMainBase']; + $ldap->cd($base); + $sort = array(); + + /* search all FAI classes */ + $ldap->search("(|$filter)",array("*")); + while($attrs = $ldap->fetch()){ + + /* Sort by categorie */ + foreach($categories as $cat){ + if(in_array($cat,$attrs['objectClass'])){ + + /* Append entry */ + $this->FAIAllclasses[$attrs['cn'][0]][$cat]=$attrs; + + /* Create sort array, because the array above is a multidimensional array, and can't be sorted by php sorting functions*/ + $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; + } + } + } + + /* Sort the sort array */ + //ksort($sort); + + /* Reorder the FAIclasses array */ + foreach($sort as $name){ + $tmp[$name] =$this->FAIAllclasses[$name]; + } + + /* Assign sorted classes */ + $this->FAIAllclasses = array(); + $this->FAIAllclasses = $tmp; + + if($dn != "new"){ + $this->dn =$dn; + } + $this->old_cn = $this->cn; + } + + + /* Combine new array, used for up down buttons */ + function combineArrays($ar0,$ar1,$ar2) + { + $ret = array(); + if(is_array($ar0)) + foreach($ar0 as $ar => $a){ + $ret[$ar]=$a; + } + if(is_array($ar1)) + foreach($ar1 as $ar => $a){ + $ret[$ar]=$a; + } + if(is_array($ar2)) + foreach($ar2 as $ar => $a){ + $ret[$ar]=$a; + } + return($ret); + } + + + function acl_base_for_current_object($dn) + { + if($dn == "new"){ + if($this->dn == "new"){ + $dn= $_SESSION['CurrentMainBase']; + }else{ + $dn = $this->dn; + } + } + return($dn); + } + + + /* returns position in array */ + function getpos($atr,$attrs) + { + $i = 0; + foreach($attrs as $attr => $name) { + $i++; + if($attr == $atr){ + return($i); + } + } + return(-1); + } + + /* Transports the given Arraykey one position up*/ + function ArrayUp($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == 1))){ + $before = array_slice($attrs,0,($pos-2)); + $mitte = array_reverse(array_slice($attrs,($pos-2),2)); + $unten = array_slice($attrs,$pos); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* Transports the given Arraykey one position down*/ + function ArrayDown($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == $cn))){ + $before = array_slice($attrs,0,($pos-1)); + $mitte = array_reverse(array_slice($attrs,($pos-1),2)); + $unten = array_slice($attrs,($pos+1)); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + /* class one position up */ + function catUp($id) + { + /* Get all cats depinding on current dir */ + $cats = $this->FAIclasses; + $this->FAIclasses =$this->ArrayUp($id,$cats); + } + + /* Class one position down */ + function catDown($id) + { + /* Get all cats depinding on current dir */ + $cats = $this->FAIclasses; + $this->FAIclasses =$this->ArrayDown($id,$cats); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","fai/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $s_entry = ""; + $s_action = ""; + + /* Remove class name From list */ + $sort_once = false; + foreach($_POST as $name => $post){ + if(preg_match("/DEL_/i",$name) && $this->acl_is_writeable("FAIclass")){ + $s_action = "delete"; + $s_entry = preg_replace("/DEL_/","",$name); + $s_entry = base64_decode(preg_replace("/_.*$/","",$s_entry)); + }elseif(preg_match("/Add_class/i",$name)&& $this->acl_is_writeable("FAIclass")){ + $s_action = "add"; + }elseif(preg_match("/DelClass/i",$name) && $this->acl_is_writeable("FAIclass")){ + $s_action = "delete"; + $s_entry = $_POST['FAIclass']; + }elseif(preg_match("/AddClass/i",$name) && $this->acl_is_writeable("FAIclass")){ + $s_action = "add"; + } + + /* Check if a list element should be pushed one position up */ + if((preg_match("/sortup_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){ + $sort_once = true; + $val = preg_replace("/sortup_/","",$name); + $val = preg_replace("/_.*$/","",$val); + $val = base64_decode($val); + $this->catUp($val); + } + + /* Check if a list element should be pushed one position down */ + if((preg_match("/sortdown_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){ + $sort_once = true; + $val = preg_replace("/sortdown_/","",$name); + $val = preg_replace("/_.*$/","",$val); + $val = base64_decode($val); + $this->catDown($val); + } + + } + + if($s_action == "delete" && $this->acl_is_writeable("FAIclass")){ + unset($this->FAIclasses[$s_entry]); + } + + if($s_action == "add" && $this->acl_is_writeable("FAIclass")){ + $this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses); + $this->is_dialog =true; + } + + /* Save Dialog */ + if(isset($_POST['SaveSubObject'])){ + $this->dialog->save_object(); + $msgs= $this->dialog->check(); + if(count($msgs)){ + print_red($msgs); + }else{ + $ret = $this->dialog->save(); + foreach($ret as $class){ + $this->FAIclasses[$class] =$class; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + //ksort($this->FAIclasses); + } + } + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + $divlist =new divSelectBox("Profile"); + $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); + + /* item images */ + $objTypes['FAIhook'] = ""; + $objTypes['FAItemplate'] = ""; + $objTypes['FAIscript'] = ""; + $objTypes['FAIvariable'] = ""; + $objTypes['FAIpackageList'] = ""; + $objTypes['FAIpartitionTable'] = ""; + + /* Delete button */ + $actions = ""; + + /* Up down buttons */ + $linkupdown = " "; + $linkupdown.= ""; + + /* Append fai classes to divlist */ + if($this->acl_is_readable("FAIclass")){ + foreach($this->FAIclasses as $usedClass){ + $str = " "; + $act = ""; + + if(isset($this->FAIAllclasses[$usedClass])){ + foreach($this->FAIAllclasses[$usedClass] as $class => $obj){ + $str.= $objTypes[$class]; + } + } + + $field1 = array("string"=> $usedClass,"attach"=>""); + $field2 = array("string"=> $str,"attach"=>""); + if(($this->FAIstate != "freeze") && $this->acl_is_writeable("FAIclass")){ + $field3 = array("string"=> preg_replace("/%KEY%/",base64_encode($usedClass),$actions). + preg_replace("/%s/",base64_encode($usedClass),$linkupdown), + "attach"=>"style='border-right:none;'"); + }else{ + $field3 = array("string"=>" ", "attach"=>"style='border-right:none;'"); + } + $divlist->AddEntry(array($field1,$field2,$field3)); + } + } + + $smarty->assign("FAIclasses" ,$this->FAIclasses); + $smarty->assign("divlist" ,$divlist->DrawList()); + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + }else{ + $smarty->assign($attrs,($this->$attrs)); + } + } + + + $dn = $this->acl_base_for_current_object($this->dn); + $smarty->assign("sub_object_is_addable", + preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiScriptEntry")) && + !preg_match("/freeze/",$this->FAIstate)); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $this->dn; + } + + new log("remove","fai/".get_class($this),$use_dn,$this->attributes); + prepare_to_save_FAI_object($use_dn,array(),true); + $this->handle_post_events("remove"); + } + + + /* Save data to object + */ + function save_object() + { + plugin::save_object(); + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(count($this->FAIclasses) == 0){ + $message[]=_("Please assign at least one class to this profile."); + } + + if(empty($this->cn)){ + $message[]=_("Please enter a valid name."); + } + + $ldap = $this->config->get_ldap_link(); + + $base = $_SESSION['faifilter']['branch']; + if($base == "main"){ + $base =$_SESSION['CurrentMainBase']; + } + $base = "ou=profiles,".$base; + + $ldap->cd($base); + if ($this->old_cn == ""){ + $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn."))",$base,array("*")); + } else { + $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",$base,array("*")); + } + + if($ldap->count() || isset($this->FAIAllclasses[$this->cn])){ + $message[]=_("There is already a FAI object with this class name defined."); + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $this->FAIclass = ""; + foreach($this->FAIclasses as $class){ + $this->FAIclass.=$class." "; + } + + $this->attrs['FAIclass']=trim($this->FAIclass); + + prepare_to_save_FAI_object($this->dn,$this->attrs); + + if($this->initially_was_account){ + new log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + new log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/profile with dn '%s' failed."),$this->dn)); + + /* Do object tagging */ + $this->handle_object_tagging(); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/profile with dn '%s' failed."),$this->dn)); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Parse ldap attribute to get all assigned classes */ + $tmp = split(" ",$this->FAIclass); + $tmp2 = array(); + foreach($tmp as $class){ + if(!empty($class)){ + $tmp2[trim($class)] = trim($class); + } + } + + /* Sort assigned classes */ + if(is_array($tmp2)){ + foreach($tmp2 as $class){ + $this->FAIclasses[$class]=$class; + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Profile"), + "plDescription" => _("FAI profile"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 30, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name"), + "description" => _("Description"), + "FAIclass" => _("FAI classes")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiProfileEntry.inc b/gosa-core/plugins/admin/fai/class_faiProfileEntry.inc new file mode 100644 index 000000000..2d9b09764 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiProfileEntry.inc @@ -0,0 +1,277 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array(); + var $objectclasses= array(); + + /* Array with available class names */ + var $FAIAllclasses = array(); + var $ui; + + function faiProfileEntry (&$config, $dn= NULL,$used=array(),$objects=false) + { + plugin::plugin ($config, $dn); + + /* Search only in fai tree */ + $base = "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + if($_SESSION['faifilter']['branch']!="main"){ + $base = $_SESSION['faifilter']['branch']; + } + + $this->ui = get_userinfo(); + + $filter = "(|(objectClass=FAIscript)(objectClass=FAItemplate)(objectClass=FAIhook)". + "(objectClass=FAIvariable)(objectClass=FAIpartitionTable)(objectClass=FAIpackageList))"; + + $FAI_objects = get_all_objects_for_given_base($base,$filter,true); + + /* Create array with categories to be able to sort different types of objects */ + $categories = array("FAIscript" => "faiScript", + "FAItemplate" => "faiTemplate", + "FAIhook" => "faiHook", + "FAIvariable" => "faiVariable", + "FAIpartitionTable" => "faiPartitionTable", + "FAIpackageList" => "faiPackageList"); + + /* Read out all objects from fai tree */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($base); + $sort=array(); + foreach($FAI_objects as $obj){ + + $ldap->cat($obj['dn']); + $attrs = $ldap->fetch(); + + /* Only use objects which have cn set */ + if((isset($attrs['cn'][0]))&&(!in_array($attrs['cn'][0],$used))){ + foreach($categories as $cat => $acl){ + if(in_array($cat,$attrs['objectClass'])){ + + $acl = $this->ui->get_permissions($attrs['dn'],"fai/".$acl); + + /* Append different types of objects */ + $this->FAIAllclasses[$attrs['cn'][0]]['objects'][$cat]=$cat; + + if(!isset($this->FAIAllclasses[$attrs['cn'][0]]['acl'])){ + $this->FAIAllclasses[$attrs['cn'][0]]['acl']=""; + } + $this->FAIAllclasses[$attrs['cn'][0]]['acl'].=$acl; + + /* Set selected status to false */ + $this->FAIAllclasses[$attrs['cn'][0]]['status']=false; + + $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; + } + } + } + } + + + $tmp = array(); + ksort($sort); + foreach($sort as $name){ + $tmp[$name] =$this->FAIAllclasses[$name]; + } + $this->FAIAllclasses = array(); + $this->FAIAllclasses = $tmp; + + /* If no search filter is set, create one */ + if (!is_global("SUBfaifilter")){ + $SUBfaifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'], "Sregex" => "*"); + $SUBfaifilter['SShowTemplates'] = true; + $SUBfaifilter['SShowScripts'] = true; + $SUBfaifilter['SShowHooks'] = true; + $SUBfaifilter['SShowVariables'] = true; + $SUBfaifilter['SShowPackages'] = true; + $SUBfaifilter['SShowPartitions']= true; + register_global("SUBfaifilter", $SUBfaifilter); + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + $SUBfaifilter = $_SESSION['SUBfaifilter']; + + /* If someone used the apply button, update searchfilter */ + if(isset($_POST['Sregex'])){ + foreach($SUBfaifilter as $key => $val){ + if(!isset($_POST[$key])){ + $SUBfaifilter[$key] = false; + }else{ + $SUBfaifilter[$key] =$_POST[$key]; + } + } + $SUBfaifilter['Sregex']= $_POST['Sregex']; + if(!strstr($SUBfaifilter['Sregex'],"*")){ + $SUBfaifilter['Sregex'] = $SUBfaifilter['Sregex']."*"; + } + } + + /* Save current searchfilter in session*/ + $_SESSION['SUBfaifilter']= $SUBfaifilter; + + /* Check if we used a checkboxe from the list, to select dselect an entry */ + foreach($_POST as $name => $value){ + foreach($this->FAIAllclasses as $class => $obj){ + $bclass = base64_encode($class); + if(isset($_POST["ON_PAGE_".$bclass])){ + if(isset($_POST['USE_'.$bclass])){ + $this->FAIAllclasses[$class]['status']=true; + }else{ + $this->FAIAllclasses[$class]['status']=false; + } + } + } + } + + /* Create different picture for each object type */ + $objTypes['FAIhook'] = " "; + $objTypes['FAItemplate'] = " "; + $objTypes['FAIscript'] = " "; + $objTypes['FAIvariable'] = " "; + $objTypes['FAIpackageList'] = " "; + $objTypes['FAIpartitionTable'] = " "; + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + }else{ + $smarty->assign($attrs,($this->$attrs)); + } + } + + /* Assign all filter attributes to smarty */ + foreach($SUBfaifilter as $key => $val){ + if(($key != "base")&&($key != "Sregex")){ + if($val){ + $smarty->assign($key."CHK", " checked "); + }else{ + $smarty->assign($key."CHK", ""); + } + }else{ + $smarty->assign($key,$val); + } + } + + /* Create a divlist to display all available class names with the depending object types */ + $divlist = new divlist("ProfileEntry"); + $divlist->SetPluginMode(); + $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); + $divlist->SetEntriesPerPage(0); + $divlist->SetHeader(array(array("string"=> _("Class name")), + array("string"=> _("Objects"),"attach"=>"style='border-right:0px;'"))); + + /* Action button allows us to delete an entry */ + $action = " + "; + + /* Check every single class name to match the current search filter */ + foreach($this->FAIAllclasses as $usedClass => $classes){ + + /* Skip those entries that we are not allowed to read. */ + if(!preg_match("/r/",$classes['acl'])){ + continue; + } + + $fi = str_replace("*",".*",$SUBfaifilter['Sregex']); + + $abort = true; + if(!preg_match("/".$fi."/",$usedClass)){ + $abort = false; + } + if((isset($classes['objects']['FAIscript']))&&($SUBfaifilter['SShowScripts'])){ + $abort = false; + } + if((isset($classes['objects']['FAItemplate']))&&($SUBfaifilter['SShowTemplates'])){ + $abort = false; + } + if((isset($classes['objects']['FAIhook']))&&($SUBfaifilter['SShowHooks'])){ + $abort = false; + } + if((isset($classes['objects']['FAIvariable']))&&($SUBfaifilter['SShowVariables'])){ + $abort = false; + } + if((isset($classes['objects']['FAIpartitionTable']))&&($SUBfaifilter['SShowPartitions'])){ + $abort = false; + } + if((isset($classes['objects']['FAIpackageList']))&&($SUBfaifilter['SShowPackages'])){ + $abort = false; + } + + if(!$abort){ + $str = ""; + foreach($classes['objects'] as $class => $obj){ + $str.= $objTypes[$obj]; + } + + /* Is this entry selected */ + if($classes['status']==true){ + $action_check = preg_replace("/%CHECK%/"," checked ",$action); + }else{ + $action_check = preg_replace("/%CHECK%/","",$action); + } + + /* Append to list */ + $field1 = array("string"=> str_replace("%KEY%",base64_encode($usedClass),$action_check).$usedClass,"attach"=>""); + $field2 = array("string"=> $str,"attach"=>"style='border-right:0px;'"); + $divlist->AddEntry(array($field1,$field2)); + } + } + + $smarty->assign("faihead" , ""); + $smarty->assign("failist" , $divlist->DrawList()); + $smarty->assign("infoimage" , get_template_path('images/info_small.png')); + $smarty->assign("launchimage" , get_template_path('images/small_filter.png')); + $smarty->assign("alphabet" , generate_alphabet()); + $smarty->assign("apply" , apply_filter(TRUE)); + $smarty->assign("search_image" , get_template_path('images/search.png')); + + $display.= $smarty->fetch(get_template_path('faiProfileEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + function save() + { + $tmp = array(); + foreach($this->FAIAllclasses as $class => $obj){ + if($obj['status']==true){ + $tmp[$class]=$class; + } + } + return($tmp); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiScript.inc b/gosa-core/plugins/admin/fai/class_faiScript.inc new file mode 100644 index 000000000..928aa0e94 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiScript.inc @@ -0,0 +1,658 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIscript"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAIscriptEntry"; + var $subClasses = array("top","FAIclass","FAIscriptEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = "faiScriptEntry"; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description","FAIpriority"); + var $sub_Load_Later = array("FAIscript"); + var $sub64coded = array(); + var $subBinary = array("FAIscript"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $SubObjects = array(); // All leafobjects of this object + + var $FAIstate = ""; + var $sort_by = "name"; + var $sort_order = "up"; + + var $view_logged = FALSE; + var $ui; + + function faiScript (&$config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. + */ + if($dn != "new"){ + + $this->dn =$dn; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + + $attrs_to_search = $this->subAttributes; + $attrs_to_search[] = "FAIstate"; + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + /* Set status for save management */ + $objects = array(); + $objects['status'] = "FreshLoaded"; + $objects['dn'] = $object['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $this->SubObjects[$objects['cn']] = $objects; + } + + } + $this->ui = get_userinfo(); + } + + + /* Reload some attributes */ + function get_object_attributes($object,$attributes) + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($object['dn'],$attributes); + $tmp = $ldap->fetch(); + + foreach($attributes as $attrs){ + if(isset($tmp[$attrs][0])){ + $var = $tmp[$attrs][0]; + + /* Check if we must decode some attributes */ + if(in_array_ics($attrs,$this->sub64coded)){ + $var = base64_decode($var); + } + + /* check if this is a binary entry */ + if(in_array_ics($attrs,$this->subBinary)){ + $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0); + } + + /* Fix slashes */ + $var = addslashes($var); + $object[$attrs] = $var; + } + } + return($object); + } + + + /* Return a valid dn to fetch acls. Because 'new' will not work. */ + function acl_base_for_current_object($dn) + { + if($dn == "new"){ + if($this->dn == "new"){ + $dn= "cn=dummy,".$_SESSION['CurrentMainBase']; + }else{ + $dn = $this->dn; + } + } + return($dn); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","fai/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add new sub object */ + if(isset($_POST['AddSubObject'])){ + $this->dialog= new $this->subClassName($this->config,"new"); + $this->dialog->set_acl_base($this->acl_base); + $this->dialog->set_acl_category("fai"); + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + + if($this->dn != "new"){ + $_SESSION['objectinfo']= $this->dn; + } + + /* Handle posts */ + $s_action = $s_entry = ""; + foreach($_POST as $name => $value){ + + /* Edit script posted */ + if(preg_match("/^editscript_/",$name)){ + $s_action = "edit"; + $s_entry = preg_replace("/^editscript_/","",$name); + $s_entry = base64_decode(preg_replace("/_.*/","",$s_entry)); + break; + } + + /* Delete script requested */ + if(preg_match("/^deletescript_/",$name)){ + $s_action = "remove"; + $s_entry = preg_replace("/^deletescript_/","",$name); + $s_entry = base64_decode(preg_replace("/_.*/","",$s_entry)); + break; + } + } + + if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ + $s_entry = $_GET['id']; + if(isset($this->SubObjects[$s_entry])){ + $s_action = "edit"; + } + } + + if($s_action =="edit" && isset($this->SubObjects[$s_entry])){ + + /* Get object, and load missing entry values */ + $obj = $this->SubObjects[$s_entry]; + if($obj['status'] == "FreshLoaded"){ + $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); + } + + /* Create new dialog and set acl attributes */ + $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); + $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn'])); + $this->dialog->set_acl_category("fai"); + + /* Assign some additional dialog informations like headline and parent */ + $_SESSION['objectinfo'] = $obj['dn']; + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + + /* Check acls, are we allowed to delete an entry */ + if($s_action == "remove" && isset($this->SubObjects[$s_entry])){ + $entry = $this->SubObjects[$s_entry]; + $acl = $this->ui->get_permissions($this->acl_base_for_current_object($entry['dn']),"fai/faiScriptEntry") ; + if(preg_match("/d/",$acl)){ + $status = $entry['status']; + if($status == "edited" || $status == "FreshLoaded"){ + $this->SubObjects[$s_entry]['status']= "delete"; + }else{ + unset($this->SubObjects[$s_entry]); + } + } + } + + /* Save the edited entry */ + if(isset($_POST['SaveSubObject'])){ + + /* Check if there are still errors remaining that must be fixed before saving */ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)>0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + + /* Get return object */ + $obj = $this->dialog->save(); + + /* If we have renamed the script entry, we must remove the old entry */ + if(isset($obj['remove'])){ + + /* Get old entry values */ + $old_stat = $this->SubObjects[$obj['remove']['from']]['status']; + + /* Depending on status, set new status */ + if($old_stat == "edited" || $old_stat == "FreshLoaded"){ + $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; + }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + unset($this->SubObjects[$obj['remove']['from']]); + } + + /* Append the new entry */ + $obj['status'] = "new"; + $this->SubObjects[$obj['remove']['to']] = $obj; + unset($this->SubObjects[$obj['remove']['to']]['remove']); + }else{ + + /* Set new status and append the entry */ + if($obj['status'] == "FreshLoaded"){ + $obj['status'] = "edited"; + } + $this->SubObjects[$obj['cn']]=$obj; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + + } + } + + /* Sort entries */ + $tmp = $keys = array(); + + if($this->sort_by == "name"){ + foreach($this->SubObjects as $key => $entry){ + $keys[$key]=$entry['cn']; + } + }elseif($this->sort_by == "priority"){ + foreach($this->SubObjects as $key => $entry){ + $keys[$key]=$entry['FAIpriority']; + } + } + + natcasesort($keys); + + if($this->sort_order == "down"){ + $keys =array_reverse($keys); + } + + foreach($keys as $key => $order_var){ + $tmp[$key]=$this->SubObjects[$key]; + } + $this->SubObjects = $tmp; + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + + /* Print dialog if $this->dialog is set */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return($display); + } + + /* Divlist added 23.02.2006 + Containing FAIscripts + */ + $divlist = new divlist("FAIscripts"); + $divlist->SetEntriesPerPage(0); + $plug = $_GET['plug']; + + if($this->sort_order == "up"){ + $dir = "\/"; + }else{ + $dir = "/\"; + } + + if($this->sort_by == "name"){ + $sort_name = $dir; + $sort_prio = ""; + }else{ + $sort_name = ""; + $sort_prio = $dir; + } + + $divlist->SetHeader(array( array("string"=>""._("Name").$sort_name.""), + array("string"=>"".$sort_prio._("Priority")."", + "attach"=>"style='width:100px;'"), + array("string"=>_("Download"), + "attach"=>"style='width:100px;'"), + array("string"=>_("Action"), + "attach"=>"style='border-right: 0px;width:100px;text-align:right;'"))); + $divlist->SetHeight(300); + $divlist->SetWidth("100%"); + foreach($this->getList(true) as $key => $name){ + + $dn= $this->acl_base_for_current_object($name['dn']); + $acl = $this->ui->get_permissions($dn,"fai/faiScriptEntry") ; + $act = ""; + + /* Hide delete icon if this object is freezed */ + if($this->FAIstate == "freeze"){ + $act .= ""; + }else{ + $act .= ""; + if(preg_match("/d/",$acl)){ + $act .=""; + } + } + + /* Check acls for download icon */ + $s_acl = $this->ui->get_permissions($dn,"fai/faiScriptEntry","FAIscript") ; + if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){ + $down = ""; + }else{ + $down = " + "._("Download")." + "; + } + + /* Check if we are allowed to view this object */ + $s_acl = $this->ui->get_permissions($dn,"fai/faiScriptEntry","cn") ; + if(preg_match("/r/",$s_acl)){ + $divlist->AddEntry(array( array("string"=>"".$name['name'].""), + array("string"=>$name['FAIpriority'] , "attach" => "style='width:100px;'"), + array("string"=>$down , "attach" => "style='width:100px;'"), + array("string"=>str_replace("%s",base64_encode($key),$act), + "attach"=>"style='border-right: 0px;width:100px;text-align:right;'"))); + } + } + $smarty->assign("Entry_divlist",$divlist->DrawList()); + + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + }else{ + $smarty->assign($attrs,($this->$attrs)); + } + } + + $dn = $this->acl_base_for_current_object($this->dn); + $smarty->assign("sub_object_is_addable", + preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiScriptEntry")) && + !preg_match("/freeze/",$this->FAIstate)); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $display.= $smarty->fetch(get_template_path('faiScript.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList($use_dns=false){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + if($use_dns){ + if((isset($obj['description']))&&(!empty($obj['description']))){ + $a_return[$obj['cn']]['name']= $obj['cn']." [".stripslashes($obj['description'])."]"; + }else{ + $a_return[$obj['cn']]['name']= $obj['cn']; + } + $a_return[$obj['cn']]['dn']= $obj['dn']; + $a_return[$obj['cn']]['FAIpriority']= $obj['FAIpriority']; + }else{ + if((isset($obj['description']))&&(!empty($obj['description']))){ + $a_return[$obj['cn']]= $obj['cn']." [".stripslashes($obj['description'])."]"; + }else{ + $a_return[$obj['cn']]= $obj['cn']; + } + } + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + if($this->acl_is_removeable()){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $this->dn; + } + + new log("remove","fai/".get_class($this),$use_dn,$this->attributes); + + prepare_to_save_FAI_object($use_dn,array(),true); + + foreach($this->SubObjects as $name => $obj){ + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $obj['dn']; + } + prepare_to_save_FAI_object($use_dn,array(),true); + } + $this->handle_post_events("remove"); + } + } + + + /* Save data to object + */ + function save_object() + { + if((isset($_POST['FAIscript_posted'])) && ($this->FAIstate != "freeze")){ + plugin::save_object(); + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + } + } + } + + /* Get sort order */ + if(isset($_GET['sort']) && in_array($_GET['sort'],array("name","priority"))){ + if($this->sort_by == $_GET['sort']){ + if($this->sort_order == "up"){ + $this->sort_order = "down"; + }elseif($this->sort_order == "down"){ + $this->sort_order = "up"; + } + } + $this->sort_by = $_GET['sort']; + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + prepare_to_save_FAI_object($this->dn,$this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Creating of FAI/script with dn '%s' failed."),$this->dn)); + + if($this->initially_was_account){ + new log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + new log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + + /* Do object tagging */ + $this->handle_object_tagging(); + + /* Prepare FAIscriptEntry to write it to ldap + * First sort array. + * Because we must delete old entries first. + * After deletion, we perform add and modify + */ + $Objects = array(); + + /* We do not need to save untouched objects */ + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "FreshLoaded"){ + unset($this->SubObjects[$name]); + } + } + + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "delete"){ + $Objects[$name] = $obj; + } + } + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] != "delete"){ + $Objects[$name] = $obj; + } + } + + foreach($Objects as $name => $obj){ + + foreach($this->sub64coded as $codeIt){ + $obj[$codeIt]=base64_encode(stripslashes($obj[$codeIt])); + } + + $tmp = array(); + $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); + foreach($attributes as $attrs){ + + if(empty($obj[$attrs])){ + $obj[$attrs] = array(); + } + if(!is_array($obj[$attrs])){ + $tmp[$attrs] = stripslashes($obj[$attrs]); + }else{ + $tmp[$attrs] = $obj[$attrs]; + } + } + + $tmp['objectClass'] = $this->subClasses; + + $sub_dn = "cn=".$obj['cn'].",".$this->dn; + + if($obj['status']=="new"){ + $ldap->cat($sub_dn,array("objectClass")); + if($ldap->count()){ + $obj['status']="edited"; + } + } + + if(empty($tmp['FAIpriority'])){ + $tmp['FAIpriority'] ="0"; + } + + /* Check if gosaAdministrativeUnitTag is required as object class */ + if($obj['status'] == "edited"){ + $ldap->cat($sub_dn,array("objectClass")); + $attrs = $ldap->fetch(); + if(isset($attrs['objectClass'])){ + if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ + $tmp['objectClass'][] = "gosaAdministrativeUnitTag"; + } + } + } + + if($obj['status'] == "delete"){ + prepare_to_save_FAI_object($sub_dn,array(),true); + $this->handle_post_events("remove"); + }elseif($obj['status'] == "edited"){ + prepare_to_save_FAI_object($sub_dn,$tmp); + $this->handle_post_events("modify"); + }elseif($obj['status']=="new"){ + prepare_to_save_FAI_object($sub_dn,$tmp); + $this->handle_post_events("add"); + } + + $this->handle_object_tagging($sub_dn, $this->gosaUnitTag); + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($source['dn']); + + $attrs_to_search = $this->subAttributes; + $attrs_to_search[] = "FAIstate"; + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + /* Set status for save management */ + $objects = array(); + $objects['status'] = "edited"; + $objects['dn'] = $object['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); + + $this->SubObjects[$objects['cn']] = $objects; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Script"), + "plDescription" => _("FAI script"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 18, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name")." ("._("Readonly").")", + "description" => _("Description")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiScriptEntry.inc b/gosa-core/plugins/admin/fai/class_faiScriptEntry.inc new file mode 100644 index 000000000..032132920 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiScriptEntry.inc @@ -0,0 +1,198 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("cn","description","FAIpriority","FAIscript"); + var $objectclasses= array(); + + var $orig_cn = ""; + + var $dn = ""; + var $cn = ""; + var $FAIpriority = "0"; + var $FAIscript = ""; + var $description = ""; + var $status = "new"; + var $parent = NULL; + var $FAIstate = ""; + + function faiScriptEntry (&$config, $dn= NULL,$object=false) + { + plugin::plugin ($config, $dn); + if($dn != "new"){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = $name; + $this->$oname=$value; + } + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + }else{ + if(is_array($object)&&count($object)){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = $name; + $this->$oname=$value; + } + }else{ + + $this->status = "new"; + $this->orig_cn = false; + } + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + if(isset($_POST['ImportUpload']) && $this->acl_is_writeable("FAIscript")){ + if(($_FILES['ImportFile']['error']!=0)){ + print_red(_("Please select a valid file.")); + }else + if(($_FILES['ImportFile']['size']==0)){ + print_red(_("Selected file is empty.")); + }else{ + $str = utf8_encode(addslashes(file_get_contents($_FILES['ImportFile']['tmp_name']))); + $this->FAIscript = $str; + } + } + + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + }else{ + $smarty->assign($attrs,($this->$attrs)); + } + } + + /* Create download button*/ + if($this->dn != "new" && $this->acl_is_readable("FAIscript")){ + $smarty->assign("DownMe"," + + "); + }else{ + $smarty->assign("DownMe",""); + } + + for($i =0 ; $i < 100 ; $i++){ + $FAIprioritys[$i]=$i; + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $acl = $this->getacl($name); + if($this->FAIstate == "freezed"){ + $acl = preg_replace("/w/","",$acl); + } + $smarty->assign($name."ACL",$acl); + } + + $smarty->assign("FAIprioritys",$FAIprioritys); + if(get_magic_quotes_gpc()){ + $smarty->assign("FAIscript" , htmlentities(stripslashes($this->FAIscript))); + }else{ + $smarty->assign("FAIscript" , htmlentities($this->FAIscript)); + } + $display.= $smarty->fetch(get_template_path('faiScriptEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ + foreach($this->attributes as $attrs){ + if($this->acl_is_writeable($attrs)){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + }else{ + $this->$attrs = ""; + } + } + } + } + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ + $message[] =_("There is already a script with the given name."); + } + + if(empty($this->cn)){ + $message[] = _("Please enter a name."); + } + + if(empty($this->FAIscript)){ + $message[]=_("Please enter a script."); + } + + return ($message); + } + + function save() + { + $tmp=array(); + foreach($this->attributes as $attrs){ + $tmp[$attrs] = $this->$attrs; + } + + /* Strip out dos newlines */ + $tmp['FAIscript']= strtr($this->FAIscript, array("\x0D" => "")); + + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ + $tmp['remove']['from'] = $this->orig_cn; + $tmp['remove']['to'] = $tmp['cn']; + } + + $tmp['dn'] = $this->dn; + $tmp['status'] = $this->status; + return($tmp); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Script entry"), + "plDescription" => _("FAI script entry"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 19, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name"), + "description" => _("Description"), + "FAIscript" => _("Script entry"), + "FAIpriority" => _("Script Priority")) + )); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiSummaryTab.inc b/gosa-core/plugins/admin/fai/class_faiSummaryTab.inc new file mode 100644 index 000000000..a9bfbb840 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiSummaryTab.inc @@ -0,0 +1,583 @@ +ui = get_userinfo(); + + /* Base object configuration */ + $this->objs = array( + "FAIscript" => array( "Image" =>"images/fai_script.png", "Name"=>_("Scripts") ,"Tree" =>"ou=scripts,") , + "FAIhook" => array( "Image" =>"images/fai_hook.png" , "Name"=>_("Hooks") ,"Tree" =>"ou=hooks,"), + "FAIvariable" => array( "Image" =>"images/fai_variable.png", "Name"=>_("Variables") ,"Tree" =>"ou=variables,") , + "FAItemplate" => array( "Image" =>"images/fai_template.png", "Name"=>_("Templates") ,"Tree" =>"ou=templates,") , + "FAIpartitionTable" => array( "Image" =>"images/fai_partitionTable.png","Name"=>_("Partition table") ,"Tree" =>"ou=disk,") , + "FAIpackageList" => array( "Image" =>"images/fai_packages.png", "Name"=>_("Package list") ,"Tree" =>"ou=packages,") , + "FAIprofile" => array( "Image" =>"images/fai_profile.png", "Name"=>_("Profiles") ,"Tree" =>"ou=profiles,")); + } + + + /* Init the fai tree with objects. + If this method is called, all assigned classes and the release name + will be read from parent object. */ + function init() + { + $this->InitCalled = true; + $this->Result = array(); + $_SESSION['faiSummaryTab']['UniqueID'] = 0; + + /* Get classes & release name + There are 2 different tabs which use the summary tab + faiProfile / Workstations */ + + /* Check if given parent object is fai profile tabs */ + if(isset($this->parent->by_name['faiProfile'])){ + + /* Get Classes and release */ + $this->Classes = $this->parent->by_object['faiProfile']->FAIclasses; + $this->base = $this->parent->by_object['faiProfile']->base; + $str = preg_replace("/^.*ou=profiles,/","",$this->dn); + + /* Check if parent tab is work tab */ + }elseif(isset($this->parent->by_name['workstartup'])){ + $this->Classes = $this->parent->by_object['workstartup']->FAIclass; + $this->Release = $this->parent->by_object['workstartup']->FAIrelease; + + /* Check if this is a workstation or an object group */ + if(isset($this->parent->by_object['workgeneric'])){ + $this->base = $this->parent->by_object['workgeneric']->base; + }elseif(isset($this->parent->by_object['ogroup'])){ + $this->base = $this->parent->by_object['ogroup']->base; + }elseif(isset($this->parent->by_object['servgeneric'])){ + $this->base = $this->parent->by_object['servgeneric']->base; + }else{ + print_red(_("Unknown type of FAI source information. This is not a profile, workstation nor a ogroup.")); + } + + /* Append workstation class && LAST */ + if(isset($this->parent->by_object['workgeneric']->cn)){ + $this->Classes[] = $this->parent->by_object['workgeneric']->cn; + } + } + + $tmp = array_flip($this->getBranches()); + + $this->Classes[] = "LAST"; + + /* You need full access to complete collection of fai acls to view this summary */ + $acl = $this->ui->has_complete_category_acls($this->base,"fai"); + if(!preg_match("/r/",$acl)){ + $this->Classes = array(); + } + + /* Set all available releases */ + $this->Releases = $tmp; + $this->usedClasses = array(); + + /* Check the configuration */ + if(count($this->Classes) && (!empty($this->Release))){ + foreach($this->Classes as $class){ + $this->resolveObject($class); + } + } + } + + + /* Capture posts, and call opnen close tag */ + function save_object() + { + $once = true; + + if(isset($_GET['expand']) && isset($_GET['id'])){ + if(isset($this->Result[$_GET['id']])){ + $this->Result[$_GET['id']]['Open'] =true ; + } + } + + if(isset($_GET['compress']) && isset($_GET['id'])){ + if(isset($this->Result[$_GET['id']])){ + unset($this->Result[$_GET['id']]['Open']); + } + } + + foreach($_POST as $name => $value ){ + + /* check for open tag request */ + if(preg_match("/^open_/",$name) && $once){ + $once = false; + $value = preg_replace("/^open_/","",$name); + $value = preg_replace("/_.*$/","",$value); + $this->Result[$value]['Open'] =true ; + } + /* Check for close tag request */ + if(preg_match("/^close_/",$name) && $once){ + $once = false; + $value = preg_replace("/^close_/","",$name); + $value = preg_replace("/_.*$/","",$value); + unset($this->Result[$value]['Open']); + } + if(preg_match("/^reloadList/",$name)){ + $this->InitCalled = false; + } + } + } + + + /* returns an array with all possibly release types */ + function getBranches($base = false,$prefix = "") + { + if(!$base){ + $base = $this->base; + } + return(get_all_releases_from_base($base,true)); + } + + + /* This function calls all nescessary functions to generate the fai class summary tree */ + function execute() + { + + /* Skip this if fai is deactivated */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(empty($tmp)){ + $str = "

"._("You can't use this plugin until FAI is activated.")."

"; + return $str; + } + + /* Check if we must (re)init the this tab */ + if(!$this->InitCalled){ + $this->init(); + } + + if(isset($_GET['show'])){ + $ldap = $this->config->get_ldap_link(); + $ldap->cat(base64_decode($_GET['id']), array('FAIscript', 'FAIhook', 'FAItemplateFile')); + $attrs = $ldap->fetch(); + if($_GET['type'] == "FAIscript"){ + $str = $attrs['FAIscript'][0]; + }elseif($_GET['type'] == "FAIhook"){ + $str = $attrs['FAIscript'][0]; + }elseif($_GET['type'] == "FAItemplate"){ + $str = $attrs['FAItemplateFile'][0]; + } + echo "
".$str."
"; + exit(); + } + + /* Get smarty class & assign created summary results */ + $smarty = get_smarty(); + $acl = $this->ui->has_complete_category_acls($this->base,"fai"); + $smarty->assign("readable", preg_match("/r/",$acl)); + + $this->ObjectList = $this->createSummary($this->Result); + $smarty->assign("objectList",$this->ObjectList); + return($smarty->fetch (get_template_path('faiSummary.tpl', TRUE, dirname(__FILE__)))); + } + + + /* Create output of from resolved fai objects */ + function createSummary($data) + { + /* Don't generate any output, if there is no result */ + $str =" "; + if(!count($this->Result)){ + $str.="
"; + $str.= (_("This object has no FAI classes assigned.")); + $str.= "
"; + return($str); + } + + /* walk through all classes */ + foreach($data as $key => $entry){ + + $image = "".$this->objs[$key]["; + if(!isset($entry['Open'])){ + $str .= " + + + "._("Open")." "; + $str .= $image." "; + $str .= " ".$this->objs[$key]['Name'].""; + }else{ + $str .= " + + "._("Close")." "; + $str .= $image." "; + $str .= "".$this->objs[$key]['Name'].""; + + /* Display FAItemplate FAIhook FAIscript entries */ + if(in_array($key,array("FAItemplate","FAIhook","FAIscript"))){ + + $nums = array(); + $tmp = array(); + if($key == "FAIscript"){ + if(is_array($entry['Entries'])){ + foreach($entry['Entries'] as $scripts){ + foreach($scripts as $script){ + + if(!isset($nums[$script['cn'][0]])){ + $nums[$script['cn'][0]]= 0; + } + $nums[$script['cn'][0]] ++; + + $tmp[$script['FAIpriority'][0].$script['cn'][0].$script['CLASS']] = $script; + } + } + } + krsort($tmp);; + + $entry['Entries'] = $tmp; + }else{ + $tmp = array(); + foreach($entry['Entries'] as $script){ + $tmp[$script['cn'][0].$script['CLASS']] = $script; + if(!isset($nums[$script['cn'][0]])){ + $nums[$script['cn'][0]]= 0; + } + $nums[$script['cn'][0]] ++; + } + ksort($tmp); + $entry['Entries'] = $tmp; + } + + foreach($entry['Entries'] as $cn => $data){ + + if(isset($nums[$data['cn'][0]]) && ($nums[$data['cn'][0]] > 1)){ + $str .=""; + }else{ + $str .=""; + } + + $str .= ""; + $str .= $image." "; + if(isset($data['FAIpriority'][0])){ + $str .= "(".$data['FAIpriority'][0].")"; + } + + $str .= " ".$data['cn'][0]; + if(isset($data['description'][0])){ + $str .= " [".$data['description'][0]."]"; + } + $str .= ""; + $str .= "".$data['CLASS'].""; + $str .= ""; + } + } + + /* Create variable entries */ + if(in_array($key,array("FAIvariable"))) { + foreach($entry['Entries'] as $cn => $data){ + $str .=""; + $str .= $image." ".$data['cn'][0]; + if(isset($data['description'][0])){ + $str .= " [".$data['description'][0]."] "; + } + /* Only display FAIvariableContent if description dosn't contain [*] */ + if(isset($data['description'][0]) && !preg_match("#\[\*\]#",$data['description'][0])){ + $str .=" = '".$data['FAIvariableContent'][0]."'"; + } + $str .= "".$data['CLASS'].""; + $str .=""; + } + } + + /* Create packagelist entries */ + if(in_array($key,array("FAIpackageList"))) { + ksort($entry['Entries']); + foreach($entry['Entries'] as $data){ + $str .=""; + $str .= $image." ".$data['cn'][0]; + $str .= "".$data['CLASS'].""; + $str .= "";; + } + } + + /* Create partition table entries */ + if(in_array($key,array("FAIpartitionTable"))) { + foreach($entry['Entries'] as $cn => $data){ + $str .= ""; + $str .= $image." ".$data['name']; + $str .= "".$data['CLASS'].""; + $str .= ""; + ksort($data['partitions']); + + $str .= ""; + $str .= " + + + + + + + + + "; + + $i = 0; + foreach($data['partitions'] as $key => $part){ + $i ++; + + if($i%2 == 1){ + $c = " class='rowxp1'"; + $d = " class='list1'"; + }else{ + $c = " class='rowxp0'"; + $d = " class='list0'"; + } + + $str.=" + + + + + + + + "; + } + $str .="
"._("No.").""._("Name").""._("FS options").""._("Mount options").""._("Size in MB").""._("Mount point").""._("Type")."
".$i."".$part['cn'][0]."".$part['FAIfsType'][0]."".$part['FAIfsOptions'][0]."".$part['FAIpartitionSize'][0]."".$part['FAImountPoint'][0]."".$part['FAIpartitionType'][0]."
"; + } + } + } + } + $str .=""; + return($str); + } + + + /* resolve specified object to append it to our object tree */ + function resolveObject($class) + { + $ldap = $this->config->get_ldap_link(); + $dn = $this->Releases [$this->Release]; + $resolvedClasses = get_all_objects_for_given_base($dn,"(&(objectClass=FAIclass)(cn=".$class."))"); + + /* Try to fetch all types of fai objects with the given cn */ + foreach($resolvedClasses as $obj){ + + $dn = $obj['dn']; + $ldap->cat($dn); + + while($attrs = $ldap->fetch()){ + + foreach($this-> objs as $key => $rest){ + if(in_array($key,$attrs['objectClass'])){ + + if(!isset($this->usedClasses[$key][$class])){ + $this->usedClasses[$key][$class] = true; + switch($key){ + case "FAIprofile": $this->prepare_FAIprofile($attrs);break; + case "FAIscript": $this->prepare_FAIscript($attrs);break; + case "FAIhook": $this->prepare_FAIhook($attrs);break; + case "FAIvariable": $this->prepare_FAIvariable($attrs);break; + case "FAItemplate": $this->prepare_FAItemplate($attrs);break; + case "FAIpackageList": $this->prepare_FAIpackageList($attrs);break; + case "FAIpartitionTable": $this->prepare_FAIpartitionTable($attrs);break; + } + } + + } + } + } + } + } + + /* Prepare fai script */ + function prepare_FAIscript($data) + { + if(isset($this->Result['FAIscript']['Entries'])){ + $current = $this->Result['FAIscript']['Entries']; + }else{ + $current = array(); + } + $ldap = $this->config->get_ldap_link(); + $ldap->cd($data['dn']); + $ldap->search("(objectClass=FAIscriptEntry)",array("cn","description","FAIpriority")); + while($attrs = $ldap->fetch()){ + $attrs['CLASS'] = $data['cn'][0]; + $current[$attrs['FAIpriority'][0]][] = $attrs; + } + $this->Result['FAIscript']['Entries'] = $current ; + } + + + /* Prepare fai script */ + function prepare_FAIpartitionTable($data) + { + if(isset($this->Result['FAIpartitionTable']['Entries'])){ + $current = $this->Result['FAIpartitionTable']['Entries']; + }else{ + $current = array(); + } + + /* get subentries */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($data['dn']); + $ldap->search("(objectClass=FAIpartitionDisk)",array("cn","description")); + $disks = array(); + + /* Create an array which is sortable by priority */ + while($attrs = $ldap->fetch()){ + $attrs['CLASS'] = $data['cn'][0]; + $disks[$attrs['cn'][0]]= $attrs; + if(isset($attrs['description'][0])){ + $disks[$attrs['cn'][0]]['name'] = $attrs['cn'][0]." [".$attrs['description'][0]."]"; + }else{ + $disks[$attrs['cn'][0]]['name'] = $attrs['cn'][0]; + } + $disks[$attrs['cn'][0]]['dn'] = $attrs['dn']; + $disks[$attrs['cn'][0]]['partitions'] = array(); + } + + /* Sort by priority */ + foreach($disks as $key => $disk){ + $ldap->cd($disk['dn']); + $ldap->search("(objectClass=FAIpartitionEntry)",array("*")); + while($attrs = $ldap->fetch()){ + if(!isset($attrs['FAIfsOptions'][0])){ + $attrs['FAIfsOptions'][0] = ""; + } + $attrs['CLASS'] = $data['cn'][0]; + $disks[$key]['partitions'][$attrs['cn'][0]] = $attrs; + } + } + $this->Result['FAIpartitionTable']['Entries'] = $disks; + } + + + /* Create template entry */ + function prepare_FAItemplate($data) + { + $current = array(); + if(isset($this->Result['FAItemplate']['Entries'])){ + $current = $this->Result['FAItemplate']['Entries']; + } + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($data['dn']); + $ldap->search("(objectClass=FAItemplateEntry)",array("cn","description")); + while($attrs = $ldap->fetch()){ + $attrs['CLASS'] = $data['cn'][0]; + $current[] = $attrs; + } + $this->Result['FAItemplate']['Entries'] = $current ; + } + + + /* Create a package list */ + function prepare_FAIpackageList($data) + { + $current = array(); + if(isset($this->Result['FAIpackageList']['Entries'])){ + $current = $this->Result['FAIpackageList']['Entries']; + } + if(isset($data['FAIpackage'])){ + unset($data['FAIpackage']['count']); + foreach($data['FAIpackage'] as $pkg){ + $attrs['CLASS'] = $data['cn'][0]; + $attrs['cn'][0] = $pkg; + $current[$pkg] = $attrs; + } + } + $this->Result['FAIpackageList']['Entries'] = $current ; + } + + + /* Create a variable entry */ + function prepare_FAIvariable($data) + { + $current = array(); + if(isset($this->Result['FAIvariable']['Entries'])){ + $current = $this->Result['FAIvariable']['Entries']; + } + $ldap = $this->config->get_ldap_link(); + $ldap->cd($data['dn']); + $ldap->search("(objectClass=FAIvariableEntry)",array("cn","description","FAIvariableContent")); + while($attrs = $ldap->fetch()){ + $attrs['CLASS'] = $data['cn'][0]; + $current[] = $attrs; + } + $this->Result['FAIvariable']['Entries'] = $current ; + } + + /* Create a hook entry */ + function prepare_FAIhook($data) + { + $current = array(); + if(isset($this->Result['FAIhook']['Entries'])){ + $current = $this->Result['FAIhook']['Entries']; + } + $ldap = $this->config->get_ldap_link(); + $ldap->cd($data['dn']); + $ldap->search("(objectClass=FAIhookEntry)",array("cn","description")); + while($attrs = $ldap->fetch()){ + $attrs['CLASS'] = $data['cn'][0]; + $current[$attrs['cn'][0]] = $attrs; + } + $this->Result['FAIhook']['Entries'] = $current ; + } + + + /* Create a new Profile entry */ + function prepare_FAIprofile($data) + { + $classes = split("\ ",$data['FAIclass'][0]); + foreach($classes as $class){ + $class = trim($class); + $this->resolveObject($class); + } + } + + /* Return plugin informations for acl handling * / + static function plInfo() + { + return (array( + "plShortName" => _("Summary"), + "plDescription" => _("FAI summary"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 15, + "plSection" => array("administration"), + "plCategory" => array("workstation","server","fai","ogroups") , + "plProvidedAcls"=> array( + "readable" => _("Viewable")), + )); + } + */ +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiTemplate.inc b/gosa-core/plugins/admin/fai/class_faiTemplate.inc new file mode 100644 index 000000000..5f4fcbf14 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiTemplate.inc @@ -0,0 +1,579 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAItemplate"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAItemplateEntry"; + var $subClasses = array("top","FAIclass","FAItemplateEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = "faiTemplateEntry"; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description","FAItemplatePath","FAIowner","FAImode"); + var $sub_Load_Later = array("FAItemplateFile"); + var $sub64coded = array(); + var $subBinary = array("FAItemplateFile"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $SubObjects = array(); // All leafobjects of this object + + var $FAIstate = ""; + var $ui; + var $view_logged = FALSE; + + function faiTemplate (&$config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. + */ + if($dn != "new"){ + $this->dn =$dn; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + + $attrs_to_search = $this->subAttributes; + $attrs_to_search[] = "FAIstate"; + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + /* Set status for save management */ + $objects = array(); + $objects['status'] = "FreshLoaded"; + $objects['dn'] = $object['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $this->SubObjects[$objects['cn']] = $objects; + } + } + $this->ui = get_userinfo(); + } + + + /* Reload some attributes */ + function get_object_attributes($object,$attributes) + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($object['dn'],$attributes); + $tmp = $ldap->fetch(); + + foreach($attributes as $attrs){ + if(isset($tmp[$attrs][0])){ + $var = $tmp[$attrs][0]; + + /* Check if we must decode some attributes */ + if(in_array_ics($attrs,$this->sub64coded)){ + $var = base64_decode($var); + } + + /* check if this is a binary entry */ + if(in_array_ics($attrs,$this->subBinary)){ + $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0); + } + + $var = stripslashes($var); + + $object[$attrs] = $var; + } + } + return($object); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","fai/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* New Listhandling + */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^editscript_/",$name)&&($once)){ + $once = false; + $entry = preg_replace("/^editscript_/","",$name); + $entry = base64_decode(preg_replace("/_.*/","",$entry)); + $obj = $this->SubObjects[$entry]; + + $acl_dn = $this->acl_base_for_current_object($obj['dn']); + $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); + if(preg_match("/r/",$acl)){ + if($obj['status'] == "FreshLoaded"){ + $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); + } + $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); + $this->dialog->set_acl_base($this->acl_base); + $this->dialog->set_acl_category("fai"); + + $_SESSION['objectinfo'] = $obj['dn']; + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + } + if(preg_match("/^deletescript_/",$name)&&($once)){ + $once = false; + $entry = preg_replace("/^deletescript_/","",$name); + $entry = base64_decode(preg_replace("/_.*/","",$entry)); + $obj = $this->SubObjects[$entry]; + + $acl_dn = $this->acl_base_for_current_object($obj['dn']); + $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); + if(preg_match("/d/",$acl)){ + $status = $this->SubObjects[$entry]['status']; + if($status == "edited" || $status == "FreshLoaded"){ + $this->SubObjects[$entry]['status']= "delete"; + }else{ + unset($this->SubObjects[$entry]); + } + } + } + } + + /* Edit entries via GET */ + if(isset($_GET['act']) && isset($_GET['id'])){ + if($_GET['act'] == "edit" && isset($this->SubObjects[$_GET['id']])){ + $obj = $this->SubObjects[$_GET['id']]; + if($obj['status'] == "FreshLoaded"){ + $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); + } + $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); + $this->dialog->acl = $this->acl; + $_SESSION['objectinfo'] = $obj['dn']; + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + } + + /* Add new sub object */ + if(isset($_POST['AddSubObject'])){ + $acl_dn = "cn=dummy,".$this->acl_base_for_current_object($this->dn); + $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); + + if(preg_match("/c/",$acl)){ + $this->dialog= new $this->subClassName($this->config,"new"); + $this->dialog->set_acl_base($this->acl_base); + $this->dialog->set_acl_category("fai"); + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + } + + if($this->dn != "new"){ + $_SESSION['objectinfo']= $this->dn; + } + + /* Save Dialog */ + if(isset($_POST['SaveSubObject']) && is_object($this->dialog)){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)>0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + /* Get return object */ + $obj = $this->dialog->save(); + if(isset($obj['remove'])){ + + $old_stat = $this->SubObjects[$obj['remove']['from']]['status']; + + /* Depending on status, set new status */ + if($old_stat == "edited" || $old_stat == "FreshLoaded"){ + $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; + }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + unset($this->SubObjects[$obj['remove']['from']]); + } + $obj['status'] = "new"; + $this->SubObjects[$obj['remove']['to']] = $obj; + unset($this->SubObjects[$obj['remove']['to']]['remove']); + }else{ + if($obj['status'] == "FreshLoaded"){ + $obj['status'] = "edited"; + } + $this->SubObjects[$obj['cn']]=$obj; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + } + + /* Sort entries */ + $tmp = $keys = array(); + foreach($this->SubObjects as $key => $entry){ + $keys[$key]=$key; + } + natcasesort($keys); + foreach($keys as $key){ + $tmp[$key]=$this->SubObjects[$key]; + } + $this->SubObjects = $tmp; + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + + /* Print dialog if $this->dialog is set */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return($display); + } + + /* Divlist Containing FAItemplates */ + $divlist = new divSelectBox("FAItemplates"); + $divlist->setHeight(400); + + $tmp = $this->getList(true); + + /* Create div list with all sub entries listed */ + foreach($this->SubObjects as $key => $name){ + + /* Skip removed entries */ + if($name['status'] == "delete") continue; + + /* Get permissions */ + $dn = $this->acl_base_for_current_object($name['dn']); + $acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry") ; + $act = ""; + + /* Hide delete icon if this object is freezed */ + if(preg_match("/freeze/",$this->FAIstate)){ + $act .= ""; + }else{ + $act .= ""; + if(preg_match("/d/",$acl)){ + $act .=""; + } + } + + /* Check acls for download icon */ + $s_acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry","FAItemplateFile") ; + if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){ + $down = ""; + }else{ + $down = " + "._("Download")." + "; + } + + /* Check if we are allowed to view this object */ + $s_acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry","cn") ; + if(preg_match("/r/",$s_acl)){ + + $edit_link = "".$tmp[$key].""; + $divlist->AddEntry(array( array("string"=> $edit_link), + array("string"=>$down , "attach" => "style='width:20px;'"), + array("string"=>str_replace("%s",base64_encode($key),$act), + "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); + } + } + $smarty->assign("Entry_divlist",$divlist->DrawList()); + /* Divlist creation complete + */ + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + }else{ + $smarty->assign($attrs,($this->$attrs)); + } + } + + $dn = $this->acl_base_for_current_object($this->dn); + $smarty->assign("sub_object_is_addable", + preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiTemplateEntry")) && + !preg_match("/freeze/",$this->FAIstate)); + + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL",$this->getacl($attr)); + } + + $display.= $smarty->fetch(get_template_path('faiTemplate.tpl', TRUE)); + return($display); + } + + + function acl_base_for_current_object($dn) + { + if($dn == "new"){ + if($this->dn == "new"){ + $dn= $_SESSION['CurrentMainBase']; + }else{ + $dn = $this->dn; + } + } + return($dn); + } + + + /* Generate listbox friendly SubObject list + */ + function getList(){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + + if((isset($obj['description']))&&(!empty($obj['description']))){ + if(strlen($obj['description']) > 40){ + $obj['description'] = substr($obj['description'],0,40)."..."; + } + $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + }else{ + $a_return[$obj['cn']]= $obj['cn']; + } + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $this->dn; + } + + prepare_to_save_FAI_object($use_dn,array(),true); + new log("remove","fai/".get_class($this),$use_dn,$this->attributes); + + foreach($this->SubObjects as $name => $obj){ +# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']); + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $obj['dn']; + } + prepare_to_save_FAI_object($use_dn,array(),true); + } + $this->handle_post_events("remove"); + } + + + /* Save data to object + */ + function save_object() + { + if((isset($_POST['FAItemplate_posted'])) && (!preg_match("/freeze/",$this->FAIstate))){ + plugin::save_object(); + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + prepare_to_save_FAI_object($this->dn,$this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/template with dn '%s' failed."),$this->dn)); + + if($this->initially_was_account){ + new log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + new log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + + /* Do object tagging */ + $this->handle_object_tagging(); + + /* Prepare FAIscriptEntry to write it to ldap + * First sort array. + * Because we must delete old entries first. + * After deletion, we perform add and modify + */ + $Objects = array(); + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "FreshLoaded"){ + unset($this->SubObjects[$name]); + } + } + + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "delete"){ + $Objects[$name] = $obj; + } + } + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] != "delete"){ + $Objects[$name] = $obj; + } + } + + foreach($Objects as $name => $obj){ + + foreach($this->sub64coded as $codeIt){ + $obj[$codeIt]=base64_encode($obj[$codeIt]); + } + $tmp = array(); + $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); + foreach($attributes as $attrs){ + if(empty($obj[$attrs])){ + $obj[$attrs] = array(); + } + $tmp[$attrs] =($obj[$attrs]); + } + + $tmp['objectClass'] = $this->subClasses; + + $sub_dn = "cn=".$obj['cn'].",".$this->dn; + + if($obj['status']=="new"){ + $ldap->cat($sub_dn,array("objectClass")); + if($ldap->count()){ + $obj['status']="edited"; + } + } + + /* Check if gosaAdministrativeUnitTag is required as object class */ + if($obj['status'] == "edited"){ + $ldap->cat($sub_dn,array("objectClass")); + $attrs = $ldap->fetch(); + if(isset($attrs['objectClass'])){ + if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ + $tmp['objectClass'][] = "gosaAdministrativeUnitTag"; + } + } + } + + if($obj['status'] == "delete"){ + prepare_to_save_FAI_object($sub_dn,array(),true); + $this->handle_post_events("remove"); + }elseif($obj['status'] == "edited"){ + prepare_to_save_FAI_object($sub_dn,$tmp); + $this->handle_post_events("modify"); + }elseif($obj['status']=="new"){ + prepare_to_save_FAI_object($sub_dn,$tmp); + $this->handle_post_events("add"); + } + + + $this->handle_object_tagging($sub_dn, $this->gosaUnitTag); + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($source['dn']); + + $attrs_to_search = $this->subAttributes; + $attrs_to_search[] = "FAIstate"; + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + /* Set status for save management */ + $objects = array(); + $objects['status'] = "edited"; + $objects['dn'] = $object['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); + + $this->SubObjects[$objects['cn']] = $objects; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Template"), + "plDescription" => _("FAI template"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 24, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name")." ("._("Readonly").")", + "description" => _("Description")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiTemplateEntry.inc b/gosa-core/plugins/admin/fai/class_faiTemplateEntry.inc new file mode 100644 index 000000000..05c6b72ac --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiTemplateEntry.inc @@ -0,0 +1,275 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("cn","description","FAItemplateFile","FAItemplatePath","FAImode","user","group","binary","FAIowner"); + var $objectclasses= array(); + + var $orig_cn = ""; + + var $dn = ""; + var $cn = ""; + var $FAItemplateFile = ""; + var $FAItemplatePath = ""; + var $description = ""; + var $status = "new"; + var $FAImode = "0640"; + var $FAIowner = "root.root"; + var $user = "root"; + var $group = "root"; + var $binary = false; + var $parent = NULL; + var $FAIstate = ""; + + function faiTemplateEntry (&$config, $dn= NULL,$object=false) + { + plugin::plugin ($config, $dn); + + if((isset($object['cn'])) && (!empty($object['cn']))){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = $name; + $this->$oname=$value; + } + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + }else{ + $this->status = "new"; + $this->orig_cn= false; + } + + $this->user = explode( '.', $this->FAIowner ); + $this->group = $this->user[1]; + $this->user = $this->user[0]; + + $_SESSION['binary'] = $this->FAItemplateFile; + $_SESSION['binarytype'] = 'octet-stream'; + $_SESSION['binaryfile'] = basename( $this->FAItemplatePath ); + + if(!empty($this->dn) && $this->dn != "new"){ + $ldap = $this->config->get_ldap_link(); + $_SESSION['binary'] =$ldap->get_attribute($this->dn,"FAItemplateFile"); + $this->FAItemplateFile = $_SESSION['binary']; + } + + $this->FAImode= sprintf("%0.4s", $this->FAImode)." "; + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $smarty->assign("rand", rand(0, 10000)); + $display = ""; + + if(isset($_POST['TmpFileUpload']) && $this->acl_is_writeable("FAItemplateFile")){ + if($str=file_get_contents($_FILES['FAItemplateFile']['tmp_name'])){ + $this->FAItemplateFile = $str; + + /* If we don't have a filename set it from upload filename. */ + if( 0 == strlen( $this->FAItemplatePath )){ + $this->FAItemplatePath = $_FILES['FAItemplateFile']['name']; + } + + $_SESSION['binary'] = $this->FAItemplateFile; + $_SESSION['binarytype'] = 'octet-stream'; + $_SESSION['binaryfile'] = basename( $this->FAItemplatePath ); + } + } + + $status= _("no file uploaded yet"); + + $bStatus = false; // Hide download icon on default + + if(strlen($this->FAItemplateFile)){ + + $status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->FAItemplateFile)); + $bStatus = true; // Display download icon + } + $smarty->assign("status",$status); + $smarty->assign("bStatus",$bStatus); + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + }else{ + $smarty->assign($attrs,($this->$attrs)); + } + } + + /* Assign file modes */ + $tmode= "$this->FAImode "; + foreach (array("s", "u", "g", "o") as $type){ + $current= substr($tmode, 0, 1); + $tmode= preg_replace("/^./", "", $tmode); + $nr= 1; + while ($nr < 5){ + if ($current & $nr){ + $smarty->assign($type.$nr, "checked"); + } else { + $smarty->assign($type.$nr, ""); + } + $nr+= $nr; + } + } + + $smarty->assign("FAItemplateFile",""); + + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL",$this->getacl($attr,preg_match("/freeze/",$this->FAIstate))); + } + + /* We now split cn/FAItemplatePath to make things more clear... */ + $smarty->assign("cn", basename($this->FAItemplatePath)); + $smarty->assign("templatePath", dirname($this->FAItemplatePath)); + + $display.= $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + /* Check if form is posted and we are not freezed */ + if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ + + plugin::save_object(); + + /* Set user.group (FAIowner) attribute */ + if(isset($_POST['group']) && isset($_POST["user"]) && $this->acl_is_writeable("FAIowner")){ + $this->FAIowner = $_POST["user"].'.'.$_POST["group"]; + $this->user = $_POST['user']; + $this->group= $_POST['group']; + } + + /* Check if permissions have changed */ + if($this->acl_is_writeable("FAImode")){ + + /* Save mode */ + $tmode= ""; + foreach (array("s", "u", "g", "o") as $type){ + $nr= 1; + $dest= 0; + while ($nr < 5){ + if (isset($_POST["$type$nr"])){ + $dest+= $nr; + } + $nr+= $nr; + } + $tmode= $tmode.$dest; + } + $this->FAImode= $tmode; + + /* Assemble cn/FAItemplatePath */ + $this->cn= preg_replace('/\/+/', '/', $this->FAItemplatePath.'/'.$this->cn); + $this->FAItemplatePath= $this->cn; + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ + $message[] =_("There is already a template with the given name."); + } + + if(empty($this->FAItemplateFile)){ + $message[]=_("Please specify a value for attribute 'file'."); + } + + if(!preg_match('/^\//', $this->FAItemplatePath)){ + $message[]=_("Please specify a valid value for attribute 'Destination path'."); + } + + if(empty($this->cn)){ + $message[] = _("Please enter a file name."); + } + +# echo $this->cn; +# if(preg_match('/\//', $this->cn)){ +# $message[] = _("The file name should not contain / characters."); +# # } + + if(empty($this->user)){ + $message[] = _("Please enter a user."); + } + elseif(preg_match("/[^0-9a-z]/i",$this->user)){ + $message[] = _("Please enter a valid user. Only a-z/0-9 are allowed."); + } + + if(empty($this->group)){ + $message[] = _("Please enter a group."); + } + elseif(preg_match("/[^0-9a-z]/i",$this->group)){ + $message[] = _("Please enter a valid group. Only a-z/0-9 are allowed."); + } + + return ($message); + } + + function save() + { + $tmp=array(); + foreach($this->attributes as $attrs){ + $tmp[$attrs] = $this->$attrs; + } + + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ + $tmp['remove']['from'] = $this->orig_cn; + $tmp['remove']['to'] = $tmp['cn']; + } + + $tmp['dn'] = $this->dn; + $tmp['status'] = $this->status; + + return($tmp); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Template entry"), + "plDescription" => _("FAI template entry"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 25, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name"), + "description" => _("Description"), + "FAItemplateFile" => _("Template file"), + "FAItemplatePath" => _("Template path"), + "FAIowner" => _("File owner"), + "FAImode" => _("File permissions")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiVariable.inc b/gosa-core/plugins/admin/fai/class_faiVariable.inc new file mode 100644 index 000000000..ae6b79a99 --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiVariable.inc @@ -0,0 +1,475 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIvariable"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAIvariableEntry"; + var $subClasses = array("top","FAIclass","FAIvariableEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = "faiVariableEntry"; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description","FAIvariableContent"); + var $sub64coded = array(); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $SubObjects = array(); // All leafobjects of this object + + var $FAIstate = ""; + var $ui ; + var $view_logged = FALSE; + + function faiVariable (&$config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + if($dn != "new"){ + $this->dn =$dn; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + + $attrs_to_search = $this->subAttributes; + $attrs_to_search[] = "FAIstate"; + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + /* Set status for save management */ + foreach($this->subAttributes as $attrs){ + if(!isset($object[$attrs][0])){ + $this->SubObjects[$object['cn'][0]][$attrs]=""; + }else{ + $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; + } + } + + foreach($this->sub64coded as $codeIt){ + $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); + } + + $this->SubObjects[$object['cn'][0]]['status'] = "edited"; + $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; + } + + } + $this->ui = get_userinfo(); + } + + + function acl_base_for_current_object($dn) + { + if($dn == "new"){ + if($this->dn == "new"){ + $dn= $_SESSION['CurrentMainBase']; + }else{ + $dn = $this->dn; + } + } + return($dn); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","fai/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add new sub object */ + if(isset($_POST['AddSubObject'])){ + $this->dialog= new $this->subClassName($this->config,"new"); + $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn)); + $this->dialog->set_acl_category("fai"); + $this->dialog->parent = &$this; + $this->is_dialog=true; + } + + if($this->dn != "new"){ + $_SESSION['objectinfo']= $this->dn; + } + + + /* Edit selected Sub Object */ + if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ + + $var = $_POST['SubObject'][0]; + $c_dn = $this->acl_base_for_current_object($this->SubObjects[$var]['dn']); + $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$var]); + $this->dialog->set_acl_category("fai"); + $this->dialog->set_acl_base($c_dn); + $this->dialog->parent = &$this; + $_SESSION['objectinfo'] = $this->SubObjects[$var]['dn']; + $this->is_dialog=true; + } + + /* Remove Sub object */ + if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ + foreach($_POST['SubObject'] as $var){ + + $c_dn = $this->acl_base_for_current_object($this->SubObjects[$var]['dn']); + $acl = $this->ui->get_permissions($c_dn,"fai/faiVariable"); + if(preg_match("/d/",$acl)){ + if($this->SubObjects[$var]['status'] == "edited"){ + $this->SubObjects[$var]['status']= "delete"; + }else{ + unset($this->SubObjects[$var]); + } + } + } + } + + /* Save Dialog */ + if(isset($_POST['SaveSubObject'])){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)>0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $obj = $this->dialog->save(); + if(isset($obj['remove'])){ + if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ + $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; + }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + unset($this->SubObjects[$obj['remove']['from']]); + } + $obj['status'] = "new"; + $this->SubObjects[$obj['remove']['to']] = $obj; + unset($this->SubObjects[$obj['remove']['to']]['remove']); + }else{ + $this->SubObjects[$obj['cn']]=$obj; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + } + + /* Sort entries */ + $tmp = $keys = array(); + foreach($this->SubObjects as $key => $entry){ + $keys[$key]=$key; + } + natcasesort($keys); + foreach($keys as $key){ + $tmp[$key]=$this->SubObjects[$key]; + } + $this->SubObjects = $tmp; + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + + /* Print dialog if $this->dialog is set */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return($display); + } + + $ui = get_userinfo(); + $ret = $this->getList(); + $tmp = array(); + foreach($this->SubObjects as $key => $obj){ + $acl = $ui->get_permissions($obj['dn'],"fai/faiVariableEntry"); + if(preg_match("/r/",$acl) || $obj['dn'] == "new"){ + $tmp[$key] = $ret[$key]; + } + } + $smarty->assign("SubObjects",$tmp); + + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs)))); + }else{ + $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs))); + } + } + + $c_dn = $this->acl_base_for_current_object($this->dn); + $smarty->assign("is_createable", preg_match("/c/",$this->ui->get_permissions($c_dn,"fai/faiVariableEntry")) && $this->FAIstate!="freeze"); + $smarty->assign("is_removeable", preg_match("/d/",$this->ui->get_permissions($c_dn,"fai/faiVariableEntry")) && $this->FAIstate!="freeze"); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation) { + $smarty->assign($name."ACL",$this->getacl($name)); + } + + + $display.= $smarty->fetch(get_template_path('faiVariable.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList(){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + + if((isset($obj['description']))&&(!empty($obj['description']))&&(!preg_match("/\[\*\]/",$obj['description']))){ + if (preg_match("/\[\*\]/", $obj['description'])){ + $a_return[$obj['cn']]= $obj['cn']." [".preg_replace("/\s*\[\*\]\s*/", "", $obj['description'])."]"; + } else { + $a_return[$obj['cn']]= $obj['cn']."=".$obj['FAIvariableContent']." [".$obj['description']."]"; + } + }else{ + if (preg_match("/\[\*\]/", $obj['description'])){ + $a_return[$obj['cn']]= $obj['cn']; + } else { + $a_return[$obj['cn']]= $obj['cn']."=".$obj['FAIvariableContent']; + } + } + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + if($this->acl_is_removeable()){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $this->dn; + } + + prepare_to_save_FAI_object($use_dn,array(),true); + new log("remove","fai/".get_class($this),$use_dn,$this->attributes); + + foreach($this->SubObjects as $name => $obj){ + $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); + if($_SESSION['faifilter']['branch'] == "main"){ + $use_dn = $obj['dn']; + } + prepare_to_save_FAI_object($use_dn,array(),true); + } + $this->handle_post_events("remove"); + } + } + + + /* Save data to object + */ + function save_object() + { + if((isset($_POST['FAIvariable_posted'])) && ($this->FAIstate != "freeze") ){ + plugin::save_object(); + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + } + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + prepare_to_save_FAI_object($this->dn,$this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/variable with dn '%s' failed."),$this->dn)); + + if($this->initially_was_account){ + new log("modify","fai/".get_class($this),$this->dn,$this->attributes); + }else{ + new log("create","fai/".get_class($this),$this->dn,$this->attributes); + } + + /* Do object tagging */ + $this->handle_object_tagging(); + + /* Prepare FAIscriptEntry to write it to ldap + * First sort array. + * Because we must delete old entries first. + * After deletion, we perform add and modify + */ + $Objects = array(); + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "delete"){ + $Objects[$name] = $obj; + } + } + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] != "delete"){ + $Objects[$name] = $obj; + } + } + + foreach($Objects as $name => $obj){ + + foreach($this->sub64coded as $codeIt){ + $obj[$codeIt]=base64_encode($obj[$codeIt]); + } + + $tmp = array(); + foreach($this->subAttributes as $attrs){ + if(empty($obj[$attrs])){ + $obj[$attrs] = array(); + } + $tmp[$attrs] = $obj[$attrs]; + } + + $tmp['objectClass'] = $this->subClasses; + + $sub_dn = "cn=".$obj['cn'].",".$this->dn; + + if($obj['status']=="new"){ + $ldap->cat($sub_dn,array("objectClass")); + if($ldap->count()){ + $obj['status']="edited"; + } + } + + /* Check if gosaAdministrativeUnitTag is required as object class */ + if($obj['status'] == "edited"){ + $ldap->cat($sub_dn,array("objectClass")); + $attrs = $ldap->fetch(); + if(isset($attrs['objectClass'])){ + if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ + $tmp['objectClass'][] = "gosaAdministrativeUnitTag"; + } + } + } + + if($obj['status'] == "delete"){ + prepare_to_save_FAI_object($sub_dn,array(),true); + $this->handle_post_events("remove"); + }elseif($obj['status'] == "edited"){ + prepare_to_save_FAI_object($sub_dn,$tmp); + $this->handle_post_events("modify"); + }elseif($obj['status']=="new"){ + prepare_to_save_FAI_object($sub_dn,$tmp); + $this->handle_post_events("add"); + } + + $this->handle_object_tagging($sub_dn, $this->gosaUnitTag); + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($source['dn']); + $attrs_to_search = $this->subAttributes; + $attrs_to_search[] = "FAIstate"; + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); + while($object = $ldap->fetch()){ + + /* Skip objects, that are tagged as removed */ + if(isset($object['FAIstate'][0])){ + if(preg_match("/removed$/",$object['FAIstate'][0])){ + continue; + } + } + + /* Set status for save management */ + foreach($this->subAttributes as $attrs){ + if(!isset($object[$attrs][0])){ + $this->SubObjects[$object['cn'][0]][$attrs]=""; + }else{ + $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; + } + } + foreach($this->sub64coded as $codeIt){ + $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); + } + $this->SubObjects[$object['cn'][0]]['status'] = "edited"; + $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Variable"), + "plDescription" => _("FAI variable"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 22, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name")." ("._("Read only").")", + "description" => _("Description")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/class_faiVariableEntry.inc b/gosa-core/plugins/admin/fai/class_faiVariableEntry.inc new file mode 100644 index 000000000..5fc6ef01e --- /dev/null +++ b/gosa-core/plugins/admin/fai/class_faiVariableEntry.inc @@ -0,0 +1,155 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("cn","description","FAIvariableContent"); + var $objectclasses= array(); + + var $orig_cn = ""; + var $dn = ""; + var $cn = ""; + var $FAIvariableContent = ""; + var $description = ""; + var $status = "new"; + var $parent = NULL; + var $FAIstate = ""; + + function faiVariableEntry (&$config, $dn= NULL,$object=false) + { + plugin::plugin ($config, $dn); + if((isset($object['cn'])) && (!empty($object['cn']))){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = $name; + $this->$oname=addslashes($value); + } + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + }else{ + $this->status = "new"; + $this->orig_cn = false; + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + /* Magic quotes GPC, escapes every ' " \, to solve some security risks + * If we post the escaped strings they will be escaped again + */ + foreach($this->attributes as $attrs){ + if(get_magic_quotes_gpc()){ + $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs)))); + }else{ + $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs))); + } + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $acl = $this->getacl($name); + if($this->FAIstate == "freezed"){ + $acl = preg_replace("/w/","",$acl); + } + $smarty->assign($name."ACL",$acl); + } + + + + $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ + foreach($this->attributes as $attrs){ + if($this->acl_is_writeable($attrs)){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + }else{ + $this->$attrs = ""; + } + } + } + } + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ + $message[] =_("There is already a variable with the given name."); + } + + if(empty($this->FAIvariableContent)) { + $message[]=_("Please specify a value for the attribute 'content'."); + } + + if(empty($this->cn)){ + $message[] = _("Please enter a name."); + } + + return ($message); + } + + function save() + { + $tmp=array(); + foreach($this->attributes as $attrs){ + $tmp[$attrs] = stripslashes( $this->$attrs); + } + + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ + $tmp['remove']['from'] = $this->orig_cn; + $tmp['remove']['to'] = $tmp['cn']; + } + + $tmp['dn'] = $this->dn; + $tmp['status'] = $this->status; + return($tmp); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Variable entry"), + "plDescription" => _("FAI variable entry "), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 23, + "plSection" => array("administration"), + "plCategory" => array("fai"), + "plProvidedAcls" => array( + "cn" => _("Name"), + "description" => _("Description"), + "FAIvariableContent"=> _("Variable content") ) + )); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/fai/faiHook.tpl b/gosa-core/plugins/admin/fai/faiHook.tpl new file mode 100644 index 000000000..6768ad92d --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiHook.tpl @@ -0,0 +1,63 @@ + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ + +{render acl=$cnACL} + +{/render} +
+ + +{render acl=$descriptionACL} + +{/render} +
+
+

 

+ + + + +
+

  + {t}List of hook scripts{/t} +

+ + + + +
+ {$Entry_divlist} +{if $sub_object_is_addable} + +{else} + +{/if} +
+
+ + + + diff --git a/gosa-core/plugins/admin/fai/faiHookEntry.tpl b/gosa-core/plugins/admin/fai/faiHookEntry.tpl new file mode 100644 index 000000000..882da267d --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiHookEntry.tpl @@ -0,0 +1,94 @@ + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {t}Name{/t}{$must}  + +{render acl=$cnACL} + +{/render} +
+ {t}Description{/t}  + +{render acl=$descriptionACL} + +{/render} +
+
+   + +

 {t}Hook attributes{/t}

+ + + + +
+ +{render acl=$FAItaskACL} + +{/render} +
+
+ + +

 

+

  + +

+ + + + +
+{render acl=$FAIscriptACL} + +{/render} +
+
+
+{render acl=$FAIscriptACL} +   +{/render} +{render acl=$FAIscriptACL} + +{/render} +{render acl=$FAIscriptACL} + {$DownMe} +{/render} +
+ +

 

+
+
+   + +
+ + + diff --git a/gosa-core/plugins/admin/fai/faiNewBranch.tpl b/gosa-core/plugins/admin/fai/faiNewBranch.tpl new file mode 100755 index 000000000..831e02898 --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiNewBranch.tpl @@ -0,0 +1,55 @@ +{if $iframe == false} + +
+

+{t}You are now going to create a branch or locked branch. This action clones the existing release to another release name. Branches can be modified as usual. FAI classes of locked branches cannot be modified, just additional classes are possible. Branch names should be alphanumeric, excluding the reserved names 'scripts', 'hooks', 'partitions', 'variables', 'templates' and 'fai'.{/t} +
+{t}Branches are created as subreleases of the currently selected branch. Creating a new branch named 1.0.2 in SARGE for example, will result in a new release called SARGE/1.0.2.{/t} +
+
+

+

+
+{t}Please enter a name for the branch{/t}   + +
+
+

+ +
+

+ + +

+
+ + + +{else} + +

{t}Processing the requested operation{/t}

+{t}As soon as the copy operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the fai management dialog.{/t} +
+
+
+ +
+ +{/if} diff --git a/gosa-core/plugins/admin/fai/faiPackage.tpl b/gosa-core/plugins/admin/fai/faiPackage.tpl new file mode 100644 index 000000000..87c83d98e --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiPackage.tpl @@ -0,0 +1,100 @@ + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ + +{render acl=$cnACL} + +{/render} +
+ + +{render acl=$descriptionACL} + +{/render} +
+
+

 {t}Repository{/t}

+ + + + + + + + + + + + + +
+ {t}Release{/t} : + + {$release} +
+ {t}Section{/t} : + + {$section} +
+ {t}Install method{/t} : + +{render acl=$FAIinstallMethodACL} + +{/render} +
+
+

 

+ + + + +
+

 {t}Used packages{/t}

+
+ +
+{render acl=$FAIpackageACL} + +{/render} +{render acl=$FAIpackageACL} + +{/render} +{render acl=$FAIdebconfInfoACL} + +{/render} +{render acl=$FAIpackageACL} + +{/render} +
+ + + + diff --git a/gosa-core/plugins/admin/fai/faiPackageConfiguration.tpl b/gosa-core/plugins/admin/fai/faiPackageConfiguration.tpl new file mode 100644 index 000000000..db047590f --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiPackageConfiguration.tpl @@ -0,0 +1,9 @@ +

 {$headline}

+{$Config} +

 

+
+
+ + +
+ diff --git a/gosa-core/plugins/admin/fai/faiPackageEntry.tpl b/gosa-core/plugins/admin/fai/faiPackageEntry.tpl new file mode 100644 index 000000000..79f47c6c4 --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiPackageEntry.tpl @@ -0,0 +1,66 @@ + + + + + +
+
+

+ {t}List of available packages{/t} +

+
+
+ {$faihead} +
+
+
+
+ {$failist} + +
+
+
+

+ [i]{t}Information{/t} +

+
+
+ {t}This menu allows you to select multiple packages to add them to the currently edited package list.{/t} +
+
+
+

+ [F] + {t}Filters{/t} +

+
+
+ {$CHKS} +
+
+ + + + + +
+ {t}Display objects matching{/t} + + +
+ {$apply} +
+
+
+ + +
+ + + + diff --git a/gosa-core/plugins/admin/fai/faiPartitionTable.tpl b/gosa-core/plugins/admin/fai/faiPartitionTable.tpl new file mode 100644 index 000000000..f330fe67b --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiPartitionTable.tpl @@ -0,0 +1,68 @@ + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ + +{render acl=$cnACL} + +{/render} +
+ + +{render acl=$descriptionACL} + +{/render} +
+
+   + +

  + +

+ + + + +
+
+{if $sub_object_is_addable} + +{else} + +{/if} + + + +
+
+ + + diff --git a/gosa-core/plugins/admin/fai/faiPartitionTableEntry.tpl b/gosa-core/plugins/admin/fai/faiPartitionTableEntry.tpl new file mode 100644 index 000000000..4379b663d --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiPartitionTableEntry.tpl @@ -0,0 +1,48 @@ + +

 {t}Device{/t}

+ + + + + +
{$must}  +{render acl=$DISKcnACL} + +{/render} +   +{render acl=$DISKdescriptionACL} + +{/render} +
+
+

 

+
+

 {t}Partition entries{/t}

+{$setup} +
+{if $sub_object_is_createable} + +{else} + +{/if} +
+
+

 

+
+
+{render acl=$allowSave} + +{/render} + +
+ + + diff --git a/gosa-core/plugins/admin/fai/faiProfile.tpl b/gosa-core/plugins/admin/fai/faiProfile.tpl new file mode 100644 index 000000000..090d968e7 --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiProfile.tpl @@ -0,0 +1,58 @@ + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ + +{render acl=$cnACL} + +{/render} +
+ + +{render acl=$descriptionACL} + +{/render} +
+
+ + + + +
+

 {t}FAI classes{/t}

+ + {$divlist} +
+{render acl=$FAIclassACL} + +{/render} + +
+
+ + + diff --git a/gosa-core/plugins/admin/fai/faiProfileEntry.tpl b/gosa-core/plugins/admin/fai/faiProfileEntry.tpl new file mode 100644 index 000000000..72e865bea --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiProfileEntry.tpl @@ -0,0 +1,73 @@ + + + + + +
+
+

+ {t}List of FAI objects (Fully Automatic Installation){/t} +

+
+
+ {$faihead} +
+
+
+ {$failist} + +
+
+
+

+ [i]{t}Information{/t} +

+
+
+

+ {t}This menu allows you to select FAI class names and to add them to the currently edited profile.{/t} +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + + + +
{t}Show only classes with templates{/t}
{t}Show only classes with scripts{/t}
{t}Show only classes with hooks{/t}
{t}Show only classes with variables{/t}
{t}Show only classes with packages{/t}
{t}Show only classes with partitions{/t}
+ + + + + +
+ {t}Display objects matching{/t} + + +
+ {$apply} +
+
+ +
+ + +
+ diff --git a/gosa-core/plugins/admin/fai/faiScript.tpl b/gosa-core/plugins/admin/fai/faiScript.tpl new file mode 100644 index 000000000..c0ff247b5 --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiScript.tpl @@ -0,0 +1,63 @@ + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ + +{render acl=$cnACL} + +{/render} +
+ + +{render acl=$descriptionACL} + +{/render} +
+
+

 

+ + + + +
+

  + {t}List of scripts{/t} +

+ + + + +
+ {$Entry_divlist} +{if $sub_object_is_addable} + +{else} + +{/if} +
+
+ + + + diff --git a/gosa-core/plugins/admin/fai/faiScriptEntry.tpl b/gosa-core/plugins/admin/fai/faiScriptEntry.tpl new file mode 100644 index 000000000..cddb2bbcd --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiScriptEntry.tpl @@ -0,0 +1,92 @@ + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {t}Name{/t}{$must}  + +{render acl=$cnACL} + +{/render} +
+ {t}Description{/t}  + +{render acl=$descriptionACL} + +{/render} +
+
+   + +

 {t}Script attributes{/t}

+ + + + + +
+ + +{render acl=$FAIpriorityACL} + +{/render} +
+
+

 

+

  + +

+ + + + +
+{render acl=$FAIscriptACL} + +{/render} +
+
+
+{render acl=$FAIscriptACL} +   +{/render} +{render acl=$FAIscriptACL} + +{/render} +{render acl=$FAIscriptACL} + {$DownMe} +{/render} +
+
+
+   + +
+ + + diff --git a/gosa-core/plugins/admin/fai/faiSummary.tpl b/gosa-core/plugins/admin/fai/faiSummary.tpl new file mode 100644 index 000000000..196f7cab8 --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiSummary.tpl @@ -0,0 +1,27 @@ + + + + + + +{if $readable} + + + + + + +{else} + + + +{/if} +
{t}FAI object tree{/t}
+ + {t}Reload class and release configuration from parent object.{/t} +
+ {$objectList} +
+ {t}You are not allowed to view the fai summary.{/t} +
+ diff --git a/gosa-core/plugins/admin/fai/faiTemplate.tpl b/gosa-core/plugins/admin/fai/faiTemplate.tpl new file mode 100644 index 000000000..627c5ddd5 --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiTemplate.tpl @@ -0,0 +1,52 @@ + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ + +{render acl=$cnACL} + +{/render} +
+ + +{render acl=$descriptionACL} + +{/render} +
+
+

  + {t}List of template files{/t} +

+ {$Entry_divlist} +{if $sub_object_is_addable} + +{else} + +{/if} +
+ + + + diff --git a/gosa-core/plugins/admin/fai/faiTemplateEntry.tpl b/gosa-core/plugins/admin/fai/faiTemplateEntry.tpl new file mode 100644 index 000000000..b8ee41a61 --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiTemplateEntry.tpl @@ -0,0 +1,203 @@ + + +

 {t}Generic{/t}

+ + + + + +
+ + + + + + + + + +
+ {t}File name{/t}{$must}  + +{render acl=$cnACL} +    +{/render} +
+ + +{render acl=$FAItemplatePathACL} + +{/render} +
+
+ {t}Description{/t}  +{render acl=$descriptionACL} + +{/render} +
+ +

 

+ + + + + + + + + + + + +

 {t}Template attributes{/t}

+ + + + + + + + +
+ + + {$status} + {if $bStatus} + + {t}Save template{/t}... + + {/if} +
+
+{render acl=$FAItemplateFileACL} + +{/render} +{render acl=$FAItemplateFileACL} +   +{/render} +
+
+
+ {t}Full path{/t}  + +{render acl=$FAItemplatePathACL} + {$FAItemplatePath} +{/render} +
+
+ + + + + + + + + + +
+ + +{render acl=$FAIownerACL} + +{/render} +
+ + +{render acl=$FAIownerACL} + +{/render} +
+
+
{t}Access{/t}{$must}  + + + + + + + + + + + + + +{render acl=$FAImodeACL} + +{/render} +{render acl=$FAImodeACL} + +{/render} +{render acl=$FAImodeACL} + +{/render} + +{render acl=$FAImodeACL} + +{/render} + + + + +{render acl=$FAImodeACL} + +{/render} +{render acl=$FAImodeACL} + +{/render} +{render acl=$FAImodeACL} + +{/render} + +{render acl=$FAImodeACL} + +{/render} + + + + +{render acl=$FAImodeACL} + +{/render} +{render acl=$FAImodeACL} + +{/render} +{render acl=$FAImodeACL} + +{/render} + +{render acl=$FAImodeACL} + +{/render} + +
{t}Class{/t}{t}Read{/t}{t}Write{/t}{t}Execute{/t} {t}Special{/t} 
{t}User{/t} ({t}SUID{/t})
{t}Group{/t} ({t}SGID{/t})
{t}Others{/t} ({t}sticky{/t})
+ +
+
+
+

 

+
+
+   + +
+
+ + + + + + diff --git a/gosa-core/plugins/admin/fai/faiVariable.tpl b/gosa-core/plugins/admin/fai/faiVariable.tpl new file mode 100644 index 000000000..cdbdab96b --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiVariable.tpl @@ -0,0 +1,72 @@ + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ + +{render acl=$cnACL} + +{/render} +
+ + +{render acl=$descriptionACL} + +{/render} +
+
+   + +

  + +

+ + + + +
+
+{if $is_createable} + +{else} + +{/if} + +{if $is_removeable} + +{else} + +{/if} +
+
+ + + + diff --git a/gosa-core/plugins/admin/fai/faiVariableEntry.tpl b/gosa-core/plugins/admin/fai/faiVariableEntry.tpl new file mode 100644 index 000000000..0fd8a4afa --- /dev/null +++ b/gosa-core/plugins/admin/fai/faiVariableEntry.tpl @@ -0,0 +1,64 @@ + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {t}Name{/t}{$must}  + +{render acl=$cnACL} + +{/render} +
+ {t}Description{/t}  + +{render acl=$descriptionACL} + +{/render} +
+
+   + +

 {t}Variable attributes{/t}

+ + + + + +
+ + +{render acl=$FAIvariableContentACL} + +{/render} +
+
+

 

+
+
+   + +
+ + + + diff --git a/gosa-core/plugins/admin/fai/main.inc b/gosa-core/plugins/admin/fai/main.inc new file mode 100644 index 000000000..ab6749d44 --- /dev/null +++ b/gosa-core/plugins/admin/fai/main.inc @@ -0,0 +1,55 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('FAI'); + } +} else { + /* Create usermanagement object on demand */ + if (!isset($_SESSION['FAI']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['FAI']= new faiManagement($config, $ui); + $_SESSION['FAI']->set_acl_category("fai"); + $_SESSION['FAI']->set_acl_base($_SESSION['CurrentMainBase']); + } + $FAI= $_SESSION['FAI']; + $FAI->save_object(); + $output= $FAI->execute(); + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('FAI'); + } + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/fai.png'), _("Fully Automatic Installation"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/fai.png'), _("Fully Automatic Installation")); + } + $display.= $output; + + $_SESSION['FAI']= $FAI; +} + +?> diff --git a/gosa-core/plugins/admin/fai/remove.tpl b/gosa-core/plugins/admin/fai/remove.tpl new file mode 100644 index 000000000..10bf93dc5 --- /dev/null +++ b/gosa-core/plugins/admin/fai/remove.tpl @@ -0,0 +1,24 @@ +
+ {t}Warning{/t} +
+ +

+ {$warning} + {t}This includes 'all' object information. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+{if $multiple} + +   + +{else} + +   + +{/if} +

diff --git a/gosa-core/plugins/admin/fai/remove_branch.tpl b/gosa-core/plugins/admin/fai/remove_branch.tpl new file mode 100755 index 000000000..3ed7f2329 --- /dev/null +++ b/gosa-core/plugins/admin/fai/remove_branch.tpl @@ -0,0 +1,18 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}This includes all account data, system access, etc. for this branch. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ +   + +

+ diff --git a/gosa-core/plugins/admin/fai/tabsHook.inc b/gosa-core/plugins/admin/fai/tabsHook.inc new file mode 100644 index 000000000..1857854b3 --- /dev/null +++ b/gosa-core/plugins/admin/fai/tabsHook.inc @@ -0,0 +1,48 @@ +addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['faiHook']; + + $new_dn= 'cn='.$baseobject->cn.",ou=hooks,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + + if($_SESSION['faifilter']['branch']!="main"){ + $new_dn ='cn='.$baseobject->cn.",ou=hooks,".$_SESSION['faifilter']['branch']; + } + + if ($this->dn != $new_dn && $this->dn != "new"){ + + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ +// $baseobject->recursive_move($this->dn, $new_dn); + } + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/admin/fai/tabsPackage.inc b/gosa-core/plugins/admin/fai/tabsPackage.inc new file mode 100644 index 000000000..8731835ef --- /dev/null +++ b/gosa-core/plugins/admin/fai/tabsPackage.inc @@ -0,0 +1,48 @@ +addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['faiPackage']; + + $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + if($_SESSION['faifilter']['branch']!="main"){ + $new_dn ='cn='.$baseobject->cn.",ou=packages,".$_SESSION['faifilter']['branch']; + } + + if ($this->dn != $new_dn && $this->dn != "new"){ + + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ +// $baseobject->recursive_move($this->dn, $new_dn); + } + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/admin/fai/tabsPartition.inc b/gosa-core/plugins/admin/fai/tabsPartition.inc new file mode 100644 index 000000000..9d2312d57 --- /dev/null +++ b/gosa-core/plugins/admin/fai/tabsPartition.inc @@ -0,0 +1,49 @@ +addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['faiPartitionTable']; + + $new_dn= 'cn='.$baseobject->cn.",ou=disk,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + + if($_SESSION['faifilter']['branch']!="main"){ + $new_dn ='cn='.$baseobject->cn.",ou=disk,".$_SESSION['faifilter']['branch']; + } + + if ($this->dn != $new_dn && $this->dn != "new"){ + + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ +// $baseobject->recursive_move($this->dn, $new_dn); + } + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/admin/fai/tabsProfile.inc b/gosa-core/plugins/admin/fai/tabsProfile.inc new file mode 100644 index 000000000..cbc3abd94 --- /dev/null +++ b/gosa-core/plugins/admin/fai/tabsProfile.inc @@ -0,0 +1,49 @@ +addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['faiProfile']; + + $new_dn= 'cn='.$baseobject->cn.",ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + + if($_SESSION['faifilter']['branch']!="main"){ + $new_dn ='cn='.$baseobject->cn.",ou=profiles,".$_SESSION['faifilter']['branch']; + } + + if ($this->dn != $new_dn && $this->dn != "new"){ + + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ +// $baseobject->recursive_move($this->dn, $new_dn); + } + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/admin/fai/tabsScript.inc b/gosa-core/plugins/admin/fai/tabsScript.inc new file mode 100644 index 000000000..28ebd224a --- /dev/null +++ b/gosa-core/plugins/admin/fai/tabsScript.inc @@ -0,0 +1,49 @@ +addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['faiScript']; + + $new_dn= 'cn='.$baseobject->cn.",ou=scripts,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + + if($_SESSION['faifilter']['branch']!="main"){ + $new_dn ='cn='.$baseobject->cn.",ou=scripts,".$_SESSION['faifilter']['branch']; + } + + if ($this->dn != $new_dn && $this->dn != "new"){ + + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ +// $baseobject->recursive_move($this->dn, $new_dn); + } + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/admin/fai/tabsTemplate.inc b/gosa-core/plugins/admin/fai/tabsTemplate.inc new file mode 100644 index 000000000..2ff58199b --- /dev/null +++ b/gosa-core/plugins/admin/fai/tabsTemplate.inc @@ -0,0 +1,49 @@ +addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['faiTemplate']; + + $new_dn= 'cn='.$baseobject->cn.",ou=templates,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + + if($_SESSION['faifilter']['branch']!="main"){ + $new_dn ='cn='.$baseobject->cn.",ou=templates,".$_SESSION['faifilter']['branch']; + } + + if ($this->dn != $new_dn && $this->dn != "new"){ + + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ +// $baseobject->recursive_move($this->dn, $new_dn); + } + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/admin/fai/tabsVariable.inc b/gosa-core/plugins/admin/fai/tabsVariable.inc new file mode 100644 index 000000000..c872f2d9b --- /dev/null +++ b/gosa-core/plugins/admin/fai/tabsVariable.inc @@ -0,0 +1,49 @@ +addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['faiVariable']; + + $new_dn= 'cn='.$baseobject->cn.",ou=variables,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + + if($_SESSION['faifilter']['branch']!="main"){ + $new_dn ='cn='.$baseobject->cn.",ou=variables,".$_SESSION['faifilter']['branch']; + } + + if ($this->dn != $new_dn && $this->dn != "new"){ + + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ +// $baseobject->recursive_move($this->dn, $new_dn); + } + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/admin/groups/application.tpl b/gosa-core/plugins/admin/groups/application.tpl new file mode 100644 index 000000000..87d8050aa --- /dev/null +++ b/gosa-core/plugins/admin/groups/application.tpl @@ -0,0 +1,44 @@ +{if $enableReleaseManagement == true} +
+ {t}Release focus{/t}  + {if $ReleaseSelectAble} +{render acl=$FAIreleaseACL} + +{/render} + {else} + {$Release} + {/if} +

 

+{ +/if} + + + + + + +
+ + + + {$UsedApps} +{render acl=$gosaMemberApplicationACL} + +{/render} +{render acl=$gosaMemberApplicationACL} + +{/render} +   + + + + +
+ {$List} +{render acl=$gosaMemberApplicationACL} + +{/render} +
+ diff --git a/gosa-core/plugins/admin/groups/application_options.tpl b/gosa-core/plugins/admin/groups/application_options.tpl new file mode 100644 index 000000000..aa5522180 --- /dev/null +++ b/gosa-core/plugins/admin/groups/application_options.tpl @@ -0,0 +1,15 @@ +
+{t}Application options{/t} +
+
+ +{$table} + +
+ +

+ +   + +

+ diff --git a/gosa-core/plugins/admin/groups/class_divListGroup.inc b/gosa-core/plugins/admin/groups/class_divListGroup.inc new file mode 100644 index 000000000..fcf32f843 --- /dev/null +++ b/gosa-core/plugins/admin/groups/class_divListGroup.inc @@ -0,0 +1,351 @@ +AddCheckBox */ + var $ShowPrimaryGroups; + var $ShowSambaGroups; + var $ShowApplicationGroups; + var $ShowMailGroups; + var $ShowFunctionalGroups; + + /* Subsearch checkbox */ + var $SubSearch = false; + + var $parent ; + var $ui ; + + function divListGroup (&$config, &$parent) + { + MultiSelectWindow::MultiSelectWindow($config, "Groups", "groups"); + + $this->parent = &$parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of groups")); + $this->SetSummary(_("List of groups")); + $this->EnableAplhabet (true); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to add, edit and remove selected groups. You may want to use the range selector on top of the group listbox, when working with a large number of groups.")); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>_("Groupname / Department"))); + $this->AddHeader(array("string"=>_("Properties"),"attach"=>"style='width:136px;'")); + $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'")); + + /* Text ,Value ,Name ,Is selected */ + $this->AddCheckBox("ShowPrimaryGroups", _("Select to see groups that are primary groups of users"), _("Show primary groups"), true); + $this->AddCheckBox("ShowSambaGroups", _("Select to see groups that have samba groups mappings"), _("Show samba groups"), true); + $this->AddCheckBox("ShowApplicationGroups", _("Select to see groups that have applications configured"), _("Show application groups"),true); + $this->AddCheckBox("ShowMailGroups", _("Select to see groups that have mail settings"), _("Show mail groups"), true); + $this->AddCheckBox("ShowFunctionalGroups", _("Select to see normal groups that have only functional aspects"), _("Show functional groups"), true); + $this->AddCheckBox(SEPERATOR); + + /* Add SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true); + $this->AddRegex ("UserRegex", _("User name of which groups are shown"), "*" , false, "images/search_user.png"); + } + + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("groups"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get acls */ + $acls = $ui->get_permissions($this->selectedBase,"groups/group"); + $acl_all= $ui->has_complete_category_acls($this->selectedBase,"groups"); + + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* Add department selection */ + $listhead .= _("Base")." ". + "  "; + + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + + /* Append create options */ + if(preg_match("/c/",$acl_all)) { + $s.= "...|". + " "._("Group")."|group_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($groups) + { + // Defining Links + $linkopen = "%s"; + + // image Buttons + $editlink = "%s"; + $userimg = "User"; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /* Assign extension images */ + $posiximg = ""; + $mailimg = ""; + $sambaimg = ""; + $applimg = ""; + $phoneimg = ""; + $envimg = ""; + + // Space + $empty = ""; + + // User and Template Images + $editlink = "%s"; + + $ui = get_userinfo(); + + // Test Every Entry and generate divlist Array + foreach($groups as $key => $val){ + + /* Create action icons - copy & paste icons */ + $acl = $ui->get_permissions($val['dn'],"groups/group"); + $acl_all= $ui->has_complete_category_acls($val['dn'],"groups"); + + $actions= ""; + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions.= " "; + $actions.= " "; + } + + /* Add edit icon */ + $actions.= ""; + + /* Add snapshot functionality */ + if(preg_match("/(c.*w|w.*c)/", $acl_all)){ + $actions.= $this->GetSnapShotActions($val['dn']); + } + + if(preg_match("/d/",$acl)){ + $actions.= ""; + } + + + $posix=$mail=$samba=$appl=$phone=$enviro=$empty; + + if(isset($val['objectClass'])){ + if(in_array("posixGroup", $val['objectClass'])) $posix = $posiximg; + if(in_array("gosaMailAccount", $val['objectClass'])) $mail = $mailimg; + if(in_array("sambaGroupMapping", $val['objectClass'])) $samba = $sambaimg; + if(in_array("gosaApplicationGroup", $val['objectClass'])) $appl = $applimg; + if(in_array("goFonPickupGroup", $val['objectClass'])) $phone = $phoneimg; + if(in_array("gotoEnvironment", $val['objectClass'])) $enviro= $envimg; + } + + $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; + + if(!isset($val['description'][0])){ + $desc = ""; + }else{ + $desc = " - [ ".$val['description'][0]." ]"; + } + + /* FAIrelease tag from groupApplications */ + if(isset($val['FAIrelease'][0])){ + $desc .= " (".$val['FAIrelease'][0].")"; + } + + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + + /* Cutted objects should be displayed in light grey */ + $display = $val['cn'][0].$desc; + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); + $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix." ".$enviro." ".$mail." ".$samba." ".$appl." ".$phone), "attach" => "style='width:136px;'"); + $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + + $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); + } + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_grps = count($groups); + + $num_grp_str = _("Number of listed groups"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_grp_str." ".$num_grps."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/groups/class_groupApplication.inc b/gosa-core/plugins/admin/groups/class_groupApplication.inc new file mode 100644 index 000000000..12b80fab2 --- /dev/null +++ b/gosa-core/plugins/admin/groups/class_groupApplication.inc @@ -0,0 +1,1230 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Appgroup attributes */ + var $gosaMemberApplication= array(); + + /* Helpers */ + var $departments = ""; // All departments within $this->curbase; + var $apps = array(); // All available applications + var $used_apps = array(); // Specifies which applications are currently assigned + + var $option_name = array(); + var $option_value = array(); + var $appoption = array(); + + var $table = ""; + var $curbase = ""; + var $curCatDir ; + var $curCatDepth =0; // + var $Categories; + + /* attribute list for save action */ + var $attributes = array("gosaMemberApplication","gosaApplicationParameter"); + var $objectclasses = array("gosaApplicationGroup"); + + var $FAIrelease = "/"; + var $InitialFAIrelease = "/"; + var $Releases = array(); + var $enableReleaseManagement = false; + + var $AllAppsForRelease = array(); + var $AllAppsForReleaseParameter = array(); + var $view_logged = FALSE; + var $CopyPasteVars = array("Categories"); + var $gosaApplicationParameter ; + var $ui = NULL; + var $no_release_acls = false; + + function appgroup (&$config, $dn= NULL, $parent= NULL) + { + + /* Check if we have relase mangement enabled and prepare group application for release management */ + $tmp = $config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + $this->enableReleaseManagement = true; + $this->objectclasses [] = "FAIreleaseTag"; + $this->attributes [] = "FAIrelease"; + } + + plugin::plugin ($config, $dn, $parent); + + /* set userinfo object */ + $this->ui = get_userinfo(); + + /* Compatibility check + In some case of old applikations with old release tag saving, + we must reassign is_account state. + (Or if release management wasn't activated before creating this app) */ + if($this->enableReleaseManagement){ + + /* Release management is activated && this is a valid group app account, + but no release class was found, so activate is_account flag */ + if(isset($this->attrs['objectClass'])){ + if($dn != "new" && ( in_array("gosaApplicationGroup",$this->attrs['objectClass'])) && + (!in_array("FAIreleaseTag",$this->attrs['objectClass']))){ + $this->is_account =true; + } + } + } + + /* Load member applications */ + if (isset ($this->attrs["gosaMemberApplication"][0])){ + $this->gosaMemberApplication = array(); + for ($i= 0; $i<$this->attrs["gosaMemberApplication"]["count"]; $i++){ + $this->gosaMemberApplication[]= + $this->attrs["gosaMemberApplication"][$i]; + } + } + + /* Load application options */ + if (isset($this->attrs['gosaApplicationParameter'])){ + for ($i= 0; $i<$this->attrs['gosaApplicationParameter']['count']; $i++){ + $option= preg_replace('/^[^:]+:/', '', + $this->attrs['gosaApplicationParameter'][$i]); + $name= preg_replace('/:.*$/', '', + $this->attrs['gosaApplicationParameter'][$i]); + $this->appoption[$name]= $option; + } + } + + /* Parse MemberApplication*/ + $tmp = array(); + $tmp2 = array(); + $prios = array(); + $cats = array(); + + foreach($this->gosaMemberApplication as $memberApp){ + if(preg_match("/\|/i",$memberApp)){ + + $tmp = split("\|",$memberApp); + + if(!empty($tmp[0])){ + $tmp2[$tmp[1]][$tmp[2]] = array("App"=>$tmp[0]); + } + if(!empty($tmp[1])){ + $n = split("/",$tmp[1]); + $c = count($n); + $cats [$tmp[1]] = $n[$c-1]; + } + $prios[$tmp[1]][$tmp[2]] = $tmp[2]; + }else{ + $tmp2[]['App'] = $memberApp; + } + } + + /* Assign collected category and application settings */ + $this->Categories = $cats; + $this->gosaMemberApplication = $tmp2; + + /* Sort application by category */ + $cats[""]=""; + foreach($cats as $cat ){ + if((isset($prios[$cat]))&&(count($prios[$cat]))){ + $max = max($prios[$cat]); + $min = 1;//min($prios[$cat]); + $last = false; + for($i = $min ; $i < $max ; $i++){ + if(!isset($prios[$cat][$i])){ + if($last == false){ + $this->gosaMemberApplication[$cat][$i]['App'] = "__SEPARATOR__".$i; + + $last = true; + } + }else{ + $last = false; + } + } + } + } + + /* Sort application by priority */ + $tmp = array(); + foreach($this->gosaMemberApplication as $key => $entries){ + ksort ($entries); + foreach($entries as $entry){ + $tmp[$key][]= $entry; + } + } + $this->gosaMemberApplication = $tmp; + $this->curbase = $this->config->current['BASE']; + + /* Get required release informations */ + if($this->enableReleaseManagement){ + $this->InitialFAIrelease = $this->FAIrelease; + $this->Releases = $this->getReleases(); + } + + } + + + /* Combine new array */ + function combineArrays($ar0,$ar1,$ar2) + { + $ret = array(); + if(is_array($ar0)) + foreach($ar0 as $ar => $a){ + $ret[$ar]=$a; + } + if(is_array($ar1)) + foreach($ar1 as $ar => $a){ + $ret[$ar]=$a; + } + if(is_array($ar2)) + foreach($ar2 as $ar => $a){ + $ret[$ar]=$a; + } + return($ret); + } + + /* Returns element position within given array */ + function getpos($atr,$attrs) + { + $i = 0; + foreach($attrs as $attr => $name) { + $i++; + if($attr == $atr){ + return($i); + } + } + return(-1); + } + + + /* Check current combination of application && release + Are all application available?, application parameter changed? ... */ + function diffAppsInReleases() + { + /* Only diff if it is required */ + $ret =array(); + + /* If current release has changed */ + if($this->FAIrelease != $this->InitialFAIrelease){ + + /* Walk through all apps which are currently displayed */ + if(isset($this->gosaMemberApplication[$this->curCatDir])){ + + foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){ + + /* If application is also available in new release, check if parameter differs */ + if(in_array($entry['App'],$this->AllAppsForRelease)){ + + $old = array(); // Old application parameter + $new = array(); // New parameters + + /* There are possibly no parameters specified */ + if(isset($this->AllAppsForReleaseParameter[$this->InitialFAIrelease][$entry['App']])){ + $old = $this->AllAppsForReleaseParameter[$this->InitialFAIrelease][$entry['App']]; + } + + if(isset($this->AllAppsForReleaseParameter[$this->FAIrelease][$entry['App']])){ + $new = $this->AllAppsForReleaseParameter[$this->FAIrelease][$entry['App']]; + } + + /* Both (old & new) have no gosaApplicationParameter + */ + if((!isset($old['gosaApplicationParameter'])) && (!isset($new['gosaApplicationParameter']))){ + $ret[$entry['App']] = false; + + /* Both got gosaApplicationParameter */ + }elseif((isset($old['gosaApplicationParameter'])) && (isset($new['gosaApplicationParameter']))){ + if(array_differs($old['gosaApplicationParameter'],$new['gosaApplicationParameter'])){ + $ret[$entry['App']] = true; + }else{ + $ret[$entry['App']] = false; + } + } + /* Initially had gosaApplicationParameter bot in new release not */ + }elseif((isset($old['gosaApplicationParameter'])) && (!isset($new['gosaApplicationParameter']))){ + $ret[$entry['App']] = true; + + /* Old release had no gosaApplicationParameter but new got some */ + }elseif((!isset($old['gosaApplicationParameter'])) && (isset($new['gosaApplicationParameter']))){ + $ret[$entry['App']] = true; + } + } + } + } + return($ret); + } + + /* TRansports the geiven Arraykey one position up*/ + function ArrayUp($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == 1))){ + $before = array_slice($attrs,0,($pos-2)); + $mitte = array_reverse(array_slice($attrs,($pos-2),2)); + $unten = array_slice($attrs,$pos); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* TRansports the geiven Arraykey one position up*/ + function ArrayDown($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == $cn))){ + $before = array_slice($attrs,0,($pos-1)); + $mitte = array_reverse(array_slice($attrs,($pos-1),2)); + $unten = array_slice($attrs,($pos+1)); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* Sort category on position up */ + function catUp($id) + { + /* Get all cats depinding on current dir */ + $cats = $this->GetSubdirs($this->curCatDir); + $newcats =$this->ArrayUp($id,$cats); + foreach($newcats as $cat => $name){ + unset($this->Categories[$cat]); + } + foreach($newcats as $cat => $name){ + $this->Categories[$cat]=$name; + } + } + + + /* Sort category on position down */ + function catDown($id) + { + /* Get all cats depinding on current dir */ + $cats = $this->GetSubdirs($this->curCatDir); + $newcats =$this->ArrayDown($id,$cats); + foreach($newcats as $cat => $name){ + unset($this->Categories[$cat]); + } + foreach($newcats as $cat => $name){ + $this->Categories[$cat]=$name; + } + } + + + /* Increase application priority */ + function getOneUp($appl) + { + $cat = $this->curCatDir; + $apps = $this->gosaMemberApplication[$cat]; + $appsA = array(); + foreach ($apps as $appkey => $name){ + $appsA[$name['App']] =$name['App']; + } + $result = $this->ArrayUp($appl,$appsA); + $ret = array(); + foreach($result as $app){ + $ret[]=array("App"=>$app); + } + $this->gosaMemberApplication[$cat] = $ret; + } + + + /* Decrease application priority */ + function getOneDown($appl) + { + $cat = $this->curCatDir; + $apps = $this->gosaMemberApplication[$cat]; + $appsA = array(); + foreach ($apps as $appkey => $name){ + $appsA[$name['App']] =$name['App']; + } + $result = $this->ArrayDown($appl,$appsA); + $ret = array(); + foreach($result as $app){ + $ret[]=array("App"=>$app); + } + $this->gosaMemberApplication[$cat] = $ret; + } + + + /* Add seperator to application list */ + function AddSeperator($id) + { + $found = false; + $cat = ""; + $tmp = array(); + foreach($this->gosaMemberApplication[$this->curCatDir] as $appID => $app){ + $tmp[] = $app; + if(($app['App'] == $id)&&(!$found)){ + $cnt = count($this->gosaMemberApplication[$this->curCatDir]); + $tmp[] = array("App" => "__SEPARATOR__".($cnt+1)); + $found = true; + } + } + if($found){ + $this->gosaMemberApplication[$this->curCatDir]=$tmp; + } + } + + + /* Check if application acls are readable */ + function check_acls() + { + return(count($this->ui->get_module_departments("application"))); + } + + + function execute() + { + /* Call parent 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); + } + + /* Check if department was selected */ + if((isset($_GET['act']))&&($_GET['act']=="depopen")){ + $dep = base64_decode($_GET['depid']); + $this->curbase =$dep; + } + + /* Check if category was selected */ + if((isset($_GET['act']))&&($_GET['act']=="open") && (empty($_GET['id']) || isset($this->Categories[base64_decode($_GET['id'])]))){ + $this->curCatDir = base64_decode($_GET['id']); + } + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Do we represent a valid group? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' is no appgroup.").""; + return ($display); + } + + /* Show tab dialog headers */ + $display= ""; + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove applications"), + _("This group has application features enabled. You can disable them by clicking below.")); + } else { + $display.= $this->show_enable_header(_("Create applications"), + _("This group has application features disabled. You can enable them by clicking below.")); + return ($display); + } + } + + /* Check acl, applications must be readable */ + if(!$this->check_acls()){ + $display .= ""._("ACL")." + "._("Insufficient permissions")." +

". + _("You do not have permission to query application entries. All your changes will not be saved."). + "

 

"; + $this->no_release_acls = true; + } + + + /* Add Categorie */ + if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){ + + /* Only allow adding a category, if it is allowed */ + if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ + + if(preg_match("/[\\\\\/]/i",$_POST['CatName'])){ + print_red(_("Invalid character in category name.")); + }elseif(!in_array($_POST['CatName'],$this->Categories)){ + if(empty($this->curCatDir)){ + $this->Categories[$_POST['CatName']]=$_POST['CatName']; + }else{ + $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName']; + } + }else{ + print_red(_("The specified category already exists.")); + } + } + } + + + $this->reload(); + $this->diffAppsInReleases(); + + /* Check POST variables for commands + to add/remove some applications */ + $only_once = false; + if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ + + /* Walk through posts */ + foreach($_POST as $name => $value){ + + /* Add a seperator to current category */ + if((preg_match("/AddSep_/",$name))&&(!$only_once)){ + $only_once = true; + $n = preg_replace("/AddSep_/","",$name); + $val= preg_replace("/_.*$/","",$n); + $this->AddSeperator($val); + } + + /* Delete application | seperator entry */ + if((preg_match("/DelApp_/",$name))&&(!$only_once)){ + $only_once = true; + + if(preg_match("/DelApp___SEPARATOR__/",$name)) { + $n= preg_replace("/DelApp___SEPARATOR__/","",$name); + $val= "__SEPARATOR__".preg_replace("/_.*$/","",$n); + }else{ + $n = preg_replace("/DelApp_/","",$name); + $val= preg_replace("/_.*$/","",$n); + } + + foreach($this->gosaMemberApplication as $key => $cat){ + foreach($cat as $key2 => $app){ + if($app['App'] == $val){ + unset($this->gosaMemberApplication[$key][$key2]); + if(isset($this->used_apps[$val])){ + foreach($this->getParameters($val) as $para){ + if(isset($this->appoption[$para])){ + unset($this->appoption[$para]); + } + } + unset($this->used_apps[$val]); + } + } + } + } + } + + if(preg_match("/DelCat_/",$name) && !$only_once){ + $only_once =TRUE; + $cat = preg_replace("/DelCat_/","",$name); + $cat = trim(base64_decode( preg_replace("/_.*$/","",$cat))); + + $free_apps = array(); + + if(isset($this->gosaMemberApplication[$cat]) && is_array($this->gosaMemberApplication[$cat])){ + foreach($this->gosaMemberApplication[$cat] as $app){ + $free_apps[] = $app['App']; + } + unset($this->gosaMemberApplication[$cat]); + unset($this->Categories[$cat]); + } + foreach($this->Categories as $key => $name){ + if(preg_match("/^".normalizePreg($cat)."\/.*/",$key)){ + foreach($this->gosaMemberApplication[$key] as $app){ + $free_apps[] = $app['App']; + } + unset($this->gosaMemberApplication[$key]); + unset($this->Categories[$key]); + } + } + foreach($free_apps as $app){ + if(isset($this->used_apps[$app])){ + unset($this->used_apps[$app]); + } + } + } + + /* Edit application parameter */ + if((preg_match("/EdiApp_/",$name))&&(!$only_once)){ + + $only_once = true; + $appname = $value; + $appname = preg_replace("/EdiApp_/","",$name); + $appname = preg_replace("/_.*$/","",$appname); + + /* We've got the appname, get parameters from ldap */ + $ldap= $this->config->get_ldap_link(); + + /* Check if we have release management enabled */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + + /* Get application parameter from ldap */ + $tmp = array_flip($this->Releases); + $base = $tmp[$this->FAIrelease]; + $ldap->cd($base); + $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter")); + $found = ""; + while($attrs = $ldap->fetch()) { + if(preg_match("/cn=".$appname.",".$base."/",$attrs['dn'])){ + $found = $attrs['dn']; + } + } + $ldap->cat($found, array("gosaApplicationParameter")); + }else{ + + /* Get application parameter from ldap */ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter")); + } + + /* Check if this application is unique */ + if ($ldap->count() != 1){ + print_red (_("The selected application name is not uniq. Please check your LDAP.")); + } else { + + /* Get parameter */ + $attrs= $ldap->fetch(); + if(isset($attrs['gosaApplicationParameter'])){ + $this->dialog= TRUE; + + /* Fill name and value arrays */ + for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){ + $option= preg_replace('/^[^:]+:/', '', + $attrs['gosaApplicationParameter'][$i]); + $name= preg_replace('/:.*$/', '', + $attrs['gosaApplicationParameter'][$i]); + $this->option_name[$i]= $name; + + /* Fill with values from application, default should be + loaded by the external scripts */ + if (isset($this->appoption[$name])){ + $this->option_value[$i]= $this->appoption[$name]; + } + } + + /* Create edit field */ + $table= ""; + for ($i= 0; $i < count($this->option_name); $i++){ + if (isset($this->option_value[$i])){ + $value= $this->option_value[$i]; + } else { + $value= ""; + } + $table.=""; + } + $table.= "
".$this->option_name[$i]."". + "
"; + $this->table= $table; + } else { + print_red (_("The selected application has no options.")); + } + } + } + } + } + + /* Add multiple */ + if(isset($_POST['AddApps'])){ + foreach($_POST as $name => $value){ + if(preg_match("/AddApp_/",$name)){ + $app = preg_replace("/AddApp_/","",$name); + $this->addApp($app); + } + } + } + + /* Add application with post */ + if((isset($_GET['act']))&&($_GET['act']=="add")){ + $this->used_apps[$_GET['id']]= $_GET['id']; + asort($this->used_apps); + $this->addApp($_GET['id']); + } + + /* Cancel edit options? */ + if (isset($_POST['edit_options_cancel'])){ + $this->dialog= FALSE; + } + + /* Finish edit options? */ + if (isset($_POST['edit_options_finish'])){ + $this->dialog= FALSE; + + /* Save informations passed by the user */ + $this->option_value= array(); + for ($i= 0; $ioption_name); $i++){ + $this->appoption[$this->option_name[$i]]= $_POST["value$i"]; + $this->is_modified= TRUE; + } + } + + /* Prepare templating stuff */ + $smarty= get_smarty(); + $smarty->assign("used_apps", $this->used_apps); + $apps= array(); + foreach ($this->apps as $key => $value){ + if (!array_key_exists($key, $this->used_apps)){ + $apps["$key"]= "$value"; + } + } + + + /* Create application list */ + $div = new divSelectBox("appgroup"); + $div->SetHeight(300); + $departments = array(); + $res = get_list("(objectClass=gosaDepartment)", "application", $this->curbase,array("description","cn","ou"),GL_SIZELIMIT); + foreach($res as $value){ + $fdn = $value['dn']; + $fdn = preg_replace("/".normalizePreg($this->curbase)."/","",$fdn); + $fdn= @LDAP::fix($fdn); + if($value["description"][0]!=".."){ + $departments[$value['dn']]= convert_department_dn($fdn)." - [".$value["description"][0]."]"; + }else{ + $departments[$value['dn']]=convert_department_dn($fdn)." ["._("Back")."]"; + } + } + + /* Create 'open' and 'add' links */ + if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ + $linkadd = "%s"; + }else{ + $linkadd = "%s"; + } + $linkopen = "%s"; + + /* Create base back entry */ + $base_back = preg_replace("/^[^,]+,/","",$this->curbase); + if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){ + $div->AddEntry(array( + array("string"=>sprintf($linkopen,base64_encode($base_back),".. ["._("back")."]"), + "attach"=>"style='border:0px;'") + )); + } + + /* Append departments for current base */ + foreach($departments as $key => $app){ + $div->AddEntry(array( + array("string"=>""._("department")." ".sprintf($linkopen,base64_encode($key),$app), + "attach"=>"style='border:0px;'") + )); + } + + /* Add applications found on this base */ + foreach($apps as $key => $app){ + $div->AddEntry(array( + array("string"=>sprintf("",$key). + ""._("application")." ".sprintf($linkadd,$key,$app), + "attach"=>"style='border:0px;'") + )); + } + + /* Create list of used/assigned applications */ + $div2 = new divSelectBox("appgroup"); + $div2->SetHeight(300); + + /* Check acls to create "edit/remove" category links */ + if(!$this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ + $linkopen = "\"\" %s"; + $catremove = "  "; + $catupdown = ""; + }else{ + $linkopen = "\"\" %s"; + $catremove = " "; + $catupdown = "". + "\"\"". + " ". + "". + "\"\"". + ""; + } + + /* Add back category for current category */ + if(empty($this->curCatDir)){ + $cnt =0; + }else{ + $cnt = count(split("/",$this->curCatDir)); + $tmp = split("/",$this->curCatDir); + $bbk = ""; + for($i = 0 ; $i < ($cnt -1 ) ; $i++){ + $bbk .= $tmp[$i]."/"; + } + $bbk = preg_replace("/\/$/","",$bbk); + $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,base64_encode($bbk),".. ["._("Back")."]")),array("string"=>" ","attach"=>"style='border-right:0px;'"))); + } + + /* Add sub categories */ + $this->GetSubdirs($this->curCatDir); + foreach($this->GetSubdirs($this->curCatDir) as $path => $name){ + $div2 ->AddEntry(array( + array("string"=>sprintf($linkopen,base64_encode($path),$name)), + array("string"=>preg_replace("/%s/",base64_encode($path),$catupdown.$catremove), + "attach"=>"align='right' style='width:80px;border-right:0px;'"))); + } + + /* Create priority & seperator links */ + $separator ="
"; + if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ + $sep = ""; + $upudown = "". + " {t}sort{/t}". + " ". + "". + " {t}sort{/t}". + " ". + ""; + }else{ + $sep = ""; + $upudown = ""; + } + + /* Create edit link */ + if($this->acl_is_writeable("gosaApplicationParameter",$this->no_release_acls)){ + $edit= " "; + }else{ + $edit= ""; + } + + /* Get differences to mark those entries that have changed from last edit. */ + $Differences = $this->diffAppsInReleases(); + + /* Walk through entries an append them to list */ + if(isset($this->gosaMemberApplication[$this->curCatDir])){ + foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){ + + /* Add seperator */ + if(preg_match("/__SEPARATOR__/",$entry['App'])){ + $div2 ->AddEntry(array(array("string"=>$separator), + array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$upudown),"attach"=>"align='right' style='border-right:0px;'"))); + }else{ + + /* Add application */ + + $image = ""; + /* Check if application was available within selected release + * or application list if release management is not active + */ + if(!in_array($entry['App'],$this->AllAppsForRelease)){ + + /* release managent is active + */ + if(!$this->enableReleaseManagement){ + $image = "R "; + }else{ + $image = "FFAIrelease)."\"> "; + } + + }elseif(isset($Differences[$entry['App']]) && ($Differences[$entry['App']] == true)) { + $entry['App'].=" ["._("Check parameter")."]"; + $image = " "; + }else{ + $image = "\"\" "; + } + + $div2->AddEntry(array(array("string"=>sprintf($image."%s",$entry['App'])), + array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$sep.$edit.$upudown), + "attach"=>"align='right' style='width:100px;border-right:0px;'"))); + } + } + } + + /* Assign created div lists to template */ + $smarty->assign("UsedApps", $div2->DrawList()); + $smarty->assign("List", $div->DrawList()); + $smarty->assign("apps", $apps); + + $smarty->assign("enableReleaseManagement",$this->enableReleaseManagement); + + $smarty->assign("ReleaseSelectAble", false); + $smarty->assign("Release", $this->FAIrelease); + + if($this->enableReleaseManagement){ + $smarty->assign("FAIrelease", $this->FAIrelease); + $smarty->assign("Releases", $this->Releases); + + if(!$this->no_release_acls && count($this->Releases)){ + $smarty->assign("ReleaseSelectAble", true); + } + } + + /* Set acls to template */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $acl => $translation){ + $smarty->assign($acl."ACL",$this->getacl($acl,$this->no_release_acls)); + } + + /* Show main page */ + if (is_object($this->dialog)){ + $smarty->assign("table", $this->table); + $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE,dirname(__FILE__))); + } else { + $display.= $smarty->fetch (get_template_path('application.tpl', TRUE,dirname(__FILE__))); + } + + return ($display); + } + + + function getReleases() + { + /* Only display those releases that we are able to read */ + $dn = $this->config->current['BASE']; + $filter = "(&(objectClass=organizationalUnit)(objectClass=FAIbranch))"; + $res = get_list($filter,"application", $dn, array("ou"), GL_SUBSEARCH); + + $ret =array(); + foreach($res as $attrs){ + if(preg_match("/ou=apps,/",$attrs['dn'])){ + $bb = preg_replace("/ou=apps,.*/","",$attrs['dn']); + $parts = array_reverse(split("ou=",$bb)); + + $str =""; + foreach($parts as $part){ + if(empty($part)) { + continue; + } + $str .= str_replace(",","",$part)."/"; + } + $name = preg_replace("/\/$/","",$str); + if(empty($name)) { + $name ="/"; + } + $ret[$attrs['dn']] = $name; + } + } + return($ret); + } + + function save_object() + { + + /* Move category one position up or down */ + if((isset($_GET['act']))&&(($_GET['act'] == "cat_up")||($_GET['act']=="cat_down"))){ + if($_GET['act']=="cat_up"){ + $this->catUp(base64_decode($_GET['id'])); + } + if($_GET['act']=="cat_down"){ + $this->catDown(base64_decode($_GET['id'])); + } + } + + /* Move application one position up or down */ + if((isset($_GET['act']))&&(($_GET['act'] == "one_up")||($_GET['act']=="one_down"))){ + if(isset($_GET['id'])){ + $id = $_GET['id']; + $act = $_GET['act']; + + if($act == "one_up"){ + $this->getOneUp($id); + }elseif($act == "one_down") { + $this->getOneDown($id); + } + } + } + + + plugin::save_object(); + } + + + function remove_from_parent() + { + if(!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + + $ldap->modify ($this->attrs); + new log("remove","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/applications with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove"); + } + + + /* Save to LDAP */ + function save() + { + /* Skip saving application settings, if we do not have release acls */ + if($this->no_release_acls){ + new log("security","groups/".get_class($this),$this->dn,array(),"Skip saving group application extension. Caused by insufficient acls"); + + return; + } + + plugin::save(); + + + + /* Copy members */ + $this->Categories[""]=""; + $this->attrs["gosaMemberApplication"]= array(); + $this->attrs["gosaApplicationParameter"]= array(); + $cat_id= 0 ; + foreach($this->Categories as $name => $cats){ + $i =0; + if(isset($this->gosaMemberApplication[$name])){ + foreach($this->gosaMemberApplication[$name] as $entry){ + if(!preg_match("/__SEPARATOR__/",$entry['App'])){ + $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$i; + $i ++; + } + } + } + if(($i==0)&&(!empty($name))){ + $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cat_id; + } + $cat_id++; + } + + + + /* Are there application parameters to be saved */ + $this->attrs['gosaApplicationParameter']= array(); + foreach($this->appoption as $name => $value){ + if ($value != ""){ + $this->attrs['gosaApplicationParameter'][]= "$name:$value"; + } + } + + /* Write back to LDAP */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + if($this->initially_was_account){ + new log("modify","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of groups/applications with dn '%s' failed."),$this->dn)); + + /* 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"); + } + } else { + $this->handle_post_events("add"); + } + + } + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + + function reload() + { + /* Generate applist */ + $this->apps= array(); + + /* Special handling for release managed apps */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp) && count($this->Releases)){ + $this->enableReleaseManagement = true; + + /* Check if release is available */ + $tmp = array_flip($this->Releases); + if(isset($tmp[$this->FAIrelease])){ + $base = $tmp[$this->FAIrelease]; + }else{ + + /* Release is not available, check if there is an alternative */ + $old_r = $this->FAIrelease; + $k = key($tmp); + + if(isset($tmp[$k])){ + + /* We have found an alternative release name */ + $r = $tmp[$k]; + $this->FAIrelease = $k; + $base = $r; + + /* Display msg */ + if(!(!$this->initially_was_account && $old_r =="/")){ + print_red(sprintf(_("Can't resolve the release name '%s', setting release name to '%s'. Possibly the objects base has changed."),$old_r,$k)); + } + }else{ + + /* There are no releases available ... */ + print_red(_("There are no releases available. You will not be able to select another release.")); + return; + } + } + + /* Get applications for this release */ + $base = preg_replace("/ou=apps,.*$/","ou=apps,".$this->curbase,$base); + $res = get_list("(objectClass=gosaApplication)","application",$base,array("*")); + }else{ + + /* Get applications for this base */ + $res = get_list("(objectClass=gosaApplication)","application","ou=apps,".$this->curbase,array("*")); + } + + /* Append applications */ + foreach($res as $attrs){ + if (isset($attrs["description"][0])){ + $this->apps[$attrs["cn"][0]]= + $attrs["cn"][0]." (". + $attrs["description"][0].")"; + } else { + $this->apps[$attrs["cn"][0]]= + $attrs["cn"][0]; + } + } + + /* Get all apps ... */ + $res = get_list("objectClass=gosaApplication","application",$this->config->current['BASE'],array("gosaApplicationParameter","cn"),GL_SUBSEARCH); + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + $this->AllAppsForRelease = array(); + if(!empty($tmp)){ + $tmp = array_flip($this->Releases); + foreach($res as $attrs){ + + $testdn = preg_replace("/ou=apps,.*$/","ou=apps",$attrs['dn']); + $testdn = preg_replace("/^[^,]+/","",$testdn); + $testdn = preg_replace("/^,/","",$testdn); + + if($testdn == preg_replace("/ou=apps,.*$/","ou=apps",$tmp[$this->FAIrelease])){ + $this->AllAppsForRelease[$attrs['dn']] = $attrs['cn'][0]; + $this->AllAppsForReleaseParameter[$this->FAIrelease][$attrs['cn'][0]] = $attrs; + } + } + }else{ + foreach($res as $attrs){ + $this->AllAppsForRelease[$attrs['dn']] = $attrs['cn'][0]; + } + } + + natcasesort ($this->apps); + reset ($this->apps); + + if(is_array($this->gosaMemberApplication)) + foreach ($this->gosaMemberApplication as $cat){ + if(is_array($cat)) + foreach($cat as $entry){ + $this->used_apps[$entry['App']]= $entry['App']; + } + } + } + + + function addApp($cn) + { + if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){ + foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){ + if($entry['App'] == $cn) return; + } + } + $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn); + $this->used_apps[$cn]=$cn; + $this->is_modified= TRUE; + } + + + function removeApp($cn) + { + $temp= array(); + foreach ($this->gosaMemberApplication as $value){ + if ($value != $cn){ + $temp[]= $value; + } + } + $this->gosaMemberApplication= $temp; + $this->is_modified= TRUE; + } + + function getParameters($app) + { + $tmp = $this->getReleases(); + $ret = array(); + if(in_array($this->FAIrelease,$tmp)){ + $tmp2 = array_flip($tmp); + $base = $tmp2[$this->FAIrelease]; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaApplication)(cn=".$app.")(gosaApplicationParameter=*))",array("gosaApplicationParameter")); + if($ldap->count()){ + $attrs = $ldap->fetch(); + for($i = 0 ; $i < $attrs['gosaApplicationParameter']['count'] ; $i ++ ){ + $name = preg_replace("/:.*$/","",$attrs['gosaApplicationParameter'][$i]); + $ret[$name] = $name; + } + } + } + return($ret); + } + + function GetSubdirs($dir) + { + $ret = array(); + $tmp1 = split("/",$this->curCatDir); + + foreach($this->Categories as $path=>$cat){ + $tmp2 = split("/",$path); + + if((empty($this->curCatDir))&&(!preg_match("/\//",$path))){ + $abort = false; + }elseif(((count($tmp1))+1) == (count($tmp2))){ + $abort = false; + for($i = 0 ; $i < count($tmp1) ; $i++){ + if($tmp1[$i] != $tmp2[$i]){ + $abort = true; + } + } + }else{ + $abort= true; + } + if(!$abort){ + $ret[$path]=$cat; + } + } + return($ret); + } + + + function PrepareForCopyPaste($source) + { + $s = new appgroup($this->config,$source['dn']); + $this->FAIrelease = $this->InitialFAIrelease = $s->FAIrelease; + $this->gosaMemberApplication = $s->gosaMemberApplication; + $this->appoption = $s->appoption; + $this->Categories = $s->Categories; + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Applications"), + "plDescription" => _("Group applications"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("admin"), + "plCategory" => array("groups"), + "plProvidedAcls"=> array( + "gosaMemberApplication" => _("Application"), + "FAIrelease" => _("Release"), + "gosaApplicationParameter" => _("Application parameter")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/groups/class_groupGeneric.inc b/gosa-core/plugins/admin/groups/class_groupGeneric.inc new file mode 100644 index 000000000..095d3be27 --- /dev/null +++ b/gosa-core/plugins/admin/groups/class_groupGeneric.inc @@ -0,0 +1,978 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Group attributes */ + var $cn= ""; + var $description= ""; + var $gidNumber= ""; + var $memberUid= array(); + + /* Helpers */ + var $base= ""; + var $force_gid= FALSE; + var $fon_group= FALSE; + var $smbgroup= FALSE; + var $groupType= FALSE; + var $samba3= FALSE; + var $sambaSID= ""; + var $sambaDomainName= "DEFAULT"; + var $SID= ""; + var $ridBase= 0; + var $members= array(); + var $users= array(); + var $member= array(); + var $allusers= array(); + var $saved_gidNumber= ""; + var $oldgroupType= ""; + var $orig_dn= ""; + var $orig_cn= ""; + var $has_mailAccount= FALSE; + var $group_dialog= FALSE; + var $nagios_group =FALSE; + var $sambaGroupType; + var $dialog; + var $rfc2307bis= FALSE; + var $OnlyShowFirstEntries =200; + var $dnMapping= array(); + var $view_logged = FALSE; + var $allowGroupsWithSameNameInOtherSubtrees = true; + + /* attribute list for save action */ + var $attributes= array("cn", "description", "gidNumber","memberUid","sambaGroupType","sambaSID"); + var $objectclasses= array("top", "posixGroup"); + + var $CopyPasteVars = array("force_gid","fon_group","smbgroup","groupType","sambaSID","sambaDomainName","SID","nagios_group","sambaGroupType"); + + function group (&$config, $dn= NULL) + { + /* Set rfc2307bis flag */ + if (isset($config->current['RFC2307BIS']) && ($config->current['RFC2307BIS']== "true")){ + $this->rfc2307bis= TRUE; + $this->attributes[]= "member"; + $this->objectclasses[]= "groupOfNames"; + } + + plugin::plugin ($config, $dn); + + /* Load attributes depending on the samba version */ + $this->samba3= ($config->current['SAMBAVERSION'] == 3); + $this->orig_dn= $dn; + $this->orig_cn= $this->cn; + + /* Get member list */ + if (isset($this->attrs['memberUid'][0])){ + $tmp= array(); + for ($i= 0; $i<$this->attrs['memberUid']['count']; $i++){ + $tmp[]= $this->attrs['memberUid'][$i]; + } + $this->memberUid= $tmp; + sort ($this->memberUid); + } + + /* Save gidNumber for later use */ + if (isset($this->attrs['gidNumber'])){ + $this->saved_gidNumber= $this->attrs['gidNumber'][0]; + } + + /* Is a samba group? */ + if (isset($this->attrs['objectClass'])){ + if (array_search ('sambaGroupMapping', $this->attrs['objectClass']) == FALSE ){ + $this->smbgroup= FALSE; + } else { + $this->smbgroup= TRUE; + if (isset($this->attrs['sambaSID'])){ + $this->sambaSID= $this->attrs['sambaSID'][0]; + } + } + if (array_search ('goFonPickupGroup', $this->attrs['objectClass']) == FALSE ){ + $this->fon_group= FALSE; + } else { + $this->fon_group= TRUE; + } + if (array_search ('nagiosContactGroup', $this->attrs['objectClass']) == FALSE ){ + $this->nagios_group= FALSE; + } else { + $this->nagios_group= TRUE; + } + } + + /* Set mail flag */ + if (isset($this->attrs['objectClass']) && in_array('gosaMailAccount', $this->attrs['objectClass'])){ + $this->has_mailAccount= TRUE; + } + + /* Get samba Domain in case of samba 3 */ + if ($this->samba3 && $this->sambaSID != ""){ + $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID); + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase")); + if ($ldap->count() != 0){ + $attrs= $ldap->fetch(); + $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0]; + + /* Get domain name for SID */ + $this->sambaDomainName= "DEFAULT"; + foreach ($this->config->data['SERVERS']['SAMBA'] as $key => $val){ + if ($val['SID'] == $this->SID){ + $this->sambaDomainName= $key; + break; + } + } + } else { + if (isset($this->config->current['RIDBASE'])){ + $this->sambaDomainName= "DEFAULT"; + $this->ridBase= $this->config->current['RIDBASE']; + $this->SID= $this->config->current['SID']; + } else { + print_red(_("Can't find this groups SID in LDAP or in your configuration file!")); + } + } + + /* Get group type */ + $this->groupType= (int)substr(strrchr($this->sambaSID, "-"), 1); + if ($this->groupType < 500 || $this->groupType > 553){ + $this->groupType= 0; + } + $this->oldgroupType= $this->groupType; + } + + /* Get global filter config */ + if (!is_global("gufilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $gufilter= array( "dselect" => $base, + "regex" => "*"); + register_global("gufilter", $gufilter); + } + $gufilter= get_global('gufilter'); + + $gufilter['SubSearchGroup'] = false; + $gufilter['dselect'] = $_SESSION['gufilter']['dselect']; + + register_global('gufilter',$gufilter); + + if ($this->dn == "new"){ + if(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['CurrentMainBase']; + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + + /* Get object base */ + $this->base =preg_replace ("/^[^,]+,".normalizePreg(get_groups_ou())."/","",$this->dn); + } + + /* This is always an account */ + $this->is_account= TRUE; + $this->reload(); + } + + function execute() + { + /* Call parent 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); + } + + /* Do we represent a valid group? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' is no group.").""; + return ($display); + } + + /* Delete user from group */ + if (isset($_POST['del_users']) && isset($_POST['members'])){ + foreach ($_POST['members'] as $value){ + unset ($this->members["$value"]); + $this->removeUser($value); + } + $this->reload(); + } + + /* Add objects? */ + if (isset($_POST["edit_membership"])){ + $this->group_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Add objects finished? */ + if (isset($_POST["add_users_finish"]) || isset($_POST["add_users_cancel"])){ + $this->group_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Add user to group */ + if (isset($_POST['add_users_finish']) && isset($_POST['users'])){ + foreach ($_POST['users'] as $value){ + $this->members["$value"]= $this->allusers[$value]; + asort($this->members); + $this->addUser($value); + } + $this->reload(); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){ + + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* Check if selected base is valid */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Assign templating stuff */ + $smarty= get_smarty(); + if ($this->samba3){ + $smarty->assign("samba3", "true"); + } else { + $smarty->assign("samba3", ""); + } + + if($this->config->search("nagiosaccount", "CLASS",array('menu'))){ + $smarty->assign("nagios",true); + }else{ + $smarty->assign("nagios",false); + } + + if($this->config->search("phoneAccount", "CLASS",array('menu'))){ + $smarty->assign("pickupGroup",true); + }else{ + $smarty->assign("pickupGroup",false); + } + + /* Manage object add dialog */ + if ($this->group_dialog){ + + /* Save data */ + $gufilter= get_global("gufilter"); + foreach( array("dselect", "regex") as $type){ + if (isset($_POST[$type])){ + $gufilter[$type]= $_POST[$type]; + } + } + if(isset($_POST['regex'])){ + if(isset($_POST['SubSearchGroup'])){ + $gufilter['SubSearchGroup'] = true; + }else{ + $gufilter['SubSearchGroup'] = false; + } + } + + if (isset($_GET['search'])){ + $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; + if ($s == "**"){ + $s= "*"; + } + $gufilter['regex']= $s; + } + register_global("gufilter", $gufilter); + $this->reload(); + + /* Show dialog */ + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + + $smarty->assign("deplist", $this->get_allowed_bases("users/user")); + $smarty->assign("alphabet", generate_alphabet()); + foreach( array("dselect", "regex","SubSearchGroup") as $type){ + $smarty->assign("$type", $gufilter[$type]); + } + $smarty->assign("hint", print_sizelimit_warning()); + $smarty->assign("users", $this->displayUsers); + $smarty->assign("apply", apply_filter()); + $display= $smarty->fetch (get_template_path('group_objects.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + $smarty->assign("bases", $this->get_allowed_bases()); + $smarty->assign("base_select", $this->base); + + if ($this->samba3){ + $domains= array(); + foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){ + $domains[$name]= $name; + } + $smarty->assign("sambaDomains", $domains); + $smarty->assign("sambaDomainName", $this->sambaDomainName); + $groupTypes= array(0 => _("Samba group"), 512 => _("Domain admins"), 513 => _("Domain users"), + 514 => _("Domain guests")); + + /* Don't loose special groups! If not key'ed above, add it to + the combo box... */ + if ($this->groupType >= 500 && $this->groupType <= 553 && !isset($groupTypes[$this->groupType])){ + $groupTypes[$this->groupType]= sprintf(_("Special group (%d)"), $this->groupType); + } + + $smarty->assign("groupTypes", $groupTypes); + $smarty->assign("groupType", $this->groupType); + } + + /* Members and users */ + $smarty->assign("members", $this->members); + + /* Checkboxes */ + foreach (array("force_gid", "smbgroup") as $val){ + if ($this->$val == "1"){ + $smarty->assign("$val", "checked"); + } else { + $smarty->assign("$val", ""); + } + } + if ($this->force_gid != "1"){ + $smarty->assign("forceMode", "disabled"); + }else{ + $smarty->assign("forceMode", ""); + } + if ($this->fon_group){ + $smarty->assign("fon_group", "checked"); + } else { + $smarty->assign("fon_group", ""); + } + + if ($this->nagios_group){ + $smarty->assign("nagios_group", "checked"); + } else { + $smarty->assign("nagios_group", ""); + } + + /* Fields */ + foreach (array("cn", "description", "gidNumber") as $val){ + $smarty->assign("$val", $this->$val); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + if($this->acl_is_writeable("base")){ + $smarty->assign("baseSelect",true); + }else{ + $smarty->assign("baseSelect",false); + } + + /* Show main page */ + $smarty->assign("alphabet", generate_alphabet(10)); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("deplist", $this->config->idepartments); + return($smarty->fetch (get_template_path('generic.tpl', TRUE))); + } + + function addUser($uid) + { + $this->memberUid[]= $uid; + $this->memberUid= array_unique($this->memberUid); + } + + function removeUser($uid) + { + $temp= array(); + foreach ($this->memberUid as $value){ + if ($value != $uid){ + $temp[]= $value; + } + } + $this->memberUid= $temp; + } + + + /* Reload data */ + function reload() + { + /* Fix regex string */ + $gufilter = get_global("gufilter"); + $regex = normalizeLdap($gufilter['regex']); + $MaxUser = $this->OnlyShowFirstEntries; + + /* Prepare ldap link */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($gufilter['dselect']); + + + /* Resolve still unresolved memberuids to fill the list with sn/giveName attributes + (Store gathered sn/givenName informations in $this->allusers too, + to be prepared when adding/deleting users) + */ + $filter = ""; + foreach ($this->memberUid as $value){ + if(!isset($this->members[$value])){ + $filter .= "(uid=".normalizeLdap($value).")"; + } + } + if(!empty($filter)){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|".$filter."))",array("dn", "uid","sn","givenName")); + while($attrs = $ldap->fetch()){ + $this->dnMapping[$attrs['uid'][0]] = $attrs['dn']; + $this->members[$attrs['uid'][0]] = $this->createResultName($attrs); + $this->allusers[$attrs['uid'][0]]= $this->createResultName($attrs); + } + } + + /* check if all uids are resolved */ + foreach ($this->memberUid as $value){ + if(!isset($this->members[$value])){ + $this->members[$value] = _("! unknown id")." [".$value."]"; + } + } + + /* Create display list of users matching regex & filter + */ + $this->displayUsers = array(); + $filter = "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$))(|(uid=".$regex.")(sn=".$regex.")(givenName=".$regex.")))"; + + /* Search in current tree or within subtrees depending on the checkbox from filter section */ + if($gufilter['SubSearchGroup']){ + $flag = GL_SIZELIMIT | GL_SUBSEARCH; + $base = $gufilter['dselect']; + }else{ + $flag = GL_SIZELIMIT ; + $base = get_people_ou().$gufilter['dselect']; + } + $i = 0; + + + $res = get_list($filter,"users",$base,array("dn", "uid", "sn", "givenName"),$flag); + + /* Fetch all users and skip already used users */ + foreach($res as $attrs){ + if(in_array($attrs['uid'][0], $this->memberUid)) { + continue; + } + $i ++; + if($i > $MaxUser) { + break; + } + $this->dnMapping[$attrs['uid'][0]]= $attrs["dn"]; + $this->allusers[$attrs['uid'][0]] = $this->createResultName($attrs); + $this->displayUsers[$attrs['uid'][0]] = $this->createResultName($attrs); + } + + /* If more than max users are found, display a message to warn the user */ + if(($i == $MaxUser)){ + print_red(sprintf(_("Your search method returned more than '%s' users, only '%s' users are shown.") , $MaxUser,$MaxUser)); + } + + /* Sort lists */ + natcasesort($this->members); + reset($this->members); + natcasesort ($this->displayUsers); + reset ($this->displayUsers); + } + + + /* Create display name, this was used so often that it is excluded into a seperate function */ + function createResultName($attrs) + { + if (isset($attrs["givenName"][0]) && isset($attrs["sn"][0])){ + $ret = $attrs["sn"][0].", ".$attrs["givenName"][0]." [".$attrs["uid"][0]."]"; + } else { + $ret= $attrs['uid'][0]; + } + return($ret); + } + + + function remove_from_parent() + { + plugin::remove_from_parent(); + + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir($this->dn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/generic with dn '%s' failed."),$this->dn)); + + new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + + /* Remove ACL dependencies too, + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($this->dn)."*))",array("gosaAclEntry","dn")); + while($attrs = $ldap->fetch()){ + $acl = new acl($this->config,$this->parent,$attrs['dn']); + foreach($acl->gosaAclEntry as $id => $entry){ + foreach($entry['members'] as $m_id => $member){ + if($m_id == "G:".$this->dn || $m_id == "U:".$this->dn){ + unset($acl->gosaAclEntry[$id]['members'][$m_id]); + gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Removed acl for %s on object %s.",$this->dn,$attrs['dn'])); + } + } + } + $acl -> save(); + } + + /* Remove ACL dependencies too, + */ + $tmp = new acl($this->config,$this->parent,$this->dn); + $tmp->remove_acl(); + + /* Send signal to the world that we've done */ + $this->handle_post_events("remove"); + } + + + /* Save data to object */ + function save_object() + { + /* Save additional values for possible next step */ + if (isset($_POST['groupedit'])){ + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + $this->force_gid= 0; + + /* Only reset sambagroup flag if we are able to write this flag */ + if($this->acl_is_writeable("sambaGroupType")){ + $this->smbgroup = 0; + } + + /* Get base selection */ + if(isset($_POST['base'])){ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$_POST['base']])){ + $this->base = $_POST['base']; + } + } + + foreach (array( + "force_gid" => "gidNumber", + "smbgroup" => "sambaGroupType") as $val => $aclname) { + if ($this->acl_is_writeable($aclname) && isset($_POST["$val"])){ + $this->$val= $_POST["$val"]; + } + } + + /* Save sambaDomain attribute */ + if ($this->acl_is_writeable("sambaDomainName") && $this->samba3 && isset ($_POST['sambaDomainName'])){ + $this->sambaDomainName= $_POST['sambaDomainName']; + $this->groupType= $_POST['groupType']; + } + + /* Save fon attribute */ + if ($this->acl_is_writeable("fon_group")){ + if (isset ($_POST['fon_group'])){ + $this->fon_group= TRUE; + } else { + $this->fon_group= FALSE; + } + } + if ($this->acl_is_writeable("nagios_group")){ + if (isset ($_POST['nagios_group'])){ + $this->nagios_group= TRUE; + } else { + $this->nagios_group= FALSE; + } + } + } + } + + + /* Save to LDAP */ + function save() + { + + /* ID handling */ + if ($this->force_gid == 0){ + if ($this->saved_gidNumber != ""){ + $this->gidNumber= $this->saved_gidNumber; + } else { + /* Calculate new, lock uids */ + $wait= 10; + while (get_lock("uidnumber") != ""){ + sleep (1); + + /* timed out? */ + if ($wait-- == 0){ + break; + } + } + add_lock ("uidnumber", "gosa"); + $this->gidNumber= $this->get_next_id("gidNumber", $this->dn); + } + } + + plugin::save(); + + /* Remove objectClass for samba/phone support */ + $tmp= array(); + for ($i= 0; $iattrs["objectClass"]); $i++){ + if ($this->attrs['objectClass'][$i] != 'sambaGroupMapping' && + $this->attrs['objectClass'][$i] != 'sambaIdmapEntry' && + $this->attrs['objectClass'][$i] != 'goFonPickupGroup' && + $this->attrs['objectClass'][$i] != 'nagiosContactGroup'){ + $tmp[]= $this->attrs['objectClass'][$i]; + } + } + $this->attrs['objectClass']= $tmp; + $ldap= $this->config->get_ldap_link(); + + /* Add samba group functionality */ + if ($this->samba3 && $this->smbgroup){ + + /* Fixed undefined index ... + */ + $this->SID = $this->ridBase = ""; + if(isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){ + $this->SID = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID']; + }else{ + print_red(sprintf(_("No configured SID found for '%s'."),$this->sambaDomainName)); + } + if(isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'])){ + $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE']; + }else{ + print_red(sprintf(_("No configured RIDBASE found for '%s'."),$this->sambaDomainName)); + } + + $this->attrs['objectClass'][]= 'sambaGroupMapping'; + $this->attrs['sambaGroupType']= "2"; + + /* Check if we need to create a special entry */ + if ($this->groupType == 0){ + + if ($this->sambaSID == "" || $this->oldgroupType != $this->groupType){ + $gidNumber= $this->gidNumber; + while(TRUE){ + $sid= $this->SID."-".($gidNumber*2 + $this->ridBase+1); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(sambaSID=$sid)",array("sambaSID")); + if ($ldap->count() == 0){ + break; + } + $gidNumber++; + } + $this->attrs['sambaSID']= $sid; + $this->sambaSID= $sid; + } + + } else { + $this->attrs['sambaSID']=$this->SID."-".$this->groupType; + } + + /* User wants me to fake the idMappings? This is useful for + making winbind resolve the group names in a reasonable amount + of time in combination with larger databases. */ + if (isset($this->config->current['SAMBAIDMAPPING']) && + preg_match('/true/i', $this->config->current['SAMBAIDMAPPING'])){ + $this->attrs['objectClass'][]= "sambaIdmapEntry"; + } + + } + + /* Add phone functionality */ + if ($this->fon_group){ + $this->attrs['objectClass'][]= "goFonPickupGroup"; + } + + /* Add nagios functionality */ + if ($this->nagios_group){ + $this->attrs['objectClass'][]= "nagiosContactGroup"; + } + + /* Take members array */ + if (count ($this->memberUid)){ + $this->attrs['memberUid']= array_unique($this->memberUid); + } + + /* New accounts need proper 'dn', propagate it to remaining objects */ + if ($this->dn == 'new'){ + $this->dn= 'cn='.$this->cn.','.get_groups_ou().$this->base; + } + + /* Add member dn's for RFC2307bis Support */ + if ($this->rfc2307bis){ + if (count($this->memberUid)){ + $this->attrs['member'] = array(); + foreach($this->attrs['memberUid'] as $uid) { + $this->attrs['member'][]= $this->dnMapping[$uid]; + } + } else { + $this->attrs['member'][]= $this->dn; + } + } + + /* Save data. Using 'modify' implies that the entry is already present, use 'add' for + new entries. So do a check first... */ + $ldap->cat ($this->dn, array('dn')); + if ($ldap->fetch()){ + /* Modify needs array() to remove values :-( */ + if (!count ($this->memberUid)){ + $this->attrs['memberUid']= array(); + } + if ($this->samba3){ + if (!$this->smbgroup){ + $this->attrs['sambaGroupType']= array(); + $this->attrs['sambaSID']= array(); + } + } + $mode= "modify"; + } else { + $mode= "add"; + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + } + + /* Write back to ldap */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->$mode($this->attrs); + + /* Remove ACL dependencies too, + */ + if($this->dn != $this->orig_dn && $this->orig_dn != "new"){ + $tmp = new acl($this->config,$this->parent,$this->dn); + $tmp->update_acl_membership($this->orig_dn,$this->dn); + } + + 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()); + } + + $ret= 0; + if ( show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/generic with dn '%s' failed."),$this->dn))){ + $ret= 1; + } + + /* Remove uid lock */ + del_lock ("uidnumber"); + + /* Post that we've done*/ + $this->handle_post_events($mode); + + return ($ret); + } + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Permissions for that base? */ + if ($this->base != ""){ + $new_dn= 'cn='.$this->cn.','.get_groups_ou().$this->base; + } else { + $new_dn= $this->dn; + } + + /* must: cn */ + if ($this->cn == "" && $this->acl_is_writeable("cn")){ + $message[]= "The required field 'Name' is not set."; + } + + /* Check for valid input */ + if (!is_uid($this->cn)){ + $message[]= _("The field 'Name' contains invalid characters. Lowercase, numbers and dashes are allowed."); + } + + if($this->allowGroupsWithSameNameInOtherSubtrees == true){ + + /* Check for used 'cn' */ + $ldap= $this->config->get_ldap_link(); + if(($this->cn != $this->orig_cn) || ($this->orig_dn == "new")){ + $ldap->cd("ou=groups,".$this->base); + $ldap->ls("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",get_groups_ou().$this->base,array("cn")); + if ($ldap->count() != 0){ + $message[]= _("Value specified as 'Name' is already used."); + } + } + + }else{ + + /* Check for used 'cn' */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn")); + if ($ldap->count() != 0){ + + /* New entry? */ + if ($this->dn == 'new'){ + $message[]= _("Value specified as 'Name' is already used."); + } + + /* Moved? */ + elseif ($new_dn != $this->orig_dn){ + $ldap->fetch(); + if ($ldap->getDN() != $this->orig_dn){ + $message[]= _("Value specified as 'Name' is already used."); + } + } + } + } + + /* Check ID */ + if ($this->force_gid == "1"){ + if (!is_id($this->gidNumber)){ + $message[]= _("Value specified as 'GID' is not valid."); + } else { + if ($this->gidNumber < $this->config->current['MINID']){ + $message[]= _("Value specified as 'GID' is too small."); + } + + } + } + + return ($message); + } + + function get_next_id($attrib, $dn) + { + $ids= array(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd ($this->config->current['BASE']); + if (preg_match('/gidNumber/i', $attrib)){ + $oc= "posixGroup"; + } else { + $oc= "posixAccount"; + } + $ldap->search ("(&(objectClass=$oc)($attrib=*))", array("$attrib")); + + /* Get list of ids */ + while ($attrs= $ldap->fetch()){ + $ids[]= (int)$attrs["$attrib"][0]; + } + + /* Find out next free id near to UID_BASE */ + if (!isset($this->config->current['BASE_HOOK'])){ + $base= $this->config->current['UIDBASE']; + } else { + /* Call base hook */ + $base= get_base_from_hook($dn, $attrib); + } + for ($id= $base; $id++; $id < pow(2,32)){ + if (!in_array($id, $ids)){ + return ($id); + } + } + + /* Check if id reached maximum */ + if ($id >= pow(2,32)){ + print_red(_("Too many users, can't allocate a free ID!")); + exit; + } + } + + function getCopyDialog() + { + $vars = array("cn"); + + if($this ->force_gid){ + $used = " checked "; + $dis = ""; + }else{ + $used = ""; + $dis = " disabled "; + } + + $smarty = get_smarty(); + $smarty->assign("used",$used); + $smarty->assign("dis" ,$dis); + $smarty->assign("cn" ,$this->cn); + $smarty->assign("gidNumber",$this->gidNumber); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + if(isset($_POST['force_gid'])){ + $this->force_gid = 1; + $this->gidNumber= $_POST['gidNumber']; + }else{ + $this->force_gid = 0; + $this->gidNumber = false; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Generic group settings"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("admin"), + "plCategory" => array("groups" => array("objectClass" => "posixGroup", "description" => _("Groups"))), + + "plProvidedAcls" => array( + "cn" => _("Name"), + "base" => _("Base"), + "description" => _("Description"), + + "fonGroup" => _("Phone pickup group"), + "nagiosGroup" => _("Nagios group"), + + "gidNumber" => _("GID"), + "memberUid" => _("Group member"), + "sambaGroupType" => _("Samba group type"), + "sambaDomainName" => _("Samba domain name"), + "sambaSID" => _("Samba SID")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/groups/class_groupMail.inc b/gosa-core/plugins/admin/groups/class_groupMail.inc new file mode 100644 index 000000000..be6f7b3fe --- /dev/null +++ b/gosa-core/plugins/admin/groups/class_groupMail.inc @@ -0,0 +1,1162 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + var $uid = ""; // User id + var $cn = ""; // cn + var $orig_cn = ""; // cn + + var $method = "mailMethod"; // Used Mail method + var $mmethod = ""; // Contains the gosa.conf MAILMETHOD + var $mail = ""; // Default mail address + + var $gosaMailAlternateAddress = array(); // Set default Alternate Mail Adresses to empty array + var $gosaMailForwardingAddress = array(); // Forwarding also empty + + var $gosaMailServer = ""; // Selected mailserver + var $gosaMailQuota = ""; // Defined Quota + var $quotaUsage = 0; // Currently used quota + + var $gosaVacationMessage = ""; // Vocation message + + var $imapacl = array('anyone' => 'p', // Set acls for everyone + '%members%' => 'lrswp', // %members% are all group-members + '' => 'p'); // Every user added gets this right + + var $kolabFolderType_SubType = ""; + var $kolabFolderType_Type = ""; + + var $gosaSpamSortLevel = ""; + var $gosaSpamMailbox = ""; + var $gosaSharedFolderTarget ; + + var $forward_dialog = FALSE; + + var $members = array(); // Group members + + var $mailusers = array(); + var $perms = array(); + var $gosaMailDeliveryMode = "[L ]"; // + var $gosaMailMaxSize = ""; // + + var $remove_folder_from_imap = true; + + /* Helper */ + var $indexed_acl= array(); + var $indexed_user= array(); + + var $view_logged = FALSE; + + /* attribute list for save action */ + var $attributes= array( "mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize", + "gosaMailAlternateAddress", "gosaMailForwardingAddress", + "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox", + "acl","gosaSharedFolderTarget", "gosaVacationMessage"); + + var $objectclasses= array("gosaMailAccount"); + var $CopyPasteVars = array("quotaUsage","imapacl"); + + function mailgroup (&$config, $dn= NULL, $ui= NULL) + { + /* Initialise all available attributes ... if possible + */ + plugin::plugin($config, $dn); + $this->orig_cn = $this->cn; + + /* Set mailMethod to the one defined in gosa.conf + */ + if (isset($this->config->current['MAILMETHOD'])){ + $this->mmethod= $this->config->current['MAILMETHOD']; + } + + /* Check if selected mail method exists + */ + $cls = get_correct_class_name("mailMethod$this->mmethod"); + if ($cls && class_exists($cls)){ + $this->method= $cls; + } else { + print_red(sprintf(_("There is no mail method '%s' specified in your gosa.conf available."), $this->mmethod)); + } + + /* Load Mailserver + */ + if(isset($this->attrs['gosaMailServer'][0])){ + $this->gosaMailServer = $this->attrs['gosaMailServer'][0]; + } + + /* Convert cn to uid in case of existing entry + */ + if (isset($this->attrs['cn'][0])){ + $this->uid= $this->attrs['cn'][0]; + } + + /* Get folder type */ + if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){ + if(isset($this->attrs['kolabFolderType'])){ + $tmp = split("\.",$this->attrs['kolabFolderType'][0]); + $this->kolabFolderType_Type = $tmp[0]; + $this->kolabFolderType_SubType = $tmp[1]; + } + } + + /* If this ins't new mailgroup, read all required data from ldap + */ + if (($dn != "new")&&($dn !== NULL)){ + + /* Load attributes which represent multiple entries + */ + 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]); + } + } + } + + /* Only do IMAP actions if gosaMailServer attribute is set + */ + if (isset ($this->attrs["gosaMailServer"][0])){ + + /* Create new instance of our defined mailclass + */ + $method= new $this->method($this->config); + + if ($method->connect($this->attrs["gosaMailServer"][0])){ + + + /* Maybe the entry is not saved in new style, get + permissions from IMAP and convert them to acl attributes */ + if (!isset($this->attrs['acl'])){ + $this->imapacl= $method->getSharedFolderPermissions($this->uid); + + /* Need to filter what a member acl could be... */ + $vote= array(); + $peak= 0; + $leader= ""; + foreach ($this->imapacl as $user => $acl){ + + if ($user != "anyone" ){ + if (!isset($vote[$acl])){ + $vote[$acl]= 1; + } else { + $vote[$acl]++; + } + if ($vote[$acl] > $peak){ + $leader= $acl; + $peek= $vote[$acl]; + } + } + + } + + /* Highest count wins as %members%, remove all members + with the same acl */ + if(!empty($leader)){ + $this->imapacl['%members%']= $leader; + } + foreach ($this->imapacl as $user => $acl){ + if ($this->acl == $leader && in_array($user, $this->attrs['memberUid'])){ + unset($this->imapacl[$user]); + } + } + + } // ENDE ! isset ($this->attrs['acl']) + + /* Adapt attributes if needed */ + $method->fixAttributesOnLoad($this); + + /* get Quota */ + $quota= $method->getQuota($this->uid); + + /* Update quota values */ + if(is_array($quota)){ + if ($quota['gosaMailQuota'] == 2147483647){ + $this->quotaUsage= ""; + $this->gosaMailQuota= ""; + } else { + $this->quotaUsage= $quota['quotaUsage']; + $this->gosaMailQuota= $quota['gosaMailQuota']; + } + }else{ + $this->quotaUsage = ""; + $this->gosaMailQuota = ""; +// print_red(sprintf(_("Can't get quota information for '%s'."),$this->uid)); + } + $method->disconnect(); + } // ENDE $method->connect($this->attrs["gosaMailServer"][0])){ + + } // ENDE gosaMailServer + + } // ENDE dn != "new" + + + /* Get global filter config */ + if (!is_global("gmailfilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $gmailfilter= array( "depselect" => $base, + "muser" => "", + "regex" => "*"); + register_global("gmailfilter", $gmailfilter); + } + + /* Load permissions */ + $tmp = array(); + if(preg_match("/olab/i",$this->mmethod)){ + $ldap = $this->config->get_ldap_link(); + + if (isset($this->attrs['acl'])){ + + for ($i= 0; $i<$this->attrs['acl']['count']; $i++){ + list($user, $permission)= split(' ', $this->attrs['acl'][$i]); + + /* Add to list */ + $this->imapacl[$user]= $permission; + + /* Get all user permissions sorted by acl, to detect the most used acl + This acl is then used for %members% + */ + if ($user != "anyone" && $user != "%members%"){ + $tmp[$permission][] = $user; + } + + /* There is an entry in $this->imapacl like this this ... + $this->attrs['imapacl']['anyone'] = "p"; + $this->attrs['imapacl']['%members%'] = "lprs"; + $this->attrs['imapacl'][''] = ""; <------ This is used to diplay an empty + Field for special acls in our template. + If there is at least one special acl in out imapacl, + we don't need this entry anymore, because it is already displayed. + */ + if ($user != "anyone" && $user != "%members%"){ + unset($this->imapacl['']); + } + } + } + + /* In this section we dectect which acl is tho most used + This will be used as %members% acl + */ + $tmp2 = array(); + foreach($tmp as $acl => $user){ + $tmp2[count($tmp[$acl])]=$acl; + } + /* Most used at last + */ + ksort($tmp2); + + /* Assign last (most used acl) to %members% acl + */ + $str = array_pop($tmp2); + if(!empty($str)) { + $this->imapacl['%members%']=$str; + } + + /* Open ldap connection + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* Remove those users, that use %members% acl && are member of this group. */ + foreach($this->imapacl as $mail => $permission){ + $ldap->search("(&(objectClass=person)(mail=".$mail."))",array("uid")); + $atr = $ldap->fetch(); + if((isset($this->attrs['memberUid'])) && (is_array($this->attrs['memberUid']))){ + if((isset($atr['uid'][0]))&&(in_array($atr['uid'][0],$this->attrs['memberUid']))&&($permission == $this->imapacl['%members%'])){ + unset($this->imapacl[$mail]); + } + } + } + /* Append an empty entry, for special acl handling */ + if(count($this->imapacl)==2){ + $this->imapacl[''] =""; + } + + }else{ // Not kolab + /* Load permissions */ + if (isset($this->attrs['acl'])){ + for ($i= 0; $i<$this->attrs['acl']['count']; $i++){ + list($user, $permission)= split(' ', $this->attrs['acl'][$i]); + $this->imapacl[$user]= $permission; + if ($user != "anyone" && $user != "%members%"){ + unset($this->imapacl['']); + } + } + } + } + + /* Load Mailserver + */ + if(isset($this->attrs['gosaMailServer'][0])){ + $this->gosaMailServer = $this->attrs['gosaMailServer'][0]; + } + /* Fill translations */ + $this->perms["lrsw"]= _("read"); + $this->perms["lrspw"]= _("post"); + $this->perms["p"]= _("external post"); + $this->perms["lrsipw"]= _("append"); + $this->perms["lrswipcd"]= _("write"); + $this->perms["lrswipcda"]= _("admin"); + $this->perms[""]= _("none"); + } + + function execute() + { + /* Call parent 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); + } + + /* Load templating engine */ + $smarty= get_smarty(); + + /* Assign acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation) { + $smarty->assign($name."ACL",$this->getacl($name)); + } + + if ($_SESSION['js']==FALSE){ + $smarty->assign("javascript", "false"); + } else { + $smarty->assign("javascript", "true"); + } + + /* Do we need to flip is_account state? */ + 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; + } + } + + $display = ""; + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + + $display.= "\"\" ". + _("This 'dn' has no valid mail extensions.").""; + return ($display); + } + + /* Show tab dialog headers */ + $display= ""; + if ($this->parent !== NULL){ + if ($this->is_account){ + $display.= $this->show_disable_header(_("Remove mail account"), + _("This account has mail features enabled. You can disable them by clicking below.")); + } else { + $display.= $this->show_enable_header(_("Create mail account"), + _("This account has mail features disabled. You can enable them by clicking below.")); + + /* Show checkbox that allows us to remove imap entry too*/ + if($this->initially_was_account){ + $c = ""; + if($this->remove_folder_from_imap){ + $c= " checked "; + } + $display .= "

Shared folder delete options

+ "; + $display .= _("Remove the shared folder and all its contents after saving this account"); + } + return ($display); + } + } + + /* Add ACL? */ + if($this->acl_is_writeable("acl")){ + foreach ($this->indexed_user as $nr => $user){ + if (isset($_POST["add_$nr"])){ + $this->imapacl[""]= "l"; + } + if (isset($_POST["del_$nr"])){ + unset ($this->imapacl[$user]); + } + } + } + + /* Trigger forward add dialog? */ + if($this->acl_is_writeable("gosaMailForwardingAddress")){ + if (isset($_POST['add_local_forwarder'])){ + $this->forward_dialog= TRUE; + $this->dialog= TRUE; + } + } + + /* Cancel forward add dialog? */ + if($this->acl_is_writeable("gosaMailForwardingAddress")){ + if (isset($_POST['add_locals_cancel'])){ + $this->forward_dialog= FALSE; + $this->dialog= FALSE; + } + } + + /* Finished adding of locals? */ + if ((isset($_POST['add_locals_finish'])) && ($this->acl_is_writeable("gosaMailForwardingAddress"))) { + if (count ($_POST['local_list']) && $this->acl_is_writeable("gosaMailForwardingAddress")){ + + /* Walk through list of forwarders, ignore own addresses */ + foreach ($_POST['local_list'] as $val){ + if (!in_array ($val, $this->gosaMailAlternateAddress) && + $val != $this->mail){ + + $this->addForwarder($val); + } + } + } + $this->forward_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Add forward email addresses */ + if ((isset($_POST['add_forwarder'])) && ($this->acl_is_writeable("gosaMailForwardingAddress"))){ + if ($_POST['forward_address'] != ""){ + + /* Valid email address specified? */ + $address= $_POST['forward_address']; + if (!is_email($address)){ + + print_red (_("You're trying to add an invalid email address ". + "to the list of forwarders.")); + + } elseif ($address == $this->mail + || in_array($address, $this->gosaMailAlternateAddress)) { + + print_red (_("Adding your one of your own addresses to the forwarders makes no sense.")); + + } else { + + /* Add it */ + if ($this->acl_is_writeable("gosaMailForwardingAddress")){ + $this->addForwarder ($address); + } + + } + } + } + + /* Delete forward email addresses */ + if (isset($_POST['delete_forwarder']) && ($this->acl_is_writeable("gosaMailForwardingAddress"))){ + if (count($_POST['forwarder_list'])&& $this->acl_is_writeable("gosaMailForwardingAddress")){ + + $this->delForwarder ($_POST['forwarder_list']); + } + } + + /* Add alternate email addresses */ + if (isset($_POST['add_alternate'])){ + if ($_POST['alternate_address'] != "" && $this->acl_is_writeable("gosaMailAlternateAddress")){ + + if (!is_email($_POST['alternate_address'])){ + print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); + + } elseif (($user= $this->addAlternate ($_POST['alternate_address'])) != ""){ + $ui= get_userinfo(); + if ($user != $ui->username){ + print_red (_("The address you're trying to add is already used by user")." '$user'."); + } + } + } + } + + /* Delete alternate email addresses */ + if($this->acl_is_writeable("gosaMailAlternateAddress")){ + if (isset($_POST['delete_alternate']) && isset ($_POST['alternates_list'])){ + if (count($_POST['alternates_list']) && $this->acl_is_writeable("gosaMailAlternateAddress")){ + $this->delAlternate ($_POST['alternates_list']); + } + } + } + + /* Show forward add dialog */ + if ($this->forward_dialog){ + $ldap= $this->config->get_ldap_link(); + + /* Save data */ + $gmailfilter= get_global("gmailfilter"); + foreach( array("depselect", "muser", "regex") as $type){ + if (isset($_POST[$type])){ + $gmailfilter[$type]= $_POST[$type]; + } + } + if (isset($_GET['search'])){ + $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; + if ($s == "**"){ + $s= "*"; + } + $gmailfilter['regex']= $s; + } + register_global("gmailfilter", $gmailfilter); + + /* Get actual list */ + $mailusers= array (); + if ($gmailfilter['regex'] != '*' && $gmailfilter['regex'] != ""){ + $regex= $gmailfilter['regex']; + $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))"; + } else { + $filter= ""; + } + if ($gmailfilter['muser'] != ""){ + $user= $gmailfilter['muser']; + $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))"; + } + + /* Add already present people to the filter */ + $exclude= ""; + foreach ($this->gosaMailForwardingAddress as $mail){ + $exclude.= "(mail=$mail)"; + } + if ($exclude != ""){ + $filter.= "(!(|$exclude))"; + } + + $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $gmailfilter['depselect'], + array("sn", "mail", "givenName"), GL_SUBSEARCH | GL_SIZELIMIT); + $ldap->cd($gmailfilter['depselect']); + $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName")); + error_reporting (0); + while ($attrs= $ldap->fetch()){ + if(preg_match('/%/', $attrs['mail'][0])){ + continue; + } + $name= $this->make_name($attrs); + $mailusers[$attrs['mail'][0]]= $name."<". + $attrs['mail'][0].">"; + } + error_reporting (E_ALL | E_STRICT); + natcasesort ($mailusers); + reset ($mailusers); + + /* Show dialog */ + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("usearch_image", get_template_path('images/search_user.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("mailusers", $mailusers); + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("hint", print_sizelimit_warning()); + foreach( array("depselect", "muser", "regex") as $type){ + $smarty->assign("$type", $gmailfilter[$type]); + } + $smarty->assign("hint", print_sizelimit_warning()); + $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE)); + return ($display); + } + + /* Assemble normal permissions */ + if (isset($this->imapacl['anyone'])){ + $smarty->assign("default_permissions", $this->imapacl['anyone']); + } + $smarty->assign("member_permissions", "lrsp"); + if (isset($this->imapacl['%members%'])){ + $smarty->assign("member_permissions", $this->imapacl['%members%']); + } + + /* Assemble extra attributes */ + $perm= $this->getacl( "permissions"); + $tmp= ""; + $nr= 0; + $count= count($this->imapacl); + $this->indexed_user= array(); + $this->indexed_acl= array(); + foreach($this->imapacl as $user => $acl){ + + /* Add additional acl settings */ + if ($user != "anyone" && $user != "%members%"){ + + $Dis = ""; + if(!preg_match("/w/",$perm)){ + $Dis = " disabled "; + } + + /* Reset given Acls to ensure that nobody can read username and acls if not allwoed */ + if(!preg_match("/r/",$perm)){ + $user = ""; + $nr = "none"; + $key = "none"; + } + + $tmp.= " + + + + +  "; + + + + if ($nr == $count - 1){ + if($this->acl_is_writeable("acl")){ + $tmp.= ""; + } + } + if ($count > 3){ + if($this->acl_is_writeable("acl")){ + $tmp.= ""; + } + } + } + $this->indexed_user[$nr]= $user; + $this->indexed_acl[$nr++]= $acl; + } + $smarty->assign("plusattributes", $tmp); + + /* Show main page */ + $mailserver= array(); + foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){ + $mailserver[]= $key; + } + $smarty->assign("mailServers", $mailserver); + foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail", + "gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){ + $smarty->assign("$val", $this->$val); + } + if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){ + if($this->acl_is_readable("gosaMailQuota")){ + $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true)); + $smarty->assign("quotadefined", "true"); + }else{ + $smarty->assign("quotadefined", "true"); + $smarty->assign("quotausage", "-"); + } + } else { + $smarty->assign("quotadefined", "false"); + } + + if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){ + + $smarty->assign("kolab", TRUE); + $smarty->assign("JS",$_SESSION['js']); + $smarty->assign("kolabFolderType_Types", array ( '' => _('Unspecified'), 'mail' => _('Mails'), + 'task' => _('Tasks') , 'journal' => _('Journals'), + 'calendar' => _('Calendar'), 'contact' => _('Contacts'), + 'note' => _('Notes'))); + if($this->kolabFolderType_Type == "mail"){ + $smarty->assign("kolabFolderType_SubTypes", array( + '' => _('Unspecified'), 'inbox' => _("Inbox") , + 'drafts' => _("Drafts"), 'sentitems' => _("Sent items"), + 'junkemail' => _("Junk mail"))); + }else{ + $smarty->assign("kolabFolderType_SubTypes", array( 'default' => _("Default"))); + } + $smarty->assign("kolabFolderType_Type", $this->kolabFolderType_Type); + $smarty->assign("kolabFolderType_SubType", $this->kolabFolderType_SubType); + }else{ + $smarty->assign("kolab", FALSE); + } + + + $display.= $smarty->fetch (get_template_path('mail.tpl', TRUE)); + return ($display); + } + + + /* remove object from parent */ + function remove_from_parent() + { + if(!$this->initially_was_account){ + return; + } + + /* Added these ObjectClass and Attributes, because they were not + removed correctly, only in case of kolab ... + */ + if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){ + $this->attributes[]="acl"; + $this->objectclasses[] = "kolabSharedFolder"; + } + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + /* Zero arrays */ + $this->attrs['gosaMailAlternateAddress']= array(); + $this->attrs['gosaMailForwardingAddress']= array(); + $this->attrs['gosaSharedFolderTarget']= array(); + + /* Connect to IMAP server for account deletion */ + if ($this->initially_was_account){ + + $method= new $this->method($this->config); + $method->fixAttributesOnRemove($this); + if ($method->connect($this->gosaMailServer) && $this->remove_folder_from_imap){ + + /* Remove account from IMAP server */ + $method->deleteMailbox($this->uid); + $method->disconnect(); + } + } + /* Keep uid */ + unset ($this->attrs['uid']); + + $ldap->cd($this->dn); + $ldap->modify ($this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/mail with dn '%s' failed."),$this->dn)); + + + 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"); + } + + + /* Save data to object */ + function save_object() + { + + /* Add special kolab attributes */ + if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){ + if(isset($_POST['kolabFolderType_Type'])){ + $this->kolabFolderType_Type = get_post("kolabFolderType_Type"); + $this->kolabFolderType_SubType = get_post("kolabFolderType_SubType"); + } + } + + /* Check if user wants to remove the shared folder from imap too */ + if($this->initially_was_account && !$this->is_account){ + if(isset($_POST['remove_folder_from_imap'])){ + $this->remove_folder_from_imap = true; + }else{ + $this->remove_folder_from_imap = false; + } + } + + /* Assemble mail delivery mode + The mode field in ldap consists of values between braces, this must + be called when 'mail' is set, because checkboxes may not be set when + we're in some other dialog. + + Example for gosaMailDeliveryMode [LR ] +L: Local delivery +R: Reject when exceeding mailsize limit +S: Use spam filter +V: Use vacation message +C: Use custom sieve script +I: Only insider delivery */ + if (isset($_POST['mailedit'])){ + + plugin::save_object(); + + $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode); + + /* Handle delivery flags */ + if($this->acl_is_writeable("gosaMailDeliveryModeL")){ + if(!preg_match("/L/",$tmp) && !isset($_POST['drop_own_mails'])){ + $tmp.="L"; + }elseif(preg_match("/L/",$tmp) && isset($_POST['drop_own_mails'])){ + $tmp = preg_replace("/L/","",$tmp); + } + } + + $opts = array( + "R" => "use_mailsize_limit", + "S" => "use_spam_filter", + "V" => "use_vacation", + "C" => "own_script", + "I" => "only_local"); + + foreach($opts as $flag => $post){ + if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){ + if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){ + $tmp.= $flag; + }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){ + $tmp = preg_replace("/".$flag."/","",$tmp); + } + } + } + + $tmp= "[$tmp]"; + if ($this->gosaMailDeliveryMode != $tmp){ + $this->is_modified= TRUE; + } + $this->gosaMailDeliveryMode= $tmp; + + /* Collect data and re-assign it to the imapacl array */ + if ($this->acl_is_writeable("acl")){ + $this->imapacl= array(); + $this->imapacl['%members%']= $_POST['member_permissions']; + $this->imapacl['anyone']= $_POST['default_permissions']; + foreach ($this->indexed_user as $nr => $user){ + if (!isset($_POST["user_$nr"])){ + continue; + } + if ($_POST["user_$nr"] != $user || + $_POST["perm_$nr"] != $this->indexed_acl[$nr]){ + $this->is_modified= TRUE; + } + $this->imapacl[$_POST["user_$nr"]]= $_POST["perm_$nr"]; + } + } + } + + } + + + + /* Save data to LDAP, depending on is_account we save or delete */ + function save() + { + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* Call parents save to prepare $this->attrs */ + plugin::save(); + + /* Save arrays */ + $this->attrs['gosaMailAlternateAddress'] = $this->gosaMailAlternateAddress; + $this->attrs['gosaMailForwardingAddress'] = $this->gosaMailForwardingAddress; + $this->attrs['gosaSharedFolderTarget'] = "share+".$this->uid; + + /* Only do IMAP actions if we are not a template */ + if(preg_match("/olab/i",$this->mmethod)){ + if (empty($this->gosaMailServer)||is_array($this->gosaMailServer)){ + if(isset($this->attrs['gosaMailServer'][0])){ + $this->gosaMailServer = $this->attrs['gosaMailServer'][0]; + } + } + } + + /* Exchange '%member%' pseudo entry */ + $memberacl= $this->imapacl['%members%']; + + foreach ($this->members as $user){ + if (!isset($this->imapacl[$user])){ + $this->imapacl[$user]= $memberacl; + } + } + + if(preg_match("/olab/i",$this->mmethod)){ + + /* Save acl's */ + $this->attrs['acl']= array(); + foreach ($this->imapacl as $user => $acl){ + if ($user == "" || preg_match("/%members%/",$user)){ + continue; + } + $ldap->search("(&(objectClass=person)(|(uid=".$user.")(mail=".$user.")))",array("mail")); + $mail = $ldap->fetch(); + if(isset($mail['mail'][0])){ + $sacl = $mail['mail'][0]." ".$acl; + }else{ + $sacl= "$user $acl"; + } + if(!in_array($sacl,$this->attrs['acl'])){ + $this->attrs['acl'][]= $sacl; + } + } + + if(!empty($this->kolabFolderType_Type)){ + $this->attrs['kolabFolderType'] = $this->kolabFolderType_Type.".".$this->kolabFolderType_SubType; + }else{ + $this->attrs['kolabFolderType'] = array(); + } + }else{ + + /* Save acl's */ + $this->attrs['acl']= array(); + foreach ($this->imapacl as $user => $acl){ + if ($user == "" || preg_match("/%members%/",$user)){ + continue; + } + $this->attrs['acl'][]= "$user $acl"; + } + } + + if ((!$this->is_template)&&(!empty($this->gosaMailServer))){ + $method= new $this->method($this->config); + $method->fixAttributesOnStore($this); + if (($method->connect($this->gosaMailServer))){ + $method->updateMailbox($this->uid); + $method->setQuota($this->uid, $this->gosaMailQuota); + $method->setSharedFolderPermissions($this->uid, $this->imapacl); + $method->disconnect(); + } + } + + /* Save data to LDAP */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of groups/mail with dn '%s' failed."),$this->dn)); + + 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"); + } + } else { + $this->handle_post_events("add"); + } + } + + /* Check formular input */ + function check() + { + $ldap= $this->config->get_ldap_link(); + + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(!$this->is_account) return array(); + + //$message[] = $str; + + /* must: mail */ + if ($this->mail == ""){ + $message[]= _("The required field 'Primary address' is not set."); + } + if (!is_email($this->mail)){ + $message[]= _("Please enter a valid email addres in 'Primary address' field."); + } + $ldap->cd($this->config->current['BASE']); + $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=". + $this->mail."))(!(uid=".$this->orig_cn."))(!(cn=".$this->orig_cn.")))"); + if ($ldap->count() != 0){ + $message[]= _("The primary address you've entered is already in use."); + } + + /* Check quota */ + if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){ + if (!is_numeric($this->gosaMailQuota)) { + $message[]= _("Value in 'Quota size' is not valid."); + } else { + $this->gosaMailQuota= (int) $this->gosaMailQuota; + } + } + + /* Check rejectsize for integer */ + if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailQuota")){ + if (!is_numeric($this->gosaMailMaxSize)){ + $message[]= _("Please specify a vaild mail size for mails to be rejected."); + } else { + $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize; + } + } + + /* Need gosaMailMaxSize if use_mailsize_limit is checked */ + if (is_integer(strpos($this->gosaMailDeliveryMode, "reject")) && $this->gosaMailMaxSize == ""){ + $message[]= _("You need to set the maximum mail size in order to reject anything."); + } + + if(ord($this->imapacl['anyone'][0])==194){ + $message[] = _("Please choose valid permission settings. Default permission can't be emtpy."); + } + + if(empty($this->gosaMailServer)){ + $message[] = _("Please select a valid mail server."); + } + + return ($message); + } + + /* Adapt from template, using 'dn' */ + function adapt_from_template($dn) + { + plugin::adapt_from_template($dn); + + foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){ + $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); + } + } + array_push($this->$val, $value); + } + } + } + } + + /* Add entry to forwarder list */ + function addForwarder($address) + { + $this->gosaMailForwardingAddress[]= $address; + $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress); + + sort ($this->gosaMailForwardingAddress); + reset ($this->gosaMailForwardingAddress); + $this->is_modified= TRUE; + } + + /* Remove list of addresses from forwarder list */ + function delForwarder($addresses) + { + $this->gosaMailForwardingAddress= array_remove_entries ($addresses, + $this->gosaMailForwardingAddress); + $this->is_modified= TRUE; + } + + + + function addAlternate($address) + { + $ldap= $this->config->get_ldap_link(); + + $address= strtolower($address); + + /* Is this address already assigned in LDAP? */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)". + "(gosaMailAlternateAddress=$address)))"); + + if ($ldap->count() > 0){ + $attrs= $ldap->fetch (); + return ($attrs["uid"][0]); + } + + /* Add to list of alternates */ + if (!in_array($address, $this->gosaMailAlternateAddress)){ + $this->gosaMailAlternateAddress[]= $address; + } + + sort ($this->gosaMailAlternateAddress); + reset ($this->gosaMailAlternateAddress); + $this->is_modified= TRUE; + + return (""); + } + + + function delAlternate($addresses) + { + $this->gosaMailAlternateAddress= array_remove_entries ($addresses, + $this->gosaMailAlternateAddress); + $this->is_modified= TRUE; + } + + + 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.= " "; + } + + return ($name); + } + + function getCopyDialog() + { + if(!$this->is_account) return(""); + + $smarty = get_smarty(); + $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress); + $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress); + $smarty->assign("mail",$this->mail); + $display= $smarty->fetch (get_template_path('paste_mail.tpl', TRUE)); + $ret = array(); + $ret['string'] = $display; + $ret['status'] = ""; + return($ret); + } + + function saveCopyDialog() + { + if(!$this->is_account) return; + + /* Perform ADD / REMOVE ... for mail alternate / mail forwarding addresses + */ + $this->execute(); + if(isset($_POST['mail'])){ + $this->mail = $_POST['mail']; + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Reset alternate mail addresses */ + $this->gosaMailAlternateAddress = array(); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Mail"), + "plDescription" => _("Group mail"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("groups"), + "plProvidedAcls"=> array( + "mail" => _("Mail address"), + "gosaMailAlternateAddress" => _("Alternate addresses"), + "gosaMailForwardingAddress" => _("Forwarding addresses"), + "gosaMailQuota" => _("Quota size"), + "gosaMailServer" => _("Mail server"), + "acl" => _("Permissions")) + )); + } + + + /* Remove given ACL for given member (uid,mail) .. + */ + function removeUserAcl($index ) + { + if(isset($this->imapacl[$index])){ + unset($this->imapacl[$index]); + } + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/groups/class_groupManagement.inc b/gosa-core/plugins/admin/groups/class_groupManagement.inc new file mode 100644 index 000000000..f146ad689 --- /dev/null +++ b/gosa-core/plugins/admin/groups/class_groupManagement.inc @@ -0,0 +1,720 @@ +config = &$config; + $this->ui = &$ui; + + /* Copy & Paste enabled ?*/ + if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + + /* Detect if we have to display the primary group checkbox */ + $tmp = ""; + if (isset($this->config->data['MAIN']['NOPRIMARYGROUP'])){ + $tmp = $this->config->data['MAIN']['NOPRIMARYGROUP']; + } + if(preg_match("/true/i",$tmp)|| (preg_match("/yes/",$tmp))){ + $this->ShowPrimaryCheckBox = false; + } else { + $this->ShowPrimaryCheckBox = true; + } + + /* Create dialog object */ + $this->DivListGroup = new divListGroup($this->config,$this); + $this->DivListGroup->DisableCheckBox("ShowPrimaryGroups",$this->ShowPrimaryCheckBox); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Store these posts if the current object is locked (used by somebody else)*/ + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_groups/"); + + /* Save data */ + $s_action = ""; + $s_entry = ""; + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/^group_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/group_".$s_action."_/i","",$key); + // Post for edit + }elseif(preg_match("/^group_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/group_".$s_action."_/i","",$key); + // Post for new + }elseif(preg_match("/^group_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/^dep_home.*/i",$key)){ + $s_action="home"; + }elseif(preg_match("/^group_tplnew.*/i",$key)){ + $s_action="new_tpl"; + }elseif(preg_match("/^group_chgpw.*/i",$key)){ + $s_action="change_pw"; + $s_entry = preg_replace("/group_chgpw_/i","",$key); + }elseif(preg_match("/_group_edit_/",$key)){ + $type = preg_replace("/_group_edit_.*$/","",$key); + $s_action="edit"; + $s_entry = preg_replace("/".$type."_group_edit_/i","",$key); + $_POST['arg'] = $type; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + }elseif(preg_match("/^remove_multiple_groups/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^multiple_copy_groups/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_groups/",$key)){ + $s_action = "cut_multiple"; + } + } + $s_entry = preg_replace("/_.$/","",$s_entry); + + /* Check for posted gets */ + if((isset($_GET['act'])) && ($_GET['act'] == "edit_entry")){ + $s_entry = $_GET['id']; + $s_action = "edit"; + } + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "group_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + + + $smarty= get_smarty(); + + /******************** + Copy & Paste Handling ... + ********************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /******************** + Create a new group ... + ********************/ + + /* New group? */ + if ($s_action=="new"){ + + /* Check create permissions */ + $acl = $this->ui->get_permissions($this->DivListGroup->selectedBase,"groups/group"); + if(preg_match("/c/",$acl)){ + + /* By default we set 'dn' to 'new', all relevant plugins will + react on this. */ + $this->dn= "new"; + + /* Create new usertab object */ + $this->grouptab= new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $this->dn); + + /* Set up the group ACL's for this 'dn' */ + $this->grouptab->set_acl_base($this->DivListGroup->selectedBase); + } + } + + + /******************** + Save Group Tab/Object Changes + ********************/ + + /* Finish group edit is triggered by the tabulator dialog, so + the user wants to save edited data. Check and save at this + point. */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->grouptab->config)) ){ + + /* Check tabs, will feed message array + Save, or display error message? */ + $message= $this->grouptab->check(); + if (count($message) == 0){ + + /* Save user data to ldap */ + $this->grouptab->save(); + + if (!isset($_POST['edit_apply'])){ + /* Group has been saved successfully, remove lock from LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + + /* There's no page reload so we have to read new groups at this point. */ + //$this->reload (); + unset ($this->grouptab); + $this->grouptab= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /******************** + Edit existing group + ********************/ + + /* User wants to edit data? */ + if (($s_action=="edit") && (!isset($this->grouptab-> config))){ + + /* Get 'dn' from posted 'uid', must be unique */ + $this->dn= $this->grouplist[trim($s_entry)]['dn']; + + /* Check locking & lock entry if required */ + $user = get_lock($this->dn); + if ($user != ""){ + return(gen_locked_message ($user, $this->dn)); + } + add_lock ($this->dn, $this->ui->dn); + + /* Register grouptab to trigger edit dialog */ + $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn); + $this->grouptab->set_acl_base($this->dn); + $_SESSION['objectinfo']= $this->dn; + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->grouplist[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $smarty->assign("info", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); + } else { + $smarty->assign("info", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); + } + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Groups should be deleted. */ + if (isset($_POST['delete_multiple_groups_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl = $this->ui->get_permissions($dn,"groups/group"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn); + $this->grouptab->set_acl_base($dn); + $this->grouptab->delete (); + unset ($this->grouptab); + $this->grouptab= NULL; + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this group!")); + new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_user_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete group + ********************/ + + /* Remove group was requested */ + if ($s_action=="del"){ + + /* Get 'dn' from posted 'uid' */ + $this->dn= $this->grouplist[trim($s_entry)]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl = $this->ui->get_permissions($this->dn,"groups/group"); + if(preg_match("/d/",$acl)){ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the group '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + + } else { + + /* Obviously the user isn't allowed to delete. Show message and clean session. */ + print_red (_("You are not allowed to delete this group!")); + } + } + + + /******************** + Delete group confirmed + ********************/ + + /* Confirmation for deletion has been passed. Group should be deleted. */ + if (isset($_POST['delete_group_confirm'])){ + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + $acl = $this->ui->get_permissions($this->dn,"groups/group"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn); + $this->grouptab->set_acl_base($this->dn); + $this->grouptab->delete (); + unset ($this->grouptab); + $this->grouptab= NULL; + + /* Group list has changed, reload it. */ + //$this->reload (); + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this group!")); + new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + + /******************** + Delete group canceled + ********************/ + + /* Delete group canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + + /******************** + A dialog was canceled + ********************/ + + /* Cancel dialogs */ + if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ + if(isset($this->grouptab->dn)){ + del_lock ($this->grouptab->dn); + } + unset ($this->grouptab); + $this->grouptab= NULL; + unset($_SESSION['objectinfo']); + } + + + /******************** + If there is currently a dialog open, display it + ********************/ + + /* Show tab dialog if object is present */ + if (isset($this->grouptab->config)){ + $display= $this->grouptab->execute(); + + /* Don't show buttons if tab dialog requests this */ + if(isset($this->grouptab->by_object)){ + if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + } + return ($display); + } + + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListGroup->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Display dialog with group list */ + $this->DivListGroup->parent = $this; + $this->DivListGroup->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListGroup->SubSearch){ + $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4,1); + } + $this->reload (); + $this->DivListGroup->setEntries($this->grouplist); + return($this->DivListGroup->Draw()); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array(get_groups_ou().$this->DivListGroup->selectedBase)); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + function reload($CreatePosixsList=false) + { + $this->grouplist = array(); + $primaries = array(); + $functional = array(); + $error= $error2 = ""; + $filter = "(objectclass=posixGroup)"; + + $base = $this->DivListGroup->selectedBase; + $Regex = $this->DivListGroup->Regex; + $UserRegex = $this->DivListGroup->UserRegex; + $SubSearch = $this->DivListGroup->SubSearch; + $ShowPrimaryGroups = $this->DivListGroup->ShowPrimaryGroups; + $ShowSambaGroups = $this->DivListGroup->ShowSambaGroups; + $ShowApplicationGroups = $this->DivListGroup->ShowApplicationGroups; + $ShowMailGroups = $this->DivListGroup->ShowMailGroups; + $ShowFunctionalGroups = $this->DivListGroup->ShowFunctionalGroups; + + /* Prepare ldap class */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($base); + $ldap->set_size_limit($_SESSION['size_limit']); + + + /******************** + Create filter depending on selected checkboxes + ********************/ + + /* Add application groups */ + if ($ShowApplicationGroups){ + $filter.= "(objectClass=gosaApplicationGroup)"; + } + + /* Add Mail Groups */ + if ($ShowMailGroups){ + $filter.= "(objectClass=gosaMailAccount)"; + } + + $sfilter= ""; + if ($this->config->current['SAMBAVERSION'] == 3){ + if (!$ShowPrimaryGroups){ + $sfilter= "(objectClass=sambaGroupMapping)"; + } elseif ($ShowSambaGroups){ + $filter.= "(objectClass=sambaGroupMapping)"; + } + } + + /* Prepare filter for given Regex && UserRegex */ + if ($filter != ""){ + $filter= "(&(cn=$Regex)(objectClass=posixGroup)(|$filter))"; + if ($UserRegex != ""){ + $filter= "(&(|(memberUID=".$UserRegex.")(cn=".$UserRegex."))$filter)"; + } + } + + + /******************** + Collect some groupids to be able to skip primary & functional groups + ********************/ + + /* Collect primary groupIDs to show primary groups + if this option is enabled in gosa conf && the checkbox is checked */ + if ($this->ShowPrimaryCheckBox){ + $res = get_list("(&(uid=$Regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))", + "groups", $base,array("gidNumber", "cn"), GL_SUBSEARCH); + foreach ($res as $attrs){ + $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0]; + } + } + + /* Collect all GroupIDs from those groups which are functional. + Only perfrom this search if ShowFunctionalGroups is unchecked, else leave arre empty */ + $ff = "(&(cn=$Regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))"; + if ($SubSearch){ + $res = get_list($ff, "groups", $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH); + } else { + $res = get_list($ff, "groups", $base,array("gidNumber", "cn", "description"), GL_NONE); + } + foreach($res as $attrs){ + if (!isset($primaries[$attrs['gidNumber'][0]])){ + $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0]; + } + } + + + /******************** + Search for the prepared filter + ********************/ + + /* Attributes to search for */ + $attrs = array("cn", "description", "gidNumber", "objectClass"); + + /* If subsearch is activated search for subobjects too */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + $attrs [] = "FAIrelease"; + } + + if ($SubSearch){ + $res= get_list($filter, "groups", $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH); + } else { + $res= get_list($filter, "groups", get_groups_ou().$base, $attrs, GL_SIZELIMIT); + } + + /* Sort values into grouplist*/ + $tmp = $tmp2 = array(); + foreach ($res as $value){ + /* Skip functional groups if checkbox isn't checked */ + if (!$ShowFunctionalGroups && isset($functional[$value['gidNumber'][0]])){ + continue; + } + + /* If gidNumber is in $primaries skip this entry */ + if (($ShowPrimaryGroups) || (!$ShowPrimaryGroups && !isset($primaries[$value['gidNumber'][0]]))){ + $tmp2[$value['cn'][0]] = $value; + $tmp [$value['cn'][0]] = $value['cn'][0]; + } + } + natcasesort($tmp); + foreach($tmp as $name){ + $this->grouplist[] = $tmp2[$name]; + } + reset ($this->grouplist); + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->grouplist[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups"); + } + + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->grouplist[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","grouptabs","GROUPTABS","groups"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","grouptabs","GROUPTABS","groups"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + /* Save data to object */ + function save_object() + { + $this->DivListGroup->save_object(); + } + + + function remove_lock() + { + if (isset($this->grouptab->dn)){ + del_lock ($this->grouptab->dn); + } + } + + + function remove_from_parent() + { + /* Optionally execute a command after we're done */ + $this->postremove(); + } + + + /* Save to LDAP */ + function save() + { + /* Optionally execute a command after we're done */ + $this->postcreate(); + } + + /* Unused functions */ + function check() { } + function adapt_from_template($dn) { } + function password_change_needed() { } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/groups/generic.tpl b/gosa-core/plugins/admin/groups/generic.tpl new file mode 100644 index 000000000..4d67c8665 --- /dev/null +++ b/gosa-core/plugins/admin/groups/generic.tpl @@ -0,0 +1,155 @@ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + {if $samba3 ne ""} + + + + {/if} + {if $pickupGroup == "true"} + + + + + + + + + + {/if} + {if $nagios == "true"} + + + + + + + + + + {/if} +
{$must} +{render acl=$cnACL} + +{/render} +
+ + +{render acl=$descriptionACL} + +{/render} +
+
+
+ {$must} + +{render acl=$baseACL} + +{/render} + +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+{render acl=$gidNumberACL} + +{/render} + +   +{render acl=$gidNumberACL} + +{/render} +
+{render acl=$sambaGroupTypeACL} + +{/render} +{render acl=$sambaGroupTypeACL} + +{/render} +   + +   +{render acl=$sambaDomainNameACL} + +{/render} +
+{render acl=$fonGroupACL} + {t}Members are in a phone pickup group{/t} +{/render} +
+{render acl=$nagiosGroupACL} + {t}Members are in a nagios group{/t} +{/render} +
+ +
+   + + + + + + +
+ +
+{render acl=$memberUidACL} + +{/render} +
+ +   + +
+
+ + + + + diff --git a/gosa-core/plugins/admin/groups/group_objects.tpl b/gosa-core/plugins/admin/groups/group_objects.tpl new file mode 100644 index 000000000..5fcdc73a2 --- /dev/null +++ b/gosa-core/plugins/admin/groups/group_objects.tpl @@ -0,0 +1,59 @@ + + + + + +
+
+

+ {$hint} +

+
+
+

+ + +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + +
+ {t}Search within subtree{/t}
+
+ + + + +
+ +   + +
+ +
+ {$apply} +
+
+ +

+ +   + +

+ diff --git a/gosa-core/plugins/admin/groups/mail.tpl b/gosa-core/plugins/admin/groups/mail.tpl new file mode 100644 index 000000000..e7eb7083a --- /dev/null +++ b/gosa-core/plugins/admin/groups/mail.tpl @@ -0,0 +1,170 @@ + + + + + + + + + +
+

{t}Generic{/t}

+ + + + + + + + + + + + + + + + + + {if $kolab} + + + + + {/if} +
{$must} +{render acl=$mailACL} + +{/render} +
+{render acl=$gosaMailServerACL} + +{/render} +
+
+ +
+
+{if $quotadefined eq "true"} + {$quotausage} +{else} + {t}not defined{/t} +{/if} +
{t}Quota size{/t} +{render acl=$gosaMailQuotaACL} + +{/render} + {t}MB{/t} +
+ {t}Folder type{/t} + + + + {if !$JS} + + {/if} +
+ +
+

{t}Alternative addresses{/t}

+ +{render acl=$gosaMailAlternateAddressACL} + +{/render} + +
+ +{render acl=$gosaMailAlternateAddressACL} + +{/render} + +{render acl=$gosaMailAlternateAddressACL} +   +{/render} + +{render acl=$gosaMailAlternateAddressACL} + +{/render} + +
+ +

 

+ + + + + + +
+

{t}IMAP shared folders{/t}

+ + + + + + + + + + + {$plusattributes} +
+{render acl=$aclACL} + +{/render} +
+{render acl=$aclACL} + +{/render} +
+ +
+

+ + {t}Forward messages to non group members{/t} +

+ +{render acl=$gosaMailForwardingAddressACL} + +{/render} + +
+ +{render acl=$gosaMailForwardingAddressACL} + +{/render} +{render acl=$gosaMailForwardingAddressACL} +   +{/render} +{render acl=$gosaMailForwardingAddressACL} +   +{/render} +{render acl=$gosaMailForwardingAddressACL} + +{/render} +
+ + + diff --git a/gosa-core/plugins/admin/groups/mail_admins.tpl b/gosa-core/plugins/admin/groups/mail_admins.tpl new file mode 100644 index 000000000..8c95cb0d0 --- /dev/null +++ b/gosa-core/plugins/admin/groups/mail_admins.tpl @@ -0,0 +1,40 @@ + + + + + + + + +
+ +
+ +
+ +
+
+ +
+
+ +
+ : + + + {if $javascript ne "true"} + + {/if} +
+ +

+ +   + +

diff --git a/gosa-core/plugins/admin/groups/mail_locals.tpl b/gosa-core/plugins/admin/groups/mail_locals.tpl new file mode 100644 index 000000000..09d734a9b --- /dev/null +++ b/gosa-core/plugins/admin/groups/mail_locals.tpl @@ -0,0 +1,69 @@ + + + + + +
+
+

+
+

+
+
+

+ +

+
+
+
+

+ [F] + {t}Filters{/t} +

+
+
+ + {$alphabet} +
+ + + + +
+   + +
+ + + + + +
+ + + +
+ + + + + +
+ + + +
+ {$apply} +
+
+ +

+ +   + +

diff --git a/gosa-core/plugins/admin/groups/main.inc b/gosa-core/plugins/admin/groups/main.inc new file mode 100644 index 000000000..3a1210163 --- /dev/null +++ b/gosa-core/plugins/admin/groups/main.inc @@ -0,0 +1,60 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('groupManagement'); + } +} else { + /* Create groupManagement object on demand */ + if (!isset($_SESSION['groupManagement']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['groupManagement']= new groupManagement ($config, $_SESSION['ui']); + } + $groupManagement= $_SESSION['groupManagement']; + $groupManagement->save_object(); + $output= $groupManagement->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/group.png'), + _("Group administration"), "\"\" ". + @LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/group.png'), _("Group administration")); + } + + $display.= $output; + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('groupManagement'); + } + + /* Show and save dialog */ + $_SESSION['groupManagement']= $groupManagement; +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/groups/paste_generic.tpl b/gosa-core/plugins/admin/groups/paste_generic.tpl new file mode 100644 index 000000000..26477def6 --- /dev/null +++ b/gosa-core/plugins/admin/groups/paste_generic.tpl @@ -0,0 +1,25 @@ +

{t}Group settings{/t}

+ + + + + + + + + +
+ {t}Group name{/t} + + +
+ + + + +
+ + diff --git a/gosa-core/plugins/admin/groups/paste_mail.tpl b/gosa-core/plugins/admin/groups/paste_mail.tpl new file mode 100644 index 000000000..e30ba9af0 --- /dev/null +++ b/gosa-core/plugins/admin/groups/paste_mail.tpl @@ -0,0 +1,56 @@ +

{t}Mail settings{/t}

+ + + + + + +
+ + + + + +
+ {$must} + + +
+
+ + + + + +
+ {t}Alternative addresses{/t} + +
+ +   + +
+ {t}Forward messages to non group members{/t} + +
+ +   +   + +
+
+
+ + + diff --git a/gosa-core/plugins/admin/groups/remove.tpl b/gosa-core/plugins/admin/groups/remove.tpl new file mode 100644 index 000000000..1c938342c --- /dev/null +++ b/gosa-core/plugins/admin/groups/remove.tpl @@ -0,0 +1,27 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}This may be a primary user group. Please double check if you really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ + {if $multiple} + +   + + {else} + +   + + {/if} + + +

+ diff --git a/gosa-core/plugins/admin/groups/tabs_group.inc b/gosa-core/plugins/admin/groups/tabs_group.inc new file mode 100644 index 000000000..094551de9 --- /dev/null +++ b/gosa-core/plugins/admin/groups/tabs_group.inc @@ -0,0 +1,101 @@ +addSpecialTabs(); + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + + /* Update reference, transfer variables */ + $baseobject= $this->by_object['group']; + foreach ($this->by_object as $name => $obj){ + /* Don't touch base object */ + if ($name != 'group'){ + $obj->parent= &$this; + $obj->cn= $baseobject->cn; + $this->by_object[$name]= $obj; + } + } + } + + function delete() + { + /* Put baseobjects 'cn' to mailobjects 'uid' */ + $baseobject= $this->by_object['group']; + if (isset($this->by_object['mailgroup'])){ + $this->by_object['mailgroup']->uid= $baseobject->cn; + } + tabs::delete(); + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['group']; + + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base; + + /* Put baseobjects 'cn' to mailobjects 'uid' */ + if (isset($this->by_object['mailgroup'])){ + $this->by_object['mailgroup']->uid= $baseobject->cn; + } + + + /* Update reference, transfer variables */ + foreach ($this->by_object as $name => $obj){ + /* Transfer attributes for mailgroup account */ + if ($name == 'mailgroup'){ + $this->by_object['mailgroup']->members= $baseobject->memberUid;; + } + } + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->update_acls($this->dn,$new_dn); + $baseobject->move($this->dn, $new_dn); + $this->by_object['group']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + $ret= tabs::save(); + + /* Fix tagging if needed */ + $baseobject->dn= $new_dn; + $baseobject->handle_object_tagging(); + + return $ret; + } + + function saveCopyDialog() + { + tabs::saveCopyDialog(); + + /* Update reference, transfer variables */ + $baseobject= $this->by_object['group']; + foreach ($this->by_object as $name => $obj){ + /* Don't touch base object */ + if ($name != 'group'){ + $obj->parent= &$this; + $obj->cn= $baseobject->cn; + $this->by_object[$name]= $obj; + } + } + } + +} + +?> diff --git a/gosa-core/plugins/admin/mimetypes/class_divListMimeTypes.inc b/gosa-core/plugins/admin/mimetypes/class_divListMimeTypes.inc new file mode 100755 index 000000000..1c8677f46 --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/class_divListMimeTypes.inc @@ -0,0 +1,343 @@ +selectedRelease = "ou=mime,".$_SESSION['CurrentMainBase']; + $this->parent = &$parent; + $this->ui = get_userinfo(); + $this->AvailableReleases= $this->parent->getReleases($this->selectedBase); + + /* Set list strings */ + $this->SetTitle (_("List of defined mime types")); + $this->SetSummary (_("List of defined mime types")); + $this->SetInformation (_("This menu allows you to add, edit and remove selected mime types. You may want to use the range selector on top of the mime type listbox, when working with a large number of mime types.")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->EnableAplhabet(true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* set Page header */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Mime type name")." / "._("Department"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); + + /* Add SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Display mime types matching"),"*" , true); + } + + + /* This function allows us to add a user defined filter part at position $position*/ + function AddUserBoxToFilter($position) + { + $str = ""; + if(($position == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){ + $smarty = get_smarty(); + $smarty->assign("selectedRelease",$this->selectedRelease); + $smarty->assign("branchimage","images/branch.png"); + $smarty->assign("releases",$this->AvailableReleases); + $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE,dirname(__FILE__))); + } + return($str); + } + + + /* Create list header, with create / copy & paste etc*/ + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments($this->module); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get acls */ + $ui = get_userinfo(); + $acl = $ui->get_permissions("cn=dummy,ou=mimetypes,".$this->selectedBase,"mimetypes/mimetype"); + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"mimetypes") ; + + + /* If this is true we add an additional seperator. Just look a few lines below */ + $add_sep = false; + + /* Get copy & paste icon */ + $Copy_Paste =""; + if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){ + $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon(); + $add_sep = true; + } + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* And at least add a department selection box */ + $listhead .= _("Base")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Mime type")."|mime_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + } + + + /* Some basic settings */ + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + + function setEntries($list) + { + /******************** + Variable init + ********************/ + + /* Create links */ + $linkopen = "%s"; + $editlink = "%s"; + $userimg = "User"; + $mimeimg = "A"; + $empty = ""; + + /* set Page header */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /******************** + Attach objects + ********************/ + + foreach($list as $key => $val){ + + $ui = get_userinfo(); + $acl = $ui->get_permissions($val['dn'],"mimetypes/mimetype"); + $acl_all = $ui->has_complete_category_acls($val['dn'],"mimetypes") ; + + /* Create action icons */ + $actions = ""; + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions .= $this->GetSnapShotActions($val['dn']); + } + + /* Get copy Paste icons */ + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions.= " "; + $actions.= " "; + } + + $actions.= ""; + + /* Add delete button */ + if(preg_match("/d/",$acl)){ + $actions.= ""; + }else{ + $actions.= " "; + } + + $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; + + if(!isset($val['description'][0])){ + $desc = ""; + }else{ + $desc = " - [ ".$val['description'][0]." ]"; + } + + /* Cutted objects should be displayed in light grey */ + $display = $val['cn'][0].$desc; + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => sprintf($mimeimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); + $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + $this->AddElement(array($field0,$field1,$field2,$field3)); + } + + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_objs = count($list); + + $num_obj_str = _("Number of listed mimetypes"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + } + + function Save() + { + MultiSelectWindow::Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + + /* check if returned selectedRelease is a valid release. + If it isn't set to a valid release */ + $this->AvailableReleases = $this->parent->getReleases($this->selectedBase); + if(!isset($this->AvailableReleases[$this->selectedRelease])){ + $this->selectedRelease =key($this->AvailableReleases); + } + $_SESSION['mimefilter']['release'] = $this->selectedRelease; + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/mimetypes/class_mimetypeGeneric.inc b/gosa-core/plugins/admin/mimetypes/class_mimetypeGeneric.inc new file mode 100644 index 000000000..38b695e98 --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/class_mimetypeGeneric.inc @@ -0,0 +1,755 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + var $objectclasses = array("top","gotoMimeType"); + var $attributes = array("cn","gotoMimeApplication","gotoMimeLeftClickAction","gotoMimeIcon", + "description","gotoMimeFilePattern","gotoMimeEmbeddedApplication", + "gotoMimeGroup"); + + /* Class vars */ + var $ui; + var $cn = ""; + var $gotoMimeLeftClickAction = "I"; + var $gotoMimeLeftClickAction_I = true; + var $gotoMimeLeftClickAction_E = false; + var $gotoMimeLeftClickAction_Q = false; + var $gotoMimeIcon = "*removed*"; + var $description = ""; + var $gotoMimeFilePattern = array(); + var $gotoMimeApplication = array(); + var $gotoMimeEmbeddedApplication = array(); + var $gotoMimeGroup = ""; + var $iconData = NULL; + var $base = ""; + var $ApplicationList = array(); + + + /* To prevent errors when using the 'apply' button, we use this variables + to manage array attributes */ + var $use_gotoMimeIcon = NULL; + var $use_gotoMimeFilePattern = array(); + var $use_gotoMimeApplication = array(); + var $use_gotoMimeEmbeddedApplication = array(); + + /* divLists */ + var $DivPatterns = NULL; + var $DivApps = NULL; + var $DivEApps = NULL; + + /* Mime type release mode */ + var $isReleaseMimeType = false; + + /* These vars will be copied too, if you use copy&paste mode */ + var $CopyPasteVars = array("use_gotoMimeFilePattern","use_gotoMimeApplication","use_gotoMimeEmbeddedApplication","iconData", + "gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q","use_gotoMimeIcon"); + + var $view_logged = FALSE; + + /* Select options */ + var $MimeGroups = array("application","audio","chemical","image","inode","message","model", + "multipart","text","video","x-conference","x-world"); + + /* Orig_Dn is used to verify if this object is new or only edited */ + var $orig_dn = ""; + + function mimetype(&$config,$dn= NULL) + { + plugin::plugin ($config, $dn); + + /* Save original dn */ + $this->orig_dn = $dn; + + /* get gotoMimeLeftClickActions I/E/Q */ + if(isset($this->gotoMimeLeftClickAction)){ + $str = $this->gotoMimeLeftClickAction; + for($i = 0 ; $i < strlen($str) ; $i ++ ){ + $varna = "gotoMimeLeftClickAction_". $str[$i]; + if(isset($this->$varna)){ + $this->$varna = true; + } + } + } + + /* Create list of defined applications in GOsa */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaApplication)(cn=*))",array('cn')); + $this->ApplicationList = array(); + while($attrs = $ldap->fetch()){ + $this->ApplicationList[$attrs['cn'][0]] = $attrs['cn'][0]; + } + + /* If both radio buttons arn't set, set option I */ + if(!$this->gotoMimeLeftClickAction_I && !$this->gotoMimeLeftClickAction_E){ + $this->gotoMimeLeftClickAction_I = true; + } + + /* Get list of array attributes */ + foreach(array("gotoMimeFilePattern") as $attr){ + $this->$attr = array(); + if(isset($this->attrs[$attr])){ + $tmp = array(); + for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){ + $str = $this->attrs[$attr][$i]; + $tmp[] = $str; + } + $use_attr = "use_".$attr; + $this->$use_attr = $tmp; + } + } + + /* Get list of array attributes with priority tag ( Test|32 )*/ + foreach(array("gotoMimeApplication","gotoMimeEmbeddedApplication") as $attr){ + $this->$attr = array(); + if(isset($this->attrs[$attr])){ + $tmp = array(); + for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){ + $str = $this->attrs[$attr][$i]; + $tmp2= split("\|",$str); + + if(count($tmp2) == 2){ + $name = $tmp2[0]; + $prio = $tmp2[1]; + $tmp[$prio] = $name; + } + } + ksort($tmp); + $use_attr = "use_".$attr; + $this->$use_attr = $tmp; + } + } + + /* Check if release Management is enabled */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)) { + $this->isReleaseMimeType= true; + } + + /* Set base */ + if ($this->dn == "new"){ + if(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['CurrentMainBase']; + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn); + } + + /* Get icon data */ + if(isset($this->attrs['gotoMimeIcon'])){ + $ldap = $this->config->get_ldap_link(); + $this->iconData = $ldap->get_attribute($this->dn,"gotoMimeIcon"); + $this->saved_attributes['gotoMimeIcon'] = $this->iconData; + } + if ($this->iconData == ""){ + $this->set_new_picture(""); + } + $_SESSION['binary'] = $this->iconData; + $_SESSION['binarytype'] = "image/jpeg"; + } + + + function execute() + { + $smarty = get_smarty(); + + if(!$this->view_logged){ + $this->view_logged =TRUE; + new log("view","mimetypes/".get_class($this),$this->dn); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Check Posts */ + $posts = array( + "/^Pattern_SortUp_/" => array("Action" => "Pattern_SortUp", "Func" => "ArrayUp", "Attr" => "use_gotoMimeFilePattern"), + "/^Pattern_SortDown_/" => array("Action" => "Pattern_SortDown","Func" => "ArrayDown", "Attr" => "use_gotoMimeFilePattern"), + "/^Pattern_Remove_/" => array("Action" => "Pattern_Remove", "Func" => "ArrayRemove","Attr" => "use_gotoMimeFilePattern"), + "/^Apps_SortUp_/" => array("Action" => "Apps_SortUp", "Func" => "ArrayUp", "Attr" => "use_gotoMimeApplication"), + "/^Apps_SortDown_/" => array("Action" => "Apps_SortDown", "Func" => "ArrayDown", "Attr" => "use_gotoMimeApplication"), + "/^Apps_Remove_/" => array("Action" => "Apps_Remove", "Func" => "ArrayRemove","Attr" => "use_gotoMimeApplication"), + "/^EApps_SortUp_/" => array("Action" => "EApps_SortUp", "Func" => "ArrayUp", "Attr" => "use_gotoMimeEmbeddedApplication"), + "/^EApps_SortDown_/" => array("Action" => "EApps_SortDown", "Func" => "ArrayDown", "Attr" => "use_gotoMimeEmbeddedApplication"), + "/^EApps_Remove_/" => array("Action" => "EApps_Remove", "Func" => "ArrayRemove","Attr" => "use_gotoMimeEmbeddedApplication")); + $once = true; + + /* Walk through posts and try to find some commands for us. */ + foreach($_POST as $name => $value){ + + /* Walk through possible commands */ + foreach($posts as $regex => $action){ + + /* Check if there is a command posted */ + if(preg_match($regex,$name) && $once){ + $once = false; + + /* Get action vars */ + $func = $action['Func']; // Get function name + $attr = $action['Attr']; // Get attribute name + + /* Get entry id */ + $s_entry = preg_replace($regex,"",$name); + $s_entry = preg_replace("/_[xy]$/","",$s_entry); + + /* Execute a command with the given attribute and entry + e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */ + if($this->acl_is_writeable($attr)){ + $this->$attr= $this->$func($s_entry,$this->$attr,true); + } + } + } + } + + /* Set a new icon was requested */ + if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){ + $this->set_new_picture($_FILES['picture_file']['tmp_name']); + } + + /* Add gotoMimeFilePattern */ + if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){ + if($this->acl_is_writeable("gotoMimeFilePattern")){ + $str = $_POST['NewFilePattern']; + if(!empty($str)){ + $this->use_gotoMimeFilePattern[] = $str; + } + } + } + + /* Add gotoMimeFilePattern */ + if(isset($_POST['AddNewApplication']) && + (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){ + if($this->acl_is_writeable("gotoMimeApplication")){ + $str = ""; + if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){ + $str = get_post("NewApplicationSelect"); + } + if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){ + $str = get_post("NewApplication"); + } + if(!empty($str) && !in_array($str,$this->use_gotoMimeApplication)){ + $this->use_gotoMimeApplication[] = $str; + } + } + } + + /* Add embedded application + * - From input or from select box + */ + if(isset($_POST['AddNewEmbeddedApplication']) && + (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){ + if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ + $str = ""; + if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){ + $str = get_post('NewEmbeddedApplicationSelect'); + } + if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){ + $str = get_post('NewEmbeddedApplication'); + } + if(!empty($str) && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){ + $this->use_gotoMimeEmbeddedApplication[] = $str; + } + } + } + + /* Create divlists */ + $DivPatterns = new divSelectBox("gotoMimePatterns"); + $DivApps = new divSelectBox("gotoMimeApplications"); + $DivEApps = new divSelectBox("gotoMimeEmbeddedApplications"); + $DivPatterns -> SetHeight(100); + $DivApps -> SetHeight(100); + $DivEApps -> SetHeight(100); + + + if($this->acl_is_writeable("gotoMimeFilePattern")){ + $Pattern_Actions= "   +   + "; + }else{ + $Pattern_Actions= ""; + } + + if($this->acl_is_writeable("gotoMimeApplication")){ + $Apps_Actions = "   +   + "; + }else{ + $Apps_Actions= ""; + } + + if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ + $EApps_Actions = "   +   + "; + }else{ + $EApps_Actions= ""; + } + + /* Before adding some entries check acls */ + if($this->acl_is_readable("gotoMimeFilePattern")){ + foreach($this->use_gotoMimeFilePattern as $key => $pattern){ + $field1 = array("string" => $pattern); + $field2 = array("string" => preg_replace("/%s/",$key,$Pattern_Actions),"attach"=>"style='border-right:0px;width:50px;'"); + $fields = array($field1,$field2); + $DivPatterns -> AddEntry($fields); + } + } + + if($this->acl_is_readable("gotoMimeApplication")){ + foreach($this->use_gotoMimeApplication as $key => $pattern){ + $field1 = array("string" => $pattern); + $field2 = array("string" => preg_replace("/%s/",$key,$Apps_Actions),"attach"=>"style='border-right:0px;width:50px;'"); + $fields = array($field1,$field2); + $DivApps -> AddEntry($fields); + } + } + if($this->acl_is_readable("gotoMimeEmbeddedApplication")){ + foreach($this->use_gotoMimeEmbeddedApplication as $key => $pattern){ + $field1 = array("string" => $pattern); + $field2 = array("string" => preg_replace("/%s/",$key,$EApps_Actions),"attach"=>"style='border-right:0px;width:50px;'"); + $fields = array($field1,$field2); + $DivEApps -> AddEntry($fields); + } + } + $smarty->assign("bases", $this->get_allowed_bases()); + $smarty->assign("base_select", $this->base); + $smarty->assign("isReleaseMimeType", $this->isReleaseMimeType); + $smarty->assign("gotoMimeFilePatterns", $DivPatterns->DrawList()); + $smarty->assign("gotoMimeApplications", $DivApps->DrawList()); + $smarty->assign("gotoMimeEmbeddedApplications", $DivEApps->DrawList()); + + $smarty->assign("ApplicationList",$this->ApplicationList); + + /* Assign class vars to smarty */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign additional vars that are not included in attributes*/ + foreach(array("gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q") as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign select box options */ + $smarty->assign("gotoMimeGroups",$this->MimeGroups); + $smarty->assign("gotoMimeIcon" ,$this->get_picture()); + return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); + } + + + function save_object() + { + if(isset($_POST['MimeGeneric'])){ + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + /* Only save base if we are not in release mode */ + if(!$this->isReleaseMimeType){ + + /* Set new base if allowed */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + + } + + /* Save radio buttons */ + if($this->acl_is_writeable("gotoMimeLeftClickAction")){ + if(isset($_POST['gotoMimeLeftClickAction_IE'])){ + $chr = $_POST['gotoMimeLeftClickAction_IE']; + if($chr == "E"){ + $this->gotoMimeLeftClickAction_E = true; + $this->gotoMimeLeftClickAction_I = false; + }else{ + $this->gotoMimeLeftClickAction_E = false; + $this->gotoMimeLeftClickAction_I = true; + } + } + if(isset($_POST['gotoMimeLeftClickAction_Q'])){ + $this->gotoMimeLeftClickAction_Q = true; + }else{ + $this->gotoMimeLeftClickAction_Q = false; + } + } + } + } + + + /* save current changes */ + function save() + { + /* Create gotoMimeLeftClickAction out of checkboxes and radio buttons */ + $arr = array ("E","I","Q"); + $str = ""; + foreach ($arr as $Chr){ + $var = "gotoMimeLeftClickAction_".$Chr; + if($this->$var){ + $str .= $Chr; + } + } + $this->gotoMimeLeftClickAction = $str; + + /* Create array entries with priority tag ( Test|3 )*/ + foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication") as $attr){ + $i = 0; + $use_attr = "use_".$attr; + $tmp = array(); + $this->$attr = array(); + foreach($this->$use_attr as $entry){ + $tmp[] = $entry."|".$i ++; + } + $this->$attr = $tmp; + } + + /* Create array entries */ + foreach(array("gotoMimeFilePattern") as $attr){ + $i = 0; + $use_attr = "use_".$attr; + $tmp = array(); + $this->$attr = array(); + foreach($this->$use_attr as $entry){ + $tmp[] = $entry; + } + $this->$attr = $tmp; + } + + /* Remove Icon if requested */ + if($this->use_gotoMimeIcon != "*removed*"){ + $this->gotoMimeIcon = $this->iconData; + }else{ + $this->gotoMimeIcon = ""; + } + + plugin::save(); + + /* If this is a newly created object, skip storing those + attributes that contain an empty array */ + if($this->orig_dn == "new"){ + foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern") as $attr){ + if(!count($this->$attr)){ + unset($this->attrs[$attr]); + } + } + } + + $ldap = $this->config->get_ldap_link(); + $ldap-> cd ( $this->config->current['BASE']); + $ldap->cat($this->dn); + if($ldap->count()){ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify($this->attrs); + new log("modify","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of mime type/generic with dn '%s' failed."),$this->dn)); + } + + + /* Remove current mime type */ + function remove_from_parent() + { + plugin::remove_from_parent(); + $ldap = $this->config->get_ldap_link(); + $ldap->rmDir($this->dn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of mime type/generic with dn '%s' failed."),$this->dn)); + new log("remove","mimetypes/".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"); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + show_ldap_error($ldap->get_error(), sprintf(_("Removing mime type from objectgroup '%s' failed"), $og->dn)); + } + } + + + /* Check given values */ + function check() + { + $message = plugin::check(); + if(empty($this->cn)){ + $message[] = _("Please specify a valid name for this mime type."); + } + if(!count($this->use_gotoMimeFilePattern)){ + $message[] = _("Please specify at least one file pattern.") ; + } + + /* Check if there is already a mime type with this cn */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current["BASE"]); + if($this->isReleaseMimeType && (isset($_SESSION['mimefilter']['release']))){ + $baseDn = str_replace($this->config->current['BASE'],$this->base,$_SESSION['mimefilter']['release']); + $baseDn = preg_replace("/ou=mime,.*/","ou=mime,".$this->base,$_SESSION['mimefilter']['release']); + $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$baseDn,array("cn")); + if($ldap->count()){ + $attrs = $ldap->fetch(); + if($this->dn != $attrs['dn']) { + $message[]= _("There's already a mime type with this 'Name'."); + } + } + }else{ + $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))","ou=mime,".$this->base,array("cn")); + if ($ldap->count()){ + $attrs = $ldap->fetch(); + if($this->dn != $attrs['dn']) { + $message[]= _("There's already an mime with this 'Name'."); + } + } + } + + return($message); + } + + /** Helper functions **/ + + /* Set a new picture */ + function set_new_picture($filename) + { + if (empty($filename)){ + $filename= "./images/default_icon.png"; + $this->use_gotoMimeIcon= "*removed*"; + }else{ + $this->use_gotoMimeIcon= $filename; + } + + if (file_exists($filename)){ + $fd = fopen ($filename, "rb"); + $this->iconData= fread ($fd, filesize ($filename)); + $_SESSION['binary']= $this->iconData; + $_SESSION['binarytype']= "image/jpeg"; + fclose ($fd); + } + } + + /* Get picture link */ + function get_picture() + { + $_SESSION['binary']= $this->iconData; + $_SESSION['binarytype']= "image/jpeg"; + return("getbin.php"); + } + + /* Transports the given Arraykey one position up*/ + function ArrayUp($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == 1))){ + $before = array_slice($attrs,0,($pos-2)); + $mitte = array_reverse(array_slice($attrs,($pos-2),2)); + $unten = array_slice($attrs,$pos); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* Transports the given Arraykey one position down*/ + function ArrayDown($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == $cn))){ + $before = array_slice($attrs,0,($pos-1)); + $mitte = array_reverse(array_slice($attrs,($pos-1),2)); + $unten = array_slice($attrs,($pos+1)); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* return the position of the element in the array */ + function getpos($atr,$attrs) + { + $i = 0; + foreach($attrs as $attr => $name) { + $i++; + if($attr == $atr){ + return($i); + } + } + return(-1); + } + + + /* Remove this element from array */ + function ArrayRemove($key,$array,$reorder = false) + { + if(isset($array[$key])){ + unset($array[$key]); + if($reorder){ + $tmp = array(); + foreach($array as $entry){ + $tmp[] = $entry; + } + $array = $tmp; + } + } + return($array); + } + + + /* Combine new array */ + function combineArrays($ar0,$ar1,$ar2) + { + $ret = array(); + if(is_array($ar0)) + foreach($ar0 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar1)) + foreach($ar1 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar2)) + foreach($ar2 as $ar => $a){ + $ret[]=$a; + } + return($ret); + } + + + /* Return a dialog with all fields that must be changed, + if we want to copy this entry */ + function getCopyDialog() + { + $str = ""; + + $smarty = get_smarty(); + $smarty->assign("cn", $this->cn); + $smarty->assign("description", $this->description); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + /* Save all */ + function saveCopyDialog() + { + $attrs = array("cn","description"); + foreach($attrs as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Mime type generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("mimetypes" => array("description" => _("Mime types"), + "objectClass" => "gotoMimeType")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "gotoMimeGroup" => _("Mime group"), + "description" => _("Description"), + "base" => _("Base"), + "gotoMimeApplication" => _("Application"), + "gotoMimeLeftClickAction" => _("Left click action"), + "gotoMimeIcon" => _("Icon"), + "gotoMimeFilePattern" => _("File patterns"), + "gotoMimeEmbeddedApplication" => _("Embedded applications")) + )); + + } + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $source_o = new mimetype($this->config,$source['dn'],$this->parent); + + foreach(array("gotoMimeLeftClickAction_Q","gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern","gotoMimeIcon","iconData") as $name){ + $use_attr = "use_".$name; + if(isset($this->$use_attr)){ + $this->$use_attr= $source_o->$use_attr; + } + $this->$name = $source_o->$name; + } + foreach($this->attributes as $name){ + $this->$name = $source_o->$name; + } + + if($this->iconData){ + $this->use_gotoMimeIcon ="Not emtpy, causes icon to be written."; + } + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc b/gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc new file mode 100755 index 000000000..5cd9c15b3 --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc @@ -0,0 +1,664 @@ +config = &$config; + $this->ui = &$ui; + + /* Check if copy & paste is activated */ + if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + + /* Creat dialog object */ + $this->DivListMimeTypes = new divListMimeTypes($this->config,$this); + + if($this->IsReleaseManagementActivated()){ + + /* Check if we should enable the release selection */ + $this->enableReleaseManagement = true; + + /* Hide SubSearch checkbox */ + $this->DivListMimeTypes->DisableCheckBox("SubSearch"); + } + + } + + + /* Get all releases */ + function getReleases($base) + { + $ldap = $this->config->get_ldap_link(); + $dn = "ou=mime,".$base; + $ret = array(); + $ret ["ou=mime,".$base] = "/"; + + $ldap->cd($dn); + $ldap->search("objectClass=organizationalUnit",array("ou")); + + while($attrs = $ldap->fetch()){ + $str = str_replace($dn,"",$attrs['dn']); + $tmp = array_reverse( split("ou=",$str)); + $str = ""; + foreach($tmp as $val){ + $val = trim(preg_replace("/,/","",$val)); + if(empty($val)) break; + $str .= "/".$val; + } + if(!empty($str)){ + $ret[$attrs['dn']]= preg_replace("/^\//","",$str); + } + } + asort($ret); + return($ret); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + + /**************** + Variable init + ****************/ + + /* These vars will be stored if you try to open a locked mime, + to be able to perform your last requests after showing a warning message */ + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^mime_edit_/","/^mime_del_/","/^item_selected/","/^remove_multiple_mimetypes/"); + + $smarty = get_smarty(); // Smarty instance + $s_action = ""; // Contains the action to proceed + $s_entry = ""; // The value for s_action + $base_back = ""; // The Link for Backbutton + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/mime_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/mime_".$s_action."_/i","",$key); + // Post for edit + }elseif(preg_match("/mime_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/mime_".$s_action."_/i","",$key); + // Post for new + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + // Post for new + }elseif(preg_match("/^mime_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/^remove_multiple_mimetypes/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^multiple_copy_mimetypes/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_mimetypes/",$key)){ + $s_action = "cut_multiple"; + } + } + + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + + $s_entry = preg_replace("/_.$/","",$s_entry); + + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "mime_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + /**************** + Copy & Paste handling + ****************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /**************** + Create a new mime type + ****************/ + + /* New mime type? */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->DivListMimeTypes->selectedBase,"mimetypes/mimetype"); + if (($s_action=="new") && preg_match("/c/",$acl)){ + + /* By default we set 'dn' to 'new', all relevant plugins will + react on this. */ + $this->dn= "new"; + + /* Create new usertab object */ + $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); + $this->mimetabs->set_acl_base($this->DivListMimeTypes->selectedBase); + } + + + /**************** + Edit entry canceled + ****************/ + + /* Cancel dialogs */ + if (isset($_POST['edit_cancel'])){ + del_lock ($this->mimetabs->dn); + unset ($this->mimetabs); + $this->mimetabs= NULL; + unset ($_SESSION['objectinfo']); + } + + + /**************** + Edit entry finished + ****************/ + + /* Finish mime edit is triggered by the tabulator dialog, so + the user wants to save edited data. Check and save at this point. */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->mimetabs->config))){ + + /* Check tabs, will feed message array */ + $this->mimetabs->save_object(); + $message= $this->mimetabs->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + /* Save data data to ldap */ + $this->mimetabs->set_release($this->DivListMimeTypes->selectedRelease); + $this->mimetabs->save(); + + if (!isset($_POST['edit_apply'])){ + /* Mime type has been saved successfully, remove lock from LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + unset ($this->mimetabs); + $this->mimetabs= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /**************** + Edit entry + ****************/ + + /* User wants to edit data? */ + if (($s_action=="edit") && (!isset($this->mimetabs->config))){ + + /* Get 'dn' from posted 'mimelist', must be unique */ + $this->dn= $this->mimetypes[$s_entry]['dn']; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so everyone will get the + above dialog */ + add_lock ($this->dn, $this->ui->dn); + + + /* Register mimetabs to trigger edit dialog */ + $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); + $this->mimetabs->set_acl_base($this->dn); + $_SESSION['objectinfo']= $this->dn; + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + $this->dns = array(); + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->mimetypes[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $smarty->assign("intro", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); + } else { + $smarty->assign("intro", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); + } + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_mimetype_confirm'])){ + + $ui = get_userinfo(); + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $acl = $ui->get_permissions($dn,"mimetypes/mimetype"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $dn,"mimetypes"); + $this->mimetabs->set_acl_base($dn); + $this->mimetabs->delete (); + unset ($this->mimetabs); + $this->mimetabs= NULL; + + } else { + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this mime type!")); + new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_mimetype_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /**************** + Delete mime type + ****************/ + + /* Remove user was requested */ + if ($s_action == "del"){ + + /* Get 'dn' from posted 'uid' */ + $this->dn= $this->mimetypes[$s_entry]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->dn,"mimetypes/mimetype"); + if (preg_match("/d/",$acl)){ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return (gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty= get_smarty(); + $smarty->assign("intro", sprintf(_("You're about to delete the mime type '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); + return($smarty->fetch (get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the user isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this mime type!")); + } + } + + + /**************** + Delete mime confirmed + ****************/ + + /* Confirmation for deletion has been passed. Group should be deleted. */ + if (isset($_POST['delete_mime_confirm'])){ + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->dn,"mimetypes/mimetype"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); + $this->mimetabs->set_acl_base($this->dn); + $this->mimetabs->delete (); + unset ($this->mimetabs); + $this->mimetabs= NULL; + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this mime type!")); + new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + /**************** + Delete mime canceled + ****************/ + + /* Delete mime type canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + /* Show tab dialog if object is present */ + if (($this->mimetabs) && (isset($this->mimetabs->config))){ + $display= $this->mimetabs->execute(); + + /* Don't show buttons if tab dialog requests this */ + if (!$this->mimetabs->by_object[$this->mimetabs->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + return ($display); + } + + + /**************** + Dialog display + ****************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListMimeTypes->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Display dialog with system list */ + $this->DivListMimeTypes->parent = $this; + $this->DivListMimeTypes->execute(); + $this->DivListMimeTypes->AddDepartments($this->DivListMimeTypes->selectedBase,3,1); + $this->reload(); + $this->DivListMimeTypes->setEntries($this->mimetypes); + return($this->DivListMimeTypes->Draw()); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array($this->DivListMimeTypes->selectedRelease)); + } + + + + function reload() + { + $this->mimetypes= array(); + + /* Set base for all searches */ + $base = $this->DivListMimeTypes->selectedBase; + $release = $this->DivListMimeTypes->selectedRelease; + $Regex = $this->DivListMimeTypes->Regex; + $SubSearch = $this->DivListMimeTypes->SubSearch; + $Flags = GL_NONE | GL_SIZELIMIT; + $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=gotoMimeType))"; + $tmp = array(); + $Releases = $this->getReleases($base); + + + /* If release management is enabled, use release as base. */ + if(!$this->enableReleaseManagement){ + $use_base = $base; + }else{ + if(isset($Releases[$release])){ + $use_base = $release; + }else{ + $use_base = $base; + } + } + + /* In case of subsearch, add the subsearch flag */ + if($SubSearch){ + $Flags |= GL_SUBSEARCH; + }else{ + if(!$this->enableReleaseManagement){ + $use_base ="ou=mime,".$use_base; + } + } + + /* Get results and create index */ + $res= get_list($Filter, "mimetypes", $use_base, array("cn","description","dn","objectClass"), $Flags); + foreach ($res as $val){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; + } + + /* sort entries */ + ksort($tmp); + $this->mimetypes=array(); + foreach($tmp as $val){ + $this->mimetypes[]=$val; + } + reset ($this->mimetypes); + } + + function remove_from_parent() + { + /* Optionally execute a command after we're done */ + $this->postremove(); + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $this->start_pasting_copied_objects = FALSE; + $dn = $this->mimetypes[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"mimetabs","MIMETABS","mimetypes"); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $this->start_pasting_copied_objects = FALSE; + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->mimetypes[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","mimetabs","MIMETABS","mimetypes"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","mimetabs","MIMETABS","mimetypes"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListMimeTypes->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + #if(!$this->CopyPasteHandler->entries_queued()){ + # $this->start_pasting_copied_objects = FALSE; + #} + return(""); + } + + + /* Check if the release management is activated. */ + function IsReleaseManagementActivated() + { + /* Check if we should enable the release selection */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + return(true); + } + return(false); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + /* Save to LDAP */ + function save() + { + /* Optionally execute a command after we're done */ + $this->postcreate(); + } + + function remove_lock() + { + if (isset($this->mimetabs->dn)){ + del_lock ($this->mimetabs->dn); + } + } + + function save_object() { + $this->DivListMimeTypes->save_object(); + } + + function check() {} + function adapt_from_template($dn) {} + function password_change_needed() {} +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/mimetypes/generic.tpl b/gosa-core/plugins/admin/mimetypes/generic.tpl new file mode 100644 index 000000000..1cb6d7549 --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/generic.tpl @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

[M] {t}Generic{/t}

+
+ + + + + + + + + + + + + +{if !$isReleaseMimeType} + + + + + +{/if} +
+ {t}Mime type{/t}{$must} + +{render acl=$gotoMimeGroupACL} + +{/render} +
+ {t}Mime group{/t} + +{render acl=$gotoMimeGroupACL} + +{/render} +
+ {t}Description{/t} + +{render acl=$descriptionACL} + +{/render} +
+ {render acl=$baseACL} + + {/render} + {if !$isReleaseMimeType} + {render acl=$baseACL disable_picture='images/folder_gray.png'} + + {/render} + {/if} +
+ +
+ + + + + +
+
+ {t}Mime icon{/t} +
+  
+ +{render acl=$gotoMimeIconACL} + +{/render} +{render acl=$gotoMimeIconACL} + +{/render} +
+
+

 

+
+

{t}Left click{/t} {t}Left click{/t}

+
+ {t}File patterns{/t}{$must} +{render acl=$gotoMimeFilePatternACL} + {$gotoMimeFilePatterns} +{/render} + +{render acl=$gotoMimeFilePatternACL} + +{/render} +{render acl=$gotoMimeFilePatternACL} + +{/render} + + {t}Applications{/t} +{render acl=$gotoMimeApplicationACL} + {$gotoMimeApplications} +{/render} + +{render acl=$gotoMimeApplicationACL} + +{/render} +{render acl=$gotoMimeApplicationACL} + +{/render} +{render acl=$gotoMimeApplicationACL} + +{/render} +
+

 

+
+

{t}Embedding{/t} {t}Embedding{/t}

+
+ + + + + +
+{render acl=$gotoMimeLeftClickActionACL} + +{/render} + {t}Show file in embedded viewer{/t} +
+ +{render acl=$gotoMimeLeftClickActionACL} + +{/render} + {t}Show file in external viewer{/t} +
+ +{render acl=$gotoMimeLeftClickActionACL} + +{/render} + {t}Ask whether to save to local disk{/t} +
+ +
+ {t}Applications{/t} +{render acl=$gotoMimeEmbeddedApplicationACL} + {$gotoMimeEmbeddedApplications} +{/render} +{render acl=$gotoMimeEmbeddedApplicationACL} + +{/render} +{render acl=$gotoMimeEmbeddedApplicationACL} + +{/render} +{render acl=$gotoMimeEmbeddedApplicationACL} + +{/render} +
+ + + diff --git a/gosa-core/plugins/admin/mimetypes/main.inc b/gosa-core/plugins/admin/mimetypes/main.inc new file mode 100755 index 000000000..1595f185e --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/main.inc @@ -0,0 +1,57 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('MimeTypeManagement'); + } +} else { + + /* Create MimeTypeManagement object on demand */ + if (!isset($_SESSION['MimeTypeManagement']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['MimeTypeManagement']= new mimetypeManagement ($config, $_SESSION['ui']); + } + + /* Get object */ + $MimeTypeManagement= $_SESSION['MimeTypeManagement']; + $MimeTypeManagement->save_object(); + $output= $MimeTypeManagement->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management")); + } + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('MimeTypeManagement'); + } + + /* Show and save dialog */ + $display.= $output; + $_SESSION['MimeTypeManagement']= $MimeTypeManagement; +} +?> diff --git a/gosa-core/plugins/admin/mimetypes/paste_generic.tpl b/gosa-core/plugins/admin/mimetypes/paste_generic.tpl new file mode 100644 index 000000000..34b5e0751 --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/paste_generic.tpl @@ -0,0 +1,31 @@ + + + + + + + +
+

 {t}Generic{/t}

+
+ + + + + + + + + + +
+ {t}Mime type{/t} + + +
+ {t}Description{/t} + + +
+ +
diff --git a/gosa-core/plugins/admin/mimetypes/release_select.tpl b/gosa-core/plugins/admin/mimetypes/release_select.tpl new file mode 100755 index 000000000..d58738f05 --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/release_select.tpl @@ -0,0 +1,16 @@ +
+
+

[F]{t}Branches{/t}

+
+
+ + + + +
+ {t}Current release{/t}  + +
+
diff --git a/gosa-core/plugins/admin/mimetypes/remove.tpl b/gosa-core/plugins/admin/mimetypes/remove.tpl new file mode 100755 index 000000000..30c423318 --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/remove.tpl @@ -0,0 +1,23 @@ +
+  {t}Warning{/t} +
+

+ {$intro} + {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-core/plugins/admin/mimetypes/tabs_mimetypes.inc b/gosa-core/plugins/admin/mimetypes/tabs_mimetypes.inc new file mode 100755 index 000000000..6c1cd34c4 --- /dev/null +++ b/gosa-core/plugins/admin/mimetypes/tabs_mimetypes.inc @@ -0,0 +1,64 @@ +addSpecialTabs(); + } + + function set_release($newRelease) + { + $this->Release= preg_replace('/,ou=mime,.*$/', '', $newRelease); + if ($this->Release != ""){ + $this->Release= ",".$this->Release; + } + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['mimetype']; + + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + + if((!empty($tmp)) && (isset($_SESSION['mimefilter']['release']))){ + if(!$baseobject->isReleaseMimeType){ + $new_dn= "cn=".$baseobject->cn.",ou=mime,".$baseobject->base; + }else{ + $new_dn ="cn=".$baseobject->cn.",".$_SESSION['mimefilter']['release']; + } + }else{ + $new_dn= "cn=".$baseobject->cn.",ou=mime,".$baseobject->base; + } + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['mimetype']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + tabs::save(); + + /* Fix tagging if needed */ + $baseobject->dn= $this->dn; + $baseobject->handle_object_tagging(); + $this->by_object['mimetype'] = $baseobject; + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc b/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc new file mode 100755 index 000000000..c0e96a7c9 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc @@ -0,0 +1,331 @@ +AddCheckBox */ + var $UserGroups ; + var $GroupGroups ; + var $ApplicationGroups ; + var $DepartmentGroups ; + var $ServerGroups ; + var $WorkstationGroups ; + var $TerminalGroups ; + var $PrinterGroups ; + var $PhoneGroups ; + + + /* Subsearch checkbox */ + var $SubSearch ; + var $parent ; + var $ui ; + + function divListOGroup (&$config,$parent) + { + MultiSelectWindow::MultiSelectWindow($config, "OGroups", "ogroups"); + + $this->parent = $parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of object groups")); + $this->SetSummary(_("List of object groups")); + $this->EnableAplhabet(true); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to add, edit or remove selected groups. You may want to use the range selector on top of the group listbox, when working with a large number of groups.")); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Properties"), "attach" => "style='width:136px;'")); + $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); + + /* Text ,Value ,Name ,Is selected */ + $this->AddCheckBox("UserGroups" , _("Select to see groups containing users") , _("Show groups containing users"), true); + $this->AddCheckBox("GroupGroups" , _("Select to see groups containing groups") , _("Show groups containing groups"), true); + $this->AddCheckBox("ApplicationGroups", _("Select to see groups containing applications"), _("Show groups containing applications"), true); + $this->AddCheckBox("DepartmentGroups" , _("Select to see groups containing departments") , _("Show groups containing departments"), true); + $this->AddCheckBox("ServerGroups" , _("Select to see groups containing servers") , _("Show groups containing servers"), true); + $this->AddCheckBox("WorkstationGroups", _("Select to see groups containing workstations"), _("Show groups containing workstations"), true); + $this->AddCheckBox("TerminalGroups" , _("Select to see groups containing terminals") , _("Show groups containing terminals"), true); + $this->AddCheckBox("PrinterGroups" , _("Select to see groups containing printer") , _("Show groups containing printer"), true); + $this->AddCheckBox("PhoneGroups" , _("Select to see groups containing phones") , _("Show groups containing phones"), true); + + /* Add SubSearch checkbox */ + $this->AddCheckBox(SEPERATOR); + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true); + } + + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("ogroups"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Add a seperator after displaying c&p and snapshot icons ? */ + $add_sep = false; + + /* Get copy & paste icon */ + $acls = $ui->get_permissions($this->selectedBase,"ogroups/ogroup"); + $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups"); + $Copy_Paste =""; + if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){ + $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon(); + $add_sep = true; + } + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + + /* Add department selector */ + $listhead .= _("Base")." ". + "  "; + + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acls)) { + $s.= "...|". + " "._("Object group")."|group_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; +# $s.= "..|". +# " "._("Edit")."|"."multiple_edit|\n"; + + $s.= "..|". + " "._("Remove")."|"."remove_multiple_ogroups/|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + /* Add Copy & Paste buttons if copy&paste is enabled + */ + // Defining Links + $linkopen = "%s"; + $editlink = "%s"; + $userimg = "User"; + $mailimg = "M"; + $empty = ""; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 80; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + $ui = get_userinfo(); + + // Assigning ogroups + foreach($list as $key => $val){ + + /* Create action icons */ + $actions= ""; + $acl_all= $ui->has_complete_category_acls($val['dn'],"ogroups"); + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions.= " "; + $actions.= " "; + } + + $actions.= ""; + + if(preg_match("/(c.*w|w.*c)/", $acl_all)){ + $actions.= $this->GetSnapShotActions($val['dn']); + } + + if(preg_match("/d/",$ui->get_permissions($val['dn'],"ogroups/ogroup"))) { + $actions.= ""; + }else{ + $actions.= " "; + } + + + if(isset($val['mail'])){ + $mail = $mailimg; + }else{ + $mail = $empty; + } + $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; + if(!isset($val['description'][0])){ + $desc = ""; + }else{ + $desc = " - [ ".$val['description'][0]." ]"; + } + + /* Cutted objects should be displayed in light grey */ + $display = $val['cn'][0].$desc; + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => ""._("Object group")."", "attach" => "style='text-align:center;width: 20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); + $field3 = array("string" => preg_replace("/%KEY/", $key, $this->parent->convert_list($val))." ".$mail, "attach" => "style='width:136px;'"); + $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + + $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); + } + + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_objs = count($list); + + $num_obj_str = _("Number of listed object groups"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/class_mailogroup.inc b/gosa-core/plugins/admin/ogroups/class_mailogroup.inc new file mode 100644 index 000000000..ebf569729 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/class_mailogroup.inc @@ -0,0 +1,199 @@ +config= $config; + + /* Save initial account state */ + $this->initially_was_account= $this->is_account; + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","ogroups/".get_class($this),$this->dn); + } + + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Show tab dialog headers */ + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove mail account"), + _("This group has mail features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Create mail account"), _("This group has mail features disabled. You can enable them by clicking below.")); + return ($display); + } + } + + /* Initialize templating engine */ + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl("mail")); + } + + /* Assign mail attribute */ + $smarty->assign("mail", $this->mail); + + /* Show main page */ + return ($display.$smarty->fetch (get_template_path('mail.tpl', TRUE))); + } + + + /* Check formular input */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if ($this->is_account){ + $ldap= $this->config->get_ldap_link(); + + /* Check if mail address is valid */ + if (!is_email($this->mail) || $this->mail == ""){ + $message[]= _("Please enter a valid email address in 'Primary address' field."); + } + + /* Check if mail address is already in use */ + $ldap->cd($this->config->current['BASE']); + $ldap->search ("(&(!(objectClass=gosaUserTemplate))(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(cn=".$this->cn.")))", array("uid")); + if ($ldap->count() != 0){ + $message[]= _("The primary address you've entered is already in use."); + } + } + + return ($message); + } + + + function save() + { + $ldap= $this->config->get_ldap_link(); + + /* Call parents save to prepare $this->attrs */ + plugin::save(); + + /* Save data to LDAP */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + if($this->initially_was_account){ + new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/mail with dn '%s' failed."),$this->dn)); + + /* 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"); + } + } else { + $this->handle_post_events("add"); + } + } + + + /* remove object from parent */ + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/mail with dn '%s' failed."),$this->dn)); + } + + + function getCopyDialog() + { + $str = ""; + $smarty = get_smarty(); + $smarty->assign("mail", $this->mail); + $str = $smarty->fetch(get_template_path("paste_mail.tpl",TRUE,dirname(__FILE__))); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['mail'])){ + $this->mail = $_POST['mail']; + } + } + + + static function plInfo() + { + return (array( + "plShortName" => _("Mail"), + "plDescription" => _("Mail group"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 4, + "plSection" => array("administration"), + "plCategory" => array("ogroups"), + "plProvidedAcls"=> array( + "mail" => _("Mail address")) + )); + } + + + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/class_ogroup.inc b/gosa-core/plugins/admin/ogroups/class_ogroup.inc new file mode 100644 index 000000000..e74b3985a --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/class_ogroup.inc @@ -0,0 +1,765 @@ + $v2){ + return 1; + } + if ($v1 < $v2){ + return -1; + } + return 0; +} + + +class ogroup extends plugin +{ + /* Variables */ + var $cn= ""; + var $description= ""; + var $base= ""; + var $gosaGroupObjects= ""; + var $department= ""; + var $objects= array(); + var $objcache= array(); + var $memberList= array(); + var $member= array(); + var $orig_dn= ""; + var $group_dialog= FALSE; + var $view_logged = FALSE; + + /* attribute list for save action */ + var $attributes= array("cn", "description", "gosaGroupObjects","member"); + var $objectclasses= array("top", "gosaGroupOfNames"); + + function ogroup (&$config, $dn= NULL) + { + plugin::plugin ($config, $dn); + $this->orig_dn= $dn; + + $this->member = array(); + + /* Load member objects */ + if (isset($this->attrs['member'])){ + foreach ($this->attrs['member'] as $key => $value){ + if ("$key" != "count"){ + $value= @LDAP::convert($value); + $this->member["$value"]= "$value"; + } + } + } + $this->is_account= TRUE; + + /* Get global filter config */ + if (!is_global("ogfilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $ogfilter= array( "dselect" => $base, + "regex" => "*"); + register_global("ogfilter", $ogfilter); + } + $ogfilter= get_global('ogfilter'); + + /* Adjust flags */ + foreach( array( "U" => "accounts", + "G" => "groups", + "A" => "applications", + "D" => "departments", + "S" => "servers", + "W" => "workstations", + "T" => "terminals", + "F" => "phones", + "_" => "subtrees", + "P" => "printers") as $key => $val){ + + if (preg_match("/$key/", $this->gosaGroupObjects)){ + $ogfilter[$val]= "checked"; + } else { + $ogfilter[$val]= ""; + } + } + register_global("ogfilter", $ogfilter); + + if(isset($_SESSION['CurrentMainBase'])){ + $this->base = $_SESSION['CurrentMainBase']; + } + + /* Set base */ + if ($this->dn == "new"){ + $this->base= $_SESSION['CurrentMainBase']; + } else { + $this->base= preg_replace("/^[^,]+,".get_groups_ou()."/","",$this->dn); + } + + /* Load member data */ + $this->reload(); + } + + function AddDelMembership($NewMember = false){ + + if($NewMember){ + + /* Add member and force reload */ + $this->member[$NewMember]= $NewMember; + $this->reload(); + + $this->memberList[$NewMember]= $this->objcache[$NewMember]; + unset ($this->objects[$NewMember]); + uasort ($this->memberList, 'sort_list'); + reset ($this->memberList); + }else{ + /* Delete objects from group */ + if (isset($_POST['delete_membership']) && isset($_POST['members'])){ + foreach ($_POST['members'] as $value){ + $this->objects["$value"]= $this->memberList[$value]; + unset ($this->memberList["$value"]); + unset ($this->member["$value"]); + uasort ($this->objects, 'sort_list'); + reset ($this->objects); + } + $this->reload(); + } + + /* Add objects to group */ + if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){ + foreach ($_POST['objects'] as $value){ + $this->memberList["$value"]= $this->objects[$value]; + $this->member["$value"]= $value; + unset ($this->objects[$value]); + uasort ($this->memberList, 'sort_list'); + reset ($this->memberList); + } + $this->reload(); + } + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","ogroups/".get_class($this),$this->dn); + } + + + /* Do we represent a valid group? */ + if (!$this->is_account){ + $display= "\"\" ". + _("This 'dn' is no object group.").""; + return ($display); + } + + /* Delete objects from group */ + if (isset($_POST['delete_membership']) && isset($_POST['members'])){ + foreach ($_POST['members'] as $value){ + if(isset($this->memberList[$value])){ + $this->objects["$value"]= $this->memberList[$value]; + unset ($this->memberList["$value"]); + unset ($this->member["$value"]); + uasort ($this->objects, 'sort_list'); + reset ($this->objects); + } + } + $this->reload(); + } + + /* Add objects to group */ + if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){ + foreach ($_POST['objects'] as $value){ + if(isset($this->objects[$value])){ + $this->memberList["$value"]= $this->objects[$value]; + $this->member["$value"]= $value; + unset ($this->objects[$value]); + uasort ($this->memberList, 'sort_list'); + reset ($this->memberList); + } + } + $this->reload(); + } + + /* Load templating engine */ + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog) && $this->acl_is_moveable()){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Add objects? */ + if (isset($_POST["edit_membership"])){ + $this->group_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Add objects finished? */ + if (isset($_POST["add_object_finish"]) || isset($_POST["add_object_cancel"])){ + $this->group_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Manage object add dialog */ + if ($this->group_dialog){ + + /* Save data */ + $ogfilter= get_global("ogfilter"); + foreach( array("dselect", "regex") as $type){ + if (isset($_POST[$type])){ + $ogfilter[$type]= $_POST[$type]; + } + } + if (isset($_POST['dselect'])){ + foreach( array("accounts", "groups", "applications", "departments", + "servers", "workstations", "terminals", "printers","subtrees", + "phones") as $type){ + + if (isset($_POST[$type])) { + $ogfilter[$type]= "checked"; + } else { + $ogfilter[$type]= ""; + } + } + } + if (isset($_GET['search'])){ + $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; + if ($s == "**"){ + $s= "*"; + } + $ogfilter['regex']= $s; + } + register_global("ogfilter", $ogfilter); + $this->reload(); + + /* Calculate actual groups */ + $smarty->assign("objects", $this->convert_list($this->objects)); + + /* Show dialog */ + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("alphabet", generate_alphabet()); + foreach( array("dselect", "regex", "accounts", "groups", "applications", + "departments", "servers", "workstations", "terminals","subtrees", + "printers", "phones") as $type){ + $smarty->assign("$type", $ogfilter[$type]); + } + $smarty->assign("hint", print_sizelimit_warning()); + $smarty->assign("apply", apply_filter()); + + $display= $smarty->fetch (get_template_path('ogroup_objects.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + /* Bases / Departments */ + if ((isset($_POST['base'])) && ($this->acl_is_moveable())){ + $this->base= $_POST['base']; + } + + /* Assemble combine string */ + if ($this->gosaGroupObjects == "[]"){ + $smarty->assign("combinedObjects", _("none")); + } elseif (strlen($this->gosaGroupObjects) > 4){ + $smarty->assign("combinedObjects", ""._("too many different objects!").""); + } else { + $conv= array( "U" => _("users"), + "G" => _("groups"), + "A" => _("applications"), + "D" => _("departments"), + "S" => _("servers"), + "W" => _("workstations"), + "T" => _("terminals"), + "F" => _("phones"), + "P" => _("printers")); + + $type= preg_replace('/[\[\]]/', '', $this->gosaGroupObjects); + $p1= $conv[$type[0]]; + error_reporting(0); + if (isset($type[1]) && preg_match('/[UGADSFWTP]/', $type[1])){ + $p2= $conv[$type[1]]; + $smarty->assign("combinedObjects", "$p1 "._("and")." $p2"); + } else { + $smarty->assign("combinedObjects", "$p1"); + } + error_reporting(E_ALL | E_STRICT); + } + + /* Assign variables */ + $smarty->assign("bases", $this->get_allowed_bases()); + $smarty->assign("base_select", $this->base); + $smarty->assign("department", $this->department); + $smarty->assign("members", $this->convert_list($this->memberList)); + + /* Objects have to be tuned... */ + $smarty->assign("objects", $this->convert_list($this->objects)); + + /* Fields */ + foreach ($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + + return ($smarty->fetch (get_template_path('generic.tpl', TRUE))); + } + + + /* Save data to object */ + function save_object() + { + /* Save additional values for possible next step */ + if (isset($_POST['ogroupedit'])){ + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + /* Save base, since this is no LDAP attribute */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + } + } + + + /* (Re-)Load objects */ + function reload() + { + /*########### + Variable initialisation + ###########*/ + + $this->objects = array(); + $this->ui = get_userinfo(); + $filter = ""; + $objectClasses = array(); + + $ogfilter = get_global("ogfilter"); + $regex = $ogfilter['regex']; + + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($ogfilter['dselect']); + + + /*########### + Generate Filter + ###########*/ + + $p_f= array("accounts" => array("CLASS"=>"gosaAccount" ,"DN"=> get_people_ou() ,"ACL" => "users"), + "groups" => array("CLASS"=>"posixGroup" ,"DN"=> get_groups_ou() ,"ACL" => "groups"), + "applications" => array("CLASS"=>"gosaApplication","DN"=> "ou=apps," ,"ACL" => "application"), + "departments" => array("CLASS"=>"gosaDepartment" ,"DN"=> "" ,"ACL" => "department"), + "servers" => array("CLASS"=>"goServer" ,"DN"=> "ou=servers,ou=systems," ,"ACL" => "server"), + "workstations" => array("CLASS"=>"gotoWorkstation","DN"=> "ou=workstations,ou=systems," ,"ACL" => "workstation"), + "terminals" => array("CLASS"=>"gotoTerminal" ,"DN"=> "ou=terminals,ou=systems," ,"ACL" => "terminal"), + "printers" => array("CLASS"=>"gotoPrinter" ,"DN"=> "ou=printers,ou=systems," ,"ACL" => "printer"), + "phones" => array("CLASS"=>"goFonHardware" ,"DN"=> "ou=phones,ou=systems," ,"ACL" => "phone")); + + + /*########### + Perform search for selected objectClasses & regex to fill list with objects + ###########*/ + + $Get_list_flags = 0; + if($ogfilter['subtrees'] == "checked"){ + $Get_list_flags |= GL_SUBSEARCH; + } + + foreach($p_f as $post_name => $data){ + + if($ogfilter[$post_name] == "checked"){ + + if($ogfilter['subtrees']){ + $base = $ogfilter['dselect']; + }else{ + $base = $data['DN'].$ogfilter['dselect']; + } + + $filter = "(&(objectClass=".$data['CLASS'].")(|(uid=$regex)(cn=$regex)(ou=$regex)))"; + $res = get_list($filter, $data['ACL'] , $base, + array("description", "objectClass", "sn", "givenName", "uid","ou","cn"),$Get_list_flags); + + /* fetch results and append them to the list */ + foreach($res as $attrs){ + + $type= $this->getObjectType($attrs); + $name= $this->getObjectName($attrs); + + /* Fill array */ + if (isset($attrs["description"][0])){ + $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); + } elseif (isset($attrs["uid"][0])) { + $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type"); + } else { + $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); + } + } + } + } + uasort ($this->objects, 'sort_list'); + reset ($this->objects); + + + /*########### + Build member list and try to detect obsolete entries + ###########*/ + + $this->memberList = array(); + + /* Walk through all single member entry */ + foreach($this->member as $dn){ + + /* The dn for the current member can't be resolved + it seams that this entry was removed + */ + /* Try to resolv the entry again, if it still fails, display error msg */ + $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass")); + + /* It has failed, add entry with type flag I (Invalid)*/ + if ($ldap->error != "Success"){ + $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I"); + + } else { + + /* Append this entry to our all object list */ + + /* Fetch object */ + $attrs= $ldap->fetch(); + + $type= $this->getObjectType($attrs); + $name= $this->getObjectName($attrs); + + if (isset($attrs["description"][0])){ + $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); + } elseif (isset($attrs["uid"][0])) { + $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type"); + } else { + $this->objcache[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); + } + $this->objcache[$attrs["dn"]]['objectClass'] = $attrs['objectClass']; + if(isset($attrs['uid'])){ + $this->objcache[$attrs["dn"]]['uid'] = $attrs['uid']; + } + + /* Fill array */ + if (isset($attrs["description"][0])){ + $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); + } else { + $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); + } + + $this->memberList[$dn]= $this->objects[$attrs["dn"]]; + } + } + uasort ($this->memberList, 'sort_list'); + reset ($this->memberList); + + /* Assemble types of currently combined objects */ + $objectTypes= ""; + foreach ($this->memberList as $dn => $desc){ + + /* Invalid object? */ + if ($desc['type'] == 'I'){ + continue; + } + + /* Fine. Add to list. */ + if (!preg_match('/'.$desc['type'].'/', $objectTypes)){ + $objectTypes.= $desc['type']; + } + } + $this->gosaGroupObjects= "[$objectTypes]"; + } + + + function convert_list($input) + { + $temp= ""; + $conv= array( "U" => "select_user.png", + "G" => "select_groups.png", + "A" => "select_application.png", + "D" => "select_department.png", + "S" => "select_server.png", + "W" => "select_workstation.png", + "T" => "select_terminal.png", + "F" => "select_phone.png", + "I" => "flag.png", + "P" => "select_printer.png"); + + foreach ($input as $key => $value){ + /* Generate output */ + $temp.= "\n"; + } + + return ($temp); + } + + + function getObjectType($attrs) + { + $type= "I"; + + foreach(array( "U" => "gosaAccount", + "G" => "posixGroup", + "A" => "gosaApplication", + "D" => "gosaDepartment", + "S" => "goServer", + "W" => "gotoWorkstation", + "T" => "gotoTerminal", + "F" => "goFonHardware", + "P" => "gotoPrinter") as $index => $class){ + if (in_array($class, $attrs['objectClass'])){ + $type= $index; + break; + } + } + + return ($type); + } + + + function getObjectName($attrs) + { + /* Person? */ + $name =""; + if (in_array('gosaAccount', $attrs['objectClass'])){ + if(isset($attrs['sn']) && isset($attrs['givenName'])){ + $name= $attrs['sn'][0].", ".$attrs['givenName'][0]; + } else { + $name= $attrs['uid'][0]; + } + } else { + if(isset($attrs["cn"][0])) { + $name= $attrs['cn'][0]; + } else { + $name= $attrs['ou'][0]; + } + } + + return ($name); + } + + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Permissions for that base? */ + if ($this->base != ""){ + $new_dn= 'cn='.$this->cn.','.get_groups_ou().$this->base; + } else { + $new_dn= $this->dn; + } + + + $ldap = $this->config->get_ldap_link(); + if($this->dn != $new_dn){ + $ldap->cat ($new_dn, array('dn')); + } + + if($ldap->count() !=0){ + $message[]= _("There is already an object with this cn."); + } + + /* Set new acl base */ + if($this->dn == "new") { + $this->set_acl_base($this->base); + } + + /* must: cn */ + if ($this->cn == ""){ + $message[]= "The required field 'Name' is not set."; + } + + /* To many different object types? */ + if (strlen($this->gosaGroupObjects) > 4){ + $message[]= _("You can combine two different object types at maximum only!"); + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Move members to target array */ + $this->attrs['member'] =array(); + foreach ($this->member as $key => $desc){ + $this->attrs['member'][]= @LDAP::fix($key); + } + + $ldap= $this->config->get_ldap_link(); + + /* New accounts need proper 'dn', propagate it to remaining objects */ + if ($this->dn == 'new'){ + $this->dn= 'cn='.$this->cn.','.get_groups_ou().$this->base; + } + + /* Save data. Using 'modify' implies that the entry is already present, use 'add' for + new entries. So do a check first... */ + $ldap->cat ($this->dn, array('dn')); + if ($ldap->fetch()){ + /* Modify needs array() to remove values :-( */ + if (!count ($this->member)){ + $this->attrs['member']= array(); + } + $mode= "modify"; + + } else { + $mode= "add"; + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + } + + /* Write back to ldap */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->$mode($this->attrs); + + if($mode == "add"){ + new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + /* Trigger post signal */ + $this->handle_post_events($mode); + + $ret= 0; + if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/generic with dn '%s' failed."),$this->dn))){ + $ret= 1; + } + + return ($ret); + } + + function remove_from_parent() + { + plugin::remove_from_parent(); + + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir($this->dn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/generic with dn '%s' failed."),$this->dn)); + + new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + /* Trigger remove signal */ + $this->handle_post_events("remove"); + } + + + function PrepareForCopyPaste($source) + { + /* Update available object types */ + if(isset($source['gosaGroupObjects'][0])){ + $this->gosaGroupObjects = $source['gosaGroupObjects'][0]; + } + + /* Reload tabs */ + $this->parent->reload($this->gosaGroupObjects ); + + /* Reload plugins */ + foreach($this->parent->by_object as $name => $class ){ + if(get_class($this) != $name) { + $this->parent->by_object[$name]->PrepareForCopyPaste($source); + } + } + + /* Load member objects */ + if (isset($source['member'])){ + foreach ($source['member'] as $key => $value){ + if ("$key" != "count"){ + $value= @LDAP::convert($value); + $this->member["$value"]= "$value"; + } + } + } + + } + + + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("cn", $this->cn); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Object group generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("administration"), + "plCategory" => array("ogroups" => array("description" => _("Object groups"), + "objectClass" => "gosaGroupOfNames")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "base" => _("Base"), + "description" => _("Description"), + "member" => _("Member")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc b/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc new file mode 100644 index 000000000..574087740 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc @@ -0,0 +1,632 @@ +config= &$config; + $this->ui= get_userinfo(); + + /* Copy & Paste enabled ? + */ + if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE'] ))){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + + /* Div lsit management */ + $this->DivListOGroup = new divListOGroup($this->config,$this); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /**************** + Variable intialisation && Check posts for commands + ****************/ + + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_ogroups/"); + + $smarty = get_smarty(); + $s_action = ""; + $s_entry = ""; + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/^group_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/^group_".$s_action."_/i","",$key); + // Post for edit + }elseif(preg_match("/^group_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/^group_".$s_action."_/i","",$key); + // Post for new + }elseif(preg_match("/^group_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + }elseif(preg_match("/^remove_multiple_ogroups/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^multiple_cut_ogroups/",$key)){ + $s_action = "cut_multiple"; + }elseif(preg_match("/^multiple_copy_ogroups/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/_group_edit_/",$key)){ + $type = preg_replace("/_group_edit_.*$/","",$key); + $s_action="edit"; + $s_entry = preg_replace("/".$type."_group_edit_/i","",$key); + $_POST['arg'] = $type; + } + } + $s_entry = preg_replace("/_.$/","",$s_entry); + + // Edit if + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "group_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + + /**************** + Copy & Paste handling + ****************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /*************** + Create a new object group + ****************/ + + /* New group? */ + if ($s_action=="new"){ + + /* By default we set 'dn' to 'new', all relevant plugins will + react on this. */ + $this->dn= "new"; + + /* Create new usertab object */ + $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $this->dn,"ogroups"); + $this->ogroup->set_acl_base($this->DivListOGroup->selectedBase); + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + if(count($ids)){ + foreach($ids as $id){ + $dn = $this->ogrouplist[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $smarty->assign("info", sprintf(_("You're about to delete the following object entry %s"), @LDAP::fix($dns_names))); + } else { + $smarty->assign("info", sprintf(_("You're about to delete the following object entries %s"), @LDAP::fix($dns_names))); + } + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_ogroup_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $acl = $this->ui->get_permissions($dn, "ogroups"); + if (preg_match('/d/', $acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $dn); + $this->ogroup->delete (); + unset ($this->ogroup); + $this->ogroup= NULL; + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this object group!")); + new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_ogroup_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /**************** + Delete object group + ****************/ + + if ($s_action=="del"){ + + /* Get 'dn' from posted 'uid' */ + $this->dn= $this->ogrouplist[$s_entry]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl = $this->ui->get_permissions($this->dn,"ogroups"); + if(preg_match("/d/",$acl)){ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the object group '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the user isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this object group!")); + } + } + + + /**************** + Delete confirmed + ****************/ + + /* Confirmation for deletion has been passed. Group should be deleted. */ + if (isset($_POST['delete_group_confirm'])){ + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + $acl = $this->ui->get_permissions($this->dn,"ogroups"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->ogroup= new ogrouptabs($this->config, + $this->config->data['TABS']['OGROUPTABS'], $this->dn); + $this->ogroup->delete (); + unset ($this->ogroup); + $this->ogroup= NULL; + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this object group!")); + new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + + /**************** + Delete object group Canceled + ****************/ + + /* Delete group canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + + /**************** + Edit group + ****************/ + + if (($s_action=="edit") && (! isset($this->ogroup->config)) ){ + + /* Get 'dn' from posted 'uid', must be unique */ + $this->dn= $this->ogrouplist[$s_entry]['dn']; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so everyone will get the + above dialog */ + add_lock ($this->dn, $this->ui->dn); + + /* Register grouptab to trigger edit dialog */ + $this->ogroup= new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $this->dn, "ogroups"); + $this->ogroup->set_acl_base($this->dn); + $_SESSION['objectinfo']= $this->dn; + } + + + /**************** + Edit finished save + ****************/ + + /* Finish button has been pressed */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->ogroup->config)) ){ + + /* Check tabs, will feed message array */ + $message= $this->ogroup->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + /* Save user data to ldap */ + $this->ogroup->save(); + + if (!isset($_POST['edit_apply'])){ + /* Group has been saved successfully, remove lock from + LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + + unset ($this->ogroup); + $this->ogroup= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /**************** + Cancel edit object group + ****************/ + + /* Cancel dialogs */ + if ((isset($_POST['edit_cancel'])) && (isset($this->ogroup->dn))){ + del_lock ($this->ogroup->dn); + unset ($this->ogroup); + $this->ogroup= NULL; + unset($_SESSION['objectinfo']); + } + + + /**************** + Display open dialogs + ****************/ + + /* Show dialog if object is present */ + if (isset($this->ogroup->config)){ + $display= $this->ogroup->execute(); + + /* Don't show buttons if tab dialog requests this */ + if (!$this->ogroup->by_object[$this->ogroup->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + return ($display); + } + + + /**************** + Display list + ****************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListOGroup->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Display dialog with group list */ + $this->DivListOGroup->parent = $this; + $this->DivListOGroup->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListOGroup->SubSearch){ + $this->DivListOGroup->AddDepartments($this->DivListOGroup->selectedBase,4,1); + } + $this->reload (); + $this->DivListOGroup->setEntries($this->ogrouplist); + return($this->DivListOGroup->Draw()); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array(get_groups_ou().$this->DivListOGroup->selectedBase)); + } + + + + function convert_list($input) + { + $temp= ""; + + $conv= array( + "U" => array("select_user.png" ,_("User") , "ogroup"), + "G" => array("select_groups.png" ,_("Group") , "ogroup"), + "A" => array("select_application.png" ,_("Application") , "ogroup"), + "D" => array("select_department.png" ,_("Department") , "ogroup"), + "S" => array("select_server.png" ,_("Server") , "ogroup"), + "F" => array("select_phone.png" ,_("Phone") , "phonequeue"), + "W" => array("select_workstation.png" ,_("Workstation") , "workstartup"), + "T" => array("select_terminal.png" ,_("Terminal") , "termgroup"), + "P" => array("select_printer.png" ,_("Printer") , "ogroup")); + + /* Assemble picture */ + $type= $input['gosaGroupObjects'][0]; + $type= preg_replace("/[^A-Z]/i","",$type); + if (isset($type[0])){ + $p1['pic']= $conv[$type[0]][0]; + $p1['tit']= $conv[$type[0]][1]; + $p1['alt']= $type[0]; + $p1['lnk']= $conv[$type[0]][2]; + $html_object_1 = ""; + $temp.= $html_object_2." class='center' id='iconB".preg_replace("/_/","",$p2['lnk']."_group_edit_%KEY")."' + src='images/".$p2['pic']."' alt='".$p2['alt']."' title='".$p2['tit']."'>"; + return ($temp); + } + + + function reload() + { + /* Set base for all searches && initialise some vars */ + $this->ogrouplist= array(); + $base = $this->DivListOGroup->selectedBase; + $filter = "(gosaGroupObjects=[])"; + $Regex = $this->DivListOGroup->Regex; + + $chk = array( + "UserGroups" => "(gosaGroupObjects=*U*)" , + "GroupGroups" => "(gosaGroupObjects=*G*)" , + "ApplicationGroups" => "(gosaGroupObjects=*A*)" , + "DepartmentGroups" => "(gosaGroupObjects=*D*)" , + "ServerGroups" => "(gosaGroupObjects=*S*)" , + "WorkstationGroups" => "(gosaGroupObjects=*W*)" , + "TerminalGroups" => "(gosaGroupObjects=*T*)" , + "PrinterGroups" => "(gosaGroupObjects=*P*)" , + "PhoneGroups" => "(gosaGroupObjects=*F*)" ); + /* Create filter */ + foreach($chk as $chkBox => $FilterPart){ + if($this->DivListOGroup->$chkBox){ + $filter .= $FilterPart; + } + } + $filter= "(&(cn=$Regex)(objectClass=gosaGroupOfNames)(|$filter))"; + + if($this->DivListOGroup->SubSearch){ + $res= get_list($filter, "ogroups", $base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT | GL_SUBSEARCH); + }else{ + $res= get_list($filter, "ogroups", get_groups_ou().$base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT ); + } + + $this->ogrouplist= $res; + ksort ($this->ogrouplist); + reset ($this->ogrouplist); + $tmp=array(); + foreach($this->ogrouplist as $tkey => $val ){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + ksort($tmp); + $this->ogrouplist=array(); + foreach($tmp as $val){ + $this->ogrouplist[]=$val; + } + reset ($this->ogrouplist); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->ogrouplist[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups"); + } + + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->ogrouplist[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","ogrouptabs","OGROUPTABS","ogroups"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","ogrouptabs","OGROUPTABS","ogroups"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListOGroup->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + function save_object() + { + $this->DivListOGroup->save_object(); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/class_phonequeue.inc b/gosa-core/plugins/admin/ogroups/class_phonequeue.inc new file mode 100644 index 000000000..f67ee78d8 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/class_phonequeue.inc @@ -0,0 +1,961 @@ +goFonHomeServers if available + * and use first server as default if necessary. + */ + if(array_key_exists('config',$_SESSION) && + array_key_exists('SERVERS',$_SESSION['config']->data) && + array_key_exists('FON',$_SESSION['config']->data['SERVERS']) && + count($_SESSION['config']->data['SERVERS']['FON']) && + is_callable("mysql_connect") + ) { + + /* Set available server */ + $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON']; + + /* Set default server */ + if($this->dn == "new"){ + $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; + } + + /* Remember inital home server, to be able to remove old entries */ + $this->init_HomeServer = $this->goFonHomeServer; + + /* get config */ + if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){ + print_red(sprintf(_("The specified home server '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry while ignoring old accounts."), preg_replace("/,/",", ",$this->goFonHomeServer), preg_replace("/,/",", ",$this->goFonHomeServers[0]['DN']))); + $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; + $this->init_HomeServer = $this->goFonHomeServers[0]['DN']; + } + $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer]; + } + + + /* Variable init + * Load phone nubmers and parse dial options + */ + if($this->is_account){ + if(isset($this->attrs['telephoneNumber'])){ + $this->telephoneNumber=$this->attrs['telephoneNumber']; + unset($this->telephoneNumber['count']); + } + for($i = 0; $i < strlen($this->goFonDialOption); $i++){ + $name = "goFonDialOption".$this->goFonDialOption[$i]; + $this->$name=$this->goFonDialOption[$i]; + } + } + + /* Set Queue announce hold time to true/false */ + if(preg_match("/no/i",$this->goFonQueueAnnounceHoldtime)){ + $this->goFonQueueAnnounceHoldtime=false; + }else{ + $this->goFonQueueAnnounceHoldtime=true; + } + + /* Define all available ringdown types */ + $types= array('ringall' =>_("ring all"), + 'roundrobin' =>_("round robin"), + 'leastrecent'=>_("least recently called"), + 'fewestcalls'=>_("fewest completed calls"), + 'random' =>_("random"), + 'rrmemory' =>_("round robin with memory")); + $i = 0; + foreach($types as $type => $name){ + $i++; + $this->goFonQueueStrategyOptions[$i] =$name; + $this->goFonQueueStrategyOptionsR[$i] =$type; + $tmp[$type] = $i; + } + $this->goFonQueueStrategy= $tmp[$this->goFonQueueStrategy]; + $this->old_cn = $this->cn; + $this->old_phone_numbers = $this->telephoneNumber; + } + + + /* This function ensures that the selected home server + * and the initially selected home server are reachable and accessible + */ + function check_database_accessibility() + { + /* Check if mysql extension is available */ + if(!is_callable("mysql_pconnect")){ + return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup.")); + } + + /******************** + * Check currently selected home server + ********************/ + + $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer]; + $r_current = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); + if(!$r_current){ + new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current)); + return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), + $cfg_Current['SERVER'],$cfg_Current['LOGIN'])); + } + $db_current = @mysql_select_db($cfg_Current['DB'],$r_current); + if(!$db_current){ + new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current)); + mysql_close($r_current); + return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER'])); + } + + /******************** + * Check init home server + ********************/ + + if($this->initially_was_account){ + $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ; + $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']); + if(!$r_init){ + new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_init)); + return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), + $cfg_Init['SERVER'],$cfg_Init['LOGIN'])); + } + $db_init = @mysql_select_db($cfg_Init['DB'],$r_init); + if(!$db_init){ + new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_init)); + mysql_close($r_init); + return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER'])); + } + } + } + + + /* Display plugin ui */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","ogroups/".get_class($this),$this->dn); + } + + 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; + } + } + + /* Show tab dialog headers */ + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove the phone queue from this Account"), + _("Phone queue is enabled for this group. You can disable it by clicking below.")); + } else { + $display= $this->show_enable_header(_("Create phone queue"), + _("For this group the phone queues are disabled. You can enable them by clicking below.")); + return ($display); + } + } + + if($this->acl_is_writeable("telephoneNumber")){ + + /* Add queue number */ + if(isset($_POST['add_phonenumber'])&&(isset($_POST['phonenumber']))&&(!empty($_POST['phonenumber']))){ + if((!in_array($_POST['phonenumber'],$this->telephoneNumber))&&(is_numeric($_POST['phonenumber']))){ + $this->telephoneNumber[]=$_POST['phonenumber']; + } + } + + /* Delete queue number */ + if(isset($_POST['delete_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){ + unset($this->telephoneNumber[$_POST['goFonQueueNumber_List']]); + } + + /* queue number up */ + if(isset($_POST['up_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){ + if($_POST['goFonQueueNumber_List']>0){ + $up = $this->telephoneNumber[$_POST['goFonQueueNumber_List']]; + $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1]; + $this->telephoneNumber[$_POST['goFonQueueNumber_List']] = $down; + $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1] = $up; + } + } + + /* Queuenumber down */ + if(isset($_POST['down_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){ + if(isset($this->telephoneNumber[($_POST['goFonQueueNumber_List']+1)])){ + $up = $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1]; + $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']]; + $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1] = $down; + $this->telephoneNumber[$_POST['goFonQueueNumber_List']] = $up; + } + $this->telephoneNumber[$_POST['goFonQueueNumber_List']] = $up; + } + } + + $tmp = array(); + foreach($this->telephoneNumber as $val){ + if(!empty($val)){ + $tmp[]= $val; + } + } + $this->telephoneNumber=$tmp; + + /* Assign samrty variables */ + $smarty= get_smarty(); + $smarty->assign("goFonQueueLanguageOptions",get_languages(FALSE,TRUE)); + $smarty->assign("goFonQueueStrategyOptions", $this->goFonQueueStrategyOptions); + + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + foreach($this->attributes as $key => $val){ + $smarty->assign($val,$this->$val); + if($this->$val == false){ + $smarty->assign($val."CHK",""); + }else{ + $smarty->assign($val."CHK"," checked "); + } + } + + /* Create array with goFonHomeServer */ + $tmp = array(); + foreach($this->goFonHomeServers as $dn => $val){ + if(!is_numeric($dn)){ + $tmp[$dn] = $val['SERVER']; + } + } + $smarty->assign("goFonHomeServers",$tmp); + + return ($display.$smarty->fetch (get_template_path('phonequeue.tpl', TRUE))); + } + + + /* Check formular input */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + if(!count($this->goFonHomeServers)){ + $message[] = _("There must be at least one server with an asterisk database to create a phone queue."); + } + if(empty($this->goFonHomeServer)){ + $message[] = _("Please select a valid goFonHomeServer."); + } + if($this->is_number_used()){ + $message[] = $this->is_number_used(); + } + if(!((is_numeric($this->goFonTimeOut))||(empty($this->goFonTimeOut)))){ + $message[] = _("Timeout must be numeric"); + } + if(!((is_numeric($this->goFonQueueRetry))||(empty($this->goFonQueueRetry)))){ + $message[] = _("Retry must be numeric"); + } + if(!((is_numeric($this->goFonMaxLen))||(empty($this->goFonMaxLen)))){ + $message[] = _("Max queue length must be numeric"); + } + if(!((is_numeric($this->goFonAnnounceFrequency))||(empty($this->goFonAnnounceFrequency)))){ + $message[] = _("Announce frequency must be numeric"); + } + if(count($this->telephoneNumber)==0){ + $message[] = _("There must be least one queue number defined."); + } + + /* check if add to database could be successfull */ + $str = $this->add_to_database(); + if(!empty($str)){ + $message[] = $str; + } + return $message; + } + + + /* This function removes the old database entries. + * If this entry should be removed or the home server has changed + * this function is called to ensure that all old entries will be deleted. + */ + function remove_from_database($save = false) + { + /* Check if we must remove old entries */ + if($this->initially_was_account){ + + /* Check if there is at least on server configuration */ + if(!count($this->goFonHomeServers)){ + return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); + } + + /******************** + * Get configuration and check it + ********************/ + + /* Check if databases are reachable, returns an error string if anything fails */ + $error_str = $this->check_database_accessibility(); + if($error_str){ + return($error_str); + } + + /* Connect to current database to be able to add new entries */ + $cfg_Current = $this->goFonHomeServers[$this->init_HomeServer] ; + $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); + $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur); + + /* Create sql entries */ + $delete[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->old_cn."';\n"; + $delete[]= "DELETE FROM ".$cfg_Current['QUEUE_TABLE']." WHERE name='".$this->old_cn."'; \n"; + $delete[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->old_cn."';\n"; + foreach($this->old_phone_numbers as $number){ + $delete[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$number."';\n"; + } + + /* Execute the queries */ + if($save){ + foreach($delete as $sql){ + $res = @mysql_query($sql,$res_cur); + if(!$res){ + new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current)); + return(_("Error while removing old queue entries from database."). + " "._("Please have a look a the gosa logfiles.")); + } + } + } + } + } + + + /* This function handles the database entries for this + * queue. + * Existing entries will be updated if possible. + */ + function add_to_database($save = false) + { + /* Check if there is at least on server configuration */ + if(!count($this->goFonHomeServers)){ + return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); + } + + /******************** + * Get configuration and check it + ********************/ + + /* Check if databases are reachable, returns an error string if anything fails */ + $error_str = $this->check_database_accessibility(); + if($error_str){ + return($error_str); + } + + /* Connect to current database to be able to add new entries */ + $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer] ; + $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); + $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur); + + /* Connect to old home server and remove old entries if necessary */ + if(($this->initially_was_account) && ($this->init_HomeServer != $this->goFonHomeServer)){ + $str = $this->remove_from_database($save); + if(!empty($str)){ + return($str);; + } + } + + /* Ensure that we have the new cn in $this->cn and the old cn in $this->old_cn */ + $this->cn = $this->parent->by_object['ogroup']->cn; + + if($save){ + + /***************** + * Create queue table entry + *****************/ + + /* Check if QUEUE_TABLE entry exists. + * If this entry is missing - create it + * else update the entry with new values. + */ + $query = "SELECT * FROM ".$cfg_Current['QUEUE_TABLE']." WHERE name='".$this->old_cn."';"; + $res = mysql_query($query,$res_cur); + if(!$res){ + new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($res_cur)); + return(_("Could not detect old queue entry, query failed.")." "._("Please have a look a the gosa logfiles.")); + } + $cnt = mysql_affected_rows($res_cur); + + + /* Create queue table entry + * Leave unused options empty. + */ + $queue["announce"] = ""; + $queue["monitor_join"] = ""; + $queue["monitor_format"] = ""; + $queue["announce_round_seconds"]= ""; + $queue["wrapuptime"] = ""; + $queue["servicelevel"] = ""; + $queue["eventmemberstatus"] = ""; + $queue["eventwhencalled"] = ""; + $queue["memberdelay"] = ""; + $queue["weight"] = ""; + $queue["timeoutrestart"] = ""; + + $queue["queue_holdtime"] = $this->goFonQueueAnnounce; + $queue["queue_lessthan"] = $this->goFonQueueLessThan; + $queue["retry"] = $this->goFonQueueRetry; + $queue["reportholdtime"] = "1"; + $queue["joinempty"] = "no"; + $queue["leavewhenempty"] = "yes"; + + $queue["context"] = "default"; + $queue["name"] = $this->cn; + $queue["timeout"] = $this->goFonTimeOut; + $queue["maxlen"] = $this->goFonMaxLen; + $queue["strategy" ] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy]; + $queue["queue_thankyou"] = $this->goFonQueueThankYou; + $queue["queue_reporthold"] = $this->goFonQueueReportHold; + $queue["announce_frequency"] = $this->goFonAnnounceFrequency; + $queue["queue_youarenext"] = $this->goFonQueueYouAreNext; + $queue["queue_thereare"] = $this->goFonQueueThereAre; + $queue["queue_callswaiting"] = $this->goFonQueueCallsWaiting; + $queue["queue_minutes"] = $this->goFonQueueMinutes; + $queue["queue_seconds"] = $this->goFonQueueSeconds; + $queue["announce_holdtime"] = $this->goFonQueueAnnounceHoldtime; + $queue["musiconhold"] = $this->goFonMusiconHold; + + + /* Check if we must create a new queue entry + * or if we can update an existing entry + * $cnt contains the number of entries matching this cn + */ + + /* Create new queue table entry + */ + if($cnt == 0){ + + /* Parse and Add Queue */ + $entries = ""; + $values = ""; + foreach($queue as $attr=>$val){ + if($val == "") continue; + $entries.= "`".$attr."`,"; + $values .= "'".$val."',"; + } + $values = preg_replace("/,$/","",$values); + $entries = preg_replace("/,$/","",$entries ); + $SQL[]="INSERT INTO ".$cfg_Current['QUEUE_TABLE']." (".$entries.") VALUES (".$values.");"; + }elseif($cnt == 1){ + + /* Update queue table entry + */ + $queue_old = @mysql_fetch_assoc($res); + foreach($queue_old as $name => $value){ + if(isset($queue[$name]) && $queue[$name] == $value){ + unset($queue[$name]); + } + } + + /* Parse and Add Queue */ + if(count($queue)){ + $query = "UPDATE ".$cfg_Current['QUEUE_TABLE']." SET "; + foreach($queue as $key => $val){ + $query.= "".$key."='".$val."',"; + } + $query = preg_replace("/,$/","",$query); + $query.= " WHERE name='".$this->old_cn."';"; + $SQL[] = $query; + } + }else{ + return(sprintf(_("More than one entry in queue table found, that uses the name ('%s'). Please fix this issue manually first."),$this->cn)); + } + + + /***************** + * Create queue member entries + *****************/ + + /* Add the queue member entries + * First we must remove all old user entries. + * to be able to add a clean set of members. + */ + $SQL[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->cn."';"; + $SQL[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->old_cn."';"; + + /* Append new Member for this queue */ + $queueuser =array(); + $i = 0; + $parent = $this->parent->by_object['ogroup']; + + + $ldap = $this->config->get_ldap_link(); + foreach($parent->memberList as $member => $mem_data){ + $ldap->cat($member,array("goFonHomeServer","objectClass","dn","uid")); + if($ldap->count()){ + + $obj = $ldap->fetch(); + + /* Calculate server and account dependencies */ + $is_acc = in_array("goFonAccount",$obj['objectClass']); + $is_home= isset($obj['goFonHomeServer'][0]) && $obj['goFonHomeServer'][0] == $this->goFonHomeServer; + + /* Append user to list of queue member, + * only if user has phoneAccount extension && is on same home server */ + if($is_acc && $is_home){ + $i ++ ; + $queueuser[$i]['queue_name'] = $this->cn; + $queueuser[$i]['interface'] = "SIP/".$obj['uid'][0]; + $queueuser[$i]['penalty'] = 1; + } + } + } + + /* Parse and Add members to query Array */ + if(is_array($queueuser)){ + foreach($queueuser as $user){ + $entries = ""; + $values = ""; + foreach($user as $attr => $val){ + $entries.= "`".$attr."`,"; + $values .= "'".$val."',"; + } + $values = preg_replace("/,$/","",$values); + $entries = preg_replace("/,$/","",$entries ); + + $SQL[]="INSERT INTO ".$cfg_Current['QUEUE_MEMBER_TABLE']." (".$entries.") VALUES (".$values.")"; + } + } + + + /***************** + * Create extension entries + *****************/ + + /* Add the extension entries + * First we must remove all old entensions. + */ + $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->cn."';\n"; + $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->old_cn."';\n"; + + /* Delete old enxtension entries for the old telephone nubmer */ + if(is_array($this->old_phone_numbers)){ + foreach($this->old_phone_numbers as $phone){ + $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$phone."';\n"; + } + } + + /* Delete enxtension entries for telephone numbers */ + if(is_array($this->telephoneNumber)){ + foreach($this->telephoneNumber as $phone){ + $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$phone."';\n"; + } + } + + /* Create a extension entry fpr each telephoneNumber */ + $i_insert_only_once = false; + $prio = 11; // This represents the priority for each telephoneNumber + foreach($this->telephoneNumber as $num){ + + /* The naming refrences */ + if($i_insert_only_once == false){ + $i_insert_only_once = true; + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $this->cn; + $a_ext[$i]['priority'] = 1; + $a_ext[$i]['app'] = "Goto"; + $a_ext[$i]['appdata'] = $num."|1"; + $i ++ ; + } + + /* If there is currently no user for this queue + * Play no service sound file and return to default context. + */ + if(count($queueuser)==0){ + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 1; + $a_ext[$i]['app'] = "SetLanguage"; + $a_ext[$i]['appdata'] = "de"; + $i ++ ; + + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 2; + $a_ext[$i]['app'] = "Playback"; + $a_ext[$i]['appdata'] = "ss-noservice"; + $i ++ ; + + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 3; + $a_ext[$i]['app'] = "Goto"; + $a_ext[$i]['appdata'] = "default"; + $i ++ ; + }else{ + + /* Dcrement priority to avoid using same priority twice */ + $prio --; + + /* Wait for 2 seconds */ + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 1; + $a_ext[$i]['app'] = "Wait"; + $a_ext[$i]['appdata'] = "2"; + $i ++ ; + + /* Set language to queue language */ + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 2; + $a_ext[$i]['app'] = "SetLanguage"; + $a_ext[$i]['appdata'] = $this->goFonQueueLanguage; + $i ++ ; + + /* Play welcome sound file */ + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 3; + $a_ext[$i]['app'] = "Playback"; + $a_ext[$i]['appdata'] = $this->goFonWelcomeMusic; + $i ++ ; + + /* Set CID name */ + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 4; + $a_ext[$i]['app'] = "SetCIDName"; + if(!empty($this->parent->by_object['ogroup']->description)){ + $a_ext[$i]['appdata'] = $this->parent->by_object['ogroup']->description; + }else{ + $a_ext[$i]['appdata'] = $this->cn." - ".$num; + } + $i ++ ; + + /* Set queue priority */ + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 5; + $a_ext[$i]['app'] = "SetVar"; + $a_ext[$i]['appdata'] = "QUEUE_PRIO=".$prio; + $i ++ ; + + /* Open queue */ + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $num; + $a_ext[$i]['priority'] = 6; + $a_ext[$i]['app'] = "Queue"; + $a_ext[$i]['appdata'] = $this->cn; + "|". + $this->goFonDialOptiont. + $this->goFonDialOptionT. + $this->goFonDialOptionh. + $this->goFonDialOptionH. + $this->goFonDialOptionr; + } + + $i++; + } + + /* Parse and Add Extension entries */ + foreach($a_ext as $ext){ + $entries = ""; + $values = ""; + foreach($ext as $attr => $val){ + $entries.= "`".$attr."`,"; + $values .= "'".$val."',"; + } + $values = preg_replace("/,$/","",$values); + $entries = preg_replace("/,$/","",$entries ); + $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$entries.") VALUES (".$values.")"; + } + + /* Do all collected mysql queries + */ + foreach($SQL as $query) + $res = mysql_query($query,$res_cur); + if(!$res){ + new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($res_cur)); + return(_("Mysql query failed.")." "._("Please have a look a the gosa logfiles.")); + } + } + @mysql_close($r_con); + return(false); + } + + + /* This function checks if the given phonenumbers + * are available or already in use + */ + function is_number_used() + { + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(& (!(uid=".$this->cn.")) + (!(cn=".$this->cn."))) + (| (objectClass=goFonAccount) + (objectClass=goFonQueue) + (objectClass=goFonConference)))", array("telephoneNumber","cn","uid")); + while($attrs = $ldap->fetch()) { + unset($attrs['telephoneNumber']['count']); + foreach($attrs['telephoneNumber'] as $tele){ + if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn']; + if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn']; + $numbers[$tele]=$attrs; + } + } + + foreach($this->telephoneNumber as $num){ + if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!= $this->attrs['cn'][0]))){ + if(isset($numbers[$num]['uid'][0])){ + return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]); + }else{ + return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]); + } + } + } + } + + + /* Get posted attributes */ + function save_object() + { + plugin::save_object(); + if(isset($_POST['phonenumber'])){ + foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionh","goFonDialOptionr","goFonDialOptionH","goFonMusiconHold") as $val){ + if(isset($_POST[$val])){ + $this->$val = $_POST[$val]; + }else{ + $this->$val = false; + } + } + if(isset($_POST['goFonQueueAnnounceHoldtime'])){ + $this->goFonQueueAnnounceHoldtime = "yes"; + }else{ + $this->goFonQueueAnnounceHoldtime = false; + } + } + } + + + function save() + { + $ldap= $this->config->get_ldap_link(); + + plugin::save(); + + /* Create dial option attribute */ + $this->attrs['goFonDialOption'] = ""; + foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){ + $this->attrs['goFonDialOption'].=$this->$val; + unset($this->attrs[$val]); + } + if(empty($this->attrs['goFonDialOption'])) { + $this->attrs['goFonDialOption']=array(); + } + + /* Set announce hold time to yes no .. */ + if($this->goFonQueueAnnounceHoldtime != "no" ){ + $this->attrs['goFonQueueAnnounceHoldtime'] = "yes"; + }else{ + $this->attrs['goFonQueueAnnounceHoldtime'] = "no"; + } + + /* Set strategy */ + $this->attrs['goFonQueueStrategy'] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy]; + + /* Add database entry, display error and abort if this fails */ + $str = $this->add_to_database(true); + if(!empty($str)){ + print_red($str); + } + + /* Save data to LDAP */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + if($this->initially_was_account){ + new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), _("Saving phone queue failed")); + + /* 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"); + } + } else { + $this->handle_post_events("add"); + } + } + + + /* remove object from parent */ + function remove_from_parent() + { + /* Cancel if nothing is to do here */ + if (!$this->initially_was_account){ + return; + } + + /* Remove database entries, + * if fails display errors and abort + */ + $str = $this->remove_from_database(true); + if(!empty($str)){ + print_red($str); + return false; + } + + /* Remove all temporary attributes */ + $tmp = array_flip($this->attributes); + foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){ + unset($this->$val); + unset($this->attrs[$val]); + unset($tmp[$val]); + } + foreach(array_flip($tmp) as $key => $val){ + $tmp2[]=$val; + } + $this->attributes = $tmp2; + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), _("Removing phone queue failed")); + } + + + function getCopyDialog() + { + $str = ""; + $str .= _("Phone number"); + $str .= " "; + return($str); + } + + + function saveCopyDialog() + { + if(isset($_POST['telephoneNumber'])){ + $this->telephoneNumber = $_POST['telephoneNumber']; + } + } + + + static function plInfo() + { + return (array( + "plShortName" => _("Phone"), + "plDescription" => _("Phone group"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 3, + "plSection" => array("administration"), + "plCategory" => array("ogroups"), + "plProvidedAcls"=> array( + + "goFonTimeOut" => _("Timeout"), + "goFonMaxLen" => _("Max queue length"), + "goFonHomeServer" => _("Home server"), + "goFonAnnounceFrequency" => _("Announce frequency"), + "goFonDialOptiont" => _("Allow the called user to transfer his call"), + "goFonDialOptionT" => _("Allows calling user to transfer call"), + "goFonDialOptionh" => _("Allow the called to hangup by pressing *"), + "goFonDialOptionr" => _("Ring instead of playing background music"), + "goFonDialOptionH" => _("Allows calling to hangup by pressing *"), + + "goFonMusiconHold" => _("Music on hold"), + "goFonWelcomeMusic" => _("Welcome music"), + "goFonQueueReportHold" => _("Report hold time"), + "goFonQueueYouAreNext" => _("'You are next' sound"), + "goFonQueueThereAre" => _("'There are' sound"), + "goFonQueueCallsWaiting" => _("'Call waiting' sound"), + "goFonQueueThankYou" => _("'Thank you' sound"), + "goFonQueueMinutes" => _("'Minutes' sound"), + "goFonQueueSeconds" => _("'Seconds' sound"), + "goFonQueueLessThan" => _("'Less than' sound"), + "telephoneNumber" => _("Queue phone number"), + "goFonQueueLanguage" => _("Language"), + "goFonQueueStrategy" => _("Method"), + "goFonQueueAnnounceHoldtime"=> _("Announce holdtime"), + "goFonQueueAnnounce" => _("Announce"), + "goFonQueueRetry" => _("Retry")) + )); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/class_termgroup.inc b/gosa-core/plugins/admin/ogroups/class_termgroup.inc new file mode 100644 index 000000000..53c59ecc8 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/class_termgroup.inc @@ -0,0 +1,432 @@ + "localboot", + "instant_update" => "softupdate", + "update" => "sceduledupdate", + "reinstall" => "install", + "rescan" => "", + "memcheck" => "memcheck", + "sysinfo" => "sysinfo"); + + var $attributes = array("gotoMode","gotoSyslogServer", "gotoNtpServer"); + var $objectclasses = array("gotoWorkstationTemplate"); + var $CopyPasteVars = array("gotoNtpServers","modes","inheritTimeServer","members"); + var $view_logged = FALSE; + + + function termgroup (&$config, $dn= NULL, $parent= NULL) + { + /*************** + Some initialisations + ***************/ + + plugin::plugin($config, $dn, $parent); + + $ldap= $config->get_ldap_link(); + + $this->is_account = true; + $this->modes["active"]= _("Activated"); + $this->modes["locked"]= _("Locked"); +// $this->modes["memcheck"]= _("Memory test"); +// $this->modes["sysinfo"]= _("System analysis"); + + $this->orig_dn = $this->dn; + + /*************** + Get mac addresses from member objects + ***************/ + + /* We're only interested in the terminal members here, evaluate + these... */ + if(isset($this->attrs['member'])){ + for ($i= 0; $i<$this->attrs['member']['count']; $i++){ + $member= $this->attrs['member'][$i]; + $ldap->cat($member, array('objectClass', 'macAddress', 'cn')); + if (preg_match("/success/i", $ldap->error)){ + $attrs = $ldap->fetch(); + if (in_array("gotoTerminal", $attrs['objectClass']) || + in_array("gotoWorkstation", $attrs['objectClass'])){ + if (isset($attrs['macAddress'])){ + $this->members[$attrs['cn'][0]]= $attrs['macAddress'][0]; + } else { + $this->members[$attrs['cn'][0]]= ""; + } + } + } + } + } + + /*************** + Perpare NTP settings + ***************/ + + /* Create used ntp server array */ + $this->gotoNtpServer= array(); + if(isset($this->attrs['gotoNtpServer'])){ + $this->inheritTimeServer = false; + unset($this->attrs['gotoNtpServer']['count']); + foreach($this->attrs['gotoNtpServer'] as $server){ + $this->gotoNtpServer[$server] = $server; + } + } + + /* Set inherit checkbox state */ + if(in_array("default",$this->gotoNtpServer)){ + $this->inheritTimeServer = true; + $this->gotoNtpServer=array(); + } + + /* Create available ntp options */ + $this->gotoNtpServers = $this->config->data['SERVERS']['NTP']; + foreach($this->gotoNtpServers as $key => $server){ + if($server == "default"){ + unset($this->gotoNtpServers[$key]); + } + } + } + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if (!$this->acl_is_createable() && $this->dn == "new"){ + $message[]= _("You have no permissions to create a workstation on this 'Base'."); + } + + /* Check for valid ntpServer selection */ + if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){ + $message[]= _("There must be at least one NTP server selected."); + } + return($message); + } + + function remove_from_parent() + { + /* Workstation startup is using gotoWorkstationTemplate too, + if we remove this oc all other not manged attributes will cause errors */ + if(isset($this->attrs['gotoKernelParameters'])){ + $this->objectclasses = array(); + } + + /* Remove acc */ + plugin::remove_from_parent(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->orig_dn); + $ldap->modify($this->attrs); + $this->handle_post_events("remove"); + new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + + function update_term_member_FAIstate($act) + { + /* Get required informations */ + $og = $this->parent->by_object['ogroup']; + $allobs = $og->objcache; + + /* Get correct value for FAIstate */ + $action = $this->mapActions[$act]; + + /* Get ldap connection */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + + /* Foreach member of mthis ogroup ... */ + foreach($og->member as $key ){ + + /* check objectClasses and create attributes array */ + $attrs = array("FAIstate"=>$action); + for($i = 0; $i < $allobs[$key]['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $allobs[$key]['objectClass'][$i]; + } + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } + if($attrs['FAIstate'] == ""){ + $attrs['FAIstate'] = array(); + } + + /* If this objects is workstation,terminal or server upodate FAIstate */ + if(preg_match("/(w|t|s)/i",$allobs[$key]['type'])){ + $ldap->cd ($key); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(),sprintf(_("Setting action state (FAIstate) failed for object '%s', value was '%s'."),$key,$action)); + } + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","ogroups/".get_class($this),$this->dn); + } + + /*************** + Handle requested action + ***************/ + + /* Watch for events */ + if (isset($_POST['action'])){ + $macaddresses=""; + $names=""; + foreach ($this->members as $cn => $macAddress){ + $macaddresses.= "$macAddress "; + $names.= "$cn "; + } + + if (isset($_POST['action'])){ + + /* Update members fai state */ + $this->update_term_member_FAIstate(trim($_POST['saction'])); + + $cmd = $this->config->search("workgeneric", "ACTIONCMD",array('tabs')); + + if ($cmd == ""){ + print_red(_("No ACTIONCMD definition found in your gosa.conf")); + } else { + exec ($cmd." ".$macaddresses." ".escapeshellarg($_POST['saction']), $dummy, $retval); + if ($retval != 0){ + print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); + } else { + $this->didAction= TRUE; + + /* Get dns from member objects. Create ldap object */ + $member = $this->parent->by_object['ogroup']->member; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* walk trough members and add FAIstate */ + foreach($member as $dn => $object){ + + /* Get object */ + $ldap->cat($dn,array("objectClass")); + $res = $ldap->fetch(); + $attrs = array(); + + /* Add FAI state */ + $attrs['FAIstate'] = ""; + if(isset($this->mapActions[$_POST['saction']])){ + $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; + } + + /* Fix objectClass index */ + for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $res['objectClass'][$i]; + } + + /* Check if we must add the objectClass */ + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } + + if($attrs['FAIstate'] == ""){ + $attrs['FAIstate'] = array(); + } + + $ldap->cd($dn); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic (FAIstate) with dn '%s' failed."),$dn)); + } + $this->didAction= TRUE; + } + } + } + } + + + /*************** + Add remove NTP server + ***************/ + + /* Add new ntp Server to our list */ + if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers']))){ + $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; + } + + /* Delete selected NtpServer for list of used servers */ + if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected']))){ + foreach($_POST['gotoNtpServerSelected'] as $name){ + unset($this->gotoNtpServer[$name]); + } + } + + + /*************** + Prepare smarty + ***************/ + + /* Set government mode */ + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated) { + $smarty->assign($name."ACL",$this->getacl($name)); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr, $this->$attr); + } + + /* Variables */ + foreach(array("gotoMode","gotoNtpServer") as $val){ + $smarty->assign($val."_select", $this->$val); + } + + $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), + "instant_update" => _("Instant update"), + "update" => _("Scheduled update"), + "reinstall" => _("Reinstall"), + "rescan" => _("Rescan hardware"), + "memcheck" => _("Memory test"), + "sysinfo" => _("System analysis"))); + + $smarty->assign("inheritTimeServer",$this->inheritTimeServer); + $smarty->assign("modes", $this->modes); + + $tmp = array(); + foreach($this->gotoNtpServers as $server){ + if(!in_array($server,$this->gotoNtpServer)){ + $tmp[$server] = $server; + } + } + + $smarty->assign("gotoNtpServers",$tmp); + $smarty->assign("syslogservers", $this->config->data['SERVERS']['SYSLOG']); + $smarty->assign("gotoSyslogServer_select", $this->gotoSyslogServer); + + /* Show main page */ + return ($smarty->fetch (get_template_path('termgroup.tpl', TRUE))); + } + + function save_object() + { + plugin::save_object(); + /* Set inherit mode */ + if(isset($_POST['workgeneric_posted'])){ + if(isset($_POST["inheritTimeServer"])){ + $this->inheritTimeServer = true; + }else{ + $this->inheritTimeServer = false; + } + } + } + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /*************** + Prepare special vars + ***************/ + + /* Unset some special vars ... */ + foreach (array("gotoSyslogServer") as $val){ + if ($this->attrs[$val] == "default"){ + $this->attrs[$val]= array(); + } + } + + /* Update ntp server settings */ + if($this->inheritTimeServer){ + $this->attrs['gotoNtpServer'] = "default"; + }else{ + /* Set ntpServers */ + $this->attrs['gotoNtpServer'] = array(); + foreach($this->gotoNtpServer as $server){ + $this->attrs['gotoNtpServer'][] = $server; + } + } + + + /*************** + Write to ldap + ***************/ + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + if($this->initially_was_account){ + new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + if(!$this->didAction){ + $this->handle_post_events("modify"); + } + show_ldap_error($ldap->get_error(), _("Saving workstation failed")); + + } + + static function plInfo() + { + return (array( + "plShortName" => _("System"), + "plDescription" => _("System group"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 5, + "plSection" => array("administration"), + "plCategory" => array("ogroups"), + "plProvidedAcls"=> array( + "gotoMode" => _("Mode"), + "gotoSyslogServer" => _("Syslog server"), + "FAIstate" => _("Action flag"), + "gotoNtpServer" => _("Ntp server")) + )); + } + + function PrepareForCopyPaste($source) + { + /* Create used ntp server array */ + $this->gotoNtpServer= array(); + + if(isset($source['gotoNtpServer'])){ + $this->inheritTimeServer = false; + unset($source['gotoNtpServer']['count']); + foreach($source['gotoNtpServer'] as $server){ + $this->gotoNtpServer[$server] = $server; + } + } + + /* Set inherit checkbox state */ + if(in_array("default",$this->gotoNtpServer)){ + $this->inheritTimeServer = true; + $this->gotoNtpServer=array(); + } + + /* Create available ntp options */ + $this->gotoNtpServers = $this->config->data['SERVERS']['NTP']; + foreach($this->gotoNtpServers as $key => $server){ + if($server == "default"){ + unset($this->gotoNtpServers[$key]); + } + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/generic.tpl b/gosa-core/plugins/admin/ogroups/generic.tpl new file mode 100644 index 000000000..f6f75bcb4 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/generic.tpl @@ -0,0 +1,65 @@ + + + + + +
+ + + + + + + + + + + + + + + + + +
{$must} +{render acl=$cnACL} + +{/render} +
+{render acl=$descriptionACL} + +{/render} +
 
{$must} +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+ +
+  ({$combinedObjects}) +
+{render acl=$memberACL} + +{/render} +
+{render acl=$memberACL} +   +{/render} +{render acl=$memberACL} + +{/render} +
+ + + diff --git a/gosa-core/plugins/admin/ogroups/mail.tpl b/gosa-core/plugins/admin/ogroups/mail.tpl new file mode 100644 index 000000000..a28d0ac04 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/mail.tpl @@ -0,0 +1,27 @@ + + + + + + + +
+

{t}Mail distribution list{/t}

+ + + + + +
{$must} +{render acl=$mailACL} + +{/render} +
+
+ + + diff --git a/gosa-core/plugins/admin/ogroups/main.inc b/gosa-core/plugins/admin/ogroups/main.inc new file mode 100644 index 000000000..79690779d --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/main.inc @@ -0,0 +1,50 @@ +save_object(); + $output= $ogroup->execute (); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/ogroup.png'), + _("Object groups"), + "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/ogroup.png'), _("Object groups")); + } + + $display.= $output; + + /* Store changes in session */ + $_SESSION['ogroup']= $ogroup; +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/ogroup_objects.tpl b/gosa-core/plugins/admin/ogroups/ogroup_objects.tpl new file mode 100644 index 000000000..663b60274 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/ogroup_objects.tpl @@ -0,0 +1,58 @@ + + + + + +
+
+

+ {t}Select objects to add{/t} {$hint} +

+
+
+

+ + +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+

+ {t}Show departments{/t}
+ {t}Show people{/t}
+ {t}Show groups{/t}
+ {t}Show applications{/t}
+ {t}Show servers{/t}
+ {t}Show workstations{/t}
+ {t}Show terminals{/t}
+ {t}Show printers{/t}
+ {t}Show phones{/t}
+

+

+ {t}Search in subtrees{/t}
+

+ +
  +
+ +
+ {$apply} +
+
+ +

+ +   + +

+ diff --git a/gosa-core/plugins/admin/ogroups/paste_generic.tpl b/gosa-core/plugins/admin/ogroups/paste_generic.tpl new file mode 100644 index 000000000..91f84d8ae --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/paste_generic.tpl @@ -0,0 +1,14 @@ + + + + + +
+ {$must} + + +
+ + diff --git a/gosa-core/plugins/admin/ogroups/paste_mail.tpl b/gosa-core/plugins/admin/ogroups/paste_mail.tpl new file mode 100644 index 000000000..737d707ef --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/paste_mail.tpl @@ -0,0 +1,14 @@ + + + + + +
+ {$must} + + +
+ + diff --git a/gosa-core/plugins/admin/ogroups/phonequeue.tpl b/gosa-core/plugins/admin/ogroups/phonequeue.tpl new file mode 100644 index 000000000..643b4a326 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/phonequeue.tpl @@ -0,0 +1,328 @@ +

+ ! {t}Only users with the same asterisk home server will be included to this queue.{/t} +

+ + + + + + + + + + + + + + + + + +
+

 {t}Phone numbers{/t}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+{render acl=$telephoneNumberACL} + +{/render} + +{render acl=$telephoneNumberACL} +
+{/render} +{render acl=$telephoneNumberACL} + +{/render} +
+{render acl=$telephoneNumberACL} + +{/render} +{render acl=$telephoneNumberACL} +   +{/render} +{render acl=$telephoneNumberACL} + +{/render} +
+

 {t}Options{/t}

{$must} +{render acl=$goFonHomeServerACL} + +{/render} +
+ {t}Language{/t} + +{render acl=$goFonQueueLanguageACL} + +{/render} +
+ {t}Timeout{/t} + +{render acl=$goFonTimeOutACL} + +{/render} +
+ {t}Retry{/t} + +{render acl=$goFonQueueRetryACL} + +{/render} +
+ {t}Strategy{/t} + +{render acl=$goFonQueueStrategyACL} + +{/render} + +
+ {t}Max queue length{/t} + +{render acl=$goFonMaxLenACL} + +{/render} +
+ {t}Announce frequency{/t} + +{render acl=$goFonAnnounceFrequencyACL} + +{/render} + {t}(in seconds){/t} +
+
+

+ + {t}Queue sound setup{/t} +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {t}Music on hold{/t} + +{render acl=$goFonMusiconHoldACL} + +{/render} +
+ {t}Welcome sound file{/t} + +{render acl=$goFonWelcomeMusicACL} + +{/render} +
+ {t}Announce message{/t} + +{render acl=$goFonQueueAnnounceACL} + +{/render} +
+ {t}Sound file for 'You are next ...'{/t} + +{render acl=$goFonQueueYouAreNextACL} + +{/render} +
+ {t}'There are ...'{/t} + +{render acl=$goFonQueueThereAreACL} + +{/render} +
+ {t}'... calls waiting'{/t} + +{render acl=$goFonQueueCallsWaitingACL} + +{/render} +
+ {t}'Thank you' message{/t} + +{render acl=$goFonQueueThankYouACL} + +{/render} +
+ {t}'minutes' sound file{/t} + +{render acl=$goFonQueueMinutesACL} + +{/render} +
+ {t}'seconds' sound file{/t} + +{render acl=$goFonQueueSecondsACL} + +{/render} +
+ {t}Hold sound file{/t} + +{render acl=$goFonQueueReportHoldACL} + +{/render} +
+ {t}Less Than sound file{/t} + +{render acl=$goFonQueueLessThanACL} + +{/render} +
+
+

+

 {t}Phone attributes {/t}

+ + + + + + + + + +
+{render acl=$goFonQueueAnnounceHoldtimeACL} + +{/render} + {t}Announce holdtime{/t} +
+{render acl=$goFonDialOptiontACL} + +{/render} + {t}Allow the called user to transfer his call{/t} +
+{render acl=$goFonDialOptionTACL} + +{/render} + {t}Allows calling user to transfer call{/t} +
+ +
+ + + + + + + + + + +
+{render acl=$goFonDialOptionhACL} + +{/render} + {t}Allow the called to hangup by pressing *{/t} +
+{render acl=$goFonDialOptionHACL} + +{/render} + {t}Allows calling to hangup by pressing *{/t} +
+{render acl=$goFonDialOptionrACL} + +{/render} + {t}Ring instead of playing background music{/t} +
+
diff --git a/gosa-core/plugins/admin/ogroups/remove.tpl b/gosa-core/plugins/admin/ogroups/remove.tpl new file mode 100644 index 000000000..720156b97 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/remove.tpl @@ -0,0 +1,24 @@ +
+  {t}Warning{/t} +
+ +

+ {$info} + {t}Please double check if you really want to do this since there is no way for GOsa to get your data back.{/t} +

+

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-core/plugins/admin/ogroups/tabs_ogroups.inc b/gosa-core/plugins/admin/ogroups/tabs_ogroups.inc new file mode 100644 index 000000000..3485bb79f --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/tabs_ogroups.inc @@ -0,0 +1,309 @@ +by_object['ogroup']->memberList as $dn => $val){ + + if(isset($this->by_object['ogroup']->objcache[$dn])){ + $obj = $this->by_object['ogroup']->objcache[$dn]; + if(isset($obj['objectClass'])){ + if(in_array("goFonAccount",$obj['objectClass'])){ + $usePhoneTab = true; + } + } + } + } + if(((!$usePhoneTab)&&(isset($this->by_object['phonequeue'])))||((!preg_match("/U/",$objects))&&(isset($this->by_object['phonequeue'])))){ + $this->by_object['phonequeue']->remove_from_parent(); + unset($this->by_object['phonequeue']); + unset($this->by_name['phonequeue']); + } + /* Remove mail group if there is no user anymore */ + if((!preg_match("/U/",$objects))&&(isset($this->by_object['mailogroup']))){ + $this->by_object['mailogroup']->remove_from_parent(); + unset($this->by_object['mailogroup']); + unset($this->by_name['mailogroup']); + } + + /* Remove terminal group, if theres no terminal left in the object list */ + if(((!preg_match("/T/",$objects)) && (!preg_match("/W/",$objects)))&&(isset($this->by_object['termgroup']))){ + $this->by_object['termgroup']->remove_from_parent(); + unset($this->by_object['termgroup']); + unset($this->by_name['termgroup']); + } + + /* Remove ws tabs, if theres no ws left in the object list */ + if((!preg_match("/W/",$objects))&&(isset($this->by_object['workservice']))){ + $this->by_object['workservice']->remove_from_parent(); + unset($this->by_object['workservice']); + unset($this->by_name['workservice']); + } + if((!preg_match("/S/",$objects) && !preg_match("/W/",$objects))&&(isset($this->by_object['workstartup']))){ + $this->by_object['workstartup']->remove_from_parent(); + unset($this->by_object['workstartup']); + unset($this->by_name['workstartup']); + $this->by_object['faiSummary']->remove_from_parent(); + unset($this->by_object['faiSummary']); + unset($this->by_name['faiSummary']); + } + + /* Create goPhoneAccount if theres an user with goPhoneAccount + * but only if there is currently no queue enabled. + */ + if(!isset($this->by_object['phonequeue'])){ + foreach($this->by_object['ogroup']->memberList as $dn => $val){ + + if(isset($this->by_object['ogroup']->objcache[$dn])){ + $obj = $this->by_object['ogroup']->objcache[$dn]; + + if(isset($obj['objectClass'])){ + if(in_array("goFonAccount",$obj['objectClass'])){ + $this->by_name['phonequeue']= _("Phone queue"); + $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn); + $this->by_object['phonequeue']->parent= &$this; + break; + } + } + } + } + } + + /* Add mail group tab , if there is curerntly no mail tab defined */ + if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){ + if(isset($this->config->current['MAILMETHOD'])){ + if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){ + $this->by_name['mailogroup']= _("Mail"); + $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn); + $this->by_object['mailogroup']->parent= &$this; + } + } + } + + /* Add Terminal tab */ + if(((preg_match("/T/",$objects)) || (preg_match("/W/",$objects)))&&(!isset($this->by_object['termgroup']))){ + if(!isset($this->by_object['termgroup'])){ + $this->by_name['termgroup']= _("System"); + $this->by_object['termgroup']= new termgroup($this->config, $this->dn); + $this->by_object['termgroup']->inheritTimeServer = false; + $this->by_object['termgroup']->parent= &$this; + } + } + + /* Add Workstation tabs */ + if((preg_match("/W/",$objects))&&(!isset($this->by_object['workservice']))){ + $this->by_name['workservice']= _("Devices"); + $this->by_object['workservice']= new workservice($this->config, $this->dn); + $this->by_object['workservice']->inheritTimeServer = false; + $this->by_object['workservice']->parent= &$this; + $this->by_object['workservice']->acl = "#all#"; + } + if((preg_match("/S/",$objects) || preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){ + $this->by_name['workstartup']= _("Startup"); + $this->by_object['workstartup']= new workstartup($this->config, $this->dn); + $this->by_object['workstartup']->parent= &$this; + $this->by_object['workstartup']->acl = "#all#"; + $this->by_name['faiSummary']= _("Summary"); + $this->by_object['faiSummary']= new faiSummaryTab($this->config, $this->dn); + $this->by_object['faiSummary']->parent= &$this; + } + + /* Add application tab if user or group is member in this object group*/ + if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['appgroup'])){ + $this->by_name['appgroup']= _("Application"); + $this->by_object['appgroup']= new appgroup($this->config, $this->dn); + $this->by_object['appgroup']->acl = "#all#"; + $this->by_object['appgroup']->parent= &$this; + } + + /* Remove application tab if not required any longer */ + if(!preg_match("/G/",$objects) && !preg_match("/U/",$objects) && isset($this->by_name['appgroup'])){ + $this->by_object['appgroup']->remove_from_parent(); + unset($this->by_name['appgroup']); + unset($this->by_object['appgroup']); + } + + /* Add environment tab if user or group is member in this object group*/ + if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['environment'])){ + $this->by_name['environment']= _("Environment"); + $this->by_object['environment']= new environment($this->config, $this->dn); + $this->by_object['environment']->acl = "#all#"; + $this->by_object['environment']->parent= &$this; + } + + /* Remove environment tab if not required any longer */ + if(!preg_match("/G/",$objects) && !preg_match("/U/",$objects) && isset($this->by_name['environment'])){ + $this->by_object['environment']->remove_from_parent(); + unset($this->by_name['environment']); + unset($this->by_object['environment']); + } + /* Move reference tab to second position from right */ + if(isset($this->by_name['acl'])){ + $tmp = $this->by_name['acl']; + unset($this->by_name['acl']); + $this->by_name['acl'] = $tmp; + } + + /* Move reference tab to last position*/ + if(isset($this->by_name['reference'])){ + $tmp = $this->by_name['reference']; + unset($this->by_name['reference']); + $this->by_name['reference'] = $tmp; + } + + /* Reset acls */ + $this->set_acl_base($this->base); + foreach($this->by_object as $name => $obj){ + $this->by_object[$name]->set_acl_category($this->acl_category); + } + } + + function execute(){ + $str = ""; + $this->by_object['ogroup']->AddDelMembership(); + $this->reload($this->by_object['ogroup']->gosaGroupObjects); + $str .= tabs::execute(); + return ( $str); + } + + function ogrouptabs($config, $data, $dn,$category ="ogroups") + { + + tabs::tabs($config, $data, $dn, $category); + $this->base= $this->by_object['ogroup']->base; + $this->acl_category = $category; + + /* Insert extra tabs for several object types - if present */ + + $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects); + + for ($n= 0; $nby_name['termgroup']= _("Terminals"); + $this->by_object['termgroup']= new termgroup($this->config, $this->dn); + $this->by_object['termgroup']->parent= &$this; + + break; + + case "U": + /* Append a PhoneQueue, if objectClass = goFonAccount */ + $use = false; + foreach($this->by_object['ogroup']->memberList as $dn => $val){ + + $obj = $this->by_object['ogroup']->objcache[$dn]; + + if(isset($obj['objectClass'])){ + if(in_array("goFonAccount",$obj['objectClass'])){ + $use = true; + } + } + } + + /* We found goFonAccount in users objectClasses*/ + if($use){ + $this->by_name['phonequeue']= _("Phone queue"); + $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn); + $this->by_object['phonequeue']->parent= &$this; + } + + /* Add a user tab used for mail distribution lists */ + if(isset($this->config->current['MAILMETHOD'])){ + if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){ + $this->by_name['mailogroup']= _("Mail"); + $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn); + $this->by_object['mailogroup']->parent= &$this; + } + } + + break; + } + } + + /* Add references/acls/snapshots */ + $this->reload($this->by_object['ogroup']->gosaGroupObjects); + $this->addSpecialTabs(); + } + + + function check($ignore_account= FALSE) + { + return (tabs::check(FALSE)); + } + + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + + /* Update reference, transfer variables */ + $baseobject= $this->by_object['ogroup']; + foreach ($this->by_object as $name => $obj){ + + /* Don't touch base object */ + if ($name != 'ogroup'){ + $obj->parent = &$this; + $obj->uid = $baseobject->uid; + $obj->cn = $baseobject->cn; + $obj->sn = $baseobject->uid; + $obj->givenName = $baseobject->uid; + $this->by_object[$name]= $obj; + } + + /* Update parent in base object */ + $this->by_object['ogroup']->parent= &$this; + } + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['ogroup']; + + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base; + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['ogroup']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + if ($this->dn == "new"){ + $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base; + } + + tabs::save(); + + /* Fix tagging if needed */ + $baseobject->dn= $new_dn; + $baseobject->handle_object_tagging(); + } + + function getCopyDialog() + { + $this->reload($this->by_object['ogroup']->gosaGroupObjects); + return(tabs::getCopyDialog()); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/ogroups/termgroup.tpl b/gosa-core/plugins/admin/ogroups/termgroup.tpl new file mode 100644 index 000000000..b35458c99 --- /dev/null +++ b/gosa-core/plugins/admin/ogroups/termgroup.tpl @@ -0,0 +1,110 @@ +
+{t}Warning{/t}: {t}Actions you choose here influence all systems in this object group. Additionally, all values editable here can be inherited by the clients assigned to this object group.{/t} +
+
+

 

+

{t}Generic{/t}

+ + + + + + + + + + + + + +
+ + + + + +

+{render acl=$gotoNtpServerACL} + +{/render} +
+{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} + +{render acl=$gotoNtpServerACL} + +{/render} +
+ + +
+ + + + + + + + + + + + +
{t}Mode{/t} +{render acl=$gotoModeACL} + +{/render} +
 
+{render acl=$gotoSyslogServerACL} + +{/render} +
+
+

 

+
+ + + + +
+ + + +

{t}Action{/t}

+ + + + + +
+{render acl=$FAIstateACL} + +{/render} + +{render acl=$FAIstateACL} + +{/render} +
+ + + + + diff --git a/gosa-core/plugins/admin/systems/ArpNewDevice.tpl b/gosa-core/plugins/admin/systems/ArpNewDevice.tpl new file mode 100644 index 000000000..8e4bf44ac --- /dev/null +++ b/gosa-core/plugins/admin/systems/ArpNewDevice.tpl @@ -0,0 +1,31 @@ +

{t}Integrating unknown devices{/t}

+

+ {t}The current device has been detected by the ARP monitor used by GOsa. You can integrate this device into your running DHCP/DNS infrastructure by submitting this form. The device entry will disapear from the list of the systems and move to the DNS/DHCP configuration.{/t} +

+ + + + + + + +
+ + + + + + + +
+
+

+{$netconfig} + + + +

diff --git a/gosa-core/plugins/admin/systems/SelectDeviceType.tpl b/gosa-core/plugins/admin/systems/SelectDeviceType.tpl new file mode 100644 index 000000000..d25acbf49 --- /dev/null +++ b/gosa-core/plugins/admin/systems/SelectDeviceType.tpl @@ -0,0 +1,46 @@ +
+

+{t}This is a new system which currently has no system type defined. Please choose a system type for this entry and press the 'continue' button. If this system should be added to a group of system settings, specify the preferred object group below.{/t} +
+
+

+

+
+{t}Please select a system type and an optional bundle of predefined settings to be inherited.{/t} +
+
+

+
+ + + + + +
+ + + + +
+ {t}System type{/t}  + +
+
+ + + + +
+ {t}Choose an object group as template{/t}  + +
+
+

 

+

+ + +

diff --git a/gosa-core/plugins/admin/systems/chooser.tpl b/gosa-core/plugins/admin/systems/chooser.tpl new file mode 100644 index 000000000..3e8bf95f9 --- /dev/null +++ b/gosa-core/plugins/admin/systems/chooser.tpl @@ -0,0 +1,21 @@ +

{t}Choose the kind of system component you want to create{/t}

+ +

+ {t}Linux terminals and workstations are autocreated on bootup. For this reason you're only be able to create templates for a specific tree. Servers are normally automatically added too, but in some special cases you may need to create a faked server entry to provide GOsa with some informations. Other network components may be used for Nagios setups to create component dependencies.{/t} +

+ +{t}Linux thin client template{/t}
+{t}Linux workstation template{/t}
+{t}Linux Server{/t}
+ +{t}Network printer{/t}
+{t}Phone{/t}
+{t}Other network component{/t}
+ +

+ +   + +

+ + diff --git a/gosa-core/plugins/admin/systems/class_ArpNewDevice.inc b/gosa-core/plugins/admin/systems/class_ArpNewDevice.inc new file mode 100644 index 000000000..79009908e --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_ArpNewDevice.inc @@ -0,0 +1,74 @@ +cn =""; + $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); + $this->acl = "#all#"; + $this->netConfigDNS->acl = $this->acl; + $this->netConfigDNS->force_dns(); + } + + function execute() + { + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $this->netConfigDNS->cn= $this->cn; + $smarty->assign("netconfig", $this->netConfigDNS->execute()); + + /* Display sub dialog from network settings */ + $this->netConfigDNS->acl = $this->acl; + if($this->netConfigDNS->dialog){ + $this->dialog = TRUE; + return($this->netConfigDNS->execute()); + }else{ + $this->dialog = FALSE; + } + + return($smarty->fetch (get_template_path('ArpNewDevice.tpl', TRUE))); + } + + function check() + { + $message= plugin::check(); + $message= array_merge($message, $this->netConfigDNS->check()); + if(empty($this->cn)){ + $message[] = _("Please specify a valid dns name."); + } + return($message); + } + + function save_object() + { + if(isset($_POST['ArpNewDevice_posted'])){ + plugin::save_object(); + $this->netConfigDNS->save_object(); + } + } + + function save() + { + $this->netConfigDNS->acl = $this->acl; + plugin::save(); + $this->netConfigDNS->cn = $this->cn; + $this->netConfigDNS->save($this->dn); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->rmdir_recursive($this->dn); + show_ldap_error($ldap->get_error(),_("Could not remove arp-alert device after writing dns and dhcp configuration.")); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_SelectDeviceType.inc b/gosa-core/plugins/admin/systems/class_SelectDeviceType.inc new file mode 100644 index 000000000..c17b8ef5f --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_SelectDeviceType.inc @@ -0,0 +1,85 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array("ObjectGroup","SystemType"); + var $objectclasses= array("whatever"); + + var $ObjectGroups = array(); + var $SystemTypes = array(); + + var $ObjectGroup = ""; + var $SystemType = ""; + + function SelectDeviceType (&$config, $dn= NULL) + { + plugin::plugin ($config, $dn); + + /* Get object groups */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn")); + $this->ObjectGroups['none']=_("none"); + while($attrs = $ldap->fetch()){ + $this->ObjectGroups[$attrs['dn']]= $attrs['cn'][0]; + } + + $this->SystemTypes =array("workstation"=>_("Workstation"), "terminal"=>_("Terminal"), "server"=>_("Server")); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $smarty->assign("ObjectGroups" ,$this->ObjectGroups); + $smarty->assign("ObjectGroupKeys" ,array_flip($this->ObjectGroups)); + $smarty->assign("SystemTypes" ,$this->SystemTypes); + $smarty->assign("SystemTypeKeys" ,array_flip($this->SystemTypes)); + + $smarty->assign("ObjectGroup",$this->ObjectGroup); + $smarty->assign("SystemType",$this->SystemType); + + $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + /* Save to LDAP */ + function save() + { + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_baseSelectDialog.inc b/gosa-core/plugins/admin/systems/class_baseSelectDialog.inc new file mode 100644 index 000000000..04275e0de --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_baseSelectDialog.inc @@ -0,0 +1,197 @@ +parent = $parent; + + $this->selectedBase = $config->current['BASE']; + $this->allowedBases = $onlyAllowThisBases; + + $this->SetTitle("Base"); + $this->SetSummary(_("Choose a base")); + $this->SetListHeader("
". + "  ". + "  ". + "  ". + "  ". + "
"); + + $this->SetInformation(_("Step in the prefered tree and click save to use the current subtree as base. Or click the image at the end of each entry.")); + + $this->EnableAplhabet (true); + $this->EnableCloseButton(true); + $this->EnableSaveButton (true); + + $this->SetSaveButtonString(_("Use")); + $this->SetCloseButtonString(_("Cancel")); + + $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>_("Base"))); + $this->AddHeader(array("string"=>_("Action"),"attach"=>"style='width:50px;border-right:0px;'")); + + /* Text ,Value ,Name ,Is selected */ +// $this->AddCheckBox("Doesnothing","servers","Doesnothing",true); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("base_selection_regex",_("Filter entries with this syntax"),"*" , true); + } + + function execute() + { + $this->setEntries(); + return($this->Draw()); + } + + function setEntries() + { + $this->ClearElementsList(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->selectedBase); + $ldap->ls("(&(objectClass=gosaDepartment) + (|(ou=".$this->base_selection_regex.") + (cn=".$this->base_selection_regex.") + (description=".$this->base_selection_regex.")))", + $this->selectedBase,array("ou","description","cn")); + + $link = "%s"; + + $base_back = preg_replace("/^[^,]+,/","",$this->selectedBase); + $base_back = convert_department_dn($base_back); + + /* Add departments, to be able to switch into them + */ + while($attrs = $ldap->fetch()){ + + $key = $attrs['dn'] ; + $val = $attrs['ou'][0]; + + if(count($this->allowedBases) != 0){ + if(!isset($this->allowedBases[$key])){ + continue; + break; + } + } + + /* Append description */ + if(isset($attrs['description'][0])){ + $val.=" [".$attrs['description'][0]."]"; + } + + /* Add missing entries ... */ + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + + /* check if this department contains sub-departments + Display different image in this case + */ + $non_empty=""; + $keys= str_replace("/","\/",$key); + foreach($this->config->departments as $keyd ){ + if(preg_match("/,".$keys."/",$keyd)){ + $non_empty="full"; + } + } + + /* Add to divlist */ + $field1 = array("string" => "department", + "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($link,base64_encode($key),$val), "attach" => "style=''"); + $field3 = array("string" => sprintf(" ",base64_encode($key)), + "attach" => "style='width:50px;border-right:0px;text-align:right;'"); + $this->AddElement(array($field1,$field2,$field3)); + } + } + + function Save() + { + MultiSelectWindow :: Save(); + $this->BaseToUse = $this->selectedBase; + } + + function isSelected() + { + return($this->BaseToUse); + } + + function setCurrentBase($base) + { + $this->selectedBase = $base; + } + + function save_object() + { + /* Save current base */ + $old_base = $this->selectedBase; + + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + + if(isset($_GET['open_dep'])){ + $this->selectedBase = base64_decode($_GET['open_dep']); + } + + $s_action =""; + foreach($_POST as $key => $value){ + if(preg_match("/^dep_back.*/i",$key)){ + $s_action="back"; + }elseif(preg_match("/^dep_root.*/",$key)){ + $s_action="root"; + }elseif(preg_match("/^dep_home.*/i",$key)){ + $s_action="home"; + }elseif(preg_match("/^usebase_/",$key)){ + $tmp = preg_replace("/^usebase_/","",$key); + $tmp = preg_replace("/_.*$/","",$tmp); + $tmp = base64_decode($tmp); + $this->BaseToUse = $tmp; + } + } + + $ui= get_userinfo(); + /* Homebutton is posted */ + if($s_action=="home"){ + $this->selectedBase=(preg_replace("/^[^,]+,/","",$ui->dn)); + $this->selectedBase=(preg_replace("/^[^,]+,/","",$this->selectedBase)); + } + + /* back to the roots ^^ */ + if($s_action=="root"){ + $this->selectedBase=($this->config->current['BASE']); + } + + /* If Backbutton is Posted */ + if($s_action=="back"){ + $base_back = preg_replace("/^[^,]+,/","",$this->selectedBase); + $base_back = convert_department_dn($base_back); + + if(isset($this->config->departments[trim($base_back)])){ + $this->selectedBase= $this->config->departments[trim($base_back)]; + }else{ + $this->selectedBase= $this->config->departments["/"]; + } + } + + /* Restore old base, if selected base is not allowed */ + if(count($this->allowedBases) && !isset($this->allowedBases[$this->selectedBase])){ + $this->selectedBase = $old_base; + } + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_componentGeneric.inc b/gosa-core/plugins/admin/systems/class_componentGeneric.inc new file mode 100644 index 000000000..8a65bdd8a --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_componentGeneric.inc @@ -0,0 +1,331 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $interfaces= array(); + var $ignore_account= TRUE; + + /* Needed values and lists */ + var $base= ""; + var $cn= ""; + var $description= ""; + var $orig_dn= ""; + + /* attribute list for save action */ + var $attributes= array("cn", "description"); + var $objectclasses= array("top", "device", "ipHost", "ieee802Device"); + var $netConfigDNS; + var $view_logged = FALSE; + + function componentGeneric (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + $this->cn= ""; + } else { + $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); + } + $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, true); + /* Save dn for later references */ + $this->orig_dn= $this->dn; + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","component/".get_class($this),$this->dn); + } + + /* Do we represent a valid phone? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no network features.").""; + return($display); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $smarty->assign("bases", $this->config->idepartments); + + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $smarty->assign("bases", $this->get_allowed_bases()); + + /* Assign attributes */ + foreach ($this->attributes as $attr){ + $smarty->assign("$attr", $this->$attr); + } + $smarty->assign("base_select", $this->base); + + /* Show main page */ + $str = $this->netConfigDNS->execute(); + if(is_object($this->netConfigDNS->dialog)){ + return($str); + } + $smarty->assign("netconfig", $str); + return($smarty->fetch (get_template_path('component.tpl', TRUE))); + } + + function set_acl_base($base) + { + plugin::set_acl_base($base); + $this->netConfigDNS->set_acl_base($base); + } + + function set_acl_category($cat) + { + plugin::set_acl_category($cat); + $this->netConfigDNS->set_acl_category($cat); + } + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + $this->netConfigDNS->remove_from_parent(); + $ldap->rmdir($this->dn); + + new log("remove","component/".get_class($this),$this->dn,$this->attributes,$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of system component/generic with dn '%s' failed."),$this->dn)); + $this->handle_post_events(array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + } + + + /* Save data to object */ + function save_object() + { + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + $this->netConfigDNS->save_object(); + + /* Set new base if allowed */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + $message= array_merge($message,$this->netConfigDNS->check()); + + $this->dn= "cn=".$this->cn.",ou=netdevices,ou=systems,".$this->base; + + if ($this->cn == "" ){ + $message[]= _("The required field 'Component name' is not set."); + } + + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn)){ + $message[] = _("Please specify a valid name for this object."); + } + + /* To check for valid ip*/ + if($this->netConfigDNS->ipHostNumber == ""){ + $message[]= _("The required field IP address is empty."); + } else { + if (!is_ip($this->netConfigDNS->ipHostNumber)){ + $message[]= _("The field IP address contains an invalid address."); + } + } + + if ($this->orig_dn != $this->dn){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->base); + $ldap->search ("(cn=".$this->cn.")", array("cn")); + if ($ldap->count() != 0){ + while ($attrs= $ldap->fetch()){ + if(preg_match("/cn=dhcp,/",$attrs['dn'])){ + continue; + } + if ($attrs['dn'] != $this->orig_dn){ + $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); + break; + } + } + } + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Remove all empty values */ + if ($this->orig_dn == 'new'){ + $attrs= array(); + foreach ($this->attrs as $key => $val){ + if (is_array($val) && count($val) == 0){ + continue; + } + $attrs[$key]= $val; + } + $this->attrs= $attrs; + } + + /* If this is a new Object IP & Mac aren't set. + IP & Mac are msut attributes, so we set this values by here. */ + if($this->orig_dn == 'new'){ + $this->attrs['ipHostNumber'] = $this->netConfigDNS->ipHostNumber; + $this->attrs['macAddress'] = $this->netConfigDNS->macAddress; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + if ($this->orig_dn == 'new'){ + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","component/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + + } else { + if ($this->orig_dn != $this->dn){ + $this->move($this->orig_dn, $this->dn); + } + + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","component/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } + + $this->netConfigDNS->cn = $this->cn; + $this->netConfigDNS->save(); + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system component/generic with dn '%s' failed."),$this->dn)); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Component generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("administration"), + "plCategory" => array("component" => array("description" => _("Network device"), + "objectClass" => array("device", "ipHost", "ieee802Device"))), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "base" => _("Base"), + "description" => _("Description")) + )); + } + + /* Display generic part for server copy & paste */ + function getCopyDialog() + { + $vars = array("cn"); + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $smarty->assign("object","component"); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + if(isset($source['macAddress'][0])){ + $this->netConfigDNS->macAddress = $source['macAddress'][0]; + } + if(isset($source['ipHostNumber'][0])){ + $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_divListRepositories.inc b/gosa-core/plugins/admin/systems/class_divListRepositories.inc new file mode 100644 index 000000000..6e43dc18c --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_divListRepositories.inc @@ -0,0 +1,84 @@ +AddCheckBox */ + var $parent ; + var $ui ; + + var $regex ="*"; + + function divListRepository ($config,$parent) + { + MultiSelectWindow::MultiSelectWindow($config,"Repository", "server"); + + $this->parent = $parent; + $this->ui = get_userinfo(); + + $this->SetTitle("repositories"); + $this->SetSummary(_("List of configured repositories.")); + $this->SetInformation(_("This menu allows you to create, delete and edit repository settings.")); + $this->EnableCloseButton(FALSE); + $this->EnableSaveButton(FALSE); + $this->AddHeader(array("string"=>_("Release"),"attach"=>"style='width:80px;'")); + $this->AddHeader(array("string"=>_("Sections"))); + $this->AddHeader(array("string"=>_("Options"),"attach"=>"style='border-right:0px;width:55px;'")); + $this->AddRegex("regex",_("Regular expression for matching object names"),"*",TRUE); + $this->EnableAplhabet(TRUE); + } + + function GenHeader() + { + if($this->parent->acl_is_createable()){ + $this->SetListHeader(""); + } + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + $link = "%s"; + $edit = " "; + + /* Hide delete icon, if delete is not allowed */ + if($this->parent->acl_is_removeable()){ + $delete = ""; + }else{ + $delete = " "; + } + + foreach($list as $name => $reps){ + + $str = " "; + if(preg_match("/".str_replace("*",".*",$this->regex)."/",$reps['Release'])){ + foreach($reps['Sections'] as $sec){ + $str.=$sec." "; + } + $this->AddElement(array( + array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"), + array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)), + array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text- align:right;'") + )); + } + } + + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow :: save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_divListSystem.inc b/gosa-core/plugins/admin/systems/class_divListSystem.inc new file mode 100644 index 000000000..61871b7a9 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_divListSystem.inc @@ -0,0 +1,468 @@ +AddCheckBox */ + var $ShowServers; + var $ShowTerminals; + var $ShowWorkstations; + var $ShowWinWorkstations; + var $ShowPrinters; + var $ShowDevices; + var $ShowPhones; + + /* Subsearch checkbox */ + var $SubSearch; + + var $parent ; + var $ui ; + + function divListSystem (&$config,$parent) + { + MultiSelectWindow::MultiSelectWindow($config, "System", array("server", + "workstation", + "terminal", + "phone", + "incoming", + "printer")); + + $this->parent = $parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of systems")); + $this->SetSummary(_("List of systems")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to add, remove and change the properties of specific systems. You can only add systems which have already been started once.")); + + $this->EnableAplhabet (true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 110; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>_("System / Department"))); + $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'")); + + /* Text ,Value ,Name ,Is selected */ + $this->AddCheckBox("ShowServers", _("Select to see servers"), _("Show servers"), true); + $this->AddCheckBox("ShowTerminals", _("Select to see Linux terminals"), _("Show terminals") , true); + $this->AddCheckBox("ShowWorkstations", _("Select to see Linux workstations"), _("Show workstations"), true); + $this->AddCheckBox("ShowWinWorkstations", _("Select to see MicroSoft Windows based workstations"), _("Show windows based workstations"),true); + $this->AddCheckBox("ShowPrinters", _("Select to see network printers"), _("Show network printers") ,true); + $this->AddCheckBox("ShowPhones", _("Select to see VOIP phones"), _("Show phones") , true); + $this->AddCheckBox("ShowDevices", _("Select to see network devices"), _("Show network devices"), true); + + /* Add SubSearch checkbox */ + $this->AddCheckBox(SEPERATOR); + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Display systems matching"),"*" , true); + $this->AddRegex ("UserRegex", _("Display systems of user"), "*" , false, "images/search_user.png"); + } + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $department = $departments = array(); + foreach($this->module as $module){ + $d = $ui->get_module_departments($module); + foreach($d as $department){ + $departments[$department] = $department; + } + } + + /* Load possible departments */ + $ui= get_userinfo(); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $departments)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* If there is at least one c (Create) and one w (Write) acl in this combination + display the snapshot paste icon. BUT check the correct acls in the management plugin */ + $all_module_acls = ""; + foreach($this->module as $module){ + $all_module_acls .= $ui->has_complete_category_acls($this->selectedBase,$module); + } + + /* Must we add an additional seperator */ + $add_sep = false; + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* Add base selection */ + $listhead .= _("Base")."  ". + "  "; + + /* Handle create icons */ + $s = ".|"._("Actions")."|\n"; + $s.= "..|". + " "._("Create")."|\n"; + if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"terminal/termgeneric"))){ + $s.= "...|". + " "._("Terminal")."|"."newsystem_terminal|\n"; + } + if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"workstation/workgeneric"))){ + $s.= "...|". + " "._("Workstation")."|"."newsystem_workstation|\n"; + } + if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"workstation/workgeneric"))){ + $s.= "...|". + " "._("Server")."|"."newsystem_server|\n"; + } + if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"phone/phoneGeneric"))){ + $s.= "...|". + " "._("Phone")."|"."newsystem_phone|\n"; + } + if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"printer/printgeneric"))){ + $s.= "...|". + " "._("Printer")."|"."newsystem_printer|\n"; + } + if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"component/componentGeneric"))){ + $s.= "...|". + " "._("Component")."|"."newsystem_component|\n"; + } + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + } + + /* Get copy & paste icon */ + $Copy_Paste =""; + if(preg_match("/(c.*w|w.*c)/",$all_module_acls) && $this->parent->CopyPasteHandler){ + $s .= "..|---|\n"; + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$all_module_acls)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($terminals) + { + $img1 = "C"; + $img2 = "L"; + $img3 = "L"; + $img4 = "M"; + $img5 = "I"; + $img6 = "F"; + $img7 = "K"; + $img8 = "A"; + $img9 = "F"; + $img10 = "L"; + + $empty =""; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 110; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + // User and Template Images + $editlink = "%s"; + + /* ACL mapping */ + $ui = get_userinfo(); + $tabs = array( + "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"), + "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"), + "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"), + "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"), + "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"), + "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"), + "incoming" => array("CLASS"=>"", "TABCLASS" =>"", "ACL"=> "incoming/systems"), + "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric")); + + + $cnts = array("component" => 0 , "terminal" => 0 , "workstation" => 0 , + "printer" => 0 , "phone" => 0 , "server" => 0, + "NewDevice" => 0, "winstation"=> 0); + + // Test Every Entry and generate divlist Array + foreach($terminals as $key => $val){ + + /* Get system type, it is used to fetch the acls for the current object. + "winstation" acls are stored as 2winworkstation", so we have to map this here */ + $type = $this->parent->get_system_type($val); + if($type == "winstation") { + $acl_type = "winworkstation"; + }else{ + $acl_type = $type; + } + + /* Map NewDevice acls to workstation acls */ + if($type == "NewDevice" || $type == "ArpNewDevice"){ + $type = "incoming"; + $acl_type = "incoming"; + } + + /* Get complete category acls */ + $acl_all = $ui->has_complete_category_acls($val['dn'],$acl_type) ; + + /* Get specific generic acls */ + $acl = $ui->get_permissions($val['dn'],$tabs[$type]['ACL']); + + $action =""; + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $action.= " "; + $action.= " "; + } + $action.= ""; + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $action.= $this->GetSnapShotActions($val['dn']); + }else{ + $action.= $empty." ".$empty." "; + } + + + if(preg_match("/d/",$acl)){ + $action.= ""; + }else{ + $action.= $empty; + } + + /* Generate picture list, which is currently disabled */ + if(in_array("goCupsServer" ,$val['objectClass'])) $cups = $img1; else $cups =$empty; + if(in_array("goLogDBServer" ,$val['objectClass'])) $logdb = $img2; else $logdb =$empty; + if(in_array("goSyslogServer" ,$val['objectClass'])) $syslog = $img3; else $syslog=$empty; + if(in_array("goImapServer" ,$val['objectClass'])) $imap = $img4; else $imap =$empty; + if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba = $img5; else $samba =$empty; + if(in_array("goShareServer" ,$val['objectClass'])) $nfs = $img6; else $nfs =$empty; + if(in_array("goKrbServer" ,$val['objectClass'])) $krb = $img7; else $krb =$empty; + if(in_array("goFonServer" ,$val['objectClass'])) $fon = $img8; else $fon =$empty; + if(in_array("goFaxServer" ,$val['objectClass'])) $fax = $img9; else $fax =$empty; + if(in_array("goLdapServer" ,$val['objectClass'])) $ldap = $img10; else $ldap =$empty; + + $pics = $cups.$logdb.$syslog.$imap.$samba.$nfs.$krb.$fon.$fax.$ldap; + $pics = ""; // Pictures currently hidden + + $val['cn'][0]= preg_replace('/\$$/', '', $val['cn'][0]); + + // Generate Array to Add + $dsc= ""; + if (isset($val['description'][0])){ + $dsc= " [".$val['description'][0]."]"; + } + if((isset($val['is_new']))&&(!empty($val['is_new']))){ + $display= $val["cn"][0]." ".$val['is_new'].$dsc; + }else{ + $display= $val["cn"][0].$dsc; + } + + + /* Check if this is a terminal/workstation && if we are allowed to change the gotoRootPasswd */ + $pwd_acl =""; + if(in_array("gotoWorkstation",$val['objectClass'])){ + $pwd_acl = $ui->get_permissions($val['dn'],"workstation/workgeneric","gotoRootPasswd"); + } + if(in_array("gotoTerminal",$val['objectClass'])){ + $pwd_acl = $ui->get_permissions($val['dn'],"terminal/termgeneric","gotoRootPasswd"); + } + if(preg_match("/w/",$pwd_acl)){ + $action2 = ""; + }else{ + $action2 = $empty; + } + + + if(in_array("gotoWorkstation",$val['objectClass'])){ + $action2= " ".$action2; + }else{ + $action2= $empty.$action2; + } + + if(isset($val['message'])){ + $display.= " (".$val['message'].")"; + } + + $img = $this->parent->convert_list($val); + + /* Cutted objects should be displayed in light grey */ + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + $type = $this->parent->get_system_type($val); + if($type == "ArpNewDevice"){ + $type = "NewDevice"; + } + $cnts[$type] ++; + + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + + $field1 = array("string" => sprintf($img['img'],$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); + $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action2.$action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + $this->AddElement( array($field0,$field1,$field2,$field3)); + } + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + + $num_ser_str = _("Number of listed servers"); + $num_ws_str = _("Number of listed workstations"); + $num_ter_str = _("Number of listed terminals"); + $num_pho_str = _("Number of listed phones"); + $num_prt_str = _("Number of listed printers"); + $num_com_str = _("Number of listed network components"); + $num_new_str = _("Number of listed new devices"); + $num_wws_str = _("Number of listed windows workstations"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_ser_str." ".$cnts['server']."    "; + $str.= "".$num_ws_str." ".$cnts['workstation']."    "; + $str.= "".$num_ter_str." ".$cnts['terminal']."    "; + $str.= "".$num_pho_str." ".$cnts['phone']."    "; + $str.= "".$num_prt_str." ".$cnts['printer']."    "; + $str.= "".$num_com_str." ".$cnts['component']."    "; + $str.= "".$num_new_str." ".$cnts['NewDevice']."    "; + $str.= "".$num_wws_str." ".$cnts['winstation']."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + } + + + function Save() + { + MultiSelectWindow :: Save(); + } + + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow :: save_object(); + + + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_divListSystemService.inc b/gosa-core/plugins/admin/systems/class_divListSystemService.inc new file mode 100644 index 000000000..ca31601ba --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_divListSystemService.inc @@ -0,0 +1,152 @@ +AddCheckBox */ + var $parent ; + var $ui ; + + function divListSystemService ($config,$parent) + { + MultiSelectWindow::MultiSelectWindow($config,"SystemService", "server"); + + $this->parent = $parent; + $this->ui = get_userinfo(); + $this->EnableJSLeaveMsg(TRUE); + + /* Set list strings */ + $this->SetTitle(_("Installed services")); + $this->SetSummary(_("Installed services")); + + /* Result page will look like a headpage */ + $this->SetInformation(_("This menu allows you to add, remove and configure the properties of a specific service.")); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* set Page header */ + $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>_("Service name"))); + $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:100px;border-right:0px;'")); + $this->HideFilterPart(); + } + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $listhead = "
". + "  ". + "  ". + "  ". + "  ". + "  ". + "
"; + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + $tmp = array(); + foreach($list as $name => $entry){ + $tmp[$name] = $entry['Message']; + } + + natcasesort($tmp); + $tmp2 = array(); + foreach($tmp as $name => $value){ + $tmp2[$name] = $list[$name]; + } + + $ui = get_userinfo(); + + foreach($tmp2 as $name => $entry){ + + switch($entry['Status']){ + case '' : $str =" ";break; + case SERVICE_STOPPED : $str =""; break; + case SERVICE_STARTED : $str =""; break; + case SERVICE_RESTARTED : $str ="R"; break; + default: $str= "".$entry["; + } + + /* Get acls */ + $acl = $ui->get_permissions($this->parent->dn,"server/".$name); + if(preg_match("/w/i",$acl) && !preg_match("/r/i",$acl)){ + continue; + } + + $WasAccount = $this->parent->plugins[$name] -> initially_was_account; + + $plug = $_GET['plug']; + $link = "".$entry['Message'].""; + + $field1 = array("string" => $str ,"attach" => "style='width:20px;'"); + $field2 = array("string" => $link); + + $actions =""; + if($entry['AllowStart'] && $WasAccount){ + $actions .= " "; + }else{ + $actions .= " "; + } + if($entry['AllowStart'] && $WasAccount){ + $actions .= " "; + }else{ + $actions .= " "; + } + if($entry['AllowStart'] && $WasAccount){ + $actions .= " "; + }else{ + $actions .= " "; + } + + /* Check if edit is enabled and allowed for current service */ + if($entry['AllowEdit'] && preg_match("/(r|w)/i",$acl)){ + $actions .= " "; + }else{ + $actions .= " "; + } + + /* Check if remove is enabled and allowed for current service */ + if($entry['AllowRemove'] && preg_match("/d/i",$acl)){ + $actions .= " "; + }else{ + $actions .= " "; + } + + $field3 = array("string" => $actions ,"attach" => "style='width:100px;border-right:0px;'"); + $this->AddElement(array($field1,$field2,$field3)); + } + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow :: save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_phoneGeneric.inc b/gosa-core/plugins/admin/systems/class_phoneGeneric.inc new file mode 100644 index 000000000..f169c0ec7 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_phoneGeneric.inc @@ -0,0 +1,521 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $interfaces= array(); + var $ignore_account= TRUE; + + /* Needed values and lists */ + var $base = ""; + var $cn = ""; + var $description = ""; + var $orig_dn = ""; + var $goFonType = ""; + var $goFonDmtfMode = ""; + var $goFonHost = ""; + var $goFonDefaultIP = "dynamic"; + var $goFonQualify = ""; + var $goFonAuth = ""; + var $goFonSecret = ""; + var $goFonInkeys = ""; + var $goFonPermit = array(); + var $goFonDeny = array(); + var $goFonOutkey = ""; + var $goFonTrunk = ""; + var $goFonAccountCode = ""; + var $goFonMSN = ""; + var $selected_categorie = 0; + var $netConfigDNS; + var $view_logged = FALSE; + + /* attribute list for save action */ + var $attributes= array("cn", "description", + "goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP", + "goFonQualify","goFonAuth","goFonSecret","goFonInkeys","goFonOutkey", + "goFonTrunk","goFonAccountCode","goFonMSN","selected_categorie","goFonPermit","goFonDeny" + ); + + /* this array defines which attributes are schown / saved for the different type of phones */ + var $usedattrs = array( "0"=>array("cn", "description", + "goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP", + "goFonQualify"), + "1"=>array("cn", "description", + "goFonType","goFonHost","goFonDefaultIP", + "goFonQualify","goFonAuth","goFonSecret","goFonInkeys","goFonOutkey", + "goFonTrunk","goFonAccountCode","selected_categorie","goFonPermit","goFonDeny"), + "2"=>array("cn", "description", "goFonMSN")); + + + var $objectclasses= array("top", "goFonHardware"); + + function phoneGeneric (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, true); + + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + $this->cn= ""; + } else { + $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); + } + + if($this->goFonMSN != ""){ + $this->selected_categorie = 2; + }elseif($this->goFonAccountCode != ""){ + $this->selected_categorie = 1 ; + + if(isset($this->attrs['goFonPermit']['count'])){ + unset ($this->attrs['goFonPermit']['count']); + $this->goFonPermit=$this->attrs['goFonPermit']; + } + + if(isset($this->attrs['goFonDeny']['count'])){ + unset ($this->attrs['goFonDeny']['count']) ; + $this->goFonDeny=$this->attrs['goFonDeny']; + } + + } else { + $this->selected_categorie = 0; + } + + if($this->goFonDefaultIP!="dynamic"){ + $this->goFonDefaultIP = "network"; + } + + /* Save dn for later references */ + $this->orig_dn= $this->dn; + } + + function set_acl_base($base) + { + plugin::set_acl_base($base); + $this->netConfigDNS->set_acl_base($base); + } + + function set_acl_category($cat) + { + plugin::set_acl_category($cat); + $this->netConfigDNS->set_acl_category($cat); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","phone/".get_class($this),$this->dn); + } + + /* Do we represent a valid phone? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no phone features.").""; + return($display); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* handle Permit Add*/ + if(isset($_POST['goFonPermitAdd']) && $this->acl_is_writeable("goFonPermit")){ + if(isset($_POST['goFonPermitNew'])){ + if(is_string($this->goFonPermit)){ + $this->goFonPermit=array(); + } + $new = $_POST['goFonPermitNew']; + if(strlen($new)> 1) { + $this->goFonPermit[]= $new; + } + } + } + + /* handle Deny Add*/ + if(isset($_POST['goFonDenyAdd']) && $this->acl_is_writeable("goFonDeny")){ + if(isset($_POST['goFonDenyNew'])){ + if(is_string($this->goFonDeny)){ + $this->goFonDeny=array(); + } + $new = $_POST['goFonDenyNew']; + if(strlen($new)> 1) { + $this->goFonDeny[]= $new; + } + } + } + + /* Handle Permit Deletion*/ + if(isset($_POST['goFonPermitDel']) && $this->acl_is_writeable("goFonPermit")){ + if(isset($_POST['goFonPermitS'])){ + if(is_string($this->goFonPermit)){ + $this->goFonPermit=array(); + } + $new = $_POST['goFonPermitS']; + $tmp = array_flip($this->goFonPermit); + unset($tmp[$new]); + $this->goFonPermit=array(); + foreach(array_flip($tmp) as $tm){ + $this->goFonPermit[]=$tm; + } + } + } + + + /* Handle Permit Deletion*/ + if(isset($_POST['goFonDenyDel']) && $this->acl_is_writeable("goFonDeny")){ + if(isset($_POST['goFonDenyS'])){ + if(is_string($this->goFonDeny)){ + $this->goFonDeny=array(); + } + $new = $_POST['goFonDenyS']; + $tmp = array_flip($this->goFonDeny); + unset($tmp[$new]); + $this->goFonDeny=array(); + foreach(array_flip($tmp) as $tm){ + $this->goFonDeny[]=$tm; + } + } + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + + $smarty->assign("bases", $this->get_allowed_bases()); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $smarty->assign("staticAddress","*");// $this->config->idepartments); + + /* Create Arrays for samrty select boxes */ + $smarty->assign("categories", array("SIP","IAX","CAPI")); + $smarty->assign("goFonTypes", array("peer" =>"peer" ,"user" =>"user" ,"friend" =>"friend")); + $smarty->assign("goFonDmtfModes", array("inband" =>"inband" ,"rfc2833"=>"rfc2833" ,"info" =>"info")); + $smarty->assign("goFonAuths", array("plaintext" =>"plaintext" ,"md5" =>"md5" /*,"rsa" =>"rsa"*/)); + $smarty->assign("goFonTrunks", array("yes" =>_("yes") ,"no" => _("no"))); + + /* deativate all fields that are not used by the specified type */ + foreach($this->attributes as $att){ + if((!in_array($att,$this->usedattrs[$this->selected_categorie]))){ + $smarty->assign($att."USED", "disabled" ); + $smarty->assign($att, ""); + }else{ + $smarty->assign($att."USED", "" ); + $smarty->assign($att, $this->$att); + } + } + + $smarty->assign("selected_categorie",$this->selected_categorie); + + /* Assign attributes */ + $smarty->assign("base_select", $this->base); + $smarty->assign("goFonDefaultIPs",array("dynamic"=>_("dynamic"),"network"=>_("Networksettings"))); + + /* Show main page */ + $str = $this->netConfigDNS->execute(); + if(is_object($this->netConfigDNS->dialog)){ + return($str); + } + $smarty->assign("netconfig", $str); + $smarty->assign("phonesettings", dirname(__FILE__)."/phonesettings.tpl"); + return($smarty->fetch (get_template_path('phone.tpl', TRUE))); + } + + function remove_from_parent() + { + if($this->acl_is_removeable()){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + $ldap->search ("(&(objectClass=goFonAccount)(goFonHardware=".$this->cn."))", array("uid","cn")); + while ($attr = $ldap->fetch()){ + print_red(sprintf(_("Can't delete because there are users which are depending on this phone. One of them is user '%s'."), + ($attr['uid'][0]." - ".$attr['cn'][0]))); + return; + } + + $this->netConfigDNS->remove_from_parent(); + $ldap->rmdir($this->dn); + + new log("remove","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of system phone/generic with dn '%s' failed."),$this->dn)); + $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + } + } + + + /* Save data to object */ + function save_object() + { + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + $this->netConfigDNS->save_object(); + + /* Set new base if allowed */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + $message= array_merge($message, $this->netConfigDNS->check()); + + $this->dn= "cn=".$this->cn.",ou=phones,ou=systems,".$this->base; + + /* To check for valid ip*/ + if($this->netConfigDNS->ipHostNumber == ""){ + $message[]= _("The required field IP address is empty."); + } else { + if (!is_ip($this->netConfigDNS->ipHostNumber)){ + $message[]= _("The field IP address contains an invalid address."); + } + } + + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) ){ + $message[] = _("Please specify a valid name for this object."); + } + + if ($this->cn == ""){ + $message[]= _("The required field 'Phone name' is not set."); + } + if ($this->cn == "0"){ + $message[]= _("The 'Phone name' '0' is reserved and cannot be used."); + } + + if ($this->orig_dn != $this->dn){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->base); + $ldap->search ("(cn=".$this->cn.")", array("cn")); + if ($ldap->count() != 0){ + while ($attrs= $ldap->fetch()){ + + if(preg_match("/cn=dhcp,/",$attrs['dn'])){ + continue; + } + + if ($attrs['dn'] != $this->orig_dn){ + $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); + break; + } + } + } + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + + /* only to define which attrs to save*/ + $mode = $this->selected_categorie; + + /* Remove all unwanted attrs */ + foreach($this->attributes as $att){ + + /* Check all attributes, if they are needed for this type of phone */ + if(!in_array($att,$this->usedattrs[$mode])){ + $this->attrs[$att] = array(); + } + } + + /* unset the categorie*/ + unset($this->attrs['selected_categorie']); + + /* Remove all empty values */ + if ($this->orig_dn == 'new'){ + $attrs= array(); + foreach ($this->attrs as $key => $val){ + if (is_array($val) && count($val) == 0){ + continue; + } + $attrs[$key]= $val; + } + $this->attrs= $attrs; + } + + if($this->goFonDefaultIP!="dynamic"){ + $this->attrs['goFonDefaultIP'] = $this->netConfigDNS->ipHostNumber; + } + + $this->attrs = $this->netConfigDNS->getVarsForSaving($this->attrs); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + if ($this->orig_dn == 'new'){ + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } else { + if ($this->orig_dn != $this->dn){ + $this->move($this->orig_dn, $this->dn); + } + + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + // $user_phone_reload + $ldap->cd ($this->config->current['BASE']); + $user_phone_assignment = $ldap->fetch($ldap->search("(&(objectClass=goFonAccount)(goFonHardware=".$this->cn."))",array("uid"))); + if($user_phone_assignment){ + $usertab= new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $user_phone_assignment['dn']); + $usertab->by_object['phoneAccount']->is_modified = true; + $usertab->save(); + unset($usertab); + } + $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } + $this->netConfigDNS->cn = $this->cn; + $this->netConfigDNS->save(); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system phone/generic with dn '%s' failed."),$this->dn)); + } + + + /* Display generic part for server copy & paste */ + function getCopyDialog() + { + $vars = array("cn"); + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $smarty->assign("object","phone"); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + if(isset($source['macAddress'][0])){ + $this->netConfigDNS->macAddress = $source['macAddress'][0]; + } + if(isset($source['ipHostNumber'][0])){ + $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; + } + + $source_o = new phoneGeneric($this->config, $source['dn']); + $this->selected_categorie = $source_o->selected_categorie; + } + + + /* Return plugin informations for acl handling + #FIXME FAIscript seams to ununsed within this class... */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Phone generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("phone" => array("description" => _("Phone hardware"), + "objectClass" => "goFonHardware")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "base" => _("Base"), + "description" => _("Description"), + "goFonType" => _("SIP Mode"), + "goFonDmtfMode" => _("SIP DTMF mode"), + "goFonDefaultIP" => _("SIP Default ip"), + "goFonQualify" => _("SIP Qualify"), + "goFonAuth" => _("IAX authentication type"), + "goFonSecret" => _("IAX secret"), + "goFonAccountCode" => _("IAX account code"), + "goFonTrunk" => _("IAX trunk lines"), + "goFonPermit" => _("IAX permit settings"), + "goFonDeny" => _("IAX deny settings"), + "goFonMSN" => _("CAPI MSN"), + "categorie" => _("Hardware type")) + )); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_printGeneric.inc b/gosa-core/plugins/admin/systems/class_printGeneric.inc new file mode 100644 index 000000000..54092c670 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_printGeneric.inc @@ -0,0 +1,1048 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $interfaces = array(); + var $ignore_account = FALSE; + + /* Needed values and lists */ + var $base = ""; + var $cn = ""; + var $l = ""; + var $description = ""; + var $labeledURI = ""; + var $gotoPrinterPPD = ""; + var $initial_PPD = ""; + var $orig_dn = ""; + + var $UserMember =""; + var $UserMembers =array(); + var $UserMemberKeys =array(); + + var $AdminMember =""; + var $AdminMembers =array(); + var $AdminMemberKeys =array(); + + var $PPDdialogToSave = NULL; + var $BelongsTo = "unknown"; // Specifies if this is a standalone printer, or belongs to a terminal / WS + + var $member =array(); + var $strings = ""; + var $netConfigDNS; + var $baseSelection = false; + var $macAddress = ""; + + var $gotoUserAdminPrinter; + var $gotoGroupAdminPrinter ; + var $gotoGroupPrinter; + var $gotoUserPrinter ; + + /* attribute list for save action */ + var $attributes = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress", + "gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter","gotoGroupPrinter"); + var $objectclasses = array("top", "gotoPrinter"); + var $view_logged = FALSE; + var $parent; + + function printgeneric (&$config, $dn,$parent_init,$parent) + { + $this->config = &$config; + $this->dn = $dn; + + /* If parent was posted(the tabs object) we can detect the printer type. */ + if($parent){ + $this->parent = $parent; + $this->getTypeOfPrinter(); + }else{ + $this->BelongsTo = "unknown"; + return; + } + + /* Update dn, to ensure storing as printer instead of WS / terminal */ + if(preg_match("/Terminal/i",$this->BelongsTo) || preg_match("/TerminalTemplate/i",$this->BelongsTo)){ + $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); + } + + if(preg_match("/Workstation/i",$this->BelongsTo) || preg_match("/WorkstationTemplate/i",$this->BelongsTo)){ + $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); + } + + $this->orig_dn = $this->dn; + + /* Get printer settings, possibly dn has changed */ + plugin::plugin ($config, $this->dn); + + /* Get is_account initially_was_account status */ + $this->getTypeOfPrinter(true); + + /* set orig dn to new if object is new */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('dn')); + if(!$ldap->count()){ + $this->orig_dn = "new"; + } + + /* create dns object */ + $this->netConfigDNS = new termDNS($this->config, $this,$this->objectclasses); + + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + $this->cn= ""; + } else { + + /* Set base and check if the extracted base exists */ + if(preg_match("/ou=incoming,/",$this->dn)){ + $this->base= preg_replace("/ou=incoming,/","",dn2base($this->dn)); + }else{ + $this->base= preg_replace("/ou=printers,ou=systems,/","",dn2base($this->dn)); + } + + if(!isset($this->config->idepartments[$this->base])){ + print_red(_("Can't extract a valid base out of object dn, setting base to '%s'."),$_SESSION['CurrentMainBase']); + $this->base = $_SESSION['CurrentMainBase']; + } + } + + /* Extract selected ppd */ + if(isset($this->gotoPrinterPPD)){ + $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD); + } + + $this->initial_PPD = $this->gotoPrinterPPD; + + /* Prepare different member types */ + foreach(array("AddUser" =>"gotoUserPrinter", + "AddGroup" =>"gotoGroupPrinter", + "AddAdminUser" =>"gotoUserAdminPrinter", + "AddAdminGroup" =>"gotoGroupAdminPrinter") as $type => $attr){ + + /* $this->members contains all members */ + $this->member[$type]=array(); + + if (isset($this->attrs[$attr]['count'])) { + unset($this->attrs[$attr]['count']); + } + + if(isset($this->attrs[$attr])){ + foreach($this->attrs[$attr] as $mem){ + if(preg_match("/Group/",$type)){ + $ldap->search("(&(objectClass=posixGroup)(cn=".$mem."))",array("cn","description")); + if($ldap->count()){ + $entry = $ldap->fetch(); + $this->member[$type][$entry['cn'][0]]=$entry; + } + }else{ + $ldap->search("(&(objectClass=person)(objectClass=inetOrgPerson)(uid=".$mem."))",array("cn","uid")); + if($ldap->count()){ + $entry = $ldap->fetch(); + $this->member[$type][$entry['uid'][0]]=$entry; + } + } + } + } + } + } + + function set_acl_base($base) + { + plugin::set_acl_base($base); + if(is_object($this->netConfigDNS)){ + $this->netConfigDNS->set_acl_base($base); + } + } + + function set_acl_category($cat) + { + plugin::set_acl_category($cat); + if(is_object($this->netConfigDNS)){ + $this->netConfigDNS->set_acl_category($cat); + } + } + + /* Detect type of printer. + * Printer can be stand alone, belong to a workstation or belong to a terminal. + * We can detect the type printer type when comparing the tabs objects + */ + function getTypeOfPrinter($UpdateAccountStatus = false) + { + /* Disable account as default + */ + $this->is_account = $this->initially_was_account = false; + + /* Detect type of printer via parent tabs. + */ + + $class = get_class($this->parent); + if(isset($this->parent->by_object['workgeneric'])){ + + /* Exclude templates + */ + $this->cn = $this->parent->by_object['workgeneric']->cn; + if($this->parent->by_object['workgeneric']->cn == "wdefault"){ + $this->BelongsTo = "WorkstationTemplate"; + }else{ + $this->BelongsTo = "Workstation"; + } + }elseif(isset($this->parent->by_object['termgeneric'])){ + + /* Exclude templates + */ + $this->cn = $this->parent->by_object['termgeneric']->cn; + if($this->parent->by_object['termgeneric']->cn == "default"){ + $this->BelongsTo = "TerminalTemplate"; + }else{ + $this->BelongsTo = "Terminal"; + } + }elseif(isset($this->parent->by_name['printgeneric'])){ + $this->BelongsTo = "Printer"; + } + + if($UpdateAccountStatus){ + + /* Set is_account / was account + */ + if($this->dn == "new"){ + $this->initially_was_account = false; + } + + /* If is printer it must be a true account. + */ + if(preg_match("/printer/i",$this->BelongsTo)){ + $this->is_account = true; + } + + /* Update dn, to ensure storing as printer instead of WS / terminal + */ + if(preg_match("/terminal/i",$this->BelongsTo)){ + $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); + } + + if(preg_match("/workstation/i",$this->BelongsTo)){ + $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); + } + + /* Detect if this is a valid printer account; + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('objectClass')); + + if($ldap->count()){ + $attrs = $ldap->fetch(); + if(in_array("gotoPrinter",$attrs['objectClass'])){ + $this->initially_was_account = true; + $this->is_account = true; + }else{ + $this->is_account = false; + } + } + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","printer/".get_class($this),$this->dn); + } + + + /* If type of printer couldn't be detected (because of missing parent object in construction) + * hide this tab. + */ + if(preg_match("/unknown/i",$this->BelongsTo)){ + $display= $this->show_enable_header(_("Add printer extension"), + _("Could not initialize printer tab, parameter parent was missing while construction."),TRUE,TRUE); + return($display); + } + + /* Templates can't have printer extensions + */ + if(preg_match("/WorkstationTemplate/i",$this->BelongsTo)){ + $display= $this->show_enable_header(_("Add printer extension"), + _("This is a workstation template, printer tab is disabled."),TRUE,TRUE); + return($display); + } + if(preg_match("/TerminalTemplate/i",$this->BelongsTo)){ + $display= $this->show_enable_header(_("Add printer extension"), + _("This is a terminal template, printer tab is disabled."),TRUE,TRUE); + return($display); + } + + /* Get cn from base object */ + if(preg_match("/^Workstation$/i",$this->BelongsTo)){ + $this->cn = $this->parent->by_object['workgeneric']->cn; + } + if(preg_match("/^Terminal$/i",$this->BelongsTo)){ + $this->cn = $this->parent->by_object['termgeneric']->cn; + } + + $smarty= get_smarty(); + + /* Assign acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL", $this->getacl($name)); + } + + $display=""; + + /* Tell smarty if this is a standalone object or a terminal / WS depending printer */ + if(preg_match("/^Printer$/i",$this->BelongsTo)){ + $smarty->assign("StandAlone",true); + }else{ + $smarty->assign("StandAlone",false); + } + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Do we represent a valid printer? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no printer features.").""; + return($display); + } + + /* If this is a WS / Terminal depending printer, display account state button */ + if(!preg_match("/^Printer$/i",$this->BelongsTo)){ + if((empty($this->cn)) && ($this->dn != "new")){ + $display= $this->show_enable_header(_("Add printer extension"), + _("This object has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE); + $this->is_account= false; + return $display; + } + + if (($this->is_account)){ + if(preg_match("/^Workstation$/i",$this->BelongsTo)){ + $display= $this->show_disable_header(_("Remove printer extension"), + _("This workstation has printer extension enabled.You can disable it by clicking below.")); + }elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){ + $display= $this->show_disable_header(_("Remove printer extension"), + _("This terminal has printer extension enabled. You can disable it by clicking below.")); + } + }else{ + if(preg_match("/^Workstation$/i",$this->BelongsTo)){ + $display= $this->show_disable_header(_("Add printer extension"), + _("This workstation has printer extension disabled. You can enable it by clicking below.")); + }elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){ + $display= $this->show_enable_header(_("Add printer extension"), + _("This terminal has printer extension disabled. You can enable it by clicking below.")); + } + return ($display); + } + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + $this->baseSelection = true; + } + } + + /* Dialog handling for base select dialog + * Check if base was selected, dialog aborted etc */ + if(is_object($this->dialog)){ + + $this->dialog->save_object(); + if($this->baseSelection){ + if($this->dialog->isClosed()){ + $this->dialog = false; + $this->baseSelection = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + + $this->dialog= false; + $this->baseSelection = false; + }else{ + return($this->dialog->execute()); + } + } + } + + /* Fill templating stuff */ + $smarty->assign("bases", $this->get_allowed_bases()); + $smarty->assign("base_select", $this->base); + + /* Assign attributes */ + foreach ($this->attributes as $attr){ + $smarty->assign("$attr", $this->$attr); + } + + if(isset($_POST['AddUser'])){ + $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddUser"); + } + if(isset($_POST['AddGroup'])){ + $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddGroup"); + } + if(isset($_POST['AddAdminUser'])){ + $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminUser"); + } + if(isset($_POST['AddAdminGroup'])){ + $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminGroup"); + } + + /* Display ppd configure/select dialog */ + if(isset($_POST['EditDriver'])){ + if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){ + $this->dialog = $this->PPDdialogToSave; + }else{ + $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); + $this->dialog->cn= $this->cn; + } + } + + /* remove ppd */ + if(isset($_POST['RemoveDriver'])){ + $this->gotoPrinterPPD = array(); + $this->PPDdialogToSave = NULL; + } + + /* Close ppd dialog */ + if(isset($_POST['ClosePPD'])){ + unset($this->dialog); + $this->dialog=FALSE; + } + + /* Save selected ppd */ + if(isset($_POST['SavePPD'])){ + $this->dialog->save_object(); + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msg){ + print_red($msg); + } + }else{ + $this->gotoPrinterPPD = array(); + $this->gotoPrinterPPD = $this->dialog->save(); + $this->PPDdialogToSave = $this->dialog; + unset($this->dialog); + $this->dialog=FALSE; + } + } + + /* Member management, delete user / group / admin ..*/ + if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){ + foreach($_POST['UserMember'] as $mem){ + $this->DelMember('AddUser',$mem); + } + } + + if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){ + foreach($_POST['UserMember'] as $mem){ + $this->DelMember('AddGroup',$mem); + } + } + + if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){ + foreach($_POST['AdminMember'] as $mem){ + $this->DelMember('AddAdminUser',$mem); + } + } + + if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){ + foreach($_POST['AdminMember'] as $mem){ + $this->DelMember('AddAdminGroup',$mem); + } + } + + /* Abort user / group adding dialog */ + if(isset($_POST['PrinterCancel'])){ + unset($this->dialog); + $this->dialog= FALSE; + } + + /* Save selected users / groups */ + if(isset($_POST['PrinterSave'])){ + $this->dialog->save_object(); + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msg){ + print_red($msg); + } + }else{ + $data= $new = $this->dialog->save(); + unset($data['type']); + foreach($data as $mem){ + $this->AddMember($new['type'], $mem['dn']); + } + unset($this->dialog); + $this->dialog=FALSE; + } + } + + /* Display dialog, if there is currently one open*/ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return $display; + } + + /* Parse selected ppd file */ + if((isset($_SESSION['config']->data['MAIN']['PPD_PATH']))&&(is_dir($_SESSION['config']->data['MAIN']['PPD_PATH']))){ + + $path = $_SESSION['config']->data['MAIN']['PPD_PATH']; + if(!preg_match("/\/$/",$path)){ + $path = $path."/"; + } + + $ppdManager= new ppdManager($path); + if(!empty($this->gotoPrinterPPD)){ + if((!file_exists($path.$this->gotoPrinterPPD))){ + $smarty->assign("driverInfo", "".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD).""); + }else{ + $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD)); + } + }else{ + $smarty->assign("driverInfo", _("Not defined")); + } + }else{ + $smarty->assign("driverInfo",_("Can't get ppd informations.")); + } + + /* Create user & admin user list */ + $list=$this->generateList(); + $userlist = array_merge($list['AddUser'],$list['AddGroup']); + $adminlist = array_merge($list['AddAdminUser'],$list['AddAdminGroup']); + + asort($userlist); + asort($adminlist); + + if(!preg_match("/Printer/i",$this->BelongsTo)){ + if(preg_match("/Terminal/i",$this->BelongsTo)){ + $smarty->assign("desc" ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"".$this->cn."")); + }else{ + $smarty->assign("desc" ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"".$this->cn."")); + } + $smarty->assign("cnACL" , $this->getacl("cn",true)); + }else{ + $smarty->assign("desc" ,""); + } + $smarty->assign("UserMember" ,$this->UserMember); + $smarty->assign("UserMembers" ,$userlist); + $smarty->assign("UserMemberKeys",array_flip($userlist)); + + $smarty->assign("AdminMember" ,$this->AdminMember); + $smarty->assign("AdminMembers" ,$adminlist); + $smarty->assign("AdminMemberKeys",array_flip($adminlist)); + if(preg_match("/Printer/i",$this->BelongsTo)){ + + /* Show main page */ + $str = $this->netConfigDNS->execute(); + if(is_object($this->netConfigDNS->dialog)){ + return($str); + } + $smarty->assign("netconfig", $str); + } else { + $smarty->assign("netconfig", ""); + } + + return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE))); + } + + function remove_from_parent() + { + /* Only remove if there was initially an account */ + if($this->initially_was_account){ + + /* Update dn, to ensure storing as printer instead of WS / terminal + */ + if(preg_match("/terminal/i",$this->BelongsTo)){ + $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); + } + + if(preg_match("/workstation/i",$this->BelongsTo)){ + $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); + } + + /* Check if this dn points to a printer, to avoid deleting something else */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('dn',"objectClass")); + if(!$ldap->count()){ + print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss."); + return; + } + + /* Check if obejct is a printer */ + $CheckPrinter = $ldap->fetch(); + if(!in_array("gotoPrinter",$CheckPrinter['objectClass'])){ + print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss."); + return; + } + + /* Remove account & dns extension */ + $this->netConfigDNS->remove_from_parent(); + $ldap->rmdir($this->dn); + + new log("remove","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of system print/generic with dn '%s' failed."),$this->dn)); + $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + + /* Remove previously selected ppd file.*/ + if(!empty($this->initial_PPD)){ + $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD); + $tmp->removeModifiedPPD(); + } + } + } + + + /* Save data to object */ + function save_object() + { + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + if(is_object($this->netConfigDNS)){ + $this->netConfigDNS->save_object(); + } + + /* Set new base if allowed */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + if (preg_match("/printer/i",$this->BelongsTo)){ + $message= array_merge($message, $this->netConfigDNS->check()); + } + + /* Don't display check messages if this is a template object */ + if(isset($this->parent->by_object['workgeneric'])){ + if($this->parent->by_object['workgeneric']->cn == "wdefault"){ + return $message; + } + }elseif(isset($this->parent->by_object['termgeneric'])){ + if($this->parent->by_object['termgeneric']->cn == "default"){ + return $message; + } + } + + $dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base; + + /* must: cn */ + if(($this->BelongsTo == "Printer") && (empty($this->cn))){ + $message[]= _("The required field 'Printer name' is not set."); + } + + /* must: cn */ + if(($this->BelongsTo == "Printer") && !is_dns_name($this->cn)){ + $message[]= _("Invalid character in printer name."); + } + + /* must: labeledURI */ + if(empty($this->labeledURI)){ + $message[]= "The required field 'Printer URL' is not set."; + } + + /* Check if there is already an entry with this cn*/ + if (($this->orig_dn != $dn)&&( preg_match("/printer/i",$this->BelongsTo))){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->base); + $ldap->ls("(cn=".$this->cn.")","ou=printers,ou=systems,".$this->base, array("cn")); + if ($ldap->count() != 0){ + while ($attrs= $ldap->fetch()){ + if(preg_match("/cn=dhcp,/",$attrs['dn'])){ + continue; + } + if ($attrs['dn'] != $this->orig_dn){ + $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); + break; + } + } + } + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* Update dn, to ensure storing as printer instead of WS / terminal + */ + if(preg_match("/terminal/i",$this->BelongsTo)){ + $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); + } + + if(preg_match("/workstation/i",$this->BelongsTo)){ + $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); + } + + if(!$this->is_account) return; + if(isset($this->parent->by_object['workgeneric'])){ + if($this->parent->by_object['workgeneric']->cn == "wdefault"){ + return; + } + }elseif(isset($this->parent->by_object['termgeneric'])){ + if($this->parent->by_object['termgeneric']->cn == "default"){ + return; + } + } + + /* If type is still unknown, the initialisation of this printer failed, abort. */ + if(preg_match("/unknown/i",$this->BelongsTo)){ + return; + } + + /* save ppd configuration */ + if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){ + $this->PPDdialogToSave->save_ppd(); + } + if($this->orig_dn != $this->dn){ + if(!empty($this->gotoPrinterPPD)) { + $this->PPDdialogToSave = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); + $this->PPDdialogToSave->cn = $this->cn; + $this->PPDdialogToSave->generateProperties(); + $this->PPDdialogToSave->update_ppd_url(); + } + } + + /* Remove previously selected ppd file.*/ + if($this->initial_PPD != $this->gotoPrinterPPD){ + if(!empty($this->initial_PPD)){ + $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD); + $tmp->removeModifiedPPD(); + } + } + + if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ + $method="https://"; + }else{ + $method="http://"; + } + + /* If no ppd is selected, remove this attribute */ + if(!empty($this->gotoPrinterPPD)) { + $this->gotoPrinterPPD = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD); + }else{ + $this->gotoPrinterPPD = array(); + } + + $dn= $this->dn; + plugin::save(); + $ldap= $this->config->get_ldap_link(); + + /* reduce objectClasses to minimun */ + $this->attrs['objectClass']= $this->objectclasses; + + /* Remove all empty values */ + if ($this->orig_dn == 'new'){ + $attrs= array(); + foreach ($this->attrs as $key => $val){ + if (is_array($val) && count($val) == 0){ + continue; + } + $attrs[$key]= $val; + } + $this->attrs= $attrs; + } + + /* Append printer user + */ + $this->attrs['gotoUserPrinter']=array(); + foreach($this->member['AddUser'] as $mem){ + $this->attrs['gotoUserPrinter'][]=$mem['uid'][0]; + } + + /* Append printer group + */ + $this->attrs['gotoGroupPrinter'] = array(); + foreach($this->member['AddGroup'] as $mem){ + $this->attrs['gotoGroupPrinter'][]=$mem['cn'][0]; + } + + /* Append printer admin user + */ + $this->attrs['gotoUserAdminPrinter'] = array(); + foreach($this->member['AddAdminUser'] as $mem){ + $this->attrs['gotoUserAdminPrinter'][]=$mem['uid'][0]; + } + + /* Append printer admin group + */ + $this->attrs['gotoGroupAdminPrinter']= array(); + foreach($this->member['AddAdminGroup'] as $mem){ + $this->attrs['gotoGroupAdminPrinter'][]=$mem['cn'][0]; + } + + if($this->orig_dn == 'new'){ + foreach(array("gotoGroupPrinter","gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter") as $checkVar){ + if(count($this->attrs[$checkVar]) == 0 || empty($this->attrs[$checkVar])){ + unset($this->attrs[$checkVar]); + } + } + }else{ + if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){ + $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; + } + } + + /* Ensure to create a new object */ + if(preg_match("/ou=incoming,/",$this->orig_dn)){ + $this->orig_dn = "new"; + } + + /* Move object in necessary*/ + if (($this->orig_dn != $this->dn) && ($this->orig_dn != 'new')){ + $this->move($this->orig_dn, $this->dn); + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn); + if(!$ldap->count()){ + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + + /* Remove empty values */ + foreach($this->attrs as $name => $value){ + if(empty($value)){ + unset($this->attrs[$name]); + } + } + + $ldap->add($this->attrs); + $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + new log("create","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } else { + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + new log("modify","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system print/generic with dn '%s' failed."),$this->dn)); + + if(preg_match("/printer/i",$this->BelongsTo)){ + $this->netConfigDNS->cn = $this->cn; + $this->netConfigDNS->dn = $this->dn; + $this->netConfigDNS->save(); + } + + /* This is a multi object. Handle tagging here... */ + $this->handle_object_tagging(); + } + + function generateList(){ + $a_return=array(); + + foreach($this->member as $type => $values){ + $a_return[$type]=array(); + foreach($values as $value){ + if((preg_match("/Group/i",$type))){ + if(!isset($value['description'])){ + $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0]; + }else{ + $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0]." [".$value['description'][0]."]"; + } + }else{ + $a_return[$type][$value['uid'][0]]=_("User")." : ".$value['cn'][0]; + } + } + } + return($a_return); + } + + /* Return plugin informations for acl handling + #FIXME FAIscript seams to ununsed within this class... */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Print generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 4, + "plSection" => array("administration"), + "plCategory" => array("printer" => array("description" => _("Printer"), + "objectClass" => "gotoPrinter"),"workstation","terminal"), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "base" => _("Base") , + "description" => _("Description"), + "l" => _("Location"), + "labeledURI" => _("LabeledURL"), + "gotoPrinterPPD" => _("Printer PPD"), + "gotoUserPrinter" => _("Permissions")) + )); + } + + + /* Delete member */ + function DelMember($type,$id) + { + /* Check if there was a printer "dn" given, or the "cn" */ + foreach($this->member[$type] as $key => $printer){ + if($printer['dn'] == $id) { + $id = $key; + } + } + + if(!$this->acl_is_writeable("gotoUserPrinter")){ + print_red(sprintf(_("You are not allowed to remove the given object '%s' from the list of members of printer '%s'."),$id,$this->dn)); + return(FALSE); + } + + if(isset($this->member[$type][$id])){ + unset($this->member[$type][$id]); + return(TRUE); + } + return(FALSE); + } + + + /* Add given obejct to members */ + function AddMember($type,$dn) + { + $types = array("AddUser","AddGroup","AddAdminUser","AddAdminGroup"); + if(!in_array_ics($type, $types)){ + print_red(sprintf(_("Illegal printer type while adding '%s' to the list of '%s' printers,"),$dn,$type)); + return(FALSE); + } + + if(!$this->acl_is_writeable("gotoUserPrinter")){ + print_red(sprintf(_("You are not allowed to add the given object '%s' to the list of members of '%s'."),$dn,$this->dn)); + return(FALSE); + } + + /* Get name of index attributes */ + if(preg_match("/user/i",$type)){ + $var = "uid"; + }else{ + $var = "cn"; + } + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($dn); + $ldap->cat($dn,array($var,"cn")); + if($ldap->count()){ + + $attrs = $ldap->fetch(); + + if(isset($attrs[$var][0])){ + $name = $attrs[$var][0]; + + /* Check if this uid/cn is already assigned to any permission */ + foreach($types as $ctype){ + + /* If we want to add a user, only check user/userAdmin members */ + if((preg_match("/user/i",$type)) && (!preg_match("/user/i",$ctype))){ + continue; + } + + /* If we want to add a group, only check groups/adminGroups .. */ + if((preg_match("/group/i",$type)) && (!preg_match("/group/i",$ctype))){ + continue; + } + + if(isset( $this->member[$ctype][$name])){ + print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0])); + return(FALSE); + } + } + + /* Everything is fine. So add the given object to members */ + $this->member[$type][$attrs[$var][0]] = $attrs ; + }else{ + print_a($attrs); + } + }else{ + print_red(sprintf(_("Can't add '%s' to list of members, it is not reachable."),$dn)); + return(FALSE); + } + return(TRUE); + } + + + /* Display generic part for server copy & paste */ + function getCopyDialog() + { + $vars = array("cn"); + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $smarty->assign("object","printer"); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + if(isset($source['macAddress'][0])){ + $this->netConfigDNS->macAddress = $source['macAddress'][0]; + } + if(isset($source['ipHostNumber'][0])){ + $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; + } + + $source_o = new printgeneric($this->config,$source['dn'],NULL,$this->parent); + foreach($this->attributes as $attr){ + $this->$attr = $source_o->$attr; + } + $this->member = $source_o -> member; + + $this->gotoPrinterPPD = ""; + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_selectUserToPrinterDialog.inc b/gosa-core/plugins/admin/systems/class_selectUserToPrinterDialog.inc new file mode 100644 index 000000000..1f110e355 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_selectUserToPrinterDialog.inc @@ -0,0 +1,198 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); + var $regex = "*"; + var $subtree = FALSE; + var $depselect = "/"; + var $deplist = "/"; + + var $searchObjects = ""; + var $searchAttrs = ""; + var $searchAppend = ""; + var $baseAddition = ""; + var $type = ""; + var $search_cat = ""; + + function selectUserToPrinterDialog (&$config, $dn= NULL,$type=false ) + { + plugin::plugin ($config, $dn); + $this->depselect = $this->config->current['BASE']; + + switch($type){ + case "AddUser" : + $this->searchObjects = "(objectClass=gosaAccount)(!(uid=*$))"; + $this->searchAttrs = array("cn","uid"); + $this->searchAppend = "uid"; + $this->baseAddition = get_people_ou(); + $this->search_cat = "users"; + ;break; + case "AddGroup" : + $this->searchObjects = "(objectClass=posixGroup)"; + $this->searchAttrs = array("cn","description"); + $this->searchAppend = "cn"; + $this->baseAddition = get_groups_ou(); + $this->search_cat = "groups"; + ;break; + case "AddAdminUser" : + $this->searchObjects = "(objectClass=gosaAccount)(!(uid=*$))"; + $this->searchAttrs = array("cn","uid"); + $this->searchAppend = "uid"; + $this->baseAddition = get_people_ou(); + $this->search_cat = "users"; + ;break; + case "AddAdminGroup" : + $this->searchObjects = "(objectClass=posixGroup)"; + $this->searchAttrs = array("cn","description"); + $this->searchAppend = "cn"; + $this->baseAddition = get_groups_ou(); + $this->search_cat = "groups"; + ;break; + } + $this->type = $type; + + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + if(isset($_POST['dialogissubmitted'])){ + $this->regex=$_POST['regexPrinter']; + $this->depselect = $_POST['depselectPrinter']; + } + $this->subtree= isset($_POST['SubSearch']); + + if((isset($_GET['search']))&&(!empty($_GET['search']))){ + $this->regex=$_GET['search']."*"; + $this->regex=preg_replace("/\*\*/","*",$this->regex); + } + + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + $deps_res[] = array("dn"=>$this->config->current['BASE']); + $deps_res= array_merge($deps_res,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", array("users","groups"), $this->config->current['BASE'], + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + /* Load possible departments */ + $ui = get_userinfo(); + + /* Allowed user departments */ + $udeps = $ui->get_module_departments("users"); + + /* Allowed groups department */ + $gdeps = $ui->get_module_departments("groups"); + + /* Combine both arrays */ + $tdeps = array_unique(array_merge($udeps,$gdeps)); + + /* Create usable departments array */ + $ids = $this->config->idepartments; + $deps = array(); + foreach($deps_res as $dep){ + if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){ + $value = $ids[$dep['dn']]; + $deps[$dep['dn']] = $value; + } + } + if(!isset($deps[$this->depselect])){ + $this->depselect = key($deps); + } + + + + $tmp_printers= $this->getPrinter(); + natcasesort($tmp_printers); + $smarty->assign("regexPrinter" , $this->regex); + $smarty->assign("deplistPrinter" , $deps);;//deplist); + $smarty->assign("depselectPrinter" , $this->depselect); + $smarty->assign("gotoPrinters" , $tmp_printers); + $smarty->assign("gotoPrinterKeys" , array_flip($tmp_printers)); + $smarty->assign("apply" , apply_filter()); + $smarty->assign("alphabet" , generate_alphabet()); + $smarty->assign("search_image" , get_template_path('images/search.png')); + $smarty->assign("tree_image" , get_template_path('images/tree.png')); + $smarty->assign("infoimage" , get_template_path('images/info.png')); + $smarty->assign("launchimage" , get_template_path('images/small_filter.png')); + $smarty->assign("deplist" , $deps); + $smarty->assign("subtree", $this->subtree?"checked":""); + + $display.= $smarty->fetch(get_template_path('selectUserToPrinterDialog.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + function check(){ + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(empty($_POST['gotoPrinter'])){ + $message[] = _("Please select a printer or press cancel."); + } + return $message; + } + + /* Save to LDAP */ + function save() + { + $a_return['type']=$this->type; + + foreach($_POST['gotoPrinter'] as $name){ + $data = $this->getPrinter(true); + $a_return[$name]= $data[$name]; + } + return($a_return); + } + + /* This function generates the Printerlist + * All printers are returned that match regex and and depselect + */ + function getPrinter($detailed = false) + { + $a_return=array(); + + $filter = "(&".$this->searchObjects."(cn=".$this->regex."))"; + $base = $this->baseAddition.$this->depselect; + $attrs = $this->searchAttrs; + $cat = $this->search_cat; + + if ($this->subtree){ + $res= get_list($filter,$cat,$this->depselect,$attrs, GL_SUBSEARCH); + } else { + $res= get_list($filter,$cat,$base,$attrs); + } + foreach($res as $printer){ + if(($detailed ==true)){ + if(isset($printer[$this->searchAppend])){ + $a_return[$printer[$this->searchAppend][0]] = $printer; + } + }else{ + if(isset($printer[$this->searchAppend])){ + if(isset($printer['description'][0])){ + $a_return[$printer[$this->searchAppend][0]] = $printer['cn'][0]." - ".$printer['description'][0]; + }else{ + $a_return[$printer[$this->searchAppend][0]] = $printer['cn'][0]; + } + } + } + } + return($a_return); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_servGeneric.inc b/gosa-core/plugins/admin/systems/class_servGeneric.inc new file mode 100644 index 000000000..9d29f5e59 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_servGeneric.inc @@ -0,0 +1,444 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $ignore_account= TRUE; + var $interfaces= array(); + + /* Needed values and lists */ + var $base= ""; + var $cn= ""; + var $l= ""; + var $description= ""; + var $orig_dn= ""; + var $didAction= FALSE; + + /* attribute list for save action */ + var $attributes= array("cn", "description","gotoMode"); + var $objectclasses= array("top", "GOhard", "goServer"); + + var $gotoMode= "locked"; + + var $netConfigDNS; + var $modes = array(); + var $ui ; + var $mapActions = array("reboot" => "", + "instant_update" => "softupdate", + "localboot" => "localboot", + "update" => "sceduledupdate", + "reinstall" => "install", + "rescan" => "", + "memcheck" => "memcheck", + "sysinfo" => "sysinfo"); + + var $fai_activated =FALSE; + var $view_logged = FALSE; + + function servgeneric (&$config, $dn= NULL, $parent= NULL) + { + /* Check if FAI is activated */ + $tmp = $config->search("faiManagement", "CLASS",array('menu','tabs')); + + if(!empty($tmp)){ + $this->fai_activated = TRUE; + } + + plugin::plugin ($config, $dn, $parent); + + $this->ui = get_userinfo(); + $this->modes["active"]= _("Activated"); + $this->modes["locked"]= _("Locked"); + + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + $this->cn= ""; + } else { + $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); + } + $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); + $this->netConfigDNS->set_acl_category("server"); + $this->netConfigDNS->set_acl_base($this->base); + + /* Save dn for later references */ + $this->orig_dn= $this->dn; + } + + + function set_acl_base($base) + { + plugin::set_acl_base($base); + $this->netConfigDNS->set_acl_base($base); + } + + + function set_acl_category($cat) + { + plugin::set_acl_category($cat); + $this->netConfigDNS->set_acl_category($cat); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Do we represent a valid server? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no server features.").""; + return($display); + } + + /* Check for action */ + if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){ + $cmd = $this->config->search("workgeneric", "ACTIONCMD",array('tabs')); + if ($cmd == ""){ + print_red(_("No ACTIONCMD definition found in your gosa.conf")); + } else { + + exec ($cmd." ".$this->netConfigDNS->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval); + if ($retval != 0){ + print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); + } else { + $this->didAction= TRUE; + + /* Set FAIstate */ + if($this->fai_activated && $this->dn != "new"){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn,array("objectClass")); + $res = $ldap->fetch(); + + $attrs = array(); + $attrs['FAIstate'] = ""; + if(isset($this->mapActions[$_POST['saction']])){ + $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; + } + + for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $res['objectClass'][$i]; + } + + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } + + if($attrs['FAIstate'] == ""){ +#FIXME we should check if FAIobject is used anymore + $attrs['FAIstate'] = array(); + } + + $ldap->cd($this->dn); + $ldap->modify($attrs); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic (FAIstate) with dn '%s' failed."),$this->dn)); + } + } + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once ){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* Only accept allowed bases */ + $tmp = $this->get_allowed_bases(); + if($tmp[$this->dialog->isSelected()]){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Assign base ACL */ + $smarty->assign("bases" , $this->get_allowed_bases()); + + /* Assign attributes */ + foreach ($this->attributes as $attr){ + $smarty->assign("$attr", $this->$attr); + } + + $smarty->assign("staticAddress", ""); + $smarty->assign("base_select", $this->base); + + /* Assign status */ + $query= "fping -q -r 1 -t 500 ".$this->cn; + exec ($query, $dummy, $retval); + + /* Offline */ + if ($retval == 0){ + $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), + "instant_update" => _("Instant update"), + "update" => _("Scheduled update"), + "reinstall" => _("Reinstall"), + "rescan" => _("Rescan hardware"), + "memcheck" => _("Memory test"), + "localboot" => _("Force localboot"), + "sysinfo" => _("System analysis"))); + } else { + $smarty->assign("actions", array("wake" => _("Wake up"), + "reinstall" => _("Reinstall"), + "update" => _("Scheduled update"), + "memcheck" => _("Memory test"), + "localboot" => _("Force localboot"), + "sysinfo" => _("System analysis"))); + } + + /* Show main page */ + $smarty->assign("fai_activated",$this->fai_activated); + + $str = $this->netConfigDNS->execute(); + if(is_object($this->netConfigDNS->dialog)){ + return($str); + } + $smarty->assign("netconfig", $str); + $smarty->assign("modes", $this->modes); + + return($smarty->fetch (get_template_path('server.tpl', TRUE))); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){ + return; + } + + $this->netConfigDNS->remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir($this->dn); + + new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/generic with dn '%s' failed."),$this->dn)); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } + + + /* Save data to object */ + function save_object() + { + /* Save current base, to be able to revert to last base, + if new base is invalid or not allowed to be selected */ + $base_tmp = $this->base; + plugin::save_object(); + $this->netConfigDNS->save_object(); + + /* Get base selection */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if($tmp[$_POST['base']]){ + $this->base = $_POST['base']; + }else{ + $this->base = $base_tmp; + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + $message= array_merge($message, $this->netConfigDNS->check()); + $this->dn= "cn=".$this->cn.",ou=servers,ou=systems,".$this->base; + + /* must: cn */ + if ($this->cn == ""){ + $message[]= _("The required field 'Server name' is not set."); + } + + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn)){ + $message[] = _("Please specify a valid name for this object."); + } + + if ($this->orig_dn != $this->dn){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->base); + $ldap->search ("(cn=".$this->cn.")", array("cn")); + if ($ldap->count() != 0){ + while ($attrs= $ldap->fetch()){ + if ($attrs['dn'] != $this->orig_dn){ + if(!preg_match("/cn=dhcp,/",$attrs['dn']) && !preg_match("/,ou=incoming,/",$attrs['dn']) && preg_match("/,ou=servers,ou=systems,/",$attrs['dn'])){ + $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); + break; + } + } + } + } + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Remove all empty values */ + if ($this->orig_dn == 'new'){ + $attrs= array(); + foreach ($this->attrs as $key => $val){ + if (is_array($val) && count($val) == 0){ + continue; + } + $attrs[$key]= $val; + } + $this->attrs= $attrs; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + if ($this->orig_dn == 'new'){ + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $mode= "add"; + } else { + + /* cn is not case sensitive for ldap, but for php it is!! */ + if($this->config->current['DNMODE'] == "cn"){ + if (strtolower($this->orig_dn) != (strtolower($this->dn))){ + $this->recursive_move($this->orig_dn, $this->dn); + plugin::save(); + } + }else{ + if ($this->orig_dn != $this->dn){ + $this->recursive_move($this->orig_dn, $this->dn); + plugin::save(); + } + } + + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + $mode= "modify"; + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic with dn '%s' failed."),$this->dn)); + $this->netConfigDNS->cn = $this->cn; + $this->netConfigDNS->save(); + + /* Optionally execute a command after we're done */ + if(!$this->didAction){ + $this->handle_post_events($mode,array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } + } + + + /* Display generic part for server copy & paste */ + function getCopyDialog() + { + $vars = array("cn"); + + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $smarty->assign("object","server"); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + if(isset($source['macAddress'][0])){ + $this->netConfigDNS->macAddress = $source['macAddress'][0]; + } + if(isset($source['ipHostNumber'][0])){ + $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; + } + + } + + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Server generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("administration"), + "plCategory" => array("server" => array("description" => _("Server"), + "objectClass" => "goServer")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "description" => _("Description"), + "gotoMode" => _("Goto mode"), + "base" => _("Base"), + "FAIstate" => _("Action flag")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_serverService.inc b/gosa-core/plugins/admin/systems/class_serverService.inc new file mode 100644 index 000000000..338052b7e --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_serverService.inc @@ -0,0 +1,442 @@ +"Config object" , "dn"=>"Object dn"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array(); + + var $divList = NULL; + + var $plugins = array(); + var $pluign_names = array(); + + var $current = ""; + var $backup = NULL; + var $acl ; + var $cn; + + function ServerService (&$config, $dn) + { + plugin::plugin($config); + $this->dn= $dn; + foreach ($config->data['TABS']['SERVERSERVICE'] as $plug){ + $name= $plug['CLASS']; + $this->plugin_names[]= $name; + $this->plugins[$name]= new $name($config, $dn); + + /* Capture all service objectClases, necessary for acl handling */ + if(isset($this->plugins[$name]->objectclasses)){ + foreach($this->plugins[$name]->objectclasses as $oc){ + $this->objectclasses[] = $oc; + } + } + } + $this->divList = new divListSystemService($config,$this); + } + + function set_acl_base($base) + { + plugin::set_acl_base($base); + foreach($this->plugins as $name => $obj){ + $this->plugins[$name]->set_acl_base($base); + } + } + + function set_acl_category($category) + { + plugin::set_acl_category($category); + foreach($this->plugins as $name => $obj){ + $this->plugins[$name]->set_acl_category($category); + } + } + + function execute() + { + /* Variable initialisation */ + $s_action = ""; + $s_entry = ""; + + /* Walk through posts and check if there are some introductions for us */ + $PossiblePosts = array("addNewService" => "", + "startServices" => "", + "stopServices" => "", + "restartServices" => "", + "removeServices" => "", + + "StartSingleService" => "/^StartSingleService_(.*)_[xy]$/", + "StopSingleService" => "/^StopSingleService_(.*)_[xy]$/", + "RestartSingleService" => "/^RestartSingleService_(.*)_[xy]$/", + "RemoveSingleService" => "/^RemoveSingleService_(.*)_[xy]$/", + "EditSingleService" => "/^EditSingleService_(.*)_[xy]$/"); + + + $once = true; + foreach($_POST as $name => $value){ + foreach($PossiblePosts as $pregCheck => $idPreg) { + if(preg_match("/^".$pregCheck."/",$name) && $once){ + $once = false; + $s_action = $pregCheck; + + if(!empty($idPreg)){ + $s_entry = preg_replace($idPreg,"\\1",$name); + } + } + } + } + + + /* Handle state changes for services */ + $map = array( "startServices" => array("type" => START_SERVICE , "service" => ALL_SERVICES), + "stopServices" => array("type" => STOP_SERVICE , "service" => ALL_SERVICES), + "restartServices" => array("type" => RESTART_SERVICE , "service" => ALL_SERVICES), + "StartSingleService" => array("type" => START_SERVICE , "service" => $s_entry), + "StopSingleService" => array("type" => STOP_SERVICE , "service" => $s_entry), + "RestartSingleService" => array("type" => RESTART_SERVICE , "service" => $s_entry)); + if(isset($map[$s_action])){ + $type = $map[$s_action]['type']; + $service = $map[$s_action]['service']; + $this->ServiceStatusUpdate($type,$service); + } + + /* Handle actions linked via href */ + if(isset($_GET['act']) && $_GET['act'] == "open" && isset($_GET['id'])){ + $id = $_GET['id']; + if(isset($this->plugins[$id])){ + $s_entry = $id; + $s_action = "EditSingleService"; + } + } + + /* Open service add dialog */ + if($s_action == "addNewService"){ + $this->dialog = new ServiceAddDialog($this->config,$this->dn,$this); + } + + + /* Remove service */ + if($s_action == "RemoveSingleService"){ + + /* Create resetted obj */ + $new_obj = new $s_entry($this->config,$this->dn); + $new_obj -> set_acl_base($this->acl_base); + $new_obj -> set_acl_category(preg_replace("/\/$/","",$this->acl_category)); + $tmp = $new_obj->getListEntry(); + + if($tmp['AllowRemove']){ + + /* Check if we are allowed to remove this service + */ + $str = $this->plugins[$s_entry]->allow_remove(); + + if(empty($str)){ + $this->plugins[$s_entry] = $new_obj; + $this->plugins[$s_entry]->is_account = false; + }else{ + print_red($str); + } + } + } + + + /* Edit a service and make a backup from all attributes, + to be able to restore old values after aborting dialog */ + if($s_action == "EditSingleService"){ + $this->backup = get_object_vars($this->plugins[$s_entry]); + $this->dialog = $this->plugins[$s_entry]; + $this->current = $s_entry; + } + + + /* Abort service add */ + if(isset($_POST['CancelServiceAdd'])){ + $this->dialog = FALSE; + $this->backup = NULL; + $this->current = ""; + } + + + /* Abort dialog + Restore vars with values before editing */ + if(isset($_POST['CancelService']) && !empty($this->current)){ + if($this->backup == NULL){ + $this->plugins[$this->current] = new $this->current($this->config,$this->dn); + $this->plugins[$this->current]-> set_acl_base($this->acl_base); + $this->plugins[$this->current]-> set_acl_category(preg_replace("/\/$/","",$this->acl_category)); + + }else{ + foreach($this->backup as $name => $value){ + $this->plugins[$this->current]->$name = $value; + } + } + $this->dialog = FALSE; + $this->backup = NULL; + $this->current = ""; + } + + + /* Abort dialog */ + if(isset($_POST['SaveService']) && is_object($this->dialog)){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $this->plugins[$this->current] = $this->dialog; + $tmp = get_object_vars($this->dialog); + foreach($tmp as $name => $value){ + $this->plugins[$this->current]->$name = $value; + } + $this->current = ""; + $this->dialog = FALSE; + $this->backup = NULL; + } + } + + + /* Abort dialog */ + if((isset($_POST['SaveServiceAdd'])) && (!empty($_POST['ServiceName']))){ + $serv = $_POST['ServiceName']; + $this->plugins[$serv]->is_account = true; + $this->dialog = $this->plugins[$serv]; + $this->current = $serv; + } + + + /* There is currently a subdialog open, display this dialog */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + + /* Dispaly services overview */ + $this->divList->execute(); + $list = array(); + + foreach($this->plugins as $name => $obj){ + if($obj->is_account){ + $list[$name] = $this->plugins[$name]->getListEntry(); + } + } + $this->divList -> setEntries($list); + return("
".$this->divList->Draw()."
"); + } + + + /* Get all used services + CLASSNAME => _($this->plugins[*]->DisplayName); */ + function getAllUsedServices() + { + $ret = array(); + foreach($this->plugins as $name => $obj){ + if($obj->is_account){ + if(isset($obj->DisplayName)){ + $ret[$name] = $obj->DisplayName; + }else{ + $ret[$name] = $name; + } + } + } + return($ret); + } + + + /* Get all unused services + CLASSNAME => _($this->plugins[*]->DisplayName); */ + function getAllUnusedServices() + { + $tmp = $this->getAllUsedServices(); + $pool_of_ocs =array(); + foreach($tmp as $name => $value){ + if(isset($this->plugins[$name]->conflicts)){ + $pool_of_ocs[]= get_class($this->plugins[$name]); + } + } + + $ret = array(); + foreach($this->plugins as $name => $obj){ + + /* Skip all pluigns that will lead into conflicts */ + $skip = false; + if(isset($obj->conflicts)){ + foreach($obj->conflicts as $oc){ + if(in_array_ics($oc,$pool_of_ocs)){ + $skip = true; + } + } + } + + /* Only show createable services */ + if(!$obj->acl_is_createable()){ + $skip = true; + } + + if(!$skip){ + if(isset($obj->DisplayName)){ + $ret[$name] = $obj->DisplayName; + }else{ + $ret[$name] = $name; + } + } + } + return($ret); + } + + + /* This function sets the status var for each used + service && calls an external hook if specified in gosa.conf*/ + function ServiceStatusUpdate($method , $service) + { + /* Skip if this is a new server */ + if($this->dn == "new"){ + print_red(_("Can't set status while this server is not saved.")); + return; + } + + $action = ""; + if($method == START_SERVICE){ + $action = SERVICE_STARTED; + }elseif($method== STOP_SERVICE){ + $action = SERVICE_STOPPED; + }elseif($method == RESTART_SERVICE){ + $action = SERVICE_RESTARTED; + }else{ + print_red(sprintf(_("The specified method '%s' can't executed for services."),$action)); + return; + } + + $caseVars = array("cn","dn"); + if($service == ALL_SERVICES){ + foreach($this->plugins as $name => $obj){ + foreach($caseVars as $var){ + if(isset($this->$var)){ + $this->plugins[$name]->$var = $this->$var; + } + } + + /* check if services can be restarted */ + $map =array(SERVICE_STARTED=> "AllowStart" , + SERVICE_STOPPED => "AllowStop", + SERVICE_RESTARTED => "AllowRestart"); + + /* get plugins informations, restart/start/stop actions allowed ?*/ + $tmp = $this->plugins[$name]->getListEntry(); + + /* Check if given action is allowed for this service */ + if($tmp[$map[$action]]){ + if($this->plugins[$name]->initially_was_account && $this->plugins[$name]->is_account){ + $this->plugins[$name]->setStatus($action); + } + } + } + }else{ + foreach($caseVars as $var){ + if(isset($this->$var)){ + $this->plugins[$service]->$var = $this->$var; + } + } + if($this->plugins[$service]->is_account){ + $this->plugins[$service]->setStatus($action); + } + } + } + + + function check() + { + $message = plugin::check(); + return $message; + } + + + function save_object() + { + foreach($this->plugins as $name => $obj){ + if($obj->is_account){ + $this->plugins[$name]->save_object(); + } + } + } + + + function remove_from_parent() + { + $caseVars = array("cn","dn"); + foreach($this->plugins as $name => $obj){ + foreach($caseVars as $var){ + if(isset($this->$var)){ + $this->plugins[$name]->$var = $this->$var; + } + } + if($this->plugins[$name]->initially_was_account){ + $this->plugins[$name]->remove_from_parent(); + } + } + } + + + function save() + { + $caseVars = array("cn","dn"); + foreach($this->plugins as $name => $obj){ + + foreach($caseVars as $var){ + if(isset($this->$var)){ + $this->plugins[$name]->$var = $this->$var; + } + } + + if($this->plugins[$name]->is_account){ + $this->plugins[$name]->save(); + }else{ + if($this->plugins[$name]->initially_was_account){ + $this->plugins[$name]->remove_from_parent(); + } + } + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + foreach($this->plugins as $name => $plugin){ + $this->plugins[$name]->PrepareForCopyPaste($source); + } + } + + + /* Check if all plugins allow a remove .. */ + function allow_remove() + { + foreach($this->plugins as $name => $obj){ + $str = $obj->allow_remove(); + if(!empty($str)){ + return($str); + } + } + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_systemManagement.inc b/gosa-core/plugins/admin/systems/class_systemManagement.inc new file mode 100644 index 000000000..60a577e8b --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_systemManagement.inc @@ -0,0 +1,1398 @@ +config= $config; + $this->ui= $ui; + + /* Creat dialog object */ + $this->DivListSystem = new divListSystem($this->config,$this); + + /* Copy & Paste enabled ?*/ + if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + + /* Check whether the arp handling active or not */ + if($this->config->search("ArpNewDevice","CLASS",array('tabs')) != ""){ + $this->arp_handling_active = TRUE; + } + + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $_SESSION['LOCK_VARS_TO_USE'] = array("/^system_edit_/i","/^system_del_/","/^act/","/^id/","/^item_selected/","/^remove_multiple_systems/"); + + /******************** + Check for functional posts, edit|delete|add|... system devices + ********************/ + $s_action = ""; // Contains the action to proceed + $s_entry = ""; // The value for s_action + $base_back = ""; // The Link for Backbutton + $smarty = get_smarty(); + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/system_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/system_del_/i","",$key); + // Post for edit + }elseif(preg_match("/system_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/system_edit_/i","",$key); + // Post for new + }elseif(preg_match("/system_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/system_tplnew.*/i",$key)){ + $s_action="new_tpl"; + }elseif(preg_match("/system_setpwd_.*/i",$key)){ + $s_action="change_pw"; + $s_entry = preg_replace("/system_setpwd_/i","",$key); + }elseif(preg_match("/gen_cd_.*/i",$key)){ + $s_action="gen_cd"; + $s_entry = preg_replace("/gen_cd_/i","",$key); + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + } + } + + /* Incoming handling + * If someone made a systemtype and ogroup selection + * Display the new requested entry type ... servtab in case of server and so on. + */ + if(isset($_POST['SystemTypeChoosen'])){ + $s_action = "SelectedSystemType"; + $s_entry = $_POST['SystemType']; + $_SESSION['SelectedSystemType']['ogroup'] = $_POST['ObjectGroup']; + $this->systab = NULL; + } + + /* remove image tags from posted entry (posts looks like this 'name_x')*/ + $s_entry = preg_replace("/_.$/","",$s_entry); + + /* Edit was requested by pressing the name(link) of an item */ + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + /* Create options */ + if(isset($_POST['menu_action']) && preg_match("/^newsystem_/",$_POST['menu_action'])){ + $s_action = "newsystem"; + $s_entry = preg_replace("/^newsystem_/","",$_POST['menu_action']); + } + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + + /* Check for exeeded sizelimit */ + if (($message= check_sizelimit()) != ""){ + return($message); + } + + /* Try to get informations about what kind of system to create */ + if ($s_action=="new") { + return ($smarty->fetch(get_template_path('chooser.tpl', TRUE))); + } + + + /******************** + Copy & Paste Handling ... + ********************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /******************** + Create FAI CD ... + ********************/ + if ($s_action=="gen_cd"){ + $this->dn= $this->terminals[$s_entry]['dn']; + $_SESSION['objectinfo']= $this->dn; + return ($smarty->fetch(get_template_path('gencd.tpl', TRUE))); + } + + + /* Start CD-Creation */ + if ((isset($_POST["cd_create"])) && !empty($this->dn)){ + $smarty->assign("src", "?plug=".$_GET['plug']."&PerformIsoCreation"); + return ($smarty->fetch(get_template_path('gencd_frame.tpl', TRUE))); + } + + + if ($this->dn != "" && isset($_GET['PerformIsoCreation'])){ + + $return_button = "
+ + +
"; + + $dsc = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); + + /* Get and check command */ + $command= $this->config->search("workgeneric", "ISOCMD",array('tabs')); + + if (check_command($command)){ + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute"); + + /* Print out html introduction */ + echo ' + + + + + + + +
';
+
+        /* Open process handle and check if it is a valid process */
+        $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
+        if (is_resource($process)) {
+          fclose($pipes[0]);
+
+          /* Print out returned lines && write JS to scroll down each line */
+          while (!feof($pipes[1])){
+            $cur_dat = fgets($pipes[1], 1024);
+            echo $cur_dat;
+            echo '' ;
+            flush();
+          }
+        }
+
+        /* Get error string && close streams */
+        $buffer= stream_get_contents($pipes[2]);
+
+        fclose($pipes[1]);
+        fclose($pipes[2]);
+        echo "
"; + + /* Check return code */ + $ret= proc_close($process); + if ($ret != 0){ + echo "

"._("Creating the image failed. Please see the report below.")."

"; + echo "
$buffer
"; + } + + + + echo $return_button."
"; + + } else { + $tmp= "

".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."

"; + echo $tmp; + } + + /* Scroll down completly */ + echo '' ; + echo ''; + flush(); + exit; + } + + + /******************** + Create new system ... + ********************/ + /* Create new default terminal + * Or create specified object of selected system type, from given incoming object + */ + + $save_object_directly = false; + if(($s_action == "SelectedSystemType") && (isset($_POST['ObjectGroup']) && ($_POST['ObjectGroup'] != "none"))){ + $save_object_directly = true; + } + + if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") { + + /* If the current entry is an incoming object + * $sw = System type as posted in new incoming handling dialog + */ + if($s_action == "SelectedSystemType") { + $sw = $s_entry; + }else{ + if(isset($_POST['system'])){ + $sw = $_POST['system']; + }else{ + $sw = $s_entry; + } + $this->dn= "new"; + } + + $tabs = array( + "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"), + "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"), + "server" => array("CLASS"=>"SERVTABS", "TABNAME"=>"servgeneric", "TABCLASS" =>"servtabs", "ACL"=> "server"), + "printer" => array("CLASS"=>"PRINTTABS", "TABNAME"=>"printgeneric", "TABCLASS" =>"printtabs", "ACL"=> "printer"), + "phone" => array("CLASS"=>"PHONETABS", "TABNAME"=>"phoneGeneric", "TABCLASS" =>"phonetabs", "ACL"=> "phone"), + "component" => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentGeneric","TABCLASS" =>"componenttabs", "ACL"=> "component")); + + if(isset($tabs[$sw])){ + $class = $tabs[$sw]["CLASS"]; + $tabname = $tabs[$sw]["TABNAME"]; + $tabclass = $tabs[$sw]["TABCLASS"]; + $acl_cat = $tabs[$sw]["ACL"]; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $ui = get_userinfo(); + $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname); + if(preg_match("/c/",$tabacl)){ + $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw); + $this->systab->set_acl_base($this->DivListSystem->selectedBase); + $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase; + $this->systab->base = $this->DivListSystem->selectedBase; + }else{ + print_red(_("You are not allowed to create a new object of this type.")); + } + } + } + + /******************** + Edit system ... + ********************/ + + /* User wants to edit data? */ + if (($s_action == "edit") && (!isset($this->systab->config))){ + + $this->dn= $this->terminals[$s_entry]['dn']; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Find out more about the object type */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('objectClass','gotoMode')); + $attrs= $ldap->fetch(); + $type= $this->get_system_type($attrs); + + /* Lock the current entry, so everyone will get the + above dialog */ + $tabs = array( + "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal"), + "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation"), + "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server"), + "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer"), + "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone"), + "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation"), + "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component")); + + + if($type == "ArpNewDevice"){ + $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn); + }elseif($type == "NewDevice"){ + $this->systab = new SelectDeviceType($this->config,$this->dn) ; + }elseif(isset($tabs[$type])){ + + $class = $tabs[$type]["CLASS"]; + $acl_cat = $tabs[$type]["ACL"]; + $tabclass = $tabs[$type]["TABCLASS"]; + + $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$acl_cat); + $this->systab->set_acl_base($this->dn); + $_SESSION['objectinfo']= $this->dn; + add_lock ($this->dn, $this->ui->dn); + }else{ + print_red (_("You can't edit this object type yet!")); + del_lock($this->dn); + } + } + + + /******************** + Change password ... + ********************/ + + /* Set terminals root password */ + if ($s_action=="change_pw"){ + $tabs = array( + "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"), + "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation")); + + $type = $this->get_system_type($this->terminals[$s_entry]); + $class = $tabs[$type]["CLASS"]; + $tabname = $tabs[$type]["TABNAME"]; + $acl_cat = $tabs[$type]["ACL"]; + $tabclass = $tabs[$type]["TABCLASS"]; + $ui = get_userinfo(); + $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd"); + if(preg_match("/w/",$tabacl)){ + $this->dn= $this->terminals[$s_entry]['dn']; + $_SESSION['objectinfo']= $this->dn; + return ($smarty->fetch(get_template_path('password.tpl', TRUE))); + }else{ + print_red(_("You are not allowed to change the password for this object.")); + } + } + + + /******************** + Password change finish, but check if entered data is ok + ********************/ + + /* Correctly specified? */ + if (isset($_POST['password_finish'])){ + if ($_POST['new_password'] != $_POST['repeated_password']){ + print_red (_("Passwords entered as new and repeated do not match!")); + return($smarty->fetch(get_template_path('password.tpl', TRUE))); + } + } + + /******************** + Password change finish + ********************/ + + /* Change terminal password */ + if (isset($_POST['password_finish']) && + $_POST['new_password'] == $_POST['repeated_password']){ + + /* Check if user is allowed to set password */ + $tabs = array( + "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"), + "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation")); + + /* Detect object type */ + $type = ""; + foreach($this->terminals as $terminal){ + if($terminal['dn'] == $this->dn){ + $type = $this->get_system_type($terminal); + break; + } + } + + /* Type detected */ + if(!empty($type)){ + + /* Get infos */ + $class = $tabs[$type]["CLASS"]; + $tabname = $tabs[$type]["TABNAME"]; + $acl_cat = $tabs[$type]["ACL"]; + $tabclass = $tabs[$type]["TABCLASS"]; + + /* Get acls */ + $ui = get_userinfo(); + $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd"); + + /* Check acls */ + if(preg_match("/w/",$tabacl)){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + + $attrs= array(); + if ($_POST['new_password'] == ""){ + $attrs['gotoRootPasswd']= array(); + } else { + $attrs['gotoRootPasswd']= crypt($_POST['new_password'],substr(session_id(),0,2)); + } + $ldap->modify($attrs); + new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error()); + }else{ + print_red(_("You are not allowed to change the password for this object.")); + } + }else{ + print_red(_("Can't detect object to change password.")); + } + unset($_SESSION['objectinfo']); + } + + + /******************** + Delete system cancel + ********************/ + + /* Delete terminal canceled? */ + if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $this->dns = array(); + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->terminals[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $smarty->assign("warning", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); + } else { + $smarty->assign("warning", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); + } + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_system_confirm'])){ + + $ui = get_userinfo(); + $tabs = array( + "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"), + "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"), + "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"), + "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"), + "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"), + "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"), + "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric")); + + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + /* Get 'dn' from posted termlinst */ + $attrs = $this->terminals[$key]; + $type= $this->get_system_type($attrs); + + /* get object type */ + $tabtype = "termtabs"; + $tabobj = "TERMTABS"; + $tabacl = ""; + if(isset($tabs[$type])){ + $tabtype = $tabs[$type]['TABCLASS']; + $tabobj = $tabs[$type]['CLASS']; + $tabacl = $ui->get_permissions($dn,$tabs[$type]['ACL']); + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + if(preg_match("/d/",$tabacl)){ + + /* Delete request is permitted, perform LDAP action */ + if($tabtype=="phonetabs"){ + $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type); + $this->systab->set_acl_base($dn); + $this->systab->by_object['phoneGeneric']->remove_from_parent (); + }else{ + $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $dn,$type); + $this->systab->set_acl_base($dn); + $this->systab->delete(); + } + unset ($this->systab); + $this->systab= NULL; + + } else { + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this component!")); + new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + } + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_system_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete system, confirm dialog + ********************/ + + /* Remove terminal was requested */ + if ($s_action=="del"){ + + /* Get 'dn' from posted termlinst */ + $this->dn = $this->terminals[$s_entry]['dn']; + $attrs = $this->terminals[$s_entry]; + + $type= $this->get_system_type($attrs); + $ui = get_userinfo(); + $tabs = array( + "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"), + "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"), + "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"), + "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"), + "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"), + "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"), + "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric")); + + + /* get object type */ + $tabtype = "termtabs"; + $tabobj = "TERMTABS"; + $tabacl = ""; + if(isset($tabs[$type])){ + $tabtype = $tabs[$type]['TABCLASS']; + $tabobj = $tabs[$type]['CLASS']; + $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']); + } + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + if(preg_match("/d/",$tabacl)){ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the user isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this component!")); + } + } + + + /******************** + Delete system, confirmed + ********************/ + /* Confirmation for deletion has been passed. Terminal should be deleted. */ + if (isset($_POST['delete_terminal_confirm'])){ + + /* Find out more about the object type */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('objectClass')); + $attrs= $ldap->fetch(); + $type= $this->get_system_type($attrs); + + $ui = get_userinfo(); + + $tabs = array( + "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"), + "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"), + "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"), + "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"), + "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"), + "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"), + "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric")); + + /* get object type */ + $tabtype = "termtabs"; + $tabobj = "TERMTABS"; + $tabacl = ""; + if(isset($tabs[$type])){ + $tabtype = $tabs[$type]['TABCLASS']; + $tabobj = $tabs[$type]['CLASS']; + $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']); + } + + /* Check if we are allowed to remove this object */ + if(preg_match("/d/",$tabacl)){ + + /* Delete request is permitted, perform LDAP action */ + if($tabtype=="phonetabs"){ + $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $this->dn,$type); + $this->systab->set_acl_base($this->dn); + $this->systab->by_object['phoneGeneric']->remove_from_parent (); + }else{ + $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $this->dn,$type); + $this->systab->set_acl_base($this->dn); + $this->systab->delete(); + } + unset ($this->systab); + $this->systab= NULL; + + /* Terminal list has changed, reload it. */ + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this component!")); + new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + + + + + + + + /******************** + Edit system type finished, check if everything went ok + ********************/ + /* Finish user edit is triggered by the tabulator dialog, so + the user wants to save edited data. Check and save at this + point. */ + if ((isset($_POST['edit_finish'])) && (isset($this->systab->config)) || $save_object_directly){ + + /* Check tabs, will feed message array */ + $message = array(); + if(!$save_object_directly){ + $message = $this->systab->check(); + }else{ + $found = false; + + /* Set gotoMode to active if we there was an ogroup selected . (save_object_directly) */ + foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"graphic") as $tab => $value){ + if(isset($this->systab->by_object[$tab]->gotoMode)) { + $found = true; + $this->systab->by_object[$tab]->gotoMode = $value; + } + } + if(!$found){ + print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified."))); + } + + } + /* Save, or display error message? */ + if (count($message) == 0){ + + /* Incoming behavior; you can select a system type and an ogroup membership. + * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset. + * Check if we must add the new object to an object group. + * + * If this is done, delete the old incoming entry... it is still there, because this is a new + * entry and not an edited one, so we will delete it. + * + */ + + if(isset($_SESSION['SelectedSystemType'])){ + $SelectedSystemType= $_SESSION['SelectedSystemType']; + if($SelectedSystemType['ogroup'] != "none"){ + $og = new ogroup($this->config,$SelectedSystemType['ogroup']); + if($og){ + $og->AddDelMembership($this->systab->dn); + $og->save(); + } + } + } + + /* Save terminal data to ldap */ + if(isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){ + foreach (array("workservice", "termservice") as $cls){ + if (isset($this->systab->by_object[$cls])){ + $this->systab->by_object[$cls]->gotoXMouseport= ""; + $this->systab->by_object[$cls]->gotoXMouseType= ""; + $this->systab->by_object[$cls]->gotoXResolution= ""; + $this->systab->by_object[$cls]->gotoXColordepth= ""; + } + } + } + + $this->systab->save(); + + if(isset($_SESSION['SelectedSystemType'])){ + unset($_SESSION['SelectedSystemType']); + if(!isset($ldap)){ + $ldap = $this->config->get_ldap_link(); + } + $ldap->cd ($this->dn); + $ldap->cat($this->dn, array('dn')); + if(count($ldap->fetch())){ + $ldap->cd($this->dn); + $ldap->rmDir($this->dn); + } + $ldap->cd($this->config->current['BASE']); + } + + /* Terminal has been saved successfully, remove lock from + LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + + unset ($this->systab); + $this->systab= NULL; + unset($_SESSION['objectinfo']); + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /******************** + Edit system was canceled + ********************/ + /* Cancel dialogs */ + if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){ + if (isset($this->systab)){ + del_lock ($this->systab->dn); + unset ($this->systab); + } + $this->systab= NULL; + unset($_SESSION['objectinfo']); + + /* Remove ogroup selection, which was set while editing a new incoming entry */ + if(isset($_SESSION['SelectedSystemType'])){ + unset($_SESSION['SelectedSystemType']); + } + } + + /******************** + Display edit dialog, or some other + ********************/ + + /* Show tab dialog if object is present */ + if (isset($this->systab->config)){ + $display= $this->systab->execute(); + + /* Don't show buttons if tab dialog requests this */ + + $dialog = FALSE; + $hide_apply = $this->dn == "new"; + if(is_object($this->systab) && !isset($this->systab->by_object)){ + $dialog = TRUE; + $hide_apply = TRUE; + }elseif(isset($this->systab->by_object[$this->systab->current]->dialog)){ + $dia = $this->systab->by_object[$this->systab->current]->dialog; + if($dia === TRUE || is_object($dia)){ + $dialog = TRUE; + } + } + if(isset($this->systab->by_object[$this->systab->current]->netConfigDNS) && + $this->systab->by_object[$this->systab->current]->netConfigDNS->dialog){ + $dialog = TRUE; + } + + if (!$dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if (!$hide_apply){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + return ($display); + } + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListSystem->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Display dialog with system list */ + $this->DivListSystem->parent = $this; + $this->DivListSystem->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListSystem->SubSearch){ + $this->DivListSystem->AddDepartments($this->DivListSystem->selectedBase,3,1); + } + $this->reload(); + $this->DivListSystem->setEntries($this->terminals); + return($this->DivListSystem->Draw()); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + $tmp = array(); + + /* Check acls, if we are not allowed to create and write each plugin tab, skip this object */ + + $tabs = array( + "terminal" => "ou=terminals,ou=systems,", + "workstation" => "ou=workstations,ou=systems,", + "incoming" => "ou=incoming,", + "server" => "ou=servers,ou=systems,", + "printer" => "ou=printers,ou=systems,", + "phone" => "ou=phones,ou=systems,", + "winworkstation" => get_winstations_ou(), + "component" => "ou=netdevices,ou=systems," + ); + + foreach($tabs as $acl_cat => $dn){ + + $acl_all = $this->ui->has_complete_category_acls($dn.$this->DivListSystem->selectedBase,$acl_cat); + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $tmp[] = $dn.$this->DivListSystem->selectedBase; + } + } + return($tmp); + } + + + function remove_from_parent() + { + /* Optionally execute a command after we're done */ + $this->postremove(); + } + + + /* Save data to object */ + function save_object() + { + $this->DivListSystem->save_object(); + } + + + /* Check values */ + function check() + { + } + + + /* Save to LDAP */ + function save() + { + } + + function adapt_from_template($dn) + { + } + + function password_change_needed() + { + } + + function reload() + { + /* some var init */ + $ui = get_userinfo(); + $res = array(); + $this->terminals = array(); + $userregex = ""; + + /* Set base for all searches */ + $base= $this->DivListSystem->selectedBase; + + /* Prepare samba class name */ + $samba =""; + if ($this->DivListSystem->ShowWinWorkstations){ + if ($this->config->current['SAMBAVERSION'] == "3"){ + $samba= "sambaSamAccount"; + } else { + $samba= "sambaAccount"; + } + } + + /* This array represents the combination between checkboxes and search filters */ + $objs = array( "ShowServers" => array("CLASS" => "goServer" ,"TREE" => "ou=servers,ou=systems," ), + "ShowTerminals" => array("CLASS" => "gotoTerminal" ,"TREE" => "ou=terminals,ou=systems,"), + "ShowPrinters" => array("CLASS" => "gotoPrinter" ,"TREE" => "ou=printers,ou=systems," ), + "ShowDevices" => array("CLASS" => "ieee802Device" ,"TREE" => "ou=netdevices,ou=systems," ), + "ShowPhones" => array("CLASS" => "goFonHardware" ,"TREE" => "ou=phones,ou=systems," ), + "ShowWorkstations" => array("CLASS" => "gotoWorkstation" ,"TREE" => "ou=workstations,ou=systems," ), + "ShowWinWorkstations"=> array("CLASS" => $samba ,"TREE" => get_winstations_ou() )); + + /* Include the 'Display Systems of user' attribute */ + if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){ + $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")"; + } + + /* Attributes to fetch */ + $sys_attrs = array("cn", "description", "macAddress", "objectClass", "sambaDomainName","gotoMode"); + $sys_categories = array("terminal", "workstation", "server", "phone" ,"printer"); + + /* Add FAIstate to attributes if FAI is activated */ + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + $sys_attrs[] = "FAIstate"; + } + + /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled */ + foreach($objs as $checkBox => $oc){ + if($this->DivListSystem->$checkBox){ + if($this->DivListSystem->SubSearch){ + if($oc['CLASS'] != ""){ + $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))"; + $new_res = get_list($filter, $sys_categories , $base,$sys_attrs, GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT); + + /* Remove all objects that are not in the expected sub department */ + foreach($new_res as $key => $obj){ + if(preg_match("/^[^,]+,".normalizePreg($oc['TREE'])."/",$obj['dn'])){ + $res[$obj['dn']] = $obj; + } + } + } + }else{ + /* User filter? */ + if($oc['CLASS'] != ""){ + $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))"; + $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs, GL_NONE | GL_SIZELIMIT)); + } + } + } + } + + /* Search for incoming objects */ + $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))"; + $res = array_merge($res,get_list($filter,$sys_categories,"ou=incoming,".$base,$sys_attrs, GL_NONE | GL_SIZELIMIT)); + + /* Get all gotoTerminal's */ + foreach ($res as $value){ + + $tmp= $value['dn']; + $add= ""; + + /* Extract base */ + foreach($objs as $obj){ + if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){ + $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn'])); + } + } + + /* Create a string containing the last part of the department. */ + $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp))); + if(empty($dn_name)){ + $dn_name = "/"; + } + + /* check if current object is a new one */ + if (preg_match ("/,ou=incoming,/i", $tmp)){ + if (in_array_ics('gotoTerminal', $value['objectClass'])){ + $add= "- "._("New terminal"); + }elseif (in_array_ics('gotoWorkstation', $value['objectClass'])){ + $add= "- "._("New workstation"); + }elseif (in_array_ics('GOhard', $value['objectClass']) && !isset($value['gotoMode'])){ + $add= "- "._("Unknown device"); + }elseif (in_array_ics('GOhard', $value['objectClass'])){ + $add= "- "._("New Device"); + } + } + + /* Detect type of object and create an entry for $this->terminals */ + $terminal = array(); + + if (in_array_ics('gotoTerminal', $value["objectClass"])){ + + /* check acl */ + $acl = $ui->get_permissions($value['dn'],"terminal/termgeneric"); + if($add != "" || preg_match("/r/",$acl)) { + if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){ + $terminal = $value; + $terminal['type'] = "T"; + $terminal['is_new'] = $add; + } else { + $terminal = $value; + $terminal['type'] = "D"; + $terminal['message'] = _("Terminal template for")." '".$dn_name."' "; + $terminal['location'] = array_search($tmp, $this->config->departments); + } + } + } elseif (in_array_ics('gotoWorkstation', $value["objectClass"])){ + + $acl = $ui->get_permissions($value['dn'],"workstation/workgeneric"); + if($add != "" || preg_match("/r/",$acl)) { + if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){ + $terminal = $value; + $terminal['type'] = "L"; + $terminal['is_new'] = $add; + } else { + $terminal = $value; + $terminal['type'] = "D"; + $terminal['location'] = array_search($tmp, $this->config->departments); + $terminal['message'] = _("Workstation template for")." '".$dn_name."' "; + } + if (isset($value["FAIstate"][0])){ + $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]); + } + } + } elseif (in_array_ics('gotoPrinter', $value["objectClass"])){ + + + $acl = $ui->get_permissions($value['dn'],"printer/printgeneric"); + if($add != "" || preg_match("/r/",$acl)) { + + $terminal = $value; + $terminal['type'] = "P"; + } + } elseif (in_array_ics('goServer', $value["objectClass"])){ + + $acl = $ui->get_permissions($value['dn'],"server/servgeneric"); + if($add != "" || preg_match("/r/",$acl)) { + + $terminal = $value; + $terminal['type'] = "S"; + if (isset($value["FAIstate"][0])){ + $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]); + } + } + } elseif (in_array_ics('goFonHardware', $value["objectClass"])){ + + $acl = $ui->get_permissions($value['dn'],"phone/phoneGeneric"); + if($add != "" || preg_match("/r/",$acl)) { + + $terminal = $value; + $terminal['type'] = "F"; + } + }elseif (in_array_ics("GOhard",$value['objectClass'])){ + + $acl = $ui->get_permissions($value['dn'],"server/servgeneric"). + $ui->get_permissions($value['dn'],"terminal/termgeneric"). + $ui->get_permissions($value['dn'],"workstation/workgeneric"); + if($add != "" || preg_match("/r/",$acl)) { + + $terminal = $value; + $terminal['type'] = "Q"; + $terminal['is_new'] = $add; + } + } elseif (in_array_ics('ieee802Device', $value["objectClass"])){ + + $acl = $ui->get_permissions($value['dn'],"component/componentGeneric"); + if($add != "" || preg_match("/r/",$acl)) { + + $terminal = $value; + $terminal['type'] = "C"; + } + } else{ + + $name= preg_replace('/\$$/', '', $value['cn'][0]); + if (isset($value['sambaDomainName'])){ + $domain= " [".$value['sambaDomainName'][0]."]"; + } else { + $domain= ""; + } + $terminal=$value; + $terminal['type'] ="W"; + $terminal['domain'] = $name.$domain; + } + + if(count($terminal)){ + $this->terminals[]=$terminal; + } + } + + $tmp=array(); + foreach($this->terminals as $tkey => $val ){ + $tmp[strtolower($val['cn'][0]).$val['dn']]=$val; + } + ksort($tmp); + $this->terminals=array(); + foreach($tmp as $val){ + $this->terminals[]=$val; + } + reset ($this->terminals); + } + + function remove_lock() + { + if (isset($this->systab->dn)){ + del_lock ($this->systab->dn); + } + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + + $tabs = array( + "terminal" => array( "CLASS" =>"TERMTABS", "TABNAME" =>"termgeneric", + "TABCLASS" =>"termtabs", "ACL" =>"terminal"), + "workstation" => array( "CLASS" =>"WORKTABS", "TABNAME" =>"workgeneric", + "TABCLASS" =>"worktabs", "ACL" =>"workstation"), + "server" => array( "CLASS" =>"SERVTABS", "TABNAME" =>"servgeneric", + "TABCLASS" =>"servtabs", "ACL" =>"server"), + "printer" => array( "CLASS" =>"PRINTTABS", "TABNAME" =>"printgeneric", + "TABCLASS" =>"printtabs", "ACL" =>"printer"), + "phone" => array( "CLASS" =>"PHONETABS", "TABNAME" =>"phoneGeneric", + "TABCLASS" =>"phonetabs", "ACL" =>"phone"), + "component" => array( "CLASS" =>"COMPONENTTABS","TABNAME" =>"componentGeneric", + "TABCLASS" =>"componenttabs","ACL" =>"component")); + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->terminals[$s_entry]['dn']; + $oc = $this->terminals[$s_entry]['objectClass']; + $type = $this->get_system_type($this->terminals[$s_entry]); + + $tab_o = $tabs[$type]['CLASS']; + $tab_c = $tabs[$type]['TABCLASS']; + $acl = $tabs[$type]['ACL']; + + $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->terminals[$id]['dn']; + $oc = $this->terminals[$id]['objectClass']; + $type = $this->get_system_type($this->terminals[$id]); + + if(isset($tabs[$type])){ + $tab_o = $tabs[$type]['CLASS']; + $tab_c = $tabs[$type]['TABCLASS']; + $acl = $tabs[$type]['ACL']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl); + } + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + function get_system_type($attrs) + { + $classes = $attrs['objectClass']; + + $type= ""; + if (in_array_ics('ieee802Device', $classes)){ + $type= "component"; + }elseif (in_array_ics('gotoTerminal', $classes)){ + $type= "terminal"; + }elseif (in_array_ics('gotoWorkstation', $classes)){ + $type= "workstation"; + }elseif (in_array_ics('gotoPrinter', $classes)){ + $type= "printer"; + }elseif (in_array_ics('goFonHardware', $classes)){ + $type= "phone"; + }elseif (in_array_ics('goServer', $classes)){ + $type= "server"; + }elseif (in_array_ics('GOhard', $classes) && !isset($attrs['gotoMode']) && $this->arp_handling_active){ + $type= "ArpNewDevice"; + }elseif (in_array_ics('GOhard', $classes)){ + $type= "NewDevice"; + }elseif (in_array_ics('sambaAccount', $classes) || + in_array_ics('sambaSamAccount', $classes)){ + $type= "winstation"; + } + return ($type); + } + + + function convert_list($input) + { + $temp= ""; + $conv= array( + "NQ" => array("select_newsystem.png",_("New System from incoming")), + "D" => array("select_default.png",_("Template")), + "T" => array("select_terminal.png",_("Terminal")), + "L" => array("select_workstation.png",_("Workstation")), + "GL" => array("select_workstation_green.png",_("Workstation is installing")), + "YL" => array("select_workstation_yellow.png",_("Workstation is waiting for action")), + "RL" => array("select_workstation_red.png",_("Workstation installation failed")), + "F" => array("select_phone.png",_("Phone")), + "S" => array("select_server.png",_("Server")), + "GS" => array("select_server_green.png",_("Server is installing")), + "YS" => array("select_server_yellow.png",_("Server is waiting for action")), + "RS" => array("select_server_red.png",_("Server installation failed")), + "W" => array("select_winstation.png",_("Winstation")), + "C" => array("select_component.png",_("Network Device")), + "NT"=> array("select_new_terminal.png",_("New Terminal")), + "NL"=> array("select_new_workstation.png",_("New Workstation")), + "P" => array("select_printer.png",_("Printer"))); + + if((isset($input['is_new']))&&(!empty($input['is_new']))){ + $input['type']="N".$input['type']; + } + foreach ($conv as $key => $value){ + if($input['type']==$key){ + $tmp['img'] ="".$key.""; + $tmp['class']=$key; + return $tmp; + } + } + } + + + function getState($type, $state) + { + switch (preg_replace('/:.*$/', '', $state)) { + case 'installing': + $type= 'G'.$type; + break; + case 'error': + $type= 'R'.$type; + break; + case 'install': + case 'sysinfo': + case 'softupdate': + case 'scheduledupdate': + $type= 'Y'.$type; + break; + } + + + return ($type); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + /* !! Incoming dummy acls, required to defined acls for incoming objects + */ + static function plInfo() + { + return (array( + "plShortName" => _("Incoming objects"), + "plDescription" => _("Incoming objects"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 99, + "plSection" => array("administration"), + "plCategory" => array("incoming" => array( "description" => _("Incoming"), + "objectClass" => "")), + "plProvidedAcls"=> array() + + )); + } + + + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_terminalGeneric.inc b/gosa-core/plugins/admin/systems/class_terminalGeneric.inc new file mode 100644 index 000000000..be12d590e --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_terminalGeneric.inc @@ -0,0 +1,682 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $gotoMode= "disabled"; + var $gotoTerminalPath= ""; + var $gotoSwapServer= ""; + var $gotoSyslogServer= ""; + var $gotoSyslogServers = array(); + var $gotoNtpServer= array(); + var $gotoNtpServers= array(); + var $gotoSndModule= ""; + var $gotoFloppyEnable= ""; + var $gotoCdromEnable= ""; + var $ghCpuType= "-"; + var $ghMemSize= "-"; + var $ghUsbSupport= "-"; + var $ghNetNic= array(); + var $ghIdeDev= array(); + var $ghScsiDev= array(); + var $ghGfxAdapter= "-"; + var $ghSoundAdapter= "-"; + var $gotoLastUser= "-"; + var $netConfigDNS; + /* Needed values and lists */ + var $base= ""; + var $cn= ""; + var $orig_dn= ""; + + var $inheritTimeServer = true; + + /* Plugin side filled */ + var $modes= array(); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array("gotoMode", "gotoTerminalPath", + "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer", + "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule", + "ghCpuType", "ghMemSize","ghUsbSupport", + "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser"); + var $objectclasses= array("top", "gotoTerminal", "GOhard"); + + var $mapActions = array("reboot" => "", + "instant_update" => "softupdate", + "update" => "sceduledupdate", + "reinstall" => "install", + "rescan" => "", + "memcheck" => "memcheck", + "sysinfo" => "sysinfo"); + + var $fai_activated = FALSE; + var $view_logged = FALSE; + + var $member_of_ogroup = FALSE; + + function termgeneric (&$config, $dn= NULL, $parent= NULL) + { + /* Check if FAI is activated */ + $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + $this->fai_activated = TRUE; + } + + plugin::plugin ($config, $dn, $parent); + + if(!isset($this->parent->by_object['ogroup'])){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn")); + $this->member_of_ogroup = $ldap->count() >= 1; + } + + $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); + /* Read arrays */ + foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ + if (!isset($this->attrs[$val])){ + continue; + } + for ($i= 0; $i<$this->attrs[$val]['count']; $i++){ + array_push($this->$val, $this->attrs[$val][$i]); + } + } + + /* Create used ntp server array */ + $this->gotoNtpServer= array(); + if(isset($this->attrs['gotoNtpServer'])){ + $this->inheritTimeServer = false; + unset($this->attrs['gotoNtpServer']['count']); + foreach($this->attrs['gotoNtpServer'] as $server){ + $this->gotoNtpServer[$server] = $server; + } + } + + /* Set inherit checkbox state */ + if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){ + $this->inheritTimeServer = true; + $this->gotoNtpServer=array(); + } + + /* You can't inherit the NTP service, if we are not member in an object group */ + if(!$this->member_of_ogroup){ + $this->inheritTimeServer = FALSE; + } + + /* Create available ntp options */ + $this->gotoNtpServers = $this->config->data['SERVERS']['NTP']; + foreach($this->gotoNtpServers as $key => $server){ + if($server == "default"){ + unset($this->gotoNtpServers[$key]); + } + } + + $this->modes["disabled"]= _("disabled"); + $this->modes["text"]= _("text"); + $this->modes["graphic"]= _("graphic"); + + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } else { + $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); + } + + /* Create an array of all Syslog servers */ + $tmp = $this->config->data['SERVERS']['SYSLOG']; + foreach($tmp as $server){ + $visible = $server; + if($server == "default" && $this->member_of_ogroup) { + $visible = "["._("inherited")."]"; + } + $this->gotoSyslogServers[$server] = $visible; + } + + $this->orig_dn= $this->dn; + } + + function set_acl_base($base) + { + plugin::set_acl_base($base); + $this->netConfigDNS->set_acl_base($base); + } + + function set_acl_category($cat) + { + plugin::set_acl_category($cat); + $this->netConfigDNS->set_acl_category($cat); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","terminal/".get_class($this),$this->dn); + } + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){ + + /* Set FAIstate */ + if($this->fai_activated && $this->dn != "new"){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn,array("objectClass")); + $res = $ldap->fetch(); + + $attrs = array(); + $attrs['FAIstate'] = ""; + if(isset($this->mapActions[$_POST['saction']])){ + $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; + } + + for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $res['objectClass'][$i]; + } + + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } + + if($attrs['FAIstate'] == ""){ +#FIXME we should check if FAIobject is used anymore + $attrs['FAIstate'] = array(); + } + + $ldap->cd($this->dn); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/generic (FAIstate) with dn '%s' failed."),$this->dn)); + } + + switch($_POST['saction']){ + case 'wake': + $cmd= $this->config->search("termgeneric", "WAKECMD",array('tabs')); + + if ($cmd == ""){ + print_red(_("No WAKECMD definition found in your gosa.conf")); + } else { + exec ($cmd." ".$this->netConfigDNS->macAddress, $dummy, $retval); + if ($retval != 0){ + print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); + } + } + break; + + case 'reboot': + $cmd= $this->config->search("termgeneric", "REBOOTCMD",array('tabs')); + if ($cmd == ""){ + print_red(_("No REBOOTCMD definition found in your gosa.conf")); + } else { + exec ($cmd." ".$this->cn, $dummy, $retval); + if ($retval != 0){ + print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); + } + } + break; + + case 'halt': + $cmd= $this->config->search("termgeneric", "HALTCMD",array('tabs')); + if ($cmd == ""){ + print_red(_("No HALTCMD definition found in your gosa.conf")); + } else { + exec ($cmd." ".$this->cn, $dummy, $retval); + if ($retval != 0){ + print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); + } + } + break; + } + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Do we represent a valid terminal? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no terminal features.").""; + return($display); + } + + /* Add new ntp Server to our list */ + if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){ + $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; + } + + /* Delete selected NtpServer for list of used servers */ + if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){ + foreach($_POST['gotoNtpServerSelected'] as $name){ + unset($this->gotoNtpServer[$name]); + } + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $smarty->assign("cn", $this->cn); + $smarty->assign("staticAddress", ""); + + $smarty->assign("bases", $this->get_allowed_bases()); + + /* tell smarty the inherit checkbox state */ + $smarty->assign("inheritTimeServer",$this->inheritTimeServer); + + /* Check if terminal is online */ + $query= "fping -q -r 1 -t 500 ".$this->cn; + exec ($query, $dummy, $retval); + + /* Offline */ + if ($retval == 0){ + $smarty->assign("actions", array( "halt" => _("Switch off"), + "reboot" => _("Reboot"), + "memcheck" => _("Memory test"), + "sysinfo" => _("System analysis"))); + } else { + $smarty->assign("actions", array("wake" => _("Wake up"), + "memcheck" => _("Memory test"), + "sysinfo" => _("System analysis"))); + } + + /* Arrays */ + $smarty->assign("modes", $this->modes); + + $tmp2 = array(); + foreach($this->config->data['SERVERS']['NFS'] as $server){ + if($server != "default"){ + $tmp2[$server]= $server; + }else{ + if($this->member_of_ogroup){ + $tmp2[$server]="["._("inherited")."]"; + } + } + } + + $smarty->assign("nfsservers", $tmp2); + $smarty->assign("syslogservers", $this->gotoSyslogServers); + + $tmp = array(); + foreach($this->gotoNtpServers as $server){ + if(!in_array($server,$this->gotoNtpServer)){ + $tmp[$server] = $server; + } + } + + $smarty->assign("ntpservers", $tmp); + $smarty->assign("fai_activated",$this->fai_activated); + + /* Variables */ + foreach(array("base", "gotoMode", "gotoTerminalPath", "gotoSwapServer","gotoSyslogServer", "gotoNtpServer") as $val){ + $smarty->assign($val."_select", $this->$val); + } + + $smarty->assign("member_of_ogroup",$this->member_of_ogroup); + + /* Show main page */ + $str = $this->netConfigDNS->execute(); + if(is_object($this->netConfigDNS->dialog)){ + return($str); + } + $smarty->assign("netconfig", $str); + return($smarty->fetch (get_template_path('terminal.tpl', TRUE))); + } + + function remove_from_parent() + { + if($this->acl_is_removeable()){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->cat($this->dn, array('dn')); + if($ldap->count()){ + $this->netConfigDNS->remove_from_parent(); + $ldap->rmDir($this->dn); + + new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of object system terminal/generic with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + } + } + } + + + /* Save data to object */ + function save_object() + { + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + /* Set new base if allowed */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + + $this->netConfigDNS->save_object(); + + /* Save terminal path to parent since it is used by termstartup, too */ + if(isset($this->parent->by_object['termstartup'])){ + $this->parent->by_object['termstartup']->gotoTerminalPath= $this->gotoTerminalPath; + } + + if(isset($_POST['termgeneric_posted'])){ + if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){ + $this->inheritTimeServer = true; + }else{ + $this->inheritTimeServer = false; + } + } + + if(isset($_POST["inheritAll"])){ + $this->set_everything_to_inherited(); + } + + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Skip IP & Mac checks if this is a template */ + if($this->cn != "default"){ + $message= array_merge($message, $this->netConfigDNS->check()); + } + + /* Permissions for that base? */ + $this->dn= "cn=".$this->cn.",ou=terminals,ou=systems,".$this->base; + + if ($this->cn == ""){ + $message[]= _("The required field 'Terminal name' is not set."); + } + + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) ){ + $message[] = _("Please specify a valid name for this object."); + } + + if ($this->orig_dn == 'new'){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->base); + + /* It is possible to have a 'default' terminal on every base */ + if($this->cn == "default"){ + $ldap->cat($this->dn); + }else{ + $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn")); + } + if ($ldap->count() != 0){ + while ($attrs= $ldap->fetch()){ + if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,ou=incoming,/", $ldap->getDN())){ + continue; + } else { + if ($attrs['dn'] != $this->orig_dn){ + $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); + break; + } + } + } + } + } + + /* Check for valid ntpServer selection */ + if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){ + $message[]= _("There must be at least one NTP server selected, or the inherit mode activated."); + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + + /* Move object if requested */ + if( $this->orig_dn != 'new' && $this->dn != $this->orig_dn){ + $this->move($this->orig_dn, $this->dn); + } + + plugin::save(); + + /* Strip out 'default' values */ + foreach (array("gotoTerminalPath", "gotoSwapServer", "gotoSyslogServer") as $val){ + if(isset($this->attrs[$val])){ + if ($this->attrs[$val] == "default"){ + $this->attrs[$val]= array(); + } + } + } + + /* Add missing arrays */ + foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){ + if (isset ($this->$val) && count ($this->$val) != 0){ + $this->attrs["$val"]= $this->$val; + } + } + + /* Remove all empty values */ + if ($this->orig_dn == 'new'){ + $attrs= array(); + foreach ($this->attrs as $key => $val){ + if (is_array($val) && count($val) == 0){ + continue; + } + $attrs[$key]= $val; + } + $this->attrs= $attrs; + } + + /* Set ntpServers */ + $this->attrs['gotoNtpServer'] = array(); + if(!$this->inheritTimeServer){ + foreach($this->gotoNtpServer as $server){ + $this->attrs['gotoNtpServer'][] = $server; + } + } + + /* Append gosaAdministrativeUnitTag to objectClass if gosaUnitTag isset */ + if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){ + $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + if ($this->orig_dn == 'new'){ + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + if (!count($this->attrs['gotoNtpServer'])){ + unset($this->attrs['gotoNtpServer']); + } + $ldap->add($this->attrs); + new log("create","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } else { + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } + + /* cn=default and macAddress=- indicates that this is a template */ + if($this->cn == "default"){ + $this->netConfigDNS->macAddress = "-"; + } + + $this->netConfigDNS->cn = $this->cn; + $this->netConfigDNS->save(); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/generic with dn '%s' failed."),$this->dn)); + } + + + + + + /* Display generic part for server copy & paste */ + function getCopyDialog() + { + $vars = array("cn"); + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $smarty->assign("object","terminal"); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + if(isset($source['macAddress'][0])){ + $this->netConfigDNS->macAddress = $source['macAddress'][0]; + } + if(isset($source['ipHostNumber'][0])){ + $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; + } + + /* Create used ntp server array */ + $this->gotoNtpServer= array(); + if(isset($source['gotoNtpServer'])){ + $this->inheritTimeServer = false; + unset($source['gotoNtpServer']['count']); + foreach($source['gotoNtpServer'] as $server){ + $this->gotoNtpServer[$server] = $server; + } + } + + /* Set inherit checkbox state */ + if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){ + $this->inheritTimeServer = true; + $this->gotoNtpServer=array(); + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Terminal"), + "plDescription" => _("Terminal generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("administration"), + "plCategory" => array("terminal" => array( "description" => _("Terminal"), + "objectClass" => "gotoTerminal")), + "plProvidedAcls"=> array( + "gotoMode" => _("Mode"), + "gotoTerminalPath" => _("Root server"), + "gotoSwapServer" => _("Swap server"), + "gotoSyslogServer" => _("Syslog server enabled"), + "gotoNtpServer" => _("Ntp server settings"), + "base" => _("Base"), + "cn" => _("Name"), + "gotoRootPasswd" => _("Root password"), + "FAIstate" => _("Action flag")) + )); + } + + + function set_everything_to_inherited() + { + $this->gotoTerminalPath = "default"; + $this->gotoSwapServer = "default" ; + $this->gotoSyslogServer = "default"; + $this->inheritTimeServer = TRUE; + + /* Set workstation service attributes to inherited */ + if($this->member_of_ogroup && isset($this->parent->by_object['termservice'])){ + foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant", + "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){ + $this->parent->by_object['termservice']->$name = "default"; + } + } + + /* Set workstation startup attributes to inherited */ + if($this->member_of_ogroup && isset($this->parent->by_object['termstartup'])){ + $this->parent->by_object['termstartup']->gotoBootKernel = "default-inherited"; + $this->parent->by_object['termstartup']->gotoLdapServer = "default-inherited"; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_terminalInfo.inc b/gosa-core/plugins/admin/systems/class_terminalInfo.inc new file mode 100644 index 000000000..0a21884d2 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_terminalInfo.inc @@ -0,0 +1,255 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $ghCpuType= "-"; + var $ghMemSize= "-"; + var $macAddress= "-"; + var $ghUsbSupport= "-"; + var $ghNetNic= array(); + var $ghIdeDev= array(); + var $ghScsiDev= array(); + var $ghGfxAdapter= "-"; + var $ghSoundAdapter= "-"; + var $ghInventoryNumber= "-"; + var $gotoLastUser= "-"; + var $gotoFloppyEnable= ""; + var $gotoCdromEnable= ""; + + /* Needed values and lists */ + var $base= ""; + var $cn= ""; + var $view_logged = FALSE; + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array("cn", "gotoMode", "gotoTerminalPath", "gotoFloppyEnable", + "gotoCdromEnable", "ghInventoryNumber", + "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer", + "ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport", + "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser"); + var $objectclasses= array("GOhard"); + + function terminfo (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config,$dn); + + /* Read arrays */ + foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ + if (!isset($this->attrs[$val])){ + continue; + } + for ($i= 0; $i<$this->attrs[$val]['count']; $i++){ + array_push($this->$val, $this->attrs[$val][$i]); + } + } + + /* Fix USB entry */ + if ($this->ghUsbSupport == "true"){ + $this->ghUsbSupport= _("present"); + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","terminal/".get_class($this),$this->dn); + } + + /* Do we represent a valid terminal? */ + if (!$this->is_account && $this->parent === NULL){ + echo "\"\" ". + _("This 'dn' has no terminal features.").""; + return; + } + + $smarty= get_smarty(); + $display= ""; + if(!is_callable("snmpget")){ + print_red(_("There is no php snmp module installed, can't gather any informations.")); + + $smarty->assign("load", progressbar(0,100,15,true)); + $smarty->assign("mem", progressbar(0,100,15,true)); + $smarty->assign("swap", progressbar(0,100,15,true)); + foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd","status","ghNetNic", "ghIdeDev", "ghScsiDev","FloppyDevice", "CdromDevice","active") as $val){ + $smarty->assign("$val", ""._("unknown status").""); + } + + + $display =""; + }else + /* Default entry? */ + if ($this->cn == "default"){ + $display= "

"; + $display.= _("This is a virtual terminal which has no properties to show here."); + $display.= "
"; + } else { + + /* Get template object */ + $smarty->assign("staticAddress", ""); + + /* Prevent undefined variable .... */ + $smarty->assign("load", progressbar(0,100,15,true)); + $smarty->assign("mem", progressbar(0,100,15,true)); + $smarty->assign("swap", progressbar(0,100,15,true)); + + /* Check if terminal is online */ + $query= "fping -q -r 1 -t 500 ".$this->cn; + exec ($query, $dummy, $retval); + + if ($retval == 0){ + $smarty->assign("status", _("online")); + $smarty->assign("active", "true"); + + /* Fill data if we have snmp */ + $host= $this->cn; + + /* Use 'goto' as snmp community or the configured value from the config */ + $community= 'goto'; + $str = search_config($this->config->data['TABS'],"terminfo","SNMPCOMMUNITY"); + if(!empty($str)){ + $community = $str; + } + + /* Get memory informations */ + if(!is_callable("snmpget")){ + $MemFree = false; + }else{ + $MemFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailReal.0"); + } + if ($MemFree != FALSE){ + $MemFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemFree); + $MemTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalReal.0"); + $MemTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemTotal); + if ($MemTotal != 0){ + $smarty->assign("mem",progressbar( (int)(($MemTotal - $MemFree)*100/$MemTotal),100,15,true)); + ; + } + $SwapFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailSwap.0"); + $SwapFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapFree); + $SwapTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalSwap.0"); + $SwapTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapTotal); + if ($SwapTotal != 0){ +#$smarty->assign("swap", (int)(($SwapTotal - $SwapFree)*100/$SwapTotal)); + $smarty->assign("swap", progressbar(0,100,15,true)); + } + + /* Get system uptime */ + $sysup= @snmpget($host, $community, "SNMPv2-MIB::sysUpTime.0"); + $smarty->assign("uptime", preg_replace('/^.* ([0-9:]+)\..*$/', '\\1', $sysup)); + + /* Get system load */ + $sysload= @snmpget($host, $community, "UCD-SNMP-MIB::laLoad.2"); + $sysload= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $sysload); + + $smarty->assign("load", progressbar($sysload*100,100,15,true)); + + /* Get status for key processes */ + $processes= @snmpwalk($host, $community, "UCD-SNMP-MIB::prNames"); + $check4= array("sshd", "cupsd", "artsd", "X", "saned"); + foreach ($check4 as $pname){ + $eflag= -1; + foreach ($processes as $key => $val){ + $process= preg_replace('/^.*[:=] (.*)$/', '\\1', $val); + if ($process == $pname){ + $index= preg_replace('/^.*\.([0-9]+) [:=] .*$/', '\\1', $val); + $res= @snmpget($host, $community, "UCD-SNMP-MIB::prErrorFlag.$index"); + $eflag= preg_replace('/^.*[:=] /', '', $res); + break; + } + } + switch ($eflag){ + case 0: + $smarty->assign("$pname", "\""._("running")."\""); + break; + case 1: + $smarty->assign("$pname", "\""._("not"); + break; + default: + $smarty->assign("$pname", _("not defined")); + } + } + } else { + foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd") as $val){ + $smarty->assign("$val", ""._("unknown status").""); + } + } + /* Check for mounted partitions (show max 8 partitions) */ + $partitions= ""; + for ($n= 1; $n<9; $n++){ + $device= @snmpget($host, $community, "UCD-SNMP-MIB::dskDevice.$n"); + if ($device == ""){ + break; + } + $device= preg_replace('/^STRING: */', '', $device); + $usage= @snmpget($host, $community, "UCD-SNMP-MIB::dskPercent.$n"); + $usage= preg_replace('/^INTEGER: */', '', $usage); + $partitions.= "$device".progressbar($usage,100,16,true)."\n"; + } + $smarty->assign("partitions", $partitions); + } else { + $smarty->assign("status", _("offline")); + $smarty->assign("active", "false"); + } + + /* Set floppy and cdrom status */ + foreach(array("Floppy", "Cdrom") as $val){ + $name= "goto".$val."Enable"; + if ($this->$name == "YES"){ + $status= _("present"); + } else { + $status= "-"; + } + $smarty->assign($val."Device", $status); + } + + /* Show main page */ + foreach(array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ + if (!count($this->$val)){ + $this->$val= "-"; + } + $smarty->assign($val, $this->$val); + } + } + foreach(array("ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport", + "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "ghInventoryNumber") as $val){ + + $smarty->assign($val, $this->$val); + } + $display= $smarty->fetch (get_template_path('info.tpl', TRUE)); + + return ($display); + } + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + } + + + /* Save to LDAP */ + function save() + { + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_terminalService.inc b/gosa-core/plugins/admin/systems/class_terminalService.inc new file mode 100644 index 000000000..49f804692 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_terminalService.inc @@ -0,0 +1,527 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $gotoLpdEnable= FALSE; + var $gotoXMonitor= ""; + var $gotoXMethod= ""; + var $gotoXdmcpServer= ""; + var $gotoFontPath= ""; + var $gotoXDriver= ""; + var $gotoXResolution= ""; + var $gotoXColordepth= ""; + var $gotoXHsync= ""; + var $gotoXVsync= ""; + var $gotoXKbModel= ""; + var $gotoXKbLayout= ""; + var $gotoXKbVariant= ""; + var $gotoXMouseType= ""; + var $gotoXMouseport= ""; + var $gotoLpdServer= ""; + var $gotoScannerEnable= ""; + var $gotoScannerModel= ""; + var $gotoScannerClients= ""; + var $gotoScannerBackend= ""; + var $goFonHardware= "automatic"; + + var $AutoSync = false; + var $view_logged = FALSE; + + /* Needed values and lists */ + var $ignore_account= TRUE; + var $base= ""; + var $cn= ""; + var $orig_dn= ""; + var $XMethods= array(); + var $XDrivers= array(); + var $XResolutions= array(); + var $XColordepths= array(); + var $XKbModels= array (); + var $XKbLayouts= array (); + var $XKbVariants= array (); + var $MouseTypes= array(); + var $MousePorts= array(); + var $gotoScannerModels= array(); + var $hardware_list= array(); + var $used_hardware= array(); + + + /* attribute list for save action */ + var $attributes= array("cn", "gotoLpdEnable", "gotoXMonitor", "gotoXMethod", "gotoXdmcpServer", + "gotoFontPath", "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoXHsync", "gotoXVsync", "gotoLpdEnable", "gotoLpdServer", + "gotoScannerEnable", "gotoScannerModel", "gotoScannerClients", + "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant", + "gotoXMouseType", "gotoXMouseport", "goFonHardware"); + var $objectclasses= array("GOhard"); + + + function termservice (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + /* Get list of available xdrivers */ + $this->XDrivers = $this->getListOfXDrivers(); + array_unshift($this->XDrivers, "["._("unknown")."]"); + + $this->XResolutions= array( + "default" => "["._("inherited")."]" , + "640x480" => "640x480", + "800x600" => "800x600", + "1024x768" => "1024x768", + "1152x864" => "1152x864", + "1280x1024" => "1280x1024", + "1400x1050" => "1400x1050", + "1600x1200" => "1600x1200"); + + if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){ + $file = $this->config->data['MAIN']['RESOLUTION_HOOK']; + + if(is_readable($file)){ + $str = file_get_contents($file); + $lines = split("\n",$str); + foreach($lines as $line){ + $line = trim($line); + if(!empty($line)){ + $this->XResolutions[$line]=$line; + } + } + //natcasesort($this->gotoXResolutions); + }else{ + print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file)); + } + } + + $this->XColordepths= array( + "default" => "["._("inherited")."]", + "8" => "8 " ._("bit"), + "15" => "15 "._("bit"), + "16" => "16 "._("bit"), + "24" => "24 "._("bit")); + + $this->XKbModels['default']= "["._("inherited")."]"; + foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex", + "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless", + "logiinetnav", "logiinternet", "macintosh", "microsoft", + "microsoftpro", "omnikey101", "pc101", "pc102", "pc104", + "pc105", "rapidaccess", "rapidaccess2", "winbook") as $type){ + $this->XKbModels[$type] = $type; + } + + /* Additional values will be extracted from CONFIG_DIR.keyboardLayouts */ + $this->XKbLayouts= array ("default"=>"["._("inherited")."]","de"=> "de","intl" =>"intl","us" =>"us"); + $this->XKbVariants= array ("default"=>"["._("inherited")."]", "nodeadkeys"=>"nodeadkeys", "basic"=>"basic"); + + $this->MouseTypes= array( "AUTO" => "["._("inherited")."]" , "ImPS/2" => "ImPS/2", + "PS/2" => "PS/2" , "Microsoft" => "Microsoft", + "Logitech" => "Logitech"); + + $this->MousePorts= array("AUTO" =>"["._("inherited")."]" , "/dev/ttyS0" => "/dev/ttyS0", + "/dev/ttyS1" => "/dev/ttyS1" , "/dev/psaux" => "/dev/psaux", + "/dev/input/mice" =>"/dev/input/mice"); + + + /* try to read additional keyboard layouts + */ + if(file_exists(CONFIG_DIR."/keyboardLayouts")){ + if(is_readable(CONFIG_DIR."/keyboardLayouts")){ + $str = file_get_contents(CONFIG_DIR."/keyboardLayouts"); + $tmp = split("\n",$str); + foreach($tmp as $entry){ + if((!empty($entry)) && (!preg_match("/^#/",$entry))){ + $entry = trim($entry); + $tmp2 = split ("\:",$entry); + $la = trim($tmp2[0]); // What would be saved to ldap + $da = trim($tmp2[1]); // This wis displayed in the listbox + $this->XKbLayouts [ $la] = $da; + } + } + } + } + + /* Load scanner models */ + $fcontents = file ($this->config->basedir."/include/scanner.inc"); + while (list ($line_num, $line) = each ($fcontents)) { + preg_match('/^(\w+) "([^"]+)" "([^"]+)" "([^"]+)"/', "$line", $matches); + $this->gotoScannerModels[$matches[2]." - ".$matches[3]]= $matches[1]."|".$matches[4]; + } + ksort ($this->gotoScannerModels); + + /* Initialize methods */ + $this->XMethods["default"]= _("default"); + $this->XMethods["indirect"]= _("show chooser"); + $this->XMethods["query"]= _("direct"); +#$this->XMethods["squery"]= _("direct via ssh"); +#$this->XMethods["nquery"]= _("direct via nx"); + $this->XMethods["load"]= _("load balanced"); +#$this->XMethods["sload"]= _("load balanced via ssh"); +#$this->XMethods["nload"]= _("load balanced via nx"); + $this->XMethods["rdp"]= _("Windows RDP"); + $this->XMethods["citrix"]= _("ICA client"); + + $this->orig_dn= $this->dn; + + /* Load hardware list */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); + while ($attrs= $ldap->fetch()){ + $cn= $attrs['cn'][0]; + if (isset($attrs['description'])){ + $description= " - ".$attrs['description'][0]; + } else { + $description= ""; + } + $this->hardware_list[$cn]= "$cn$description"; + } + + /* Eventually colorize phones */ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware')); + while($attrs = $ldap->fetch()){ + $cn = $attrs['goFonHardware'][0]; + if(isset($this->hardware_list[$cn])){ + $this->used_hardware[$cn]= $cn; + } + } + + $this->hardware_list["automatic"]= _("automatic"); + ksort($this->hardware_list); + + /* Convert gotoLpdEnable */ + $this->gotoLpdEnable= preg_match("/yes/i",$this->gotoLpdEnable); + + /* Load hardware list */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))"); + if ($ldap->count() == 1){ + $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport"); + $attrs= $ldap->fetch(); + + foreach ($map as $name){ + if (!isset($attrs[$name][0])){ + continue; + } + + switch ($name){ + case 'gotoXResolution': + $this->XResolutions['default'] = _("inherited").' ['.$attrs[$name][0].']' ; + break; + case 'gotoXColordepth': + $this->XColordepths['default'] = _("inherited").' ['.$attrs[$name][0].' '._('Bit').']'; + break; + case 'gotoXKbModel': + $this->XKbModels['default'] = _("inherited").' ['.$attrs[$name][0].']'; + break; + case 'gotoXKbLayout': + $this->XKbLayouts['default'] = _("inherited").' ['.$attrs[$name][0].']'; + break; + case 'gotoXKbVariant': + $this->XKbVariants['default'] = _("inherited").' ['.$attrs[$name][0].']' ; + break; + case 'gotoXMouseType': + $this->MouseTypes['AUTO'] = _("inherited").' ['.$attrs[$name][0].']' ; + break; + case 'gotoXMouseport': + $this->MousePorts['AUTO'] = _("inherited").' ['.$attrs[$name][0].']' ; + break; + } + } + } + if(preg_match("/\+/",$this->gotoXHsync)){ + $this->AutoSync = true; + $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync); + $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync); + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","terminal/".get_class($this),$this->dn); + } + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Do we represent a valid terminal? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no terminal features.").""; + return ($display); + } + + /* Show main page */ + $smarty= get_smarty(); + + /* Assign acls */ + $tmp= $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + + /* Arrays */ + foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths", + "gotoScannerModels", "XKbModels","XKbVariants", + "MouseTypes", "MousePorts") as $val){ + $smarty->assign("$val", $this->$val); + } + $smarty->assign("XKbLayouts", $this->XKbLayouts); + $smarty->assign("XKbLayoutKeys",array_flip($this->XKbLayouts)); + + $smarty->assign("xdmcpservers", $this->config->data['SERVERS']['TERMINAL']); + $smarty->assign("fontservers", $this->config->data['SERVERS']['FONT']); + $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); + $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); + + /* Variables - select */ + foreach(array("gotoXMethod", "gotoXdmcpServer", "gotoFontPath", + "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoLpdServer", "gotoScannerModel", "gotoXKbModel", "gotoXKbLayout", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ + + $smarty->assign($val."_select", $this->$val); + } + + /* Variables */ + foreach(array("gotoXHsync", "gotoXVsync") as $val){ + $smarty->assign($val, $this->$val); + } + $smarty->assign("staticAddress", ""); + + /* Checkboxes */ + foreach(array("gotoLpdEnable", "gotoScannerEnable") as $val){ + if ($this->$val == TRUE) { + $smarty->assign("$val", "checked"); + } else { + $smarty->assign("$val", ""); + } + } + + /* Phone stuff */ + $smarty->assign ("goFonHardware", $this->goFonHardware); + $hl= "\n"; + $smarty->assign ("hardware_list", $hl); + $smarty->assign ("gotoXMonitor", $this->gotoXMonitor); + + $smarty->assign("AutoSyncACL",$this->getacl("AutoSync")); + + $smarty->assign("AutoSyncCHK"," "); + if($this->AutoSync){ + $smarty->assign("AutoSyncCHK"," checked "); + $smarty->assign("gotoXVsyncACL", preg_replace("/w/","",$this->getacl("gotoXVsync"))); + $smarty->assign("gotoXHsyncACL", preg_replace("/w/","",$this->getacl("gotoXHsync"))); + } + + /* Show main page */ + return($smarty->fetch (get_template_path('terminalService.tpl', TRUE))); + } + + function remove_from_parent() + { + new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs)); + $this->handle_post_events("remove"); + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + + /* Save checkbox state */ + if (isset ($_POST['gotoXMethod'])){ + foreach (array("gotoLpdEnable", "gotoScannerEnable") as $val){ + + if($this->acl_is_writeable($val)){ + if (!isset ($_POST["$val"])){ + $this->$val= FALSE; + } else { + $this->$val= TRUE; + } + } + } + } + + if(isset($_POST['gotoXDriver'])){ + if(isset($_POST['AutoSync'])){ + $this->AutoSync = true; + }else{ + $this->AutoSync = false; + } + } + + /* Default entries can use blank hsync/vsync entries */ + if ($this->dn != "" && $this->cn != "default" && $this->cn != "default"){ + + /* But only if no auto sync is enabled... */ + if (!$this->AutoSync){ + + /* Check vsync for correct usage */ + $val= preg_replace ("/\s/", "", $this->gotoXVsync); + if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXVsync")){ + + $message[]= _("Please specify a valid VSync range."); + } elseif ($this->acl_is_writeable("gotoXVsync")){ + list($v1,$v2)= preg_split ("/[-+]/", $val); + if ($v2 != ""){ + if ($v1 > $v2){ + $message[]= _("Please specify a valid VSync range."); + } + } + } + + /* Check hsync for correct usage */ + $val= preg_replace ("/\s/", "", $this->gotoXHsync); + if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXHsync")){ + + $message[]= _("Please specify a valid HSync range."); + } elseif ($this->acl_is_writeable("gotoXHsync")){ + list($v1,$v2)= preg_split ("/[-+]/", $val); + if ($v2 != ""){ + if ($v1 > $v2){ + $message[]= _("Please specify a valid HSync range."); + } + } + } + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* Convert to string */ + $this->gotoLpdEnable= $this->gotoLpdEnable?"Yes":"No"; + + plugin::save(); + + /* Strip out 'default' values */ + foreach(array("gotoXMethod", "gotoXdmcpServer", "gotoFontPath", + "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoLpdServer", "gotoScannerModel", "gotoXKbModel", "gotoXKbLayout", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ + + if ($this->attrs[$val] == "default"){ + $this->attrs[$val]= array(); + } + } + + if($this->AutoSync){ + $this->attrs['gotoXHsync'] = "30+55"; + $this->attrs['gotoXVsync'] = "50+70"; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/service with dn '%s' failed."),$this->dn)); + $this->handle_post_events("modify"); + } + + + function getListOfXDrivers() + { + $drivers = array(); + + /* Generate a list of xdrivers from CONFIG_DIR/xdrivers */ + if (file_exists(CONFIG_DIR.'/xdrivers')){ + $xdrivers = file (CONFIG_DIR.'/xdrivers'); + foreach ($xdrivers as $line){ + if (!preg_match ("/^#/", $line)){ + $drivers[]= trim($line); + } + } + } else { + $drivers = array("ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", "fglrx", + "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc", "nv", "nvidia", + "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion", + "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware"); + } + return($drivers); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Service"), + "plDescription" => _("Terminal service"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 3, + "plSection" => array("administration"), + "plCategory" => array("terminal"), + + "plProvidedAcls"=> array( + "gotoXMonitor" => _("Monitor"), + "gotoXMethod" => _("Method"), + "gotoXdmcpServer" => _("Remote desktop"), + "gotoFontPath" => _("Font path"), + "gotoXDriver" => _("Gfx driver"), + "gotoXResolution" => _("Gfx resolution"), + "gotoXColordepth" => _("Gfx color depth"), + "gotoXHsync" => _("Hsync"), + "gotoXVsync" => _("Vsync"), + "AutoSync" => _("Auto-Sync"), + "gotoLpdEnable" => _("Printer service enabled"), + "gotoLpdServer" => _("Spool server"), + "gotoScannerEnable" => _("Scanner enabled"), + "gotoScannerModel" => _("Scanner model"), + "gotoXKbModel" => _("Keyboard model"), + "gotoXKbLayout" => _("Keyboard layout"), + "gotoXKbVariant" => _("Keyboard variant"), + "gotoXMouseType" => _("Mouse type"), + "gotoXMouseport" => _("Mouse port"), + "goFonHardware" => _("Telephone hardware")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_terminalStartup.inc b/gosa-core/plugins/admin/systems/class_terminalStartup.inc new file mode 100644 index 000000000..0174459e3 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_terminalStartup.inc @@ -0,0 +1,582 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $bootmode= "G"; + var $goLdapServerList= array(); + var $gotoBootKernel= "default-inherit"; + var $gotoKernelParameters= ""; + var $gotoLdapServer= ""; + var $gotoModules= array(); + var $gotoTerminalPath= ""; + var $gotoBootKernels= array(); + + /* Ldap server list */ + var $gotoLdapServers = array(); + var $gotoLdapServerList = array(); + var $gotoLdap_inherit = FALSE; + + /* Share */ + var $gotoShares = array();// Currently Share Option + var $gotoShare = ""; // currently selected Share Option + var $gotoShareSelections= array();// Available Shares for this account in Listbox format + var $gotoAvailableShares= array();// Available Shares for this account + + + /* attribute list for save action */ + var $attributes= array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters","gotoModules"); + var $objectclasses= array("GOhard"); + var $view_logged = FALSE; + + /* Helper */ + var $customParameters= ""; + var $orig_dn= ""; + var $ignore_account= TRUE; + + function termstartup (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $this->gotoBootKernels = array("default-inherit"=>"["._("inherited")."]"); + + /* Get arrays */ + foreach (array("gotoModules") as $val){ + $this->$val = array(); + if (isset($this->attrs["$val"]["count"])){ + for ($i= 0; $i<$this->attrs["count"]; $i++){ + if (isset($this->attrs["$val"][$i])){ + array_push($this->$val, $this->attrs["$val"][$i]); + } + } + } + sort ($this->$val); + $this->$val= array_unique($this->$val); + } + + /* Parse Kernel Parameters to decide what boot mode is enabled */ + if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){ + $this->bootmode= "G"; + } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){ + $this->bootmode= "D"; + } elseif ($this->gotoKernelParameters == "") { + $this->bootmode= "G"; + } else { + $this->bootmode= "T"; + } + if (preg_match("/ o /", $this->gotoKernelParameters)){ + $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters); + } else { + $this->customParameters= ""; + } + + /* Prepare Shares */ + if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){ + unset($this->attrs['gotoShare']['count']); + foreach($this->attrs['gotoShare'] as $share){ + $tmp = $tmp2 = array(); + $tmp = split("\|",$share); + $tmp2['server'] =$tmp[0]; + $tmp2['name'] =$tmp[1]; + $tmp2['mountPoint'] =$tmp[2]; + $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; + } + } + + $this->gotoShareSelections= $config->getShareList(true); + $this->gotoAvailableShares= $config->getShareList(false); + + $this->orig_dn= $this->dn; + + /* Get list of boot kernels */ + if (isset($this->config->data['TABS'])){ + $command= $this->config->search(get_class($this), "KERNELS",array('tabs')); + + if (!check_command($command)){ + $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command, + get_class($this)); + } else { + $fh= popen($command, "r"); + while (!feof($fh)) { + $buffer= trim(fgets($fh, 256)); + + if(!empty($buffer)){ + + $name=$value = $buffer; + + if(preg_match("/:/",$buffer)){ + $name = preg_replace("/:.*$/","",$buffer); + $value= preg_replace("/^.*:/","",$buffer); + $this->gotoBootKernels[$name]= $name.":".$value; + }else{ + $this->gotoBootKernels[$name]= $value; + } + } + } + pclose($fh); + } + + } + + foreach($this->config->data['SERVERS']['LDAP'] as $server) { + $this->gotoLdapServerList[]= $server; + } + if(isset($this->attrs['gotoLdapServer'])){ + unset($this->attrs['gotoLdapServer']['count']); + sort($this->attrs['gotoLdapServer']); + foreach($this->attrs['gotoLdapServer'] as $value){ + $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value); + } + } + if(!count($this->gotoLdapServers)){ + $this->gotoLdap_inherit = TRUE; + } + + /* Load hardware list */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))"); + if ($ldap->count() == 1){ + $map= array("gotoLdapServer"); + $attrs= $ldap->fetch(); + + foreach ($map as $name){ + if (!isset($attrs[$name][0])){ + continue; + } + + switch ($name){ + case 'gotoLdapServer': + $this->goLdapServerList= array_merge(array('default-inherit' => _("inherited").' ['.$attrs[$name][0].']' ), $this->goLdapServerList); + break; + } + } + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","terminal/".get_class($this),$this->dn); + } + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Do we represent a valid terminal? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no terminal features.").""; + return ($display); + } + + /* Add module */ + if (isset ($_POST['add_module'])){ + if ($_POST['module'] != "" && $this->acl_is_writeable("gotoMode")){ + $this->add_list ($this->gotoModules, $_POST['module']); + } + } + + /* Delete module */ + if (isset ($_POST['delete_module'])){ + if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoMode")){ + $this->del_list ($this->gotoModules, $_POST['modules_list']); + } + } + + /* Show main page */ + $smarty= get_smarty(); + + /* Assign acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + + /* In this section server shares will be defined + * A user can select one of the given shares and a mount point + * and attach this combination to his setup. + */ + $smarty->assign("gotoShareSelections", $this->gotoShareSelections); + $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections)); + $smarty->assign("gotoBootKernels",$this->gotoBootKernels); + + /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry + * This entry will be, a combination of mountPoint and sharedefinitions + */ + if(isset($_POST['gotoShareAdd']) && $this->acl_is_writeable("gotoShare")){ + /* We assign a share to this user, if we don't know where to mount the share */ + if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){ + print_red(_("You must specify a valid mount point.")); + }else{ + $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']]; + $s_mount = $_POST['gotoShareMountPoint']; + /* Preparing the new assignment */ + $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share; + $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount; + } + } + + /* if the Post gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected) + * If there is no defined share selected, we will abort the deletion without any message + */ + if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare'])) && $this->acl_is_writeable("gotoShare")){ + unset($this->gotoShares[$_POST['gotoShare']]); + } + + $smarty->assign("gotoShares",$this->printOutAssignedShares()); + $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares())); + + /* Create divSelectBox for ldap server selection + */ + $SelectBoxLdapServer = new divSelectBox("LdapServer"); + $SelectBoxLdapServer->SetHeight(80); + + /* Add new ldap server to the list */ + if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){ + if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){ + $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']]; + if(!in_array($to_add,$this->gotoLdapServers)){ + $this->gotoLdapServers[] = $to_add; + } + } + } + + /* Move ldap servers up and down */ + if(!$this->gotoLdap_inherit){ + foreach($_POST as $name => $value){ + if(preg_match("/sort_ldap_up_/",$name)){ + $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name); + $from = $id; + $to = $id -1; + $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); + if($tmp){ + $this->gotoLdapServers = $tmp; + } + break; + } + if(preg_match("/sort_ldap_down_/",$name)){ + $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name); + $from = $id; + $to = $id +1; + $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); + if($tmp){ + $this->gotoLdapServers = $tmp; + } + break; + } + if(preg_match("/gotoLdapRemove_/",$name)){ + $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name); + $value = $this->gotoLdapServers[$id]; + $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers); + break; + } + } + } + /* Add Entries + */ + foreach($this->gotoLdapServers as $key => $server){ + if(!in_array($server,$this->gotoLdapServerList)){ + $server = $server." (missing)"; + } + + $SelectBoxLdapServer->AddEntry( + array(array("string" => $server), + array("string" => + " ". + " ". + "", + "attach" => "style='text-align:right;width:40px;border-right:0px;'"))); + } + + if($this->gotoLdap_inherit){ + $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));; + }else{ + $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer")); + } + + $list = array(); + foreach($this->gotoLdapServerList as $key => $entry){ + if(!in_array($entry,$this->gotoLdapServers)){ + $list[$key] = $entry; + } + } + $smarty->assign("gotoLdapServers", $SelectBoxLdapServer->DrawList()); + $smarty->assign("gotoLdapServerList", $list); + $smarty->assign("gotoLdap_inherit", $this->gotoLdap_inherit); + $smarty->assign("JS", $_SESSION['js']); + + foreach (array("gotoModules" ) as $val){ + $smarty->assign("$val", $this->$val); + } + + /* Values */ + foreach(array("gotoBootKernel", "customParameters") as $val){ + $smarty->assign($val, $this->$val); + } + + /* Radio button group */ + if (preg_match("/G/", $this->bootmode)) { + $smarty->assign("graphicalbootup", "checked"); + } else { + $smarty->assign("graphicalbootup", ""); + } + if (preg_match("/T/", $this->bootmode)) { + $smarty->assign("textbootup", "checked"); + } else { + $smarty->assign("textbootup", ""); + } + if (preg_match("/D/", $this->bootmode)) { + $smarty->assign("debugbootup", "checked"); + } else { + $smarty->assign("debugbootup", ""); + } + + /* Show main page */ + return($smarty->fetch (get_template_path('terminalStartup.tpl', TRUE))); + } + + function remove_from_parent() + { + if($this->acl_is_removeable()){ + $this->handle_post_events("remove"); + new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs)); + } + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + + if(isset($_POST['TerminalStarttabPosted'])){ + if(isset($_POST['gotoLdap_inherit'])){ + $this->gotoLdap_inherit = TRUE; + }else{ + $this->gotoLdap_inherit = FALSE; + } + + /* Save group radio buttons */ + if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){ + $this->bootmode= $_POST["bootmode"]; + } + + /* Save kernel parameters */ + if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){ + $this->customParameters= $_POST["customParameters"]; + } + } + } + + + /* Save to LDAP */ + function save() + { + /* Find proper terminal path for tftp configuration + FIXME: This is suboptimal when the default has changed to + another location! */ + if ($this->gotoTerminalPath == "default-inherit"){ + $ldap= $this->config->get_ldap_link(); + + /* Strip relevant part from dn, keep trailing ',' */ + $tmp= preg_replace("/^cn=[^,]+,ou=terminals,ou=systems,/i", "", $this->dn); + $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp); + + /* Walk from top to base and try to load default values for + 'gotoTerminalPath'. Abort when an entry is found. */ + while (TRUE){ + $tmp= preg_replace ("/^[^,]+,/", "", $tmp); + + $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp". + $this->config->current['BASE'], array('gotoTerminalPath')); + $attrs= $ldap->fetch(); + if (isset($attrs['gotoTerminalPath'])){ + $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0]; + break; + } + + /* Nothing left? */ + if ($tmp == ""){ + break; + } + } + } + + /* Add semi automatic values */ + // FIXME: LDAP Server may not be set here... + $this->gotoKernelParameters= "root=/dev/nfs nfsroot=". + $this->gotoTerminalPath. + ",ro,hard,nolock,fg,rsize=8192 ". + "ip=::::::dhcp ldap=".base64_encode($this->gotoLdapServer); + + switch ($this->bootmode){ + case "D": + $this->gotoKernelParameters.= " debug"; + break; + case "G": + $this->gotoKernelParameters.= " splash=silent"; + break; + } + if ($this->customParameters != ""){ + $this->gotoKernelParameters.= " o ".$this->customParameters; + } + + plugin::save(); + + /* Add missing arrays */ + foreach (array("gotoModules") as $val){ + if (isset ($this->$val) && count ($this->$val) != 0){ + + $this->attrs["$val"]= array_unique($this->$val); + } + if(!isset($this->attrs["$val"])){ + $this->attrs["$val"]=array(); + } + } + + /* Prepare list of ldap servers */ + $this->attrs['gotoLdapServer'] = array(); + if(!$this->gotoLdap_inherit){ + $i = 0; + foreach($this->gotoLdapServers as $server){ + $i ++; + $this->attrs['gotoLdapServer'][] = $i.":".$server; + } + } + + /* Strip out 'default' values */ + foreach(array("gotoBootKernel") as $value){ + if (!isset($this->attrs[$value]) || $this->attrs[$value] == "default-inherit"){ + $this->attrs[$value] = array(); + } + } + + /* prepare share settings */ + $tmp = array(); + foreach($this->gotoShares as $name => $settings){ + $tmp2 = split("\|",$name); + $name = $tmp2[0]; + $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint']; + } + $this->attrs['gotoShare']=$tmp; + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + + $this->cleanup(); + $ldap->modify ($this->attrs); + + new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/startup with dn '%s' failed."),$this->dn)); + $this->handle_post_events("modify"); + } + + /* Add value to array, check if unique */ + function add_list (&$array, $value) + { + if ($value != ""){ + $array[]= $value; + sort($array); + array_unique ($array); + } + } + + + /* Delete value to array, check if unique */ + function del_list (&$array, $list) + { + $tmp= array(); + foreach ($array as $mod){ + if (!in_array($mod, $list)){ + $tmp[]= $mod; + } + } + $array= $tmp; + } + + /* Generate ListBox frindly output for the defined shares + * Possibly Add or remove an attribute here, + */ + function printOutAssignedShares() + { + $a_return = array(); + if(is_array($this->gotoShares)){ + foreach($this->gotoShares as $share){ + $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]"; + } + } + return($a_return); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $source_o = new termstartup ($this->config, $source['dn']); + + foreach(array("gotoModules", "gotoKernelParameters","gotoShares","customParameters","bootmode","gotoTerminalPath","gotoShares","goLdapServerList","gotoBootKernel","gotoLdapServer","gotoBootKernels") as $attr){ + $this->$attr = $source_o->$attr; + } + } + + + function array_switch_item($ar,$from,$to) + { + if(!is_array($ar)){ + return(false); + } + if(!isset($ar[$from])){ + return(false); + } + if(!isset($ar[$to])){ + return(false); + } + + $tmp = $ar[$from]; + $ar[$from] = $ar[$to]; + $ar[$to] = $tmp; + return($ar); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Startup"), + "plDescription" => _("Terminal startup"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 5, + "plSection" => array("administration"), + "plCategory" => array("terminal"), + + "plProvidedAcls"=> array( + "gotoLdapServer" => _("Ldap server"), + "gotoShare" => _("Shares"), + "gotoModules" => _("Kernel modules"), + "gotoBootKernel" => _("Boot kernel"), + "gotoKernelParameters"=> _("Kernel parameter")) + )); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_winGeneric.inc b/gosa-core/plugins/admin/systems/class_winGeneric.inc new file mode 100644 index 000000000..8a15e930c --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_winGeneric.inc @@ -0,0 +1,306 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $interfaces= array(); + + /* Needed values and lists */ + var $base= ""; + var $cn= ""; + var $description= ""; + var $orig_dn= ""; + var $shadowLastChange=""; + var $uidNumber=""; + var $gidNumber=""; + var $loginShell=""; + var $gecos=""; + var $shadowMin=""; + var $shadowWarning=""; + var $shadowInactive=""; + var $uid=""; + var $sn=""; + var $givenName=""; + var $homeDirectory=""; + var $sambaSID=""; + var $sambaPrimaryGroupSID=""; + var $displayName=""; + var $sambaPwdMustChange=""; + var $sambaNTPassword=""; + var $sambaPwdLastSet=""; + var $sambaAcctFlags=""; + var $netConfigDNS; + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("cn", "description","shadowLastChange", + "uidNumber","gidNumber","loginShell","gecos","shadowMin","shadowWarning", + "shadowInactive","uid","cn","sn","givenName","homeDirectory","sambaSID", + "sambaPrimaryGroupSID","displayName", "sambaPwdMustChange", + "sambaNTPassword","sambaPwdLastSet","sambaAcctFlags"); + var $objectclasses= array("posixAccount","person","organizationalPerson","inetOrgPerson","gosaAccount","shadowAccount","sambaSamAccount","top"); + + var $view_logged = FALSE; + + function wingeneric (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + $this->cn= ""; + } else { + $this->base= preg_replace ("/^[^,]+,".normalizePreg(get_winstations_ou())."/", "", $this->dn); + } + + /* Save dn for later references */ + $this->orig_dn= $this->dn; + + $this->cn= preg_replace("/\\\$\$/","",$this->cn); + } + + + function set_acl_base($base) + { + plugin::set_acl_base($base); + $this->netConfigDNS->set_acl_base($base); + } + + function set_acl_category($cat) + { + plugin::set_acl_category($cat); + $this->netConfigDNS->set_acl_category($cat); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","winworkstation/".get_class($this),$this->dn); + } + + + /* Do we represent a valid phone? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no network features.").""; + return($display); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + + // Undefined index in wingeneric.tpl ... + $smarty->assign("bases", $this->config->idepartments); + + /* Assign attributes */ + foreach ($this->attributes as $attr){ + $smarty->assign("$attr", $this->$attr); + } + + $smarty->assign("base_select", $this->base); + + /* Show main page */ + $str = $this->netConfigDNS->execute(); + if(is_object($this->netConfigDNS->dialog)){ + return($str); + } + $smarty->assign("netconfig", $str); + return($smarty->fetch (get_template_path('wingeneric.tpl', TRUE))); + } + + function remove_from_parent() + { + $this->netConfigDNS->remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir($this->dn); + new log("remove","winworkstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of system wingeneric/generic with dn '%s' failed."),$this->dn)); + $this->handle_post_events("remove"); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + } + + + /* Save data to object */ + function save_object() + { + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + $this->netConfigDNS->save_object(); + + /* Set new base if allowed */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + $message= array_merge($message, $this->netConfigDNS->check()); + $this->dn= "cn=".$this->cn.",ou=netdevices,ou=systems,".$this->base; + + /* Set new acl base */ + if($this->dn == "new") { + $this->set_acl_base($this->base); + } + + if(!$this->acl_is_createable() && $this->dn == "new"){ + $message[]= _("You have no permissions to create a component on this 'Base'."); + } + + if ($this->orig_dn != $this->dn){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->base); + $ldap->search ("(cn=".$this->cn.")", array("cn")); + if ($ldap->count() != 0){ + while ($attrs= $ldap->fetch()){ + if(preg_match("/cn=dhcp,/",$attrs['dn'])){ + continue; + } + if ($attrs['dn'] != $this->orig_dn){ + $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); + break; + } + } + } + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Remove all empty values */ + if ($this->orig_dn == 'new'){ + $attrs= array(); + foreach ($this->attrs as $key => $val){ + if (is_array($val) && count($val) == 0){ + continue; + } + $attrs[$key]= $val; + } + $this->attrs= $attrs; + } + + if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){ + $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + if ($this->orig_dn == 'new'){ + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","winworkstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("add"); + } else { + if ($this->orig_dn != $this->dn){ + $this->move($this->orig_dn, $this->dn); + } + + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","winworkstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("modify"); + } + + $this->netConfigDNS->cn = preg_replace("/\\\$\$/","",$this->cn); + $this->netConfigDNS->save(); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system wingeneric/generic with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->postcreate(); + } + + /* Return plugin informations for acl handling + #FIXME FAIscript seams to ununsed within this class... */ + static function plInfo() + { + return (array( + "plShortName" => _("Win generic"), + "plDescription" => _("Windows workstation generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("winworkstation" => array("description" => _("Win workstation"), + "objectClass" => "gotoWorkstation")), + "plProvidedAcls"=> array( + "cn" => _("Workstation name"), + "description" => _("Description")) + )); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_workstationGeneric.inc b/gosa-core/plugins/admin/systems/class_workstationGeneric.inc new file mode 100644 index 000000000..14641c0b7 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_workstationGeneric.inc @@ -0,0 +1,663 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Generic terminal attributes */ + var $gotoMode= "locked"; + var $gotoSyslogServer= ""; + var $gotoSyslogServers= array(); + var $gotoNtpServer= array(); + var $gotoNtpServers= array(); + var $gotoSndModule= ""; + var $gotoFloppyEnable= ""; + var $gotoCdromEnable= ""; + var $ghCpuType= "-"; + var $ghMemSize= "-"; + var $ghUsbSupport= "-"; + var $ghNetNic= array(); + var $ghIdeDev= array(); + var $ghScsiDev= array(); + var $ghGfxAdapter= "-"; + var $ghSoundAdapter= "-"; + var $gotoLastUser= "-"; + var $FAIscript= ""; + var $didAction= FALSE; + var $FAIstate= ""; + var $view_logged = FALSE; + + /* Needed values and lists */ + var $base= ""; + var $cn= ""; + var $l= ""; + var $orig_dn= ""; + + /* Plugin side filled */ + var $modes= array(); + + var $netConfigDNS; + + var $inheritTimeServer = true; + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array("gotoMode", "gotoSyslogServer", "gotoNtpServer", + "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule", + "ghCpuType", "ghMemSize", "ghUsbSupport", + "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript"); + var $objectclasses= array("top", "gotoWorkstation", "GOhard"); + + var $mapActions = array("reboot" => "", + "localboot" => "localboot", + "halt" => "", + "instant_update" => "softupdate", + "update" => "scheduledupdate", + "reinstall" => "install", + "rescan" => "", + "memcheck" => "memcheck", + "sysinfo" => "sysinfo"); + + + var $fai_activated = FALSE; + + var $member_of_ogroup = FALSE; + + function workgeneric (&$config, $dn= NULL, $parent= NULL) + { + $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + $this->fai_activated = TRUE; + } + + plugin::plugin ($config, $dn, $parent); + + if(!isset($this->parent->by_object['ogroup'])){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn")); + $this->member_of_ogroup = $ldap->count() >= 1; + } + + $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); + + /* Read arrays */ + foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ + if (!isset($this->attrs[$val])){ + continue; + } + for ($i= 0; $i<$this->attrs[$val]['count']; $i++){ + array_push($this->$val, $this->attrs[$val][$i]); + } + } + + /* Create used ntp server array */ + $this->gotoNtpServer= array(); + if(isset($this->attrs['gotoNtpServer'])){ + $this->inheritTimeServer = false; + unset($this->attrs['gotoNtpServer']['count']); + foreach($this->attrs['gotoNtpServer'] as $server){ + $this->gotoNtpServer[$server] = $server; + } + } + + /* Set inherit checkbox state */ + if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer) == 0)){ + $this->inheritTimeServer = true; + $this->gotoNtpServer=array(); + } + + /* You can't inherit the NTP service, if we are not member in an object group */ + if(!$this->member_of_ogroup){ + $this->inheritTimeServer = FALSE; + } + + /* Create available ntp options */ + $tmp = $this->config->data['SERVERS']['NTP']; + $this->gotoNtpServers = array(); + foreach($tmp as $key => $server){ + if($server == "default") continue; + $this->gotoNtpServers[$server] = $server; + } + + $this->modes["active"]= _("Activated"); + $this->modes["locked"]= _("Locked"); + + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } else { + $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); + } + + /* Create an array of all Syslog servers */ + $tmp = $this->config->data['SERVERS']['SYSLOG']; + foreach($tmp as $server){ + $visible = $server; + if($server == "default" && $this->member_of_ogroup) { + $visible = "["._("inherited")."]"; + } + $this->gotoSyslogServers[$server] = $visible; + } + + /* Save 'dn' for later referal */ + $this->orig_dn= $this->dn; + } + + + function set_acl_base($base) + { + plugin::set_acl_base($base); + $this->netConfigDNS->set_acl_base($base); + } + + function set_acl_category($cat) + { + plugin::set_acl_category($cat); + $this->netConfigDNS->set_acl_category($cat); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","workstation/".get_class($this),$this->dn); + } + + /* Do we need to flip is_account state? */ + 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['action'])) && ($this->acl_is_writeable("FAIstate"))){ + $cmd= $this->config->search("workgeneric", "ACTIONCMD",array('tabs')); + if ($cmd == ""){ + print_red(_("No ACTIONCMD definition found in your gosa.conf")); + } else { + exec ($cmd." ".$this->netConfigDNS->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval); + if ($retval != 0){ + print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); + } elseif ($_POST['saction'] != "wake") { + + /* Set FAIstate */ + if($this->fai_activated && $this->dn != "new"){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn,array("objectClass")); + $res = $ldap->fetch(); + + $attrs = array(); + $attrs['FAIstate'] = $this->FAIstate; + if(isset($this->mapActions[$_POST['saction']]) && $this->mapActions[$_POST['saction']] != ""){ + $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; + } + + for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $res['objectClass'][$i]; + } + + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } + + if($attrs['FAIstate'] == ""){ +#FIXME we should check if FAIobject is not used anymore + $attrs['FAIstate'] = array(); + } + + $ldap->cd($this->dn); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic (FAIstate) with dn '%s' failed."),$this->dn)); + + } + $this->didAction= TRUE; + } + } + } + + /* Do we represent a valid terminal? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no workstation features.").""; + return($display); + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Add new ntp Server to our list */ + if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){ + $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; + } + + /* Delete selected NtpServer for list of used servers */ + if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){ + foreach($_POST['gotoNtpServerSelected'] as $name){ + unset($this->gotoNtpServer[$name]); + } + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $smarty->assign("cn", $this->cn); + $smarty->assign("l", $this->l); + $smarty->assign("bases", $this->get_allowed_bases()); + $smarty->assign("staticAddress", ""); + + $tmp = array(); + foreach($this->gotoNtpServers as $server){ + if(!in_array($server,$this->gotoNtpServer)){ + $tmp[$server] = $server; + } + } + $smarty->assign("gotoNtpServers",$tmp); + + /* Check if workstation is online */ + $query= "fping -q -r 1 -t 500 ".$this->cn; + exec ($query, $dummy, $retval); + + /* Offline */ + if ($retval == 0){ + $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), + "instant_update" => _("Instant update"), + "update" => _("Scheduled update"), + "reinstall" => _("Reinstall"), + "rescan" => _("Rescan hardware"), + "memcheck" => _("Memory test"), + "localboot" => _("Force localboot"), + "sysinfo" => _("System analysis"))); + } else { + $smarty->assign("actions", array("wake" => _("Wake up"), + "reinstall" => _("Reinstall"), + "update" => _("Scheduled update"), + "memcheck" => _("Memory test"), + "localboot" => _("Force localboot"), + "sysinfo" => _("System analysis"))); + } + /* Arrays */ + $smarty->assign("modes", $this->modes); + $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); + $smarty->assign("syslogservers", $this->gotoSyslogServers); + $smarty->assign("fai_activated",$this->fai_activated); + + $ntpser = array(); + foreach($this->gotoNtpServers as $server){ + if(!in_array($server,$this->gotoNtpServer)){ + $ntpser[$server] = $server; + } + } + $smarty->assign("gotoNtpServers", $ntpser); + + /* Variables */ + foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){ + $smarty->assign($val."_select", $this->$val); + } + + /* tell smarty the inherit checkbox state */ + $smarty->assign("inheritTimeServer",$this->inheritTimeServer); + $smarty->assign("member_of_ogroup",$this->member_of_ogroup); + + $str = $this->netConfigDNS->execute(); + if(is_object($this->netConfigDNS->dialog)){ + return($str); + } + $smarty->assign("netconfig", $str); + + /* Show main page */ + return($smarty->fetch (get_template_path('workstation.tpl', TRUE))); + } + + function remove_from_parent() + { + if($this->acl_is_removeable()){ + + $this->netConfigDNS->remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir($this->dn); + new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of system workstation/generic with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + } + + if(isset($_POST["inheritAll"])){ + $this->set_everything_to_inherited(); + } + } + + + /* Save data to object */ + function save_object() + { + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + /* Save base, since this is no LDAP attribute */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + + $this->netConfigDNS->save_object(); + + /* Set inherit mode */ + if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){ + if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){ + $this->inheritTimeServer = true; + }else{ + $this->inheritTimeServer = false; + } + } + + if(isset($_POST["inheritAll"])){ + $this->set_everything_to_inherited(); + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Skip IP & Mac checks if this is a template */ + if($this->cn != "wdefault"){ + $message= array_merge($message, $this->netConfigDNS->check()); + } + + $this->dn= "cn=".$this->cn.",ou=workstations,ou=systems,".$this->base; + + if ($this->cn == ""){ + $message[]= _("The required field 'Workstation name' is not set."); + } + + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn)){ + $message[] = _("Please specify a valid name for this object."); + } + + if ($this->orig_dn != $this->dn){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->base); + + if($this->cn == "wdefault"){ + $ldap->cat($this->dn); + }else{ + $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn")); + } + if ($ldap->count() != 0){ + while ($attrs= $ldap->fetch()){ + if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,ou=incoming,/", $ldap->getDN())){ + continue; + } else { + if ($attrs['dn'] != $this->orig_dn){ + $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); + break; + } + } + } + } + } + + /* Check for valid ntpServer selection */ + if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){ + $message[]= _("There must be at least one NTP server selected, or the inherit mode activated."); + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Strip out 'default' values */ + foreach (array("gotoSyslogServer") as $val){ + + if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){ + $this->attrs[$val]= array(); + } + } + + /* Add missing arrays */ + foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){ + if (isset ($this->$val) && count ($this->$val) != 0){ + $this->attrs["$val"]= $this->$val; + } + } + + /* Remove all empty values */ + if ($this->orig_dn == 'new'){ + $attrs= array(); + foreach ($this->attrs as $key => $val){ + if (is_array($val) && count($val) == 0){ + continue; + } + $attrs[$key]= $val; + } + $this->attrs= $attrs; + } + + /* Update ntp server settings */ + if($this->inheritTimeServer){ + if($this->is_new){ + if(isset($this->attrs['gotoNtpServer'])){ + unset($this->attrs['gotoNtpServer']); + } + }else{ + $this->attrs['gotoNtpServer'] = array(); + } + }else{ + /* Set ntpServers */ + $this->attrs['gotoNtpServer'] = array(); + foreach($this->gotoNtpServer as $server){ + $this->attrs['gotoNtpServer'][] = $server; + } + } + + if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){ + $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + if ($this->orig_dn == 'new'){ + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn)); + if(!$this->didAction){ + $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } + } else { + if ($this->orig_dn != $this->dn){ + $this->move($this->orig_dn, $this->dn); + } + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + if(!$this->didAction){ + $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); + } + } + + /* cn=default and macAddress=- indicates that this is a template */ + if($this->cn == "wdefault"){ + $this->netConfigDNS->macAddress = "-"; + } + + $this->netConfigDNS->cn = $this->cn; + $this->netConfigDNS->save(); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn)); + } + + + /* Display generic part for server copy & paste */ + function getCopyDialog() + { + $vars = array("cn"); + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $smarty->assign("object","workstation"); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + if(isset($source['macAddress'][0])){ + $this->netConfigDNS->macAddress = $source['macAddress'][0]; + } + if(isset($source['ipHostNumber'][0])){ + $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; + } + + /* Create used ntp server array */ + $this->gotoNtpServer= array(); + if(isset($source['gotoNtpServer'])){ + $this->inheritTimeServer = false; + unset($source['gotoNtpServer']['count']); + foreach($source['gotoNtpServer'] as $server){ + $this->gotoNtpServer[$server] = $server; + } + } + + /* Set inherit checkbox state */ + if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){ + $this->inheritTimeServer = true; + $this->gotoNtpServer=array(); + } + } + + + /* Return plugin informations for acl handling + #FIXME FAIscript seams to ununsed within this class... */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Workstation generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("workstation" => array("description" => _("Workstation"), + "objectClass" => "gotoWorkstation")), + "plProvidedAcls"=> array( + "cn" => _("Workstation name"), + "l" => _("Location") , + "base" => _("Base") , + "gotoMode" => _("Goto mode"), + "gotoSyslogServer" => _("Syslog server"), + "gotoNtpServer" => _("Ntp server"), + "gotoRootPasswd" => _("Root password"), + "FAIstate" => _("Action flag")) + )); + } + + function set_everything_to_inherited() + { + $this->gotoSyslogServer = "default"; + $this->inheritTimeServer = TRUE; + + /* Set workstation service attributes to inherited */ + if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){ + foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant", + "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){ + $this->parent->by_object['workservice']->$name = "default"; + } + } + + /* Set workstation startup attributes to inherited */ + if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){ + $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited"; + $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited"; + $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited"; + } + } +} + // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_workstationService.inc b/gosa-core/plugins/admin/systems/class_workstationService.inc new file mode 100644 index 000000000..23698cf61 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_workstationService.inc @@ -0,0 +1,505 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + var $gotoScannerEnable; + /* Generic terminal attributes */ + var $gotoXMonitor= ""; + var $gotoXDriver= ""; + var $gotoXResolution= ""; + var $gotoXColordepth= ""; + var $gotoXHsync= ""; + var $gotoXVsync= ""; + var $AutoSync = false; + var $gotoXKbModel= ""; + var $gotoXKbLayout= ""; + var $gotoXKbVariant= ""; + var $gotoXMouseType= ""; + var $gotoXMouseport= ""; + var $gotoScannerClients= ""; + var $gotoScannerBackend= ""; + var $goFonHardware= "automatic"; + var $view_logged = FALSE; + + /* Needed values and lists */ + var $ignore_account= TRUE; + var $base= ""; + var $cn= ""; + var $orig_dn= ""; + var $XMethods= array(); + var $XDrivers= array(); + var $XResolutions = array(); + var $MouseTypes= array(); + var $MousePorts= array(); + var $hardware_list= array(); + var $used_hardware= array(); + + + /* attribute list for save action */ + var $attributes= array("gotoXMonitor", + "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoXHsync", "gotoXVsync", + "gotoScannerEnable", "gotoScannerClients", + "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant", + "gotoXMouseType", "gotoXMouseport", "goFonHardware"); + var $objectclasses= array("GOhard"); + + var $XColordepths =array(); + var $XKbModels =array(); + var $XKbLayouts =array(); + var $XKbVariants =array(); + + function workservice (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $this->XResolutions= array( + "640x480" => "640x480", + "800x600" => "800x600", + "1024x768" => "1024x768", + "1152x864" => "1152x864", + "1280x1024" => "1280x1024", + "1400x1050" => "1400x1050", + "1600x1200" => "1600x1200"); + + if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){ + $file = $this->config->data['MAIN']['RESOLUTION_HOOK']; + + if(is_readable($file)){ + $str = file_get_contents($file); + $lines = split("\n",$str); + foreach($lines as $line){ + $line = trim($line); + if(!empty($line)){ + $this->XResolutions[$line]=$line; + } + } + //natcasesort($this->gotoXResolutions); + }else{ + print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file)); + } + } + + /* Get list of available xdrivers */ + $this->XDrivers = $this->getListOfXDrivers(); + + array_unshift($this->XDrivers, "["._("unknown")."]"); + + $this->XColordepths= array( + "8" => "8 " ._("bit"), + "15" => "15 "._("bit"), + "16" => "16 "._("bit"), + "24" => "24 "._("bit")); + + foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex", + "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless", + "logiinetnav", "logiinternet", "macintosh", "microsoft", + "microsoftpro", "omnikey101", "pc101", "pc102", "pc104", + "pc105", "rapidaccess", "rapidaccess2", "winbook") as $type){ + $this->XKbModels[$type] = $type; + } + + $this->MouseTypes= array("ImPS/2" => "ImPS/2", "PS/2" => "PS/2", "Microsoft" => "Microsoft", + "Logitech" => "Logitech"); + + $this->MousePorts= array("/dev/ttyS0" =>"/dev/ttyS0", + "/dev/ttyS1" => "/dev/ttyS1", "/dev/psaux" =>"/dev/psaux", + "/dev/input/mice" => "/dev/input/mice"); + + /* Additional values will be extracted from CONFIG_DIR./keyboardLayouts */ + $this->XKbLayouts= array ("de"=> "de","intl" =>"intl","us" =>"us"); + $this->XKbVariants= array ("nodeadkeys"=>"nodeadkeys", "basic"=>"basic"); + + /* try to read additional keyboard layouts + */ + if(file_exists(CONFIG_DIR."/keyboardLayouts")){ + if(is_readable(CONFIG_DIR."/keyboardLayouts")){ + $str = file_get_contents(CONFIG_DIR."/keyboardLayouts"); + $tmp = split("\n",$str); + foreach($tmp as $entry){ + if((!empty($entry)) && (!preg_match("/^#/",$entry))){ + $entry = trim($entry); + $tmp2 = split ("\:",$entry); + $la = trim($tmp2[0]); // What would be saved to ldap + $da = trim($tmp2[1]); // This wis displayed in the listbox + $this->XKbLayouts [ $la] = $da; + } + } + } + } + + /* Initialize methods */ + $this->XMethods["indirect"]= _("show chooser"); + $this->XMethods["query"]= _("direct"); + #$this->XMethods["squery"]= _("direct via ssh"); + #$this->XMethods["nquery"]= _("direct via nx"); + $this->XMethods["load"]= _("load balanced"); + #$this->XMethods["sload"]= _("load balanced via ssh"); + #$this->XMethods["nload"]= _("load balanced via nx"); + $this->XMethods["rdp"]= _("Windows RDP"); + $this->XMethods["citrix"]= _("ICA client"); + + $this->orig_dn= $this->dn; + + /* Load hardware list */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); + while ($attrs= $ldap->fetch()){ + $cn= $attrs['cn'][0]; + if (isset($attrs['description'])){ + $description= " - ".$attrs['description'][0]; + } else { + $description= ""; + } + $this->hardware_list[$cn]= "$cn$description"; + } + + /* Eventually colorize phones */ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware')); + while($attrs = $ldap->fetch()){ + $cn = $attrs['goFonHardware'][0]; + if(isset($this->hardware_list[$cn])){ + $this->used_hardware[$cn]= $cn; + } + } + + if(preg_match("/\+/",$this->gotoXHsync)){ + $this->AutoSync = true; + $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync); + $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync); + } + + $this->hardware_list["automatic"]= _("automatic"); + ksort($this->hardware_list); + + /* Load hardware list */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))"); + if ($ldap->count() == 1){ + $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport"); + $attrs= $ldap->fetch(); + + foreach ($map as $name){ + if (!isset($attrs[$name][0])){ + continue; + } + + switch ($name){ + case 'gotoXResolution': + $this->XResolutions= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions; + break; + case 'gotoXColordepth': + $this->XColordepths= array('default' => _("inherited").' ['.$attrs[$name][0].' '._('Bit').']') + $this->XColordepths; + break; + case 'gotoXKbModel': + $this->XKbModels= array('default' => _("inherited").' ['.$attrs[$name][0].']') + $this->XKbModels; + break; + case 'gotoXKbLayout': + $this->XKbLayouts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbLayouts; + break; + case 'gotoXKbVariant': + $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants; + break; + case 'gotoXMouseType': + $this->MouseTypes= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes; + break; + case 'gotoXMouseport': + $this->MousePorts= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts; + break; + } + + } + + } + + /* Workaround to fill in inherited values if we've specified an objectclass */ + if (isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){ + $this->XResolutions= array('default' => _("inherited")); + $this->XColordepths= array('default' => _("inherited")); + $this->XKbModels= array('default' => _("inherited")); + $this->XKbLayouts= array('default' => _("inherited")); + $this->XKbVariants= array('default' => _("inherited")); + $this->MouseTypes= array('AUTO' => _("inherited")); + $this->MousePorts= array('AUTO' => _("inherited")); + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","workstation/".get_class($this),$this->dn); + } + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Show main page */ + $smarty= get_smarty(); + + /* Assign ACLs */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Arrays */ + foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths", + "XKbModels", "XKbVariants", + "MouseTypes", "MousePorts") as $val){ + $smarty->assign("$val", $this->$val); + } + $smarty->assign("XKbLayouts" ,$this->XKbLayouts); + $smarty->assign("XKbLayoutKeys" ,array_flip($this->XKbLayouts)); + + $smarty->assign("xdmcpservers", $this->config->data['SERVERS']['TERMINAL']); + $smarty->assign("fontservers", $this->config->data['SERVERS']['FONT']); + $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); + $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); + + /* Variables - select */ + foreach(array( + "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoXKbModel", "gotoXKbLayout","gotoScannerEnable", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ + + $smarty->assign($val."_select", $this->$val); + } + + /* Variables */ + foreach(array("gotoXHsync", "gotoXVsync") as $val){ + $smarty->assign($val, $this->$val); + } + $smarty->assign("staticAddress", ""); + + /* Checkboxes */ + foreach(array("gotoScannerEnable") as $val){ + if ($this->$val == TRUE) { + $smarty->assign("$val", "checked"); + } else { + $smarty->assign("$val", ""); + } + } + + /* Phone stuff */ + $smarty->assign ("goFonHardware", $this->goFonHardware); + + $perms = ""; + if($this->acl_is_writeable("goFonHardware")){ + $perms = " disabled "; + } + + $hl= "\n"; + $smarty->assign ("hardware_list", $hl); + $smarty->assign ("gotoXMonitor", $this->gotoXMonitor); + + if($this->AutoSync){ + $smarty->assign("AutoSyncCHK"," checked "); + $smarty->assign("hiddenState"," disabled "); + }else{ + $smarty->assign("AutoSyncCHK"," "); + $smarty->assign("hiddenState",""); + } + + /* Show main page */ + return($smarty->fetch (get_template_path('workstationService.tpl',TRUE,dirname(__FILE__)))); + } + + function remove_from_parent() + { + $this->handle_post_events("remove"); + new log("remove","workstation/".get_class($this),$this->dn); + } + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + + if((isset($_POST['gotoXDriver'])) && $this->acl_is_writeable("AutoSync")) { + if(isset($_POST['AutoSync'])){ + $this->AutoSync = true; + }else{ + $this->AutoSync = false; + } + } + } + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Default entries can use blank hsync/vsync entries */ + if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){ + + /* But only if no auto sync is enabled... */ + if (!$this->AutoSync){ + + /* Check vsync for correct usage */ + $val= preg_replace ("/\s/", "", $this->gotoXVsync); + + if($this->acl_is_writeable("gotoXVsync")){ + if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){ + $message[]= _("Please specify a valid VSync range."); + } else{ + list($v1,$v2)= preg_split ("/[-+]/", $val); + if ($v2 != ""){ + if ($v1 > $v2){ + $message[]= _("Please specify a valid VSync range."); + } + } + } + } + + /* Check hsync for correct usage */ + $val= preg_replace ("/\s/", "", $this->gotoXHsync); + if($this->acl_is_writeable("gotoXHsync")){ + if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){ + $message[]= _("Please specify a valid HSync range."); + } else{ + list($v1,$v2)= preg_split ("/[-+]/", $val); + if ($v2 != ""){ + if ($v1 > $v2){ + $message[]= _("Please specify a valid HSync range."); + } + } + } + } + } + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* remove objectclass GOhard if this is an ogroup tab */ + if(isset($this->parent->by_object['ogroup'])){ + $this->objectclasses = array(); + } + + plugin::save(); + + /* Strip out 'default' values */ + foreach(array( + "gotoXDriver", "gotoXResolution", "gotoXColordepth", + "gotoXKbModel", "gotoXKbLayout", + "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ + + if ($this->attrs[$val] == "default"){ + $this->attrs[$val]= array(); + } + } + + if($this->AutoSync){ + $this->attrs['gotoXHsync'] = "30+55"; + $this->attrs['gotoXVsync'] = "50+70"; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/service with dn '%s' failed."),$this->dn)); + $this->handle_post_events("modify"); + } + + + function getListOfXDrivers() + { + /* Generate a list of xdrivers from CONFIG_DIR./xdrivers */ + $drivers = array(); + if (file_exists(CONFIG_DIR.'/xdrivers')){ + $xdrivers = file (CONFIG_DIR.'/xdrivers'); + foreach ($xdrivers as $line){ + if (!preg_match ("/^#/", $line)){ + $drivers[]= trim($line); + } + } + } else { + $drivers = array("ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", "fglrx", + "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc", "nv", "nvidia", + "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion", + "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware"); + } + return($drivers); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Service"), + "plDescription" => _("Workstation service"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 10, + "plSection" => array("administration"), + "plCategory" => array("workstation","ogroups"), + + "plProvidedAcls"=> array( + "gotoXMonitor" => _("Monitor"), + "gotoXDriver" => _("Gfx driver"), + "gotoXResolution" => _("Gfx resolution"), + "gotoXColordepth" => _("Gfx color depth"), + "gotoXHsync" => _("Hsync"), + "gotoXVsync" => _("Vsync"), + "AutoSync" => _("Use DDC"), + "gotoScannerEnable" => _("Scanner enabled"), + "gotoXKbModel" => _("Keyboard model"), + "gotoXKbLayout" => _("Keyboard layout"), + "gotoXKbVariant" => _("Keyboard variant"), + "gotoXMouseType" => _("Mouse type"), + "gotoXMouseport" => _("Mouse port"), + "goFonHardware" => _("Telephone hardware")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/class_workstationStartup.inc b/gosa-core/plugins/admin/systems/class_workstationStartup.inc new file mode 100644 index 000000000..8e9ed5240 --- /dev/null +++ b/gosa-core/plugins/admin/systems/class_workstationStartup.inc @@ -0,0 +1,1360 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Ldap server list */ + var $gotoLdapServers = array(); + var $gotoLdapServerList = array(); + var $gotoLdap_inherit = FALSE; + + /* Generic terminal attributes */ + var $bootmode = "G"; + var $gotoBootKernel = "default-inherited"; + var $gotoKernelParameters = ""; + var $gotoLdapServer = "default-inherited"; + var $gotoModules = array(); + var $gotoAutoFs = array(); + var $gotoFilesystem = array(); + var $gotoTerminalPath = ""; + var $FAIstatus = ""; + var $gotoBootKernels = array(); + + /* attribute list for save action */ + var $attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "FAIclass", "FAIstatus", "gotoShare","FAIdebianMirror", "FAIrelease"); + var $objectclasses = array("GOhard", "FAIobject"); + + /* Share */ + var $gotoShares = array();// Currently Share Option + var $gotoShare = ""; // currently selected Share Option + var $gotoShareSelections= array();// Available Shares for this account in Listbox format + var $gotoAvailableShares= array();// Available Shares for this account + + /* Helper */ + var $customParameters = ""; + var $orig_dn = ""; + var $ignore_account = TRUE; + + /* FAI class selection */ + var $FAIclass = array(); + var $FAIclasses = array(); + var $FAIclassInfo = array(); + var $FAIrelease = ""; + var $FAIdebianMirror = "auto"; + + var $unresolved_classes = array(); + var $view_logged = FALSE; + + /* FAI class selection */ + var $InheritedFAIclass = array(); + var $InheritedFAIrelease = ""; + var $InheritedFAIdebianMirror = "auto"; + + /* Contains all possible server/release/class settings */ + var $FAIServRepConfig = array(); + + var $CopyPasteVars = array("gotoModules","gotoShares"); + + var $fai_activated = FALSE; + var $o_group_dn =""; + var $member_of_ogroup = FALSE; + + function workstartup (&$config, $dn= NULL, $parent= NULL) + { + /* Check if FAI is active */ + $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + $this->fai_activated = TRUE; + }else{ + $this->attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "gotoShare"); + $this->objectclasses = array("GOhard"); + } + + plugin::plugin ($config, $dn, $parent); + + if(!isset($this->parent->by_object['ogroup'])){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn","dn")); + if($ldap->count()){ + $this->member_of_ogroup = TRUE; + $attrs = $ldap->fetch(); + $this->o_group_dn = $attrs['dn']; + } + } + + /* Creating a list of valid Mirrors + * none will not be saved to ldap. + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + foreach($this->config->data['SERVERS']['LDAP'] as $server) { + $this->gotoLdapServerList[]= $server; + } + + if(isset($this->attrs['gotoLdapServer'])){ + unset($this->attrs['gotoLdapServer']['count']); + sort($this->attrs['gotoLdapServer']); + foreach($this->attrs['gotoLdapServer'] as $value){ + $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value); + } + } + if(!count($this->gotoLdapServers) && $this->member_of_ogroup){ + $this->gotoLdap_inherit = TRUE; + } + + /* FAI Initialization + Skip this if FAI is not activated + */ + if($this->fai_activated) { + + $_SESSION['getAvailableClassesForThisRelease_CACHE'] = array(); + $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'] = array(); + + /* Search all FAI objects */ + $ldap->search("(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAIpartitionTable))",array("cn","objectClass","FAIdebianSection",'description')); + /* Sort all entries, and attach elementtype. + * To be able to show the types in the listbox. + */ + while($attr = $ldap->fetch()){ + $cn = $attr['cn'][0]; + + if(!isset($attr['description'])){ + $attr['description'][0] =""; + } + + $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'][] = $attr; + + if(in_array('FAIpackageList',$attr['objectClass'])){ + $tmp2[$cn]['FAIpackageList']['obj'] = 'FAIpackageList'; + $tmp2[$cn]['FAIpackageList']['kzl'] = 'Pl'; + $tmp2[$cn]['FAIpackageList']['sec'] = $attr['FAIdebianSection']; + $tmp2[$cn]['FAIpackageList']['desc'] = $attr['description']; + $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; + } + if(in_array('FAItemplate',$attr['objectClass'])){ + $tmp2[$cn]['FAItemplate']['obj'] = 'FAItemplate'; + $tmp2[$cn]['FAItemplate']['kzl'] = 'T'; + $tmp2[$cn]['FAItemplate']['desc'] = $attr['description']; + $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; + } + if(in_array('FAIvariable',$attr['objectClass'])){ + $tmp2[$cn]['FAIvariable']['obj'] = 'FAIvariable'; + $tmp2[$cn]['FAIvariable']['kzl'] = 'V'; + $tmp2[$cn]['FAIvariable']['desc'] = $attr['description']; + $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; + } + if(in_array('FAIscript',$attr['objectClass'])){ + $tmp2[$cn]['FAIscript']['obj'] = 'FAIscript'; + $tmp2[$cn]['FAIscript']['kzl'] = 'S'; + $tmp2[$cn]['FAIscript']['desc'] = $attr['description']; + $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; + } + if(in_array('FAIhook',$attr['objectClass'])){ + $tmp2[$cn]['FAIhook']['obj'] = 'FAIhook'; + $tmp2[$cn]['FAIhook']['kzl'] = 'H'; + $tmp2[$cn]['FAIhook']['desc'] = $attr['description']; + $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; + } + if(in_array('FAIpartitionTable',$attr['objectClass'])){ + $tmp2[$cn]['FAIpartitionTable']['obj']= 'FAIpartitionTable'; + $tmp2[$cn]['FAIpartitionTable']['kzl']= 'Pt'; + $tmp2[$cn]['FAIpartitionTable']['desc'] = $attr['description']; + $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; + } + if(in_array('FAIprofile',$attr['objectClass'])){ + $tmp2[$cn]['FAIprofile']['obj']= 'FAIprofile'; + $tmp2[$cn]['FAIprofile']['kzl']= 'P'; + $tmp2[$cn]['FAIprofile']['desc'] = $attr['description']; + $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; + } + } + if(is_array($this->FAIclasses)){ + natcasesort($this->FAIclasses); + } + + if(isset($tmp2)){ + $this->FAIclassInfo = $tmp2; + } else { + $this->FAIclassInfo = array(); + } + + /* Build up an array like this one : + [$url]['SERVER'] = 'srv1-002'; + [$url]['RELEASE']['siga/rc9.0.2'] + ['SECTIONS'][0] "main"; + ['SECTIONS'][1] "non-free"; + [$url]['RELEASE']['siga/rc9.0.2'] + ['PACKAGES'][0] "pkg1"; + ['PACKAGES'][1] "postfix"; + */ + + $ldap->search("(&(FAIrepository=*)(objectClass=FAIrepositoryServer))",array("FAIrepository")); + $test = array(); + while($attr = $ldap->fetch()){ + if(isset($attr['FAIrepository'])){ + + unset($attr['FAIrepository']['count']); + + foreach($attr['FAIrepository'] as $rep){ + $tmp = split("\|",$rep); + + if(count($tmp)==4){ + $sections = split(",",$tmp[3]); + $release = $tmp[2]; + $server = $tmp[1]; + $url = $tmp[0]; + + $test[$url]['RELEASE'][$release]['SECTIONS'] = $sections; + + /* Result will be cached + */ + $rel_classes = $this->getAvailableClassesForThisRelease($release); + $test[$url]['RELEASE'][$release]['PACKAGES'] = $rel_classes; + $test[$url]['SERVER'] = $server; + + /* auto gets all releases/classes + */ + $test['auto']['RELEASE'][$release]['SECTION'] = $sections; + $test['auto']['RELEASE'][$release]['PACKAGES'] = $rel_classes; + } + } + } + } + + /* Add possible elements from hook */ + $lines= $this->GetHookElements(); + foreach ($lines as $hline){ + $entries= split(";", $hline); + if (isset($entries[1]) && !isset($test[$entries[1]])){ + $test[$entries[1]]['RELEASE']= array(); + + /* Split releases */ + if (isset($entries[2])){ + $releases= split(",", $entries[2]); + + foreach ($releases as $release){ + $rname= preg_replace('/:.*$/', '', $release); + $sections= split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release)); + $classes= split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release)); + $test[$entries[1]]['RELEASE'][$rname]= array(); + $test[$entries[1]]['RELEASE'][$rname]['SECTION']= $sections; + foreach ($classes as $class){ + if ($class != ""){ + $test[$entries[1]]['RELEASE'][$rname]['PACKAGES'][$class]= $class; + } + } + } + } + } + } + + $this->FAIServRepConfig= $test; + + if((isset($this->FAIclass))&&(!is_array($this->FAIclass))){ + $tmp = array(); + $tmp = split(" ",$this->FAIclass); + $tmp2 =array(); + + foreach($tmp as $class){ + if( ":" == $class[0] ) { + $this->FAIrelease = substr( $class, 1 ); + } + else + { + $tmp2[$class] = $class; + } + } + $this->FAIclass = $tmp2; + } + + if(!is_array($this->FAIclass)){ + $this->FAIclass =array(); + } + }// END of FAI initialization stuff + + + /* Get arrays */ + foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){ + if (isset($this->attrs["$val"]["count"])){ + for ($i= 0; $i<$this->attrs["count"]; $i++){ + if (isset($this->attrs["$val"][$i])){ + array_push($this->$val, $this->attrs["$val"][$i]); + } + } + } + sort ($this->$val); + $this->$val= array_unique($this->$val); + } + + /* Parse Kernel Parameters to decide what boot mode is enabled */ + if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){ + $this->bootmode= "G"; + } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){ + $this->bootmode= "D"; + } elseif ($this->gotoKernelParameters == "") { + $this->bootmode= "G"; + } else { + $this->bootmode= "T"; + } + if (preg_match("/ o /", $this->gotoKernelParameters)){ + $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters); + } else { + $this->customParameters= ""; + } + + /* Prepare Shares */ + if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){ + unset($this->attrs['gotoShare']['count']); + foreach($this->attrs['gotoShare'] as $share){ + $tmp = $tmp2 = array(); + $tmp = split("\|",$share); + $tmp2['server'] =$tmp[0]; + $tmp2['name'] =$tmp[1]; + $tmp2['mountPoint'] =$tmp[2]; + $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; + } + } + + $this->gotoShareSelections= $config->getShareList(true); + $this->gotoAvailableShares= $config->getShareList(false); + $tmp2 = array(); + + + $this->orig_dn= $this->dn; + + /* Handle inheritance value "default" */ + if ($this->member_of_ogroup){ + $this->gotoBootKernels= array("default-inherited" => '['._("inherited").']'); + } + + /* Load hardware list */ + if ($this->member_of_ogroup){ + + if(count($this->FAIclass)==0 && $this->FAIrelease == ""){ + $this->FAIdebianMirror = "inherited"; + } + + if($this->fai_activated){ + $map= array("gotoBootKernel","FAIclass","FAIdebianMirror"); + }else{ + $map= array("gotoBootKernel"); + } + + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->o_group_dn); + $attrs= $ldap->fetch(); + + foreach ($map as $name){ + if (!isset($attrs[$name][0])){ + continue; + } + + switch ($name){ + case 'gotoBootKernel': + $this->gotoBootKernels['default-inherited']= _("inherited").' ['.$attrs[$name][0].']' ; + break; + + case 'FAIclass': + $str = split(":",$attrs[$name][0]); + $this->InheritedFAIclass = split("\ ",trim($str[0])); + $this->InheritedFAIrelease = trim($str[1]); + break; + + case 'FAIdebianMirror': + $this->InheritedFAIdebianMirror = $attrs[$name][0]; + break; + } + } + } + + /* Get list of boot kernels */ + if (isset($this->config->data['TABS'])){ + $command= $this->config->search(get_class($this), "KERNELS",array('tabs')); + + if (!check_command($command)){ + $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command, + get_class($this)); + } else { + $fh= popen($command, "r"); + while (!feof($fh)) { + $buffer= trim(fgets($fh, 256)); + + if(!empty($buffer)){ + + $name=$value = $buffer; + + if(preg_match("/:/",$buffer)){ + $name = preg_replace("/:.*$/","",$buffer); + $value= preg_replace("/^.*:/","",$buffer); + $this->gotoBootKernels[$name]= $name.":".$value; + }else{ + $this->gotoBootKernels[$name]= $value; + } + } + + } + pclose($fh); + } + } + + /* Turn to default, if we've nothing to inherit */ + if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){ + $this->gotoBootKernel= "default"; + } + + /* Preselect release if none was selected yet */ + if(empty($this->FAIrelease) && $this->FAIdebianMirror == "auto"){ + if(isset($this->FAIServRepConfig['auto']['RELEASE']) && is_array($this->FAIServRepConfig['auto']['RELEASE'])){ + $this->FAIrelease = key($this->FAIServRepConfig['auto']['RELEASE']); + } + } + } + + + /* This class is called by the contrucktor ONLY. + * It return the available classes for each + * Server / Release combination ... + * (Release specifies which classes are available) + */ + function getAvailableClassesForThisRelease($release) + { + /* There could be more than one server providing this release, + so use cached result if available + */ + if(isset($_SESSION['getAvailableClassesForThisRelease_CACHE'][$release])) { + return($_SESSION['getAvailableClassesForThisRelease_CACHE'][$release]); + } + + $test2 = array(); + $bb = $this->generateDNSyn($release); + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* Get classes fpr given release */ + $p_classes = get_all_objects_for_given_base($bb, + "(|(objectClass=FAIpackageList)(objectClass=FAItemplate)". + "(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)". + "(objectClass=FAIprofile)(objectClass=FAIpartitionTable))"); + + /* Create list of classes */ + foreach($p_classes as $class){ + $ldap->cat($class['dn'],array("cn")); + $attr = $ldap->fetch(); + $test2[$attr['cn'][0]] = $attr['cn'][0]; + } + $_SESSION['getAvailableClassesForThisRelease_CACHE'][$release] = $test2; + return($test2); + } + + + /* Create array to display available classes/profiles in a selectbox + * This function only displays the available classes. + * If a class is available is defined by these facts : + * 1. Is this class available for the selected release ? + * - if it is available, check if the release is available for the selected server + * (done by $this->getFAIreleases()) + * 2. Is this class currently not assigned to $this->FAIclass + */ + function selectFriendlyClasses(){ + $tmp=array(); + + if($this->FAIdebianMirror == "inherited" || $this->FAIrelease == ""){ + return($tmp); + } + + /* check if the current release exists, + else select the first one .. + */ + $tmp2 = $this->getFAIreleases(); + if(!isset($tmp2[$this->FAIrelease]) || !$tmp2[$this->FAIrelease]['USE']){ + foreach($tmp2 as $key => $data){ + if($data['USE']){ + $this->FAIrelease = $key; + } + } + } + if(!in_array($this->FAIrelease, $tmp2)){ +# $this->FAIrelease = key($tmp2); + } + + /* Get all Packages for this server/release combination + */ + if(!isset($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'][$this->FAIrelease]['PACKAGES'])){ + $pkgs = array(); + print_red(_("There are packages in your configuration, which can't be resolved with current server/release settings.")); + }else{ + $pkgs = $this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'][$this->FAIrelease]['PACKAGES']; + } + + /* Check each and every single class name + */ + foreach($pkgs as $pkg){ + + /* Class already assigned to the classes list ? + * If not ... go on + */ + if(!in_array($pkg,$this->FAIclass)){ + + /* Create the displayed list entry value + HKLMOP [-Pl P V T-] or something like that + */ + $str = ""; + foreach($this->FAIclassInfo[$pkg] as $entry){ + if(isset($entry['kzl'])){ + $str .= $entry['kzl']." "; + } + } + + /* Append class if everyting was fine + */ + $tmp[$pkg] = $pkg." [-".trim($str)."-]"; + } + } + /* Just sort and return new classes list ... + ( possibly we should cache the result ... ) + */ + natcasesort ($tmp); + return($tmp); + } + + function check() + { + $messages = array(); + + /* Call common method to give check the hook */ + $messages= plugin::check(); + + /* If there are packages selected, but no mirror show error */ + if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){ + $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'."); + } + + return($messages); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","workstation/".get_class($this),$this->dn); + } + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Do we represent a valid terminal? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' has no terminal features.").""; + return ($display); + } + + /* Add module */ + if (isset ($_POST['add_module'])){ + if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModule")){ + $this->add_list ($this->gotoModules, $_POST['module']); + } + } + + /* Delete module */ + if (isset ($_POST['delete_module'])){ + if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModule")){ + $this->del_list ($this->gotoModules, $_POST['modules_list']); + } + } + + /* FAI class management */ + if($this->fai_activated){ + if(((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))) && ($this->acl_is_writeable("FAIclass"))){ + $found = 0 ; + + /* If this new class/profile will attach a second partition table + * to our list of classes, abort and show a message. + */ + foreach($this->FAIclass as $name){ + if(isset($this->FAIclassInfo[$name])){ + foreach($this->FAIclassInfo[$name] as $atr){ + if(isset($atr['obj'])){ + if($atr['obj'] == "FAIpartitionTable"){ + $found ++ ; + } + } + } + } + } + + if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){ + print_red(_("There is already a profile in your selection that contain partition table configurations.")); + }else{ + $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel']; + } + } + + $sort = false; + + /* Move one used class class one position up or down */ + if($this->acl_is_writeable("FAIclass")){ + foreach($_POST as $name => $val){ + + $sort_type = false; + if((preg_match("/sort_up/",$name))&&(!$sort)){ + $sort_type = "sort_up_"; + } + if((preg_match("/sort_down/",$name))&&(!$sort)){ + $sort_type = "sort_down_"; + } + + if(($sort_type)&&(!$sort)){ + $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name))); + $sort = true; + + $last = -1; + $change_down = -1; + + /* Create array with numeric index */ + $tmp = array(); + foreach($this->FAIclass as $class){ + $tmp [] = $class; + } + + /* Walk trough array */ + foreach($tmp as $key => $faiName){ + if($faiName == $value){ + if($sort_type == "sort_up_"){ + if($last != -1){ + $change_down= $last; + } + }else{ + if(isset($tmp[$key+1])){ + $change_down = $key; + } + } + } + $last = $key; + } + + $tmp2 = array(); + $skip = false; + + foreach($tmp as $ky => $vl){ + + if($ky == $change_down){ + $skip = $vl; + }else{ + $tmp2[$vl] = $vl; + } + if(($skip != false)&&($ky != $change_down)){ + $tmp2[$skip] = $skip; + $skip =false; + } + } + $this->FAIclass = $tmp2; + } + + if(preg_match("/fai_remove/i",$name)){ + $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name))); + unset($this->FAIclass[$value]); + } + } + } + + /* Delete selected class from our list */ + if($this->acl_is_writeable("FAIclass")){ + if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){ + if(isset($this->FAIclass[$_POST['FAIclassSel']])){ + unset($this->FAIclass[$_POST['FAIclassSel']]); + } + } + } + }// END fai handling + + /* Show main page */ + $smarty= get_smarty(); + + /* Assign ACLs to smarty */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $smarty->assign("member_of_ogroup",$this->member_of_ogroup); + + /* In this section server shares will be defined + * A user can select one of the given shares and a mount point + * and attach this combination to his setup. + */ + $smarty->assign("gotoShareSelections", $this->gotoShareSelections); + $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections)); + + /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry + * This entry will be, a combination of mountPoint and sharedefinitions + */ + if((isset($_POST['gotoShareAdd'])) && ($this->acl_is_writeable("gotoShare"))) { + /* We assign a share to this user, if we don't know where to mount the share */ + if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){ + print_red(_("You must specify a valid mount point.")); + }else{ + if(count($this->gotoAvailableShares)){ + $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']]; + $s_mount = $_POST['gotoShareMountPoint']; + /* Preparing the new assignment */ + $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share; + $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount; + } + } + } + + /* if the Post gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected) + * If there is no defined share selected, we will abort the deletion without any message + */ + if(($this->acl_is_writeable("gotoShare"))&& (isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){ + unset($this->gotoShares[$_POST['gotoShare']]); + } + + $smarty->assign("gotoShares",$this->printOutAssignedShares()); + $smarty->assign("gotoSharesCount",count($this->printOutAssignedShares())); + $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares())); + $smarty->assign("gotoBootKernels",$this->gotoBootKernels); + + /* Create divSelectBox for ldap server selection + */ + $SelectBoxLdapServer = new divSelectBox("LdapServer"); + $SelectBoxLdapServer->SetHeight(130); + + /* Add new ldap server to the list */ + if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){ + if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){ + $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']]; + if(!in_array($to_add,$this->gotoLdapServers)){ + $this->gotoLdapServers[] = $to_add; + } + } + } + + /* Move ldap servers up and down */ + if(!$this->gotoLdap_inherit){ + foreach($_POST as $name => $value){ + if(preg_match("/sort_ldap_up_/",$name)){ + $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name); + $from = $id; + $to = $id -1; + $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); + if($tmp){ + $this->gotoLdapServers = $tmp; + } + break; + } + if(preg_match("/sort_ldap_down_/",$name)){ + $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name); + $from = $id; + $to = $id +1; + $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); + if($tmp){ + $this->gotoLdapServers = $tmp; + } + break; + } + if(preg_match("/gotoLdapRemove_/",$name)){ + $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name); + $value = $this->gotoLdapServers[$id]; + $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers); + break; + } + } + } + + /* Add Entries + */ + foreach($this->gotoLdapServers as $key => $server){ + if(!in_array($server,$this->gotoLdapServerList)){ + $server = $server." (missing)"; + } + + $SelectBoxLdapServer->AddEntry( + array(array("string" => $server), + array("string" => + " ". + " ". + "", + "attach" => "style='text-align:right;width:40px;border-right:0px;'"))); + } + + if($this->gotoLdap_inherit){ + $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));; + }else{ + $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer")); + } + + $list = array(); + foreach($this->gotoLdapServerList as $key => $entry){ + if(!in_array($entry,$this->gotoLdapServers)){ + $list[$key] = $entry; + } + } + $smarty->assign("gotoLdapServers", $SelectBoxLdapServer->DrawList()); + $smarty->assign("gotoLdapServerList", $list); + $smarty->assign("gotoLdap_inherit", $this->gotoLdap_inherit); + $smarty->assign("JS", $_SESSION['js']); + + foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){ + $smarty->assign("$val", $this->$val); + } + + /* Values */ + foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){ + $smarty->assign($val, $this->$val); + } + + $smarty->assign("fai_activated",$this->fai_activated); + + /* Create FAI output */ + if($this->fai_activated){ + $smarty->assign("FAIdebianMirrors",$this->getFAIdebianMirrors()); + $smarty->assign("FAIdebianMirror",$this->FAIdebianMirror); + $smarty->assign("FAIreleases",$this->getFAIreleases()); + $smarty->assign("FAIrelease",$this->FAIrelease); + $smarty->assign("FAIclasses",$this->selectFriendlyClasses()); + $smarty->assign("FAIclassesKeys",array_flip($this->selectFriendlyClasses())); + $smarty->assign("FAIclassKeys",$this->FAIclass); + + $inheritedRelease = array(); + if(!empty($this->InheritedFAIrelease)){ + $inheritedRelease[$this->InheritedFAIrelease]= $this->InheritedFAIrelease; + } + $smarty->assign("InheritedFAIrelease",$inheritedRelease); + + $div = new divSelectBox("WSFAIscriptClasses"); + $div -> SetHeight("110"); + $str_up = "  "; + $str_down = "  "; + $str_remove = "  "; + $str_empty = "  \"\""; + + $i = 1; + + if($this->FAIdebianMirror == "inherited"){ + $tmp = $this->InheritedFAIclass; + }else{ + $tmp = $this->FAIclass; + } + + foreach($tmp as $class){ + + $marker = ""; + if(in_array_ics($class,$this->unresolved_classes)){ + $marker = " ("._("Not available in current setup").")"; + } + + if($this->FAIdebianMirror == "inherited"){ + $str = ""; + }else{ + if($i==1){ + $str = $str_empty.$str_down.$str_remove; + }elseif($i == count($this->FAIclass)){ + $str = $str_up.$str_empty.$str_remove; + }else{ + $str = $str_up.$str_down.$str_remove; + } + } + $i ++ ; + + $desc = ""; + if(isset($this->FAIclassInfo[$class])){ + foreach($this->FAIclassInfo[$class] as $types ){ + if(isset($types['desc'][0])){ + $desc.= $types['desc'][0]." "; + } + } + } + if(!empty($desc)){ + $desc = " [".trim($desc)."]"; + } + + $div->AddEntry(array( + array("string"=>$class.$desc.$marker), + array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'") + )); + } + $smarty->assign("FAIScriptlist",$div->DrawList()); + }// END FAI output generation + + /* Radio button group */ + if (preg_match("/G/", $this->bootmode)) { + $smarty->assign("graphicalbootup", "checked"); + } else { + $smarty->assign("graphicalbootup", ""); + } + if (preg_match("/T/", $this->bootmode)) { + $smarty->assign("textbootup", "checked"); + } else { + $smarty->assign("textbootup", ""); + } + if (preg_match("/D/", $this->bootmode)) { + $smarty->assign("debugbootup", "checked"); + } else { + $smarty->assign("debugbootup", ""); + } + + /* Show main page */ + return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__)))); + } + + function remove_from_parent() + { + $this->handle_post_events("remove"); + new log("remove","workstation/".get_class($this),$this->dn); + } + + function generateDNSyn($release) + { + $str = ""; + $tmp = split("\/",$release); + $tmp = array_reverse($tmp); + $base = "ou=fai,ou=configs,ou=systems,"; + foreach($tmp as $departmentname){ + $str .= ",ou=".$departmentname; + } + $str = preg_replace("/^,/","",($str.",".$base)); + + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=FAIbranch))",array("ou")); + while($attrs = $ldap->fetch()){ + if(preg_match("/".normalizePreg($str)."/",$attrs['dn'])){ + return($attrs['dn']); + } + } + + return($str.$this->config->current['BASE']); + } + + function getFAIdebianMirrors() + { + $ret = array(); + + /* Only add inherit option, if we are part in an object group + */ + if($this->member_of_ogroup) { + $ret['inherited']['NAME']="["._("inherited")."]"; + $ret['inherited']['USE'] = TRUE; + } + + $ret['auto']['NAME']=_("automatic"); + $ret['auto']['USE'] = TRUE; + $secs = array(); + + /* Walk through all available servers + and check if they support the currently selected classes + if not, dont't add them to our list + */ + foreach($this->FAIServRepConfig as $mirror => $rest){ + + /* Automatically selection is available everytime */ + if($mirror == "auto"){ + continue; + } + + $use = false; + if(count($this->FAIclass) == 0){ + $use = true; + }else{ + $tmp = $this->getFAIreleases(); + foreach($tmp as $release => $data){ + if(isset($rest['RELEASE'][$release]) && $release == $this->FAIrelease){ + $use = $data['USE']; + } + } + } + + /* If current server, doesn't support this class + remove it from list + */ + $ret[$mirror]['NAME'] = $mirror; + $ret[$mirror]['USE'] = $use; + } + return($ret); + } + + function getFAIreleases() + { + $ret = array(); + + if($this->FAIdebianMirror == "inherited") { + return(array()); + } + + if(!isset($this->FAIServRepConfig[$this->FAIdebianMirror])){ + $this->FAIdebianMirror = "auto"; + } + + $errorClasses = array(); + if(isset($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'])) { + foreach($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'] as $release => $sections){ + $use = true; + + if(!count($this->FAIclass) == 0){ + foreach($this->FAIclass as $class){ + if(!in_array($class, $sections['PACKAGES'])){ + $use = false; + $errorClasses[$class] = $class; + }else{ + if(isset($errorClasses[$class])){ + unset($errorClasses[$class]); + } + } + } + } + $ret[$release]['NAME']=$release; + $ret[$release]['USE']=$use; + } + } + + if((count($ret) == 0 ) && ($this->FAIdebianMirror != "auto")){ + $eClasses = " "; + foreach($errorClasses as $class){ + $eClasses .= $class." "; + } + + print_red(sprintf(_("Can't resolve one or more of the given FAIclass(es) [%s] in FAI server '%s'. Server was reset to 'auto'."),$eClasses, $this->FAIdebianMirror)); + $this->FAIdebianMirror = "auto"; + return($this->getFAIreleases()); + }elseif((count($ret) == 0 ) && ($this->FAIdebianMirror == "auto")){ + + $eClasses = " "; + foreach($errorClasses as $class){ + $eClasses .= $class." "; + } + + $eClasses = preg_replace("/ */","",$eClasses); + + if(!empty($eClasses)) { + + $this->unresolved_classes = $errorClasses; + $this->FAIdebianMirror = "auto"; + print_red(sprintf(_("Can't resolve the given FAIclass(es) [%s] anyway, please check your FAI configurations, possibly some classes where deleted or renamed. Server was reset to 'auto'."),$eClasses)); + } + } + return($ret); + } + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + + if(isset($_POST['WorkstationStarttabPosted'])){ + if(isset($_POST['gotoLdap_inherit'])){ + $this->gotoLdap_inherit = TRUE; + }else{ + $this->gotoLdap_inherit = FALSE; + } + + /* Save group radio buttons */ + if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){ + $this->bootmode= $_POST["bootmode"]; + } + + /* Save kernel parameters */ + if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){ + $this->customParameters= $_POST["customParameters"]; + } + } + } + + + /* Save to LDAP */ + function save() + { + + /* Depending on the baseobject (Ogroup / WS) we + * use another set of objectClasses + * In case of WS itself, we use "array("GOhard", "FAIobject");" + * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject")) + */ + if(isset($this->parent->by_object['ogroup'])){ + $this->objectclasses = array("gotoWorkstationTemplate"); + }elseif(isset($this->parent->by_object['workgeneric'])){ + $this->objectclasses = array("GOhard"); + }elseif(isset($this->parent->by_object['servgeneric'])){ + $this->objectclasses = array("GOhard","gotoWorkstationTemplate"); + }else{ + print "Object Type Configuration : unknown"; + exit(); + } + + /* Append FAI class */ + if($this->fai_activated){ + $this->objectclasses[] = "FAIobject"; + } + + /* Find proper terminal path for tftp configuration + FIXME: This is suboptimal when the default has changed to + another location! */ + if (($this->gotoTerminalPath == "default")){ + $ldap= $this->config->get_ldap_link(); + + /* Strip relevant part from dn, keep trailing ',' */ + $tmp= preg_replace("/^cn=[^,]+,ou=terminals,ou=systems,/i", "", $this->dn); + $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp); + + /* Walk from top to base and try to load default values for + 'gotoTerminalPath'. Abort when an entry is found. */ + while (TRUE){ + $tmp= preg_replace ("/^[^,]+,/", "", $tmp); + + $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp". + $this->config->current['BASE'], array('gotoTerminalPath')); + $attrs= $ldap->fetch(); + if (isset($attrs['gotoTerminalPath'])){ + $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0]; + break; + } + + /* Nothing left? */ + if ($tmp == ""){ + break; + } + } + } + + /* Add semi automatic values */ + // FIXME: LDAP Server may not be set here... + $this->gotoKernelParameters= "ldap=".base64_encode($this->gotoLdapServer); + + switch ($this->bootmode){ + case "D": + $this->gotoKernelParameters.= " debug"; + break; + case "G": + $this->gotoKernelParameters.= " splash=silent"; + break; + } + if ($this->customParameters != ""){ + $this->gotoKernelParameters.= " o ".$this->customParameters; + } + + plugin::save(); + + unset( $this->attrs['FAIrelease'] ); + + $str = ""; + + /* Skip FAI attribute handling if not necessary */ + if($this->fai_activated){ + if($this->FAIdebianMirror == "inherited"){ + $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] = $this->attrs['FAIdebianMirror'] = array(); + }else{ + foreach($this->FAIclass as $class){ + $str .= $class." "; + } + $str .= ":" . $this->FAIrelease; + $this->attrs['FAIclass']= ""; + $this->attrs['FAIclass']= trim($str); + + if(empty($this->attrs['FAIclass'])){ + $this->attrs['FAIclass'] = array(); + } + } + } + + /* Add missing arrays */ + foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){ + if (isset ($this->$val) && count ($this->$val) != 0){ + + $this->attrs["$val"]= array_unique($this->$val); + } + if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array(); + } + + /* Prepare list of ldap servers */ + $this->attrs['gotoLdapServer'] = array(); + if(!$this->gotoLdap_inherit){ + $i = 0; + foreach($this->gotoLdapServers as $server){ + $i ++; + $this->attrs['gotoLdapServer'][] = $i.":".$server; + } + } + + if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){ + $this->attrs['gotoBootKernel']= array(); + } + + /* if mirror == none stop saving this attribute */ + if($this->FAIdebianMirror == "none"){ + $this->FAIdebianMirror = ""; + } + + /* Get FAIstate from object, the generic tab could have changed it during execute */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + + + /* Skip FAI attribute handling if not necessary */ + if($this->fai_activated){ + $ldap->cat($this->dn,array("FAIstate")); + $checkFAIstate = $ldap->fetch(); + + /* Remove FAI objects if no FAI class is selected */ + if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){ + $this->attrs['FAIclass'] = array(); + $this->attrs['FAIdebianMirror'] = array(); + } + } + + + /* prepare share settings */ + $tmp = array(); + foreach($this->gotoShares as $name => $settings){ + $tmp2= split("\|",$name); + $name = $tmp2[0]; + $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint']; + } + $this->attrs['gotoShare']=$tmp; + + $this->cleanup(); + $ldap->modify ($this->attrs); + new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/startup with dn '%s' failed."),$this->dn)); + $this->handle_post_events("modify"); + } + + /* Add value to array, check if unique */ + function add_list (&$array, $value) + { + if ($value != ""){ + $array[]= $value; + sort($array); + array_unique ($array); + } + } + + + /* Delete value to array, check if unique */ + function del_list (&$array, $list) + { + $tmp= array(); + foreach ($array as $mod){ + if (!in_array($mod, $list)){ + $tmp[]= $mod; + } + } + $array= $tmp; + } + + /* Generate ListBox frindly output for the defined shares + * Possibly Add or remove an attribute here, + */ + function printOutAssignedShares() + { + $a_return = array(); + if(is_array($this->gotoShares)){ + foreach($this->gotoShares as $share){ + $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]"; + } + } + return($a_return); + } + + + function GetHookElements() + { + $ret = array(); + $cmd= $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs')); + if(!empty($cmd)){ + $res = shell_exec($cmd); + $res2 = trim($res); + if((!$res)){ + print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s' please check your gosa.conf."),$cmd)); + }elseif(empty($res2)){ + print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd)); + }else{ + $tmp = split("\n",$res); + foreach($tmp as $line){ + if(empty($line)) continue; + $ret[]= $line; + } + } + } + return($ret); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $source_o = new workstartup ($this->config, $source['dn']); + + foreach(array("FAIclass","gotoModules", "gotoAutoFs", "gotoFilesystem","gotoKernelParameters","gotoShares","customParameters") as $attr){ + $this->$attr = $source_o->$attr; + } + } + + + function array_switch_item($ar,$from,$to) + { + if(!is_array($ar)){ + return(false); + } + if(!isset($ar[$from])){ + return(false); + } + if(!isset($ar[$to])){ + return(false); + } + + $tmp = $ar[$from]; + $ar[$from] = $ar[$to]; + $ar[$to] = $tmp; + return($ar); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Startup"), + "plDescription" => _("System startup"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 9, + "plSection" => array("administration"), + "plCategory" => array("workstation","server","ogroups"), + + "plProvidedAcls"=> array( + "gotoLdapServer" => _("Ldap server"), + "gotoBootKernel" => _("Boot kernel"), + "gotoKernelParameters" => _("Kernel parameter"), + + "gotoModules" => _("Kernel modules"), + "gotoShare" => _("Shares"), + + "FAIclass" => _("FAI classes"), + "FAIdebianMirror" => _("Debian mirror"), + "FAIrelease" => _("Debian release"), + + "FAIstatus" => _("FAI status flag")) // #FIXME is this acl realy necessary ? + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/component.tpl b/gosa-core/plugins/admin/systems/component.tpl new file mode 100644 index 000000000..3ddd5068c --- /dev/null +++ b/gosa-core/plugins/admin/systems/component.tpl @@ -0,0 +1,56 @@ + + + + + +
+ + + + + + + + + + + + +
{$must} +{render acl=$cnACL} + +{/render} +
 
{$must} +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} + +
+
+ + + + + +
+{render acl=$descriptionACL} + +{/render} +
+
+ +

 

+ +{$netconfig} + + + diff --git a/gosa-core/plugins/admin/systems/contents.tpl b/gosa-core/plugins/admin/systems/contents.tpl new file mode 100644 index 000000000..001d50d43 --- /dev/null +++ b/gosa-core/plugins/admin/systems/contents.tpl @@ -0,0 +1 @@ +{$Kekse} sind gesund diff --git a/gosa-core/plugins/admin/systems/gencd.tpl b/gosa-core/plugins/admin/systems/gencd.tpl new file mode 100644 index 000000000..f0c449677 --- /dev/null +++ b/gosa-core/plugins/admin/systems/gencd.tpl @@ -0,0 +1,20 @@ +

+ {t}CD-Install-Image generation{/t} +

+

+ {t}This option enables you to generate FAI install CD images for the selected workstation. The procedure may take about 10 minutes to complete, so please be patient after pressing the 'Create ISO-Image' button.{/t} +

+ +

+ +   + +

+ + + diff --git a/gosa-core/plugins/admin/systems/gencd_frame.tpl b/gosa-core/plugins/admin/systems/gencd_frame.tpl new file mode 100644 index 000000000..4c53bdab5 --- /dev/null +++ b/gosa-core/plugins/admin/systems/gencd_frame.tpl @@ -0,0 +1,3 @@ + diff --git a/gosa-core/plugins/admin/systems/info.tpl b/gosa-core/plugins/admin/systems/info.tpl new file mode 100644 index 000000000..e088c595a --- /dev/null +++ b/gosa-core/plugins/admin/systems/info.tpl @@ -0,0 +1,135 @@ +

{t}System information{/t}

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
{t}CPU{/t}{$ghCpuType}
{t}Memory{/t}{$ghMemSize}
{t}Boot MAC{/t}{$macAddress}
{t}USB support{/t}{$ghUsbSupport}
{t}System status{/t}{$status}
{t}Inventory number{/t}{$ghInventoryNumber}
{t}Last login{/t}{$gotoLastUser}
+
+   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t}Network devices{/t} + {foreach item=netcard from=$ghNetNic} + {$netcard}
+ {/foreach} +
{t}IDE devices{/t} + {foreach item=idedev from=$ghIdeDev} + {$idedev}
+ {/foreach} +
{t}SCSI devices{/t} + {foreach item=scsidev from=$ghScsiDev} + {$scsidev}
+ {/foreach} +
{t}Floppy device{/t}{$FloppyDevice}
{t}CDROM device{/t}{$CdromDevice}
{t}Graphic device{/t}{$ghGfxAdapter}
{t}Audio device{/t}{$ghSoundAdapter}
+
+ +{if $active eq "true"} +
+

{t}System status{/t}

+ + + + + + +
+ + + + + + + + + + + + + + + + + {$partitions} +
{t}Up since{/t}{$uptime}
{t}CPU load{/t}{$load}
{t}Memory usage{/t}{$mem}
{t}Swap usage{/t}{$swap}
 
+
+   + + + + + + + + + + + + + + + + + +
{t}SSH service{/t}{$sshd}
{t}Print service{/t}{$cupsd}
{t}Scan service{/t}{$saned}
{t}Sound service{/t}{$artsd}
{t}GUI{/t}{$X}
+
+{/if} + diff --git a/gosa-core/plugins/admin/systems/main.inc b/gosa-core/plugins/admin/systems/main.inc new file mode 100644 index 000000000..f9bd8fb9c --- /dev/null +++ b/gosa-core/plugins/admin/systems/main.inc @@ -0,0 +1,55 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('systems'); + } +} else { + /* Create usermanagement object on demand */ + if (!isset($_SESSION['systems']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['systems']= new systems($config, $ui); + } + $systems= $_SESSION['systems']; + $systems->save_object(); + $output= $systems->execute(); + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('systems'); + } + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/system.png'), _("System management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/system.png'), _("System management")); + } + + /* Show and save dialog */ + $display.= $output; + $_SESSION['systems']= $systems; +} + +?> diff --git a/gosa-core/plugins/admin/systems/network.tpl b/gosa-core/plugins/admin/systems/network.tpl new file mode 100644 index 000000000..7cb6b3ff9 --- /dev/null +++ b/gosa-core/plugins/admin/systems/network.tpl @@ -0,0 +1,152 @@ +

{t}Network settings{/t}

+ + + + + + {if $DNS_is_account==true} + + {/if} + + +
+ + + + + + + + + + {if $dhcpEnabled} + + + + {/if} +
+{render acl=$ipHostNumberACL} + +{/render} +{render acl=$ipHostNumberACL} +{if $DNSAccount == true} + + {else} + + {/if} +{/render} +
{$staticAddress} +{render acl=$macAddressACL} + +{/render} + {if $autonet==true} + + {/if} +
+ + {if $dhcpParentNodeCnt} + + + + + {else} + + + + {/if} + {if $dhcp_is_Account} + + + + + {/if} +
+ + + {t}Enable DHCP for this device{/t} + +
+ + {t}Enable DHCP for this device{/t} ({t}not configured{/t}) + +
  + {t}Parent node{/t} + +   + +
+
+
+ + {if $ZoneCnt} + {if $DNSAccount == true} + + {else} + + {/if} + + {t}Enable DNS for this device{/t} + + {if $DNSAccount == true} +
+ {else} + + {else} + + {t}Enable DNS for this device{/t} ({t}not configured{/t}) + + {/if} + +
+ + + diff --git a/gosa-core/plugins/admin/systems/password.tpl b/gosa-core/plugins/admin/systems/password.tpl new file mode 100644 index 000000000..734a4ae0c --- /dev/null +++ b/gosa-core/plugins/admin/systems/password.tpl @@ -0,0 +1,39 @@ +

+ {t}To change the terminal root password use the fields below. The changes take effect during the next reboot. Please memorize the new password, because you wouldn't be able to log in.{/t} +

+

+ {t}Leave fields blank for password inheritance from default entries.{/t} +

+ +

+ {t}Changing the password impinges on authentification only.{/t} +

+ + + + + + + + + + +
+ +
+ +

+ +   + +

+ + + diff --git a/gosa-core/plugins/admin/systems/paste_generic.tpl b/gosa-core/plugins/admin/systems/paste_generic.tpl new file mode 100644 index 000000000..b15920aee --- /dev/null +++ b/gosa-core/plugins/admin/systems/paste_generic.tpl @@ -0,0 +1,60 @@ +{if $object == "server"} + + + + + +
{$must} + +
+{/if} +{if $object == "workstation"} + + + + + +
{$must} + +
+{/if} +{if $object == "terminal"} + + + + + +
{$must} + +
+{/if} +{if $object == "printer"} + + + + + +
{$must} + +
+{/if} +{if $object == "phone"} + + + + + +
{$must} + +
+{/if} +{if $object == "component"} + + + + + +
{$must} + +
+{/if} diff --git a/gosa-core/plugins/admin/systems/phone.tpl b/gosa-core/plugins/admin/systems/phone.tpl new file mode 100644 index 000000000..58fdd6084 --- /dev/null +++ b/gosa-core/plugins/admin/systems/phone.tpl @@ -0,0 +1,57 @@ + + + + + +
+ + + + + + + + + + + + +
{$must} +{render acl=$cnACL} + +{/render} +
 
{$must} +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+
+ + + + + +
+{render acl=$descriptionACL} + +{/render} +
+
+ +

 

+{include file="$phonesettings"} + +

 

+{$netconfig} + + + diff --git a/gosa-core/plugins/admin/systems/phonesettings.tpl b/gosa-core/plugins/admin/systems/phonesettings.tpl new file mode 100644 index 000000000..19385ac86 --- /dev/null +++ b/gosa-core/plugins/admin/systems/phonesettings.tpl @@ -0,0 +1,260 @@ +

{t}Advanced phone settings{/t}

+ + + + + +{if $selected_categorie eq '0'} + + + + +
+ {$staticAddress} +{render acl=$categorieACL} + +{/render} + {if $javascript eq 'false'} + + {/if} +
+
+
+ + + + + + + + + +
+ {$staticAddress} + + +{render acl=$goFonTypeACL} + +{/render} +
+ + +{render acl=$goFonDmtfModeACL} + +{/render} +
+
+ + + + + + + + + +
+ + +{render acl=$goFonDefaultIPACL} + +{/render} +
+ + +{render acl=$goFonQualifyACL} + +{/render} +
+
+{/if} + +{if $selected_categorie eq '1'} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +{render acl=$goFonTypeACL} + +{/render} +
+ + +{render acl=$goFonDefaultIPACL} + +{/render} +
+ + +{render acl=$goFonQualifyACL} + +{/render} +
+   +
+ + +{render acl=$goFonAuthACL} + +{/render} +
+ + +{render acl=$goFonSecretACL} + +{/render} +
+   +
+ + +{render acl=$goFonAccountCodeACL} + +{/render} +
+ + +{render acl=$goFonTrunkACL} + +{/render} +
+ + + + + + + + +
+
+{render acl=$goFonPermitACL} + +{/render} +
+{render acl=$goFonPermitACL} + +{/render} +{render acl=$goFonPermitACL} + +{/render} +{render acl=$goFonPermitACL} + +{/render} +

+
+
+{render acl=$goFonDenyACL} + +{/render} +
+{render acl=$goFonDenyACL} + +{/render} +{render acl=$goFonDenyACL} + +{/render} +{render acl=$goFonDenyACL} + +{/render} +
+ + +{/if} + +{if $selected_categorie eq '2'} + + + + + + +
+   +{render acl=$goFonMSNACL} + +{/render} +
+ + +   + + + +{/if} diff --git a/gosa-core/plugins/admin/systems/ppd/class_printerPPDDialog.inc b/gosa-core/plugins/admin/systems/ppd/class_printerPPDDialog.inc new file mode 100644 index 000000000..a93e91bb4 --- /dev/null +++ b/gosa-core/plugins/admin/systems/ppd/class_printerPPDDialog.inc @@ -0,0 +1,546 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("cn"); + var $objectclasses = array("whatever"); + + /* PPD Handling */ + var $selectedPPD = false; // e.g. /vendor/device.ppd + var $ppdManager = false; // new ppdManager; + var $ppdConfig = false; // $this->ppdManager->loadProperties($this->selectedPPD['link']); + var $ppdList = array(); // Contains all Printer models + var $ppdListHeader = array(); // Contains all printer vendors + + /* Paths */ + var $pathToPPD = ""; // Base path, defined in gosa.conf e.g. "/var/spool/ppd/" + var $pathToModified = "modified/"; // used to store the modified ppds + + /* Object Info */ + var $cn = "" ; // Used to tag the ppds modified by the printer object, + + /* If there is already a ppd file for the same type of printer, + * remember the path to ppd file and display a dialog which allows + * to overwrite the current ppd file. + */ + var $add_ppd_later = ""; + var $add_later_msg_dialog = NULL; + + function printerPPDDialog (&$config, $dn= NULL, $ppdfile=NULL ) + { + plugin::plugin ($config, $dn); + $this->depselect = $this->config->current['BASE']; + + /* Get PPD path and remove double //, and add trailing / */ + if(isset($_SESSION['config']->data['MAIN']['PPD_PATH'])){ + $this->pathToPPD = $_SESSION['config']->data['MAIN']['PPD_PATH']; + $this->pathToPPD= preg_replace("/\/\//", "/", $this->pathToPPD); + if(!preg_match("/\/$/",$this->pathToPPD)){ + $this->pathToPPD = $this->pathToPPD."/"; + } + }else{ + $this->pathToPPD = ""; + } + + /* It seams that we have an existing PPD path, so go on */ + if(!((!is_dir($this->pathToPPD))||(empty($this->pathToPPD)))){ + + /* Load all available PPD files and sort them into an array */ + $this->ppdManager= new ppdManager($this->pathToPPD); + $this->getPrinterReload (); + + /* The user has already a valid PPD assigned + * Get some informations about this PPD + * and set it as selected. + * The ppdpath ['link'] should be relative from .../ppd/modified/ + * e.g. "/Compaq/Compaq-J1200.ppd" */ + if(($ppdfile!== NULL)&&(strlen($ppdfile)>0)){ + $ppdfile = preg_replace("#".$this->pathToModified."#","",$ppdfile); + if(!file_exists($this->pathToPPD.$this->pathToModified.$ppdfile)){ + print_red(sprintf(_("Can't open '%s', ppd settings resetted."),$ppdfile)); + }else{ + $res = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$ppdfile); + if($res){ + $tmp = split("\n",$res); + $tmp3 = array(); + $tmp3['name'] = trim(preg_replace("/^\-/","",trim($tmp[1]))); + $tmp3['link'] = $ppdfile; + $tmp3['ppd'] = $res; + } + $this->selectedPPD = $tmp3; + } + } + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $display= ""; + $smarty= get_smarty(); + $smarty->assign("ppdString", _("Can't get ppd informations.")); + $smarty->assign("showOptions", ""); + + /* Check these paths */ + $paths = array($this->pathToPPD, $this->pathToPPD.$this->pathToModified); + + /* If one of our required paths is not available, stop here and display some info */ + foreach($paths as $path){ + + /* Check if path is write/readable*/ + $is_r = @is_readable($path); + if(((!is_dir($path))||(empty($path)) || (!$is_r)) && (!@mkdir($path))){ + print_red(sprintf(_("The specified path '%s' which results from PPD_PATH in your gosa.conf is invalid, can't read/write any ppd informations."),$path)); + /* Print out template */ + $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__))); + return($display); + } + } + + // PPD selection / upload / dialog handling + + /* Is there a new PPD file uploaded ? */ + if((isset($_FILES['NewPPDFile']))&&(isset($_POST['SubmitNewPPDFile']))){ + $file = ($_FILES['NewPPDFile']); + if($file['size'] != 0 ){ + if($name = $this->AddPPD($file['tmp_name'])){ + $this->SelectPPD($name); + } + }else{ + print_red(_("Please specify a valid ppd file.")); + } + } + + /* Overwrite existing PPD file and select it as currently used for this object */ + if(is_object($this->add_later_msg_dialog) && ($this->add_later_msg_dialog->is_confirmed()) && $this->add_ppd_later != ""){ + if($name = $this->AddPPD($this->add_ppd_later,TRUE)){ + $this->SelectPPD($name); + } + $this->add_ppd_later = ""; + $this->add_later_msg_dialog = NULL; + } + + /* Open a dialog that allow us to select different PPDs */ + if(isset($_POST['SelectPPD'])){ + $this->dialog= new printerPPDSelectionDialog($this->config,$this->dn,$this->ppdList,$this->ppdListHeader,$this->selectedPPD); + } + + /* The selection dialog fpr PPDs is canceled */ + if(isset($_POST['ClosePPDSelection'])){ + unset($this->dialog); + $this->dialog=FALSE; + } + + /* Div Selection */ + if((isset($_GET['act']))&&($_GET['act']=="use")){ + $this->SelectPPD(base64_decode($_GET['id'])); + unset($this->dialog); + $this->dialog=FALSE; + + } + + /* if a dialog is open, print the dialog instead of this class */ + if(is_object($this->dialog)){ + $display = $this->dialog->execute(); + return($display); + } + + // ENDE PPD selection / upload / dialog handling + + /* Give smarty the information it needs */ + $smarty->assign("ppdString" ,$this->getPPDInformation()); + $tmp= $this->generateProperties(); + if ($tmp == ""){ + $smarty->assign("showOptions", 0); + } else { + $smarty->assign("showOptions", 1); + $smarty->assign("properties",$this->generateProperties()); + } + + /* Print out template */ + $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + + /* Select PPD */ + function SelectPPD($name) + { + /* Replace base path we don't need it here + The path we need looks like this : "/Vendor/ModellName.ppd"; + thats all */ + $name = preg_replace("#".$this->pathToPPD."#","",$name); + + /* Intialise some base vars */ + $AbsoluteSourceName = $this->pathToPPD.$name; + $AbsoluteDestinationPath = $this->pathToPPD.$this->pathToModified; + $Vendor = ""; // Vendor + $Name = ""; // Name + $Modell = ""; // Modell + $PrinterName = ""; // The new name of the printer + $PPDName = ""; + + /* Force reload of config dialog */ + $this->ppdConfig = false; + $this->selectedPPD['link'] = false; + + /* Get PPD informations and set vendor / modell / name */ + if((!file_exists($AbsoluteSourceName)) || (!is_readable($AbsoluteSourceName))){ + print_red(sprintf(_("Can't select PPD file '%s', the file is not readable"),$AbsoluteSourceName)); + return; + } + $res = $this->ppdManager->loadDescription($AbsoluteSourceName); + if($res){ + $tmp = split("\n",$res); + $Name = trim(preg_replace("/^\-/","",trim($tmp[1]))); + $Vendor = trim($tmp[0]); + $Model = trim(preg_replace("/".$Vendor."/","",$Name)); + } + + $PrinterName = $this->cn."-".preg_replace("/[^a-z0-9-_\.]/i","_",$Name); + $PPDName = $Vendor."/".$PrinterName.".ppd"; + + /* Create the vendors path, if it doesn't exists already */ + if(!is_dir($AbsoluteDestinationPath.$Vendor)){ + if(!(@mkdir($AbsoluteDestinationPath.$Vendor))){ + print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$AbsoluteDestinationPath.$Vendor)); + return(false); + } + } + + /* Create destination file handle */ + $fp = @fopen($AbsoluteDestinationPath.$PPDName,"w+"); + if(!$fp){ + print_red(sprintf(_("Can't create file '%s' to store modifed ppd informations."),$AbsoluteDestinationPath.$PPDName)); + return(false); + } + + $str = file_get_contents($AbsoluteSourceName); + fputs($fp,$str); + @fclose($fp); + + //$this->ppdManager->updateAttribute($filename,"NO_SECTION","ModelName",$printerName); + + $tmp3['link'] =$PPDName; + $this->selectedPPD = $tmp3; + $this->getPrinterReload(); + return($PPDName); + } + + + /* This function adds a new ppd file to the list of available ppds. + All required paths and files will be created + $_PathOnHdd e.g. = /tmp/PHP_tmpfile213452 */ + function AddPPD($_PathOnHdd,$overwrite = FALSE) + { + /* Check if file exists && is readable */ + if((!is_file($_PathOnHdd)) || (!is_readable($_PathOnHdd))){ + print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd)); + return(false); + } + + /* Reload list to detect changes e.g. a file has been deleted */ + $this->getPrinterReload(); + + /* Get Description from ppd, & parse out some informations */ + $res = @$this->ppdManager->loadDescription($_PathOnHdd); + if($res){ + $tmp = split("\n",$res); + $name = trim(preg_replace("/^\-/","",trim($tmp[1]))); + $vendor = trim($tmp[0]); + $model = trim(preg_replace("/".$vendor."/","",$name)); + } + + /* Check if parse was successfull */ + if(empty($name) || empty($vendor)){ + print_red(sprintf(_("The given ppd file '%s' seams to be invalid, can't get any model or vendor informations."),$_PathOnHdd)); + return(false); + } + + /* Prepare list of ppds */ + if(!isset($this->ppdList[$vendor])){ + $this->ppdList[$vendor] = array(); + } + + /* Create ppd file and fill in the source contents */ + $ppdname = $vendor."/".$name.".ppd"; + $filename = $this->pathToPPD.preg_replace("/[^a-z0-9-_\.\/]/i","_",$ppdname); + $filename = $this->pathToPPD.$ppdname; + $contents = file_get_contents($_PathOnHdd); + + + /* Check if this ppd already exists */ + $found = false; + foreach($this->ppdList[$vendor] as $key => $val){ + if(preg_match("/".$model.".*/i",$key)){ + $found = true; + if(!$overwrite){ + if(!copy($_PathOnHdd,$_PathOnHdd."_back")){ + print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd)); + }else{ + $this->add_ppd_later = $_PathOnHdd."_back"; + $this->add_later_msg_dialog = new msg_dialog(_("Overwrite existing PPD"), + _("There is already a ppd file for this kind of printer. Do you want to overwrite it?"),CONFIRM_DIALOG); + } + return; + } + } + } + + /* Create the vendors path, if it doesn't exists already */ + if(!is_dir($this->pathToPPD.$vendor)){ + if(!(@mkdir($this->pathToPPD.$vendor))){ + print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$this->pathToPPD.$vendor)); + return(false); + } + } + + /* Open file handle */ + $fp = fopen($filename,"w+"); + + /* Check file handle & contents */ + if(!$fp){ + print_red(sprintf(_("Can't save file '%s'."),$filename)); + return; + } + if(empty($contents)){ + print_red(_("Uploaded ppd file is empty, can't create new ppd file.")); + return; + } + + /* Fille file with data */ + fputs($fp,$contents); + @fclose($fp); + + /* Our job is done here */ + return($ppdname); + } + + + /* This function reloads the list of available printers/vendors + $this->ppdListHeader + Compaq => 1 + $this->ppdList + Compaq => Compaq IJ1200 => name => Compaq IJ1200 + link => /var/spool/ppd/Compaq/Compaq-J1200.ppd + ppd => Compaq - Co + */ + function getPrinterReload() + { + if(is_readable($this->pathToPPD)){ + $tmp = @$this->ppdManager->getPrinterList(true); + + $this->ppdListHeader = $this->ppdList = array(); + + /* Sort all available files, and create header (Vendor index) */ + foreach($tmp as $file=>$ppd){ + + if(preg_match("#".$this->pathToModified."#",$file)) continue; + + $tmp2 = split("\n",$ppd); + if(!isset($this->ppdListHeader[$tmp2[0]])){ + $this->ppdListHeader[$tmp2[0]]=0; + } + $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2]); + $tmp3['link'] =$file; + $tmp3['ppd'] =$ppd; + $this->ppdListHeader[$tmp2[0]]++; + $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2])]=$tmp3; + } + } + } + + + /* Save all options posted from ppd dialog */ + function save_object() + { + if(!((isset($_POST['PPDDisSubmitted'])) && (is_array($this->ppdConfig)))){ + return; + } + + foreach($this->ppdConfig as $cat => $obj){ + foreach($obj as $attr => $attributes){ + if(isset($_POST[base64_encode($attributes['_name'])])){ + $this->ppdConfig[$cat][$attr]['_default'] = $_POST[base64_encode($attributes['_name'])]; + } + } + } + } + + + /* Save modified ppd */ + function save_ppd() + { + if($this->ppdManager){ + $this->ppdManager->saveProperties($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'],$this->ppdConfig); + } + } + + + /* Return selected ppd path, if none is selected then false */ + function save() + { + /* return the selected PPD, and in future the selected options too */ + return($this->pathToModified.$this->selectedPPD['link']); + } + + + /* Get Information for a single PPD entry + * This will be shown on top of template + */ + function getPPDInformation() + { + $str = "none"; + if(!empty($this->selectedPPD)){ + $str = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']); + } + return($str) ; + } + + + /* Display all options from the selected ppd file */ + function generateProperties() + { + /* Set Headline */ + $str = ""; + $feed= ""; + + $s_ppd = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']; + + /* If ppd exists and is readable */ + if((!empty($this->selectedPPD['link']))&&(file_exists($s_ppd))){ + + /* If there is no initial Configuration, load it */ + if($this->ppdConfig == false){ + $this->ppdConfig = $this->ppdManager->loadProperties($s_ppd); + } + + /* Create a table */ + $str .= "
"; + + /* Input all data to the table */ + foreach($this->ppdConfig as $cat => $obj){ + + /* Add new category */ + $str .= ""; + + /* Add attributes of the current category */ + foreach($obj as $attr => $settings){ + + /* Skip all entries beginning with _ */ + if($attr[0] == "_") continue; + + /* Prepare data */ + $values = array(); + $name = $settings['_name']; + + if (!isset($settings['_default'])){ + $default = ""; + } else { + $default = $settings['_default']; + } + + $type = $settings['_type']; + + /* Add name to table */ + $str .= "\n"; + } + } + $str .= "
$feed"; + if ($feed == ""){ + $feed= "
"; + } + $str .= ""._("Section")." '".$cat."' 
"; + $str .= "
\n"; + $str .= $name."
\n"; + $str .= "
\n"; + + /* Get all values */ + foreach( $settings as $vname => $value){ + if($vname[0] != "_"){ + $values[$vname]= $value; + } + } + + /* preparing Html output + * Supported types are PickOne/Boolean + */ + + /* If type is PickOne, create a select box */ + if(($type == "PickOne")||(($type=="Boolean")&&(count($values)>1))){ + + $str .= "\n"; + + }elseif($type == "Boolean"){ + + /* If type is Boolean & no values are given */ + $str .= "\n"; + + }else{ + print_red(sprintf(_("Unsupported ppd type '%s' used for '%s' "),$type,$name)); + } + $str .= "
\n"; + } + return($str); + } + + function removeModifiedPPD() + { + $path = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']; + + if(file_exists($path)){ + if(is_writeable($path)){ + if(!@unlink($path)){ + print_red(sprintf(_("Removing old ppd file '%s' failed."),$path)); + } + }else{ + print_red(sprintf(_("Removing old ppd file '%s' failed. File is not accessible."),$path)); + } + }else{ + print_red(sprintf(_("Removing old ppd file '%s' failed. File does not exists or is not accessible."),$path)); + } + } + + function update_ppd_url() + { + $this->SelectPPD("modified/".$this->selectedPPD['link']); + } + + function check() + { + $message = plugin::check(); + if(empty($this->selectedPPD['link'])){ + $message[] = _("Please select a valid ppd file or use 'Cancel' to go back to printer configuration."); + } + return($message); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc b/gosa-core/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc new file mode 100644 index 000000000..d4f5d16b8 --- /dev/null +++ b/gosa-core/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc @@ -0,0 +1,197 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = FALSE; + var $attributes = array(); + var $objectclasses = array("whatever"); + + var $list =array(); + var $header =array(); + var $current_del_id = ""; + var $Vendor = ""; + + function printerPPDSelectionDialog (&$config, $dn= NULL,$list=false,$headers=false,$ppd=false) + { + plugin::plugin ($config, $dn); + $this->list = $list; + $this->header = $headers; + $this->depselect = $this->config->current['BASE']; + + if(!isset($_SESSION['printerPPDSelectionDialog'])){ + $_SESSION['printerPPDSelectionDialog']['regex'] = "*"; + } + + /* Order the manufacturers index */ + ksort($this->header); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + $s_action = "none"; + + $regex = $_SESSION['printerPPDSelectionDialog']['regex']; + + if(isset($_GET['search'])){ + $regex = $_GET['search']."*"; + } + + if(isset($_POST['regex'])){ + $regex= $_POST['regex']; + } + + $regex = str_replace("**","*",$regex); + $_SESSION['printerPPDSelectionDialog']['regex'] = $regex; + + + /* Delete requested, check if everything is ok and display confirmation dialog */ + if(isset($_GET['act']) && $_GET['act'] == "del"){ + + /* Get id and check if id is valid */ + $id_to_del = base64_decode($_GET['id']); + $found = ""; + foreach($this->list[$this->Vendor] as $key => $data){ + if($data['link'] == $id_to_del){ + $found = $key; + break; + } + } + if(!empty($found)){ + $this->current_del_id = $id_to_del; + + $smarty->assign("warning", sprintf(_("You're about to delete the ppd file '%s' at '%s'."), $found,$id_to_del)); + return($smarty->fetch(get_template_path('remove_ppd.tpl', TRUE))); + + }else{ + print_red(sprintf(_("Could not found specified ppd file '%s'."),$id_to_del)); + } + } + + /* Deletion confirmed */ + if(isset($_POST['delete_ppd_confirm']) && !empty($this->current_del_id)){ + + /* check if file is removeable */ + if(is_writeable($this->current_del_id)){ + $is_ok = @unlink($this->current_del_id); + + /* Update ppd list */ + if($is_ok){ + foreach($this->list as $vendor => $ppds){ + foreach($ppds as $ppd => $data){ + if($data['link'] == $this->current_del_id){ + unset($this->list[$vendor][$ppd]); + } + } + } + } + }else{ + $is_ok = false; + } + + if(!$is_ok){ + print_red(_("Something went wrong while trying to remove the ppd file from server, possibly we have no write access.")); + } + } + + + /** Added **/ + $list = array(); + foreach($this->list as $cat => $ppds){ + foreach($ppds as $ppd){ + if(preg_match("/^".str_replace("*",".*",$regex)."/i",$ppd['ppd'])){ + if(is_readable($ppd['link'])){ + $list[$ppd['link']] = $ppd; + } + } + } + } + + if((isset($_GET['act']))&&($_GET['act']=="open")) { + + if((!empty($_GET['id'])) && (!isset( $this->header[base64_decode($_GET['id'])]))){ + print_red(sprintf(_("Selected vendor '%s' does not exists in our list of ppds."),base64_decode($_GET['id']))); + $this->Vendor = ""; + }else{ + $this->Vendor = base64_decode($_GET['id']); + } + } + + $div = new divSelectBox("printerPPDSelectionDialog"); + $div ->SetHeight(450); + $div ->SetSummary(_("Printer ppd selection.")); + + $linkopen = " +  %s + "; + $uselink = "%s"; + $dellink = " + "._("delete")." + "; + + if(empty($this->Vendor)){ + foreach($this-> header as $key => $entry){ + $div ->AddEntry (array( + array("string"=>sprintf($linkopen,base64_encode($key),$key),"attach"=>"style='border-right:0px;'") + )); + } + }else{ + $div ->AddEntry (array( + array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'") + )); + foreach($list as $key => $ppd){ + if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){ + + if(is_writeable($ppd['link'])){ + $del_str = sprintf($dellink,base64_encode($key)); + }else{ + $del_str = ""; + } + + $div ->AddEntry (array( + array("string"=>sprintf($uselink,base64_encode($key),$ppd['ppd'])), + array("string"=>$del_str,"attach"=>"style='border-right:0px;'") + + )); + } + } + } + + $smarty->assign("List", $div -> DrawList()); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("apply", apply_filter()); + $smarty->assign("regex", $regex); + + $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + function save_object() + { + } + + function check(){ + } + + /* Save to LDAP */ + function save() + { + return $this->selectedPPD; + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/ppd/printerPPDDialog.tpl b/gosa-core/plugins/admin/systems/ppd/printerPPDDialog.tpl new file mode 100644 index 000000000..761d00516 --- /dev/null +++ b/gosa-core/plugins/admin/systems/ppd/printerPPDDialog.tpl @@ -0,0 +1,24 @@ +

P {t}Printer driver{/t}

+ + + + + +
+ {t}Model{/t}: {$ppdString}  + + + {t}New driver{/t}  + + +
+{if $showOptions eq 1} +

 

+

L {t}Options{/t}

+{$properties} +{/if} +

+ + + +

diff --git a/gosa-core/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl b/gosa-core/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl new file mode 100644 index 000000000..b6cad00b8 --- /dev/null +++ b/gosa-core/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl @@ -0,0 +1,48 @@ + + + + + +
+
+

+ {t}Select objects to add{/t} +

+
+
+ {$List} + +
+
+
+

+ [F] + {t}Filters{/t} +

+
+
+ + {$alphabet} +
+ + + + + +
+ + + +
+ {$apply} + +
+
+ +

+ +

+ diff --git a/gosa-core/plugins/admin/systems/ppd/remove_ppd.tpl b/gosa-core/plugins/admin/systems/ppd/remove_ppd.tpl new file mode 100644 index 000000000..6d28ba9ec --- /dev/null +++ b/gosa-core/plugins/admin/systems/ppd/remove_ppd.tpl @@ -0,0 +1,15 @@ +
+ {t}Warning{/t} +
+

+ {$warning} +

+ +

+ {t}The ppd file will be removed from the server and can not be restored.{/t} +

+

+ +   + +

diff --git a/gosa-core/plugins/admin/systems/printer.tpl b/gosa-core/plugins/admin/systems/printer.tpl new file mode 100644 index 000000000..e4ba965b9 --- /dev/null +++ b/gosa-core/plugins/admin/systems/printer.tpl @@ -0,0 +1,150 @@ + + + + + +
+{if $StandAlone } +

{t}General{/t}

+ + + + + + + + + + + + + + + + +
{$must} +{render acl=$cnACL} + +{/render} +
+{render acl=$descriptionACL} + +{/render} +
 
{$must} +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+
+{/if} +

{t}Details{/t}

+ + + + + + + + + +
+{render acl=$lACL} + +{/render} +
{$must} +{render acl=$labeledURIACL} + +{/render} +
+ + + + +
+
+ {t}Driver{/t}: {$driverInfo}  +{render acl=$gotoPrinterPPDACL mode=read_active} + +{/render} +{render acl=$gotoPrinterPPDACL} + +{/render} +
+
+ +

 

+ +

{t}Permissions{/t}

+ + + + + +
+ + + + +
+ {t}Users which are allowed to use this printer{/t}
+{render acl=$gotoUserPrinterACL} +
+{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +
+ +
+ + + + +
+ {t}Users which are allowed to administrate this printer{/t}
+{render acl=$gotoUserPrinterACL} +
+{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +{render acl=$gotoUserPrinterACL} + +{/render} + +
+ +
+ + +{if $netconfig ne ''} +

 

+{$netconfig} +{/if} + + + diff --git a/gosa-core/plugins/admin/systems/remove.tpl b/gosa-core/plugins/admin/systems/remove.tpl new file mode 100644 index 000000000..dc5dbb2bd --- /dev/null +++ b/gosa-core/plugins/admin/systems/remove.tpl @@ -0,0 +1,23 @@ +
+ {t}Warning{/t} +
+

+ {$warning} + {t}This includes all system and setup informations. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

diff --git a/gosa-core/plugins/admin/systems/selectUserToPrinterDialog.tpl b/gosa-core/plugins/admin/systems/selectUserToPrinterDialog.tpl new file mode 100644 index 000000000..c60be2297 --- /dev/null +++ b/gosa-core/plugins/admin/systems/selectUserToPrinterDialog.tpl @@ -0,0 +1,70 @@ + + + + + + + +
+
+

+ +

+
+
+

+
+

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + +
+  {t}Search in subtrees{/t} +
+ + + + + +
+ + + +
+ + + + + +
+ + + +
+ {$apply} +
+
+ +

 

+

+ + +

+ diff --git a/gosa-core/plugins/admin/systems/server.tpl b/gosa-core/plugins/admin/systems/server.tpl new file mode 100644 index 000000000..4e2d9b6a4 --- /dev/null +++ b/gosa-core/plugins/admin/systems/server.tpl @@ -0,0 +1,85 @@ + + + + + +
+ + + + + + + + + + + + + +
{$must} +{render acl=$cnACL} + +{/render} +
+{render acl=$descriptionACL} + +{/render} +

{$must}
+
+{render acl=$baseACL} + +{/render} + +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+
+ + + + + +
{t}Mode{/t} +{render acl=$gotoModeACL} + +{/render} +
+
+ +

 

+ +{$netconfig} + +{if $fai_activated} +

 

+ +

{t}Action{/t}

+ + + + + +
+{render acl=$FAIstateACL} + +{/render} + + +
+{/if} + + + diff --git a/gosa-core/plugins/admin/systems/services/ServiceAddDialog.tpl b/gosa-core/plugins/admin/systems/services/ServiceAddDialog.tpl new file mode 100644 index 000000000..f055f33c1 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/ServiceAddDialog.tpl @@ -0,0 +1,32 @@ +
 
+
+ {t}Adding a new service to the current server{/t} +
+
+

+{t}This dialog allows you to add new services to the currenty edited server object. The box below shows all available but not already used services.{/t} +
+
+

+{if $Services} +
+
{t}Service to add{/t}   + +{else} +
+ {t}All available services are already in use.{/t} +
+{/if} +
+
+
+

+

+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/class_ServiceAddDialog.inc b/gosa-core/plugins/admin/systems/services/class_ServiceAddDialog.inc new file mode 100644 index 000000000..47e97012d --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/class_ServiceAddDialog.inc @@ -0,0 +1,34 @@ +"Config object" , "dn"=>"Object dn"); + + /* This plugin does not have any ocs */ + var $objectclasses = array(); + var $parent = NULL; + + function ServiceAddDialog(&$config,$dn,$parent) + { + plugin::plugin($config); + $this->parent = $parent; + } + + function execute() + { + $smarty = get_smarty(); + $services = $this->parent->getAllUnusedServices(); + natcasesort($services); + $smarty->assign("Services",$services); + return($smarty->fetch(get_template_path("ServiceAddDialog.tpl", TRUE,dirname(__FILE__)))); + } + + function check(){ return array();} + function save_object(){;} + function save(){} + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/class_goService.inc b/gosa-core/plugins/admin/systems/services/class_goService.inc new file mode 100644 index 000000000..edfd3d7d5 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/class_goService.inc @@ -0,0 +1,238 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array(); + var $attributes = array(); + var $StatusFlag = ""; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array(); + var $dn = NULL; + var $cn = ""; + var $DisplayName = ""; + var $view_logged =FALSE; + + + /* Construcktion */ + function goService(&$config,$dn) + { + plugin::plugin($config,$dn); + $this->DisplayName = _("Empty service"); + } + + + /* Create content */ + function execute() + { + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $str ="
". + "  ". + " ". + "
"; + return($str); + } + + + /* Get service information for serverService plugin */ + function getListEntry() + { + + $this->updateStatusState(); + + /* Assign status flag */ + if(!empty($this->StatusFlag)){ + $flag = $this->StatusFlag; + $fields['Status'] = $this->$flag; + }else{ + $fields['Status'] = ""; + } + + /* Name displayed in service overview */ + $fields['Message'] = _("Empty service"); + + /* Allow/disallow some functions */ + $fields['AllowStart'] = $this->acl_is_writeable("start"); + $fields['AllowStop'] = $this->acl_is_writeable("stop"); + $fields['AllowRestart'] = $this->acl_is_writeable("restart"); + $fields['AllowRemove'] = $this->acl_is_removeable(); + $fields['AllowEdit'] = true; + return($fields); + } + + + /* Remove service */ + function remove_from_parent() + { + if(!$this->initially_was_account || !$this->acl_is_removeable()){ + return; + } + + plugin::remove_from_parent(); + + /* Remove status flag, it is not a memeber of + this->attributes, so ensure that it is deleted too */ + if(!empty($this->StatusFlag)){ + $this->attrs[$this->StatusFlag] = array(); + } + + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + + } + + new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn)); + $this->handle_post_events("remove"); + } + + + /* Save service */ + function save() + { + plugin::save(); + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + if($this->initially_was_account){ + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("modify"); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn)); + } + + + /* Directly save new status flag */ + function setStatus($value) + { + if($value == "none") return; + + /* Can't set status flag for new services (Object doesn't exists in ldap tree) */ + if(!$this->initially_was_account) return; + + /* Can't set status flag, if no flag is specified */ + if(empty($this->StatusFlag)){ + return; + } + + /* Get object (server), update status flag and save changes */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + + $tmp = $ldap->fetch(); + for($i = 0; $i < $tmp['objectClass']['count']; $i ++){ + $attrs['objectClass'][] = $tmp['objectClass'][$i]; + } + $flag = $this->StatusFlag; + $attrs[$flag] = $value; + $this->$flag = $value; + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn)); + $this->action_hook(); + } + } + + + function check() + { + $message = plugin::check(); + return($message); + } + + + function save_object() + { + plugin::save_object(); + } + + + function action_hook($add_attrs= array()) + { + /* Find postcreate entries for this class */ + $command= $this->config->search(get_class($this), "ACTION_HOOK",array('menu','tabs')); + if ($command != ""){ + + /* Walk through attribute list */ + foreach ($this->attributes as $attr){ + if (!is_array($this->$attr)){ + $command= preg_replace("/%$attr/", $this->$attr, $command); + } + } + $command= preg_replace("/%dn/", $this->dn, $command); + + /* Additional attributes */ + foreach ($add_attrs as $name => $value){ + $command= preg_replace("/%$name/", $value, $command); + } + + /* If there are still some %.. in our command, try to fill these with some other class vars */ + if(preg_match("/%/",$command)){ + $attrs = get_object_vars($this); + foreach($attrs as $name => $value){ + if(!is_string($value)) continue; + $command= preg_replace("/%$name/", $value, $command); + } + } + + if (check_command($command)){ + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, + $command, "Execute"); + + exec($command); + } else { + $message= sprintf(_("Command '%s', specified as ACTION_HOOK for plugin '%s' doesn't seem to exist."), $command, get_class($this)); + print_red ($message); + } + } + } + + + /* Get updates for status flag */ + function updateStatusState() + { + if(empty($this->StatusFlag)) return; + + $attrs = array(); + $flag = $this->StatusFlag; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->cn); + $ldap->cat($this->dn,array($flag)); + if($ldap->count()){ + $attrs = $ldap->fetch(); + } + if(isset($attrs[$flag][0])){ + $this->$flag = $attrs[$flag][0]; + } + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/cups/class_goCupsServer.inc b/gosa-core/plugins/admin/systems/services/cups/class_goCupsServer.inc new file mode 100644 index 000000000..6fa572b9d --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/cups/class_goCupsServer.inc @@ -0,0 +1,85 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goCupsServer"); + var $attributes = array(); + var $StatusFlag = "goCupsServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goCupsServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $acl; + var $cn = ""; + var $goCupsServerStatus = ""; + var $view_logged =FALSE; + + function goCupsServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("Print service"); + } + + + function execute() + { + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goCupsServer.tpl",TRUE,dirname(__FILE__)))); + } + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Print service"); + $fields['AllowEdit'] = false; + return($fields); + } + + function check() + { + $message = plugin::check(); + return($message); + } + + function save_object() + { + plugin::save_object(); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Cups"), + "plDescription" => _("Print service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 100, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + + "plProvidedAcls"=> array() + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/cups/goCupsServer.tpl b/gosa-core/plugins/admin/systems/services/cups/goCupsServer.tpl new file mode 100644 index 000000000..e10bd2f67 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/cups/goCupsServer.tpl @@ -0,0 +1,9 @@ +

{t}Print Service{/t} {t}enabled{/t}

+ +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc new file mode 100644 index 000000000..43f583152 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc @@ -0,0 +1,146 @@ +is_account= TRUE; + $this->setAutoStatements(); + $this->setAutoOptions(); + } + + function execute() + { + /* Check for interaction */ + if (isset($_POST['add_statement']) && $_POST['addstatement'] != ""){ + $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addstatement')); + $val= preg_replace("/^$key\s*/", '', get_post('addstatement')); + $this->statements[$key]= $val; + } + if (isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){ + $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpstatements')); + if (in_array($key, $this->autoStatements)){ + print_red(_("Can't delete automatic statements. Please use the fields above.")); + } else { + unset($this->statements[$key]); + } + } + if (isset($_POST['add_option']) && $_POST['addoption'] != ""){ + $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addoption')); + $val= preg_replace("/^$key\s*/", '', get_post('addoption')); + $this->options[$key]= $val; + } + if (isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){ + $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpoptions')); + if (in_array($key, $this->autoOptions)){ + print_red(_("Can't delete automatic options. Please use the fields above.")); + } else { + unset($this->options[$key]); + } + } + + $smarty= get_smarty(); + + /* Assign arrays */ + $statements= array(); + foreach ($this->statements as $key => $val){ + if (in_array($key, $this->autoStatements)){ + $statements[$key]= "$key $val ["._("automatic")."]"; + } else { + $statements[$key]= "$key $val"; + } + } + $smarty->assign("dhcpstatements", $statements); + $options= array(); + foreach ($this->options as $key => $val){ + if (in_array($key, $this->autoOptions)){ + $options[$key]= "$key $val ["._("automatic")."]"; + } else { + $options[$key]= "$key $val"; + } + } + $smarty->assign("dhcpoptions", $options); + + /* Show main page */ + $smarty->assign("show_advanced", $this->show_advanced); + return ($smarty->fetch (get_template_path('dhcp_advanced.tpl', TRUE,dirname(__FILE__)))); + } + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['show_advanced'])){ + $this->show_advanced= TRUE; + } + if (isset($_POST['hide_advanced'])){ + $this->show_advanced= FALSE; + } + } + + + /* Check values */ + function check() + { + /* Nothing to check here */ + $message= array(); + return $message; + } + + + /* Save to LDAP */ + function save() + { + } + + + function setAutoOptions($addopt= array()) + { + $options= array("routers", "domain-name", "domain-name-servers", "subnet-mask", "broadcast-address"); + $this->autoOptions= array_merge($options, $addopt); + } + + + function setAutoStatements($addstat= array()) + { + $statements= array("filename", "next-server", "get-lease-hostnames", "use-host-decl-names"); + $this->autoStatements= array_merge($statements, $addstat); + } + +} + +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc new file mode 100644 index 000000000..cbe987da8 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc @@ -0,0 +1,126 @@ +assign("cn", $this->cn); + + /* Show main page */ + $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE)).$this->network->execute(); + + /* Merge arrays for advanced view */ + $this->fix_options(); + foreach (array("options", "statements") as $type){ + $this->advanced->$type= $this->$type + $this->network->$type; + } + + $display.= $this->advanced->execute(); + + /* Merge back for removals */ + foreach (array("options", "statements") as $type){ + $this->$type= $this->advanced->$type; + $this->network->$type= $this->advanced->$type; + } + + /* Add footer */ + $display.= "
". + " 
"; + + + return ($display); + } + + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + /* Save cn */ + if (isset($_POST['cn'])){ + $this->cn= validate(get_post('cn')); + } + + /* Handle global saving */ + dhcpPlugin::save_object(); + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = $this->parent->dhcpObjectCache; + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= _("Required field 'Name' is not filled."); + } + if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){ + $message[]= _("Field 'Name' contains illegal characters."); + } + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= _("The name for this host section is already used!"); + break; + } + } + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + return ($this->attrs); + } + + +} + +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpHost.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpHost.inc new file mode 100644 index 000000000..e8aab5c95 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpHost.inc @@ -0,0 +1,181 @@ +new){ + $this->dhcpHWAddress= $attrs['dhcpHWAddress'][0]; + } + + $this->advanced->setAutoOptions(array("host-name")); + $this->advanced->setAutoStatements(array("fixed-address")); + + $this->realGosaHost = $host_exists_in_gosa; + } + + function execute() + { + $smarty= get_smarty(); + $smarty->assign("cn", $this->cn); + $smarty->assign("dhcpHWAddress", preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress)); + $smarty->assign("realGosaHost",$this->realGosaHost); + + /* Create fixed address */ + if (isset($this->statements['fixed-address'])){ + $smarty->assign("fixedaddr", $this->statements['fixed-address']); + } else { + $smarty->assign("fixedaddr", ""); + } + + /* Prepare hw type selector */ + $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress); + $smarty->assign("hwtype", $hwtype); + $smarty->assign("hwtypes", array("ethernet" => _("Ethernet"), + "fddi" => _("FDDI"), + "token-ring" => _("Token Ring"))); + /* Show main page */ + $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute(); + + /* Merge arrays for advanced view */ + $this->fix_options(); + foreach (array("options", "statements") as $type){ + $this->advanced->$type= $this->$type + $this->network->$type; + } + $display.= $this->advanced->execute(); + + /* Merge back for removals */ + foreach (array("options", "statements") as $type){ + $this->$type= $this->advanced->$type; + $this->network->$type= $this->advanced->$type; + } + + /* Add footer */ + $display.= "
". + " 
"; + + + return ($display); + } + + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + /* Save remaining attributes */ + if (isset($_POST['dhcp_host_posted'])){ + + /* Assemble hwAddress */ + if (isset($_POST['dhcpHWAddress'])){ + $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress'); + } + + if(!$this->realGosaHost){ + $this->cn= validate(get_post('cn')); + } + + /* Save fixed address */ + if(!$this->realGosaHost){ + if ($_POST['fixedaddr'] != ""){ + $this->statements['fixed-address']= get_post('fixedaddr'); + } else { + unset ($this->statements['fixed-address']); + } + } + $this->options['host-name']= $this->cn; + } + + dhcpPlugin::save_object(); + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = array(); + if(isset($this->parent)){ + $cache = $this->parent->dhcpObjectCache; + } + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= _("Required field 'Name' is not filled."); + } + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= _("The name for this host section is already used!"); + break; + } + } + } + + /* Check syntax of MAC address */ + $check= preg_replace('/^[^\s]*\s/', '', $this->dhcpHWAddress); + if (!preg_match('/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/', $check)){ + $message[]= _("The hardware address specified by you is not valid!"); + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + if ($this->dhcpHWAddress != ""){ + $this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress); + } else { + $this->attrs['dhcpHWAddress']= array(); + } + + return ($this->attrs); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc new file mode 100644 index 000000000..1c3ced065 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc @@ -0,0 +1,226 @@ +is_account= TRUE; + } + + function execute() + { + /* Check for iteraction */ + if (isset($_POST['add_dns']) && $_POST['addserver'] != ""){ + if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){ + print_red(_("The name of the DNS server your're going to add is not valid!")); + } else { + $servers= array(); + if (isset($this->options['domain-name-servers'])){ + foreach(split(",", $this->options['domain-name-servers']) as $val){ + $servers[$val]= $val; + } + } + $servers[get_post('addserver')]= get_post('addserver'); + + $tmp= ""; + foreach($servers as $val){ + $tmp.= $val.","; + } + $this->options['domain-name-servers']= preg_replace('/,$/', '', $tmp); + } + } + if (isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){ + $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '', + $this->options['domain-name-servers']); + $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp); + if ($tmp != ""){ + $this->options['domain-name-servers']= $tmp; + } else { + unset($this->options['domain-name-servers']); + } + } + + /* Show main page */ + $smarty= get_smarty(); + + /* + * Assemble options + */ + + /* Router */ + if (isset($this->options['routers'])){ + $smarty->assign("routers", $this->options['routers']); + } else { + $smarty->assign("routers", ""); + } + + /* DNS */ + if (isset($this->options['domain-name'])){ + $smarty->assign("domain", trim($this->options['domain-name'], '"')); + } else { + $smarty->assign("domain", ""); + } + if (isset($this->options['domain-name-servers'])){ + $servers= array(); + foreach(split(",", $this->options['domain-name-servers']) as $val){ + $servers[$val]= $val; + } + $smarty->assign("dnsservers", $servers); + } else { + $smarty->assign("dnsservers", ""); + } + + /* Netmask / Broadcast */ + if (isset($this->options['subnet-mask'])){ + $this->options['subnet-mask']= normalize_netmask($this->options['subnet-mask']); + $smarty->assign("subnet_mask", $this->options['subnet-mask']); + } else { + $smarty->assign("subnet_mask", ""); + } + if (isset($this->options['broadcast-address'])){ + $smarty->assign("broadcast_address", $this->options['broadcast-address']); + } else { + $smarty->assign("broadcast_address", ""); + } + + /* Boot stuff */ + if (isset($this->statements['filename'])){ + $smarty->assign("filename", trim($this->statements['filename'], '"')); + } else { + $smarty->assign("filename", ""); + } + if (isset($this->statements['next-server'])){ + $smarty->assign("nextserver", $this->statements['next-server']); + } else { + $smarty->assign("nextserver", ""); + } + + /* Set flags */ + $smarty->assign("autohost", ""); + if (isset($this->statements['get-lease-hostnames'])){ + if (preg_match('/^(true|on|yes)$/', $this->statements['get-lease-hostnames'])){ + $smarty->assign("autohost", "checked"); + } + } + $smarty->assign("autohostdecl", ""); + if (isset($this->statements['use-host-decl-names'])){ + if (preg_match('/^(true|on|yes)$/', $this->statements['use-host-decl-names'])){ + $smarty->assign("autohostdecl", "checked"); + } + } + + return $smarty->fetch(get_template_path('dhcp_network.tpl', TRUE,dirname(__FILE__))); + } + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + /* Only save, if we are "active" */ + if (isset($_POST['routers'])){ + + /* + * Assemble options + */ + + /* Options */ + foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask", + "broadcast-address" => "broadcast_address") as $key => $val){ + + if ($_POST["$val"] == ''){ + unset($this->options["$key"]); + } else { + $this->options["$key"]= get_post("$val"); + } + } + + /* Statements */ + foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){ + if ($_POST["$val"] == ''){ + unset($this->statements["$key"]); + } else { + + /* Only quote filename values */ + if(in_array($key,array("filename"))){ + $this->statements["$key"]= '"'.get_post("$val").'"'; + }else{ + $this->statements["$key"]= get_post("$val"); + } + } + } + + /* Flags */ + if (isset ($_POST['autohost'])){ + $this->statements['get-lease-hostnames']= "true"; + } else { + unset($this->statements['get-lease-hostnames']); + } + if (isset ($_POST['autohostdecl'])){ + $this->statements['use-host-decl-names']= "on"; + } else { + unset($this->statements['use-host-decl-names']); + } + } + } + + + /* Check values */ + function check() + { + $message= array(); + + /* Check netmask and broadcast */ + foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){ + if (!isset($this->options["$key"])){ + continue; + } + $tmp= preg_replace('/^[^\s]+\s/', '', $this->options["$key"]); + + if (!is_ip($tmp)){ + $message[]= sprintf(_("Error in definition of '%s'!"), $typ); + } + } + + return $message; + } + + + /* Save to LDAP */ + function save() + { + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc new file mode 100644 index 000000000..756a97893 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc @@ -0,0 +1,80 @@ + array("dhcpSharedNetwork", "dhcpSubnet", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/), + #"dhcpClass" => array("dhcpSubClass"), + "dhcpSubClass" => array(), + "dhcpHost" => array(), + "dhcpGroup" => array("dhcpHost"), + "dhcpPool" => array(), + "dhcpSubnet" => array("dhcpPool", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/), + "dhcpSharedNetwork" => array("dhcpSubnet", "dhcpPool")); + + + + function dhcpNewSectionDialog($type) + { + $this->types= array( "dhcpService" => _("Global options"), + /*"dhcpClass" => _("Class"),*/ + "dhcpSubClass" => _("Subclass"), + "dhcpHost" => _("Host"), + "dhcpGroup" => _("Group"), + "dhcpPool" => _("Pool"), + "dhcpSubnet" => _("Subnet"), + "dhcpSharedNetwork" => _("Shared network")); + + $this->classtype= $type; + } + + function execute() + { + /* Fill templating stuff */ + $smarty = get_smarty(); + $display= ""; + + $sections= $this->sectionMap[$this->classtype]; + $t_sections= array(); + foreach ($sections as $section){ + $t_sections[$section]= $this->types[$section]; + } + asort($t_sections); + $ui = get_userinfo(); + $smarty->assign("sections", $t_sections); + $display.= $smarty->fetch(get_template_path('dhcpNewSection.tpl', TRUE)); + return($display); + } + + /* Get posts and set class name + */ + function save_object() + { + } + + /* Check given class name */ + function check() + { + /* Call common method to give check the hook */ + $message= ""; + + return ($message); + } + + + /* Return the class name */ + function save() + { + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc new file mode 100644 index 000000000..9e9821e8a --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpPool.inc @@ -0,0 +1,191 @@ +new){ + $this->dhcpRange= $attrs['dhcpRange'][0]; + list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange); + } + + $this->advanced->setAutoOptions(array("host-name")); + $this->advanced->setAutoStatements(array("fixed-address")); + } + + function execute() + { + $smarty= get_smarty(); + $smarty->assign("cn", $this->cn); + $smarty->assign("range_start", $this->range_start); + $smarty->assign("range_stop", $this->range_stop); + + /* Show main page */ + $display= $smarty->fetch(get_template_path('dhcp_pool.tpl', TRUE)).$this->network->execute(); + + /* Merge arrays for advanced view */ + $this->fix_options(); + foreach (array("options", "statements") as $type){ + $this->advanced->$type= $this->$type + $this->network->$type;; + } + + $display.= $this->advanced->execute(); + + /* Merge back for removals */ + foreach (array("options", "statements") as $type){ + $this->$type= $this->advanced->$type; + $this->network->$type= $this->advanced->$type; + } + + /* Add footer */ + $display.= "
". + " 
"; + + return ($display); + } + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['cn'])){ + $this->cn= validate(get_post('cn')); + $this->range_start= validate(get_post('range_start')); + $this->range_stop= validate(get_post('range_stop')); + } + + dhcpPlugin::save_object(); + + /* Move range to internal variable */ + $this->dhcpRange= $this->range_start." ".$this->range_stop; + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = $this->parent->dhcpObjectCache; + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= _("Required field 'Name' is not filled."); + } + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= _("The name for this section is already used!"); + break; + } + } + } + + if ($this->dhcpRange == ""){ + $message[]= _("Required field 'Range' is not filled."); + } + + if (!is_ip($this->range_start) || !is_ip($this->range_stop)){ + $message[]= _("Field 'Range' contains invalid IP addresses."); + } + + if(!is_ip_range($this->range_start,$this->range_stop)){ + $message[] = _("Field 'Range' contains invalid IP range."); + } + + /* Check if range is in the network */ + $dn= $this->dn; + while (preg_match('/,/', $dn)){ + $type= $this->objectType($cache, $dn); + + /* Check for subnet */ + if ($type == 'dhcpSubnet'){ + $network= $cache[$dn]['cn'][0]; + $netmask= normalize_netmask($cache[$dn]['dhcpNetMask'][0]); + if (!is_in_network($network, $netmask, $this->range_start) || + !is_in_network($network, $netmask, $this->range_stop)){ + $message[] = _("'Range' is not inside the configured network."); + } + } + + /* Stop if we've examined the service base object */ + if ($type == 'dhcpService'){ + break; + } + $dn= preg_replace('/^[^,]+,/', '', $dn); + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + $this->attrs['dhcpRange']= array($this->dhcpRange); + + return ($this->attrs); + } + + + function objectType($cache, $dn) + { + $type= ""; + $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost", + "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork"); + + foreach ($cache[$dn]['objectClass'] as $oc){ + if (in_array($oc, $types)){ + $type= $oc; + break; + } + } + + return ($type); + } + + +} + +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc new file mode 100644 index 000000000..57f76cc9e --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpService.inc @@ -0,0 +1,181 @@ +new){ + /* Load attributes */ + $this->dhcpPrimaryDN= $attrs['dhcpPrimaryDN'][0]; + } else { + /* We keep the parent dn here if it's new */ + $this->statements['default-lease-time']= 600; + $this->statements['max-lease-time']= 1700; + $this->statements['authoritative']= TRUE; + $this->statements['ddns-update-style']= 'none'; + } + + $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-identifier", "ddns-update-style")); + $this->advanced->setAutoOptions(array("server-name")); + + /* Save for later action */ + $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN; + } + + + function execute() + { + /* Show main page */ + $smarty= get_smarty(); + + $smarty->assign('ddns_styles', $this->ddns_styles); + foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $value){ + if (isset($this->statements[preg_replace('/_/', '-', $value)])){ + $smarty->assign("$value", $this->statements[preg_replace('/_/', '-', $value)]); + } else { + $smarty->assign("$value", ""); + } + } + + if (isset($this->statements['authoritative'])){ + $smarty->assign("authoritative", "checked"); + } else { + $smarty->assign("authoritative", ""); + } + + /* Show main page */ + $display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE)).$this->network->execute(); + + /* Merge arrays for advanced view */ + $this->fix_options(); + foreach (array("options", "statements") as $type){ + $this->advanced->$type= $this->$type + $this->network->$type;; + } + + $display.= $this->advanced->execute(); + + /* Merge back for removals */ + foreach (array("options", "statements") as $type){ + $this->$type= $this->advanced->$type; + $this->network->$type= $this->advanced->$type; + } + + /* Add footer */ + $display.= "
". + " 
"; + + + return ($display); + + } + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + /* No need to save in the first time */ + if (!isset($_POST['ddns_update_style'])){ + return; + } + + /* Save remaining attributes */ + foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){ + $tval= preg_replace('/_/', '-', $val); + if ($_POST[$val] != ""){ + $this->statements[$tval]= validate(get_post($val)); + } else { + unset ($this->statements[$tval]); + } + } + if (isset($_POST['authoritative'])){ + $this->statements['authoritative']= ""; + } else { + unset($this->statements['authoritative']); + } + + dhcpPlugin::save_object(); + } + + + /* Check values */ + function check() + { + $message= array(); + + if (!is_id($this->statements['default-lease-time'])){ + $message[]= _('Default lease time needs to be numeric.'); + } + if (!is_id($this->statements['max-lease-time'])){ + $message[]= _('Maximum lease time needs to be numeric.'); + } + if ($this->statements['default-lease-time'] > $this->statements['max-lease-time']){ + $message[]= _('Default lease time needs to smaller than the maximum lease time.'); + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + global $config; + $this->attrs= array(); + + /* Get and set server name */ + $ldap= $config->get_ldap_link(); + $ldap->cat($this->dhcpPrimaryDN, array('cn')); + $res= $ldap->fetch(); + $server_name= $res['cn'][0]; + + dhcpPlugin::save(); + + $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN); + $this->removeOption('server-name'); +# $this->attrs['dhcpOption'][]= "server-name $server_name"; + + return ($this->attrs); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc new file mode 100644 index 000000000..6e55b75d6 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc @@ -0,0 +1,188 @@ +advanced->setAutoStatements(array("server-identifier", "default-lease-time", + "max-lease-time", "min-lease-time", "authoritative", "deny-unknown-clients", + "deny-bootp", "deny-booting")); + } + + + function execute() + { + $smarty= get_smarty(); + + /* Fill template */ + $smarty->assign ("cn", $this->cn); + foreach (array("server-identifier", "default-lease-time", "max-lease-time", "min-lease-time") as $attr){ + if (isset($this->statements[$attr])){ + $smarty->assign(preg_replace('/-/', '_', $attr), $this->statements[$attr]); + } else { + $smarty->assign(preg_replace('/-/', '_', $attr), ""); + } + } + if (isset($this->statements["authoritative"])){ + $smarty->assign("authoritative", "checked"); + } else { + $smarty->assign("authoritative", ""); + } + if (!isset($this->statements["deny unknown-clients"])){ + $smarty->assign("allow_unknown_state", "checked"); + } else { + $smarty->assign("allow_unknown_state", ""); + } + if (!isset($this->statements["deny bootp"])){ + $smarty->assign("allow_bootp_state", "checked"); + } else { + $smarty->assign("allow_bootp_state", ""); + } + if (!isset($this->statements["deny booting"])){ + $smarty->assign("allow_booting_state", "checked"); + } else { + $smarty->assign("allow_booting_state", ""); + } + + /* Show main page */ + $display= $smarty->fetch(get_template_path('dhcp_sharedNetwork.tpl', TRUE)).$this->network->execute(); + + /* Merge arrays for advanced view */ + $this->fix_options(); + foreach (array("options", "statements") as $type){ + $this->advanced->$type= $this->$type + $this->network->$type; + } + + $display.= $this->advanced->execute(); + + /* Merge back for removals */ + foreach (array("options", "statements") as $type){ + $this->$type= $this->advanced->$type; + $this->network->$type= $this->advanced->$type; + } + + /* Add footer */ + $display.= "
". + " 
"; + + + return ($display); + } + + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['cn'])){ + $this->cn= validate(get_post('cn')); + dhcpPlugin::save_object(); + + foreach (array("server-identifier", "default-lease-time", + "max-lease-time", "min-lease-time") as $attr){ + if (isset($_POST[$attr]) && $_POST[$attr] != ""){ + $this->statements[$attr]= get_post($attr); + } else { + unset($this->statements[$attr]); + } + } + + if (isset($_POST["authoritative"])){ + $this->statements["authoritative"]= ""; + } else { + unset ($this->statements["authoritative"]); + } + + foreach(array("unknown-clients", "bootp", "booting") as $name){ + if (isset($_POST[$name])){ + $this->statements["allow $name"]= ""; + unset($this->statements["deny $name"]); + } else { + $this->statements["deny $name"]= ""; + unset($this->statements["allow $name"]); + } + } + } + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = $this->parent->dhcpObjectCache; + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= _("Required field 'Name' is not filled."); + } + + /* Check lease times */ + foreach (array("default-lease-time" => _("Default lease time"), + "max-lease-time" => _("Max. lease time"), + "min-lease-time" => _("Min. lease time")) as $key => $val){ + if (isset($this->statements[$key]) && $this->statements[$key] != "" && + !is_id($this->statements[$key])){ + $message[]= sprintf(_("The value specified as '%s' is not numeric!"), $val); + } + } + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= _("The name for this host section is already used!"); + break; + } + } + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + + return ($this->attrs); + } + +} + +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc new file mode 100644 index 000000000..8c2da41de --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc @@ -0,0 +1,200 @@ +new){ + /* Load attributes */ + foreach (array("dhcpNetMask", "dhcpRange") as $attr){ + if (isset($attrs[$attr][0])){ + $this->$attr= $attrs[$attr][0]; + } + } + if (isset($attrs['dhcpRange']) && count($attrs['dhcpRange'])){ + $this->use_range= TRUE; + list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange); + } + } + + $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask); + } + + + function execute() + { + $smarty= get_smarty(); + $smarty->assign("cn", $this->cn); + $smarty->assign("dhcp_netmask", $this->dhcpNetMask); + + /* Prepare range */ + if ($this->use_range){ + $smarty->assign("use_range", "checked"); + $smarty->assign("range_disabled", ""); + } else { + $smarty->assign("use_range", ""); + $smarty->assign("range_disabled", "disabled"); + } + $smarty->assign("range_start", $this->range_start); + $smarty->assign("range_stop", $this->range_stop); + + /* Show main page */ + $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE)).$this->network->execute(); + + /* Merge arrays for advanced view */ + $this->fix_options(); + foreach (array("options", "statements") as $type){ + $this->advanced->$type= $this->$type + $this->network->$type; + } + + $display.= $this->advanced->execute(); + + /* Merge back for removals */ + foreach (array("options", "statements") as $type){ + $this->$type= $this->advanced->$type; + $this->network->$type= $this->advanced->$type; + } + + /* Add footer */ + $display.= "
". + " 
"; + + /* Show main page */ + return $display; + } + + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + if(isset($_POST['dhcp_subnet_posted'])){ + if (isset($_POST['cn'])){ + $this->cn= validate(get_post('cn')); + } + if (isset($_POST['dhcp_netmask'])){ + $this->dhcpNetMask= validate(get_post('dhcp_netmask')); + } + if (isset($_POST['use_range'])){ + $this->use_range= TRUE; + $this->range_start= validate(get_post('range_start')); + $this->range_stop= validate(get_post('range_stop')); + } else { + $this->use_range= FALSE; + } + + /* Move range to internal variable */ + $this->dhcpRange= $this->range_start." ".$this->range_stop; + dhcpPlugin::save_object(); + } + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = $this->parent->dhcpObjectCache; + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= _("Required field 'Network address' is not filled."); + } + if ($this->dhcpNetMask == ""){ + $message[]= _("Required field 'Netmask' is not filled."); + } + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= _("The name for this section is already used!"); + break; + } + } + } + + /* IP's? */ + foreach(array('dhcpNetMask' => _("Netmask"), 'cn' => _("Network address"), 'range_start' => _("Range"), 'range_stop' => _("Range")) as $attr => $str){ + if ($this->$attr != "" && !is_ip($this->$attr)){ + $message[]= sprintf(_("The field '%s' contains an invalid IP address"), $str); + } + } + + /* Check ip range */ + if ($this->use_range){ + if(!is_ip_range($this->range_start,$this->range_stop)){ + $message[] = _("Field 'Range' contains invalid IP range."); + } + + /* Check if range is in the network */ + if (!is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) || + !is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){ + $message[] = _("'Range' is not inside the configured network."); + } + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + + /* Move dn to the result */ + $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask)); + if ($this->use_range && !empty($this->dhcpRange)){ + $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop); + } else { + $this->attrs['dhcpRange']= array(); + } + + return ($this->attrs); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/class_servDHCP.inc b/gosa-core/plugins/admin/systems/services/dhcp/class_servDHCP.inc new file mode 100644 index 000000000..c804ec2bc --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/class_servDHCP.inc @@ -0,0 +1,739 @@ + array(),"FOR_LIST"=> array()); + var $take_over_id = -1; + var $display_warning = TRUE; + + function servdhcp (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $this->serviceDN = "cn=dhcp,".$dn; + $this->orig_dn = $dn; + + $this->DisplayName = _("DHCP service"); + + $this->types= array( "dhcpLog" => _("Logging"), + "dhcpService" => _("Global options"), + "dhcpClass" => _("Class"), + "dhcpSubClass" => _("Subclass"), + "dhcpHost" => _("Host"), + "dhcpGroup" => _("Group"), + "dhcpPool" => _("Pool"), + "dhcpSubnet" => _("Subnet"), + "dhcpFailOverPeer" => _("Failover peer"), + "dhcpSharedNetwork" => _("Shared network")); + + + /* Backport: PHP4 compatibility */ + foreach($this->types as $type => $translation){ + $this->types[strtolower($type)] = $translation; + } + + /* Load information about available services */ + $this->reload(); + if (!count($this->dhcpSections)){ + $this->is_account= FALSE; + $this->dhcp_server_list = $this->get_list_of_dhcp_servers(); + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $smarty->assign("dns_take_over",FALSE); + $display= ""; + + + /*****************/ + /* Handle Take Over Actions + /*****************/ + + /* Give smarty the required informations */ + $smarty->assign("dhcp_server_list", $this->dhcp_server_list['FOR_LIST']); + $smarty->assign("dhcp_server_list_cnt", count($this->dhcp_server_list['FOR_LIST'])); + + /* Take over requested, save id */ + if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){ + $id = $_POST['take_over_src']; + if(isset($this->dhcp_server_list['ENTRIES'][$id])){ + $this->take_over_id = $id; + } + } + + /* Abort take over action */ + if(isset($_POST['cancel_take_over'])){ + $this->dialog =false; + $this->take_over_id = -1; + $this->dhcp_server_list = $this->get_list_of_dhcp_servers(); + } + + /* Display informartion about take over that will be started when saving this server + * and hide default dhcp output + */ + if($this->take_over_id != -1){ + + $this->dialog = FALSE; + $id = $this->take_over_id; + $smarty->assign("dns_take_over",TRUE); + $warning = sprintf(_("You are going to migrate the DHCP setup from server '%s'."), + $this->dhcp_server_list['ENTRIES'][$id]['cn'][0]); + $warning.= " "._("The migration will be started when you save this system. To cancel this action, use the cancel button below."); + + if($this->display_warning){ + print_red($warning); + $this->display_warning = FALSE; + } + return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE))); + } + + + /*****************/ + /* List handling + /*****************/ + + /* Section Creation? */ + if (isset($_POST['create_section']) && isset($_POST['section'])){ + $section= $_POST['section']; + $tmp = new dhcpNewSectionDialog(NULL); + if (isset($tmp->sectionMap[$section])){ + $this->dialog= new $section($this->current_object); + $this->current_object= ""; + } else { + $this->dialog= FALSE; + } + } + + /* Cancel section creation? */ + if (isset($_POST['cancel_section']) || isset($_POST['cancel_dhcp'])){ + $this->dialog= FALSE; + } + + /* Save changes */ + if (isset($_POST['save_dhcp'])){ + $this->dialog->save_object(); + $messages= $this->dialog->check(); + if (count($messages)){ + show_errors($messages); + } else { + $dn= $this->dialog->dn; + $class= get_class($this->dialog); + $type= $this->types[$class]; + if(empty($this->serviceDN)){ + $indent= substr_count(preg_replace("/".$this->dn."/", '', $dn), ",") -1; + }else{ + $indent= substr_count(preg_replace("/".$this->serviceDN."/", '', $dn), ","); + } + $spaces= ""; + for ($i= 0; $i<$indent; $i++){ + $spaces.= "    "; + } + $data= $this->dialog->save(); + if ($this->current_object == ""){ + /* New object */ + $newsects= array(); + foreach ($this->dhcpSections as $key => $dsc){ + $newsects[$key]= $dsc; + if ($key == $dn){ + $spaces.= "    "; + $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'"; + } + } + $this->dhcpObjectCache[$data['dn']]= $data; + $this->dhcpSections= $newsects; + } else { + if ($dn != $data['dn']){ + /* Old object, new name */ + $this->dhcpObjectCache[$dn]= array(); + $this->dhcpObjectCache[$data['dn']]= $data; + + /* If we renamed a section, we've to rename a couple of objects, too */ + foreach ($this->dhcpObjectCache as $key => $dsc){ + if (preg_match("/,$dn$/", $key)){ + $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key); + $dsc['MODIFIED']= TRUE; + $this->dhcpObjectCache[$new_dn]= $dsc; + unset($this->dhcpObjectCache[$key]); + } + } + $newsects= array(); + foreach ($this->dhcpSections as $key => $dsc){ + if ($key == $dn){ + $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'"; + continue; + } + if (preg_match("/,$dn$/", $key)){ + $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key); + $newsects[$new_dn]= $dsc; + } else { + $newsects[$key]= $dsc; + } + } + $this->dhcpSections= $newsects; + + } else { + /* Old object, old name */ + $this->dhcpObjectCache[$data['dn']]= $data; + } + } + $this->dialog= FALSE; + } + } + + /* Remove section? */ + if (isset($_POST['delete_dhcp_confirm'])){ + if ($this->acl_is_removeable()){ + unset($this->dhcpSections[$this->current_object]); + unset($this->dhcpObjectCache[$this->current_object]); + $this->dhcpObjectCache[$this->current_object]= array(); + foreach ($this->dhcpSections as $key => $value){ + if (preg_match("/".$this->current_object."$/", $key)){ + unset($this->dhcpSections[$key]); + unset($this->dhcpObjectCache[$key]); + $this->dhcpObjectCache[$key]= array(); + } + } + } else { + print_red(_("You're not allowed to remove DHCP sections!")); + } + $this->dialog= FALSE; + } + + /* Look for post entries */ + foreach($_POST as $name => $value){ + + /* Insert new section? */ + if (preg_match('/^insertDhcp_.*_x$/', $name)){ + $dn= base64_decode(preg_replace('/^insertDhcp_([^_]+)_x$/', '\1', $name)); + if (isset($this->dhcpObjectCache[$dn])){ + $this->dialog= new dhcpNewSectionDialog($this->objectType($dn)); + $this->current_object= $dn; + $this->dialog->acl= $this->acl; + } + } + + /* Edit section? */ + if (preg_match('/^editDhcp_.*_x$/', $name)){ + $dn= base64_decode(preg_replace('/^editDhcp_([^_]+)_x$/', '\1', $name)); + if (isset($this->dhcpObjectCache[$dn])){ + $section= $this->objectType($dn); + $this->current_object= $dn; + $this->dialog= new $section($this->dhcpObjectCache[$dn]); + } + } + + /* Remove section? */ + if (preg_match('/^delDhcp_.*_x$/', $name)){ + $dn= base64_decode(preg_replace('/^delDhcp_([^_]+)_x$/', '\1', $name)); + if (isset($this->dhcpObjectCache[$dn])){ + $this->current_object= $dn; + $this->dialog= 1; + $smarty->assign("warning", sprintf(_("You're about to delete the DHCP section '%s'."), $dn)); + return($smarty->fetch(get_template_path('remove_dhcp.tpl', TRUE))); + } + } + + } + + if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){ + $dn = base64_decode($_GET['id']); + if (isset($this->dhcpObjectCache[$dn])){ + $section= $this->objectType($dn); + $this->current_object= $dn; + $this->dialog= new $section($this->dhcpObjectCache[$dn]); + } + } + + + if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){ + $dn = base64_decode($_GET['id']); + if (isset($this->dhcpObjectCache[$dn])){ + $section= $this->objectType($dn); + $this->current_object= $dn; + $this->dialog= new $section($this->dhcpObjectCache[$dn]); + } + } + + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Show tab dialog headers */ + if ($this->is_account){ +# $display= $this->show_header(_("Remove DHCP service"), +# _("This server has DHCP features enabled. You can disable them by clicking below.")); + + if (!count($this->dhcpObjectCache)){ + $attrs= array(); + $attrs['dn']= 'cn=dhcp,'.$this->dn; + $attrs['cn']= array('dhcp'); + $attrs['objectClass']= array('top', 'dhcpService'); + $attrs['dhcpPrimaryDN']= array($this->dn); + $attrs['dhcpStatements']= array("default-lease-time 600", + "max-lease-time 1200", + "authoritative", + "ddns-update-style none"); + $attrs['MODIFIED']= TRUE; + $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options"); + $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs; + } + + } else { +# $display= $this->show_header(_("Add DHCP service"), + +# _("This server has DHCP features disabled. You can enable them by clicking below.")); + return ($display); + } + + + /* Show dialog + */ + if(isset($this->dialog) && is_object($this->dialog)){ + $this->dialog->save_object(); + $this->dialog->parent = $this; + return($this->dialog->execute()); + } + + /* Create Listbox with existing Zones + */ + $DhcpList = new divSelectBox("dhcpSections"); + $DhcpList->SetHeight(400); + + /* Add entries to divlist + */ + $editImgIns = "". + "". + ""; + $editImgInsNoDel = "". + ""; + $editImg = "". + ""; + + $tmp = new dhcpNewSectionDialog(NULL); + foreach($this->dhcpSections as $section => $values ){ + + $values = "".$values.""; + + if (count($tmp->sectionMap[$this->objectType($section)])){ + if ($this->objectType($section) == "dhcpService"){ + $DhcpList->AddEntry(array( + array("string" => $values), + array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'") + )); + } else { + $DhcpList->AddEntry(array( + array("string" => $values), + array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'") + )); + } + } else { + $DhcpList->AddEntry(array( + array("string" => $values), + array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'") + )); + } + } + + /* Display tempalte */ + $smarty->assign("DhcpList",$DhcpList->DrawList()); + $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE)); + return($display); + } + + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + /* Remove subtrees */ + $ldap= $this->config->get_ldap_link(); + foreach ($this->dhcpObjectCache as $dn => $content){ + if ($this->objectType($dn) == 'dhcpService'){ + $ldap->rmdir_recursive($dn); + show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed")); + } + } + + /* Remove from self */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed")); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove"); + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* Take over handling + * - Load servdhcp class and dhcpObjectCache for the source dhcp setup. + * - Assign dhcpObjectCache to this configuration. + * - Save this setup and remove source setup from ldap. + */ + if($this->take_over_id != -1){ + $id = $this->take_over_id; + $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']); + $tmp = new servdhcp ($this->config, $src); + $this->orig_dn = $src; + $this->dhcpObjectCache = $tmp->dhcpObjectCache; + } + + /* Save dhcp setttings */ + $ldap= $this->config->get_ldap_link(); + foreach ($this->dhcpObjectCache as $dn => $data){ + + if($this->dn != $this->orig_dn){ + $dn = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$dn); + } + + /* Remove entry? */ + if (count($data) == 0){ + /* Check if exists, then remove... */ + if($ldap->cat($dn)){ + $ldap->rmdir_recursive($dn); + show_ldap_error($ldap->get_error(), _("Can't remove DHCP object!")); + } + continue; + } + + /* Opdate dhcp option 'server-name' to actual server name */ + if($this->dn != $this->orig_dn){ + $fixed = FALSE; + foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){ + if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){ + foreach($data['dhcpOption'] as $key => $option){ + if(preg_match("/^server-name /",$option)){ + $data['dhcpOption'][$key] = "server-name ".$this->cn; + $data['MODIFIED'] = TRUE; + break; + } + } + } + + /* Skip next loops if entry is updated */ + if($fixed){ + break; + } + } + } + + /* Modify existing entry? */ + if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){ + + if($ldap->cat($dn)){ + $modify= TRUE; + } else { + $modify= FALSE; + } + + /* Build new entry */ + $attrs= array(); + foreach ($data as $attribute => $values){ + if ($attribute == "MODIFIED" || $attribute == "dn"){ + continue; + } + + if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){ + foreach($values as $v_key => $value){ + $values[$v_key] = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$value); + } + } + + if (count($values)){ + + if($attribute == "dhcpOption"){ + foreach($values as $key => $value){ + $option_name = trim(preg_replace("/[^ ]*$/","",$value)); + $option_value= trim(preg_replace("/^[^ ]*/","",$value)); + if(in_array($option_name,$this->quote_option)){ + $values[$key] = $option_name." \"".$option_value."\""; + } + } + } + if (count($values) == 1){ + $attrs[$attribute]= $values[0]; + } else { + $attrs[$attribute]= $values; + } + } else { + if ($modify){ + $attrs[$attribute]= array(); + } + } + } + + $ldap->cd($dn); + if ($modify){ + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(), _("Can't save DHCP object!")); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("modify"); + } else { + $ldap->add($attrs); + show_ldap_error($ldap->get_error(), _("Can't save DHCP object!")); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("create"); + } + } + } + + $this->dhcpServiceDN= $this->serviceDN; + if($this->dn != $this->orig_dn){ + $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN); + } + + /* Replace 'new' dn */ + if(preg_match("/new$/",$this->dhcpServiceDN)){ + $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN); + } + + plugin::save(); + + /* Save data to LDAP */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), _("Saving DHCP service failed")); + + /* 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"); + } + } else { + $this->handle_post_events("add"); + } + + /* Take over handling + * - Remove old dhcp config from source server + */ + if($this->take_over_id != -1){ + $id = $this->take_over_id; + $src = $this->dhcp_server_list['ENTRIES'][$id]['dn']; + $tmp = new servdhcp ($this->config, $src); + $tmp->remove_from_parent(); + } + } + + + function reload() + { + /* Init LDAP and load list */ + $ldap= $this->config->get_ldap_link(); + $ui= get_userinfo(); + $me= $this->dn; + + $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))"; + + $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH); + $final= array(); + + foreach ($list as $value){ + + /* Set header */ + $sortpart= split(",", $value['dn']); + $sortpart= array_reverse($sortpart); + $tmp= implode(",", $sortpart); + + $final[$value['dn']]= $tmp."!"._("Global options"); + + /* Read all sub entries to place here */ + $ldap->cd($value['dn']); + $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array()); + $this->serviceDN= $value['dn']; + + while ($attrs= $ldap->fetch()){ + $sattrs= array(); + for ($i= 0; $i<$attrs['count']; $i++){ + $sattrs[$attrs[$i]]= $attrs[$attrs[$i]]; + unset($sattrs[$attrs[$i]]['count']); + } + $sattrs['dn']= $ldap->getDN(); + + foreach($sattrs as $name => $values){ + if($name == "dhcpOption"){ + foreach($values as $key => $value){ + $value_name = trim(preg_replace("/[^ ]*$/","",$value)); + $value_value= trim(preg_replace("/^[^ ]*/","",$value)); + if(in_array($value_name,$this->quote_option)){ + $value_value = preg_replace("/^\"/","",$value_value); + $value_value = preg_replace("/\"$/","",$value_value); + $sattrs[$name][$key] = $value_name." ".$value_value; + } + } + } + } + + $this->dhcpObjectCache[$ldap->getDN()]= $sattrs; + $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN()); + $indent= substr_count($tmp, ","); + $spaces= ""; + for ($i= 0; $i<$indent; $i++){ + $spaces.= "    "; + } + + foreach ($this->types as $key => $val){ + if (in_array("$key", $attrs['objectClass'])){ + $type= $val; + break; + } + } + + /* Prepare for sorting... */ + $sortpart= split(",", $ldap->getDN()); + $sortpart= array_reverse($sortpart); + $tmp= implode(",", $sortpart); + $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'"; + } + } + + /* Sort it... */ + natsort($final); + $this->dhcpSections= array(); + foreach ($final as $key => $val){ + $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val); + } + + } + + + function objectType($dn) + { + $type= ""; + $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost", + "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork"); + + foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){ + if (in_array($oc, $types)){ + $type= $oc; + break; + } + } + + /* That should not happen... */ + if ($type == ""){ + print_red(_("DHCP configuration set is unknown. Please contact your system administrator.")); + } + + return ($type); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("DHCP service"), + "plDescription" => _("DHCP service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 84, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + + ) + )); + } + + + function take_over_service() + { + + } + + + function get_list_of_dhcp_servers() + { + $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array()); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN")); + while($attrs = $ldap->fetch()){ + + /* Skip own config */ + if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){ + continue; + } + + $ret['ENTRIES'][] = $attrs; + } + foreach($ret['ENTRIES'] as $key => $data){ + $ret['FOR_LIST'][$key] = $data['cn'][0]; + } + return($ret); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("DHCP service"); + $fields['AllowEdit'] = true; + return($fields); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl new file mode 100644 index 000000000..517c3b403 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl @@ -0,0 +1,25 @@ +
+ {t}Create new DHCP section{/t} +
+
+

+{t}Please choose one of the following DHCP section types.{/t} +

+
+{t}Section{/t}  + + +

+ +   + +

+ + + diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl new file mode 100644 index 000000000..5ce0e4600 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl @@ -0,0 +1,46 @@ +{* GOsa dhcp sharedNetwork - smarty template *} + +

+
+ +{if $show_advanced} + + + + + + + + + + +
+
+ {t}DHCP statements{/t} +
+ +
+   +   + +
+
+ {t}DHCP options{/t} +
+ +
+   +   + +
+ +{else} + + + +{/if} +

 

diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_group.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_group.tpl new file mode 100644 index 000000000..930fc05ee --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_group.tpl @@ -0,0 +1,22 @@ +{* GOsa dhcp sharedNetwork - smarty template *} +

{t}Generic{/t}

+ + + + + +
+ {t}Name{/t}{$must} + + +
+ +

 

+ + + diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_host.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_host.tpl new file mode 100644 index 000000000..602c51255 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_host.tpl @@ -0,0 +1,52 @@ +{* GOsa dhcp host - smarty template *} +

{t}Generic{/t}

+ + + + + +
+ + + + + + + + + +
{t}Name{/t}{$must} + +
{t}Fixed address{/t} + +
+
+ + + + + + + + + +
{t}Hardware type{/t} + +
{t}Hardware address{/t}{$must} + +
+
+ +

+ + + diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_network.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_network.tpl new file mode 100644 index 000000000..5645a63ac --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_network.tpl @@ -0,0 +1,90 @@ +{* GOsa dhcp sharedNetwork - smarty template *} + + + + + +
+

{t}Network configuration{/t}

+ + + + + + + + + + + + + +
{t}Router{/t} + +
{t}Netmask{/t} + +
{t}Broadcast{/t} + +
+
+
+

{t}Bootup{/t}

+ + + + + + + + + +
{t}Filename{/t} + +
{t}Next server{/t} + +
+ +
+

{t}Domain Name Service{/t}

+ + + + + + + + + + + +
{t}Domain{/t} + +
+
+ {t}DNS server{/t}
+ +
+   + + +
+

{t}Domain Name Service options{/t}

+ {t}Assign hostnames found via reverse mapping{/t} +
+ {t}Assign hostnames from host declarations{/t} +
+ +
+ + + diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_pool.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_pool.tpl new file mode 100644 index 000000000..dcbd05c3d --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_pool.tpl @@ -0,0 +1,26 @@ +{* GOsa dhcp sharedNetwork - smarty template *} +

{t}Generic{/t}

+ + + + + +
+ {t}Name{/t}{$must}  + + + {t}Range{/t}{$must}  + +  -  + +
+ +

 

+ + + diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_service.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_service.tpl new file mode 100644 index 000000000..6ca515e67 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_service.tpl @@ -0,0 +1,43 @@ +

{t}Generic{/t}

+ + + + + + + + +
+ {t}Authoritative service{/t}
+
+ {t}Dynamic DNS update{/t} + +
+ + + + + + + + + + +
{t}Default lease time (s){/t} + +
{t}Maximum lease time (s){/t} + +
+ +
+ +

+ + + diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl new file mode 100644 index 000000000..374da3500 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl @@ -0,0 +1,107 @@ +{* GOsa dhcp sharedNetwork - smarty template *} +

{t}Generic{/t}

+ + + + + + + + +
+ + + + + + + + + + +
{t}Name{/t}{$must} + +
{t}Server identifier{/t} + +
+ +
+ + + + +
+ {t}Authoritative server{/t} +
+
+ +

 

+ + + + + + + + +
+ +

{t}Leases{/t}

+ + + + + + + + + + + + + +
{t}Default lease time{/t} +  {t}seconds{/t} +
{t}Max. lease time{/t} +  {t}seconds{/t} +
{t}Min. lease time{/t} +  {t}seconds{/t} +
+ +
+

{t}Access control{/t}

+ + + + + + + + + + +
+ {t}Allow unknown clients{/t} +
+ {t}Allow bootp clients{/t} +
+ {t}Allow booting{/t} +
+
+ +

 

+ + + diff --git a/gosa-core/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl new file mode 100644 index 000000000..05425fbdc --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl @@ -0,0 +1,41 @@ +{* GOsa dhcp subnet - smarty template *} +

{t}Generic{/t}

+ + + + + +
+ + + + + + + + +
{t}Network address{/t}{$must}
{t}Netmask{/t}{$must}
+
+ + + + + + + + + +
{t}Range for dynamic address assignment{/t}
  +  -  + +
+
+ +

+ + + diff --git a/gosa-core/plugins/admin/systems/services/dhcp/remove_dhcp.tpl b/gosa-core/plugins/admin/systems/services/dhcp/remove_dhcp.tpl new file mode 100644 index 000000000..39fb19bb6 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/remove_dhcp.tpl @@ -0,0 +1,17 @@ +
+ {t}Warning{/t} +
+

+ {$warning} + {t}This includes 'all' DHCP subsections that are located within this section. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ +   + +

diff --git a/gosa-core/plugins/admin/systems/services/dhcp/servdhcp.tpl b/gosa-core/plugins/admin/systems/services/dhcp/servdhcp.tpl new file mode 100644 index 000000000..846af22ff --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dhcp/servdhcp.tpl @@ -0,0 +1,35 @@ +{if $dns_take_over} + + + + +
+

{t}DHCP take over will take place when saving this entry. Choose 'Cancel' to abort.{/t}

+
+{else} + +{if $dhcp_server_list_cnt} + + + +{/if} + + + +
+ {t}Take over dhcp configuration from following server{/t}  + + +
+

{t}DHCP sections{/t}

+ {$DhcpList} +
+{/if} +

 

+
+ +   + +
"Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = FALSE; + var $attributes = array(); + var $objectclasses = array("whatever"); + + var $RecordTypes = array(); + var $Zones = array(); + + var $orig_dn = ""; + + var $initially_was_account; + + /* ServerService tab vars */ + var $conflicts = array("servdns"); + var $DisplayName = ""; + var $StatusFlag = ""; + var $view_logged = FALSE; + + var $dns_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array()); + var $take_over_id = -1; + + + function servdns (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $this->DisplayName = _("DNS service"); + + $this->orig_dn = $dn; + + /* Get record types for zones + */ + $this->RecordTypes = getDnsRecordTypes(true); + + /* Get all zone Informations + */ + $this->Zones = getDNSZoneEntries($config,$dn); + + /* If there is at least one entry in this -> types, we have DNS enabled + */ + if(count($this->Zones) == 0){ + $this->is_account = false; + $this->dns_server_list = $this->get_list_of_dns_servers(); + }else{ + $this->is_account = true; + } + $this->initially_was_account = $this->is_account; + } + + + function get_list_of_dns_servers() + { + $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array()); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=dNSZone)(zoneName=*))",array("dn","zoneName")); + $dns = array(); + while($attrs = $ldap->fetch()){ + /* Skip own config */ + if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){ + continue; + } + $dn = preg_replace("/^zoneName=[^,]+,/","",$attrs['dn']); + if(preg_match("/^cn=/",$dn) && !in_array($dn,$dns)){ + $dns[] = $dn; + } + } + $i = 0; + foreach($dns as $dn){ + $ldap->cat($dn,array('*')); + if($ldap->count()){ + $i ++; + $attrs = $ldap->fetch(); + $ret['ENTRIES'][$i] = $attrs; + $ret['FOR_LIST'][$i] = $attrs['cn'][0]; + } + } + return($ret); + } + + + function get_dns_info_string($id) + { + $ret=""; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dns_server_list['ENTRIES'][$id]['dn']); + $ldap->search("(|(zoneName=*)(relativeDomainName=*))",array("dn")); + while($attrs = $ldap->fetch()){ + $ret .= $attrs['dn']."\n"; + } + return($ret); + } + + + function execute() + { + /* Call parent execute + */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Fill templating stuff + */ + $smarty= get_smarty(); + $smarty->assign("dns_take_over",FALSE); + $smarty->assign("is_createable",$this->acl_is_createable()); + $display= ""; + + + $this->initially_was_account= $this->is_account; + /*****************/ + /* Handle Take Over Actions + /*****************/ + + /* Give smarty the required informations */ + $smarty->assign("dns_server_list", $this->dns_server_list['FOR_LIST']); + $smarty->assign("dns_server_list_cnt", count($this->dns_server_list['FOR_LIST'])); + + /* Take over requested, save id */ + if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){ + $id = $_POST['take_over_src']; + if(isset($this->dns_server_list['ENTRIES'][$id])){ + $this->take_over_id = $id; + } + } + + /* Abort take over action */ + if(isset($_POST['cancel_take_over'])){ + $this->dialog =false; + $this->take_over_id = -1; + $this->dns_server_list = $this->get_list_of_dns_servers(); + } + + /* Display informartion about take over that will be started when saving this server + * and hide default dns output + */ + if($this->take_over_id != -1){ + $this->dialog = FALSE; + $id = $this->take_over_id; + $info = $this->get_dns_info_string($id); + $smarty->assign("dns_take_over",TRUE); + $smarty->assign("info",$info); + $warning = sprintf(_("You are going to migrate the DNS setup from server '%s'."),$this->dns_server_list['ENTRIES'][$id]['cn'][0]); + $warning2 = _("The migration will be startet when you save this system. To cancel this action, use the cancel button below."); + $smarty->assign("warning",$warning); + $smarty->assign("warning2",$warning2); + return($smarty->fetch(get_template_path('servdns.tpl', TRUE))); + } + + + /* Do we need to flip is_account state? + */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove DNS service"), + _("This server has DNS features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Add DNS service"), + _("This server has DNS features disabled. You can enable them by clicking below.")); + return ($display); + } + + + /* Edited or Added zone + */ + if(isset($_POST['SaveZoneChanges'])){ + $this->dialog->save_object(); + + /* Check for errors + */ + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msgs){ + print_red($msgs); + } + }else{ + /* add new/edited zone + */ + $ret = $this->dialog->save(); + if(!$this->dialog->isNew){ + unset($this->Zones[$this->dialog->OldZoneName]); + } + $this->Zones[$ret['zoneName']] = $ret; + $this->dialog = FALSE; + } + } + + /* Cancel zone edit / new + */ + if(isset($_POST['CancelZoneChanges'])){ + $this->dialog = FALSE; + } + + /* Add empty new zone + */ + if(isset($_POST['AddZone'])){ + $this->dialog = new servdnseditZone($this->config,$this->dn); + } + + /* Check for edit zone request + */ + $once = false; + foreach( $_POST as $name => $value){ + + /* check all post for edit request + */ + if(preg_match("/^editZone_/",$name)&&!$once){ + $once =true; + $tmp = preg_replace("/^editZone_/","",$name); + $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); + $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$tmp]); + } + + /* check posts for delete zone + */ + if(preg_match("/^delZone_/",$name)&&!$once){ + + $once =true; + $tmp = preg_replace("/^delZone_/","",$name); + $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); + + /* Initiate deletion + */ + $this->RemoveZone($tmp); + } + } + + if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ + $id = base64_decode($_GET['id']); + if(isset($this->Zones[$id])){ + $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]); + } + } + + if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ + $id = base64_decode($_GET['id']); + if(isset($this->Zones[$id])){ + $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]); + } + } + + /* Show dialog + */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $this->dialog->parent = $this; + return($this->dialog->execute()); + } + + /* Create Listbox with existing Zones + */ + $ZoneList = new divSelectBox("dNSZones"); + $ZoneList -> SetHeight(254); + + /* Add entries to divlist + */ + $editImg = ""; + if($this->acl_is_removeable()){ + $editImg.= ""; + } + + $link = "%s"; + foreach($this->Zones as $zone => $values ){ + $ZoneList->AddEntry(array( + array("string" => sprintf($link,base64_encode($zone),($zone))), + array("string" => sprintf($link,base64_encode($zone),_("Reverse zone")." : ".($values['ReverseZone']))), + array("string" => _("TTL")." : ".$values['sOAttl']), + array("string" => _("Class")." : ".$values['dNSClass']), + array("string" =>str_replace("%s",base64_encode($zone),$editImg)) + )); + } + + /* Display tempalte + */ + $smarty->assign("ZoneList",$ZoneList->DrawList()); + $display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE)); + return($display); + } + + + /* Delete specified zone + */ + function RemoveZone($id) + { + $zones = $this->getUsedZoneNames(); + + if(isset($this->Zones[$id]['InitialReverseZone'])){ + $rev = FlipIp($this->Zones[$id]['InitialReverseZone']); + }else{ + $rev = FlipIp($this->Zones[$id]['ReverseZone']); + } + + $zonename = ""; + if(isset($this->Zones[$id]['InitialzoneName'])){ + $zonename= $this->Zones[$id]['InitialzoneName']; + } + + $used = array(); + + /* Add Records which use this zoneName + */ + if(isset($zones[$zonename])){ + $used = array_merge($used,$zones[$zonename]); + } + + /* Add Records which uses this reverse zone + */ + if(isset($zones[$rev.".in-addr.arpa"])){ + $used = array_merge($used,$zones[$rev.".in-addr.arpa"]); + } + + /* There are still entries using this configuration + * Abort deletion + */ + if(count($used)){ + $i = 2; + $str =""; + foreach($used as $dn){ + if($i > 0 && !preg_match("/,relativeDomainName=/",$dn)){ + $i --; + $name = preg_replace("/^[^=]+=([^,]*),.*$/","\\1",$dn); + $zone = preg_replace("/^.*zoneName=([^,]*),.*$/","\\1",$dn); + $str.= $name.".".$zone." "; + } + } + + /* Only show 2 dns in the error message + */ + if(count($used)> 2) { + $str .=" ... "; + } + print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str))); + return(false); + }else{ + unset($this->Zones[$id]); + return(true); + } + } + + + /* This funtion returns all used Zonenames + */ + function getUsedZoneNames() + { + $ret = array(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=dNSZone)(!(relativeDomainName=@))(zoneName=*))",array("zoneName","relativeDomainName")); + while($attr = $ldap->fetch()){ + $ret[$attr['zoneName'][0]][] = $attr['dn']; + } + return($ret); + } + + + /* Remove dns service + */ + function remove_from_parent() + { + if($this->initially_was_account){ + $bool = true; + $this->is_account = FALSE; + foreach($this->Zones as $key => $zone){ + $bool= $bool & $this->RemoveZone($key); + } + + if($bool){ + $this->save(); + } + return($bool); + } + } + + + /* Save to LDAP */ + function save() + { + + /* Take over handling + * - Create list of zones managed by source server + * - Copy ldap entries to destination server + * - Remove old zone entries from source + */ + if($this->take_over_id != -1){ + $del = array(); + $id = $this->take_over_id; + $src = $this->dns_server_list['ENTRIES'][$id]['dn']; + $ldap = $this->config->get_ldap_link(); + $ldap->ls("(objectClass=dnsZone)",$src,array('cn')); + while($attrs = $ldap->fetch()){ + $src_zone = $attrs['dn']; + $dst_zone = preg_replace("/".normalizePreg($src)."$/",$this->dn,$src_zone); + $res = plugin::recursive_move($src_zone, $dst_zone); + + if($res){ + $del [] = $src_zone; + } + } + foreach($del as $src_zone){ + $ldap->rmdir_recursive($src_zone); + } + return; + } + + /* Save zone editor changes now */ + foreach($this->Zones as $name => $zone){ + if(isset($zone['zoneEditor'] ) && $zone['zoneEditor'] != NULL && is_object($zone['zoneEditor'])){ + $zone['zoneEditor']->save(); + unset($this->Zones[$name]['zoneEditor']);; + } + } + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* Get differences + */ + $old_dn = $this->orig_dn; + if($old_dn == "new"){ + $old_dn = $this->dn; + } + + $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); + + /* Update dns to current object dn */ + $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); + $tmp2 = array(); + foreach($tmp as $key1 => $data1){ + $tmp2[$key1] = array(); + foreach($data1 as $key2 => $data2){ + $tmp2[$key1][preg_replace("/".normalizePreg($old_dn)."$/",$this->dn,$key2)] = $data2; + } + } + $tmp = $tmp2; + + /* Updated zone entries if reverser or forward name has changed + * Must be done before moving entries, else the given dn is invalid + */ + if(isset($tmp['zoneUpdates'])){ + foreach($tmp['zoneUpdates'] as $dn => $attrs){ + $ldap->cd($dn); + $ldap->modify($attrs); + new log("modfiy","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Updating of system server/dns with dn '%s' failed."),$this->dn)); + } + } + + /* Delete dns + */ + foreach($tmp['del'] as $dn => $del){ + + $for = $del['InitialzoneName']; + $rev = FlipIp($del['InitialReverseZone']).".in-addr.arpa"; + + $ldap->cd($dn); + $ldap->rmdir_recursive($dn); + new log("remove","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ +# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $for)); +# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $rev)); + } + } + + /* move follwoing entries + */ + foreach($tmp['move'] as $src => $dst){ + $this->recursive_move($src,$dst); + } + + /* Add || Update new DNS entries + */ + foreach($tmp['add'] as $dn => $attrs){ + $ldap->cd($dn); + $ldap->cat($dn, array('dn')); + if($ldap->fetch()){ + $ldap->cd($dn); + $ldap->modify ($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ +# $this->handle_post_events("modify",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); + } + }else{ + $ldap->cd($dn); + $ldap->add($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); + + /* Handle Post events */ + if(preg_match("/^zoneName=/",$dn)){ +# $this->handle_post_events("add",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); + } + } + } + $this->handle_post_events("modify"); + } + + + /* Directly save new status flag */ + function setStatus($value) + { + if($value == "none") return; + if(!$this->initially_was_account) return; + if(empty($this->StatusFlag)) return; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + + $tmp = $ldap->fetch(); + for($i = 0; $i < $tmp['objectClass']['count']; $i ++){ + $attrs['objectClass'][] = $tmp['objectClass'][$i]; + } + $flag = $this->StatusFlag; + $attrs[$flag] = $value; + $this->$flag = $value; + $ldap->modify($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/dns with dn '%s' failed."),$this->dn)); + $this->action_hook(); + } + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("DNS service"); + $fields['AllowEdit'] = true; + return($fields); + } + + + /* Get updates for status flag */ + function updateStatusState() + { + if(empty($this->StatusFlag)) return; + + $attrs = array(); + $flag = $this->StatusFlag; + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->cn); + $ldap->cat($this->dn,array($flag)); + if($ldap->count()){ + $attrs = $ldap->fetch(); + } + if(isset($attrs[$flag][0])){ + $this->$flag = $attrs[$flag][0]; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("DNS service"), + "plDescription" => _("DNS service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 83, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "zoneName" =>_("Zone name"), + "ReverseZone" =>_("Reverse zone"), + "sOAprimary" =>_("Primary dns server"), + "sOAmail" =>_("Mail address"), + "sOAserial" =>_("Serial"), + "sOArefresh" =>_("Refresh"), + "sOAretry" =>_("Retry"), + "sOAexpire" =>_("Expire"), + "sOAttl" =>_("TTL"), + "zoneRecords" =>_("Zone records")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc b/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc new file mode 100644 index 000000000..d5df0871d --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZone.inc @@ -0,0 +1,603 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("zoneName","ReverseZone","dNSClass", + "sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl"); + var $objectclasses = array("whatever"); + + var $RecordTypes = array(); + + var $ReverseZone = ""; + var $zoneName = ""; + var $dNSClass = "IN"; + + var $sOAprimary = ""; + var $sOAmail = ""; + var $sOAserial = ""; + var $sOArefresh = "3600"; + var $sOAretry = "1800"; + var $sOAexpire = "720000"; + var $sOAttl = "6400"; + + var $Records = array(); + var $mXRecords = array(); + + var $OldZoneName = ""; // To detect changes made with this edit + var $OldReverseZone = ""; + + var $InitialReverseZone = ""; + var $InitialzoneName = ""; + var $NetworkClass = "A" ; // One out of A,B,C + + var $dialog = false; + + var $zoneEditor = NULL; + + var $isNew = true; + + var $ZoneObject = array(); + + function servdnseditZone (&$config, $dn= NULL,$attrs = array()) + { + plugin::plugin ($config, $dn); + + /* All types with required attrs */ + $this->RecordTypes = getDnsRecordTypes(true); + + if(!count($attrs)){ + $this->OldZoneName = ""; + $this->OldReverseZone = ""; + $this->isNew = true; + $this->sOAserial = date("Ymd")."1"; + + $this->InitialzoneName = "";//$attrs['InitialzoneName']; + $this->InitialReverseZone = "";//$attrs['InitialReverseZone']; + }else{ + $this->ZoneObject = $attrs; + + if(isset($attrs['zoneEditor'])){ + $this->zoneEditor = $attrs['zoneEditor']; + } + $this->OldZoneName = $attrs['zoneName']; + $this->OldReverseZone = $attrs['ReverseZone']; + + $this->InitialzoneName = $attrs['InitialzoneName']; + $this->InitialReverseZone = $attrs['InitialReverseZone']; + + $this->isNew = false; + + foreach($this->attributes as $value){ + $this->$value = $attrs[$value]; + } + + $this->sOAmail = preg_replace("/\./","@",$this->sOAmail,1); + $this->sOAmail = preg_replace("/\.$/","",$this->sOAmail); + $this->sOAprimary = preg_replace("/\.$/","",$this->sOAprimary); + $this->zoneName = preg_replace("/\.$/","",$this->zoneName); + + if(isset($attrs['RECORDS'])){ + $this->Records = $attrs['RECORDS']; + + $tmp2 = array(); + $usedPrio = array(); + foreach($this->Records as $key => $rec){ + if($rec['type'] == "mXRecord"){ + $tmp = split(" ",$rec['value']); + $rec['value'] = $tmp[1]; + $tmp2[$tmp[0]] = $rec; + unset($this->Records[$key]); + } + if($rec['type'] == "nSRecord"){ + unset($this->Records[$key]); + } + } + if(count($tmp2) != 0){ + reset($tmp2); + ksort($tmp2); + } + $this->mXRecords = $tmp2; + }else{ + $this->mXRecords = array(); + $this->Records = array(); + } + + $str = date("Ymd"); + if(preg_match("/^".$str."/",$this->sOAserial)){ + $this->sOAserial = $this->sOAserial + 1; + }else{ + $this->sOAserial = date("Ymd")."01"; + } + } + + /* Detect Network class */ + if(!empty($this->ReverseZone)){ + + $dots = count(split("\.",$this->ReverseZone)); + if($dots == 1){ + $this->NetworkClass = "A"; + $this->ReverseZone .= ".0.0.0"; + }elseif($dots == 2){ + $this->NetworkClass = "B"; + $this->ReverseZone .= ".0.0"; + }else{ + $this->NetworkClass = "C"; + $this->ReverseZone .= ".0"; + } + } + } + + /* TRansports the geiven Arraykey one position up*/ + function ArrayUp($atr,$attrs) + { + $ret = $attrs; + $pos = $atr ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == 1)||($pos >$cn))){ + $before = array_slice($attrs,0,($pos-2)); + $mitte = array_reverse(array_slice($attrs,($pos-2),2)); + $unten = array_slice($attrs,$pos); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* TRansports the geiven Arraykey one position up*/ + function ArrayDown($atr,$attrs) + { + $ret = $attrs; + $pos = $atr ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == $cn))){ + $before = array_slice($attrs,0,($pos-1)); + $mitte = array_reverse(array_slice($attrs,($pos-1),2)); + $unten = array_slice($attrs,($pos+1)); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + /* Combine new array */ + function combineArrays($ar0,$ar1,$ar2) + { + $ret = array(); + if(is_array($ar0)) + foreach($ar0 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar1)) + foreach($ar1 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar2)) + foreach($ar2 as $ar => $a){ + $ret[]=$a; + } + return($ret); + } + + function getpos($atr,$attrs) + { + $i = 0; + foreach($attrs as $attr => $name) { + $i++; + if($attr == $atr){ + return($i); + } + } + return(-1); + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + + + /* Fill templating stuff */ + $smarty= get_smarty(); + $ui = get_userinfo(); + + $smarty->assign("ACLs",$this->parent->getacl("")); + $display= ""; + + /* Open Zone Entry Edit Dialog + */ + if(!count($this->ZoneObject)){ + $smarty->assign("AllowZoneEdit" , false); + }else{ + $smarty->assign("AllowZoneEdit" , true); + if(isset($_POST['EditZoneEntries'])){ + if($this->zoneEditor == NULL){ + $this->zoneEditor= new servDNSeditZoneEntries($this->config,$this->dn,$this->ZoneObject); + $this->zoneEditor->parent = $this; + } + $this->dialog = $this->zoneEditor; + } + } + + /* Save Zone Entry Edit Dialog + */ + if(isset($_POST['SaveZoneEntryChanges'])){ + $this->dialog->save_object(); + if(count($this->dialog->check())){ + $msgs = $this->dialog->check(); + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $this->zoneEditor = clone $this->dialog; + $this->dialog = FALSE; +# $rev = FlipIp(getNameFromMix($this->InitialReverseZone)).".in-addr.arpa"; +# $for = getNameFromMix($this->InitialzoneName); +# +# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $rev)); +# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $for)); +# $this->dialog = false; + } + } + + /* Cancel Zone Entrie Edit Dialog + */ + if(isset($_POST['CancelZoneEntryChanges'])){ + $this->dialog = false; + } + + /* Display any type of open dialogs + */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + $once =true; + foreach($_POST as $name => $value){ + if((preg_match("/^MXup_/",$name)) && ($once)){ + $once = false; + + $id = preg_replace("/^MXup_/","",$name); + $id = preg_replace("/_.*$/","",$id); + $id = base64_decode($id); + + $this->mXRecords = $this->ArrayUp(($id+1),$this->mXRecords); + } + if((preg_match("/^MXdown_/",$name)) && ($once)){ + $once = false; + + $id = preg_replace("/^MXdown_/","",$name); + $id = preg_replace("/_.*$/","",$id); + $id = base64_decode($id); + + $this->mXRecords = $this->ArrayDown(($id+1),$this->mXRecords); + } + if((preg_match("/^MXdel_/",$name)) && ($once)){ + $once = false; + + $id = preg_replace("/^MXdel_/","",$name); + $id = preg_replace("/_.*$/","",$id); + $id = base64_decode($id); + + unset($this->mXRecords[$id]); + + $tmp =array(); + foreach($this->mXRecords as $entry){ + $tmp[] = $entry; + } + + $this->mXRecords = $tmp; + } + } + + if((isset($_POST['AddMXRecord'])) && (!empty($_POST['StrMXRecord']))){ + $this->mXRecords[] = array("type"=>"mXRecord","value"=>trim($_POST['StrMXRecord'])); + } + + /* Handle Post events */ + $once = true; + foreach($_POST as $name => $value){ + + /* Delete record if requested */ + if((preg_match("/RemoveRecord_/",$name))&&($once)){ + $once = false; + $id= preg_replace("/RemoveRecord_/","",$name); + unset($this->Records[$id]); + } + } + + /* Add new Zonerecord */ + if(isset($_POST['AddNewRecord'])){ + $this->Records[] = array("type"=>"aRecord","value"=>""); + } + + /* Fill in values */ + foreach($this->attributes as $name){ + $smarty->assign($name,$this->$name); + } + + + $div = new divSelectBox("MxRecords"); + $div->setHeight(120); + $recs = $this->mXRecords; + + $oneup = " "; + $onedown = " "; + $onedel = " + "; + + foreach($recs as $key => $rec){ + $div ->AddEntry(array( + array("string"=>$rec['value']), +/* array("string"=>$key, + "attach"=>"style='width:20px;'"),*/ + array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel), + "attach"=>"style='width:70px;border-right:0px;'") + )); + } + + /* Assign records list */ + $smarty->assign("NotNew", false); + $smarty->assign("Mxrecords", $div->DrawList()); + $smarty->assign("records" , $this->generateRecordsList()); + $smarty->assign("NetworkClass", $this->NetworkClass); + $smarty->assign("NetworkClasses", array("A"=>"255.0.0.0 (Class A)","B"=>"255.255.0.0 (Class B)","C"=>"255.255.255.0 (Class C)")); + + /* Display tempalte */ + $display.= $smarty->fetch(get_template_path('servdnseditzone.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + } + + /* Save data to object */ + function save_object() + { + //plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + + foreach($this->Records as $id => $value){ + if(isset($_POST['RecordTypeSelectedFor_'.$id])){ + $this->Records[$id]['type'] = $_POST['RecordTypeSelectedFor_'.$id]; + } + if(isset($_POST['RecordValue_'.$id])){ + $this->Records[$id]['value'] = $_POST['RecordValue_'.$id]; + } + } + + if(isset($_POST['NetworkClass'])){ + $this->NetworkClass = $_POST['NetworkClass']; + } + + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Check if zoneName is already in use */ + $usedZones = $this->getUsedZoneNames(); + if(($this->isNew == true)||($this->zoneName != $this->InitialzoneName)||($this->ReverseZone != $this->InitialReverseZone)){ + /* if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){ + $message[] =_("This zoneName is already in use"); + } + if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitialReverseZone)){ + $message[] =_("This reverse zone is already in use"); + }*/ + } + + if(empty($this->zoneName)){ + $message[] =sprintf(_("Please choose a valid zone name.")); + } + + if(empty($this->ReverseZone)){ + $message[] =sprintf(_("Please choose a valid reverse zone name.")); + } + + if($this->zoneName != strtolower($this->zoneName)){ + $message[] = _("Only lowercase strings are allowed as zone name."); + } + + if(!is_numeric($this->sOAserial)){ + $message[] = _("Please specify a numeric value for serial number."); + } + + if(!is_numeric($this->sOArefresh)){ + $message[] = _("Please specify a numeric value for refresh."); + } + + if(!is_numeric($this->sOAttl)){ + $message[] = _("Please specify a numeric value for ttl."); + } + + if(!is_numeric($this->sOAexpire)){ + $message[] = _("Please specify a numeric value for expire."); + } + + if(!is_numeric($this->sOAretry)){ + $message[] = _("Please specify a numeric value for retry."); + } + + foreach($this->Records as $name => $values){ + /* only lower-case is allowed in record entries ... */ + if($values['value'] != strtolower($values['value'])){ + $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']); + } + } + + /* Check class for given Zone Address */ + $addr = preg_replace("/^[^\/]*+\//","",$this->ReverseZone); + + /* Check for valid&complete IP address */ + if(!is_ip($addr)){ + $message[] = _("The given network address is not a valid, please specify a valid IP address."); + } + + /* Check if given address matches selected network class */ + switch($this->NetworkClass){ + case 'A': { + if(!preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){ + $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.0.0.0")); + } + } + break; + case 'B': { + if(!preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){ + $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.0.0")); + } + } + break; + case 'C': { + if(!preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){ + $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.x.0")); + } + } + break; + default : $message[] =sprintf(_("The given network class '%s' is not valid."),$this->NetworkClass); + } + + return ($message); + } + + /* This funtion returns all used Zonenames */ + function getUsedZoneNames() + { + $ret = array(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(zoneName=*))",array("zoneName","tXTRecord")); + while($attr = $ldap->fetch()){ + if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){ + if(isset($attr['tXTRecord'][0])){ + $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]); + $ret[$zn] =FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0])); + } + }else{ + $ret[$attr['zoneName'][0]]=""; + } + } + return($ret); + } + + /* Save to LDAP */ + function save() + { + $ret =array(); + foreach($this->attributes as $name){ + $ret[$name] = $this->$name; + } + + /* Create mx records + */ + foreach($this->mXRecords as $key => $rec){ + $rec['value']= $key." ".$rec['value']; + $this->Records [] = $rec; + } + + + $ret['RECORDS'] = $this->Records; + + switch($this->NetworkClass){ + case 'C' : $ret['ReverseZone']= preg_replace("/\.[0-9]*$/","",$this->ReverseZone);break; + case 'B' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break; + case 'A' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break; + default : trigger_error("Invalid network class given '".$this->NetworkClass."'"); + } + + $ret['InitialReverseZone']= $this->InitialReverseZone; + $ret['InitialzoneName'] = $this->InitialzoneName; + + $ret['sOAmail'] = preg_replace("/\@/",".",$this->sOAmail); + + foreach(array("sOAprimary","zoneName","sOAmail") as $attr){ + if(!preg_match("/\.$/",$ret[$attr])){ + if(!is_ip($ret[$attr])){ + $ret[$attr] = $ret[$attr]."."; + } + } + } + + $ret['RECORDS'][] = array("type" => "nSRecord","value" => $ret['sOAprimary']) ; + + $ret['zoneEditor'] = $this->zoneEditor; + return($ret); + } + + + /* This function generate a table row for each used record. + This table row displays the recordtype in a select box + and the specified value for the record, and a remove button. + The last element of the table also got an 'add' button. + */ + function generateRecordsList($changeStateForRecords="") + { + $changeStateForRecords = ""; + + $str = ""; + foreach($this->Records as $key => $entry){ + + if($entry['type'] == "mXRecord") continue; + + $changeStateForRecords.= "changeState('RecordTypeSelectedFor_".$key."');\n"; + $changeStateForRecords.= "changeState('RecordValue_".$key."');\n"; + $changeStateForRecords.= "changeState('RemoveRecord_".$key."');\n"; + + $str.=" ". + " ". + " ". + " ". + ""; + } + + $str.= " ". + " ". + " ". + "
".$this->generateRecordListBox($entry['type'],"RecordTypeSelectedFor_".$key)."
". + " ". + "
"; + return($str); + } + + /* This function generates a select box out of $this->RecordTypes options. + The Parameter $selected is used to predefine an attribute. + $name is used to specify a post name + */ + function generateRecordListBox($selected,$name) + { + $str = ""; + return($str); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc b/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc new file mode 100644 index 000000000..8453ae794 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc @@ -0,0 +1,498 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); + + var $Devices = array(); + + var $zoneName = ""; // ZoneName of currently edited Zone + var $reverseName = ""; // ReverseZone of the currently edited Zone + + var $RecordTypes = array(); // Possible record type. + + var $disableDialog = false; // Dialog will be disabled, if this zone is new + + function servDNSeditZoneEntries (&$config,$dn, &$zoneObject) + { + plugin::plugin ($config, $dn); + + /* Initialise class + */ + $this->RecordTypes = getDnsRecordTypes(); + $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn; + $this->zoneName = $zoneObject['InitialzoneName']; + $this->reverseName = $zoneObject['InitialReverseZone']; + + /* Remove nSRecord from listed types */ + if(isset($this->RecordTypes['nSRecord'])){ + unset($this->RecordTypes['nSRecord']); + } + /* Remove nSRecord from listed types */ + if(isset($this->RecordTypes['pTRRecord'])){ + unset($this->RecordTypes['pTRRecord']); + } + + /* Get ldap connection + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + /* Get zone content + */ + $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName")); + + while($attrs = $ldap->fetch()){ + $this->Devices[$attrs['relativeDomainName'][0]] = getDNSHostEntries($config,$attrs['relativeDomainName'][0],true); + $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0]; + } + + $ldap->cat($this->dn,array("objectClass")); + + $this->disableDialog = true; + if(count($this->Devices)|| $ldap->count()){ + $this->disableDialog = false; + } + } + + function execute() + { + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $table = ""; + foreach($this->Devices as $key => $dev){ + $table .= $this->generateRecordConfigurationRow($key); + } + + $smarty->assign("disableDialog",$this->disableDialog); + $smarty->assign("table",$table);; + $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE)); + return($display); + } + + + function save_object() + { + /* Check posts for operations ... + */ + $once = true; + $ptr_updates = array(); + foreach($_POST as $name => $value){ + + /* Add a new Record in given object + */ + + $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name); + $tmp2 = split("\|",$tmp); + + /* Add new host entry + */ + if((preg_match("/^UserRecord_?/",$name)) && ($once)){ + $once = false; + $entry = getDNSHostEntries($this->config,"",true); + $entry['exists'] = true; + $entry['zoneName'] = strtoupper($this->attrs['cn'][0])."/".$this->zoneName; + $entry['RECORDS'][] = array("type" => "aRecord" , "value"=>""); + $this->Devices[_("New entry")] = $entry; + } + + if(count($tmp2) != 2) continue; + + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; + + /* Add new REcord + */ + if((preg_match("/^AddRecord_/",$name)) && ($once)){ + $once = false; + $this->Devices[$Name]['RECORDS'][] = $this->Devices[$Name]['RECORDS'][$RecordID]; + } + + /* Remove record from given dn + */ + if((preg_match("/^RemoveRecord_/",$name)) && ($once)){ + $once = false; + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + unset($this->Devices[$Name]['RECORDS'][$RecordID]); + } + + /* Check if there is at least one visible record. Else remove complete entry */ + $visible = false; + foreach($this->Devices[$Name]['RECORDS'] as $rec){ + if(in_array($rec['type'],$this->RecordTypes)){ + $visible = true; + break; + } + } + if(!$visible && isset($this->Devices[$Name]['RECORDS'])){ + $this->Devices[$Name]['RECORDS'] = array(); + } + } + } + + /* Possible attributes posted + */ + foreach($_POST as $name => $value){ + + /* Extract informations out of post name + */ + $tmp = preg_replace("/^.*_/","\\1",$name); + $tmp2 = split("\|",$tmp); + + if(count($tmp2) != 2) continue; + + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; + + /* Check for value change + */ + if(preg_match("/ValueSelection_/",$name)){ + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + + /* Update value */ + $old = $this->Devices[$Name]['RECORDS'][$RecordID]['value']; + $this->Devices[$Name]['RECORDS'][$RecordID]['value'] = $value; + + /* Handle pTRRecord */ + if(!isset($ptr_updates[$Name]) && $this->Devices[$Name]['RECORDS'][$RecordID]['type'] == "aRecord"){ + + $found = false; + $ip = $value; + $match = preg_replace("/^[^\/]*+\//","",$this->reverseName); + $ip = preg_replace("/^".normalizePreg($match)."/","",$ip); + $ip = preg_replace("/^\./","",$ip); + + foreach($this->Devices[$Name]['RECORDS'] as $key => $dev){ + if($dev['type'] == "pTRRecord"){ + $ptr_updates[$Name] = $Name; + $this->Devices[$Name]['RECORDS'][$key]['value'] = $ip; + $found = true; + break; + } + } + if(!$found){ + $dev = array('type'=> 'pTRRecord', 'value' => $ip); + $this->Devices[$Name]['RECORDS'][] = $dev; + } + } + } + } + + /* record type changed + */ + if(preg_match("/^RecordTypeSelection_/",$name)){ + if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ + $this->Devices[$Name]['RECORDS'][$RecordID]['type'] = $value; + } + } + } + + /* check for renamed entries + */ + foreach($_POST as $name => $value){ + + /* Extract informations out of post name + */ + $tmp = preg_replace("/^.*_/","\\1",$name); + $tmp2 = split("\|",$tmp); + + if(count($tmp2) != 2) continue; + + $Name = base64_decode($tmp2[0]); + $RecordID = $tmp2[1]; + + /* Host renamed + */ + if(preg_match("/RenameHost_/",$name)){ + if((isset($this->Devices[$Name])) && ($Name != $value)){ + + if(isset($this->Devices[$value])){ + print_red(sprintf(_("Can't rename '%s' to '%s' there is already an entry with the same name in our zone editing dialog."),$Name,$value)); + }else{ + $this->Devices[$value] = $this->Devices[$Name]; + unset($this->Devices[$Name]); + } + } + } + } + } + + + /* check something + */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + + $names = array(); + foreach($this->Devices as $DevName => $device){ + + /* Don't need to check empty values ... */ + if(!count($device['RECORDS'])) continue; + + /* Checking entry name + */ + if(!preg_match("/^[a-z0-9_\.-]+$/i", $DevName) || (empty($DevName))){ + $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $DevName); + } + + /* Renaming check for existing devices + */ + if(isset($device['OrigCn']) && ($DevName != $device['OrigCn'] )){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); + if($ldap->count()){ + $message[] = sprintf(_("Can not rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$DevName); + } + }elseif(!isset($device['OrigCn'])){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); + if($ldap->count()){ + $message[] = sprintf(_("Can not create '%s',the destination name already exists."),$DevName); + } + } + + /* Check names + */ + if(!isset($names[$DevName])){ + $names[$DevName] = ""; + }else{ + $message[] = sprintf(_("The name '%s' is used more than once."),$DevName); + } + + /* Names should be written in lowercase + */ +# if(strtolower($DevName) != $DevName){ +# $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $DevName); +# } + + /* Check records + */ + $singleEntries = array("cNAMERecord","pTRRecord"); + + $tmp = array(); + $tmp2 = array(); + foreach($device['RECORDS'] as $Num => $Rec){ + + /* Check for multiple use of unique record types + */ + if(in_array($Rec['type'],$singleEntries)){ + if(!isset($tmp[$Rec['type']])){ + $tmp[$Rec['type']] = ""; + }else{ + $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$Rec['type']); + } + } + + /* Check for empty / duplicate entries in record array + */ + if(empty($Rec['value'])){ + $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$Rec['type'],$DevName); + } + + /* Check for duplicate record entries + */ + if(!isset($tmp[$Rec['type']][$Rec['value']])){ + $tmp[$Rec['type']][$Rec['value']] = ""; + }else{ + $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$Rec['type'],$DevName); + } + } + } + return ($message); + } + + function save() + { + if($this->disableDialog) return; + + $todo = array(); + + + + /* Create todolist + */ + foreach($this->Devices as $name => $dev){ + if(isset($dev['OrigCn'])){ + if(count($dev['RECORDS'])){ + $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); + }else{ + $dev['exists'] = false; + $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); + } + }else{ + if(count($dev['RECORDS'])){ + $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name); + }else{ + $dev['exists'] = false; + $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name); + } + } + } + + $tmp = array(); + $tmp['del'] = array(); + $tmp['add'] = array(); + $tmp['move'] = array(); + foreach($todo as $to){ + foreach($to as $type => $entries){ + $tmp[$type] = array_merge($tmp[$type],$entries); + } + } + + /* Get ldap link + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + + /* move follwoing entries + */ + foreach($tmp['move'] as $src => $dst){ + $this->recursive_move($src,$dst); + } + + /* Delete dns */ + foreach($tmp['del'] as $dn => $del){ + $ldap->cd($dn); + $ldap->rmdir_recursive($dn); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("remove",array("dn" => $dn)); + } + } + + /* Add || Update new DNS entries + */ + foreach($tmp['add'] as $dn => $attrs){ + $ldap->cd($dn); + $ldap->cat($dn, array('dn')); + if(count($ldap->fetch())){ + $ldap->cd($dn); + $ldap->modify ($attrs); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("modify",array("dn" => $dn)); + } + }else{ + $ldap->cd($dn); + $ldap->add($attrs); + if(is_object($this->parent->parent)){ + $this->parent->parent->handle_post_events("create",array("dn" => $dn)); + } + } + } + } + + + /* Create html table out of given entry + */ + function generateRecordConfigurationRow($objKey){ + + /* Get some basic informations + */ + $obj = $this->Devices[$objKey]; + $objectName = $objKey; + + /* Abort if emtpy + */ + if(count($obj['RECORDS']) == 0) return ""; + + /* Set title + */ + $str= "
"; + + $hostNameOnce = true; + + /* Walk through all defined records + */ + $str.= ""; + foreach($obj['RECORDS'] as $id => $record){ + + /* Skip not selectable entries */ + if(!isset($this->RecordTypes [$record['type']])) { + continue; + } + + /* Create unique post name + */ + $name = base64_encode($objKey)."|".$id; + + $str .= " + + + + "; + } + $str .="
\n"; + + /* Only first host entry name should be editable + */ + if($hostNameOnce){ + $hostNameOnce = false; + $str .="\n"; + } + + /* Create rest. Selectbox, icons ... + */ + $str .=" + + ".$this->createRecordTypeSelection($record['type'],$name)." + + + + + + "; + +# if($record['type'] == "aRecord"){ +# $str .=""; +# }else{ +# $str .= ""; +# } + + $str.= + "
"; + return($str); + } + + + /* Create selectbox with all available option types + */ + function createRecordTypeSelection($id,$refID){ + + $str = "\n"; + return($str); + } + + + function remove_from_parent() + { + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dns/class_termDNS.inc b/gosa-core/plugins/admin/systems/services/dns/class_termDNS.inc new file mode 100644 index 000000000..025933291 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dns/class_termDNS.inc @@ -0,0 +1,1012 @@ +parent = $parent; + $this->objectclasses = $objectClasses; + $this->IPisMust = $IPisMust; + + plugin::plugin ($config, $parent->dn); + + if(isset($this->attrs['cn'][0])){ + $this->OrigCn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]); + $this->cn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]); + } + + + /************ + * DHCP + ************/ + + /* Hide all dhcp specific code, if dhcp plugin is not present in config */ + $dhcpEnabled = FALSE; + if($this->config->search("servdhcp","class",array("tabs"))){ + $this->dhcpEnabled = TRUE; + } + if($this->dhcpEnabled){ + $this->dhcpParentNodes = $this->get_dhcp_parent_nodes(); + $this->dhcpParentNode = $this->get_dhcp_parent_node(); + if($this->dhcpParentNode){ + $this->dhcp_is_Account = TRUE; + $this->initial_dhcp_is_Account = TRUE; + $this->dhcpHostEntry = $this->get_dhcp_host_entry(); + } + $this->initial_dhcpHostEntry = $this->dhcpHostEntry; + $this->initial_dhcpParentNode= $this->dhcpParentNode; + } + + + /************ + * Autonetwork hook + ************/ + + /* Do we have autonet support? */ + if (isset($this->config->data['MAIN']['AUTO_NETWORK_HOOK'])){ + $this->autonet= true; + } + + + /************ + * DNS + ************/ + + /* Hide all dns specific code, if dns is not available + */ + $DNSenabled = false; + foreach($this->config->data['TABS']['SERVERSERVICE'] as $tab){ + if(preg_match("/^servdns$/",$tab['CLASS'])){ + $this->DNSenabled = true; + } + } + if(!$this->DNSenabled){ + $this->DNS_is_account = false; + return; + } + + if($this->DNSenabled){ + + /* Get Zones + */ + $this->Zones = getAvailableZones($config); + + /* Get Entry + */ + $this->dnsEntry = getDNSHostEntries($config,$this->OrigCn); + + /* Remove A record which equals $this->ipHostNumber + */ + $ptr = $this->get_pTRRecord(); + foreach($this->dnsEntry['RECORDS'] as $key => $rec){ + if(($rec['type'] == "aRecord") && ($rec['value'] == $this->ipHostNumber)){ + unset($this->dnsEntry['RECORDS'][$key]); + } + if(($rec['type'] == "pTRRecord") && ($rec['value'] == $ptr)){ + unset($this->dnsEntry['RECORDS'][$key]); + } + } + + /* Get Record types + */ + $this->RecordTypes = getDnsRecordTypes(); + + /* If there is at least one entry in this -> types, we have DNS enabled + */ + if($this->dnsEntry['exists']){ + $this->DNS_is_account = true; + }else{ + $this->DNS_is_account = false; + } + } + + /* Create a list of used mac and ip addresses */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(|(macAddress=*)(ipHostNumber=*))",array("macAddress","ipHostNumber")); + while($attrs = $ldap->fetch()){ + if(isset($attrs['ipHostNumber'][0])){ + $this->used_ip_mac["ip:".$attrs['ipHostNumber'][0]] = "ip:".$attrs['ipHostNumber'][0]; + } + if(isset($attrs['macAddress'][0])){ + $this->used_ip_mac["mac:".$attrs['macAddress'][0]] = "mac:".$attrs['macAddress'][0]; + } + } + + /* Save initial ip and mac values, to be able + check if the used values are already in use */ + $this->orig_ipHostNumber = $this->ipHostNumber; + $this->orig_macAddress = $this->macAddress; + + /* Store initally account settings + */ + $this->initially_was_account = $this->DNS_is_account; + + if($this->DNS_is_account){ + new log("view","unknown/".get_class($this),$this->dn); + } + } + + + function netmaskIsCoherent($idZone) + { + $netmask = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($idZone))); + if(!strstr($this->ipHostNumber, $netmask)){ + return false; + }else{ + return true; + } + } + + + function getVarsForSaving($attrs) + { + foreach($this->attributes as $attr){ + if(!empty($this->$attr)){ + $attrs[$attr] = $this->$attr; + } + } + return($attrs); + } + + function execute() + { + /* Call parent execute */ + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $display= ""; + + $smarty->assign("staticAddress", ""); + $smarty->assign("autonet", $this->autonet); + + /* Check for autonet button */ + if ($this->autonet && isset($_POST['autonet'])){ + $cmd= $this->config->data['MAIN']['AUTO_NETWORK_HOOK']; + if(!empty($cmd) && $this->cn != ""){ + $res = shell_exec($cmd." ".$this->cn); + if(!$res){ + print_red(sprintf(_("Can't execute specified AUTO_NETWORK_HOOK '%s'. Please check your gosa.conf."),$cmd)); + } else { + $res= split(';', trim($res)); + if (isset($res[0]) && $res[0] != ""){ + $this->ipHostNumber= $res[0]; + } + if (isset($res[1]) && $res[1] != ""){ + $this->macAddress= $res[1]; + } + } + } + } + + + /********** + * DHCP Handling + **********/ + + if(isset($_POST['dhcpEditOptions'])){ + + if(count($this->dhcpHostEntry) == 0){ + $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE); + }else{ + $this->dialog = new dhcpHost($this->dhcpHostEntry,TRUE); + } + $this->dialog->cn = $this->cn; + $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress; + if(!empty($this->ipHostNumber)){ + $this->dialog->statements['fixed-address'] = $this->ipHostNumber; + } + } + + if(isset($_POST['cancel_dhcp'])){ + $this->dialog = FALSE; + } + + if(isset($_POST['save_dhcp'])){ + $this->dialog->save_object(); + + $msgs = $this->dialog->check(array()); + if(count($msgs)){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $this->dhcpHostEntry = $this->dialog->save(); + $this->dialog = FALSE; + } + } + + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + $smarty->assign("dhcpEnabled", $this->dhcpEnabled); + $smarty->assign("dhcp_is_Account",$this->dhcp_is_Account); + $smarty->assign("dhcpParentNode", $this->dhcpParentNode); + $smarty->assign("dhcpParentNodes",$this->dhcpParentNodes); + $smarty->assign("dhcpParentNodeCnt",count($this->dhcpParentNodes)); + + + /********** + * DNS Handling + **********/ + + /* There is no dns available + */ + if($this->DNSenabled == false){ + + /* Is IP address must ? */ + $smarty->assign("DNS_is_account",false); + $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account))); + + /* Assign smarty all non DNs attributes */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $smarty->assign("staticAddress","*"); + + $display.= $smarty->fetch(get_template_path('network.tpl', TRUE)); + }else{ + $smarty->assign("DNS_is_account",true); + + /* Add new empty array to our record list */ + if(isset($_POST['AddNewRecord'])){ + $this->dnsEntry['RECORDS'][] =array("type"=>"aRecord","value"=>""); + } + + /* propose_ip */ + if(isset($_POST['propose_ip'])){ + foreach($this->Zones as $key => $name){ + if($name == $this->dnsEntry['zoneName']){ + $net = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($key))); + $this->ipHostNumber = $this->generateRandomIp($net); + } + } + } + + /* Handle all posts */ + $only_once =true; + foreach($_POST as $name => $value){ + + /* Check if we have to delete a record entry */ + if((preg_match("/RemoveRecord_/",$name))&&($only_once)) { + + /* Avoid performing this once again */ + $only_once = false; + + /* Extract id for specified entry */ + $id = preg_replace("/RemoveRecord_/","",$name); + $id = preg_replace("/_.*$/","",$id); + + /* Delete this record, mark edited entries to be able to delete them */ + if(isset($this->dnsEntry['RECORDS'][$id])){ + unset($this->dnsEntry['RECORDS'][$id]); + } + } + } + /* Assign smarty all non DNs attributes */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign smarty all DNS attributes */ + foreach($this->DNSattributes as $attr){ + $smarty->assign($attr,$this->dnsEntry[$attr]); + } + + /* Assign all needed vars */ + $smarty->assign("DNSAccount",$this->DNS_is_account); + $smarty->assign("hide_dns_check_box",$this->hide_dns_check_box); + + $smarty->assign("Zones",$this->Zones); + $smarty->assign("ZoneCnt",count($this->Zones)); + $smarty->assign("ZoneKeys",($this->Zones)); + $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account))); + + /* Create zone array */ + $idZones = array(); + foreach($this->Zones as $id => $zone){ + if($this->netmaskIsCoherent($id)) { + $idZones[$id] = $zone; + }else{ + $idZones[$id] = $zone." ("._("Not matching").")"; + } + } + $smarty->assign("Zones",$idZones); + $smarty->assign("ZoneKeys", $this->Zones); + + $tmp = $this->generateRecordsList(); + + $changeStateForRecords = $tmp['changeStateForRecords']; + + $smarty->assign("records",$tmp['str']); + $smarty->assign("changeStateForRecords",$changeStateForRecords); + $smarty->assign("staticAddress","*"); + + $display.= $smarty->fetch(get_template_path('network.tpl', TRUE)); + } + return($display); + } + + + function remove_from_parent() + { + if($this->initially_was_account){ + + $ldap = $this->config->get_ldap_link(); + + $tmp = array(); + $this->dnsEntry['exists'] = false; + $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn); + + /* Delete dns */ + foreach($tmp['del'] as $dn => $del){ + $ldap->cd($dn); + $ldap->rmdir_recursive($dn); + new log("remove","unknown/".get_class($this),$dn); + } + } + } + + + /* Save data to object */ + function save_object() + { + + if(isset($_POST['network_tpl_posted'])){ + + /* Save all posted vars */ + plugin::save_object(); + + /* Handle DHCP Posts*/ + if($this->dhcpEnabled && isset($_POST['network_tpl_posted'])){ + foreach($this->dhcpAttributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + if(isset($_POST['dhcp_is_Account'])){ + $this->dhcp_is_Account = TRUE; + }else{ + $this->dhcp_is_Account = FALSE; + } + } + + /* Ge all non dns attributes (IP/MAC)*/ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){ + $this->$attr = $_POST[$attr]; + } + } + + /* Check if DNS should be enabled / disabled */ + if($this->DNS_is_account && $this->acl_is_removeable() && !isset($_POST['DNS_is_account'])){ + $this->DNS_is_account = false; + }elseif(!$this->DNS_is_account && $this->acl_is_createable() && isset($_POST['DNS_is_account'])){ + $this->DNS_is_account = true; + } + + /* Get dns attributes */ + if(($this->DNSenabled) && (isset($_POST['network_tpl_posted']))){ + + /* Check for posted record changes */ + if(is_array($this->dnsEntry['RECORDS']) && $this->acl_is_writeable("Records")){ + foreach($this->dnsEntry['RECORDS'] as $key => $value){ + + /* Check if type has changed */ + if(isset($_POST['RecordTypeSelectedFor_'.$key])){ + $this->dnsEntry['RECORDS'][$key]['type'] = $_POST['RecordTypeSelectedFor_'.$key]; + } + /* Check if value has changed */ + if(isset($_POST['RecordValue_'.$key])){ + $this->dnsEntry['RECORDS'][$key]['value'] = $_POST['RecordValue_'.$key]; + } + } + } + /* Get all basic DNS attributes (TTL, Clas ..)*/ + foreach($this->DNSattributes as $attr){ + if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){ + $this->dnsEntry[$attr] = $_POST[$attr]; + } + } + + + } + if($this->hide_dns_check_box){ + $this->DNS_is_account = true; + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if($this->dhcpEnabled && $this->dhcp_is_Account && $this->dhcpParentNode != "" && count($this->dhcpHostEntry) == 0){ +# $message[] =_("You have not configured your dhcp settings yet."); + } + + /* Check if mac and ip are already used */ + if(!empty($this->ipHostNumber) && $this->DNS_is_account && + $this->ipHostNumber != $this->orig_ipHostNumber && + in_array("ip:".$this->ipHostNumber,$this->used_ip_mac)){ + $message[] =_("The specified IP address is already in use."); + } + if(!empty($this->macAddress) && $this->dhcp_is_Account && + $this->macAddress != $this->orig_macAddress && + in_array("mac:".$this->macAddress,$this->used_ip_mac)){ + print_red(sprintf(_("The specified MAC address '%s' for this system '%s' is already in use."),$this->macAddress,$this->cn)); + } + + /* Check if ip must be given + */ + if(($this->IPisMust)||($this->DNS_is_account)){ + if (empty($this->ipHostNumber)){ + $message[]= _("The required field 'IP-address' is not set."); + } + + if (!is_ip($this->ipHostNumber)){ + $message[]= _("Wrong IP format in field IP-address."); + } + } + + /* Check if mac is empty + */ + if ($this->macAddress == "" ){ + $message[]= _("The required field 'MAC-address' is not set."); + } + if(!is_mac($this->macAddress)){ + $message[]=(_("The given macaddress is invalid. There must be 6 2byte segments seperated by ':'.")); + } + + /* only perfrom this checks if this is a valid DNS account */ + if($this->DNS_is_account){ + + $checkArray = array(); + $onlyOnce = array(); + + // $onlyOnce['cNAMERecord'] = 0; + $tmp = array_flip($this->Zones); + $tmp2 = $tmp[$this->dnsEntry['zoneName']]; + if(!$this->netmaskIsCoherent($tmp2)){ //this->dnsEntry['zoneName'])){ + $tmp2 = preg_replace("/^.*\//","",$tmp2); + $message[] =sprintf(_("The specified IP address '%s' is not matching the selected reverse zone entry '%s'."),$this->ipHostNumber,$tmp2); + } + + /* Walk through all entries and detect duplicates or mismatches + */ + foreach($this->dnsEntry['RECORDS'] as $name => $values){ + + /* Count record values, to detect duplicate entries for a specific record + */ + if(!isset($checkArray[$values['type']][$values['value']])){ + $checkArray[$values['type']][$values['value']] = 0; + }else{ + $message[] = sprintf(_("Found duplicate value for record type '%s'."),$values['type']); + } + + /* Check if given entries in $onlyOnce are used more than once + */ + if(isset($onlyOnce[$values['type']])){ + $onlyOnce[$values['type']] ++; + if($onlyOnce[$values['type']] > 1){ + $message[] = sprintf(_("Found more than one entry for the uniqe record type '%s'."),$values['type']); + } + } + + /* Skip txt record ... + */ + if($values['type'] == "tXTRecord") continue; + + /* Check if there is an aRecord defined which uses the same IP as used in IPhostAddress + */ + if(($values['type'] == "aRecord")&&($values['value'] == $this->ipHostNumber)){ + $message[]=sprintf(_("The device IP '%s' is added as 'A Record', this will be done automatically, please remove the record."), + $this->ipHostNumber); + } + + /* only lower-case is allowed in record entries ... + */ + if($values['value'] != strtolower($values['value'])){ + $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']); + } + } + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + $ldap= $this->config->get_ldap_link(); + + $dn = $this->parent->dn; + + /*******************/ + /* IP-MAC HANDLING */ + /*******************/ + + /* $dn was posted as parameter */ + $this->dn = $dn; + + /* Save DNS setting & ip/Mac*/ + plugin::save(); + + /* Write back to ldap */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /****************/ + /* DHCP HANDLING */ + /****************/ + + /* New entry */ + if($this->dhcpEnabled){ + + if(count($this->dhcpHostEntry) == 0){ + $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE); + $this->dialog->cn = $this->cn; + $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress; + if(!empty($this->ipHostNumber)){ + $this->dialog->statements['fixed-address'] = $this->ipHostNumber; + } + $this->dialog->execute(); + $this->dialog->save_object(); + $this->dhcpHostEntry = $this->dialog->save(); + if(count($this->dhcpHostEntry['dhcpOption']) == 0){ + $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn); + } + } + + if(count($this->dhcpHostEntry) == 0){ + $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE); + $this->dialog->cn = $this->cn; + $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress; + if(!empty($this->ipHostNumber)){ + $this->dialog->statements['fixed-address'] = $this->ipHostNumber; + } + $this->dialog->execute(); + $this->dialog->save_object(); + $this->dhcpHostEntry = $this->dialog->save(); + if(count($this->dhcpHostEntry['dhcpOption']) == 0){ + $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn); + } + } + + /* Write mac address to dhcp settings */ + if($this->dhcp_is_Account){ + if(!isset($this->dhcpHostEntry['dhcpHWAddress'][0]) || + !preg_match("/ethernet ".$this->macAddress."/",$this->dhcpHostEntry['dhcpHWAddress'][0])){ + $this->dhcpHostEntry['dhcpHWAddress'] = array("ethernet ".$this->macAddress); + $this->dhcpHostEntry['MODIFIED'] = TRUE; + } + } + + + /* Unset dhcpStatements if this attribute is empty */ + if(isset($this->dhcpHostEntry['dhcpStatements']) && + ($this->dhcpHostEntry['dhcpStatements'] == "" || count($this->dhcpHostEntry['dhcpStatements']) == 0) ){ + unset($this->dhcpHostEntry['dhcpStatements']); + } + + /* DHCP removed */ + if($this->initial_dhcp_is_Account && !$this->dhcp_is_Account){ + $ldap->rmdir_recursive($this->dhcpHostEntry['dn']); + show_ldap_error($ldap->get_error(),_("Removing dhcp entry for this object failed.")); + + $tmp = new servdhcp($this->config,$this->dhcpParentNode); + $tmp->handle_post_events("remove"); + } + + /* DHCP Added */ + if(!$this->initial_dhcp_is_Account && $this->dhcp_is_Account){ + $attrs = $this->dhcpHostEntry; + unset($attrs['MODIFIED']); + unset($attrs['dn']); + $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode); + $res = $ldap->add($attrs); + + $tmp = new servdhcp($this->config,$this->dhcpParentNode); + $tmp->handle_post_events("add"); + + show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed.")); + } + + /* DHCP still activated */ + if($this->initial_dhcp_is_Account && $this->dhcp_is_Account){ + + /* DHCP node changed */ + if(($this->initial_dhcpParentNode != $this->dhcpParentNode) || + ($this->cn != $this->OrigCn)){ + $attrs = $this->dhcpHostEntry; + $attrs['cn'] = $this->cn; + unset($attrs['dn']); + unset($attrs['MODIFIED']); + $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode); + $res = $ldap->add($attrs); + + $tmp = new servdhcp($this->config,$this->dhcpParentNode); + $tmp->handle_post_events("modify"); + + show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed.")); + if($res){ + $ldap->rmdir_recursive($this->dhcpHostEntry['dn']); + show_ldap_error($ldap->get_error(),_("Removing old dhcp entry failed.")); + } + } + + /* SAME node but modified */ + if(isset($this->dhcpHostEntry['MODIFIED']) && $this->dhcpHostEntry['MODIFIED'] == 1 && + $this->initial_dhcpParentNode == $this->dhcpParentNode){ + $attrs = $this->dhcpHostEntry; + unset($attrs['dn']); + unset($attrs['MODIFIED']); + $ldap->cd($this->dhcpHostEntry['dn']); + $ldap->modify($attrs); + + $tmp = new servdhcp($this->config,$this->dhcpParentNode); + $tmp->handle_post_events("modify"); + + show_ldap_error($ldap->get_error(),_("Modifying dhcp entry failed.")); + } + } + } + + + /****************/ + /* DNS HANDLING */ + /****************/ + + /* If isn't DNS account but initially was DNS account + remove all DNS entries + */ + if((!$this->DNSenabled) || ((!$this->DNS_is_account)&&(!$this->initially_was_account))){ + return; + }else{ + + /* Add ipHostNumber to aRecords + */ + $backup_dnsEntry = $this->dnsEntry; + if(!empty($this->ipHostNumber)){ + $this->dnsEntry['RECORDS'][] = array("type"=>"aRecord","value"=>$this->ipHostNumber); + $ptr = $this->get_pTRRecord(); + if(!empty($ptr)){ + $this->dnsEntry['RECORDS'][] = array("type"=>"pTRRecord","value"=>$ptr); + } + } + + /* Create diff and follow instructions + * If Account was disabled, remove account by setting exists to false + */ + if((!$this->DNS_is_account)&&($this->initially_was_account)){ + $this->dnsEntry['exists'] = false; + $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn); + }else{ + $this->dnsEntry['exists'] = $this->DNS_is_account; + $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn); + } + + /* move follwoing entries + */ + foreach($tmp['move'] as $src => $dst){ + $this->recursive_move($src,$dst); + } + + /* Delete dns */ + foreach($tmp['del'] as $dn => $del){ + $ldap->cd($dn); + $ldap->rmdir_recursive($dn); + new log("modify","unknown/".get_class($this),$dn,array("*"),$ldap->get_error()); + } + + /* Add || Update new DNS entries + */ + foreach($tmp['add'] as $dn => $attrs){ + $ldap->cd($dn); + $ldap->cat($dn, array('dn')); + if(count($ldap->fetch())){ + $ldap->cd($dn); + $ldap->modify ($attrs); + }else{ + $ldap->cd($dn); + $ldap->add($attrs); + } + new log("modify","unknown/".get_class($this),$dn,array_keys($attrs),$ldap->get_error()); + } + + + /* Display errors + */ + if($ldap->get_error() != "Success"){ + show_ldap_error($ldap->get_error(), sprintf(_("Saving of terminal/dns account with dn '%s' failed."),$this->dn)); + } + + $tmp2 = new servdns($this->config,$this->dn); + $tmp2->handle_post_events("modify"); + + $this->dnsEntry = $backup_dnsEntry; + } + } + + /* Create html table with all used record types + */ + function generateRecordsList() + { + $changeStateForRecords = ""; + + if(!$this->DNS_is_account) { + $str = ""; + return(array("str" => $str, "changeStateForRecords"=> "")); + } + + $str = ""; + foreach($this->dnsEntry['RECORDS'] as $key => $entry){ + + $changeStateForRecords.= "changeState('RecordTypeSelectedFor_".$key."');\n"; + $changeStateForRecords.= "changeState('RecordValue_".$key."');\n"; + $changeStateForRecords.= "changeState('RemoveRecord_".$key."');\n"; + + $str.=" ". + " ". + " ". + " ". + ""; + } + + $str.= " ". + " ". + " ". + "
".$this->generateRecordListBox($entry['type'],"RecordTypeSelectedFor_".$key)."
". + " ". + "
"; + $ret = array("str" => $str, "changeStateForRecords" => $changeStateForRecords); + return($ret); + } + + + /* Create a html select box which allows us to select different types of records + */ + function generateRecordListBox($selected,$name) + { + $str = ""; + return($str); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + $tmp = array( + "plShortName" => _("DNS"), + "plDescription" => _("DNS settings"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 5, + "plSection" => array("administration"), + "plCategory" => array("workstation","terminal","phone","server","component","printer","winworkstation"), + + "plProvidedAcls"=> array( + "ipHostNumber" => _("IP address"), + "macAddress" => _("MAC address")) + ); + + /* Hide all dns specific code, if dns is not available + */ + foreach($_SESSION['config']->data['TABS']['SERVERSERVICE'] as $tab){ + if(preg_match("/^servdns$/",$tab['CLASS'])){ + $tmp['plProvidedAcls']["Records"] = _("DNS records"); + $tmp['plProvidedAcls']["zoneName"] = _("Zone name"); + $tmp['plProvidedAcls']["dNSTTL"] = _("TTL"); + break; + } + } + return($tmp); + } + + + function get_dhcp_host_entry() + { + $attrs = array(); + $dn = $this->get_dhcp_host_entry_dn(); + if($dn){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($dn,array("*")); + if($ldap->count()){ + $attrs = $ldap->fetch(); + foreach($attrs as $key => $value){ + if(is_numeric($key) || ($key == "count")){ + unset($attrs[$key]); + } + if(is_array($value) && isset($value['count'])){ + unset($attrs[$key]['count']); + } + } + } + } + return($attrs); + } + + + function get_dhcp_host_entry_dn() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search ("(&(objectClass=dhcpHost)(cn=".$this->cn."))",array("cn","dn")); + + if($ldap->count()){ + $attr = $ldap->fetch(); + return($attr['dn']); + }else{ + return(""); + } + } + + + function get_dhcp_parent_node() + { + return(preg_replace("/^cn=".normalizePreg($this->cn).",/","",$this->get_dhcp_host_entry_dn())); + } + + + function get_dhcp_parent_nodes() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=dhcpService)",array("dhcpPrimaryDN")); + + $dhcp_dns = array(); + while($attr = $ldap->fetch()){ + $dhcp_dns[$attr['dn']] = $attr['dhcpPrimaryDN'][0]; + } + + foreach($dhcp_dns as $key => $pri_dns){ + $ldap->cat($pri_dns,array("cn")); + $tmp = $ldap->fetch(); + if(isset($tmp['cn'][0])){ + $dhcp_dns[$key] = $tmp['cn'][0]; + }else{ + unset($dhcp_dns[$key]); + } + } + + $tmp = $tmp2 = array(); + foreach($dhcp_dns as $dn => $cn){ + $ldap->cd($dn); + $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpGroup)". + "(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork))",array("cn")); + while($attr = $ldap->fetch()){ + $tmp[$attr['dn']] = $attr['cn'][0]; + } + $tmp2 = array_merge($tmp2,$this->create_tree($tmp,preg_replace("/^[^,]+,/i","",$dn),"(".$cn.") ")); + } + return($tmp2); + } + + + /* this function returns the default ptr record entry */ + function get_pTRRecord() + { + if(!empty($this->ipHostNumber) && isset($this->dnsEntry['zoneName']) && !empty($this->dnsEntry['zoneName'])){ + $ldap = $this->config->get_ldap_link(); + $ldap->cat(getDNSZoneDN($this->config,$this->dnsEntry['zoneName'])); + $attrs = $ldap->fetch(); + $tmp = array_flip($this->Zones); + $tmp = preg_replace("/^[^\/]*+\//","",$tmp[$this->dnsEntry['zoneName']]); + $tmp = trim(preg_replace("/\.in-addr.arpa$/","",$tmp)); + $ptr = preg_replace("/^".normalizePreg(FlipIp($tmp))."\./","",$this->ipHostNumber); + return($ptr); + }else{ + return(FALSE); + } + } + + + function generateRandomIP($net = "") + { + $str = $net; + $cnt = 4; + while(substr_count($str,".") < 3 && $cnt > 0){ + $str .= ".".rand(0,255); + $str = preg_replace("/\.\.*/",".",$str); + $str = trim($str,". "); + $cnt --; + } + return($str); + } + + + function create_tree($arr,$base,$current = "") + { + $ret = array(); + foreach($arr as $r => $name){ + $base_part = str_replace($base,"",$r); + if(preg_match("/^[a-z]*=".normalizePreg($name)."(|,)$/i",$base_part)){ + $ret[$r] = $current.$name; + $tmp = $this->create_tree($arr,$r,$current.". "); + foreach($tmp as $sub_key => $sub_name){ + $ret[$sub_key] = $sub_name; + } + } + } + return($ret); + } + + function force_dns() + { + if($this->DNSenabled){ + $this->DNS_is_account = TRUE; + $this->hide_dns_check_box = TRUE; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl b/gosa-core/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl new file mode 100644 index 000000000..9c0428c29 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl @@ -0,0 +1,27 @@ +

{t}This dialog allows you to configure all components of this DNS zone on a single list.{/t}

+

 

+{if $disableDialog} +
+ {t}This dialog can't be used until the currently edited zone was saved or the zone entry exists in the ldap database.{/t} + +{else} +
+ {$table} +
+ +{/if} + +

 

+
+

+ + +

+
+ + + diff --git a/gosa-core/plugins/admin/systems/services/dns/servdns.tpl b/gosa-core/plugins/admin/systems/services/dns/servdns.tpl new file mode 100644 index 000000000..6cfa50f09 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dns/servdns.tpl @@ -0,0 +1,63 @@ +{if $dns_take_over} + + + + +
+

{t}DNS take over initiated{/t}

+ {$warning} + {t}This includes 'all' DNS zones that are located within this server. Please double check if your really want to do this.{/t} +

+ {$warning2} +
+ +

+

+ {t}Following objects will be taken over{/t} : +

+

+

{$info}
+

+
+{else} + +{if $dns_server_list_cnt} + + + +{/if} + + + +
+ {t}Take over DNS configuration from{/t}  + + +
+

{t}Zones{/t}

+ {$ZoneList} + {if $is_createable} + + {else} + + {/if} +
+ + + + +{/if} +

 

+

+

+ +   + +
+

diff --git a/gosa-core/plugins/admin/systems/services/dns/servdnseditzone.tpl b/gosa-core/plugins/admin/systems/services/dns/servdnseditzone.tpl new file mode 100644 index 000000000..1136dba53 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/dns/servdnseditzone.tpl @@ -0,0 +1,177 @@ +

{t}Generic{/t}

+ + + + + +
+ + + + + + + + + + + + + +
{t}Zone name{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Network address{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Netmask{/t} + +{render acl=$ACLs} + +{/render} +
+
+ + + + + +
+ {t}Zone records{/t} +
+ {if $AllowZoneEdit == false} + {t}Can't be edited because the zone wasn't saved right now.{/t} + {/if} +
+{render acl=$ACLs} + +{/render} +
+
+

 

+

{t}SOA record{/t}

+ + + + + +
+ + + + + + + + + + + + + +
{t}Primary dns server for this zone{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Mail address{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Serial number (automatically incremented){/t}{$must} + +{render acl=$ACLs} + +{/render} +
+
+ + + + + + + + + + + + + + + + + +
{t}Refresh{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Retry{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}Expire{/t}{$must} + +{render acl=$ACLs} + +{/render} +
{t}TTL{/t}{$must} + +{render acl=$ACLs} + +{/render} +
+
+ +

 

+
+ + + + + +
+

{t}MxRecords{/t}

+ + + + +
+{render acl=$ACLs} + {$Mxrecords} +{/render} +{render acl=$ACLs} + +{/render} +{render acl=$ACLs} + +{/render} +
+
+

{t}Global zone records{/t}

+{render acl=$ACLs} + {$records} +{/render} +
+
+

+{render acl=$ACLs} + +{/render} + +

+
+ diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiAccount.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiAccount.inc new file mode 100644 index 000000000..e6411087a --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_glpiAccount.inc @@ -0,0 +1,806 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= FALSE; + var $attributes= array("ID","name","contact", + "tech_num","comments","date_mod","os","location","domain","network","contact_num", + "model","type","is_template","FK_glpi_enterprise","deleted"); + + var $ID ; // Is set if this entry is edited + var $name = ""; // This should be the dn of this entry + var $contact = ""; // Empty + + var $comments = ""; // Comment + + var $contact_num = ""; // Contact person + var $tech_num = ""; // Technical responsible person + + var $addUser = ""; // This is used to remember if a dialog was opened for tech_num or contact_num + + var $date_mod = ""; // Modification timestamp + var $os = 0; // Operating system + var $location = 0; // Not used yet + var $domain = 0; // ? Set to 0 + var $network = 0; // ? Set to 0 + + var $model = 0; // ? Can't remember this, it isn't used in GOsa + var $type = 0; // System type id + var $is_template = 0; // Used as template ? + var $FK_glpi_enterprise = 0; // Manufacturer id + var $deleted = "N"; // Deleted entries should have this set to Y + + var $renameTypeDialog = false; + var $renameOSDialog = false; + var $select_type ; + var $view_logged = FALSE; + + /* Not necessary, cause we use mysql databse */ + var $objectclasses= array("whatever"); + + /* Used to remember if this was an account (simply: is this an edited entry) */ + var $initially_was_account = false; + + /* Remember current dialog */ + var $edit_type = false; + var $edit_os = false; + + var $data; + var $handle = NULL; // Glpi class handle used to query database + + var $cur_dialog = NULL; // This contains the sub dialog handle + + var $orig_dn; // To check if dn, has changed + var $ui; // Some GOsa specific user informations + + var $usedDevices = array(); // Which devices are currently selected + var $usedAttachments = array(); // Used Attachments + + /* Contructor + Sets default values and checks if we already have an existing glpi account + */ + function glpiAccount (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + $this->ui= get_userinfo(); + + /* Abort class construction, if no db is defined */ + if(!isset($this->config->data['SERVERS']['GLPI'])){ + return; + } + + // Get informations about databse connection + $this->data = $this->config->data['SERVERS']['GLPI']; + + // Abort if mysql extension is missing + if(!is_callable("mysql_connect")){ + return; + } + + // Create handle of glpi class, and check if database connection is established + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + + if(!$this->handle->is_connected){ + return; + } + + // If this dn is already used in database, then get all informations for this entry + if($this->handle->is_account($this->dn)){ + $this->is_account = true; + $tmp = ($this->handle->getComputerInformations($this->dn)); + + foreach(array("tech_num","os","FK_glpi_enterprise","type","comments","contact_num") as $attr){ + $this->$attr = $tmp[0][$attr]; + } + $this->usedDevices = $this->handle->getUsedDevices($tmp[0]['ID']); + $atts = $this->handle->getAssignAttachments($tmp[0]['ID']); + foreach($atts as $attachment){ + + $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc']; + } + }else{ + $this->is_account = false; + } + + /* set defaults */ + $this->name = $this->dn; + $this->orig_dn = $this->dn; + $this->initially_was_account = $this->is_account; + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","all/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Assign smarty defaults + To avoid undefined indexes, if there is an error with the glpi db + */ + foreach(array("SystemTypes","SystemTypeKeys","Manufacturers", + "OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys", + "OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){ + $smarty->assign($attr,array()); + } + foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){ + $smarty->assign($attr,""); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation) { + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Check if there is a glpi database server defined + */ + if(!isset($this->config->data['SERVERS']['GLPI'])){ + print_red(_("There is no server with valid glpi database service.")); + return($smarty->fetch(get_template_path('glpi.tpl', TRUE))); + } + + $this->data = $this->config->data['SERVERS']['GLPI']; + + /* Check if we can call mysql_connect + If we can't, there is no the mysql-php extension + */ + if(!is_callable("mysql_connect")){ + print_red(_("Can't connect to glpi database, the php-mysql extension is missing.")); + return($smarty->fetch(get_template_path('glpi.tpl', TRUE))); + } + + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + + /* If handle == false, abort + Seems that the server, username and or password is wrong + */ + if(!$this->handle->is_connected){ + print_red(_("Can't connect to glpi database, check configuration twice.")); + return($smarty->fetch(get_template_path('glpi.tpl', TRUE))); + } + + /* All checks are ok + Lets handle Posts, templates etc below ... + */ + + $users = $this->handle->getUsers(); + $ldap= $this->config->get_ldap_link(); + + /* Check for Trading button Post + */ + if(isset($_POST['Trading'])){ + print_red(_("This feature is not implemented yet.")); + } + + /* Check for Software button Post + */ + if(isset($_POST['Software'])){ + print_red(_("This feature is not implemented yet.")); + } + + /* Check for Contract button Post + */ + if(isset($_POST['Contracts'])){ + print_red(_("This feature is not implemented yet.")); + } + + /* Add Device was requested, open new dialog + */ + if((isset($_POST['AddDevice'])) && ($this->acl_is_writeable("Devices"))){ + $this->dialog =true; + $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices); + } + + /* Attachment pool was closed with use + */ + if(isset($_POST['UseAttachment']) && ($this->acl_is_writeable("Attachments"))){ + if(count($this->cur_dialog->check())){ + foreach($this->cur_dialog->check() as $msg){ + print_red($msg); + } + }else{ + $this->cur_dialog->save_object(); + $this->usedAttachments = $this->cur_dialog->save(); + $this->cur_dialog = false; + $this->edit_type = false; + } + } + + /* Attachment pool was closed with abort + */ + if(isset($_POST['AbortAttachment'])){ + $this->cur_dialog = false; + $this->edit_type = false; + } + + /* Open Attachment pool to add/edit Attachments + */ + if(isset($_POST['AddAttachment']) && ($this->acl_is_writeable("Attachments"))){ + $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments); + $this->dialog = true; + } + + /* Remove Attachment fro this tab + */ + $once = true; + foreach($_POST as $name => $value){ + if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){ + $once= false; + $name = preg_replace("/^delAttachment_/","",$name); + $entry = preg_replace("/_.*$/","",$name); + if(isset($this->usedAttachments[$entry])){ + unset($this->usedAttachments[$entry]); + } + } + } + if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && ($this->acl_is_writeable("Attachments"))){ + foreach($_POST['Attachments'] as $entry){ + if(isset($this->usedAttachments[$entry])){ + unset($this->usedAttachments[$entry]); + } + } + } + + /* We have selected some devices and pressed use button + */ + if(isset($_POST['SelectDeviceSave']) && $this->acl_is_writeable("Devices")){ + $this->cur_dialog->save_object(); + $this->usedDevices= ($this->cur_dialog->getSelected()); + $this->cur_dialog = false; + $this->dialog = false; + $this->edit_type=false; + } + + /* Aborted Device selction + */ + if(isset($_POST['SelectDeviceCancel']) && ($this->acl_is_writeable("Devices"))){ + $this->dialog = false; + $this->cur_dialog = false; + $this->edit_type=false; + } + + /* System type management + */ + if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){ + $this->dialog = true; + $this->edit_type=true; + } + + /* This closes the system type editing dialog + */ + if(isset($_POST['close_edit_type']) && ($this->acl_is_writeable("type"))){ + $this->edit_type=false; + $this->dialog = false; + } + + if(isset($_POST['Rename_Cancel'])){ + $this->renameTypeDialog = false; + $this->renameOSDialog = false; + } + + /* This appends a new system to our sytem types + */ + if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){ + $attr = $this->handle->getSystemTypes(); + if(in_array(trim($_POST['type_string']),$attr)){ + print_red(_("Adding new sytem type failed, this system type name is already used.")) ; + }else{ + $this->handle->addSystemType(trim($_POST['type_string'])); + } + } + + /* Remove selected type from our system types list + */ + if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){ + $tmp = $this->handle->is_systemTypeUsed($_POST['select_type']); + if(count($tmp)){ + $names = ""; + foreach($tmp as $name){ + $names .= ", ".$name; + } + $names = preg_replace("/^, /","",$names); + $names = trim($names); + if(count($tmp) == 3){ + $names .= " ..."; + } + print_red(sprintf(_("You can't delete this system type, it is still in use by these system(s) '%s'"),$names)); + }else{ + $this->handle->removeSystemType($_POST['select_type']); + } + } + + /* Rename selected system type to given string + */ + if(isset($_POST['Rename_type_OK'])){ + $attr = $this->handle->getSystemTypes(); + if(in_array(trim($_POST['string']),$attr)){ + print_red(_("Rename failed, this system type name is already used.")) ; + }else{ + $this->renameTypeDialog = false; + $this->handle->updateSystemType($_POST['string'],trim($this->select_type)); + } + } + + + if((isset($_POST['rename_type'])&&(!empty($_POST['select_type'])))||($this->renameTypeDialog)){ + if(isset($_POST['select_type'])){ + $this->select_type = $_POST['select_type']; + } + $this->renameTypeDialog = true; + $tmp = $this->handle->getSystemTypes(); + + $smarty->assign("string",$tmp[$this->select_type]); + if(isset($_POST['string'])){ + $smarty->assign("string",$_POST['string']); + } + $smarty->assign("Method","rename"); + $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE)); + return($display); + } + + + + /* Someone wants to edit the system types ... + So, lets open a new dialog which provides some buttons to edit the types + */ + if($this->edit_type){ + $smarty->assign("Method","edit"); + $smarty->assign("SystemTypes", $this->handle->getSystemTypes()); + $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes())); + $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE)); + return($display); + } + + /* System os management + */ + if(isset($_POST['edit_os']) && $this->acl_is_writeable("os")){ + $this->dialog = true; + $this->edit_os=true; + } + + /* Close Operating system dialog + */ + if(isset($_POST['close_edit_os'])){ + $this->edit_os=false; + $this->dialog = false; + } + + /* Add new os to the db + */ + if((isset($_POST['add_os']))&&(!empty($_POST['is_string'])) && $this->acl_is_writeable("os")){ + $attr = $this->handle->getOSTypes(); + if(in_array(trim($_POST['is_string']),$attr)){ + print_red(_("Adding new operating system failed, specifed name is already used.")) ; + }else{ + $this->handle->addOS(trim($_POST['is_string'])); + } + } + + /* Delete selected os from list and db + */ + if((isset($_POST['del_os']))&&(!empty($_POST['select_os'])) && $this->acl_is_writeable("os")){ + $tmp = $this->handle->is_osUsed($_POST['select_os']); + + if(count($tmp)){ + + $names = ""; + foreach($tmp as $name){ + $names .= ", ".$name; + } + $names = preg_replace("/^, /","",$names); + $names = trim($names); + if(count($tmp) == 3){ + $names .= " ..."; + } + print_red(sprintf(_("You can't delete this operating system, it is still in use by these system(s) '%s'"),$names)); + + }else{ + $this->handle->removeOS_byID($_POST['select_os']); + } + } + + /* Rename selected os to given string + */ + if(isset($_POST['Rename_os_OK']) && $this->acl_is_writeable("os")){ + $attr = $this->handle->getOSTypes(); + if(in_array(trim($_POST['string']),$attr)){ + print_red(_("Updating operating system failed, specifed name is already used.")) ; + }else{ + $this->handle->updateOS($_POST['string'],$this->select_type); + $this->renameOSDialog = false; + } + } + if((isset($_POST['rename_os'])&&(!empty($_POST['select_os'])))||($this->renameOSDialog)){ + if(isset($_POST['select_os'])){ + $this->select_type = $_POST['select_os']; + } + $this->renameOSDialog = true; + $tmp = $this->handle->getOSTypes(); + + $smarty->assign("string",$tmp[$this->select_type]); + if(isset($_POST['string'])){ + $smarty->assign("string",$_POST['string']); + } + $smarty->assign("Method","rename"); + $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE)); + return($display); + } + + /* Open dialog to edit os types + */ + if($this->edit_os){ + $smarty->assign("Method","edit"); + $smarty->assign("OSs", $this->handle->getOSTypes()); + $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes())); + $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE)); + return($display); + } + + + + /* Show dialog to select a new contact person + * Select a contact person + */ + if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){ + $this->addUser = "contact"; + $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num"); + $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category)); + $this->cur_dialog->set_acl_base($this->dn); + + } + + /* Open dialog which allows to edit the manufacturers + */ + if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){ + $this->cur_dialog = new glpiManufacturer($this->config,$this->dn); + $this->dialog = true; + } + + /* Close manufacturer editing dialog + */ + if(isset($_POST['close_edit_manufacturer'])){ + $this->dialog = false; + $this->cur_dialog = false; + } + + /* Abort user selection + */ + $smarty->assign("AbortSelectUser","SelectUserCancel"); + if(isset($_POST['SelectUserCancel'])){ + $this->dialog = false; + $this->addUser =""; + $this->cur_dialog = false; + } + + /* Selecte technical responsible person + */ + if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){ + $this->addUser ="tech"; + $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num"); + $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category)); + $this->cur_dialog->set_acl_base($this->dn); + } + + /* Technical responsible person selected*/ + if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")&&(strlen($_GET['id']) > 100)){ + print_red(sprintf(_("Could not add the given user, the users dn is too long, only 100 characters are allowed here."))); + + }elseif(isset($_GET['act'])&&($_GET['act']=="user_tech_num") && strlen($_GET['id'])){ + + + /* Get posted id */ + $id = base64_decode($_GET['id']); + + /* Check if user is already created in glpi database */ + if(!in_array($id,$users)){ + + /* If this user doesn't exists in glpi db, we must create him */ + $ldap->cat($id, array('cn', 'mail', 'telephoneNumber')); + $atr = $ldap->fetch(); + $tmp = array(); + $use = array( "cn" =>"name", + "mail" =>"email", + "telephoneNumber" =>"phone"); + + /* Create array */ + foreach($use as $gosa => $glpi){ + if(isset($atr[$gosa])){ + $tmp[$glpi]= $atr[$gosa][0]; + } + } + + /* Add this user */ + $this->handle->addUser($tmp,$id); + } + + /* Re-read users */ + $users = ($this->handle->getUsers()); + + /* Get user */ + $tmp = array_flip($users); + $id=$tmp[$id]; + + /* Use user id, close dialog */ + if($this->addUser == "tech"){ + $this->tech_num = $id; + }else{ + $this->contact_num = $id; + } + $this->cur_dialog = false; + $this->dialog= false; + } + + /* if( cur_dialog != false || cur_dialog != NULL) + * There is a dialog which wants to be displayed + */ + if(isset($this->cur_dialog) && is_object($this->cur_dialog)){ + $this->cur_dialog->save_object(); + $this->dialog=true; + $this->cur_dialog->parent = &$this; + return($this->cur_dialog->execute()); + }else{ + $this->dialog= false; + } + + /* Assign smarty defaults */ + foreach(array("SystemTypes","SystemTypeKeys","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){ + $smarty->assign($attr,array()); + } + + /* Assign some vars to smarty + */ + foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){ + $smarty->assign($attr,""); + } + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Show tab dialog headers */ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove inventory"), + _("This device has inventory informations enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Add inventory"), + _("This device has inventory informations disabled. You can enable them by clicking below.")); + return ($display); + } + + /* Assign system types + */ + $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes())); + $smarty->assign("SystemTypes", $this->handle->getSystemTypes()); + $smarty->assign("type", $this->type); + + /* Assign os types + */ + $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes())); + $smarty->assign("OSs", $this->handle->getOSTypes()); + $smarty->assign("os", $this->os); + + /* Dispaly installed devices */ + $smarty->assign("InstalledDevices" ,$this->getDevices()); + $smarty->assign("InstalledDeviceKeys" ,array_flip($this->getDevices())); + + /* Append manufacturers + */ + $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises())); + $smarty->assign("Manufacturers", $this->handle->getEnterprises()); + $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise); + + /* Assign used Attachments + */ + + $divlist = new divSelectBox("glpiAttachmentsList"); + $divlist-> SetHeight(130); + $atts = $this->getUsedAttachments(true); + $downlink = "%s"; + $del_link = ""; + foreach($atts as $id => $attachment){ + $divlist->AddEntry + ( + array( + array("string"=>$attachment['name']), + array("string"=>$attachment['mime']), + array("string"=>sprintf($downlink,$id,$attachment['filename'])), + array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"), + ) + ); + } + + $smarty->assign("AttachmentsDiv" ,$divlist->DrawList()); + /* Handle contact person + Assign name ... to smarty, if set + */ + if(isset($users[$this->contact_num])){ + $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid')); + $tr = $ldap->fetch(); + $str = ""; + if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } + if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } + if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } + $smarty->assign("contact_num", $str); + }else{ + $smarty->assign("contact_num", _("N/A")); + } + + /* Handle tech person + Assign name ... to smarty, if set + */ + if(isset($users[$this->tech_num])){ + $tr = $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid')); + $tr = $ldap->fetch(); + $str = ""; + if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } + if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } + if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } + $smarty->assign("tech_num", $str); + }else{ + $smarty->assign("tech_num", _("N/A")); + } + $smarty->assign("comments", $this->comments); + + $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){ + return; + } + if(function_exists("mysql_pconnect")){ + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + if($this->initially_was_account){ + $this->handle->removeComputerInformations($this->dn); + new log("remove","undefined/".get_class($this),$this->dn); + } + }else{ + print_red(_("Can't remove glpi account, while mysql extension is missing.")); + new log("remove","undefined/".get_class($this),$this->dn,array(),_("Can't remove glpi account, while mysql extension is missing.")); + } + + } + + function getDevices(){ + $ret = array(); + foreach($this->usedDevices as $type => $entries){ + foreach($entries as $ent){ + if(isset($ent['designation'])){ + $ret[] = $ent['designation']." [".$type."]"; + }else{ + $ret[] = $ent['name']." [".$type."]"; + } + } + } + return($ret); + } + + + /* Save data to object */ + function save_object() + { + if(!isset($_POST['glpi_tpl_posted'])) { + return ; + } + plugin::save_object(); + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + // if($this->TechnicalResponsible == ""){ + // $message[] = _("Please select a technical responsible person for this entry."); + // } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + if($this->is_account){ + $attrs = array(); + $this->date_mod = date("Y-m-d H:i:s"); + foreach($this->attributes as $attr){ + $attrs[$attr] = $this->$attr; + } + $attrs['name'] = $this->dn; + unset($attrs['ID']); + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + + /* check if we have to update, add */ + if($this->initially_was_account&&$this->is_account){ + $this->handle->updateComputerInformations($attrs,$this->orig_dn); + new log("modify","undefined/".get_class($this),$this->dn); + }elseif($this->is_account){ + $this->handle->addComputerInformations($attrs,$this->dn); + new log("create","undefined/".get_class($this),$this->dn); + } + $tmp = $this->handle->getComputerInformations($this->dn); + $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']); + } + } + + + /* Return used attachments */ + function getUsedAttachments($divlist = false) + { + $atts =$this->handle->getAttachments(); + $ret = array(); + foreach($atts as $entry){ + if(in_array($entry['ID'],$this->usedAttachments)){ + if($divlist){ + $ret[$entry['ID']] = $entry; + }else{ + $cm =""; + if(isset($entry['comment'])){ + $cm=" [".$entry['comment']."]"; + } + if(isset($entry['mime'])){ + $cm.=" -".$entry['mime'].""; + } + + $ret[$entry['ID']]= $entry['name'].$cm; + } + } + } + return($ret); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Glpi"), + "plDescription" => _("Inventory extension"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 20, + "plSection" => array("administration"), + "plCategory" => array("workstation","terminal","component","server","phone") , + "plProvidedAcls"=> array( + + "tech_num" => _("Technical responsible"), + "comments" => _("Comment"), + "os" => _("Operating system"), + "location" => _("Location"), + "contact_num" => _("Contact person"), + "model" => _("Model"), + "type" => _("Type"), + "FK_glpi_enterprise" => _("Manufacturer"), + "Attachments" => _("Attachments"), + "Devices" => _("Peripheral devices")) + )); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc new file mode 100644 index 000000000..b50066029 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc @@ -0,0 +1,362 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("name","comment","mime","filename","date_mod"); + var $objectclasses = array("whatever"); + + var $parent; + var $edit = false; + var $entry = false; + var $date_mod =""; + var $name =""; + var $comment =""; + var $mime =""; + var $filename =""; + + var $Selected = array(); + + var $delAttach= ""; + + function glpiAttachmentPool (&$config, $dn= NULL,$used=NULL) + { + plugin::plugin ($config, $dn); + if(!isset($_SESSION['GlpiAttachmentFilter'])){ + $_SESSION['GlpiAttachmentFilter'] = array("filter"=>"*"); + } + + /* Assign used attributes */ + if($used !== NULL){ + $this->Selected = $used; + } + } + + function execute() + { + plugin::execute(); + $attach = $this->parent->handle->getAttachments(); + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + $only_once = true; + + /* walk through all posted objects */ + foreach($_POST as $name => $value){ + + /* Open dialog to create a new entry */ + if(preg_match("/new_attach/",$name)){ + $this->edit = true; + $this->entry=array(); + + /* Set default values */ + foreach($this->attributes as $attr) { + $this->$attr = ""; + $this->entry[$attr]=""; + } + } + + /* Remove attach*/ + if((preg_match("/^delAttach_/",$name))&&($only_once)){ + $only_once = false; + $str = preg_replace("/^delAttach_/","",$name); + $str = base64_decode(preg_replace("/_.*$/","",$str)); + + /* remove attach from db */ + $this->delAttach = $str; + $smarty->assign("warning", sprintf(_("You're about to delete the glpi attachment component '%s'."), $attach[$str]['name'])); + return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE))); + } + + /* Start editing entry */ + if((preg_match("/^editAttach_/",$name))&&($only_once)){ + $only_once = false; + $str = preg_replace("/^editAttach_/","",$name); + $str = base64_decode(preg_replace("/_.*$/","",$str)); + + /* Check if we have an attachment with given ID */ + foreach($attach as $att ){ + if($att['ID'] == $str ){ + + /* Entry was found, show dialog */ + $this->edit = true; + $this->entry = $att; + + foreach($att as $name => $value){ + $this->$name = $value; + } + } + } + } + } + + if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){ + if($this->parent->handle->is_attachmentUsed($this->delAttach)){ + $tmp = $this->parent->handle->is_attachmentUsed($this->delAttach); + + $names = ""; + foreach($tmp as $name){ + $names .= ", ".$name; + } + $names = preg_replace("/^, /","",$names); + $names = trim($names); + if(count($tmp) == 3){ + $names .= " ..."; + } + print_red(sprintf(_("You can't delete this attachment, it is still in use by these system(s) '%s'"),$names)); + + }else{ + $this->parent->handle->deleteAttachment($this->delAttach); + @unlink(CONFIG_DIR."/glpi/".$this->filename); + $attach = $this->parent->handle->getAttachments(); + } + } + + /* Someone tries to upload a file */ + if(($this->edit == true)&&(isset($_POST['upload']))){ + if(!isset($_FILES['filename'])){ + print_red(_("There is no valid file uploaded.")); + }else{ + $FILE = $_FILES['filename']; + if(!isset($FILE['name'])){ + print_red(_("There is no valid file uploaded.")); + }else{ + if($FILE['error']!=0) { + print_red(_("Upload wasn't successfull.")); + }else{ + if(!is_dir(CONFIG_DIR."/glpi/")){ + print_red(sprintf(_("Missing directory '%s/glpi/' to store glpi uploads."),CONFIG_DIR)); + }else{ + $filen = CONFIG_DIR."/glpi/".$FILE['name']; + if(file_exists($filen)){ + print_red(_("There is already a file with the same name uploaded.")); + }else{ + $fh = fopen($filen,"w"); + if(!$fh){ + print_red(sprintf(_("Can't create file '%s'."),$filen)); + }else{ + $str = file_get_contents($FILE['tmp_name']); + fwrite($fh,$str,strlen($str)); + fclose($fh); + $this->mime = $FILE['type']; + $this->filename = $FILE['name']; + } + } // File already exists + } + } // Check if any error occurred + } // check if valid filename was uploaded + } // ende check if file was uploaded + }// upload post + + /* save attachment*/ + if(($this->edit == true)&&(isset($_POST['SaveAttachment']))){ + if(count($this->check())==0){ + $this->date_mod = date("Y-m-d H:i:s"); + $this->save_entry(); + $this->edit= false; + $this->entry = array(); + $attach = $this->parent->handle->getAttachments(); + }else{ + foreach($this->check() as $msg){ + print_red($msg); + } + } + } + + /* Abort editing/adding attachment*/ + if(($this->edit == true)&&(isset($_POST['CancelAttachment']))){ + $this->edit = false; + $this->entry = array(); + } + + /* If edit == true, we have to show a dialog to edit or add an attach + */ + if($this->edit == true){ + foreach($this->attributes as $attr){ + $smarty->assign($attr,htmlentities(utf8_decode($this->$attr))); + } + if(!empty($this->filename)){ + if(is_readable(CONFIG_DIR."/glpi/".$this->filename)){ + $status =_("File is available."); + }else{ + $status =_("File is not readable, possibly the file is missing."); + } + }else{ + $status = _("Currently no file uploaded."); + } + $smarty->assign("status",$status); + return($smarty->fetch(get_template_path('glpiAttachmentEdit.tpl', TRUE))); + } + + /* Create list with checkboxes to select / deselect some attachents */ + $divlist = new divlist("Attachment"); + $divlist->SetPluginMode(); + $divlist->SetHeader(array( + array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), + array("string" => _("Name")), + array("string" => _("Mime"),"attach"=>"style='width:200px;'"), + array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); + + $divlist->SetSummary(_("This table displays all available attachments.")); + $divlist->SetEntriesPerPage(0); + + $editdel = ""; + $editdel.= ""; + + /* Add all given attachments to divlist + */ + foreach($attach as $entry){ + + /* Create display name*/ + if((empty($entry['name']))||(empty($entry['comment']))){ + + /* In glpi it is possible to add entries without name + so i've added this block + */ + if(empty($entry['name'])){ + $str1 = ""._("empty").""; + }else{ + $str1 = $entry['name']; + } + + if(!empty($entry['comment'])){ + $str1.= " [".$entry['comment']."]"; + } + }else{ + /* Both attributes given */ + $str1 = $entry['name']." [".$entry['comment']."]"; + } + + $edit = str_replace("%s",base64_encode($entry['ID']),$editdel); + $str2 = $entry['mime']." "; + + $chkbox = "". + ""; + + if(in_array($entry['ID'],$this->Selected)){ + $chkbox = preg_replace("/%CHECKED%/"," checked ",$chkbox); + }else { + $chkbox = preg_replace("/%CHECKED%/"," ",$chkbox); + } + $chkbox = preg_replace("/%s/",$entry['ID'],$chkbox); + $divlist->AddEntry(array( + array("string" => $chkbox, + "attach" => "style='text-align:center;width:20px;'"), + array("string"=> $str1), + array("string"=> $str2,"attach"=>"style='width:200px;'"), + array("string"=> $edit ,"attach" => "style='width:60px;border-right:0px;text-align:right;'") + )); + + } + + $listhead = "
". + "  ". + "
"; + + $smarty->assign("attachments", $divlist->DrawList()); + $smarty->assign("attachmenthead", $listhead); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("searchu_image", get_template_path('images/search_user.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info_small.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("attachment_regex", $_SESSION['GlpiAttachmentFilter']['filter']); + + $display.= $smarty->fetch(get_template_path('glpiAttachmentPool.tpl', TRUE)); + return($display); + } + + function save() + { + return($this->Selected); + } + + /* Adds new or saves edited entries */ + function save_entry() + { + if($this->edit){ + $tmp = array(); + foreach($this->attributes as $attr){ + $tmp[$attr] = $this->$attr; + } + $id = -1; + if(isset($this->entry['ID'])){ + $id = $this->entry['ID']; + } + $this->parent->handle->saveAttachments($tmp,$id); + } + } + + function save_object() + { + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + + /* Checkboxes are only posted, if they are checked + * To check if it was deselected, we check if wasOnPage + * was posted with given name, so we can deselect this entry + */ + + foreach($_POST as $name => $value){ + if(preg_match("/wasOnPage_/",$name)){ + $id=preg_replace("/wasOnPage_/","",$name); + if(isset($_POST["useMe_".$id])){ + $this->Selected[$id]=$id; + }else{ + if(isset($this->Selected[$id])){ + unset($this->Selected[$id]); + } + } + } + } + } + + /* Simple check */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if($this->edit){ + + /* check if given name is already in use */ + $att = $this->parent->handle->getAttachments(); + $ok = true; + $this->name=trim($this->name); + + foreach($att as $val){ + if(!isset($this->entry['ID'])){ + if($val['name'] == $this->name){ + $ok = false; + } + }else{ + if(($val['name'] == $this->name)&&($this->entry['ID'] != $val['ID'])){ + $ok = false; + } + } + } + if(!$ok){ + $message[] = _("This name is already in use."); + } + if(empty($this->name)){ + $message[] = _("Please specify a valid name for this attachment."); + } + } + return($message); + } + +}// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc new file mode 100644 index 000000000..0f24300d8 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc @@ -0,0 +1,427 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array(); + var $objectclasses= array("whatever"); + + var $devices = array(); + var $ui; + + var $parent ; + var $EditEntry; + var $editMode =false; + + var $DeviceAttrs = array(); + var $AllowedDevices = array(); + + var $Selected = array(); + + var $delete = array(); + + function glpiDeviceManagement (&$config, $dn= NULL,$used=NULL) + { + plugin::plugin ($config, $dn); + + if(!isset($_SESSION['glpiDeviceRegex'])){ + $tmp['device_regex'] = "*"; + $_SESSION['glpiDeviceRegex'] = $tmp; + } + $this->ui = get_userinfo(); + + if(isset($used)){ + $this->Selected = $used; + } + + /* Specify which vars are allowed for a sepcific type of device */ + $this->DeviceAttrs['case'] = array("designation","format","comment","FK_glpi_enterprise"); + $this->DeviceAttrs['moboard'] = array("designation","chipset","comment","FK_glpi_enterprise"); + $this->DeviceAttrs['processor'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default"); + $this->DeviceAttrs['iface'] = array("designation","bandwidth","comment","FK_glpi_enterprise","specif_default"); + $this->DeviceAttrs['ram'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default","type"); + $this->DeviceAttrs['hdd'] = array("designation","rpm","interface","cache","comment","FK_glpi_enterprise","specif_default"); + $this->DeviceAttrs['drive'] = array("designation","speed","interface","is_writer","comment","FK_glpi_enterprise","specif_default"); + $this->DeviceAttrs['control'] = array("designation","interface","raid","comment","FK_glpi_enterprise"); + $this->DeviceAttrs['gfxcard'] = array("designation","ram","interface","comment","FK_glpi_enterprise","specif_default"); + $this->DeviceAttrs['sndcard'] = array("designation","type","comment","FK_glpi_enterprise","specif_default"); + $this->DeviceAttrs['power'] = array("designation","power","comment","FK_glpi_enterprise","atx"); + $this->DeviceAttrs['pci'] = array("designation","comment","FK_glpi_enterprise","specif_default"); + $this->DeviceAttrs['monitor'] = array("name","comments","serial","otherserial","size", + "flags_micro","flags_speaker","flags_subd","flags_bnc", + "location","type","FK_glpi_enterprise","is_global","deleted","is_template","tplname"); + + $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci","monitor"); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Get all defined devices */ + $this->reload(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* this var is used to ensure that every post is only performed once */ + $only_once = true; + + /* Check Post for some actions */ + foreach($_POST as $name => $value){ + + /* If new_ then we should create an new device */ + if((preg_match("/^new_/",$name))&&($only_once)){ + + /* don't do this twice */ + $only_once = false; + + /*extract device device_type */ + $deviceType = preg_replace("/_.*$/","",preg_replace("/^new_/","",$name)); + + /* Check if type is allowed, and create empty entry */ + $tmp = array(); + if((!isset($this->DeviceAttrs[$deviceType]))||((!in_array($deviceType,$this->AllowedDevices)))){ + print_red(sprintf(_("Internal Error can't create device of type '%s'"),$deviceType)); + }else{ + foreach($this->DeviceAttrs[$deviceType] as $attr){ + $tmp[$attr] = ""; + } + $tmp['device_type'] = $deviceType; + $this->EditEntry = $tmp; + $this->editMode =true; + } + } + } + + /* delete was requested ... show dialog */ + if((isset($_GET['act']))&&($_GET['act']=="del_device")){ + $id = base64_decode($_GET['id']); + $tmp = $this->devices[$id]; + + $this->delete = $tmp; + + if(isset($tmp['name'])){ + $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['name'])); + }elseif(isset($tmp['designation'])){ + $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['designation'])); + }else{ + print_red(_("Can't detect object name.")); + } + + return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE))); + } + + /* Delete entry, but check if this device is in currently in use */ + if(isset($_POST['delete_glpi_confirm'])){ + if(count($this->parent->handle->is_deviceUsed($this->delete))){ + + $tmp = $this->parent->handle->is_deviceUsed($this->delete); + + $names = ""; + foreach($tmp as $name){ + $names .= ", ".$name; + } + $names = preg_replace("/^, /","",$names); + $names = trim($names); + if(count($tmp) == 3){ + $names .= " ..."; + } + print_red(sprintf(_("You can't delete this device, it is still in use by these system(s) '%s'"),$names)); + }else{ + $this->parent->handle->deleteDevice($this->delete); + $this->reload(); + } + } + + /* Open entry for editing if requested */ + if((isset($_GET['act']))&&($_GET['act']=="edit_device")){ + $id = base64_decode($_GET['id']); + $this->editMode =true; + $this->EditEntry = $this->devices[$id]; + } + + /* Abort editing this entry */ + if(isset($_POST['AbortDeviceChanges'])){ + $this->EditEntry = array(); + $this->editMode = false; + } + + /* Save all changes made on currently selected entry */ + if(isset($_POST['SaveDeviceChanges'])){ + + /* First check if all changes made are allowed */ + if(count($this->check())==0){ + $this->save(); + $this->editMode = false; + $this->reload(); + }else{ + foreach($this->check() as $msg){ + print_red($msg); + } + } + + } + + /* Check if we are currently editing something ? */ + if($this->editMode == true){ + return ($this->editDevice($this->EditEntry)); + } + + /* ENDE : GET / POST handling + * Below, only output generation for headpage + */ + + $divlist = new divlist("glpi devices"); + $divlist->SetPluginMode(); + $divlist->SetEntriesPerPage(0); + $divlist->SetHeader(array( + array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), + array("string" => _("devices"), "attach" => "style=''"), + array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); + + $edit = "%s"; + $editdel = ""._("Edit").""; + $editdel.= ""._("Delete").""; + + $useDevice = ""; + + foreach($this->devices as $key=>$user){ + + if(isset($user['designation'])){ + $str = "designation"; + }else{ + $str = "name"; + } + + if(isset($this->Selected[$user['device_type']][$user[$str]])){ + $use = " checked "; + }else{ + $use =""; + } + + /* Dawn databse struckture ....*/ + if(empty($user['comment']) && isset($user['comments'])) { + $user['comment'] = $user['comments']; + } + + $field1 = array("string" => preg_replace("/%s/",base64_encode($key),preg_replace("/%USE%/",$use,$useDevice)), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]." [".$user['comment']."]"), "attach" => "style=''"); + $field3 = array("string" => sprintf($editdel,base64_encode($key),base64_encode($key)), + "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + $divlist->AddEntry(array($field1,$field2,$field3)); + + } + + $listhead = "
". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "
"; + + $filter= $_SESSION['glpiDeviceRegex']; + $smarty->assign("devicehead", $listhead); + $smarty->assign("devices", $divlist->DrawList()); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("searchu_image", get_template_path('images/search_user.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info_small.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("device_regex", $filter['device_regex']); + + $display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE)); + return($display); + } + + /* Save device to glpi database + * If this is a new device, create a new entry, else update this entry + */ + function save() + { + if($this->parent->handle->deviceExists($this->EditEntry)){ + $this->parent->handle->updateDevices($this->EditEntry); + }else{ + $this->parent->handle->addDevice($this->EditEntry); + } + + } + + /* this only gets all already defined devices */ + function reload() + { + $this->devices = $this->parent->handle->getDevices(); + ksort($this->devices); + } + + /* This funtions saves all POST variables. + The variable must be in the array $this->EditEntry + */ + function save_object() + { + foreach($_POST as $name => $value){ + + if(preg_match("/wasOnPage_/",$name)){ + $dN = base64_decode($value); + + $device = $this->devices[$dN]; + $type = $device['device_type']; + + if(isset($device['designation'])){ + $str = "designation"; + }else{ + $str = "name"; + } + + if(isset($_POST['useDevice_'.$value])){ + $this->Selected[$type][$device[$str]] = $device; + }else{ + if(isset($this->Selected[$type][$device[$str]])){ + unset($this->Selected[$type][$device[$str]]); + } + } + } + } + + if(is_array($this->EditEntry)){ + foreach($this->EditEntry as $name => $value){ + if(isset($_POST[$name])){ + $this->EditEntry[$name] = $_POST[$name]; + } + + } + } + } + + /* returns the selected devices */ + function getSelected() + { + return($this->Selected); + } + + /* This function checks all created devices. + If you wan't to use device specific checks, + use >>if($attr['device_type']=="moboard")<< to create a device type depending check + */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + $attr = $this->EditEntry; + + if(isset($attr['designation'])){ + $str2 = "designation"; + }else{ + $str2 = "name"; + } + if(empty($attr[$str2])){ + $message[]=(_("You have to specify a valid name for this device.")); + } + + /* Avoid same name twice */ + $devices = ($this->parent->handle->getDevices()); + foreach($devices as $dev){ + + /* Some devices use designation some name for name + */ + if(isset($dev['designation'])){ + $str = "designation"; + }else{ + $str = "name"; + } + + if($dev[$str]==$attr[$str2]){ + + /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */ + if(isset($attr['ID'])){ + if(!(($dev['ID'] == $attr['ID'])&&($dev['device_type']==$attr['device_type']))){ + $message[] = _("This device name is already in use."); + } + }else{ + $message[] = _("This device name is already in use."); + } + } + } + + return($message); + } + + /* This functions displays the template for all available devices + * This function is also used if we create a new device + */ + function editDevice($entry) + { + $smarty = get_smarty(); + + /* Transfer given data to smarty */ + foreach($this->EditEntry as $name => $value){ + $smarty->assign($name,htmlentities(utf8_decode($value))); + } + + /* Set default select boxes, manufacturers ... */ + $smarty->assign("device_type",$entry['device_type']); + + $none = array(0 => _("none")); + $manufacturer = array_merge($none,$this->parent->handle->getEnterprises()); + + $ramtypes = $this->parent->handle->getRAMTypes(); + + $smarty->assign("RAMtypes", $ramtypes); + $smarty->assign("RAMtypeKeys", array_flip($ramtypes)); + + $deviceControlTypes = array_merge($none,$this->parent->handle->getGlpiDeviceControlTypes()); + + $smarty->assign("HDDInterfaceKeys",array_flip($deviceControlTypes)); + $smarty->assign("HDDInterfaces" , $deviceControlTypes); + + $gfxControlTypes = array("0"=>_("None"),"AGP"=>"AGP","PCI"=>"PCI","PCI-X"=>"PCI-X","Other"=>_("Other")); + + $smarty->assign("GFXInterfaceKeys",array_flip($gfxControlTypes)); + $smarty->assign("GFXInterfaces" , $gfxControlTypes); + + $smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer)); + $smarty->assign("FK_glpi_enterprises", $manufacturer); + + $smarty->assign("formats",array("Large","Medium","Micro")); + $smarty->assign("formats",array("Large","Medium","Micro")); + + $smarty->assign("formats",array("Large","Medium","Micro")); + $smarty->assign("formatKeys",array('Grand','Moyen','Micro')); + return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE))); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc new file mode 100644 index 000000000..8e676d8ee --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc @@ -0,0 +1,170 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email"); + var $objectclasses= array("whatever"); + + var $ui; + + var $editMode = false; + var $Edit_Add = "edit"; + + var $name =""; + var $type =""; + var $address =""; + var $website =""; + var $phonenumber=""; + var $comments =""; + var $deleted =""; + var $fax =""; + var $email =""; + var $ID =-1; + + function glpiManufacturer(&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + $this->ui = get_userinfo(); + } + + function execute() + { + plugin::execute(); + $smarty = get_smarty(); + $display = ""; + + /* Remove enterprise from db */ + if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){ + + $tmp = $this->parent->handle->is_manufacturerUsed($_POST['manufacturer']); + if(count($tmp)){ + + $names = ""; + foreach($tmp as $name){ + $names .= ", ".$name; + } + $names = preg_replace("/^, /","",$names); + $names = trim($names); + if(count($tmp) == 3){ + $names .= " ..."; + } + print_red(sprintf(_("You can't delete this manufacturer, it is still in use by these system(s) '%s'"),$names)); + }else{ + $this->parent->handle->removeEnterprise($_POST['manufacturer']); + } + } + + /* Add new Manufactuer : Open dialog with empty fields */ + if(isset($_POST['add_manu'])){ + $this->editMode = true; + $this->Edit_Add = "add"; + foreach($this->attributes as $atr){ + $this->$atr = ""; + } + } + + /* Edit existing manuatctuerer data */ + if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){ + $this->editMode = true; + $this->Edit_Add = "edit"; + $tmp = $this->parent->handle->getEnterprise($_POST['manufacturer']); + $tmp = $tmp[0]; + foreach($this->attributes as $atr){ + $this->$atr = ""; + } + foreach($this->attributes as $atr){ + if(isset($tmp[$atr])){ + $this->$atr = $tmp[$atr]; + } + } + $this->ID = $_POST['manufacturer']; + } + + /* close Dialog without saving */ + if(isset($_POST['close_manufacturer'])){ + $this->editMode=false; + } + + /* close dialog an save all changes / adds */ + if(isset($_POST['save_manufacturer'])){ + $tmp = array(); + foreach($this->attributes as $attrs){ + $tmp[$attrs]=$this->$attrs; + } + + $allok = true; + if(empty($tmp['name'])){ + print_red(_("Please specify a name.")); + $allok = false; + } + + $attr = $this->parent->handle->getEnterprises(); + + if($this->ID == -1 ){ + if(in_array($tmp['name'],$attr)){ + $allok = false; + print_red(_("Specified name is already in use, please choose another one.")); + } + }else{ + unset($attr[$this->ID]); + if(in_array($tmp['name'],$attr)){ + $allok = false; + print_red(_("Specified name is already in use, please choose another one.")); + } + } + + /* all checks are ok , so save changes */ + if($allok){ + if($this->Edit_Add == "add"){ + $this->parent->handle->addEnterprise($tmp); + $this->editMode=false; + }else{ + $this->parent->handle->updateEnterprise($tmp,$this->ID); + $this->editMode=false; + } + } + } + + /* As long as this war is true, we have to display the edit dialog */ + if($this->editMode == true){ + $this->save_object(); + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + $display.= $smarty->fetch(get_template_path('glpiManufacturerAdd.tpl', TRUE)); + return($display); + } + + + $smarty->assign("Manus", $this->parent->handle->getEnterprises()); + $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises())); + $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE)); + return($display); + } + + /* Save to LDAP */ + function save() + { + } + + function save_object() + { + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = stripslashes($_POST[$attr]); + } + } + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc new file mode 100644 index 000000000..049249cd5 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc @@ -0,0 +1,807 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= FALSE; + var $attributes= array("ID","name","contact","ramSize","flags_serial","flags_par","flags_usb", + "tech_num","comments","date_mod","location","domain","network","contact_num","serial","otherserial", + "type","is_template","FK_glpi_enterprise","deleted"); + + var $ID ; // Is set if this entry is edited + var $name = ""; // This should be the dn of this entry + var $FK_glpi_enterprise = 0; // Manufacturer id + var $tech_num = ""; // Technical responsible person + var $contact_num = ""; // Contact person + + var $comments = ""; // Comment + + var $type = 0; // printer type id + var $serial = ""; + var $otherserial = ""; + var $ramSize = 0; + var $flags_serial = false; + var $flags_par = false; + var $flags_usb = false; + + var $date_mod = ""; // Modification timestamp + + var $location = 0; // Not used yet + var $domain = 0; // ? Set to 0 + var $network = 0; // ? Set to 0 + + var $is_template = 0; // Used as template ? + var $contact = ""; // Empty + var $deleted = "N"; // Deleted entries should have this set to Y + + var $rename = false; + var $select_type ; + + var $editManufacturer = false; + + /* Not necessary, cause we use mysql databse */ + var $objectclasses= array("whatever"); + + /* Used to remember if this was an account (simply: is this an edited entry) */ + var $initially_was_account = false; + + /* Remember current dialog */ + var $edit_type = false; + var $edit_os = false; + + var $data; + var $handle = NULL; // Glpi class handle used to query database + + var $cur_dialog = NULL; // This contains the sub dialog handle + + var $orig_dn; // To check if dn, has changed + var $ui; // Some GOsa specific user informations + + var $usedDevices = array(); // Which devices are currently selected + var $usedAttachments = array(); // Used Attachments + var $usedCartridges = array(); // Used Cartridges + + var $view_logged = FALSE; + + /* Contructor + Sets default values and checks if we already have an existing glpi account + */ + function glpiPrinterAccount (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + $this->ui= get_userinfo(); + + $this->is_account = false; + + /* Abort class construction, if no db is defined */ + if(!isset($this->config->data['SERVERS']['GLPI'])){ + return; + } + + // Get informations about databse connection + $this->data = $this->config->data['SERVERS']['GLPI']; + + // Abort if mysql extension is missing + if(!is_callable("mysql_connect")){ + return; + } + + // Create handle of glpi class, and check if database connection is established + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + + if(!$this->handle->is_connected){ + return; + } + + // If this dn is already used in database, then get all informations for this entry + if($this->handle->is_printer_account($this->dn)){ + $this->is_account = true; + $tmp = ($this->handle->getPrinterInformations($this->dn)); + + foreach(array("tech_num","FK_glpi_enterprise","type","comments","contact_num","flags_serial","flags_par","flags_usb","ramSize") as $attr){ + $this->$attr = $tmp[0][$attr]; + } + + $atts = $this->handle->getAssignPrinterAttachments($tmp[0]['ID']); + foreach($atts as $attachment){ + $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc']; + } + + $cart= $this->handle->getUsedCartridges($tmp[0]['ID']); + foreach($cart as $key => $cartridge){ + $this->usedCartridges[$key]=$cartridge; + $this->usedCartridges[$key]['status']="exists"; + } + + + }else{ + $this->is_account = false; + } + + /* set defaults */ + $this->name = $this->dn; + $this->orig_dn = $this->dn; + $this->initially_was_account = $this->is_account; + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","printer/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $smarty->assign("CartridgesACL",$this->getacl("Cartridges")); + + /* Assign smarty defaults + To avoid undefined indexes, if there is an error with the glpi db + */ + foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers", + "Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){ + $smarty->assign($attr,array()); + } + foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){ + $smarty->assign($attr,""); + } + + /* Assign acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Check if there is a glpi database server defined + */ + if(!isset($this->config->data['SERVERS']['GLPI'])){ + print_red(_("There is no server with valid glpi database service.")); + return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE))); + } + + $this->data = $this->config->data['SERVERS']['GLPI']; + + /* Check if we can call mysql_connect + If we can't, there is no the mysql-php extension + */ + if(!is_callable("mysql_connect")){ + print_red(_("Can't connect to glpi database, the php-mysql extension is missing.")); + return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE))); + } + + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + + /* If handle == false, abort + Seems that the server, username and or password is wrong + */ + if(!$this->handle->is_connected){ + print_red(_("Can't connect to glpi database, check configuration twice.")); + return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE))); + } + + /* All checks are ok + Lets handle Posts, templates etc below ... + */ + + $users = $this->handle->getUsers(); + $ldap= $this->config->get_ldap_link(); + + + /* ########################################################################## + * Some tab management + */ + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Show tab dialog headers */ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove inventory"), + _("This server has inventory features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Add inventory"), + _("This server has inventory features disabled. You can enable them by clicking below.")); + return ($display); + } + + + /* ########################################################################## + * Printer type management + * Dialog + */ + + /* Rename was requested */ + if(isset($_POST['Rename_PType_OK']) && $this->acl_is_writeable("type")){ + $tmp = $this->handle->getPrinterTypes(); + $allok = true; + foreach($tmp as $id => $name){ + if(trim($name) == trim($_POST['string'])){ + $allok = false; + } + } + if($allok){ + $this->handle->updatePrinterType($_POST['string'],$this->select_type); + $this->rename = false; + }else{ + print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['string'])); + } + } + + /* abort rename + */ + if(isset($_POST['Rename_Cancel'])){ + $this->rename = false; + } + + /* Printer type management + */ + if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){ + $this->dialog = true; + $this->edit_type=true; + } + + /* This closes the printer type editing dialog + */ + if(isset($_POST['close_edit_type'])){ + $this->edit_type=false; + $this->dialog = false; + } + + /* This appends a new printer to our sytem types + */ + if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){ + + $tmp = $this->handle->getPrinterTypes(); + $allok = true; + foreach($tmp as $id => $name){ + if(trim($name) == trim($_POST['type_string'])){ + $allok = false; + } + } + if($allok){ + $this->handle->addPrinterType($_POST['type_string']); + }else{ + print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string'])); + } + } + + /* Remove selected type from our printer types list + */ + if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){ + $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']); + if(count($tmp)){ + $str = ""; + foreach($tmp as $id => $name){ + $str .= $name.", "; + } + $str = preg_replace("/, $/","",$str); + print_red(sprintf(_("Can't delete printer type, it is still in use by '%s'."),$str)); + }else{ + $this->handle->removePrinterType($_POST['select_type']); + } + } + + /* Rename selected printer type to given string + */ + if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename) && $this->acl_is_writeable("type")){ + $this->rename = true; + + $smarty->assign("Method","rename"); + + $tmp = $this->handle->getPrinterTypes(); + + if(isset($_POST['select_type'])){ + $this->select_type = $_POST['select_type']; + } + $smarty->assign("string",$tmp[$this->select_type]); + if(isset($_POST['string'])){ + $smarty->assign("string",$_POST['string']); + } + + $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE)); + return($display); + } + + /* Someone wants to edit the printer types ... + So, lets open a new dialog which provides some buttons to edit the types + */ + if($this->edit_type){ + $smarty->assign("Method","edit"); + $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes()); + $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes())); + $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE)); + return($display); + } + + + /* ########################################################################## + * Edit manufacturers + * Dialog + */ + + /* Open dialog which allows to edit the manufacturers + */ + if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){ + $this->cur_dialog = new glpiManufacturer($this->config,$this->dn); + $this->dialog = true; + $this->editManufacturer =true; + } + + /* Close manufacturer editing dialog + */ + if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){ + $this->dialog = false; + $this->cur_dialog = false; + $this->editManufacturer=false; + } + + + /* ########################################################################## + * Technical responsible person + * Contact person + * Dialog + */ + + /* Show dialog to select a new contact person + * Select a contact person + */ + if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){ + $this->addUser = "contact"; + $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num"); + } + + /* Selecte technical responsible person + */ + if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){ + $this->addUser ="tech"; + $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num"); + } + + /* Abort user selection + */ + $smarty->assign("AbortSelectUser","SelectUserCancel"); + if(isset($_POST['SelectUserCancel'])){ + $this->dialog = false; + $this->addUser =""; + $this->cur_dialog = false; + } + + /* Technical responsible/contact person selected */ + if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")){ + + /* Get posted id */ + $id = base64_decode($_GET['id']); + + /* Check if user is already created in glpi database */ + if(!in_array($id,$users)){ + + /* If this user doesn't exists in glpi db, we must create him */ + $ldap->cat($id, array('cn', 'mail', 'telephoneNumber')); + $atr = $ldap->fetch(); + $tmp = array(); + $use = array( "cn" =>"name", + "mail" =>"email", + "telephoneNumber" =>"phone"); + + /* Create array */ + foreach($use as $gosa => $glpi){ + if(isset($atr[$gosa])){ + $tmp[$glpi]= $atr[$gosa][0]; + } + } + + /* Add this user */ + $this->handle->addUser($tmp,$id); + } + + /* Re-read users */ + $users = ($this->handle->getUsers()); + + /* Get user */ + $tmp = array_flip($users); + $id=$tmp[$id]; + + /* Use user id, close dialog */ + if($this->addUser == "tech"){ + $this->tech_num = $id; + }else{ + $this->contact_num = $id; + } + $this->cur_dialog = false; + $this->dialog= false; + } + + + /* ########################################################################## + * Handle attachments + */ + + /* Attachment pool was closed with use + */ + if(isset($_POST['UseAttachment']) && $this->acl_is_writeable("Attachments")){ + if(count($this->cur_dialog->check())){ + foreach($this->cur_dialog->check() as $msg){ + print_red($msg); + } + }else{ + $this->cur_dialog->save_object(); + $this->usedAttachments = $this->cur_dialog->save(); + $this->cur_dialog = false; + $this->edit_type = false; + } + } + + /* Attachment pool was closed with abort + */ + if(isset($_POST['AbortAttachment'])){ + $this->cur_dialog = false; + $this->edit_type = false; + } + + /* Open Attachment pool to add/edit Attachments + */ + if(isset($_POST['AddAttachment']) && $this->acl_is_writeable("Attachments")){ + $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments); + $this->dialog = true; + } + + /* Remove Attachment from this tab + */ + $once = true; + foreach($_POST as $name => $value){ + if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){ + $once= false; + $name = preg_replace("/^delAttachment_/","",$name); + $entry = preg_replace("/_.*$/","",$name); + if(isset($this->usedAttachments[$entry])){ + unset($this->usedAttachments[$entry]); + } + } + } + if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && $this->acl_is_writeable("Attachments")){ + if(isset($this->usedAttachments[$_POST['Attachments']])){ + unset($this->usedAttachments[$_POST['Attachments']]); + } + } + + /* ########################################################################## + * Printer Cartridge handling + */ + + /* Abort cartridge select dialog + */ + if(isset($_POST['SelectCartridgeCancel'])){ + $this->cur_dialog = false; + $this->edit_type = false; + } + + /* Get selected cartridges and add them to our list + */ + if(isset($_POST['SelectCartridgeSave'])){ + $this->cur_dialog->save_object(); + $carts = $this->cur_dialog->save(); + foreach($carts as $cart){ + $cart['status'] = "new"; + $this->usedCartridges[] = $cart; + } + $this->cur_dialog = false; + $this->edit_type = false; + } + + /* Remove cartridge + */ + if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges'])) && $this->acl_is_writeable("ManageCartridges")){ + + foreach($_POST['Cartridges'] as $cartID){ + + if(isset($this->usedCartridges[$cartID])){ + if($this->usedCartridges[$cartID]['status'] == "exists"){ + $this->usedCartridges[$cartID]['status'] = "deleted"; + }else{ + unset($this->usedCartridges[$cartID]); + } + } + } + } + + /* Open Attachment pool to add/edit Attachments + */ + if(isset($_POST['AddCartridge']) && $this->acl_is_writeable("ManageCartridges")){ + $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type); + $this->dialog = true; + } + + + /* ########################################################################## + * Draw Dialogs + */ + /* if( cur_dialog != false || cur_dialog != NULL) + * There is a dialog which wants to be displayed + */ + if($this->cur_dialog && is_object($this->cur_dialog)){ + $this->cur_dialog->save_object(); + $this->dialog=true; + $this->cur_dialog->parent = &$this; + return($this->cur_dialog->execute()); + }else{ + $this->dialog= false; + } + + + /* ########################################################################## + * Assign listbox / checkbox .... values to smarty + */ + /* Assign smarty defaults */ + foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){ + $smarty->assign($attr,array()); + } + + /* Assign some vars to smarty + */ + foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){ + $smarty->assign($attr,""); + } + + $smarty->assign("comments", $this->comments); + $smarty->assign("flags_serial", $this->flags_serial); + $smarty->assign("flags_par", $this->flags_par); + $smarty->assign("flags_usb", $this->flags_usb); + + /* Assign system types + */ + $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes()); + $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes())); + $smarty->assign("type", $this->type); + + /* Append manufacturers + */ + $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises())); + $smarty->assign("Manufacturers", $this->handle->getEnterprises()); + $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise); + + /* Assign used Attachments + */ + + $divlist = new divSelectBox("glpiAttachmentsList"); + $divlist-> SetHeight(120); + $atts = $this->getUsedAttachments(true); + $downlink = "%s"; + $del_link = ""; + foreach($atts as $id => $attachment){ + $divlist->AddEntry + ( + array( + array("string"=>$attachment['name']), + array("string"=>$attachment['mime']), + array("string"=>sprintf($downlink,$id,$attachment['filename'])), + array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"), + ) + ); + } + + $smarty->assign("AttachmentsDiv" ,$divlist->DrawList()); + $smarty->assign("Attachments", $this->getUsedAttachments()); + $smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments())); + + /* Assign Cartridges + */ + $smarty->assign("Cartridges", $this->getUsedCartridges()); + $smarty->assign("CartridgeKeys", $this->getUsedCartridges(true)); + + /* ########################################################################## + * Assign contact and technical responsible person + */ + if(isset($users[$this->contact_num])){ + $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid')); + $tr = $ldap->fetch(); + $str = ""; + if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } + if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } + if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } + $smarty->assign("contact_num", $str); + }else{ + $smarty->assign("contact_num", _("N/A")); + } + + /* Handle tech person + Assign name ... to smarty, if set + */ + if(isset($users[$this->tech_num])){ + $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid')); + $tr = $ldap->fetch(); + $str = ""; + if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } + if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } + if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } + $smarty->assign("tech_num", $str); + }else{ + $smarty->assign("tech_num", _("N/A")); + } + + /* If theres a cartridge selected, you can't change the printer type. + */ + $disp = true; + + foreach($this->usedCartridges as $cart){ + if($cart['status'] != "deleted"){ + $disp = false; + } + } + if($disp==false){ + $smarty->assign("typeACL", $this->getacl("type",true)); + } + + $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + if($this->initially_was_account){ + $this->handle->removePrinterInformations($this->dn); + new log("remove","printer/".get_class($this),$this->dn); + } + } + + + /* Save data to object */ + function save_object() + { + if(isset($_POST['glpiPrinterFlagsPosted'])){ + plugin::save_object(); + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + } + } + + if(isset($_POST['FK_glpi_enterprise']) && $this->acl_is_writeable("FKglpienterprise")){ + $this->FK_glpi_enterprise = $_POST['FK_glpi_enterprise']; + } + + foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){ + if($this->acl_is_writeable($checkboxes)){ + if(isset($_POST[$checkboxes])){ + $this->$checkboxes = 1; + }else{ + $this->$checkboxes = 0; + } + } + } + } + + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + // if($this->TechnicalResponsible == ""){ + // $message[] = _("Please select a technical responsible person for this entry."); + // } + + return ($message); + } + + /* Save to LDAP */ + function save() + { + if($this->is_account){ + $attrs = array(); + $this->date_mod = date("Y-m-d H:i:s"); + foreach($this->attributes as $attr){ + $attrs[$attr] = $this->$attr; + } + $attrs['name'] = $this->dn; + unset($attrs['ID']); + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + if($this->initially_was_account&&$this->is_account){ + $this->handle->updatePrinterInformations($attrs,$this->dn); + new log("modify","printer/".get_class($this),$this->dn); + }elseif($this->is_account){ + $this->handle->addPrinterInformations($attrs,$this->dn); + new log("create","printer/".get_class($this),$this->dn); + } + $tmp = $this->handle->getPrinterInformations($this->dn); + $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']); + + foreach($this->usedCartridges as $cart){ + if($cart['status'] == "deleted"){ + $this->handle->removeCartridgeFromPrinter($cart['ID']); + }elseif($cart['status'] == "new"){ + $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']); + } + } + } + } + + /* Return used attachments */ + function getUsedAttachments($divlist = false) + { + $atts =$this->handle->getAttachments(); + $ret = array(); + foreach($atts as $entry){ + if(in_array($entry['ID'],$this->usedAttachments)){ + if($divlist){ + $ret[$entry['ID']] = $entry; + }else{ + $cm =""; + if(isset($entry['comment'])){ + $cm=" [".$entry['comment']."]"; + } + if(isset($entry['mime'])){ + $cm.=" -".$entry['mime'].""; + } + + $ret[$entry['ID']]= $entry['name'].$cm; + } + } + } + return($ret); + } + + function getUsedCartridges($flip = false) + { + $ret = array(); + foreach($this->usedCartridges as $key => $value){ + if($value['status'] == "deleted") continue; + if($flip){ + $ret[$key] = $key; + }else{ + $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use']; + } + } + return($ret); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Glpi"), + "plDescription" => _("Printer inventory extension"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 10, + "plSection" => array("administration"), + "plCategory" => array("printer"), + + "plProvidedAcls"=> array( + "flags_serial" => _("Supports serial interface"), + "flags_par" => _("Supports parallel interface"), + "flags_usb" => _("Supports usb interface"), + "tech_num" => _("Technical responsible"), + "comments" => _("Comments"), + "location" => _("Location"), + "contact_num" => _("Contact person"), + "type" => _("Type"), + "FKglpienterprise" => _("Manufacturer"), + + "Attachments" => _("Attachments"), + + "ManageCartridges" => _("Cartridge settings")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc new file mode 100644 index 000000000..3d9d63010 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc @@ -0,0 +1,298 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); + + var $parent = NULL; // Contains parent class, to access glpi db handle + var $usedCartridges = array(); // IDs of used cartridges for this printer + var $PrinterType = 0; // Specifies which cartridge types are available + + var $cur_dialog = false; + var $cur_sub_dialog = false; + + var $editManufacturer = false; + var $del = 0; + + + function glpiPrinterCartridges (&$config,$dn,$type) + { + plugin::plugin ($config, $dn); + + /* Assign some basic settings */ + $this->ui = get_userinfo(); + if(!isset($_SESSION['glpiCartridgeRegex'])){ + $_SESSION['glpiCartridgeRegex'] = "*"; + } + + /* Only display cartridges for this type of printer */ + $this->PrinterType = $type; + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + $display =""; + $smarty = get_smarty(); + $filter = $_SESSION['glpiCartridgeRegex']; + + /* Filter settings, remove double* */ + if(isset($_GET['search'])){ + $filter = preg_replace("/\*\**/","*",$_GET['search']."*"); + }elseif(isset($_POST['cartridge_regex'])){ + $filter = preg_replace("/\*\**/","*",$_POST['cartridge_regex']); + } + if(empty($filter)) { + $filter = "*"; + } + $_SESSION['glpiCartridgeRegex']= $filter; + + /* Open dialog which allows to edit the manufacturers + */ + if(isset($_POST['edit_manufacturer_cartridges'])){ + $this->cur_sub_dialog = new glpiManufacturer($this->config,$this->dn); + $this->dialog = true; + $this->editManufacturer =true; + } + + /* Close manufacturer editing dialog + */ + if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){ + $this->dialog = false; + $this->cur_sub_dialog = false; + $this->editManufacturer=false; + } + + /* Check poted vars and do the requested job, but only once */ + $only_once = true; + foreach($_POST as $name => $value){ + + /* We have to create a new cartridge */ + if(preg_match("/^newcartridge/",$name)&&($only_once)){ + $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType); + $only_once = false; + } + } + + /* Edit cartridge */ + if(isset($_GET['act'])&&$_GET['act']=="edit_cartridge"){ + $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id'])); + $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$_GET['id']]); + } + + /* remove cartridge */ + if(isset($_GET['act'])&&$_GET['act']=="del_cartridge"){ + /* remove attach from db */ + $this->del = $_GET['id']; + $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id'])); + $smarty->assign("warning", sprintf(_("You're about to delete the glpi cartridge type '%s'."), $val[$this->del]['name'])); + return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE))); + } + + if(isset($_POST['delete_cancel'])){ + $this->del = false; + } + + /* Delete this entry */ + if(isset($_POST['delete_glpi_confirm'])&&($this->del)) { + $tmp = $this->parent->handle->is_cartridgeTypeUsed($this->del); + if(count($tmp)){ + + $str = ""; + foreach($tmp as $id => $name){ + $str .= $name.", "; + } + $str = preg_replace("/, $/","",$str); + + print_red(sprintf(_("You can't delete this cartridge type, it is still in use by this printer(s) '%s'."),$str)); + }else{ + $val = ($this->parent->handle->getCartridgeTypeInformations($this->del)); + $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$this->del]); + $this->cur_dialog->parent = $this->parent; + $this->cur_dialog->remove_from_parent(); + $this->cur_dialog= false; + } + } + + /* Abort edit / add dialog */ + if(isset($_POST['CancelCartridge'])){ + $this->cur_dialog = false; + } + + /* Save changes if check is ok */ + if(isset($_POST['SaveCartridge'])){ + $this->cur_dialog->save_object(); + if(count($this->cur_dialog->check())) { + foreach($this->cur_dialog->check() as $checks){ + print_red($checks); + } + }else{ + $this->cur_dialog->save(); + $this->cur_dialog = false; + } + } + + /* If we have a dialog open, display it */ + if($this->cur_sub_dialog){ + $this->cur_sub_dialog->parent = $this->parent; + $this->cur_sub_dialog->save_object(); + return($this->cur_sub_dialog->execute()); + } + /* If we have a dialog open, display it */ + if($this->cur_dialog){ + $this->cur_dialog->parent = $this->parent; + $this->cur_dialog->save_object(); + return($this->cur_dialog->execute()); + } + + /* Create divlist */ + $divlist = new divlist("glpi devices"); + $divlist->SetPluginMode(); + $divlist->SetEntriesPerPage(0); + $divlist->SetHeader(array( + array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), + array("string" => _("Cartridges"), "attach" => "style=''"), + array("string" => _("Action"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); + + /* Links for editing,adding.... */ + $edit = "%s"; + $editdel = ""._("Edit").""; + $editdel.= ""._("Delete").""; + + /* Checkbox for selection of some cartridges */ + $useCartridge = ""; + + /* Add cartridges */ + $cart = $this->getCartridgeTypes(); + + /* Remove typically error possibilities */ + $f = str_replace("/","\/",$filter); + $f = str_replace(".","\.",$f); + $f = str_replace("*",".*",$f); + + /* Assign cartridges */ + foreach($cart as $key=>$cartr){ + + /* Skip if filter doesn't match*/ + if(!preg_match("/^".$f."$/i",$cartr['cartridgeName'])){ + continue; + } + + /* check if this cartridge is selected */ + $chk = ""; + if(isset($this->usedCartridges[$key])){ + $chk = " checked "; + } + + /* Add fields */ + $field1 = array("string" => preg_replace("/%s/",($key),preg_replace("/%CHECKED%/",$chk,$useCartridge)), + "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($edit,($key),$cartr['cartridgeName']." [".$cartr['cartridgeTypeName']."]"), + "attach" => "style=''"); + $field3 = array("string" => sprintf($editdel,($key),($key)), + "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + + $divlist->AddEntry(array($field1,$field2,$field3)); + + } + + /* Create list header */ + $listhead = "
". + "  ". + "
"; + + /* Tell smarty some vars */ + $filter= $_SESSION['glpiCartridgeRegex']; + $smarty->assign("devicehead", $listhead); + $smarty->assign("devices", $divlist->DrawList()); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("searchu_image", get_template_path('images/search_user.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info_small.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("cartridge_regex", $filter); + + $display.= $smarty->fetch(get_template_path('glpiPrinterCartridges.tpl', TRUE)); + return($display); + } + + /* Save device to glpi database + * If this is a new device, create a new entry, else update this entry + */ + function save() + { + $carts = $this->getCartridgeTypes(); + $ret = array(); + foreach($this->usedCartridges as $key){ + $tmp =array(); + $tmp['date_use'] = date("Y-m-d"); + $tmp['ID'] = -1; + $tmp['type_ID'] = $carts[$key]['cartridgeID']; + $tmp['name'] = $carts[$key]['cartridgeName']; + $tmp['FK_glpi_printers']= -1; + $tmp['type_name'] = $carts[$key]['cartridgeTypeName']; + $ret[$key] = $tmp; + } + return($ret); + } + + /* this only gets all already defined devices */ + function reload() + { + $this->devices = $this->parent->handle->getDevices(); + ksort($this->devices); + } + + /* This funtions saves all POST variables. + The variable must be in the array $this->EditEntry + */ + function save_object() + { + /* Checkbox handling + * Check which checkbox is selected + */ + foreach($_POST as $name => $value){ + if(preg_match("/wasOnPage/",$name)){ + $id = preg_replace("/wasOnPage_/","",$name); + if(isset($_POST['useCartridge_'.$id])){ + $this->usedCartridges[$id]=$id; + }else{ + unset($this->usedCartridges[$id]); + } + } + } + } + + /* This function cehck all created devices if you wan't to create device specific check + use >>if($attr['device_type']=="moboard")<< to create a device type depending check + */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + return($message); + } + + /* Return cartriges for our divlist */ + function getCartridgeTypes() + { + $ret = array(); + $ret = $this->parent->handle->getAvailableCartridgeTypes($this->PrinterType); + return($ret); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc new file mode 100644 index 000000000..e1d86fcb6 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc @@ -0,0 +1,337 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("ID","name","ref","location","type","FK_glpi_enterprise","tech_num","deleted","comments","alarm"); + var $objectclasses = array("whatever"); + + var $printer_type = 0; + + var $additional_printer= array(); + var $needToCatch = true; + + var $parent = NULL; + + var $ID = ""; + var $name = ""; + var $ref = ""; + var $location = ""; + var $type = ""; + var $FK_glpi_enterprise = ""; + var $tech_num = ""; + var $deleted = ""; + var $comments = ""; + var $alarm = ""; + + var $cur_dialog = false; + var $edit_type =false; + + + function glpiPrinterCartridgesEdit (&$config, $dn,$printer_type,$values = NULL ) + { + plugin::plugin ($config, $dn); + foreach($this->attributes as $val){ + if(isset($values[$val])){ + $this->$val = $values[$val]; + }else{ + $this->$val = ""; + } + } + $this->needToCatch = true; + $this->printer_type = $printer_type; + } + + function remove_from_parent() + { + if($this->ID > 0){ + $this->parent->handle->removeCartridgeDropdownType($this->ID); + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Get all currently used/supported printer types for this cartridge type + */ + if($this->needToCatch){ + $this->needToCatch = false; + if(!empty($this->type)){ + $this->additional_printer= $this->parent->handle->getSupportedPrinterTypeIDsForCartridge($this->ID); + } + } + + + + + + + /* Printer type management + */ + if(isset($_POST['edit_type_cartridge'])){ + $this->dialog = true; + $this->edit_type=true; + } + + /* This closes the printer type editing dialog + */ + if(isset($_POST['close_edit_type_cartridge'])){ + $this->edit_type=false; + $this->dialog = false; + } + + /* This appends a new printer to our sytem types + */ + if((isset($_POST['add_cartridge_type']))&&(!empty($_POST['cartridge_type_string']))){ + print "Add"; + $this->parent->handle->addCartridgeDropdownType($_POST['cartridge_type_string']); + } + + /* Remove selected type from our printer types list + */ + if((isset($_POST['del_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))){ + $used = $this->parent->handle->getUsedDropdownTypes($_POST['select_type_cartridge']); + if(!count($used)){ + $this->parent->handle->removeCartridgeDropdownType($_POST['select_type_cartridge']); + }else{ + print_red(_("Can't delete this entry, it is still in use.")); + } + } + + /* Rename selected printer type to given string + */ + /* Update*/ + if((isset($_POST['rename_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))&&(!empty($_POST['cartridge_type_string']))){ + $this->parent->handle->updateCartridgeDropdownType($_POST['cartridge_type_string'],$_POST['select_type_cartridge']); + } + + /* Someone wants to edit the printer types ... + So, lets open a new dialog which provides some buttons to edit the types + */ + if($this->edit_type){ + $smarty->assign("PrinterTypes", $this->parent->handle->getCartridgeTypes()); + $smarty->assign("PrinterTypeKeys", array_flip($this->parent->handle->getCartridgeTypes())); + $display= $smarty->fetch(get_template_path('glpi_edit_cartridge_type.tpl', TRUE)); + return($display); + } + + /* Assign attributes */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Selecte technical responsible person + */ + if(isset($_POST['SelectCartridgeTechPerson'])){ + $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_cartridge_tech_num"); + } + + /* Abort user selection + */ + $smarty->assign("AbortSelectUser","SelectCartridgeUserCancel"); + $smarty->assign("SaveSelectUser" ,"user_cartridge_tech_num"); + if(isset($_POST['SelectCartridgeUserCancel'])){ + $this->dialog = false; + $this->addUser =""; + $this->cur_dialog = false; + } + + /* Start ldap, and get all glpiUsers */ + $ldap = $this->config->get_ldap_link(); + $users = ($this->parent->handle->getUsers()); + + /* Technical responsible/contact person selected + */ + if(isset($_GET['act'])&&($_GET['act']=="user_cartridge_tech_num")){ + + /* Get posted id */ + $id = base64_decode($_GET['id']); + + /* Check if user is already created in glpi database */ + if(!in_array($id,$users)){ + + /* If this user doesn't exists in glpi db, we must create him */ + $ldap->cat($id, array('cn', 'mail', 'telephoneNumber')); + $atr = $ldap->fetch(); + $tmp = array(); + $use = array( "cn" =>"name", + "mail" =>"email", + "telephoneNumber" =>"phone"); + + /* Create array */ + foreach($use as $gosa => $glpi){ + if(isset($atr[$gosa])){ + $tmp[$glpi]= $atr[$gosa][0]; + } + } + + /* Add this user */ + $this->parent->handle->addUser($tmp,$id); + } + + /* Re-read users */ + $users = ($this->parent->handle->getUsers()); + + /* Get user */ + $tmp = array_flip($users); + $id=$tmp[$id]; + + /* Close dialog and use this user */ + $this->tech_num = $id; + $this->cur_dialog = false; + $this->dialog= false; + } + + /* Execute dialog*/ + if($this->cur_dialog){ + $this->cur_dialog->save_object(); + $this->dialog=true; + $this->cur_dialog->parent = &$this; + return($this->cur_dialog->execute()); + }else{ + $this->dialog= false; + } + + /* Create matrix with all possible printer types + */ + $matrix = ""; + $types = $this->parent->handle->getPrinterTypes(); + + /* Specifies number of cols */ + $spalten = 2; + + $spalt = $spalten; + foreach($types as $key => $type){ + $spalt -- ; + + /* Create new row, if cols for this row reached $spalten */ + if($spalt < 0) { + $spalt = $spalten -1; + $matrix .= ""; + } + + /* Avoid deselecting every checkbox */ + if($key == $this->printer_type){ + $matrix.= ""; + }else{ + + /* Cehck checkbox */ + $check = ""; + if(isset($this->additional_printer[$key])){ + $check = " checked "; + } + $matrix.= ""; + } + } + + /* Complete table row, to avoid html errors */ + if($spalt >0){ + while($spalt >0){ + $spalt -- ; + $matrix .=""; + } + } + + $matrix .= "
".$type."".$type." 
"; + + /* Append manufacturers + */ + $smarty->assign("PrinterTypeMatrix", $matrix); + + $smarty->assign("ManufacturerKeys", array_flip($this->parent->handle->getEnterprises())); + $smarty->assign("Manufacturers", $this->parent->handle->getEnterprises()); + $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise); + + $smarty->assign("typeKeys", array_flip($this->parent->handle->getCartridgeTypes())); + $smarty->assign("types", $this->parent->handle->getCartridgeTypes()); + $smarty->assign("type", $this->type); + + /* Handle tech person + Assign name ... to smarty, if set + */ + if(isset($users[$this->tech_num])){ + $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid')); + $tr = $ldap->fetch(); + $str = ""; + if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } + if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } + if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } + $smarty->assign("tech_num", $str); + }else{ + $smarty->assign("tech_num", _("N/A")); + } + + + $display.= $smarty->fetch(get_template_path('glpiPrinterCartridgesEdit.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + /* Check given values */ + function check(){ + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Avoid choosing an already used name */ + $types = $this->parent->handle->getCartridgeTypeInformations(); + foreach($types as $type){ + if($type['name'] == $this->name){ + if($type['ID'] != $this->ID){ + $message[]= _("The selected name is already in use."); + } + } + } + return $message; + } + + /* Save Post data */ + function save_object() + { + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr= $_POST[$attr]; + } + } + + /* Get selected checkboxes */ + foreach($_POST as $name => $value){ + if(preg_match("/wasOnPage_/",$name)){ + $id = preg_replace("/wasOnPage_/","",$name); + if(isset($_POST['UsePrinterType_'.$id])){ + $this->additional_printer[$id]=$id; + }else{ + if(isset($this->additional_printer[$id])){ + unset($this->additional_printer[$id]); + } + } + } + } + } + + /* Create / Update database with this new infos */ + function save() + { + $tmp = array(); + foreach($this->attributes as $attr){ + $tmp[$attr] = $this-> $attr; + } + $types = array(); + $types = $this->additional_printer; + $types[$this->printer_type]=$this->printer_type; + $this->parent->handle->Add_UpdateCatrigdeType($tmp,$types); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc new file mode 100644 index 000000000..7073b12a4 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc @@ -0,0 +1,285 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array(); + var $objectclasses= array("whatever"); + + var $users = array(); + var $departments = array(); + + var $ui; + + var $PostVarName = ""; + + function glpiSelectUser (&$config, $dn= NULL,$postvar) + { + plugin::plugin ($config, $dn); + + $this->PostVarName = $postvar; + + if(!isset($_SESSION['glpi_user_filter'])){ + $tmp['users_regex'] = "*"; + $tmp['base'] = $this->config->current['BASE']; + $_SESSION['glpi_user_filter'] = $tmp; + } + + $this->ui = get_userinfo(); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if(isset($_POST['depselect'])){ + $_SESSION['glpi_user_filter']['base'] = $_POST['depselect']; + } + + $filter = $_SESSION['glpi_user_filter']; + + /* Filter settings, remove double* */ + if(isset($_GET['search'])){ + $filter['users_regex'] = preg_replace("/\*\**/","*",$_GET['search']."*"); + }elseif(isset($_POST['regex'])){ + $filter['users_regex'] = preg_replace("/\*\**/","*",$_POST['regex']); + } + if(empty($filter['users_regex'])) { + $filter = "*"; + } + + + $s_action=""; + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/dep_back.*/i",$key)){ + $s_action="back"; + }elseif(preg_match("/user_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/dep_home.*/i",$key)){ + $s_action="home"; + } + } + + /* Homebutton is posted */ + if($s_action=="home"){ + $filter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn)); + $filter['base']=(preg_replace("/^[^,]+,/","",$filter['base'])); + } + + if($s_action=="root"){ + $filter['base']=($this->config->current['BASE']); + } + + + /* If Backbutton is Posted */ + if($s_action=="back"){ + $base_back = preg_replace("/^[^,]+,/","",$filter['base']); + $base_back = convert_department_dn($base_back); + + if(isset($this->config->departments[trim($base_back)])){ + $filter['base']= $this->config->departments[trim($base_back)]; + }else{ + $filter['base']= $this->config->departments["/"]; + } + } + + if((isset($_GET['act']))&&($_GET['act']=="dep_open")){ + $entry = base64_decode($_GET['dep_id']); + $filter['base']= ($this->config->departments[$entry]); + } + + $_SESSION['glpi_user_filter'] = $filter; + + $this->reload(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $divlist = new divlist("glpi users"); + $divlist->SetPluginMode(); + $divlist->SetEntriesPerPage(0); + $divlist->SetHeader(array( + array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), + array("string" => _("Users")." / "._("Departments"), "attach" => "style=''"), + array("string" => _("Use"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); + $linkopen = "%s"; + foreach($this->departments as $key=> $val){ + + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + + $non_empty=""; + $keys= str_replace("/","\/",$key); + foreach($this->config->departments as $keyd=>$vald ){ + if(preg_match("/".$keys."\/.*/",$keyd)){ + $non_empty="full"; + } + } + + $field1 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''"); + $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + $divlist->AddEntry(array($field1,$field2,$field3)); + } + + $useruse = "%s"; + + foreach($this->users as $key=>$user){ + $field1 = array("string" => "user", "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($useruse,base64_encode($key),$user), "attach" => "style=''"); + $field3 = array("string" => sprintf($useruse,base64_encode($key),""._("use").""), + "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + $divlist->AddEntry(array($field1,$field2,$field3)); + + } + + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + + + /* Get all departments within this subtree */ + $this->base = $_SESSION['glpi_user_filter']['base']; + $options =""; + $base = $this->config->current['BASE']; + $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "users", $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH); + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("users"); + $ids = $this->config->idepartments; + foreach($deps as $dep){ + if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){ + $value = $ids[$dep['dn']]; + if ($this->base == $dep['dn']){ + $options.= ""; + } else { + $options.= ""; + } + } + } + + $listhead = "
". + "  ". + "  ". + "  ". + "  ". +"  "._("Base")." ". + " ". + "  ". + "
"; + + + $filter= $_SESSION['glpi_user_filter']; + $smarty->assign("usershead", $listhead); + $smarty->assign("users", $divlist->DrawList()); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("searchu_image", get_template_path('images/search_user.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info_small.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("users_regex", $filter['users_regex']); + + + $display.= $smarty->fetch(get_template_path('glpiSelectUser.tpl', TRUE)); + return($display); + } + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Optionally execute a command after we're done */ +#$this->handle_post_events($mode); + } + + function reload() + { + + $filter= $_SESSION['glpi_user_filter']; + + $base = $filter['base']; + $regex= $filter['users_regex']; + /* NEW LIST MANAGMENT + * We also need to search for the departments + * So we are able to navigate like in konquerer + */ + + $res3= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))","users", + $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT); + + $this->departments= array(); + $tmp = array(); + foreach ($res3 as $value){ + $tmp[strtolower($value['dn']).$value['dn']]=$value; + } + ksort($tmp); + foreach($tmp as $value){ + if(isset($value["description"][0])){ + $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]"; + }else{ + $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0]; + } + } + + /* END NEW LIST MANAGMENT + */ + $ou = get_people_ou(); + + $res2= get_list("(&(|(cn=$regex)(sn=$regex))(objectClass=person))", "users", + $ou.$base, array("cn", "sn", "uid", "givenName", "description"), + GL_SUBSEARCH | GL_SIZELIMIT); + + $tmp = array(); + + foreach($res2 as $val){ + $str = ""; + if(isset($val['givenName'][0])){ + $str .= $val['givenName'][0]; + } + if(isset($val['sn'][0])){ + $str .= $val['sn'][0]; + } + if(isset($val['uid'][0])){ + $str .= $val['uid'][0]; + } + + $tmp[$str] = $val; + } + + ksort($tmp); + $this->users = array(); + foreach($tmp as $value){ + if (isset($value["givenName"][0]) && isset($value["sn"][0])){ + $this->users[$value['dn']]= $value["sn"][0].", ". + $value["givenName"][0]. + " [".$value["uid"][0]."]"; + } else { + $this->users[$value["dn"]]= "[".$value["uid"][0]."]"; + } + } + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_goGlpiServer.inc b/gosa-core/plugins/admin/systems/services/glpi/class_goGlpiServer.inc new file mode 100644 index 000000000..07c07d427 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/class_goGlpiServer.inc @@ -0,0 +1,109 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goGlpiServer"); + var $attributes = array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword"); + var $StatusFlag = "goGlpiServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goGlpiServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $cn = ""; + var $acl; + + var $goGlpiServerStatus =""; + var $goGlpiAdmin =""; + var $goGlpiDatabase =""; + var $goGlpiPassword =""; + var $view_logged =FALSE; + + + function goGlpiServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("Inventory database"); + } + + + function execute() + { + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation ){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + return($smarty->fetch(get_template_path("goGlpiServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Inventory database service"); + $fields['AllowEdit'] = true; + return($fields); + } + + function check() + { + $message = plugin::check(); + if(empty($this->goGlpiAdmin)){ + $message[]= _("The attribute user is empty or contains invalid characters."); + } + if(empty($this->goGlpiDatabase)){ + $message[]= _("The attribute database is empty or contains invalid characters."); + } + return($message); + } + + + function save_object() + { + if(isset($_POST['goGlpiServer_posted'])){ + plugin::save_object(); + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Inventory database"), + "plDescription" => _("Inventory database")." ("._("Services").")" , + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 93, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + + "goGlpiAdmin" => _("Admin"), + "goGlpiDatabase" => _("Database"), + "goGlpiPassword" => _("Password")) + )); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi.tpl new file mode 100644 index 000000000..0d2f8db36 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpi.tpl @@ -0,0 +1,138 @@ + + + + + +
+ + +

{t}Generic{/t}

+ + + + + + + + + + + + + + + + + + + + + + +
{t}System type{/t} + +{render acl=$typeACL} + +{/render} +{render acl=$typeACL} + +{/render} +
{t}Operating system{/t} + +{render acl=$osACL} + +{/render} +{render acl=$osACL} + +{/render} +
{t}Manufacturer{/t} + +{render acl=$FK_glpi_enterpriseACL} + +{/render} +{render acl=$FK_glpi_enterpriseACL} + +{/render} +
+ {t}Contact person{/t} + + {$contact_num}    +{render acl=$contact_numACL} + +{/render} +
{t}Technical responsible{/t}  + + {$tech_num}    +{render acl=$tech_numACL} + +{/render} +
+
+ +

{t}Comment{/t}

+ + + + +
+{render acl=$commentsACL} + +{/render} +
+
+

 

+ + + + + +
+

{t}Installed devices{/t}

+ + + + +
+{render acl=$DevicesACL} + +{/render} +{render acl=$DevicesACL} + +{/render} +
+ +
+

{t}Attachments{/t}

+ + + + +
+{render acl=$AttachmentsACL} + {$AttachmentsDiv} +{/render} +{render acl=$AttachmentsACL} + +{/render} +
+
+ +

diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl new file mode 100644 index 000000000..7d91e50af --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl @@ -0,0 +1,78 @@ +
+

{t}Attachment{/t}

+ + + + + + +
+ + + + + + + + + +
+ {t}Name{/t} + + +
+ {t}Comment{/t} + + +
+
+ + + + + + + + + + + + + + + + + +
+ {t}File{/t} + + +
+ {t}Status{/t} + + {$status} +
+ {t}Filename{/t} + + {$filename} +
+ {t}Mime-type{/t} + + {$mime} +
+
+ + +

 

+
+

+ + +

+
+ + diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl new file mode 100644 index 000000000..e3a73be8d --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl @@ -0,0 +1,54 @@ + + + + + +
+
+

+ {t}List of attachments{/t} +

+
+
+ {$attachmenthead} +
+
+
+ {$attachments} + +
+
+
+

[i]{t}Information{/t}

+
+
+ {t}This dialog allow you to attach additional objects (like manuals, guides, etc.) to your currently edited computer.{/t} +
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + +
+ +
+ {$apply} +
+
+ + +

 

+
+

+ + +

+
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl new file mode 100644 index 000000000..ab2baa740 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl @@ -0,0 +1,54 @@ + + + + + +
+
+

+ {t}List of devices{/t} +

+
+
+ {$devicehead} +
+
+
+ {$devices} + +
+
+
+

[i]{t}Information{/t}

+
+
+ {t}This dialog allows you to attach a device to your currently edited computer.{/t} +
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + +
+ +
+ {$apply} +
+
+ + +

 

+
+

+ + +

+
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturer.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturer.tpl new file mode 100644 index 000000000..a15a29aa4 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturer.tpl @@ -0,0 +1,15 @@ +

{t}Manage manufacturers{/t}

+ +
+ + + + +

 

+
+

+ +

+
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl new file mode 100644 index 000000000..c5b060d29 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl @@ -0,0 +1,89 @@ +

{t}Add/Edit manufacturer{/t}

+ + + + + +
+ + + + + + + + + + + + + +
{t}Name{/t} + + +
{t}Website{/t} + + +
{t}Address{/t} + + +
+
+ + + + + + + + + + + + + + + + + +
{t}Phone number{/t} + + +
{t}Fax{/t} + + +
{t}Email{/t} + + +
{t}Comments{/t} + + +
+
+ + + + + + + + + + + + + +
+

 

+
+

+ + +

+
+ + diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiPrinter.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinter.tpl new file mode 100644 index 000000000..46e344678 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinter.tpl @@ -0,0 +1,159 @@ + + + + + +
+ + +

{t}Generic{/t}

+ + + + + + + + + +
{t}Printer type{/t} + +{render acl=$typeACL} + +{/render} +{render acl=$typeACL} + +{/render} +
{t}Manufacturer{/t} + +{render acl=$FKglpienterpriseACL} + +{/render} +{render acl=$FKglpienterpriseACL} + +{/render} +
+
+

{t}Supported interfaces{/t}

+ + + + + + + + + + + + + +
+{render acl=$flags_serialACL} + +{/render} + + {t}Serial{/t} +
+{render acl=$flags_parACL} + +{/render} + + {t}Parallel{/t} +
+{render acl=$flags_usbACL} + +{/render} + + {t}USB{/t} +
+ +
+

 

+ + + + + +
+

{t}Contacts{/t}

+ + + + + + + + + +
{t}Technical responsible{/t}  + + {$tech_num}    +{render acl=$tech_numACL} + +{/render} +
+ {t}Contact person{/t} + + {$contact_num}    +{render acl=$contact_numACL} + +{/render} + +
+
+

{t}Attachments{/t}

+ + + + +
+{render acl=$AttachmentsACL} + {$AttachmentsDiv} +{/render} +{render acl=$AttachmentsACL} + +{/render} +
+
+

 

+ + + + + +
+

{t}Information{/t}

+ + + + +
+{render acl=$commentsACL} + +{/render} +
+
+

{t}Installed cartridges{/t}

+ + + + +
+{render acl=$CartridgesACL} + +{/render} +{render acl=$CartridgesACL} + +{/render} +{render acl=$CartridgesACL} + +{/render} +
+
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl new file mode 100644 index 000000000..5dcd2de13 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl @@ -0,0 +1,54 @@ + + + + + +
+
+

+ {t}List of available cartridge type for this type of printer{/t} +

+
+
+ {$devicehead} +
+
+
+ {$devices} + +
+
+
+

[i]{t}Information{/t}

+
+
+ {t}This dialog allows you to create new types of cartridges, and select one or more types for your printer. Cartridge types depends on the printer type you have selected. For each selected cartridge type there will be a new cartridge created, this allows you to select the same cartridge type for more then one printer.{/t} +
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + +
+ +
+ {$apply} +
+
+ + +

 

+
+

+ + +

+
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl new file mode 100644 index 000000000..6857efdb3 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl @@ -0,0 +1,83 @@ + + + + + +
+

{t}Generic{/t}

+ + + + + + + + + +
{t}Name{/t} + + +
{t}Reference{/t} + + +
+

 

+

{t}Comments{/t}

+ + + + + +
{t}Comment{/t} + + +
+
+

{t}Generic{/t}

+ + + + + + + + + + + + + +
{t}Type{/t} + + + +
{t}Manufacturer{/t} + + + +
{t}Technical responsible{/t}  + + {$tech_num}    + +
+

 

+ {$PrinterTypeMatrix} +
+ +

 

+
+

+   +
+

+
+ + diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiSelectUser.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiSelectUser.tpl new file mode 100644 index 000000000..75bf351bd --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpiSelectUser.tpl @@ -0,0 +1,53 @@ + + + + + +
+
+

+ {t}List of users{/t} +

+
+
+ {$usershead} +
+
+
+ {$users} + +
+
+
+

[i]{t}Information{/t}

+
+
+ {t}This dialog allows you to select a user as technical responsible person.{/t} +
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + +
+ +
+ {$apply} +
+
+ + +

 

+
+

+ +

+
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_devices.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_devices.tpl new file mode 100644 index 000000000..44de4fa93 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpi_devices.tpl @@ -0,0 +1,763 @@ +{if $device_type=="monitor"} +

 {t}Add/Edit monitor{/t}

+

 

+
+ + + + + +
+ + + + + + + + + + + + + + + + + +
{t}Name{/t} + + +
{t}Comments{/t} + + +
{t}Manufacturer{/t} + + +
{t}Monitor size{/t} + + {t}Inch{/t} +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
{t}Integrated microphone{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}Integrated speakers{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}Sub-D{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}BNC{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}Serial number{/t} + + +
{t}Additional serial number{/t} + + +
+
+ + +{elseif $device_type=="pci"} + +

 {t}Add/Edit other device{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + +
{t}Manufacturer{/t} + + +
+
+ +{elseif $device_type=="power"} + +

 {t}Add/Edit power supply{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Atx{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}Power{/t} + + +
+
+{elseif $device_type=="gfxcard"} + +

 {t}Add/Edit graphic card{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Interface{/t} + + +
{t}Ram{/t} + + +
+
+{elseif $device_type=="control"} + +

 {t}Add/Edit controller{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Interface{/t} + + +
{t}Size{/t} + + {t}Yes{/t} + {t}No{/t} +
+
+ +{elseif $device_type=="drive"} + +

 {t}Add/Edit drive{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Speed{/t} + + +
{t}Interface{/t} + + +
{t}Writeable{/t} + + {t}Yes{/t} + {t}No{/t} +
+
+ +{elseif $device_type=="hdd"} +

 {t}Add/Edit harddisk{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + + + + + + + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Rpm{/t} + + +
{t}Cache{/t} + + +
{t}Size{/t} + + +
{t}Type{/t} + + +
+
+ +{elseif $device_type=="ram"} + +

 {t}Add/Edit memory{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + + + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Frequenz{/t} + + +
{t}Size{/t} + + +
{t}Type{/t} + + +
+
+ +{elseif $device_type=="sndcard"} +

 {t}Add/Edit sound card{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Type{/t} + + +
+
+{elseif $device_type=="iface"} +

 {t}Add/Edit network interface{/t}

+

 

+
+ + + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}MAC address{/t} + + +
{t}Bandwidth{/t} + + +
+
+{elseif $device_type=="processor"} +

 {t}Add/Edit processor{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Frequence{/t} + + +
{t}Default frequence{/t} + + +
+
+ +{elseif $device_type=="moboard"} +

 {t}Add/Edit motherboard{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}Chipset{/t} + + +
+
+{elseif $device_type=="case"} +

 {t}Add/Edit computer case{/t}

+

 

+
+ + + + + +
+ + + + + + + + + +
{t}Name{/t} + + +
{t}Comment{/t} + + +
+
+ + + + + + + + + +
{t}Manufacturer{/t} + + +
{t}format{/t} + + +
+
+{/if} + + +

 

+
+

+ + +

+
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl new file mode 100644 index 000000000..cbc91d95f --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl @@ -0,0 +1,21 @@ +
+
+ + + + + +

 

+
+

+ +

+
+ + diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_os.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_os.tpl new file mode 100644 index 000000000..8e3726451 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_os.tpl @@ -0,0 +1,39 @@ +

{t}Manage OS-types{/t}

+{if $Method == "edit"} + +
+ + + + + +

 

+
+

+ +

+
+ +{else} +{t}Please enter a new name{/t}  +

 

+

+

+ + +
+

+ +{/if} + + diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl new file mode 100644 index 000000000..a63e9235e --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl @@ -0,0 +1,40 @@ +
+{if $Method == "edit"} +
+ + + + + +

 

+
+

+ +

+
+ + +{else} + + {t}Please enter a new name{/t}  +

 

+

+

+ + +
+

+ + +{/if} + diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_type.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_type.tpl new file mode 100644 index 000000000..14a4f5431 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_type.tpl @@ -0,0 +1,37 @@ +

{t}Manage System-types{/t}

+{if $Method == "edit"} + +
+ + + + + +

 

+
+

+ +

+
+ +{else} +{t}Please enter a new name{/t}  +

 

+

+

+ + +
+

+ +{/if} diff --git a/gosa-core/plugins/admin/systems/services/glpi/goGlpiServer.tpl b/gosa-core/plugins/admin/systems/services/glpi/goGlpiServer.tpl new file mode 100644 index 000000000..36a2f2476 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/goGlpiServer.tpl @@ -0,0 +1,36 @@ +

{t}GLPI database information{/t}

+ + + + + + + + + + + + + +
{t}Logging DB user{/t}{$must} +{render acl=$goGlpiAdminACL} + +{/render} +
{t}Password{/t} +{render acl=$goGlpiPasswordACL} + +{/render} +
{t}Database{/t}{$must} +{render acl=$goGlpiDatabaseACL} + +{/render} +
+ + +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/glpi/remove_glpi.tpl b/gosa-core/plugins/admin/systems/services/glpi/remove_glpi.tpl new file mode 100644 index 000000000..4106caf06 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/glpi/remove_glpi.tpl @@ -0,0 +1,17 @@ +
+ {t}Warning{/t} +
+

+ {$warning} + {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}Best thing to do before performing this action would be to save the current contents of your MySql database in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ +   + +

diff --git a/gosa-core/plugins/admin/systems/services/gofax/class_goFaxServer.inc b/gosa-core/plugins/admin/systems/services/gofax/class_goFaxServer.inc new file mode 100644 index 000000000..1e5e04976 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/gofax/class_goFaxServer.inc @@ -0,0 +1,103 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goFaxServer"); + var $attributes = array("goFaxAdmin", "goFaxPassword"); + var $StatusFlag = "goFaxServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goFaxServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $acl; + + var $goFaxAdmin = ""; + var $goFaxPassword = ""; + var $goFaxServerStatus = ""; + var $cn = ""; + var $view_logged =FALSE; + + function goFaxServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("FAX database"); + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Assign acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation ){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goFaxServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("FAX database configuration"); + $fields['AllowEdit'] = true; + return($fields); + } + + function check() + { + $message = plugin::check(); + if (empty($this->goFaxAdmin)){ + $message[]= _("The attribute user is empty or contains invalid characters."); + } + if (empty($this->goFaxPassword)){ + $message[]= _("The attribute password is empty or contains invalid characters."); + } + return($message); + } + + + function save_object() + { + if(isset($_POST['goFaxServerPosted'])){ + plugin::save_object(); + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Fax database"), + "plDescription" => _("Fax database")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 99, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "goFaxAdmin" => _("Login name"), + "goFaxPassword" => _("Password")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/gofax/goFaxServer.tpl b/gosa-core/plugins/admin/systems/services/gofax/goFaxServer.tpl new file mode 100644 index 000000000..27560b3f3 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/gofax/goFaxServer.tpl @@ -0,0 +1,27 @@ +

{t}FAX database information{/t}

+ + + + + + + + + +
{t}FAX DB user{/t}{$must} +{render acl=$goFaxAdminACL} + +{/render} +
{t}Password{/t}{$must} +{render acl=$goFaxPasswordACL} + +{/render} +
+ +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/gofon/class_goFonServer.inc b/gosa-core/plugins/admin/systems/services/gofon/class_goFonServer.inc new file mode 100644 index 000000000..2e69a849d --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/gofon/class_goFonServer.inc @@ -0,0 +1,182 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goFonServer"); + var $attributes = array("goFonAdmin", "goFonPassword","goFonAreaCode", "goFonCountryCode"); + var $StatusFlag = "goFonServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goFonServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $cn =""; + var $acl; + + var $goFonServerStatus = ""; + var $goFonPassword = ""; + var $goFonAdmin = ""; + var $goFonAreaCode = ""; + var $goFonCountryCode = ""; + var $view_logged =FALSE; + + var $orig_dn = ""; + + function goFonServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("VoIP service"); + + $this->orig_dn = $dn; + } + + + function execute() + { + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + return($smarty->fetch(get_template_path("goFonServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("VoIP service - Asterisk management"); + $fields['AllowEdit'] = true; + return($fields); + } + + function check() + { + $message = plugin::check(); + if (empty($this->goFonAdmin)){ + $message[]= _("The attribute DB user is empty or contains invalid characters."); + } + if (empty($this->goFonPassword)){ + $message[]= _("The attribute password is empty or contains invalid characters."); + } + if (empty($this->goFonAreaCode)){ + $message[]= _("The attribute local dial prefix is empty or contains invalid characters."); + } + if (empty($this->goFonCountryCode)){ + $message[]= _("The attribute country dial prefix is empty or contains invalid characters."); + } + return($message); + } + + + function save_object() + { + if(isset($_POST['goFonServerPosted'])){ + plugin::save_object(); + } + } + + + function allow_remove() + { + /* Check if we are able to remove the asterisk database. If the database is still in use skip */ + if($this->is_account){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer")); + if($ldap->count()){ + + /* Number of entries shown in warning */ + $i = 3; + $str = ""; + while(($attrs = $ldap->fetch()) && $i >= 0){ + $i --; + if(isset($attrs['uid'][0])){ + $str .= $attrs['uid'][0]." "; + }else{ + $str .= $attrs['cn'][0]." "; + } + } + + /* Some entries found */ + if($i != 3){ + return(sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str))); + } + } + } + } + + + function save() + { + goService::save(); + /* Update goFonAccounts if server was is renamed. + Set attribute goFonHomeServer to current dn + */ + if(in_array("goFonServer",$this->objectclasses)){ + if($this->orig_dn != "new" && $this->orig_dn != $this->dn){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(goFonHomeServer=".$this->orig_dn.")(|(objectClass=goFonAccount)(objectClass=goFonConference)))",array("goFonHomeServer")); + $dns = array(); + while($attrs = $ldap->fetch()){ + $dns[] = $attrs['dn']; + } + foreach($dns as $dn){ + $ldap->cd($dn); + $ldap->modify(array("goFonHomeServer" => $this->dn)); + show_ldap_error($ldap->get_error(),sprintf(_("Updating gofon home server failed for '%s'."),$dn)); + } + } + + /* Updated config list of gofon servers */ + if($this->orig_dn == "new" || $this->orig_dn != $this->dn){ + $_SESSION['config']->load_servers(); + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("VoIP service"), + "plDescription" => _("VoIP - asterisk management")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 92, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + + "goFonAdmin" => _("Admin"), + "goFonPassword" => _("Password"), + "goFonAreaCode" => _("Area code"), + "goFonCountryCode"=> _("Country code")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/gofon/goFonServer.tpl b/gosa-core/plugins/admin/systems/services/gofon/goFonServer.tpl new file mode 100644 index 000000000..14a1603b8 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/gofon/goFonServer.tpl @@ -0,0 +1,43 @@ +

{t}VoIP database information{/t}

+ + + + + + + + + + + + + + + + + +
{t}Asterisk DB user{/t}{$must} +{render acl=$goFonAdminACL} + +{/render} +
{t}Password{/t}{$must} +{render acl=$goFonPasswordACL} + +{/render} +
{t}Country dial prefix{/t}{$must} +{render acl=$goFonCountryCodeACL} + +{/render} +
{t}Local dial prefix{/t}{$must} +{render acl=$goFonAreaCodeACL} + +{/render} +
+ +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/imap/class_goImapServer.inc b/gosa-core/plugins/admin/systems/services/imap/class_goImapServer.inc new file mode 100644 index 000000000..e5681b942 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/imap/class_goImapServer.inc @@ -0,0 +1,187 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goImapServer"); + + /* This class can't be assigned twice so it conflicts with itsself */ + + var $DisplayName = ""; + var $dn = NULL; + var $StatusFlag = "goImapServerStatus"; + var $attributes = array("goImapName","goImapConnect","goImapAdmin","goImapPassword", + "goImapSieveServer","goImapSievePort", + "cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL"); + + var $cn = ""; + + var $goImapName = ""; + var $goImapConnect = ""; + var $goImapAdmin = ""; + var $goImapPassword = ""; + + var $goImapSieveServer = ""; + var $goImapSievePort = ""; + + var $goImapServerStatus = ""; + + var $cyrusImap = false; + var $cyrusImapSSL = false; + var $cyrusPop3 = false; + var $cyrusPop3SSL = false; + var $is_account = false; + var $view_logged =FALSE; + + var $acl; + + var $Actions = array(); + var $conflicts = array("goImapServer","kolab"); + + function goImapServer(&$config,$dn) + { + goService::goService($config,$dn); + + $this->DisplayName = _("IMAP/POP3 service"); + + $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED, + SERVICE_STARTED => SERVICE_STARTED, + SERVICE_RESTARTED=>SERVICE_RESTARTED, + "repair_database"=>_("Repair database")); + + } + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* set new status */ + if(isset($_POST['ExecAction'])){ + if(isset($this->Actions[$_POST['action']])){ + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation) { + if(preg_match("/^".$_POST['action']."$/i",$name)){ + if($this->acl_is_writeable($name)){ + $this->setStatus($_POST['action']); + } + } + } + + } + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + $smarty->assign("Actions",$this->Actions); + $smarty->assign("is_new",$this->dn); + $smarty->assign("is_acc",$this->initially_was_account); + return($smarty->fetch(get_template_path("goImapServer.tpl",TRUE,dirname(__FILE__)))); + } + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("IMAP/POP3 (Cyrus) service"); + $fields['AllowRemove']= true; + $fields['AllowEdit'] = true; + return($fields); + } + + function check() + { + $message = plugin::check(); + if(empty($this->goImapName)){ + $message[] =_("Please specify a server identifier."); + } + if(empty($this->goImapConnect)){ + $message[] =_("Please specify a connect url."); + } + if(empty($this->goImapAdmin)){ + $message[] =_("Please specify an admin user."); + } + if(empty($this->goImapPassword)){ + $message[] =_("Please specify a password for the admin user."); + } + + /* Check connect string */ + if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){ + $message[]= sprintf(_("The imap connect string needs to be in the form '%s'."), + '{server-name:port/options}'); + } + if (!preg_match('/^[0-9]+$/', $this->goImapSievePort)){ + $message[]= _("The sieve port needs to be numeric."); + } + + return ($message); + } + + + function save_object() + { + if(isset($_POST['goImapServerPosted'])){ + plugin::save_object(); + + foreach(array("cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL") as $checkbox) { + + if($this->acl_is_writeable($checkbox)){ + if(!isset($_POST[$checkbox])){ + $this->$checkbox = false; + }else{ + $this->$checkbox = true; + } + } + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("IMAP/POP3"), + "plDescription" => _("IMAP/POP3")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 94, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + "repair_database" => _("Repair database"), + + "goImapName" =>_("Server identifier"), + "goImapConnect" =>_("Connect URL"), + "goImapAdmin" =>_("Admin user"), + "goImapPassword" =>_("Admin password"), + "goImapSievePort" =>_("Sieve port"), + "cyrusImap" =>_("Start IMAP service"), + "cyrusImapSSL" =>_("Start IMAP SSL service"), + "cyrusPop3" =>_("Start POP3 service"), + "cyrusPop3SSL" =>_("Start POP3 SSL service")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/imap/goImapServer.tpl b/gosa-core/plugins/admin/systems/services/imap/goImapServer.tpl new file mode 100644 index 000000000..17c40092d --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/imap/goImapServer.tpl @@ -0,0 +1,120 @@ +

{t}Generic{/t}

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
{t}Server identifier{/t}{$must} + +{render acl=$goImapNameACL} + +{/render} +
{t}Connect URL{/t}{$must} + +{render acl=$goImapConnectACL} + +{/render} +
{t}Admin user{/t}{$must} + +{render acl=$goImapAdminACL} + +{/render} +
{t}Password{/t}{$must} + +{render acl=$goImapPasswordACL} + +{/render} +
{t}Sieve port{/t}{$must} + +{render acl=$goImapSievePortACL} + +{/render} +
+
+ + + + + + + + + + + + + + + + + +
+{render acl=$cyrusImapACL} + +{/render} + {t}Start IMAP service{/t} +
+{render acl=$cyrusImapSSLACL} + +{/render} + {t}Start IMAP SSL service{/t} +
+{render acl=$cyrusPop3ACL} + +{/render} + {t}Start POP3 service{/t} +
+{render acl=$cyrusPop3SSLACL} + +{/render} + {t}Start POP3 SSL service{/t} +
+
+

 

+
+

Action

+{if $is_new == "new"} + {t}The server must be saved before you can use the status flag.{/t} +{elseif !$is_acc} + {t}The service must be saved before you can use the status flag.{/t} +{/if} +
+ + + +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/kerberos/class_goKrbServer.inc b/gosa-core/plugins/admin/systems/services/kerberos/class_goKrbServer.inc new file mode 100644 index 000000000..3eef127f4 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/kerberos/class_goKrbServer.inc @@ -0,0 +1,107 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goKrbServer"); + var $attributes = array("goKrbRealm", "goKrbAdmin","goKrbPassword"); + var $StatusFlag = "goKrbServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goKrbServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $goKrbServerStatus= ""; + var $cn =""; + var $goKrbRealm = ""; + var $goKrbAdmin = ""; + var $goKrbPassword =""; + var $view_logged =FALSE; + + function goKrbServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("Kerberos service"); + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $tmp = $this->plinfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goKrbServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Kerberos service (kadmin access informations)"); + $fields['AllowEdit'] = true; + return($fields); + } + + function check() + { + $message = plugin::check(); + /* goKrbPassword is a must field, if goKrbServer is used as objectClass */ + if (empty($this->goKrbPassword)){ + $message[]= sprintf(_("The specified kerberos password is empty."), $attr); + } + if (empty($this->goKrbAdmin)){ + $message[]= sprintf(_("The specified kerberos admin is empty."), $attr); + } + if (empty($this->goKrbRealm)){ + $message[]= sprintf(_("The specified kerberos realm is empty."), $attr); + } + + return($message); + } + + + function save_object() + { + if(isset($_POST['goKrbServerPosted'])){ + plugin::save_object(); + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Kerberos"), + "plDescription" => _("Kerberos access information")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 95, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "goKrbRealm" => _("Realm"), + "goKrbAdmin" => _("Admin"), + "goKrbPassword" => _("Password")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/kerberos/goKrbServer.tpl b/gosa-core/plugins/admin/systems/services/kerberos/goKrbServer.tpl new file mode 100644 index 000000000..a0234ebe1 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/kerberos/goKrbServer.tpl @@ -0,0 +1,34 @@ +

{t}Kerberos kadmin access{/t}

+ + + + + + + + + + + + + +
{t}Kerberos Realm{/t}{$must} +{render acl=$goKrbRealmACL} + +{/render} +
{t}Admin user{/t}{$must} +{render acl=$goKrbAdminACL} + +{/render} +
{t}Password{/t}{$must} +{render acl=$goKrbPasswordACL} + +{/render} +
+

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/kiosk/class_goKioskService.inc b/gosa-core/plugins/admin/systems/services/kiosk/class_goKioskService.inc new file mode 100644 index 000000000..287ed9e36 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/kiosk/class_goKioskService.inc @@ -0,0 +1,245 @@ +DisplayName = _("Kiosk profile service"); + $this->baseDir = $this->config->search('environment', 'kioskpath',array('menu','tabs')); + $this->server_path = preg_replace("/%cn/", $this->cn, $this->server_path); + + /* Load list of profiles and check if they still exists */ + if ($this->baseDir == ""){ + print_red(_("There is no KIOSKPATH defined in your gosa.conf. Can't manage kiosk profiles!")); + }else{ + $this->gotoKioskProfiles = array(); + if(isset($this->attrs['gotoKioskProfile']) && is_array($this->attrs['gotoKioskProfile'])){ + for($i = 0 ; $i < $this->attrs['gotoKioskProfile']['count']; $i ++){ + $url = $this->attrs['gotoKioskProfile'][$i]; + $this->server_path = preg_replace("/\/[^\/]*$/","",$url); + $name= preg_replace("/^.*\//","",$url); + $this->gotoKioskProfiles[] = array('url' => $url , + 'name' => $name , + 'initial' =>TRUE, + 'exists' => file_exists($this->baseDir."/".$name)); + } + } + } + } + + + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*/".$this->cn."/*))",array("cn")); + $str =""; + $cnt = 3; + while($cnt && $attrs = $ldap->fetch()){ + $str .= $attrs['cn'][0].", "; + $cnt --; + } + $str = preg_replace("/, $/","",$str); + if($cnt != 3){ + print_red(sprintf(_("Can not remove kiosk profile service, it is currently in use by following user(s) : %s."),$str)); + }else{ + goService::remove_from_parent(); + } + } + + + function execute() + { + /* log actions */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add new kiosk profile + * in profile directory ($this->baseDir); + */ + if((isset($_POST['profileAdd']))&&(isset($_FILES['newProfile']))){ + $file = $_FILES['newProfile']; + if(!file_exists($this->baseDir.$file['name'])){ + $tmp = array( + 'url' => "" , + 'name' => $file['name'] , + 'initial' => FALSE, + 'tmp_name'=> $file['tmp_name'], + 'content' => file_get_contents($file['tmp_name']), + 'exists' => TRUE); + $this->gotoKioskProfiles[] = $tmp; + } + if(!is_writeable($this->baseDir)){ + print_red(sprintf(_("Can't save new kiosk profiles, possibly permission denied for folder: '%s'."),$this->baseDir)); + } + } + + $only_once = true; + foreach($_POST as $name => $value){ + + if((preg_match("/^delkiosk_/",$name))&&($only_once)){ + + /* Get id, name and path */ + $only_once = false; + $id = preg_replace("/^delkiosk_/","",$name); + $id = preg_replace("/_.*$/","",$id); + $name = $this->gotoKioskProfiles[$id]['name']; + $filename = $this->baseDir."/".$name; + + /* check if profile is still in use */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*".$name.")",array("cn","uid","gotoKioskProfile")); + $used_by = ""; + $cnt = 3; + while(($attrs = $ldap->fetch()) && ($cnt)){ + $cnt --; + $check = preg_replace("/^.*\//i","",$attrs['gotoKioskProfile'][0]); + if($check == $name){ + $used_by .= $attrs['cn'][0].", "; + } + } + $used_by = preg_replace("/, $/","",$used_by); + if(!empty($used_by)){ + print_red(sprintf(_("Can't remove kioks profile, it is still in use by the following objects '%s'."),$used_by)); + }else{ + if($this->gotoKioskProfiles[$id]['initial']){ + $res = @unlink($filename); + if(!$res){ + if(!is_writeable($filename)){ + print_red(sprintf(_("Can't delete '%s'. Error was: permission denied."), $filename)); + } + if(!file_exists($filename)){ + print_red(sprintf(_("Can't delete '%s'. Error was: file doesn't exist."), $filename)); + } + } + unset($this->gotoKioskProfiles[$id]); + } + } + } + } + + /* Display list of profiles */ + $divlist = new divSelectBox("KioskProfiles"); + $divlist -> SetHeight (300); + foreach($this->gotoKioskProfiles as $key => $val ){ + $divlist->AddEntry(array( + array("string"=>"".$val['name'].""), + array("string"=>"" , + "attach"=>" style='border-right: 0px;width:24px; text-align:center;' ") + )); + } + + /* Assign all existing profiles to smarty */ + $smarty->assign("divlist",$divlist->DrawList()); + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $smarty->assign("server_path",$this->server_path); + return($smarty->fetch(get_template_path("goKioskService.tpl",TRUE,dirname(__FILE__)))); + } + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Kiosk profile service"); + $fields['AllowEdit'] = TRUE; + $fields['AllowStart'] = false; + $fields['AllowStop'] = false; + $fields['AllowRestart'] = false; + return($fields); + } + + function check() + { + $message = plugin::check(); + return($message); + } + + function save() + { + goService::save(); + + $method = $this->server_path."/"; + $method = preg_replace("/\/\/*$/","/",$method); + $this->attrs['gotoKioskProfile'] = array(); + foreach($this->gotoKioskProfiles as $profile){ + if(!$profile['initial']){ + + $contents = $profile['content']; + $path = $this->baseDir."/".$profile['name']; + $fp = @fopen($path,"w"); + if(!$fp){ + print_red(_("Can't save new kiosk profiles, possibly permission denied for folder")." : ",$path); + }else{ + fwrite($fp,$contents,strlen($contents)); + $this->attrs['gotoKioskProfile'][] = $method.$profile['name']; + } + @unlink($profile['tmp_name']); + }else{ + $this->attrs['gotoKioskProfile'][] = $method.$profile['name']; + } + } + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error(),_("Wohl kaum")); + } + + + function save_object() + { + if(isset($_POST['goKioskPosted'])){ + goService::save_object(); + if(isset($_POST['server_path'])){ + $this->server_path = get_post("server_path"); + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Kiosk"), + "plDescription" => _("Kiosk profile management")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 100, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array() + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/kiosk/goKioskService.tpl b/gosa-core/plugins/admin/systems/services/kiosk/goKioskService.tpl new file mode 100644 index 000000000..f81230464 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/kiosk/goKioskService.tpl @@ -0,0 +1,24 @@ +

 

+ + + +{t}Server path{/t}  +
+
+{$divlist} + + + +

 

+
+ +   + +
+ + + diff --git a/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc b/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc new file mode 100644 index 000000000..7d31ff58d --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc @@ -0,0 +1,415 @@ +"Eins ist toll", "zwei"=>"Zwei ist noch besser"); + + var $postfix_mydomain = ""; + var $cyrus_admins = ""; + var $postfix_mydestination = ""; + var $postfix_mynetworks = "127.0.0.1/8"; + var $postfix_enable_virus_scan = "TRUE"; + var $postfix_relayhost = ""; + var $postfix_mxrelayenabled = true; + var $postfix_allow_unauthenticated = "FALSE"; + var $cyrus_quotawarn = "80"; + var $kolabFreeBusyFuture = "1"; + var $k = "kolab"; + var $cyrus_imap = "TRUE"; + var $cyrus_pop3 = "FALSE"; + var $cyrus_imaps = "TRUE"; + var $cyrus_pop3s = "TRUE"; + var $cyrus_sieve = "TRUE"; + var $apache_allow_unauthenticated_fb = "TRUE"; + var $proftpd_ftp = "FALSE"; + var $apache_http = "TRUE"; + var $kolabHost = array(); + var $orig_cn = ""; + var $view_logged = FALSE; + + var $attributes = array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k", + "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http", + "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture", + "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", + "cyrus_quotawarn"); + var $objectclasses = array("top", "kolab"); + + /* Serverservice vars */ + var $conflicts = array("goImapServer","goMailServer"); + var $DisplayName = "Kolab mail service"; + var $StatusFlag = ""; + + function servkolab(&$config, $dn = NULL, $parent= NULL) + { + /* Setting the hostname and tell this Plugin that we are the kolab extension*/ + $this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn); + $this->dn = "k=kolab,".$config->current['BASE']; + + /* Load variables, if given*/ + plugin::plugin($config, $this->dn); + + /* Copy needed attributes */ + foreach($this->attributes as $val) { + $name = preg_replace('/_/', '-', $val); + if (isset($this->attrs["$name"][0])) { + $this->$val = $this->attrs["$name"][0]; + } + } + + /* Toggle relayhost */ + $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost); + $this->postfix_relayhost = preg_replace("/[\[\]]/","",$this->postfix_relayhost); + + /* Is this Server a member of the Kolab extension or not ?*/ + if(isset($this->attrs['kolabHost'])) { + $this->kolabHost= $this->attrs['kolabHost']; + unset($this->kolabHost['count']); + } + $this->is_account = false; + $this->initially_was_account = false; + foreach($this->kolabHost as $host){ + if($this->hostname == $host){ + $this->is_account = true; + $this->initially_was_account = true; + } + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /*************** + Variable initialisation + ***************/ + + $smarty = get_smarty(); + $display = ""; + $ldap = $this->config->get_ldap_link(); + + + /* Assemble free/busy string */ + $edit = sprintf('', + $this->kolabFreeBusyFuture); + $fbfuture = sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit); + + /* Assemble quota string */ + $edit = sprintf('', + $this->cyrus_quotawarn); + $quotastr = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit); + + /*************** + Assign informations to smarty + ***************/ + + /* Set relayhost and if we have MX lookup enabled*/ + if($this->postfix_mxrelayenabled) { + $smarty->assign("RelayMxSupportCheck"," checked "); + } else { + $smarty->assign("RelayMxSupportCheck",""); + } + + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Initialize all attributes, that were submitted */ + foreach($this->attributes as $val) + { + /* Tell smarty which variables we are useing */ + $smarty->assign($val, $this->$val); + if (($this->$val != "FALSE") && !empty($this->$val)){ + $smarty->assign($val."Check", "checked"); + } else { + $smarty->assign($val."Check", ""); + } + } + + $smarty->assign("fbfuture", $fbfuture); + $smarty->assign("quotastr", $quotastr); + + /* Load Template */ + $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE)); + return ($display); + } + + function remove_from_parent() + { + + /* Remove status flag, it is not a memeber of + this->attributes, so ensure that it is deleted too */ + if(!empty($this->StatusFlag)){ + $this->attrs[$this->StatusFlag] = array(); + } + + + /* Only walk through following code, if this host + was a member of the kolab hosts, else skip this */ + if(!$this->initially_was_account){ + return; + } + + /* !!! Don't use "cn" in this function + hostname -> the initial name of the host + cn -> is the new name of the host, in case that it was renamed. + */ + + $ldap = $this->config->get_ldap_link(); + $this->dn = "k=kolab,".$this->config->current['BASE']; + + /* We can't simply remove the whole entry, it is possible that there are + some other hosts assigned to this object. + So, first of all check if we are the last host entry within the host + : Remove k=kolab entry + if we aren't alone, only remove host name from hosts entry and save */ + /* Are we alone? Remove complete entry... */ + + /* Check if we are definitly in kolabHosts */ + if(!in_array_ics($this->hostname,$this->kolabHost)) { + return; + } + + /* Integration check, not translated because they can't pop up at all, only for debug */ + if(count($this->kolabHost) == 0){ + print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists."); + return; + } + if(!isset($this->hostname) || (empty($this->hostname))){ + print_red("The required attribute hostname seams to empty."); + } + + /* Our hostname is in kolabHosts and there is a only one entry + = we are the last host entry, delete k=kolab entry */ + if (count($this->kolabHost) == 1){ + + /* Remove complete entry */ + $ldap->rmdir ($this->dn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn)); + } else { + + /* Only modify kolabHost */ + $hosts= array(); + foreach ($this->kolabHost as $host){ + if($host != $this->hostname){ + $hosts[]= $host; + } + } + $attrs= array('kolabHost' => $hosts); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn)); + } + + new log("remove","server/".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"); + } + + + function save_object() + { + if (isset($_POST['kolabtab'])){ + plugin::save_object(); + + + foreach($this->attributes as $attr){ + if(($this->acl_is_writeable(preg_replace("/_/","",$attr))) && (isset($_POST[$attr]))){ + $this->$attr = $_POST[$attr]; + } + } + + /* Save checkboxes */ + foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated", + "cyrus_imap", "cyrus_pop3", "cyrus_imaps", + "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", + "proftpd_ftp", "apache_http") as $cb){ + + if($this->acl_is_writeable(preg_replace("/_/","",$cb))){ + if (isset($_POST[$cb])){ + $this->$cb= "TRUE"; + } else { + $this->$cb= "FALSE"; + } + } + } + + /* Toggell relay check */ + if($this->acl_is_writeable("postfixmxrelayenabled")){ + $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']); + } + } + + } + + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(($this->kolabFreeBusyFuture=="")) { + $message[] = _("Future days in Free/Busy settings must be set."); + }elseif(!is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){ + $message[] = _("Future days in Free/Busy settings must be a positive value."); + } + + if(!is_int((int)($this->cyrus_quotawarn))) { + $message[] = _("The given Quota settings value must be a number."); + }elseif(!(($this->cyrus_quotawarn<=100)&&($this->cyrus_quotawarn>=0))){ + $message[] = _("Please choose a value between 1 and 100 for Quota settings."); + }elseif(strcasecmp($this->cyrus_quotawarn,(int)$this->cyrus_quotawarn)){ + $message[] = _("Future days must be a value."); + } + + if(empty($this->postfix_mynetworks)) { + $message[] = _("No SMTP privileged networks set."); + } + + /*if(empty($this->postfix_relayhost)) { + $message[] = _("No SMTP smarthost/relayhost set."); + } + */ + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* Set ldap connection */ + $ldap = $this->config->get_ldap_link(); + + /* Open current dn*/ + $this->dn = "k=kolab,".$this->config->current['BASE']; + + /* Adapt relayhost */ + $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost); + if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){ + $this->postfix_relayhost= "[".$this->postfix_relayhost."]"; + } + + /* Check if this server was renamed, in this case we have to remove old cn first*/ + if($this->hostname != $this->cn){ + $tmp = array(); + if(in_array_ics($this->hostname,$this->kolabHost)){ + foreach($this->kolabHost as $host){ + if($host != $this->hostname){ + $tmp[] = $host; + } + } + $this->kolabHost = $tmp; + } + } + + /* Add ourselves to the list of kolabHost's if needed */ + if (!in_array_ics($this->cn,$this->kolabHost)){ + $this->kolabHost[]= $this->cn; + } + + /* Call parents save to prepare $this->attrs */ + plugin::save(); + + /* Save or modify? */ + $ldap->cat($this->dn, array('dn')); + if (!$ldap->fetch()){ + $mode= "add"; + } else { + $mode= "modify"; + } + + /* Do attribute conversion */ + foreach ($this->attrs as $key => $value){ + if (preg_match('/_/', $key)){ + $old_key= $key; + $key= preg_replace('/_/', '-', $key); + $this->attrs[$key]= $value; + unset($this->attrs[$old_key]); + } + } + /* Add kolab hosts */ + $this->attrs['kolabHost']= $this->kolabHost; + + /* Perform LDAP action */ + $ldap->cd($this->dn); + $this->cleanup();; + $ldap->$mode($this->attrs); + + if($mode == "add"){ + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/kolab with dn '%s' failed."),$this->dn)); + + /* 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"); + } + } else { + $this->handle_post_events("add"); + } + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Kolab mail service"); + $fields['AllowEdit'] = true; + return($fields); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Kolab"), + "plDescription" => _("Kolab mail service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 85, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "postfixmydomain" => _("Postfix mydomain") , + "postfixmydestination" => _("My destination") , + "cyrusadmins" => _("Cyrus admins") , + "proftpdftp" => _("FTP FreeBusy service") , + "postfixmynetworks" => _("SMTP privileged networks") , + "postfixenablevirusscan" => _("Enable virus scan") , + "postfixrelayhost" => _("Relayhost") , + "postfixmxrelayenabled" => _("Enable MX lookup for relayhost"), + "apachehttp" => _("HTTP FreeBusy service") , + "apacheallowunauthenticatedfb" => _("Allow unauthenticated free busy"), + "postfixallowunauthenticated" => _("Accept Internet Mail") , + "cyrusimap" => _("IMAP service") , + "kolabFreeBusyFuture" => _("kolabFreeBusyFuture") , + "cyruspop3" => _("POP3 service") , + "cyrusimaps" => _("IMAP/SSL service") , + "cyruspop3s" => _("POP3/SSL service") , + "cyrussieve" => _("Sieve service") , + "cyrusquotawarn" => _("Quota settings")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl b/gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl new file mode 100644 index 000000000..ec83b7801 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl @@ -0,0 +1,249 @@ + + + + + +
+ + + + + + + + + + + + + + + + +
{t}Generic{/t}
{t}Postfix mydomain{/t} + +{render acl=$postfixmydomainACL} + +{/render} +
{t}Postfix mydestination{/t} + +{render acl=$postfixmydestinationACL} + +{/render} +
{t}Cyrus admins{/t} + +{render acl=$cyrusadminsACL} + +{/render} +
+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t}Services{/t}
+{render acl=$cyruspop3ACL} + +{/render} + + +
+{render acl=$cyruspop3sACL} + +{/render} + + +
+{render acl=$cyrusimapACL} + +{/render} + + +
+{render acl=$cyrusimapsACL} + +{/render} + + +
+{render acl=$cyrussieveACL} + +{/render} + + +
+{render acl=$proftpdftpACL} + +{/render} + + +
+{render acl=$apachehttpACL} + +{/render} + + +
+{render acl=$postfixenablevirusscanACL} + +{/render} + + +
+ +

 

+
+ + + + + + + + +
+ {t}Quota settings{/t} +
+{render acl=$cyrusquotawarnACL} + {$quotastr} +{/render} +
+ +
+ + + + + + + + + + + +
+ {t}Free/Busy settings{/t} +
+{render acl=$apacheallowunauthenticatedfbACL} + {t}Allow unauthenticated downloading of Free/Busy information{/t} +{/render} +
+{render acl=$kolabFreeBusyFutureACL} + {$fbfuture} +{/render} +
+ +

 

+
+ + + + + + + +
+ {t}SMTP privileged networks{/t} +
+
+{render acl=$postfixmynetworksACL} + +{/render} +
+ ( {t}Enter multiple values, seperated with{/t} , ) +
+ + +

 

+
+ + + + + + + + + + + + +
+ {t}SMTP smarthost/relayhost{/t} +
+{render acl=$postfixrelayhostACL} + +{/render} + +
+   +{render acl=$postfixrelayhostACL} + +{/render} +
+ + +

 

+
+ + + + + + + + + +
+ {t}Accept Internet Mail{/t} +
+{render acl=$postfixallowunauthenticatedACL} + +{/render} + +
+ + +
+ + + +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/ldap/class_goLdapServer.inc b/gosa-core/plugins/admin/systems/services/ldap/class_goLdapServer.inc new file mode 100644 index 000000000..c16df0387 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/ldap/class_goLdapServer.inc @@ -0,0 +1,97 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goLdapServer"); + var $attributes = array("goLdapBase"); + var $StatusFlag = "goLdapServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goLdapServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $cn = ""; + var $goLdapServerStatus = ""; + var $goLdapBase = ""; + var $view_logged =FALSE; + + function goLdapServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("LDAP service"); + } + + + function execute() + { + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + return($smarty->fetch(get_template_path("goLdapServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("LDAP Service"); + $fields['AllowEdit'] = true; + return($fields); + } + + + + function check() + { + $message = plugin::check(); + if(empty($this->goLdapBase)){ + $message[] = _("The given base is empty or contains invalid characters."); + } + return($message); + } + + + function save_object() + { + if(isset($_POST['goLdapServerPosted'])){ + plugin::save_object(); + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Ldap"), + "plDescription" => _("Ldap")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 96, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "goLdapBase" => _("Ldap base")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/ldap/goLdapServer.tpl b/gosa-core/plugins/admin/systems/services/ldap/goLdapServer.tpl new file mode 100644 index 000000000..24e181771 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/ldap/goLdapServer.tpl @@ -0,0 +1,13 @@ +

{t}LDAP service{/t}

+{t}LDAP URI{/t}{$must} +{render acl=$goLdapBaseACL} + +{/render} + +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/log/class_gosaLogServer.inc b/gosa-core/plugins/admin/systems/services/log/class_gosaLogServer.inc new file mode 100644 index 000000000..cade0e243 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/log/class_gosaLogServer.inc @@ -0,0 +1,108 @@ +DisplayName = _("GOsa MySQL logging service"); + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("gosaLogServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("GOsa MySQL logging service"); + $fields['AllowEdit'] = true; + $fields['AllowStart'] = FALSE; + $fields['AllowStop'] = FALSE; + $fields['AllowRestart'] = FALSE; + return($fields); + } + + + function check() + { + $message = plugin::check(); + if (empty($this->goLogDBUser)){ + $message[]= sprintf_("The attribute user is empty or contains invalid characters."); + } + if (empty($this->goLogDBPassword)){ + $message[]= sprintf_("The attribute password is empty or contains invalid characters."); + } + if (empty($this->goLogDB)){ + $message[]= sprintf_("The attribute database is empty or contains invalid characters."); + } + return($message); + } + + + function save_object() + { + if(isset($_POST['gosaLogServerPosted'])){ + plugin::save_object(); + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("GOsa logging service"), + "plDescription" => _("GOsa logging service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 98, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "goLogDB" => _("Database"), + "goLogDBUser" => _("User"), + "goLogDBPassword" => _("Password"), + "viewEntries" => _("Allow view of entries on this server")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/log/gosaLogServer.tpl b/gosa-core/plugins/admin/systems/services/log/gosaLogServer.tpl new file mode 100644 index 000000000..7dd032a36 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/log/gosaLogServer.tpl @@ -0,0 +1,35 @@ +

{t}GOsa logging database{/t}

+ + + + + + + + + + + + + +
{t}Database user{/t}{$must} +{render acl=$goLogDBUserACL} + +{/render} +
{t}Password{/t}{$must} +{render acl=$goLogDBPasswordACL} + +{/render} +
{t}Database{/t}{$must} +{render acl=$goLogDBACL} + +{/render} +
+ +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc b/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc new file mode 100644 index 000000000..742249ef7 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc @@ -0,0 +1,725 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goMailServer"); + + /* This class can't be assigned twice so it conflicts with itsself */ + var $DisplayName = ""; + var $dn = NULL; + var $StatusFlag = "goMailServerStatus"; + var $attributes = array("description","postfixHeaderSizeLimit", + "postfixMailboxSizeLimit","postfixMessageSizeLimit", + "postfixMyDestinations","postfixMyDomain","postfixMyhostname", + "postfixMyNetworks","postfixRelayhost","postfixTransportTable", + "postfixSenderRestrictions","postfixRecipientRestrictions"); + + var $goMailServerStatus ; + var $postfixHeaderSizeLimit = 0; + var $postfixMailboxSizeLimit = 0; + var $postfixMessageSizeLimit = 0; + var $postfixMyDestinations = array(); + var $postfixMyDomain = ""; + var $postfixMyhostname = ""; + var $postfixMyNetworks = array(); + var $postfixRelayhost = ""; + var $postfixTransportTable = array(); + var $postfixSenderRestrictions = array(); + var $postfixRecipientRestrictions = array(); + var $description = ""; + var $RestrictionFilters = array(); + var $TransportProtocols = array(); + var $Actions = array(); + var $cn = ""; + var $conflicts = array("goMailServer","kolab"); + var $view_logged =FALSE; + + function goMailServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("Mail smtp service (Postfix)"); + + $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED, + SERVICE_STARTED => SERVICE_STARTED, + SERVICE_RESTARTED=>SERVICE_RESTARTED); + + /* Fill RestrictionFilters TransportProtocols from external hooks */ + $str = $this->config->data['TABS']['SERVERSERVICE']; + $this->TransportProtocols =array("smtp"=>"SMTP"); + $this->RestrictionFilters = array("FILTER"=>"FILTER"); + foreach(array("ADDITIONALRESTRICTIONFILTERS"=>"RestrictionFilters", + "ADDITIONALPROTOCOLLS" =>"TransportProtocols") as $file => $var){ + if(isset($this->config->data['MAIN'][$file])){ + $file = $this->config->data['MAIN'][$file]; + if((isset($file)) && is_readable($file)){ + $tmp = file_get_contents($file); + $tmp2= split("\n",$tmp); + foreach($tmp2 as $entry){ + if(empty($entry)) continue; + if(preg_match("/:/",$entry)){ + $tmp3 = split(":",$entry); + $r = $this->$var; + $r[$tmp3[0]]=$tmp3[1]; + $this->$var = $r; + }else{ + $r = $this->$var; + $r[$entry] =$entry; + $this->$var = $r; + } + } + } + } + } + + + /* Get postfix my networks */ + $this->postfixMyNetworks = array(); + $tmp = array(); + if(isset($this->attrs['postfixMyNetworks'][0])){ + $tmp = split(",",$this->attrs['postfixMyNetworks'][0]); + foreach($tmp as $str){ + if(!empty($str)){ + $this->postfixMyNetworks[base64_encode($str)] = $str; + } + } + } + + + /* Create full name */ + if(isset($this->attrs['postfixMyDomain'][0])){ + $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0]; + } + + + /* Get postfix my domains */ + $this->postfixMyDestinations = array(); + if(isset($this->attrs['postfixMyDestinations'][0])){ + unset($this->attrs['postfixMyDestinations']['count']); + foreach($this->attrs['postfixMyDestinations'] as $str){ + $this->postfixMyDestinations[base64_encode($str)] = $str; + } + } + + + /* Get transport tables */ + $tmp = array(); + $this->postfixTransportTable = array(); + if(isset($this->attrs['postfixTransportTable'])){ + $tmp = array(); + unset($this->attrs['postfixTransportTable']['count']); + foreach($this->attrs['postfixTransportTable'] as $entry){ + + //0: offshore.vip.ms-europa.lhsystems.com smtp:172.28.0.2 + + $Number = preg_replace('/^([^:]+):.*$/', '\\1', $entry); + $Rest = trim(preg_replace("/^[0-9]*:/","",$entry)); + + $Protocol_Destination = preg_replace("/^.*\ /","",$Rest); + $Source = preg_replace("/\ .*$/","",$Rest); + + $Protocol = preg_replace ('/^([^:]+):.*$/', '\\1' ,trim($Protocol_Destination)); + $Destination = preg_replace ('/^[^:]+:(.*)$/', '\\1' ,trim($Protocol_Destination)); + + $Destination = preg_replace ("/[\[\]]/","",$Destination); + + $tmp[$Number]['src'] = $Source; + $tmp[$Number]['dst'] = $Destination; + $tmp[$Number]['prt'] = $Protocol; + } + ksort($tmp); + foreach($tmp as $entry){ + $this->postfixTransportTable[] = $entry; + } + } + + + /* Get sender restrictions */ + $tmp = array(); + $this->postfixSenderRestrictions = array(); + if(isset($this->attrs['postfixSenderRestrictions'])){ + unset($this->attrs['postfixSenderRestrictions']['count']); + foreach($this->attrs['postfixSenderRestrictions'] as $entry){ + $nr = preg_replace("/:.*$/","",$entry); + $rest= trim(preg_replace("/^[^:]+:/","",$entry)); + $src = preg_replace("/ .*$/","",$rest); + $rest= preg_replace("/^[^ ]+ /","",$rest); + $dst = preg_replace("/^.* /","",$rest); + $prt = preg_replace("/ .*$/","",$rest); + + $tmp[$nr]['src'] = $src; + $tmp[$nr]['dst'] = $dst; + $tmp[$nr]['filter'] = $prt; + } + ksort($tmp); + foreach($tmp as $entry){ + $this->postfixSenderRestrictions[] = $entry; + } + } + + + /* Get sender restrictions */ + $tmp = array(); + $this->postfixRecipientRestrictions = array(); + if(isset($this->attrs['postfixRecipientRestrictions'])){ + unset($this->attrs['postfixRecipientRestrictions']['count']); + foreach($this->attrs['postfixRecipientRestrictions'] as $entry){ + $nr = preg_replace("/:.*$/","",$entry); + $rest= trim(preg_replace("/^[^:]+:/","",$entry)); + $src = preg_replace("/ .*$/","",$rest); + $rest= preg_replace("/^[^ ]+ /","",$rest); + $dst = preg_replace("/^.* /","",$rest); + $prt = preg_replace("/ .*$/","",$rest); + + $tmp[$nr]['src'] = $src; + $tmp[$nr]['dst'] = $dst; + $tmp[$nr]['filter'] = $prt; + } + ksort($tmp); + foreach($tmp as $entry){ + $this->postfixRecipientRestrictions[] = $entry; + } + } + + } + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $delAr = array( + "TranslationDel_"=>"TranslationDel", + "SenderRestrictDel_"=>"SenderRestrictDel", + "RecipientRestrictDel_"=>"RecipientRestrictDel"); + + $once = true; + $s_action = ""; + $s_entry = ""; + + /* Check posts for some intruductions */ + foreach($_POST as $name => $value){ + foreach($delAr as $preg => $type){ + if((preg_match("/^".$preg."/",$name)) && ($once)){ + $once = false; + $s_action = $type; + $s_entry = preg_replace("/^".$preg."/","",$name); + $s_entry = preg_replace("/_[xy]$/","",$s_entry); + } + } + + + if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeablei("postfixTransportTableACL"))){ + $once = false; + $key = preg_replace("/^TranslationUp_/","",$name); + $key = preg_replace("/_[xy]$/","",$key); + $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ; + } + if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){ + $once = false; + $key = preg_replace("/^TranslationDown_/","",$name); + $key = preg_replace("/_[xy]$/","",$key); + $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ; + } + if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){ + $once = false; + $key = preg_replace("/^SenderRestrictUp_/","",$name); + $key = preg_replace("/_[xy]$/","",$key); + $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ; + } + if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){ + $once = false; + $key = preg_replace("/^SenderRestrictDown_/","",$name); + $key = preg_replace("/_[xy]$/","",$key); + $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ; + } + if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){ + $once = false; + $key = preg_replace("/^RecipientRestrictUp_/","",$name); + $key = preg_replace("/_[xy]$/","",$key); + $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ; + } + if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){ + $once = false; + $key = preg_replace("/^RecipientRestrictDown_/","",$name); + $key = preg_replace("/_[xy]$/","",$key); + $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ; + } + } + + + /* Add delete my network entry */ + if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){ + $str = $_POST['NewString_postfixMyNetworks']; + $this->postfixMyNetworks[base64_encode($str)] = $str; + } + + if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){ + foreach($_POST['Select_postfixMyNetworks'] as $str ){ + unset($this->postfixMyNetworks[$str]); + } + } + + + /* Add delete my domain entry */ + if($this->acl_is_writeable("postfixMyDestinations")){ + if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){ + $str = $_POST['NewString_postfixMyDestinations']; + $this->postfixMyDestinations[base64_encode($str)] = $str; + } + + if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){ + foreach($_POST['Select_postfixMyDestinations'] as $str ){ + unset($this->postfixMyDestinations[$str]); + } + } + } + + + /* Add sender restriction */ + if($this->acl_is_writeable("postfixSenderRestrictions")){ + if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){ + unset($this->postfixSenderRestrictions[$s_entry]); + } + + if(isset($_POST['AddpostfixSenderRestrictions'])){ + $src = $_POST['Source_postfixSenderRestrictions']; + $dst = $_POST['Destination_postfixSenderRestrictions']; + $Filter = $_POST['SenderRestrictionFilter']; + $tmp['src'] = $src; + $tmp['dst'] = $dst; + $tmp['filter'] = $Filter; + $this->postfixSenderRestrictions[] = $tmp; + } + } + + + /* Add sender restriction */ + if($this->acl_is_writeable("postfixRecipientRestrictions")){ + if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){ + unset($this->postfixRecipientRestrictions[$s_entry]); + } + + if(isset($_POST['AddpostfixRecipientRestrictions'])){ + $src = $_POST['Source_postfixRecipientRestrictions']; + $dst = $_POST['Destination_postfixRecipientRestrictions']; + $Filter = $_POST['RecipientRestrictionFilter']; + $tmp['src'] = $src; + $tmp['dst'] = $dst; + $tmp['filter'] = $Filter; + $this->postfixRecipientRestrictions[] = $tmp; + } + } + + /* Handle transports */ + if($this->acl_is_writeable("postfixTransportTable")){ + if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){ + unset($this->postfixTransportTable[$s_entry]); + } + + if(isset($_POST['AddpostfixTransportTable'])){ + $src = trim($_POST['Source_postfixTransportTable']); + $dst = trim($_POST['Destination_postfixTransportTable']); + $prt = trim($_POST['TransportProtocol']); + + if((!empty($src)) && (!empty($dst))){ + if(preg_match("/:/",$dst)){ + $tmp = split("\:",$dst); + $port = trim($tmp[1]); + $ip = trim($tmp[0]); + + if((is_ip($ip)) && (is_numeric($port))){ + $dst = "[".$ip."]:".$port; + } + } + if(is_ip($dst)){ + $dst = "[".$dst."]"; + } + $tmp2 ['src'] = $src; + $tmp2 ['dst'] = $dst; + $tmp2 ['prt'] = $prt; + + $this->postfixTransportTable[] = $tmp2; + } + } + } + + /* Set attributes */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + + /* Create divList for translation tables */ + $divTranslation = new divSelectBox("TransportProtocols"); + $divTranslation->SetHeight(90); + foreach($this->postfixTransportTable as $key => $entry){ + $img = ""; + + if($key != 0 && $this->acl_is_writeable("postfixTransportTable")){ + $img.= " "; + }else{ + $img.= ""; + } + if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){ + $img.= " "; + }else{ + $img.= ""; + } + + if($this->acl_is_writeable("postfixTransportTable")){ + $img.= " "; + } + $field1 = array("string"=> $entry['src']); + $field2 = array("string"=> $entry['dst']); + $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'"); + $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'"); + $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,)); + } + $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList()); + + + /* Create divList for sender restrictions */ + $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions"); + $DivSenderRestrict->SetHeight(90); + foreach($this->postfixSenderRestrictions as $key => $entry){ + $img =""; + + if($key != 0 && $this->acl_is_writeable("postfixSenderRestrictions")){ + $img.= " "; + }else{ + $img.= ""; + } + if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){ + $img.= " "; + }else{ + $img.= ""; + } + + if($this->acl_is_writeable("postfixSenderRestrictions")){ + $img.= " "; + } + + $field1 = array("string"=> $entry['src']); + $field2 = array("string"=> $entry['dst']); + $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'"); + $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'"); + $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,)); + } + $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList()); + + + /* Create divList for translation tables */ + $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions"); + $DivRecipientRestrict->SetHeight(90); + + foreach($this->postfixRecipientRestrictions as $key => $entry){ + $img = ""; + if($key != 0 && $this->acl_is_writeable("postfixRecipientRestrictions")){ + $img.= " "; + }else{ + $img.= ""; + } + if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){ + $img.= " "; + }else{ + $img.= ""; + } + + if($this->acl_is_writeable("postfixRecipientRestrictions")){ + $img.= " "; + } + $field1 = array("string"=> $entry['src']); + $field2 = array("string"=> $entry['dst']); + $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'"); + $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'"); + $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,)); + } + $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList()); + + + /* set new status */ + if(isset($_POST['ExecAction'])){ + if(isset($this->Actions[$_POST['action']])){ + $this->setStatus($_POST['action']); + } + } + + + $smarty->assign("is_new", $this->dn); + $smarty->assign("is_acc", $this->initially_was_account); + $smarty->assign("TransportProtocols", $this->TransportProtocols); + $smarty->assign("Actions", $this->Actions); + $smarty->assign("RestrictionFilters", $this->RestrictionFilters); + $smarty->assign("postfixTransportTable" , $this->getTransports()); + $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions()); + $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions()); + + return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__)))); + } + + + /* return transports formated for select box */ + function getTransports() + { + $ret = array(); + foreach($this->postfixTransportTable as $key => $vals){ + $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst']; + } + return($ret); + } + + + /* return sender restriction formated for select box */ + function getSenderRestrictions() + { + $ret = array(); + foreach($this->postfixSenderRestrictions as $key => $vals){ + $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst']; + } + return($ret); + } + + + /* return recipient restriction formated for select box */ + function getRecipientRestrictions() + { + $ret = array(); + foreach($this->postfixRecipientRestrictions as $key => $vals){ + $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst']; + } + return($ret); + } + + + /* Return list entry */ + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Mail smtp service (Postfix)"); + $fields['AllowEdit'] = true; + return($fields); + } + + + function save() + { + $this->postfixMyDomain = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname); + $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname); + + plugin::save(); + + /* Fix transport table*/ + $i = 0 ; + $this->attrs['postfixTransportTable'] = array(); + foreach($this->postfixTransportTable as $key => $entry){ + $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst']; + $i ++; + } + + + /* Fix sender restrictions */ + $i = 0; + $this->attrs['postfixSenderRestrictions'] =array(); + foreach($this->postfixSenderRestrictions as $key => $entry){ + $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; + $i ++; + } + + + /* Fix recipient restrictions */ + $i = 0; + $this->attrs['postfixRecipientRestrictions'] =array(); + foreach($this->postfixRecipientRestrictions as $key => $entry){ + $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; + $i ++; + } + + + /* Fix mydomains */ + $this->attrs['postfixMyDestinations'] = array(); + foreach($this->postfixMyDestinations as $entry){ + $this->attrs['postfixMyDestinations'][] =$entry; + } + + + /* Fix mydomains */ + if(count($this->postfixMyNetworks)){ + $this->attrs['postfixMyNetworks'] = ""; + foreach($this->postfixMyNetworks as $entry){ + $this->attrs['postfixMyNetworks'] .=$entry.","; + } + $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']); + }else{ + $this->attrs['postfixMyNetworks'] = array(); + } + + + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/mail with dn '%s' failed."),$this->dn)); + if($this->initially_was_account){ + $this->handle_post_events("modify"); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + } + + + function check() + { + $message =plugin::check(); + + if(!is_numeric($this->postfixHeaderSizeLimit)){ + $message[] = _("Please specify a numeric value for header size limit."); + } + + if(!is_numeric($this->postfixMailboxSizeLimit)){ + $message[] = _("Please specify a numeric value for mailbox size limit."); + } + + if(!is_numeric($this->postfixMessageSizeLimit)){ + $message[] = _("Please specify a numeric value for message size limit."); + } + + return $message; + } + + + /* Combine new array */ + function combineArrays($ar0,$ar1,$ar2) + { + $ret = array(); + if(is_array($ar0)) + foreach($ar0 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar1)) + foreach($ar1 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar2)) + foreach($ar2 as $ar => $a){ + $ret[]=$a; + } + return($ret); + } + + + function getpos($atr,$attrs) + { + $i = 0; + foreach($attrs as $attr => $name) { + $i++; + if($attr == $atr){ + return($i); + } + } + + return(-1); + } + + + /* TRansports the geiven Arraykey one position up*/ + function ArrayUp($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == 1))){ + $before = array_slice($attrs,0,($pos-2)); + $mitte = array_reverse(array_slice($attrs,($pos-2),2)); + $unten = array_slice($attrs,$pos); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* TRansports the geiven Arraykey one position up*/ + function ArrayDown($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == $cn))){ + $before = array_slice($attrs,0,($pos-1)); + $mitte = array_reverse(array_slice($attrs,($pos-1),2)); + $unten = array_slice($attrs,($pos+1)); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + function save_object() + { + plugin::save_object(); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $source_o = new goMailServer($this->config,$source['dn']); + foreach(array("postfixMyDomain","postfixMyhostname","postfixMyNetworks","postfixTransportTable","postfixSenderRestrictions","postfixRecipientRestrictions","postfixMyDestinations") as $attr){ + $this->$attr = $source_o->$attr; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Mail smtp (Postfix)"), + "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 98, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "postfixMyhostname" => _("Visible full qualified hostname"), + "description" => _("Description"), + "postfixHeaderSizeLimit" => _("Header size limit"), + "postfixMailboxSizeLimit" => _("Max mailbox size"), + "postfixMessageSizeLimit" => _("Max message size"), + "postfixMyDestinations" => _("Domains to accept mail for"), + "postfixMyNetworks" => _("Local networks"), + "postfixRelayhost" => _("Relay host"), + "postfixTransportTable" => _("Transport table"), + "postfixSenderRestrictions" => _("Restrictions for sender"), + "postfixRecipientRestrictions"=> _("Restrictions for recipient")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/mail/goMailServer.tpl b/gosa-core/plugins/admin/systems/services/mail/goMailServer.tpl new file mode 100644 index 000000000..a17d08f04 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/mail/goMailServer.tpl @@ -0,0 +1,225 @@ +

{t}Generic{/t}

+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
{t}Visible full qualified hostname{/t} + +{render acl=$postfixMyhostnameACL} + +{/render} +
{t}Max mail header size{/t} + +{render acl=$postfixMyhostnameACL} +  {t}KB{/t} +{/render} +
{t}Max mailbox size{/t} + +{render acl=$postfixMailboxSizeLimitACL} +  {t}KB{/t} +{/render}
{t}Max message size{/t} + +{render acl=$postfixMessageSizeLimitACL} +  {t}KB{/t} +{/render} +
{t}Relay host{/t} + +{render acl=$postfixRelayhostACL} + +{/render} +
+
+ + + + +
+ {t}Local networks{/t}
+{render acl=$postfixMyNetworksACL} + +{/render} +{render acl=$postfixMyNetworksACL} + +{/render} +{render acl=$postfixMyNetworksACL} + +{/render} +{render acl=$postfixMyNetworksACL} + +{/render} +
+
+

 

+

{t}Domains and routing{/t}

+
+ + + + +
+ {t}Domains to accept mail for{/t}
+{render acl=$postfixMyDestinationsACL} + +{render acl=$postfixMyDestinationsACL} + +{/render} +{render acl=$postfixMyDestinationsACL} + +{/render} +{render acl=$postfixMyDestinationsACL} + +{/render} +
+
+ + + + +
+ {t}Transports{/t}
+{render acl=$postfixTransportTableACL} + {$Div_postfixTransportTable} +{/render} + +{render acl=$postfixTransportTableACL} + +{/render} +{render acl=$postfixTransportTableACL} + +{/render} +{render acl=$postfixTransportTableACL} + +{/render} +{render acl=$postfixTransportTableACL} + +{/render} +
+
+

 

+

{t}Restrictions{/t}

+
+ + + + +
+ {t}Restrictions for sender{/t}
+{render acl=$postfixSenderRestrictionsACL} + {$Div_postfixSenderRestrictions} +{/render} +{render acl=$postfixSenderRestrictionsACL} + +{/render} +{render acl=$postfixSenderRestrictionsACL} + +{/render} +{render acl=$postfixSenderRestrictionsACL} + +{/render} +{render acl=$postfixSenderRestrictionsACL} + +{/render} +
+
+ + + + +
+ {t}Restrictions for recipient{/t}
+{render acl=$postfixRecipientRestrictionsACL} + {$Div_postfixRecipientRestrictions} +{/render} +{render acl=$postfixRecipientRestrictionsACL} + +{/render} +{render acl=$postfixRecipientRestrictionsACL} + +{/render} +{render acl=$postfixRecipientRestrictionsACL} + +{/render} +{render acl=$postfixRecipientRestrictionsACL} + +{/render} +
+
+ +

 

+
+

Action

+{if $is_new == "new"} + {t}The server must be saved before you can use the status flag.{/t} +{elseif !$is_acc} + {t}The service must be saved before you can use the status flag.{/t} +{/if} +
+ + + +

 

+
+ +   + +

+ diff --git a/gosa-core/plugins/admin/systems/services/nfs/class_servNfs.inc b/gosa-core/plugins/admin/systems/services/nfs/class_servNfs.inc new file mode 100644 index 000000000..1386de1fc --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/nfs/class_servNfs.inc @@ -0,0 +1,267 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("description","type","charset","path","option", "volume"); + var $objectclasses = array("whatever"); + var $is_account = true; + + var $name =""; // Name of + var $description =""; // description + var $type =""; // Type FS/Samba/NCP + var $charset =""; // charset + var $host =""; // hostname + var $types =array(); // Array Types NFS/Samba/NCP/netatalk + var $charsets =array(); // Array with charsets + var $path =""; // Path + var $volume =""; // Volume + var $option =""; // Options + var $is_edit =false; + var $create_mount_init = false; //mount entry set for this entry (while editing)? + var $create_mount = false; //save mount entry + + var $parent = NULL; + var $view_logged = FALSE; + + function servnfs (&$config, $parent,$entry= false,$mount =false) + { + $this->parent = $parent; + $dn = $parent->dn; + plugin::plugin ($config, $dn); + + $this->types = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP"); + if($dn){ + $this->host = substr($dn, 3, strpos($dn, ',')-3); + } + + $this->charsets = array(); + + if(!file_exists(CONFIG_DIR."/encodings")){ + print_red(sprintf(_("The file '%s/encodings' does not exist, can't get supported charsets."),CONFIG_DIR)); + }else{ + if(!is_readable(CONFIG_DIR."/encodings")){ + print_red(sprintf(_("Can't read '%s/encodings', please check permissions."),CONFIG_DIR)); + }else{ + $fp = fopen(CONFIG_DIR."/encodings","r"); + $i = 100; + while(!feof($fp)&&$i){ + $i -- ; + $str = trim(fgets($fp,256)); + + /* Skip comments */ + if(!preg_match("/^#/",$str)){ + $arr = split("\=",$str); + if(count($arr)==2){ + $this->charsets[$arr[0]]=$arr[1]; + } + } + } + } + } + + if($entry){ + list($this->name, $this->description, $this->type, $this->charset, + $this->path, $this->option, $this->volume)= split("\|",$entry."|"); + $this->is_edit = true; + + }else{ + $this->attributes[] = "name"; + } + + + $this->create_mount_init = $mount; + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + + $smarty->assign("charsets" ,$this->charsets); + $smarty->assign("types" ,$this->types); + + /* attrs to smarty*/ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + $tmp = $this->parent->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->parent->getacl($name)); + } + + $smarty->assign("name",$this->name); + if($this->is_edit){ + $smarty->assign("nameACL", preg_replace("/w/","",$this->parent->getacl("name"))); + } + $smarty->assign("allow_mounts", $this->parent->allow_mounts); + $smarty->assign("mount_checked", ""); + + $smarty->assign("appleMountsACL", $this->getacl("appleMounts")); + + if (($this->type == "netatalk") || ($this->type == "NFS")) { + if ($this->create_mount_init) { + $smarty->assign("mount_checked", "checked"); + } else { + $tmp = split(",", $this->dn); + $clip = $tmp[0] . ",ou=servers,ou=systems,"; + $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip)); + switch ($this->type) { + case "netatalk" : { + $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn; + break; + } + case "NFS" : { + $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn; + break; + } + default : { + continue; + } + } + $ldap = $this->config->get_ldap_link(); + $ldap->cat($mountdn, array('dn')); + $attrs = $ldap->fetch(); + if (count($attrs) > 0) { + $smarty->assign("mount_checked", "checked"); + } + } + } + + $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + /* This cannot be removed... */ + } + + + /* Save data to object */ + function save_object() + { + if(isset($_POST['servnfs_posted'])){ + + foreach($this->attributes as $name){ + if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){ + $this->$name = $_POST[$name]; + } + } + + if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) { + $this->create_mount = true; + } else { + $this->create_mount = false; + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + // fixme : a check for the path ? ? + if(empty($this->path)){ + $message[]=_("Please specify a valid path for your setup."); + } + + // only 0-9a-z + if(!$this->is_edit){ + if(!preg_match("/^[a-z0-9\._äüö]*$/ui",$this->name)){ + $message[]=_("Please specify a valid name for your share."); + } + if(empty($this->name)){ + $message[]=_("Please specify a name for your share."); + } + } + + if(!empty($this->description) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->description)){ + $message[]=_("Description contains invalid characters."); + } + + if(!empty($this->volume) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->volume)){ + $message[]=_("Volume contains invalid characters."); + } + + if(preg_match("/\|/",$this->path)){ + $message[]=_("Path contains invalid characters."); + } + + if(!empty($this->option) && preg_match("/^[^a-z0-9\._äüö,=\+ -]*$/ui",$this->option)){ + $message[]=_("Option contains invalid characters."); + } + + /* remove a / at the end of the path, we neither need it there nor + * do we want to check for it later. + */ + if(substr($this->path, -1, 1) == '/') { + $this->path=substr($this->path, 0, -1); + } + + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=goShareServer)", array("goExportEntry")); + while($test = $ldap->fetch()){ + if($test['dn']==$this->dn) + continue; + if(isset($test['goExportEntry'])){ + foreach($test['goExportEntry'] as $entry){ + $tmp = split("\|",$entry); + if($tmp[0] == $this->name){ + $message[]="Name already in use"; + } + } + } + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* Everything seems perfect, lets + generate an new export Entry + */ + + $s_return = ""; + + $s_return.= $this->name."|"; + $s_return.= $this->description."|"; + $s_return.= $this->type."|"; + $s_return.= $this->charset."|"; + $s_return.= $this->path."|"; + $s_return.= $this->option."|"; + $s_return.= $this->volume; + + return(array($this->name=>$s_return)); + } + + function should_create_mount() { + return $this->create_mount; + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/nfs/servnfs.tpl b/gosa-core/plugins/admin/systems/services/nfs/servnfs.tpl new file mode 100644 index 000000000..9fb70a5f4 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/nfs/servnfs.tpl @@ -0,0 +1,144 @@ +

 {t}Edit share{/t}

+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ {t}Name{/t} {$must} + +{render acl=$nameACL} + +{/render} +
+ {t}Description{/t} + +{render acl=$descriptionACL} + +{/render} +
+ {t}Path{/t} / {t}Volume{/t} + +{render acl=$pathACL} + +{/render} +
+
{t}Server{/t}
+
+{render acl=$volumeACL} + +{/render} +
+
+ + + + + + + + + + + + + + + +
+ + {t}Type{/t} + +{render acl=$typeACL} + +{/render} + {if $allow_mounts == TRUE} +

+{render acl=$netatalkmountACL} + +{/render} + +
+
+ {/if} + + {literal} + + {/literal} +
+ {t}Codepage{/t} + +{render acl=$charsetACL} + +{/render} +
+ {t}Option{/t} + +{render acl=$optionACL} + +{/render} +
+
+

 

+
+ + +
+ diff --git a/gosa-core/plugins/admin/systems/services/ntp/class_goNtpServer.inc b/gosa-core/plugins/admin/systems/services/ntp/class_goNtpServer.inc new file mode 100644 index 000000000..b179ae95b --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/ntp/class_goNtpServer.inc @@ -0,0 +1,147 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goNtpServer"); + var $attributes = array("goTimeSource"); + var $StatusFlag = "goNtpServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goNtpServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $goTimeSource = array(); + var $goNtpServerStatus= ""; + var $acl; + var $cn = ""; + var $view_logged =FALSE; + + function goNtpServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("Time service (NTP)"); + + /* Load arrays */ + $tmp = array(); + if (isset($this->attrs['goTimeSource'])){ + for ($i= 0; $i<$this->attrs['goTimeSource']['count']; $i++){ + $tmp[$this->attrs['goTimeSource'][$i]]= $this->attrs['goTimeSource'][$i]; + } + } + $this->goTimeSource= $tmp; + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Here we add a new entry */ + if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "" && $this->acl_is_writeable("goTimeSource")) { + $this->goTimeSource[$_POST['NewNTPExport']]= $_POST['NewNTPExport']; + asort($this->goTimeSource); + } + + /* Deleting an Entry, is a bit more complicated than adding one*/ + if((isset($_POST['DelNTPEnt'])) && (isset($_POST['goTimeSource'])) && $this->acl_is_writeable("goTimeSource")) { + foreach ($_POST['goTimeSource'] as $entry){ + if (isset($this->goTimeSource[$entry])){ + unset($this->goTimeSource[$entry]); + } + } + } + + $smarty->assign("goNtpServerACL", $this->getacl("goNtpServer")) ; + $smarty->assign("goTimeSource" , $this->goTimeSource); + return($smarty->fetch(get_template_path("goNtpServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Time service (NTP)"); + $fields['AllowEdit'] = true; + return($fields); + } + + + function save() + { + plugin::save(); + $this->attrs['goTimeSource'] =array(); + foreach($this->goTimeSource as $entry){ + $this->attrs['goTimeSource'][] = $entry; + } + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/goNtpServer with dn '%s' failed."),$this->dn)); + if($this->initially_was_account){ + $this->handle_post_events("modify"); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Time service"), + "plDescription" => _("Time service - NTP")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 91, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "goTimeSource" =>_("Ntp source")) + )); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Load arrays */ + $tmp = array(); + if (isset($source['goTimeSource'])){ + for ($i= 0; $i<$source['goTimeSource']['count']; $i++){ + $tmp[$source['goTimeSource'][$i]]= $source['goTimeSource'][$i]; + } + } + $this->goTimeSource= $tmp; + + + } + + function check(){ return array();} + + function save_object(){;} +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/ntp/goNtpServer.tpl b/gosa-core/plugins/admin/systems/services/ntp/goNtpServer.tpl new file mode 100644 index 000000000..25a91d432 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/ntp/goNtpServer.tpl @@ -0,0 +1,32 @@ +
+

{t}Time server{/t}

+
+ + + + +
+{render acl=$goNtpServerACL} + +{/render} +
+{render acl=$goNtpServerACL} + +{/render} +{render acl=$goNtpServerACL} + +{/render} +{render acl=$goNtpServerACL} + +{/render} +
+ +

 

+
+ +   + +
diff --git a/gosa-core/plugins/admin/systems/services/repository/class_servRepository.inc b/gosa-core/plugins/admin/systems/services/repository/class_servRepository.inc new file mode 100644 index 000000000..10321c024 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/repository/class_servRepository.inc @@ -0,0 +1,366 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + // var $ignore_account = TRUE; + var $attributes = array("FAIrepository"); + var $objectclasses = array("FAIrepositoryServer"); + + /* Repositories */ + var $repositories = array(); + var $FAIrepository = array(); + var $conflicts = array("FAIrepositoryServer"); + var $DisplayName = ""; + var $StatusFlag = ""; + + var $view_logged = FALSE; + var $fai_activated = FALSE; + + var $divlist = NULL; + + function servrepository (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $this->DisplayName = _("Repository service"); + + /* Skip this if fai is deactivated */ + $tmp= $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + $this->fai_activated = TRUE; + }else{ + return; + } + + $this->repositories = array(); + if(isset($this->attrs['FAIrepository'])){ + for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){ + $tmp = split("\|",$this->attrs['FAIrepository'][$i]); + $tmp2 = array(); + $tmp3 = array(); + + if(isset($tmp[1])){ + $tmp2['ParentServer'] = $tmp[1]; + if(empty($tmp[1])){ + $tmp2['ParentServer'] = "none"; + } + }else{ + $tmp2['ParentServer'] = "none"; + } + + if(isset($tmp[0])){ + $tmp2['Url'] = $tmp[0]; + }else{ + $tmp2['Url'] = ""; + } + + if(isset($tmp[2])){ + $tmp2['Release'] = $tmp[2]; + }else{ + $tmp2['Release'] = ""; + } + + if(isset($tmp[3])){ + $tmp3 = split(",",$tmp[3]); + foreach($tmp3 as $sec){ + $tmp2['Sections'][$sec]=$sec; + } + }else{ + $tmp['Section']=array(); + } + + $this->repositories[$tmp[2]]=$tmp2; + } + } + + + /* Create divlist */ + $this->divlist = new divListRepository($this->config,$this); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + if(!$this->fai_activated){ + $str = "

"._("You can't use this plugin until FAI is activated.")."

"; + return $str; + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $smarty->assign("is_createable",$this->acl_is_createable()); + $display= ""; + + /* Show tab dialog headers */ + /* + ADD / EDIT Repository + Dialog Handling + */ + $once = false; + if(isset($_POST['servRepository'])){ + foreach($_POST as $name => $value){ + + if(preg_match("/AddRepository/",$name) && $this->acl_is_createable()){ + $once = true; + $this->dialog = new servRepositorySetup($this->config,$this->dn); + $this->dialog->parent = $this; + } + + if((preg_match("/^delete_/",$name)) && (!$once) && $this->acl_is_removeable()){ + $once = true; + $value = preg_replace("/delete_/","",$name); + $value = base64_decode(preg_replace("/_.*$/","",$value)); + + $url = $this->repositories[$value]['Url']; + $release = $this->repositories[$value]['Release']; + + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + + $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass")); + + $found = false; + $found_in = " "; + while($attrs = $ldap->fetch()){ + foreach($attrs['FAIclass'] as $class){ + if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){ + $found = true; + $found_in .= $attrs['cn'][0]." "; + } + } + } + + if($found){ + print_red(sprintf(_("You can't delete this release, it is still used by these workstations [%s]. Please solve this dependencies first, to keep data base consistency."),$found_in)); + }else{ + if(isset($this->repositories[$value])){ + unset($this->repositories[$value]); + } + } + } + + if((preg_match("/^edit_/",$name))&&(!$once)){ + $value = preg_replace("/edit_/","",$name); + $value = base64_decode(preg_replace("/_.$/","",$value)); + + if(isset($this->repositories[$value])){ + + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + + $url = $this->repositories[$value]['Url']; + $release = $this->repositories[$value]['Release']; + + $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass")); + + $found = false; + $found_in = " "; + while($attrs = $ldap->fetch()){ + foreach($attrs['FAIclass'] as $class){ + if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){ + $found = true; + $found_in .= $attrs['cn'][0]." "; + } + } + } + + if($found){ + print_red(sprintf(_("Be careful editing this release, it is still used by these workstations [%s]."),$found_in)); + } + + if(isset($this->repositories[$value])){ + $once = true; + $obj = $this->repositories[$value]; + + /* to be able to detect if this was renamed */ + $obj['initialy_was'] = $obj['Release']; + $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); + $this->dialog->parent = $this; + } + } + } + } + } + if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){ + $obj = $this->repositories[base64_decode($_GET['id'])]; + $obj['initialy_was'] = $obj['Release']; + $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); + $this->dialog->parent = $this; + } + + if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){ + $this->dialog->save_object(); + if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){ + print_red(_("This name is already in use.")); + }else + + if(count($this->dialog->check())!=0){ + foreach($this->dialog->check() as $msg){ + print_red($msg); + } + }else{ + $obj = $this->dialog->save(); + if($this->dialog->is_new_name()){ + $oldname = $this->dialog->initialy_was; + $this->repositories[$obj['Release']]=$obj; + unset($this->repositories[$oldname]); + }else{ + $this->repositories[$obj['Release']]=$obj; + } + $this->dialog = FALSE; + $this->is_dialog= false; + } + } + + if(isset($_POST['repository_setup_cancel'])){ + $this->dialog=FALSE; + $this->is_dialog = false; + } + + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $this->is_dialog = true; + return($this->dialog->execute()); + } + + /* + Repository setup dialog handling /END + */ + + + $link = "%s"; + $edit = " "; + + /* Hide delete icon, if delete is not allowed */ + if($this->acl_is_removeable()){ + $delete = ""; + }else{ + $delete = " "; + } + + $this->divlist->execute(); + $this->divlist->setEntries($this->repositories); + $smarty->assign("Repositories",$this->divlist->Draw()); + $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE)); + return($display); + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + if(is_object($this->divlist)){ + $this->divlist->save_object(); + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + return ($message); + } + + + /* Save to LDAP */ + function save() + { + if(!$this->fai_activated) return; + + plugin::save(); + + $arr = array(); + foreach($this->repositories as $servername => $conf){ + $str = ""; + foreach($conf['Sections'] as $sec){ + $str.=$sec.","; + } + $str=preg_replace("/,$/","",$str); + + if($conf['ParentServer']=="none"){ + $conf['ParentServer'] =""; + } + + $arr[]=$conf['Url']."|".$conf['ParentServer']."|".$conf['Release']."|".$str; + } + $this->attrs['FAIrepository'] = $arr; + + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + + $ldap->cat($this->dn, array('dn')); + + if($ldap->count()){ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + $this->handle_post_events("modify"); + }else{ + $ldap->cd ($this->config->current['BASE']); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + $this->handle_post_events("add"); + } + + if($this->initially_was_account){ + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Repository service"); + $fields['AllowEdit'] = true; + $fields['AllowStart'] = $fields['AllowStop'] = $fields['AllowRestart'] = false; + return($fields); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Repository"), + "plDescription" => _("Repository service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 84, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "cn" => _("Name"), + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + "Release" => _("Releases"), + "Section" => _("Sections"), + "ParentServer" => _("Parent server"), + "Url" => _("Url")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/repository/class_servRepositorySetup.inc b/gosa-core/plugins/admin/systems/services/repository/class_servRepositorySetup.inc new file mode 100644 index 000000000..40f37b062 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/repository/class_servRepositorySetup.inc @@ -0,0 +1,225 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("Release","ParentServer","Url","cn"); + var $objectclasses = array("whatever"); + + /* Attributes */ + var $Release = ""; + var $ParentServer = ""; + var $Url = ""; + var $Sections = array(); + var $ParentServers = ""; + var $initialy_was = false; + var $cn = ""; + var $parent = ""; + + function servRepositorySetup (&$config, $dn= NULL,$data = false) + { + plugin::plugin ($config, $dn); + if($data != false){ + foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){ + if(isset($data[$atr])){ + $this->$atr = $data[$atr]; + } + } + } + } + + function GetName() + { + return($this->Release); + } + + function is_new_name() + { + if(!$this->initialy_was){ + return(true); + }else{ + if($this->Release != $this->initialy_was){ + return(true); + } + } + return(false); + } + + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + + if((isset($_POST['AddSection']))&&(isset($_POST['SectionName']))&&(!empty($_POST['SectionName']))){ + + /* Replace multiple spaces with a single, and cut of white spaces (trim)*/ + $val = preg_replace("/\ \ * /" , " ", trim($_POST['SectionName'])); + + /* check if there are more than one entry given ( "section1 section2 )*/ + if(preg_match("/ /",$val)){ + + /* Generate list of new section names */ + $vals = split(" ",$val); + + /* Add new entries */ + foreach($vals as $entry){ + $entry = trim($entry); + $this->Sections[$entry]=$entry; + } + }else{ + $this->Sections[$val]=$val; + } + } + + foreach($_POST as $name => $value){ + if(preg_match("/^delete_/",$name)){ + + $val = preg_replace("/^delete_/","",$name); + $val = base64_decode(preg_replace("/_.*$/","",$val)); + + if(isset($this->Sections[$val])){ + unset($this->Sections[$val]); + } + } + } + + $divlist = new divSelectBox("servRepositorySetup"); + $divlist->setHeight("220"); + + $dellink = ""; + + foreach($this->Sections as $sec){ + $divlist->AddEntry(array( + array("string"=>$sec), + array("string"=>sprintf($dellink,base64_encode($sec),$sec),"attach"=>"style='border-right:0px;width:20px;'") + )); + } + + $smarty->assign("Sections",$divlist->DrawList()); + + /* Get && assign acls */ + $tmp = $this->parent->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->parent->getacl($name)); + } + + /* Assign values */ + foreach($this->attributes as $attr){ + $smarty->assign($attr ,$this->$attr); + } + + $tmp = $this->getParentServers(); + $smarty->assign("ParentServers" ,$tmp); + $smarty->assign("ParentServerKeys",array_flip($tmp)); + + return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE))); + } + + /* Save data to object */ + function save_object() + { + if(isset($_POST['servRepositorySetup_Posted'])) { + + foreach($this->attributes as $attr){ + if(($this->parent->acl_is_writeable($attr)) && (isset($_POST[$attr]))){ + $this->$attr = $_POST[$attr]; + } + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(empty($this->Release)){ + $message[]=_("Please enter a value for 'release'."); + } + + if(empty($this->Url)){ + $message[] = _("Please specify a valid value for 'url'."); + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + $tmp = array(); + $tmp['ParentServer'] = $this->ParentServer; + $tmp['Url'] = $this->Url; + $tmp['Release'] = $this->Release; + $tmp['Sections'] = $this->Sections; + return($tmp); + } + + function getParentServers() + { + $ret = array(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=FAIrepositoryServer)",array("*")); + while($attr = $ldap->fetch()){ + if($attr['cn'][0] == $this->cn) continue; + $ret[$attr['cn'][0]]= $attr['cn'][0]; + } + + $ret = array_merge($ret,$this->GetHookElements()); + + $ret['none']= " "; + asort($ret); + return($ret); + } + + /* this funtions calls a defined hook + and parses all additional serverdata + */ + function GetHookElements() + { + $ret = array(); + $cmd = $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs')); + if(!empty($cmd)){ + $res = shell_exec($cmd); + $res2 = trim($res); + if(!$res){ + print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s'. Please check your gosa.conf."),$cmd)); + }elseif(empty($res2)){ + print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd)); + }else{ + $tmp = split("\n",$res); + foreach($tmp as $hook){ + /* skip empty */ + if(empty($hook)) continue; + + if(preg_match("/;/",$hook)){ + $hookinfo = split(";",$hook); + $ret[$hookinfo[0]] = $hookinfo[0]; + }else{ + $ret[$hook] = $hook; + } + } + } + } + return($ret); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/repository/servRepository.tpl b/gosa-core/plugins/admin/systems/services/repository/servRepository.tpl new file mode 100644 index 000000000..ca42710c1 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/repository/servRepository.tpl @@ -0,0 +1,9 @@ +{$Repositories} + + +

 

+
+ +   + +
diff --git a/gosa-core/plugins/admin/systems/services/repository/servRepositorySetup.tpl b/gosa-core/plugins/admin/systems/services/repository/servRepositorySetup.tpl new file mode 100644 index 000000000..29691ec44 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/repository/servRepositorySetup.tpl @@ -0,0 +1,58 @@ +

 {t}Repository{/t}

+ + + + + + +
+ + + + + + + + + + + + + +
{t}Parent server{/t} + +{render acl=$ParentServerACL} + +{/render} +
{t}Release{/t} + +{render acl=$ReleaseACL} + +{/render} +
{t}URL{/t} + +{render acl=$UrlACL} + +{/render} +
+
+ {t}Sections{/t}
+{render acl=$SectionACL} + {$Sections} +{/render} +{render acl=$SectionACL} + +{/render} +{render acl=$SectionACL} + +{/render} +
+ +

+ +   + +

+ diff --git a/gosa-core/plugins/admin/systems/services/shares/class_goShareServer.inc b/gosa-core/plugins/admin/systems/services/shares/class_goShareServer.inc new file mode 100644 index 000000000..354d78037 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/shares/class_goShareServer.inc @@ -0,0 +1,409 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goShareServer"); + var $attributes = array("goExportEntry"); + var $StatusFlag = "goShareServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goShareServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $cn = ""; + var $goShareServerStatus = ""; + var $goExportEntry = array(); + var $allow_mounts = false; + var $mounts_to_remove = array(); + var $mounts_to_add = array(); + var $view_logged =FALSE; + + function goShareServer(&$config,$dn) + { + goService::goService($config,$dn); + + $this->DisplayName = _("File service"); + + $tmp =array(); + if(isset($this->attrs['goExportEntry'])){ + if(isset($this->attrs['goExportEntry']['count'])){ + for($i= 0; $i<$this->attrs['goExportEntry']['count']; $i++){ + $entry= $this->attrs['goExportEntry'][$i]; + $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry; + } + } + } + $this->goExportEntryList = $tmp; + + $ldap = $this->config->get_ldap_link(); + $avl_objectclasses = $ldap->get_objectclasses(); + if (isset($avl_objectclasses["mount"])) { + $this->allow_mounts = true; + } + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + + if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList'])) && ($this->acl_is_writeable("name"))){ + if($this->allow_mounts){ + foreach($_POST['goExportEntryList'] as $entry){ + $this->deleteFromMountList($this->goExportEntryList[$entry]); + } + } + foreach($_POST['goExportEntryList'] as $entry){ + $this->deleteFromList($entry); + } + } + + if(isset($_POST['NewNfsAdd']) && ($this->acl_is_writeable("name"))){ + $this->oldone = NULL; + $this->o_subWindow = new servnfs($this->config, $this); + $this->o_subWindow->set_acl_category("server"); + $this->o_subWindow->set_acl_base($this->dn); + $this->dialog = true; + } + + if((isset($_POST['NewNfsEdit']))&&(isset($_POST['goExportEntryList']))){ + $entry = $this->goExportEntryList[$_POST['goExportEntryList'][0]]; + $add_mount=isset($this->mounts_to_add[$entry]); + $this->oldone=$entry; + $this->o_subWindow = new servnfs($this->config,$this,$entry,$add_mount); + $this->o_subWindow->set_acl_base($this->dn); + $this->o_subWindow->set_acl_category("server"); + $this->dialog = true; + } + if(isset($this->o_subWindow)){ + $this->o_subWindow->save_object(TRUE); + } + + /* Save NFS setup */ + if(isset($_POST['NFSsave']) && isset($this->o_subWindow) && is_object($this->o_subWindow)){ + if(count($this->o_subWindow->check())>0){ + foreach($this->o_subWindow->check() as $msg) { + print_red($msg); + } + }else{ + $this->o_subWindow->save_object(); + $newone = $this->o_subWindow->save(); + + $this->addToList($newone); + if($this->allow_mounts){ + if($this->oldone != NULL) { + $this->deleteFromMountList($this->oldone); + } + if ($this->o_subWindow->should_create_mount()) { + $this->addToMountList($newone); + } + } + unset($this->o_subWindow); + $this->dialog = false; + } + } + + /* Cancel NFS setup */ + if(isset($_POST['NFScancel'])){ + $this->oldone = NULL; + unset($this->o_subWindow); + $this->dialog = false; + } + + /* Execute NFS setup dialog*/ + if(isset($this->o_subWindow)){ + return $this->o_subWindow->execute(); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + $smarty->assign("createable",$this->acl_is_createable()); + $smarty->assign("removeable",$this->acl_is_removeable()); + + $tellSmarty= array(); + ksort($this->goExportEntryList); + foreach($this->goExportEntryList as $name=>$values){ + $tmp = split("\|",$values); + $tellSmarty[$name] = $tmp[0]." ".$tmp[4]." (".$tmp[2].")"; + } + $smarty->assign("goExportEntry",array_keys($tellSmarty)); + $smarty->assign("goExportEntryKeys",($tellSmarty)); + return($smarty->fetch(get_template_path("goShareServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("File service (Shares)"); + $fields['AllowEdit'] = true; + return($fields); + } + + + function save() + { + plugin::save(); + + /* Arrays */ + foreach (array("goExportEntryList"=>"goExportEntry") as $source => $destination){ + $this->attrs[$destination]= array(); + foreach ($this->$source as $element){ + $this->attrs[$destination][]= $element; + } + } + + + /* Process netatalk mounts */ + if($this->allow_mounts) { + $this->process_mounts(); + } + + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/shares with dn '%s' failed."),$this->dn)); + if($this->initially_was_account){ + $this->handle_post_events("modify"); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + } + + + function check() + { + $message = plugin::check(); + return($message); + } + + + function save_object() + { + if(isset($_POST['goShareServerPosted'])){ + plugin::save_object(); + } + } + + function addToList($entry){ + $key = key($entry); + $this->goExportEntryList[$key]=$entry[$key]; + } + + function deleteFromList($id) + { + /* Check if the share is used by someone */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(|(gotoProfileServer=*|$id)(gotoShare=*|$id|*||*))", array("cn")); + $cnt= $ldap->count(); + if ($cnt){ + $msg= sprintf(_("The share can't be removed since it is still used by %d users:"), $cnt); + $msg.= "

    "; + while ($attrs= $ldap->fetch()){ + $msg.= "
  • ".$attrs["cn"][0]."
  • "; + } + $msg.= "
"._("Please correct the share-/profile settings of these users"); + print_red($msg); + + } else { + /* Finally remove it */ + unset($this->goExportEntryList[$id]); + } + } + + function process_mounts() { + + $clip = "cn=" . $this->cn . ",ou=servers,ou=systems,"; + $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip)); + + $mounts = array( + "objectClass" => "container", + "cn" => "mounts" + ); + + # load data from mounts container + $ldap = $this->config->get_ldap_link(); + $ldap->cat($mountsdn, array('dn')); + $attrs = $ldap->fetch(); + + # mounts container not present yet, so we create it + if (count($attrs) == 0) { + $ldap->cd($mountsdn); + $ldap->add($mounts); + show_ldap_error($ldap->get_error(), sprintf(_("Creating system server/shares (mount container) with dn '%s' failed."),$this->dn)); + new log("modify","server/".get_class($this),$mountsdn,array_keys($mounts),$ldap->get_error()); + } + + # remove deleted mounts from the container + foreach ($this->mounts_to_remove as $entry) { + $mount=$this->returnMountEntry($entry); + $mountdn = "cn=".$mount["cn"].","."$mountsdn"; + + $ldap->cat($mountdn, array('dn')); + $attrs = $ldap->fetch(); + + if (count($attrs) != 0) { + $ldap->rmdir($mountdn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing system server/shares (mount container) with dn '%s' failed."),$this->dn)); + new log("remove","server/".get_class($this),$mountdn,array_keys($mount),$ldap->get_error()); + } + } + + # add new mounts to the container + foreach ($this->mounts_to_add as $entry) { + $mount=$this->returnMountEntry($entry); + $mountdn = "cn=".$mount["cn"].","."$mountsdn"; + $ldap->cd($mountdn); + $ldap->add($mount); + show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/shares (mount container) with dn '%s' failed."),$this->dn)); + new log("create","server/".get_class($this),$mountdn,array_keys($mount),$ldap->get_error()); + } + } + + function addToMountList($entry) + { + if($this->acl_is_writeable("name")){ + $key = key($entry); + $type = $this->get_share_type($entry[$key]); + if (($type == "netatalk") || ($type == "NFS")) { + $this->mounts_to_add[$entry[$key]] = $entry[$key]; + unset($this->mounts_to_remove[$entry[$key]]); + } + } + } + + function deleteFromMountList($entry) + { + if($this->acl_is_writeable("name")){ + $type = $this->get_share_type($entry); + if (($type == "netatalk") || ($type == "NFS")) { + $this->mounts_to_remove[$entry] = $entry; + unset($this->mounts_to_add[$entry]); + } + } + } + + function get_share_type($share) + { + $tmp = split("\|", $share); + return $tmp[2]; + } + + function returnMountEntry($entry) + { + $item = split("\|", $entry); + $name = $item[0]; + $description = $item[1]; + $type = $item[2]; + $charset = $item[3]; + $path = $item[4]; + $options = $item[5]; + + switch ($type) { + case "netatalk" : { + $mount = array( + "mountDirectory" => "/Network/Servers/", + "mountOption" => array( + "net", + "url==afp://;AUTH=NO%20USER%20AUTHENT@".$this->cn."/$name/" + ), + "mountType" => "url", + "objectClass" => "mount", + "cn" => $this->cn .":/".$name + ); + break; + } + case "NFS" : { + $mount = array( + "mountDirectory" => "/Network/Servers/", + "mountOption" => "net", + "mountType" => "nfs", + "objectClass" => "mount", + "cn" => $this->cn .":".$path + ); + break; + } + default : { + continue; + } + } + return $mount; + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $tmp =array(); + if(isset($source['goExportEntry'])){ + if(isset($source['goExportEntry']['count'])){ + for($i= 0; $i<$source['goExportEntry']['count']; $i++){ + $entry= $source['goExportEntry'][$i]; + $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry; + } + } + } + $this->goExportEntryList = $tmp; + $this->goExportEntry = $tmp; + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("File service (Shares)"), + "plDescription" => _("File service - Shares")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 90, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "name" => _("Name"), + "netatalkmount" => _("Apple mounts"), + "description" => _("Description"), + "type" => _("Type"), + "charset" => _("Charset"), + "path" => _("Path"), + "option" => _("Option"), + "volume" => _("Volume")) + + )); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/shares/goShareServer.tpl b/gosa-core/plugins/admin/systems/services/shares/goShareServer.tpl new file mode 100644 index 000000000..2c645c7f4 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/shares/goShareServer.tpl @@ -0,0 +1,33 @@ +

{t}Shares{/t}

+ + + + +
+{render acl=$nameACL mode=read_active} + +{/render} +
+ +{render acl=$nameACL} + +{/render} +{render acl=$nameACL mode=read_active} + +{/render} +{render acl=$nameACL} + +{/render} +
+ + +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc new file mode 100644 index 000000000..82ff0fbaf --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServer.inc @@ -0,0 +1,357 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goSpamServer"); + var $attributes = array("saRewriteHeader","saTrustedNetworks","saRequiredScore","saFlags","saRule"); + var $StatusFlag = "saStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goSpamServer"); + var $Flags = array("B","b","C","R","D","P"); + + var $DisplayName = ""; + var $dn = NULL; + var $cn = ""; + var $saStatus = ""; + + var $saRewriteHeader = ""; + var $saTrustedNetworks= array(); + var $TrustedNetworks = array(); + var $saRequiredScore = 0; + var $saFlags = ""; + var $Rules = array(); + var $saRule = array(); + + var $saFlagsB = false; + var $saFlagsb = false; + var $saFlagsC = false; + var $saFlagsR = false; + var $saFlagsD = false; + var $saFlagsP = false; + + var $ui = NULL; + var $acl = NULL; + var $view_logged =FALSE; + + function gospamserver(&$config,$dn, $parent= NULL) + { + /* Init class */ + goService::goService($config,$dn, $parent); + $this->DisplayName = _("Spamassassin"); + + /* Get userinfo & acls */ + $this->ui = get_userinfo(); + + /* Get Flags */ + foreach($this->Flags as $flag){ + $var = "saFlags".$flag; + if(preg_match("/".$flag."/",$this->saFlags)){ + $this->$var = TRUE; + } + } + + /* Get trusted networks */ + $this->TrustedNetworks = array(); + if(isset($this->attrs['saTrustedNetworks']) && is_array($this->attrs['saTrustedNetworks'])){ + $var = $this->attrs['saTrustedNetworks']; + for($i = 0 ; $i < $var['count'] ; $i ++ ){ + $var2 = $this->attrs['saTrustedNetworks'][$i]; + $this->TrustedNetworks[ $var2 ] = $var2; + } + } + + /* Get rules */ + $this->Rules = array(); + if(isset($this->attrs['saRule']) && is_array($this->attrs['saRule'])){ + $var = $this->attrs['saRule']; + for($i = 0 ; $i < $var['count'] ; $i ++ ){ + $var2 = $this->attrs['saRule'][$i]; + $name = preg_replace("/:.*$/","",$var2); + $value= base64_decode(preg_replace("/^.*:/","",$var2)); + $this->Rules[ $name ] = $value; + } + } + } + + + function execute() + { + $display =""; + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* If displayed, it is ever true*/ + $this->is_account =true; + + /* Get acls */ + $tmp = $this->plinfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Add new trusted network */ + if(isset($_POST['AddNewTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){ + $this->AddTrust($_POST['NewTrustName']); + } + + /* Delete selected trusted network */ + if(isset($_POST['DelTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){ + $this->DelTrust($_POST['TrustedNetworks']); + } + + /* Add a new rule */ + if(isset($_POST['AddRule']) && $this->acl_is_writeable("saRule")){ + $this->dialog = new goSpamServerRule($this->config,$this->dn); + } + + /* Cancel adding/editing specified rule */ + if(isset($_POST['CancelRule'])){ + $this->dialog = FALSE; + } + + /* Handle post to delete rules */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^editRule_/",$name) && $once && $this->acl_is_readable("saRule")){ + $once = false; + $entry = preg_replace("/^editRule_/","",$name); + $entry = preg_replace("/_(x|y)$/","",$entry); + $rule = $this->Rules[$entry]; + $name = $entry; + $this->dialog = new goSpamServerRule($this->config,$this->dn,$name,$rule); + } + if(preg_match("/^delRule_/",$name) && $once && $this->acl_is_writeable("saRule")){ + $once = false; + $entry = preg_replace("/^delRule_/","",$name); + $entry = preg_replace("/_(x|y)$/","",$entry); + unset($this->Rules[$entry]); + } + } + + /* Save rules */ + if(isset($_POST['SaveRule'])){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)){ + foreach($msgs as $msg){ + print_red($msg); + } + }elseif($this->acl_is_writeable("saRule")){ + $ret = $this->dialog->save(); + if((!empty($ret['orig_name'])) && isset($this->Rules[$ret['orig_name']])){ + unset($this->Rules[$ret['orig_name']]); + } + $this->Rules[$ret['name']] = $ret['rule']; + $this->dialog = FALSE; + } + } + + /* Display dialog if available */ + if($this->dialog && $this->dialog->config){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + /* Assign smarty vars */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign checkbox states */ + foreach($this->Flags as $Flag){ + $var = "saFlags".$Flag; + $smarty->assign("saFlags".$Flag."ACL", $this->getacl($Flag)); + if($this->$var){ + $smarty->assign("saFlags".$Flag."CHK"," checked " ); + }else{ + $smarty->assign("saFlags".$Flag."CHK",""); + } + } + + /* Create divlist */ + $DivRules = new divSelectBox("SpamRules"); + $DivRules->SetHeight(130); + + if($this->acl_is_writeable("saTrustedNetworks")){ + $actions = ""; + }else{ + + $actions = ""; + if($this->acl_is_writeable("saRule")){ + $actions.= ""; + } + } + + foreach($this->Rules as $key => $net){ + $field1 = array("string" => $key ); + $field2 = array("string" => sprintf($actions,$key,$key) , "attach" => "style='border-right:0px;width:36px;'"); + $DivRules->AddEntry(array($field1,$field2)); + } + $smarty->assign("divRules",$DivRules->DrawList()); + $smarty->assign("TrustedNetworks",$this->TrustedNetworks); + + /* Create Spam score select box entries */ + $tmp = array(); + for($i = 0 ; $i <= 20 ; $i ++ ){ + $tmp[$i] = $i; + } + $smarty->assign("SpamScore",$tmp); + + return($display.$smarty->fetch(get_template_path("goSpamServer.tpl",TRUE,dirname(__FILE__)))); + } + + + /* Add $post to list of configured trusted */ + function AddTrust($post) + { + if(!empty($post)){ + if(is_ip($post) || is_domain($post) || (is_ip_with_subnetmask($post))){ + $this->TrustedNetworks[$post] = $post; + }else{ + print_red(_("Specified value is not a valid 'trusted network' value.")); + } + } + } + + + /* Delete trusted network */ + function DelTrust($posts) + { + foreach($posts as $post){ + if(isset($this->TrustedNetworks[$post])){ + unset($this->TrustedNetworks[$post]); + } + } + } + + function save() + { + if(!$this->is_account) return; + plugin::save(); + + /* Create Flags */ + $this->attrs['saFlags'] = array(); + foreach($this->Flags as $flag){ + $var = "saFlags".$flag; + if($this->$var){ + $this->attrs['saFlags'].=$flag; + } + } + + /* Create trusted network entries */ + $this->attrs['saTrustedNetworks'] = array(); + foreach($this->TrustedNetworks as $net){ + $this->attrs['saTrustedNetworks'][] = $net; + } + + /* Rules */ + $this->attrs['saRule'] = array(); + foreach($this->Rules as $name => $rule){ + $this->attrs['saRule'][] = $name.":".base64_encode($rule); + } + + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + if($this->initially_was_account){ + $this->handle_post_events("modify"); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/spamassassin with dn '%s' failed."),$this->dn)); + } + + function check() + { + $message = plugin::check(); + + /* Check if required score is numeric */ + if(!is_numeric($this->saRequiredScore)){ + $message[] = _("Required score must be a numeric value."); + } + + return($message); + } + + + function save_object() + { + if(isset($_POST['goSpamServer'])){ + + plugin::save_object(); + + /* Check flags */ + foreach($this->Flags as $flag){ + $var = "saFlags".$flag; + + if($this->acl_is_writeable($var)){ + if(isset($_POST[$var])){ + $this->$var = TRUE; + }else{ + $this->$var = FALSE; + } + } + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Spamassassin"), + "plDescription" => _("Spamassassin")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 89, + "plSection" => array("administration"), + "plCategory" => array("server"), + "plProvidedAcls"=> array( + + "saRewriteHeader" => _("Rewrite header"), + "saTrustedNetworks" => _("Trusted networks"), + "saRequiredScore" => _("Required score"), + "saRule" => _("Rules"), + + "saFlagB" => _("Enable use of bayes filtering"), + "saFlagb" => _("Enabled bayes auto learning"), + "saFlagC" => _("Enable RBL checks"), + "saFlagR" => _("Enable use of Razor"), + "saFlagD" => _("Enable use of DDC"), + "saFlagP" => _("Enable use of Pyzor")) + )); + } + + /* For newer service management dialogs */ + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Spamassassin"); + $fields['AllowEdit'] = true; + return($fields); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc new file mode 100644 index 000000000..c8eed5d4e --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/spam/class_goSpamServerRule.inc @@ -0,0 +1,61 @@ +name = $this->orig_name= $name; + $this->rule = $rule; + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goSpamServerRule.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + + function save() + { + $ret =array(); + $ret['orig_name'] = $this->orig_name; + $ret['name'] = $this->name; + $ret['rule'] = $this->rule; + return($ret); + } + + function check() + { + $messages = plugin::check(); + return($messages); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl b/gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl new file mode 100644 index 000000000..c8b58852f --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/spam/goSpamServer.tpl @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + +

Spam tagging

+ + + + + + + + + + +
+ {t}Rewrite header{/t} + +{render acl=$saRewriteHeaderACL} + +{/render} +
+ {t}Required score{/t} + +{render acl=$saRequiredScoreACL} + +{/render} +
+ +

Trusted networks

+ + + + + +
+{render acl=$saTrustedNetworksACL} +
+{/render} +{render acl=$saTrustedNetworksACL} +   +{/render} +{render acl=$saTrustedNetworksACL} + +{/render} +{render acl=$saTrustedNetworksACL} + +{/render} +
+ +
+

 

+
+

Flags

+ + + + + +
+{render acl=$saFlagsBACL} +  {t}Enable use of bayes filtering{/t}
+{/render} +{render acl=$saFlagsbACL} +  {t}Enable bayes auto learning{/t}
+{/render} +{render acl=$saFlagsCACL} +  {t}Enable RBL checks{/t} +{/render} +
+
+ + + + +
+{render acl=$saFlagsRACL} +  {t}Enable use of Razor{/t}
+{/render} +{render acl=$saFlagsDACL} +  {t}Enable use of DDC{/t}
+{/render} +{render acl=$saFlagsPACL} +  {t}Enable use of Pyzor{/t} +{/render} +
+ +
+

 

+

Rules

+ + + + + +
+ {$divRules}
+{render acl=$saTrustedNetworksACL} + +{/render} +
+ +
+ + +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl b/gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl new file mode 100644 index 000000000..6448ab556 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/spam/goSpamServerRule.tpl @@ -0,0 +1,25 @@ +

Edit spam rule

+ + + + + + + + + +
+ {t}Name{/t} + + +
+ {t}Rule{/t} + +
+

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/syslog/class_goLogDBServer.inc b/gosa-core/plugins/admin/systems/services/syslog/class_goLogDBServer.inc new file mode 100644 index 000000000..3a193dbf2 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/syslog/class_goLogDBServer.inc @@ -0,0 +1,106 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goLogDBServer"); + var $attributes = array("goLogAdmin", "goLogPassword"); + var $StatusFlag = "goLogDBServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goLogDBServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $acl; + var $cn = ""; + var $goLogDBServerStatus = ""; + var $goLogAdmin = ""; + var $goLogPassword = ""; + var $view_logged =FALSE; + + + function goLogDBServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("Syslog service database"); + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goLogDBServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Syslog service database"); + $fields['AllowEdit'] = true; + return($fields); + } + + + function check() + { + $message = plugin::check(); + if (empty($this->goLogAdmin)){ + $message[]= sprintf_("The attribute user is empty or contains invalid characters."); + } + if (empty($this->goLogPassword)){ + $message[]= sprintf_("The attribute password is empty or contains invalid characters."); + } + return($message); + } + + + function save_object() + { + if(isset($_POST['goLogDBServerPosted'])){ + plugin::save_object(); + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Logging database"), + "plDescription" => _("Logging database")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 97, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + "goLogAdmin" => _("Admin"), + "goLogPassword" => _("Password")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/syslog/class_goSyslogServer.inc b/gosa-core/plugins/admin/systems/services/syslog/class_goSyslogServer.inc new file mode 100644 index 000000000..9461977e2 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/syslog/class_goSyslogServer.inc @@ -0,0 +1,83 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goSyslogServer"); + var $attributes = array(); + var $StatusFlag = "goSyslogServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goSyslogServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $acl; + var $cn = ""; + var $goSyslogServerStatus = ""; + var $view_logged =FALSE; + + function goSyslogServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("Syslog server"); + } + + + function execute() + { + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + + $smarty = get_smarty(); + return($smarty->fetch(get_template_path("goSyslogServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Syslog server"); + $fields['AllowEdit'] = false; + return($fields); + } + + function check() + { + $message = plugin::check(); + return($message); + } + + + function save_object() + { + plugin::save_object(); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Logging service"), + "plDescription" => _("Logging service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 88, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array() + )); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/syslog/goLogDBServer.tpl b/gosa-core/plugins/admin/systems/services/syslog/goLogDBServer.tpl new file mode 100644 index 000000000..839507029 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/syslog/goLogDBServer.tpl @@ -0,0 +1,27 @@ +

{t}Logging database information{/t}

+ + + + + + + + + +
{t}Logging DB user{/t}{$must} +{render acl=$goLogAdminACL} + +{/render} +
{t}Password{/t}{$must} +{render acl=$goLogPasswordACL} + +{/render} +
+ +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/syslog/goSyslogServer.tpl b/gosa-core/plugins/admin/systems/services/syslog/goSyslogServer.tpl new file mode 100644 index 000000000..a7ed661a8 --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/syslog/goSyslogServer.tpl @@ -0,0 +1,9 @@ +

{t}Syslog Service{/t} {t}enabled{/t}

+ +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/terminal/class_goTerminalServer.inc b/gosa-core/plugins/admin/systems/services/terminal/class_goTerminalServer.inc new file mode 100644 index 000000000..e832de04c --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/terminal/class_goTerminalServer.inc @@ -0,0 +1,141 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* This plugin only writes its objectClass */ + var $objectclasses = array("goTerminalServer"); + var $attributes = array("goXdmcpIsEnabled", "goFontPath"); + var $StatusFlag = "goTerminalServerStatus"; + + /* This class can't be assigned twice so it conflicts with itsself */ + var $conflicts = array("goTerminalServer"); + + var $DisplayName = ""; + var $dn = NULL; + var $acl; + var $cn = ""; + var $goTerminalServerStatus = ""; + var $goXdmcpIsEnabled = false; + var $goFontPath = ""; + var $view_logged =FALSE; + + + function goTerminalServer(&$config,$dn) + { + goService::goService($config,$dn); + $this->DisplayName = _("Terminal service"); + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + + $tmp = $this->plinfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Terminal service"); + $fields['AllowEdit'] = true; + return($fields); + } + + + function save() + { + plugin::save(); + + if(!$this->goXdmcpIsEnabled){ + $this->attrs['goXdmcpIsEnabled'] = "0"; + } + + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/terminalServer with dn '%s' failed."),$this->dn)); + if($this->initially_was_account){ + $this->handle_post_events("modify"); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + } + + + function check() + { + $message = plugin::check(); + if(empty($this->goFontPath)){ + $message[]=_("Terminal server, must have fontpath specified."); + } + + return($message); + } + + + function save_object() + { + if(isset($_POST['goTerminalServerPosted'])){ + plugin::save_object(); + if($this->acl_is_writeable("goXdmcpIsEnabled")){ + if(isset($_POST['goXdmcpIsEnabled'])){ + $this->goXdmcpIsEnabled = true; + }else{ + $this->goXdmcpIsEnabled = false; + } + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Terminal service"), + "plDescription" => _("Terminal service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 87, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "goXdmcpIsEnabled" => _("Temporary disable login"), + "goFontPath" => _("Font path")) + )); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/terminal/goTerminalServer.tpl b/gosa-core/plugins/admin/systems/services/terminal/goTerminalServer.tpl new file mode 100644 index 000000000..5fca2091f --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/terminal/goTerminalServer.tpl @@ -0,0 +1,27 @@ +

{t}Terminal service{/t}

+ + + + + + + + +
+{render acl=$goXdmcpIsEnabledACL} + +{/render} + {t}Temporary disable login{/t} +
{t}Font path{/t} +{render acl=$goXdmcpIsEnabledACL} + +{/render} +
+ +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc b/gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc new file mode 100644 index 000000000..f91c5f5ae --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/virus/class_goVirusServer.inc @@ -0,0 +1,248 @@ +DisplayName = _("Anti virus"); + + /* Get userinfo & acls */ + $this->ui = get_userinfo(); + + /* Get Flags */ + foreach($this->Flags as $flag){ + $var = "avFlags".$flag; + if(preg_match("/".$flag."/",$this->avFlags)){ + $this->$var = TRUE; + } + } + } + + + function execute() + { + $smarty = get_smarty(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation) { + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $display = ""; + $smarty->assign("servtabs",FALSE); + $this->is_account = true; + + /* Assign smarty vars */ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign checkbox states */ + foreach($this->Flags as $Flag){ + $var = "avFlags".$Flag; + if($this->$var){ + $smarty->assign("avFlags".$Flag."CHK"," checked " ); + }else{ + $smarty->assign("avFlags".$Flag."CHK",""); + } + } + + /* Assign value for max thread select box */ + $tmp = array(); + for($i = 1 ; $i <= 20 ; $i ++){ + $tmp[$i] = $i; + } + $smarty->assign("ThreadValues",$tmp); + + if($this->avFlagsA){ + $smarty->assign("avFlagsAState" , "" ); + }else{ + $smarty->assign("avFlagsAState" , " disabled " ); + } + + return($display.$smarty->fetch(get_template_path("goVirusServer.tpl",TRUE,dirname(__FILE__)))); + } + + + function save() + { + if(!$this->is_account) return; + + /* Create Flags */ + $this->avFlags = ""; + foreach($this->Flags as $flag){ + $var = "avFlags".$flag; + if($this->$var){ + $this->avFlags .=$flag; + } + } + + plugin::save(); + + if(!$this->avFlagsA){ + $arr = array("avArchiveMaxFileSize","avArchiveMaxRecursion","avArchiveMaxCompressionRatio"); + foreach($arr as $attr){ + $this->attrs[$attr] = array(); + } + $this->attrs['avFlags'] = preg_replace("/E/","",$this->attrs['avFlags']); + } + + /* Check if this is a new entry ... add/modify */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("objectClass")); + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + if($this->initially_was_account){ + $this->handle_post_events("modify"); + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + $this->handle_post_events("add"); + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/anti virus with dn '%s' failed."),$this->dn)); + } + + function check() + { + $message = plugin::check(); + + $mustBeNumeric = array( + "avMaxDirectoryRecursions" =>_("Maximum directory recursions"), + "avMaxThreads" =>_("Maximum threads"), + "avArchiveMaxFileSize" =>_("Maximum file size"), + "avArchiveMaxRecursion" =>_("Maximum recursions"), + "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"), + "avChecksPerDay" =>_("Checks per day")); + + foreach($mustBeNumeric as $key => $trans){ + if(!is_numeric($this->$key)){ + $message[] = sprintf(_("The specified value for '%s' must be a numeric value."),$trans); + } + } + + foreach(array("avUser"=>_("Database user"),"avHttpProxyURL"=>_("Http proxy URL"),"avDatabaseMirror"=>_("Database mirror")) as $attr => $name){ + if(!preg_match("/^[a-z0-9:_\-\.\/]*$/",$this->$attr)){ + $message[] = sprintf(_("Please specify a valid value for '%s'."),$name); + } + } + + return($message); + } + + + function save_object() + { + if(isset($_POST['goVirusServer'])){ + plugin::save_object(); + foreach($this->Flags as $flag){ + + $var = "avFlags".$flag; + if($this->acl_is_writeable($var)){ + if(isset($_POST[$var])){ + $this->$var = TRUE; + }else{ + $this->$var = FALSE; + } + } + } + } + } + + + /* For newer service management dialogs */ + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['AllowEdit'] = true; + $fields['Message'] = _("Anti virus"); + return($fields); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Anti virus"), + "plDescription" => _("Anti virus")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 96, + "plSection" => array("administration"), + "plCategory" => array("server"), + "plProvidedAcls"=> array( + + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + + "avFlagsD" =>_("Enable debugging"), + "avFlagsS" =>_("Enable mail scanning"), + "avFlagsA" =>_("Enable scanning of archives"), + "avFlagsE" =>_("Block encrypted archives"), + + "avMaxThreads" =>_("Maximum threads"), + "avMaxDirectoryRecursions" =>_("Maximum directory recursions"), + "avUser" =>_("Anti virus user"), + "avArchiveMaxFileSize" =>_("Maximum file size"), + "avArchiveMaxRecursion" =>_("Maximum recursions"), + "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"), + "avDatabaseMirror" =>_("Database mirror"), + "avChecksPerDay" =>_("Checks per day"), + "avHttpProxyURL" =>_("Http proxy URL")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl b/gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl new file mode 100644 index 000000000..af14a2b1c --- /dev/null +++ b/gosa-core/plugins/admin/systems/services/virus/goVirusServer.tpl @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + +
+

{t}Generic virus filtering{/t}

+
+ + + + + + + + + + + + + + + + + +
+ {t}Database user{/t} + +{render acl=$avUserACL} + +{/render} +
+ {t}Database mirror{/t} + +{render acl=$avDatabaseMirrorACL} + +{/render} +
+ {t}Http proxy URL{/t} + +{render acl=$avHttpProxyURLACL} + +{/render} +
+ {t}Maximum threads{/t} + +{render acl=$avMaxThreadsACL} + +{/render} +
+ +
+ + + + + + + + + + + + + + + + +
+ {t}Max directory recursions{/t} + +{render acl=$avMaxDirectoryRecursionsACL} + +{/render} +
+ {t}Checks per day{/t} + +{render acl=$avChecksPerDayACL} + +{/render} +
+{render acl=$avFlagsDACL} + +{/render} + {t}Enable debugging{/t} +
+{render acl=$avFlagsSACL} + +{/render} + {t}Enable mail scanning{/t} +
+
+

 

+

{t}Archive scanning{/t}

+
+ + + + + + + +
+{render acl=$avFlagsAACL} + +{/render} + {t}Enable scanning of archives{/t} +
+{render acl=$avFlagsEACL} + +{/render} + {t}Block encrypted archives{/t} +
+ +
+ + + + + + + + + + + + + +
{t}Maximum file size{/t} + +{render acl=$avArchiveMaxFileSizeACL} + +{/render} +
{t}Maximum recursion{/t} + +{render acl=$avArchiveMaxRecursionACL} + +{/render} +
{t}Maximum compression ratio{/t} + +{render acl=$avArchiveMaxCompressionRatioACL} + +{/render} +
+ +
+ +

 

+
+ +   + +
+ diff --git a/gosa-core/plugins/admin/systems/tabs_arpnewdevice.inc b/gosa-core/plugins/admin/systems/tabs_arpnewdevice.inc new file mode 100644 index 000000000..fe12b4090 --- /dev/null +++ b/gosa-core/plugins/admin/systems/tabs_arpnewdevice.inc @@ -0,0 +1,19 @@ +by_object[$this->current]->execute()); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/tabs_component.inc b/gosa-core/plugins/admin/systems/tabs_component.inc new file mode 100644 index 000000000..941203e24 --- /dev/null +++ b/gosa-core/plugins/admin/systems/tabs_component.inc @@ -0,0 +1,41 @@ +addSpecialTabs(); + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + } + + + function save($ignore_account= FALSE) + { + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $baseobject= $this->by_object['componentGeneric']; + $this->dn= "cn=$baseobject->cn,ou=netdevices,ou=systems,".$baseobject->base; + $baseobject->dn= $this->dn; + + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->dn= $this->dn; + } + + tabs::save(TRUE); + + /* Fix tagging if needed */ + $baseobject->handle_object_tagging(); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/tabs_phone.inc b/gosa-core/plugins/admin/systems/tabs_phone.inc new file mode 100644 index 000000000..13d5ac3c7 --- /dev/null +++ b/gosa-core/plugins/admin/systems/tabs_phone.inc @@ -0,0 +1,41 @@ +addSpecialTabs(); + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + } + + + function save($ignore_account= FALSE) + { + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $baseobject= $this->by_object['phoneGeneric']; + $this->dn= "cn=$baseobject->cn,ou=phones,ou=systems,".$baseobject->base; + $baseobject->dn= $this->dn; + + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->dn= $this->dn; + } + + tabs::save(TRUE); + + /* Fix tagging if needed */ + $baseobject->handle_object_tagging(); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/tabs_printers.inc b/gosa-core/plugins/admin/systems/tabs_printers.inc new file mode 100644 index 000000000..92963d6b0 --- /dev/null +++ b/gosa-core/plugins/admin/systems/tabs_printers.inc @@ -0,0 +1,65 @@ +dn= $dn; + $this->config= $config; + + $baseobject= NULL; + + foreach ($data as $tab){ + $this->by_name[$tab['CLASS']]= $tab['NAME']; + + if ($baseobject === NULL){ + $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this); + $this->by_object[$tab['CLASS']]= $baseobject; + } else { + $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this); + } + + $this->by_object[$tab['CLASS']]->parent= &$this; + $this->by_object[$tab['CLASS']]->set_acl_category($category); + + /* Initialize current */ + if ($this->current == ""){ + $this->current= $tab['CLASS']; + } + } + + /* Add references/acls/snapshots */ + $this->addSpecialTabs(); + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + } + + + function save($ignore_account= FALSE) + { + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $baseobject= $this->by_object['printgeneric']; + $this->dn= "cn=$baseobject->cn,ou=printers,ou=systems,".$baseobject->base; + $baseobject->dn= $this->dn; + + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->dn= $this->dn; + } + + tabs::save(FALSE); + + /* Fix tagging if needed */ + $baseobject->handle_object_tagging(); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/tabs_server.inc b/gosa-core/plugins/admin/systems/tabs_server.inc new file mode 100644 index 000000000..564e92588 --- /dev/null +++ b/gosa-core/plugins/admin/systems/tabs_server.inc @@ -0,0 +1,70 @@ +dn= $dn; + $this->config= $config; + + $baseobject= NULL; + + foreach ($data as $tab){ + $this->by_name[$tab['CLASS']]= $tab['NAME']; + + if ($baseobject === NULL){ + $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this); + $this->by_object[$tab['CLASS']]= $baseobject; + } else { + $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this); + } + + $this->by_object[$tab['CLASS']]->parent= &$this; + $this->by_object[$tab['CLASS']]->set_acl_category($category); + + /* Initialize current */ + if ($this->current == ""){ + $this->current= $tab['CLASS']; + } + } + + /* Add references/acls/snapshots */ + $this->addSpecialTabs(); + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + } + + + function save($ignore_account= FALSE) + { + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $baseobject= $this->by_object['servgeneric']; + $this->dn= "cn=$baseobject->cn,ou=servers,ou=systems,".$baseobject->base; + $baseobject->dn= $this->dn; + + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->dn= $this->dn; + $this->by_object[$key]->cn= $baseobject->cn; + } + + tabs::save(FALSE); + + /* Reload server settings after saving */ + $config= $_SESSION['config']; + $config->load_servers(); + $_SESSION['config']= $config; + + /* Fix tagging if needed */ + $baseobject->handle_object_tagging(); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/tabs_terminal.inc b/gosa-core/plugins/admin/systems/tabs_terminal.inc new file mode 100644 index 000000000..3a3b77486 --- /dev/null +++ b/gosa-core/plugins/admin/systems/tabs_terminal.inc @@ -0,0 +1,80 @@ +dn= $dn; + $this->config= $config; + + $baseobject= NULL; + + foreach ($data as $tab){ + $this->by_name[$tab['CLASS']]= $tab['NAME']; + + if ($baseobject === NULL){ + $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this); + $this->by_object[$tab['CLASS']]= $baseobject; + } else { + $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this); + } + + $this->by_object[$tab['CLASS']]->parent= &$this; + $this->by_object[$tab['CLASS']]->set_acl_category($category); + + /* Initialize current */ + if ($this->current == ""){ + $this->current= $tab['CLASS']; + } + } + + /* Add references/acls/snapshots */ + $this->addSpecialTabs(); + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + + /* Update reference, transfer variables */ + if(isset($this->by_object['termstartup'])){ + $this->by_object['termstartup']->gotoTerminalPath= $this->by_object['termgeneric']->gotoTerminalPath; + } + + $base_obj = $this->by_object['termgeneric']; + foreach($this->by_object as $name => $plug){ + $this->by_object[$name]->cn = $base_obj->cn; + } + } + + + function save($ignore_account= FALSE) + { + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $baseobject= $this->by_object['termgeneric']; + $this->dn= "cn=".$baseobject->cn.",ou=terminals,ou=systems,".$baseobject->base; + $baseobject->dn= $this->dn; + + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->dn= $this->dn; + $this->by_object[$key]->cn= $baseobject->cn; + } + + tabs::save(TRUE); + if(isset($this->by_object['printgeneric'])){ + if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){ + $this->by_object['printgeneric']->remove_from_parent(); + } + } + + /* Fix tagging if needed */ + $baseobject->handle_object_tagging(); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/tabs_winstation.inc b/gosa-core/plugins/admin/systems/tabs_winstation.inc new file mode 100644 index 000000000..cada48b80 --- /dev/null +++ b/gosa-core/plugins/admin/systems/tabs_winstation.inc @@ -0,0 +1,47 @@ +addSpecialTabs(); + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + } + + + function save($ignore_account= FALSE) + { + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + + /* add $ to end of name if mising */ + $baseobject= $this->by_object['wingeneric']; + if(!preg_match("/\\\$\$/",$baseobject->cn)){ + $baseobject->cn .= "$"; + } + + $this->dn= "uid=$baseobject->cn,".get_winstations_ou().$baseobject->base; + $baseobject->dn= $this->dn; + + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->dn= $this->dn; + } + + tabs::save(TRUE); + + /* Fix tagging if needed */ + $baseobject->handle_object_tagging(); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/tabs_workstation.inc b/gosa-core/plugins/admin/systems/tabs_workstation.inc new file mode 100644 index 000000000..6c34fd1e8 --- /dev/null +++ b/gosa-core/plugins/admin/systems/tabs_workstation.inc @@ -0,0 +1,78 @@ +dn= $dn; + $this->config= $config; + + $baseobject= NULL; + + foreach ($data as $tab){ + $this->by_name[$tab['CLASS']]= $tab['NAME']; + + if ($baseobject === NULL){ + $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this); + $this->by_object[$tab['CLASS']]= $baseobject; + } else { + $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this); + } + + $this->by_object[$tab['CLASS']]->parent= &$this; + $this->by_object[$tab['CLASS']]->set_acl_category($category); + + /* Initialize current */ + if ($this->current == ""){ + $this->current= $tab['CLASS']; + } + } + + /* Add references/acls/snapshots */ + $this->addSpecialTabs(); + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + + /* Assign current cn */ + $baseobject= $this->by_object['workgeneric']; + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->cn= $baseobject->cn; + } + } + + + function save($ignore_account= FALSE) + { + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $baseobject= $this->by_object['workgeneric']; + $this->dn= "cn=".$baseobject->cn.",ou=workstations,ou=systems,".$baseobject->base; + $baseobject->dn= $this->dn; + + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->dn= $this->dn; + $this->by_object[$key]->cn= $baseobject->cn; + } + + tabs::save(TRUE); + + if(isset($this->by_object['printgeneric'])){ + if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){ + $this->by_object['printgeneric']->remove_from_parent(); + } + } + + /* Fix tagging if needed */ + $baseobject->handle_object_tagging(); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/systems/terminal.tpl b/gosa-core/plugins/admin/systems/terminal.tpl new file mode 100644 index 000000000..dc088f867 --- /dev/null +++ b/gosa-core/plugins/admin/systems/terminal.tpl @@ -0,0 +1,176 @@ +

{t}Properties{/t}

+ + + + + +
+ + + {if $cn eq 'default'} + + {else} + + + {/if} + + + + + +
{t}Terminal template{/t}{$must} +{render acl=$cnACL} + +{/render} +
{$must} + +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+{if $member_of_ogroup} +
+
+
+ +{/if} +
+ + + + + + + + + +
+{render acl=$gotoModeACL} + +{/render} +
+{render acl=$gotoSyslogServerACL} + +{/render} +
+
+

 

+ + + + + +
+ + + + + + + + + +
+{render acl=$gotoTerminalPathACL} + +{/render} +
+{render acl=$gotoSwapServerACL} + +{/render} +
+
+ + + + + + + +
+{if $member_of_ogroup} +{render acl=$gotoNtpServerACL} + {t}Inherit time server attributes{/t} +{/render} +{else} + {t}Inherit time server attributes{/t} +{/if} +

+{render acl=$gotoNtpServerACL} + +{/render} +
+{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} +
+ +
+ +{if $cn neq 'default'} +

 

+ +{$netconfig} +{/if} + +{if $fai_activated} +

 

+

{t}Action{/t}

+ + + + + +
+{render acl=$gotoNtpServerACL} + +{/render} + +{render acl=$gotoNtpServerACL} + +{/render} +
+{/if} + + + + diff --git a/gosa-core/plugins/admin/systems/terminalService.tpl b/gosa-core/plugins/admin/systems/terminalService.tpl new file mode 100644 index 000000000..72ba28b1a --- /dev/null +++ b/gosa-core/plugins/admin/systems/terminalService.tpl @@ -0,0 +1,269 @@ + + + + + + + + + + + + +
+

{t}Keyboard{/t}

+ + + + + + + + + + + + + +
+{render acl=$gotoXKbModelACL} + +{/render} +
+{render acl=$gotoXKbLayoutACL} + +{/render} +
+{render acl=$gotoXKbVariantACL} + +{/render} +
+ +
+   + +

{t}Mouse{/t}

+ + + + + + + + + +
+{render acl=$gotoXMouseTypeACL} + +{/render} +
+{render acl=$gotoXMouseportACL} + +{/render} +
+ +
+   + +

{t}Telephone hardware{/t}

+ + + + +
{t}Telephone{/t}  +{render acl=$goFonHardwareACL} + {$hardware_list} +{/render} +
+ +
+ + + + + + + + + + + + + +

+

{t}Graphic device{/t}

+ + + + + + + + + + + + + +
+{render acl=$gotoXDriverACL} + +{/render} +
+{render acl=$gotoXResolutionACL} + +{/render } +
+{render acl=$gotoXColordepthACL} + +{/render} +
+
+   + +

{t}Display device{/t}

+ + + + + + + + + + + + +{/render} + + + + +{/render} + +
{t}Type{/t}{$gotoXMonitor}
+{render acl=$AutoSyncACL} + +{/render} + {t}Use DDC for automatic detection{/t}
+{render acl=$gotoXHsyncACL} + kHz
+{render acl=$gotoXVsyncACL} + Hz
+ +
+   + +

{t}Remote desktop{/t}

+ + + + + + + + + + + + + + + + +
+{render acl=$gotoXMethodACL} + +{/render} +
+{render acl=$gotoXdmcpServerACL} + +{/render} +
+{render acl=$gotoFontPathACL} + +{/render} +
+ +
+ + + + + + + + + +

+

+{render acl=$gotoLpdEnableACL} + +{/render} + {t}Provide print services{/t} +
+ + + + + + + +
+{render acl=$gotoLpdServerACL} + +{/render} +
+ +
+   + +

{t}Scan device{/t}

+{render acl=$gotoScannerEnableACL} + +{/render} + {t}Provide scan services{/t} +
+ + + + + + +
+{render acl=$gotoScannerEnableACL} + +{/render} +
+ +
+ +
diff --git a/gosa-core/plugins/admin/systems/terminalStartup.tpl b/gosa-core/plugins/admin/systems/terminalStartup.tpl new file mode 100644 index 000000000..ccfacfbaa --- /dev/null +++ b/gosa-core/plugins/admin/systems/terminalStartup.tpl @@ -0,0 +1,142 @@ +

{t}Boot parameters{/t}

+ + + + + + + + +
+ + + + + + + + + +{/render} + + + + +
+{render acl=$gotoBootKernelACL} + +{/render} +
+{render acl=$gotoKernelParametersACL} +
+{render acl=$gotoLdapServerACL} +( + {t}inherit from group{/t}) +{if !$JS} + +{/if} +{/render} +{render acl=$gotoLdapServerACL_inherit} + {$gotoLdapServers} +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +
+ +
+   + +{render acl=$gotoKernelParametersACL} + +{/render} + {t}use graphical bootup{/t} +
+{render acl=$gotoKernelParametersACL} + +{/render} + {t}use standard linux textual bootup{/t} +
+{render acl=$gotoKernelParametersACL} + +{/render} + {t}use debug mode for startup{/t} +
+ + + + + + + + + +

+

+ {t}Kernel modules (format: name parameters){/t} +

+{render acl=$gotoModulesACL} + +{/render} +
+{render acl=$gotoModulesACL} + +{/render} +{render acl=$gotoModulesACL} +   +{/render} +{render acl=$gotoModulesACL} + +{/render} +
+

 

+ + + + +
+{render acl=$gotoShareACL} + +{/render} +
+{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +
+
+ + + + diff --git a/gosa-core/plugins/admin/systems/wingeneric.tpl b/gosa-core/plugins/admin/systems/wingeneric.tpl new file mode 100644 index 000000000..fb58a6d66 --- /dev/null +++ b/gosa-core/plugins/admin/systems/wingeneric.tpl @@ -0,0 +1,42 @@ + + + + + +
+ + + + + + + + + + + +
{$must}
 
{$must} + + +
+
+ + + + + +
+
+ +

 

+ +{$netconfig} + + + diff --git a/gosa-core/plugins/admin/systems/workstation.tpl b/gosa-core/plugins/admin/systems/workstation.tpl new file mode 100644 index 000000000..ba8489947 --- /dev/null +++ b/gosa-core/plugins/admin/systems/workstation.tpl @@ -0,0 +1,157 @@ +

{t}Properties{/t}

+ + + + + +
+ + +{if $cn eq 'wdefault'} + +{else} + + +{/if} + + + + + + + + + +
{t}Workstation template{/t}{$must} +{render acl=$cnACL} + +{/render} +
+{render acl=$lACL} + +{/render} +
{$must} +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+{if $member_of_ogroup} +
+
+
+ +{/if} +
+ + + + + + + + + +
{t}Mode{/t} +{render acl=$gotoModeACL} + +{/render} +
+{render acl=$gotoSyslogServerACL} + +{/render} +
+

 

+ + + + + + + +
+{if $member_of_ogroup} +{render acl=$gotoNtpServerACL} + {t}Inherit time server attributes{/t} +{/render} +{else} + {t}Inherit time server attributes{/t} +{/if} +

+{render acl=$gotoNtpServerACL} + +{/render} +
+{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} +
+
+{if $cn neq 'wdefault'} +

 

+ +{$netconfig} +{/if} +

 

+ +{if $fai_activated} +

{t}Action{/t}

+ + + + + +
+{render acl=$FAIstateACL} + +{/render} + + +
+{/if} + + {if $cn eq 'wdefault'} + + + {else} + + {/if} + diff --git a/gosa-core/plugins/admin/systems/workstationService.tpl b/gosa-core/plugins/admin/systems/workstationService.tpl new file mode 100644 index 000000000..e5171fe01 --- /dev/null +++ b/gosa-core/plugins/admin/systems/workstationService.tpl @@ -0,0 +1,224 @@ + + + + + + + + + + + + +
+

{t}Keyboard{/t}

+ + + + + + + + + + + + + +
+ +{render acl=$gotoXKbModelACL} + +{/render} + +
+ +{render acl=$gotoXKbLayoutACL} + +{/render} + +
+ +{render acl=$gotoXKbVariantACL} + +{/render} + +
+ +
+   + +

{t}Mouse{/t}

+ + + + +{/render} + + + + + + +
+ +{render acl=$gotoXMouseTypeACL} + +
+ +{render acl=$gotoXMouseportACL} + +{/render} + +
+ +
+   + +

{t}Telephone hardware{/t}

+ + + + +
{t}Telephone{/t}  + +{render acl=$goFonHardwareACL} + {$hardware_list} +{/render} + +
+ +
+ + + + + + + + + + + + + +

+

{t}Graphic device{/t}

+ + + + + + + + + + + + + +
+ +{render acl=$gotoXDriverACL} + +{/render} + +
+ +{render acl=$gotoXResolutionACL} + +{/render} + +
+ +{render acl=$gotoXColordepthACL} + +{/render} + +
+
+   + +

{t}Display device{/t}

+ + + + + + + + + + + + + + + + + +
{t}Type{/t}{if $gotoXMonitor==""}{t}unknown{/t}{/if}{$gotoXMonitor}
+ +{render acl=$AutoSyncACL} + +{/render} + + {t}Use DDC for automatic detection{/t}
+ +{render acl=$gotoXHsyncACL} + kHz +{/render} + +
+ +{render acl=$gotoXVsyncACL} + Hz +{/render} + +
+ +
+   + + + +

{t}Scan device{/t}

+ +{render acl=$gotoScannerEnableACL} + +{/render} + + {t}Provide scan services{/t} +
+
+ + +
+ + + + + + diff --git a/gosa-core/plugins/admin/systems/workstationStartup.tpl b/gosa-core/plugins/admin/systems/workstationStartup.tpl new file mode 100644 index 000000000..d69b2ec72 --- /dev/null +++ b/gosa-core/plugins/admin/systems/workstationStartup.tpl @@ -0,0 +1,244 @@ + + + + + + + + +
+

{t}Boot parameters{/t}

+ + + + + + + + + + + + + +
+{render acl=$gotoBootKernelACL} + +{/render} +
+{render acl=$gotoKernelParametersACL} + +{/render} +
+{render acl=$gotoLdapServerACL} +{if $member_of_ogroup} +( + {t}inherit from group{/t}) +{if !$JS} + +{/if} +{/if} +{/render} +{render acl=$gotoLdapServerACL_inherit} + {$gotoLdapServers} +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +
+ +
+   + + + {if $fai_activated} + + {if $FAIdebianMirror == "inherited"} + + + + + + + + + + +
+

 {t}FAI server{/t} +

+
+

 {t}Release{/t} +

+
+ {render acl=$FAIdebianMirrorACL} + + {/render} + + +
+

+  {t}Assigned FAI classes{/t} +

+ {render acl=$FAIclassACL} + {$FAIScriptlist} + {/render} + {else} + + + + + + + + + + +
+

 {t}FAI server{/t} +

+
+

 {t}Release{/t} +

+
+ {render acl=$FAIdebianMirrorACL} + + {/render} + {if $javascript eq 'false'} + {render acl=$FAIdebianMirrorACL} + + {/render} + {/if} + + {render acl=$FAIreleaseACL} + + {/render} +
+

+  {t}Assigned FAI classes{/t} +

+ {render acl=$FAIclassACL} + {$FAIScriptlist} + {/render} + + {render acl=$FAIclassACL} + + {/render} + {render acl=$FAIclassACL} + + {/render} + + {/if} + + {else} + +

{t}FAI Object assignment disabled. You can't use this feature until FAI is activated.{/t}

+ + {/if} +
+ + + + + + + + + +

+

+ {t}Kernel modules (format: name parameters){/t} +

+{render acl=$gotoModulesACL} + +{/render} +
+{render acl=$gotoModulesACL} + +{/render} +{render acl=$gotoModulesACL} +   +{/render} +{render acl=$gotoModulesACL} + +{/render} +
+

 

+ + + + +
+{render acl=$gotoShareACL} + +{/render} +
+{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +
+
+ + + diff --git a/gosa-core/plugins/admin/users/class_divListUsers.inc b/gosa-core/plugins/admin/users/class_divListUsers.inc new file mode 100644 index 000000000..6ba71d714 --- /dev/null +++ b/gosa-core/plugins/admin/users/class_divListUsers.inc @@ -0,0 +1,435 @@ +parent = $parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of users")); + $this->SetSummary(_("List of users")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to create, edit and delete selected users. Having a great number of users, you may want to use the range selectors on top of the user list.")); + + $this->EnableAplhabet (true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 122; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=> " ", "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string"=>_("Username")." / "._("Department"))); + $this->AddHeader(array("string"=>_("Properties"), "attach" => "style='width:166px;'")); + $this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); + + $this->AddCheckBox("ShowTemplates" ,_("Select to see template pseudo users") ,_("Show templates") , false); + $this->AddCheckBox("ShowFunctionalUsers",_("Select to see users that have only a GOsa object"),_("Show functional users") , true); + $this->AddCheckBox("ShowUnixUsers" ,_("Select to see users that have posix settings") ,_("Show unix users") , true); + $this->AddCheckBox("ShowMailUsers" ,_("Select to see users that have mail settings") ,_("Show mail users") , true); + $this->AddCheckBox("ShowSambaUsers" ,_("Select to see users that have samba settings") ,_("Show samba users") , true); + $this->AddCheckBox("ShowProxyUsers" ,_("Select to see users that have proxy settings") ,_("Show proxy users") , true); + + /* Add SubSearch checkbox */ + $this->AddCheckBox(SEPERATOR); + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Display users matching"),"*" , true); + } + + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("users"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get copy & paste icon */ + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"users") ; + $acl = $ui->get_permissions($this->selectedBase,"users/user"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + $listhead .= + _("Base")." ". + "  "; + + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("User")."|user_new|\n"; + $s.= "...|". + " "._("Template")."|user_tplnew|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Edit")."|"."multiple_edit|\n"; + $s.= "..|". + " "._("Change password")."|"."multiple_password_change|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + } + + /* so some basic settings */ + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + /******************** + Variable init + ********************/ + + $num_users = 0; + $num_templates = 0; + + /* Variable initialation */ + $enviro = $posix = $maila = $faxac = $samba = $netatalk = ""; + $empty = "-"; + $userimg = "User"; + $tplimg = "Template"; + $editlink = "%s"; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 122; + if($this->parent->snapshotEnabled()){ + $action_col_size += 38; + } + + /* Possilbe objectClass image combinations */ + $possibleAccounts = array( + "posixAccount" => array("VAR"=>"posix" ,"IMG"=>"posiximg"), + "gotoEnvironment" => array("VAR"=>"enviro" ,"IMG"=>"eviroimg"), + "gosaMailAccount" => array("VAR"=>"maila" ,"IMG"=>"mailimg"), + "goFaxAccount" => array("VAR"=>"faxac" ,"IMG"=>"faximg"), + "sambaSamAccount" => array("VAR"=>"samba" ,"IMG"=>"sambaimg"), + "apple-user" => array("VAR"=>"netatalk" ,"IMG"=>"netatalkimg")); + + /* Pictures for Extensions */ + $usrimg =""; + $posiximg = ""; + $eviroimg = ""; + $mailimg = ""; + $fonimg = ""; + $faximg = ""; + $sambaimg = ""; + $netatalkimg = ""; + $tplcreateuserimg = ""; + + /******************** + END :: Variable init + ********************/ + + + /******************** + Append entries to divlist + ********************/ + + $ui = get_userinfo(); + + // Test Every Entry and generate divlist Array + foreach($list as $key => $val){ + + /* Create action icons */ + $action= ""; + + /* Add copy & cut icons */ + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"users") ; + $acl = $ui->get_permissions($val['dn'],"users/user"); + if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){ + $action .= " "; + $action.= " "; + } + + /* Add deactivate status */ + $lock_status = ""; + + if(isset($val['userPassword'][0]) && preg_match("/^\{[^\}]/",$val['userPassword'][0])){ + if(preg_match("/^[^\}]*+\}!/",$val['userPassword'][0])){ + $lock_status = ""; + }else{ + $lock_status = ""; + } + }else{ + $lock_status = " "; + } + + /* Generate edit icon */ + $action.= ""; + + /* Add deactivate status if we are allowed to */ + if (preg_match("/w/",$acl_all)){ + $action.= $lock_status; + } + + /* Add Password change icon, if we are able to write users/password */ + if(!in_array_ics("gosaUserTemplate",$val['objectClass']) && preg_match("/w/",$ui->get_permissions($val['dn'],"users/password"))) { + $action.= ""; + }else{ + $action.= " "; + } + + /* Add snapshot icon */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $action.= $this->GetSnapShotActions($val['dn']); + } + + /* Add remove icon, if we are allowed to remove the current user */ + if(preg_match("/d/",$ui->get_permissions($val['dn'],"users/user"))) { + $action.= ""; + }else{ + $action.= " "; + } + + /* Create phonaccopunt informationm, if conencted && is phoneAccount */ + if((in_array("goFonAccount" ,$val['objectClass']))){ + + /* Set defaults */ + $fonac = preg_replace("/%image%/", "select_phone.png", $fonimg); + $fonac = preg_replace("/%KEY%/", "$key", $fonac); + $fonac = preg_replace("/%title%/", "", $fonac); + + }else{ + $fonac=$empty; + } + + /* Set images for different types of objectClasses */ + foreach($possibleAccounts as $objectClass => $Settigns){ + if(in_array($objectClass ,$val['objectClass'])){ + $$Settigns['VAR'] = preg_replace("/%KEY%/", "$key", $$Settigns['IMG']); + }else{ + $$Settigns['VAR'] = $empty; + } + } + + /* Create userimg */ + if(in_array("gosaUserTemplate",$val['objectClass'])){ + $tpl = preg_replace("/%KEY%/", "$key", $tplimg); + $s_img_create_from_template = preg_replace("/%KEY%/", "$key", $tplcreateuserimg); + $num_templates ++; + }else{ + $s_img_create_from_template = ""; + $tpl = $userimg; + $num_users ++; + } + + /* Insert key into userimg */ + $usrimg2 = preg_replace("/%KEY%/", "$key", $usrimg); + + // Generate caption for rows + if (isset($val["sn"]) && isset($val["givenName"])){ + $display= $val["sn"][0].", ".$val["givenName"][0]." [".$val["uid"][0]."]"; + } else { + $display= "[".$val["uid"][0]."]"; + } + + /* Connect all images */ + $UseImg = $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$netatalk; + + /* Cutted objects should be displayed in light grey */ + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => sprintf($tpl,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); + $field3 = array("string" => $UseImg, "attach" => "style='width:166px;'"); + $field4 = array("string" => $s_img_create_from_template.preg_replace("/%KEY%/", "$key", $action), + "attach" => "style='width:".$action_col_size."px;border-right:0px; text-align:right;'"); + /* Add to list */ + $add = array($field0,$field1,$field2,$field3,$field4); + $this->AddElement($add); + + // Template or User + if(in_array("gosaUserTemplate",$val['objectClass'])){ + $tpls[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add; + }else{ + $users[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add; + } + } + + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_users = count($list); + + $num_user_str = _("Number of listed users"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_user_str." ".$num_users."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc new file mode 100644 index 000000000..a031e89d9 --- /dev/null +++ b/gosa-core/plugins/admin/users/class_userManagement.inc @@ -0,0 +1,1117 @@ + + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +class userManagement extends plugin +{ + /* Plugin definitions */ + var $plHeadline= "Users"; + var $plDescription= "This does something"; + + /* Dialog attributes */ + var $usertab = NULL; + var $ui = NULL; + var $templates = array(); + var $got_uid = false; + var $CopyPasteHandler = NULL; + var $CPPasswordChange = ""; // Contains the entry id which should get a new password + var $DivListUsers; + + var $pwd_change_queue = array(); + + var $start_pasting_copied_objects = FALSE; + var $current_action =""; + var $msg_dialog= NULL; + + function userManagement(&$config, $ui) + { + /* Save configuration for internal use */ + $this->config= &$config; + $this->ui= &$ui; + + /* Copy & Paste handler */ + if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){ + $this->CopyPasteHandler= new CopyPasteHandler($this->config); + } + + /* Creat dialog object */ + $this->DivListUsers = new divListUsers($this->config,$this); + + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* LOCK MESSAGE Vars */ + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_users/","/^multiple_edit/","/menu_action/"); + + $smarty = get_smarty(); // Smarty instance + $s_action = ""; // Contains the action to be taken + $s_entry = ""; // The value for s_action + + /* Edit entry button pressed? */ + if( isset($_GET['act']) && $_GET['act'] == "edit_entry" ){ + $s_action= "edit"; + $s_entry= validate($_GET['id']); + } + + /* Test relevant POST values */ + foreach($_POST as $key => $val){ + + /* Get every possible POST combination and set s_action/s_entry accordingly */ + foreach(array("del" => "user_del", + "edit" => "user_edit", + "new" => "user_new", + "new_tpl" => "user_tplnew", + "del_multiple" => "^remove_multiple_users", + "create_user_from_tpl" => "userfrom_tpl", + "change_pw" => "user_chgpw", + "editPaste" => "editPaste", + "copy_multiple" => "multiple_copy_users", + "multiple_edit" => "multiple_edit", + "cut_multiple" => "multiple_cut_users", + "multiple_password_change" => "multiple_password_change", + "copy" => "^copy", + "toggle_lock_status" => "toggle_lock_status", + "cut" => "^cut") as $act => $name){ + + if (preg_match("/".$name.".*/", $key)){ + $s_action= $act; + $s_entry= preg_replace("/".$name."_/i", "", $key); + break; + } + } + + } /* ...Test POST */ + + /* Remove coordinate prefix from POST, required by some browsers */ + $s_entry= preg_replace("/_.$/", "", $s_entry); + + /* Seperate possibly encoded tab and entry, default to tab "user" */ + if(preg_match("/.*-.*/", $s_entry)){ + $s_tab= preg_replace("/^[^-]*-/i", "" ,$s_entry); + $s_entry= preg_replace("/-[^-]*$/i", "", $s_entry); + }else{ + $s_tab= "user"; + } + + if(!$this->config->search($s_tab, 'class',array('tabs'))){ + $s_tab = "user"; + } + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "user_new"){ + $s_action = "new"; + } + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "user_tplnew"){ + $s_action = "new_tpl"; + } + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "multiple_edit"){ + $s_action = "multiple_edit"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_password_change/",$_POST['menu_action'])){ + $s_action = "multiple_password_change"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + + /******************** + Copy & Paste + ********************/ + + /* Display the copy & paste dialog, if it is currently open */ + if($this->CPPasswordChange == ""){ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + } + + + /******************** + Change password confirmed + ********************/ + + /* Perform password change */ + if (isset($_POST['password_finish'])){ + + /* For security reasons, check if user is allowed to set password again */ + $dn = $this->dn; + $acl = $this->ui->get_permissions($dn, "users/password"); + $cacl= $this->ui->get_permissions($dn, "users/user"); + + if (preg_match('/w/', $acl) || preg_match('/c/', $cacl)){ + + /* Check input and feed errors into 'message' */ + $message= array(); + + /* Sanity checks... */ + if ($_POST['new_password'] != $_POST['repeated_password']){ + + /* Matching passwords in new and repeated? */ + $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match."); + } else { + + /* Empty password is not permitted by default. */ + if ($_POST['new_password'] == ""){ + $message[]= _("The password you've entered as 'New password' is empty."); + } + } + + /* Errors, or password change? */ + if (count($message) != 0){ + + /* Show error message and continue editing */ + show_errors ($message); + return($smarty->fetch(get_template_path('password.tpl', TRUE))); + } + + $config= $this->config; + $ldap_ui= $this->config->get_ldap_link(); + if(isset($this->usertab->dn)){ + $ldap_ui->cat($this->usertab->dn,array("uid")); + $user = $ldap_ui->fetch(); + }else{ + $ldap_ui->cat($this->dn,array("uid")); + $user = $ldap_ui->fetch(); + } + if((is_array($user))&&(isset($user['uid']))){ + $username= $user['uid'][0]; + } + + /* Set password, perform required steps */ + if ($this->usertab){ + if ($this->usertab->password_change_needed()){ + $obj= $this->usertab->by_object['user']; + change_password ($this->usertab->dn, $_POST['new_password'],0, $obj->pw_storage); + if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){ + exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr); + } + new log("modify","users/".get_class($this),$this->usertab->dn,array(),"Password has been changed"); + unset($this->usertab); + $this->usertab= NULL; + } + } else { + change_password ($this->dn, $_POST['new_password']); + if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){ + exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr); + } + new log("modify","users/".get_class($this),$this->dn,array(),"Password has been changed"); + } + } else { + + /* Missing permissions, show message */ + msg_dialog::display(_("Password change failed."),_("You are not allowed to set this users password!"),WARNING_DIALOG); + } + /* Clean session, delete lock */ + del_lock ($this->dn); + unset ($this->usertab); + $this->usertab= NULL; + $this->lognames= array();; + $this->sn= ""; + $this->givenName= ""; + $this->uid= ""; + unset ($_SESSION['objectinfo']); + } + + + /******************** + Change multiple passwords requested + ********************/ + + if($s_action == "multiple_password_change"){ + $this->pwd_change_queue = $this->list_get_selected_items(); + } + + + /******************** + Change password requested + ********************/ + + /* Password change requested */ + if (($s_action == "change_pw") || (!empty($this->CPPasswordChange)) || count($this->pwd_change_queue)){ + + /* Get users whose passwords should be changed. */ + if(count($this->pwd_change_queue)){ + $s_entry= array_pop($this->pwd_change_queue); + } + + if(!empty($this->CPPasswordChange)){ + $s_entry = $this->CPPasswordChange; + $this->CPPasswordChange = ""; + } + + /* Get 'dn' from posted 'uid' */ + $this->dn= $this->list[trim($s_entry)]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + if (preg_match("/w/",$this->ui->get_permissions($this->dn,"users/password"))){ + + /* User is allowed to change passwords, save 'dn' and 'acl' for next + dialog. */ + $_SESSION['objectinfo']= $this->dn; + return ($smarty->fetch(get_template_path('password.tpl', TRUE))); + + + } else { + /* User is not allowed. Show message and cancel. */ + msg_dialog::display(_("Password change"),_("You are not allowed to set this users password!"),WARNING_DIALOG); + } + } + + + + /******************** + Edit existing entry + ********************/ + + /* User wants to edit data? */ + if (($s_action=="edit") && (!isset($this->usertab->config))){ + + /* Get 'dn' from posted 'uid', must be unique */ + $this->dn= $this->list[trim($s_entry)]['dn']; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so everyone will get the + above dialog */ + add_lock ($this->dn, $this->ui->dn); + + /* Register usertab to trigger edit dialog */ + $this->usertab= new usertabs($this->config, + $this->config->data['TABS']['USERTABS'], $this->dn); + + /* Switch tab, if it was requested by the user */ + $this->usertab->current = $s_tab; + + /* Set ACL and move DN to the headline */ + $this->usertab->set_acl_base($this->dn); + $_SESSION['objectinfo']= $this->dn; + } + + + /******************** + Edit multiple entries + ********************/ + + /* User wants to edit data? */ + if ($s_action == "multiple_edit" && !isset($this->usertab->config)){ + + $this->dn = array(); + foreach($this->list_get_selected_items() as $id){ + $this->dn[] = $this->list[$id]['dn'];; + } + $tmp = new multi_plug($this->config,"usertabs",$this->config->data['TABS']['USERTABS'], + $this->dn,$this->DivListUsers->selectedBase,"user"); + if ($tmp->entries_locked()){ + return($tmp->display_lock_message()); + } + $tmp->lock_entries($this->ui->dn); + if($tmp->multiple_available()){ + $this->usertab = $tmp; + $this->usertab->set_active_tab($s_tab); + $_SESSION['objectinfo']= $this->usertab->get_object_info(); + } + } + + + /******************** + Edit canceled + ********************/ + + /* Reset all relevant data, if we get a _cancel request */ + if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ + if (isset($this->usertab)){ + del_lock ($this->usertab->dn); + unset ($this->usertab); + } + $this->usertab= NULL; + $this->lognames= array();; + $this->sn= ""; + $this->givenName= ""; + $this->uid= ""; + unset ($_SESSION['objectinfo']); + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + $this->dns = array(); + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->list[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + if (count($this->dns) == 1){ + $info = sprintf(_("You're about to delete the following entry: %s"), @LDAP::fix($dns_names)); + } else { + $info = sprintf(_("You're about to delete the following entries: %s"), @LDAP::fix($dns_names)); + } + $this->msg_dialog = new msg_dialog(_("Delete users"),$info,CONFIRM_DIALOG); + $this->current_action = $s_action; + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if ($this->current_action == "del_multiple" && is_object($this->msg_dialog) && $this->msg_dialog->is_confirmed()){ + + $this->current_action = ""; + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $acl = $this->ui->get_permissions($dn, "users/user"); + if (preg_match('/d/', $acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$dn); + $this->usertab->set_acl_base(); + $this->usertab->delete (); + unset ($this->usertab); + $this->usertab= NULL; + } else { + msg_dialog::display(_("User delete"),sprintf(_("You are not allowed to delete the user '%s'!"),$dn),WARNING_DIALOG); + if(isset($this->ui->uid)){ + new log("security","users/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_user_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Toggle lock status for user + ********************/ + + if($s_action == "toggle_lock_status" && isset($this->list[$s_entry])){ + + /* Get entry check current status */ + $val = $this->list[$s_entry]; + $pwd = $val['userPassword'][0]; + + if(!preg_match("/^\{[^\}]/",$pwd)){ + trigger_error("Can not deactivate user which is using clear password encryption."); + }else{ + + $locked = false; + if(preg_match("/^[^\}]*+\}!/",$pwd)){ + $locked = true; + } + + /* Create ldap array to update status */ + $attrs = array("userPassword" => $pwd); + if($locked){ + $attrs['userPassword'] = preg_replace("/(^[^\}]+\})!(.*$)/","\\1\\2",$attrs['userPassword']); + }else{ + $attrs['userPassword'] = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$attrs['userPassword']); + } + + /* Write new status back to ldap */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($val['dn']); + $ldap->modify($attrs); + if($locked){ + show_ldap_error($ldap->get_error(),_("Could not set user status from locked to unlocked.")); + }else{ + show_ldap_error($ldap->get_error(),_("Could not set user status from unlocked to locked.")); + } + } + } + + + /******************** + Delete entry requested, display confirm dialog + ********************/ + + /* Remove user was requested */ + if ($s_action=="del"){ + + /* Get 'dn' from posted 'uid' */ + $this->dn= $this->list[trim($s_entry)]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + + /* Lock the current entry, so nobody will edit it during deletion */ +# add_lock ($this->dn, $this->ui->dn); +# $smarty->assign("info", sprintf(_("You're about to delete the user %s."), @LDAP::fix($this->dn))); +# $smarty->assign("multiple", false); +# return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + $this->msg_dialog = new msg_dialog( _("Delete user"),sprintf(_("You're about to delete the user %s."), @LDAP::fix($this->dn)),CONFIRM_DIALOG); + $this->current_action = $s_action; + } + + + /******************** + Delete entry confirmed + ********************/ + + /* Confirmation for deletion has been passed. User should be deleted. */ + if ($this->current_action == "del" && is_object($this->msg_dialog) && $this->msg_dialog->is_confirmed()){ + + $this->current_action = ""; + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + + $acl = $this->ui->get_permissions($this->dn, "users/user"); + + if (preg_match('/d/', $acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$this->dn); + $this->usertab->set_acl_base(); + $this->usertab->delete (); + unset ($this->usertab); + $this->usertab= NULL; + msg_dialog::display(_("User delted"),_("User successfully removed."),INFO_DIALOG); + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + msg_dialog::display(_("User delete"),_("You are not allowed to delete this user!"),WARNING_DIALOG); + + if(isset($this->ui->uid)){ + new log("security","users/".get_class($this),$this->dn,array(),"Tried to trick deletion."); + } + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + /******************** + Delete entry Canceled + ********************/ + + /* Delete user canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + } + + + /******************** + Edit entry finished (Save) + ********************/ + + /* Finish user edit is triggered by the tabulator dialog, so + the user wants to save edited data. Check and save at this + point. */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->usertab->config))){ + + /* Check tabs, will feed message array */ + $this->usertab->last= $this->usertab->current; + $this->usertab->save_object(); + $message= $this->usertab->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + /* No errors. Go ahead and prepare to ask for a password + in case we're creating a new user. 'dn' will be 'new' + in this case. It is set to the correct value later. */ + if ($this->dn == "new"){ + $set_pass= 1; + } else { + $set_pass= 0; + } + + /* Save user data to ldap */ + if($this->usertab->save() == 1){ + return; + } + + if (!isset($_POST['edit_apply'])){ + /* User has been saved successfully, remove lock from LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + + /* In case of new users, ask for a password, skip this for templates */ + if (($set_pass || $this->usertab->password_change_needed()) && !$this->is_template){ + $this->dn = $this->usertab->dn; + return($smarty->fetch(get_template_path('password.tpl', TRUE))); + } + + unset ($this->usertab); + $this->usertab= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /******************** + We want to create a new user, so fetch all available user templates + ********************/ + + /* Generate template list */ + if (($s_action=="new")||($s_action=="create_user_from_tpl")){ + + $this->templates= array(); + $ldap= $this->config->get_ldap_link(); + + /* Create list of templates */ + foreach ($this->config->departments as $key => $value){ + + /* Get acls from different ou's */ + $acl = $this->ui->get_permissions("cn=dummy,".get_people_ou().$value,"users/user") ; + + /* If creation of a new user is allowed, append this template */ + if (preg_match("/c/",$acl)){ + + /* Search all templates from the current dn */ + $ldap->cd (get_people_ou().$value); + $ldap->search ("(objectClass=gosaUserTemplate)", array("uid")); + + /* Append */ + if ($ldap->count() != 0){ + while ($attrs= $ldap->fetch()){ + $this->templates[$ldap->getDN()]= + $attrs['uid'][0]." - ".@LDAP::fix($key); + } + $this->templates['none']= _("none"); + } + } + } + + /* Sort templates */ + natcasesort ($this->templates); + reset ($this->templates); + } + + + /******************** + Create a new user,template, user from template + ********************/ + + /* Check selected options for template */ + if (isset($_POST['template_continue'])){ + $message = array(); + if(!isset($_POST['template']) || (empty($_POST['template']))){ + $message[] = _("Please select a valid template."); + } + if(!isset($_POST['sn']) || (empty($_POST['sn']))){ + $message[]= _("The required field 'Name' is not set."); + } + if(!isset($_POST['givenName']) || (empty($_POST['givenName']))){ + $message[]= _("The required field 'Given name' is not set."); + } + + /* Show error message / continue editing */ + if (count($message) > 0){ + show_errors ($message); + + foreach(array("sn", "givenName", "uid", "template") as $attr){ + if(isset($_POST[$attr])){ + $smarty->assign("$attr", $_POST[$attr]); + }else{ + $smarty->assign("$attr", ""); + } + } + $smarty->assign("templates",$this->templates); + $smarty->assign("got_uid",$this->got_uid); + $smarty->assign("edit_uid",false); + return($smarty->fetch(get_template_path('template.tpl', TRUE))); + + } + } + + /* New user/template request */ + if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){ + /* By default we set 'dn' to 'new', all relevant plugins will + react on this. */ + $this->dn= "new"; + + if (isset($this->config->current['IDGEN'])){ + $this->got_uid= false; + } else { + $this->got_uid= true; + } + + /* Create new usertab object */ + $this->usertab= new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn); + $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase; + $this->usertab->set_acl_base('dummy,'.$this->DivListUsers->selectedBase); + + /* Take care about templates */ + if ($s_action=="new_tpl"){ + $this->is_template= TRUE; + $this->usertab->set_template_mode (); + } else { + $this->is_template= FALSE; + } + + /* Use template if there are any of them */ + if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){ + foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){ + $smarty->assign("$attr", $this->$attr); + } + if ($s_action=="create_user_from_tpl"){ + $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']); + } else { + $smarty->assign("template", "none"); + } + $smarty->assign("edit_uid", ""); + return($smarty->fetch(get_template_path('template.tpl', TRUE))); + } + } + + /******************** + Template selected continue edit + ********************/ + + /* Continue template editing */ + if ((isset($_POST['template_continue'])) && ($_POST['template'] != 'none') && (!isset($_POST['uid']))){ + + $this->sn = $_POST['sn']; + $this->givenName = $_POST['givenName']; + + /* Check for requred values */ + $message= array(); + if ($this->sn == "") { + $message[]= _("The required field 'Name' is not set."); + } + if ($this->givenName == "") { + $message[]= _("The required field 'Given name' is not set."); + } + + /* Check if dn is used */ + $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']); + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($dn); + $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName")); + if ($ldap->count () != 0){ + $message[]= _("A person with the choosen name is already used in this tree."); + } + + /* Show error message / continue editing */ + if (count($message) > 0){ + show_errors ($message); + } else { + $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName); + if (isset($this->config->current['IDGEN']) && + $this->config->current['IDGEN'] != ""){ + $uids= gen_uids ($this->config->current['IDGEN'], $attributes); + if (count($uids)){ + $smarty->assign("edit_uid", "false"); + $smarty->assign("uids", $uids); + $this->uid= current($uids); + } + } else { + $smarty->assign("edit_uid", ""); + $this->uid= ""; + } + $this->got_uid= true; + } + + foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){ + $smarty->assign("$attr", $this->$attr); + } + if (isset($_POST['template'])){ + $smarty->assign("template", $_POST['template']); + } + return($smarty->fetch(get_template_path('template.tpl', TRUE))); + } + + /******************** + No template selected continue edit + ********************/ + + /* No template. Ok. Lets fill data into the normal user dialog */ + if (isset($_POST['template_continue']) && $_POST['template'] == 'none'){ + foreach(array("sn", "givenName", "uid") as $attr){ + if (isset($_POST[$attr])){ + $this->usertab->by_object['user']->$attr= $_POST[$attr]; + } + } + } + + + /******************** + Template selected continue edit + ********************/ + + /* Finish template preamble */ + if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){ + + /* Might not be filled if IDGEN is unset */ + $this->sn = $_POST['sn']; + $this->givenName = $_POST['givenName']; + + /* Move user supplied data to sub plugins */ + $this->uid = $_POST['uid']; + $this->usertab->uid = $this->uid; + $this->usertab->sn = $this->sn; + $this->usertab->givenName = $this->givenName; + $template_dn = $_POST['template']; + $this->usertab->adapt_from_template($template_dn); + $template_base = preg_replace("/^[^,]+,".normalizePreg(get_people_ou())."/", '', $template_dn); + $this->usertab->by_object['user']->base= $template_base; + } + + + /******************** + If no template was selected set base + ********************/ + + if (isset($_POST['template_continue']) && ($_POST['template'] == 'none')){ + $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase; + } + + + /******************** + Display subdialog + ********************/ + + /* Show tab dialog if object is present */ + if(isset($this->usertab->config)){ + $display= $this->usertab->execute(); + + /* Don't show buttons if tab dialog requests this */ + + $dia = FALSE; + if(isset($this->usertab->by_object[$this->usertab->current]->dialog)){ + $dia = $this->usertab->by_object[$this->usertab->current]->dialog; + } + + if(!is_object($dia) && $dia != TRUE){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + return ($display); + } + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListUsers->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Return rendered main page */ + /* Display dialog with system list */ + $this->DivListUsers->parent = $this; + $this->DivListUsers->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListUsers->SubSearch){ + $this->DivListUsers->AddDepartments($this->DivListUsers->selectedBase,4,1); + } + $this->reload(); + $this->DivListUsers->setEntries($this->list); + return($this->DivListUsers->Draw()); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array(get_people_ou().$this->DivListUsers->selectedBase)); + } + + + function reload() + { + /* Set base for all searches */ + $base= $this->DivListUsers->selectedBase; + $this->list =array(); + + /* Get filter configuration */ + $Regex = $this->DivListUsers->Regex; + $SubSearch = $this->DivListUsers->SubSearch; + $ShowTemplates = $this->DivListUsers->ShowTemplates; + $ShowFunctionalUsers = $this->DivListUsers->ShowFunctionalUsers; + $ShowUnixUsers = $this->DivListUsers->ShowUnixUsers; + $ShowMailUsers = $this->DivListUsers->ShowMailUsers; + $ShowSambaUsers = $this->DivListUsers->ShowSambaUsers; + $ShowProxyUsers = $this->DivListUsers->ShowProxyUsers; + + /* Setup filter depending on selection */ + $filter=""; + if ($this->config->current['SAMBAVERSION'] == 3){ + $samba= "sambaSamAccount"; + } else { + $samba= "sambaAccount"; + } + + if ($ShowFunctionalUsers){ + $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)". + "(objectClass=gosaMailAccount)(objectClass=$samba)". + "(objectClass=gosaProxyAccount))))"; + } + if ($ShowUnixUsers){ + $filter.= "(objectClass=posixAccount)"; + } + if ($ShowMailUsers){ + $filter.= "(objectClass=gosaMailAccount)"; + } + if ($ShowSambaUsers){ + $filter.= "(objectClass=$samba)"; + } + if ($ShowProxyUsers){ + $filter.= "(objectClass=gosaProxyAccount)"; + } + if ($ShowTemplates){ + $filter= "(|(objectClass=gosaUserTemplate)(&(objectClass=gosaAccount)(|$filter)))"; + } else { + $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|$filter))"; + } + $filter= "(&(|(uid=".normalizeLdap($Regex).")(sn=".normalizeLdap($Regex).")(givenName=".normalizeLdap($Regex)."))$filter)"; + + /* Generate userlist */ + $ldap= $this->config->get_ldap_link(TRUE); + + if ($SubSearch){ + $ListTemp = get_list($filter, "users", $base, + array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SUBSEARCH | GL_SIZELIMIT); + } else { + $base= get_people_ou().$base; + $ListTemp = get_list($filter, "users", $base, + array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SIZELIMIT); + } + $SortTemp = array(); + $List = array(); + foreach($ListTemp as $Key => $Entry){ + + /* Skip entries that are not located under the people ou (normaly 'ou=people,') + * Else winstations will be listed too, if you use the subtree flag. + */ + if(!preg_match("/".normalizePreg(get_people_ou())."/i",$Entry['dn'])){ + continue; + }else{ + + // Generate caption for rows + if (isset($Entry["sn"]) && isset($Entry["givenName"])){ + $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]"; + } else { + $display= "[".$Entry["uid"][0]."]"; + } + + $display = strtolower($display); + $List[$display] = $Entry; + $SortTemp[$display] = $display; + } + } + sort($SortTemp); + reset($SortTemp); + + $this->list = array(); + foreach($SortTemp as $Key){ + $this->list[] = $List[$Key]; + } + } + + function remove_lock() + { + /* Remove user lock if a DN is marked as "currently edited" */ + if (isset($this->usertab->dn)){ + del_lock ($this->usertab->dn); + } + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->list[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"usertabs","USERTABS","users"); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->list[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","usertabs","USERTABS","users"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","usertabs","USERTABS","users"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListUsers->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */ + if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){ + $s_entry = $this->CopyPasteHandler->last_entry(); + $this->reload(); + foreach($this->list as $key => $entry){ + if($entry['dn'] == $s_entry){ + $this->CPPasswordChange = $key; + } + } + } + + /* Return dialog data */ + if(!empty($data) && $this->CPPasswordChange == ""){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + function save_object() + { + /* Handle divlist filter && department selection*/ + if(!is_object($this->usertab)){ + $this->DivListUsers->save_object(); + } + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + /* A set of disabled and therefore overloaded functions. They are + not needed in this class. */ + function remove_from_parent() { } + function check() { } + function save() { } + function adapt_from_template($dn) { } + function password_change_needed() { } + +} /* ... class userManagement */ +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/users/main.inc b/gosa-core/plugins/admin/users/main.inc new file mode 100644 index 000000000..d545835f7 --- /dev/null +++ b/gosa-core/plugins/admin/users/main.inc @@ -0,0 +1,65 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('userManagement'); + } +} else { + /* Create usermanagement object on demand */ + if (!isset($_SESSION['userManagement']) || + (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['userManagement']= new userManagement ($config, $_SESSION['ui']); + $_SESSION['userManagement']->set_acl_category("users"); + } + $userManagement= $_SESSION['userManagement']; + $userManagement->save_object(); + $output= $userManagement->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/user.png'), + _("User administration"), + "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/user.png'), + _("User administration")); + } + + /* Generate dialog output */ + $display.= $output; + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('userManagement'); + } + + /* Show and save dialog */ + $_SESSION['userManagement']= $userManagement; +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/users/password.tpl b/gosa-core/plugins/admin/users/password.tpl new file mode 100644 index 000000000..83dfc2494 --- /dev/null +++ b/gosa-core/plugins/admin/users/password.tpl @@ -0,0 +1,32 @@ +

+ {t}To change the user password use the fields below. The changes take effect immediately. Please memorize the new password, because the user wouldn't be able to login without it.{/t} +

+ +

+ {t}Changing the password affects your authentification on mail, proxy, samba and unix services.{/t} +

+ + + + + + + + + + +
+
+

+ +   + +

+ + + diff --git a/gosa-core/plugins/admin/users/remove.tpl b/gosa-core/plugins/admin/users/remove.tpl new file mode 100644 index 000000000..eb4147166 --- /dev/null +++ b/gosa-core/plugins/admin/users/remove.tpl @@ -0,0 +1,23 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + + + {else} + + + {/if} +   +

+ diff --git a/gosa-core/plugins/admin/users/tabs_user.inc b/gosa-core/plugins/admin/users/tabs_user.inc new file mode 100644 index 000000000..c6565337e --- /dev/null +++ b/gosa-core/plugins/admin/users/tabs_user.inc @@ -0,0 +1,142 @@ +base= $this->by_object['user']->base; + + /* Add references/acls/snapshots */ + $this->addSpecialTabs(); + + } + + function save_object($save_current= FALSE) + { + tabs::save_object($save_current); + + /* Update reference, transfer variables */ + $baseobject= $this->by_object['user']; + foreach ($this->by_object as $name => $obj){ + + /* Adding uid to sub plugins of connectivity */ + if($name == "connectivity"){ + foreach ($obj->plugin_name as $plg_name){ + if(isset($obj->plugin[$plg_name]->uid)){ + $obj->plugin[$plg_name]->uid = $baseobject->uid; + } + } + } + + /* Don't touch base object */ + if ($name != 'user'){ + $obj->parent= &$this; + $obj->uid= $baseobject->uid; + $obj->sn= $baseobject->uid; + $obj->givenName= $baseobject->uid; + } + + /* Copy mail if needed */ + if ($name == "gofaxAccount"){ + if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){ + $obj->mail= $this->by_object['mailAccount']->mail; + } + } + + $this->by_object[$name]= $obj; + + /* Update parent in base object */ + $this->by_object['user']->parent= &$this; + } + + /* Move facsimile / phone number if nessecary */ + if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){ + + /* Move number to fax plugin */ + $this->by_object['gofaxAccount']->facsimileTelephoneNumber= + $this->by_object['user']->facsimileTelephoneNumber; + + /* Move phone number if plugin exists */ + if (isset($this->by_object['phoneAccount']) && + !$this->by_object['phoneAccount']->is_account){ + $this->by_object['phoneAccount']->phoneNumbers= array(); + if ($this->by_object['user']->telephoneNumber != ""){ + $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber; + } + } + } + + /* Move number from fax plugin */ + if ($this->last == "gofaxAccount"){ + + $this->by_object['user']->facsimileTelephoneNumber= + $this->by_object['gofaxAccount']->facsimileTelephoneNumber; + } + + /* Move number from fax plugin */ + if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){ + reset($this->by_object['phoneAccount']->phoneNumbers); + $number= key($this->by_object['phoneAccount']->phoneNumbers); + + /* Only the first phoneAccount number, if it is not empty */ + if(!empty($number)){ + $this->by_object['user']->telephoneNumber= $number; + } + } + + /* Possibly change acl base */ + $this->set_acl_base(); + } + + function save($ignore_account= FALSE) + { + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $baseobject= $this->by_object['user']; + $baseobject->update_new_dn(); + if ($this->dn != 'new'){ + + $new_dn= $baseobject->new_dn; + + if (strtolower($this->dn) != strtolower($new_dn)){ + + /* Udpate acls */ + $baseobject->update_acls($this->dn,$new_dn); + $baseobject->move($this->dn, $new_dn); + $this->by_object['user']= $baseobject; + + /* Did we change ourselves? Update ui object. */ + change_ui_dn($this->dn, $new_dn); + } + } + + $this->dn= $baseobject->new_dn; + + return tabs::save(); + } + + + function set_template_mode() + { + foreach ($this->by_object as $key => $obj){ + $this->by_object[$key]->is_template= TRUE; + } + } + + function saveCopyDialog() + { + tabs::saveCopyDialog(); + $baseobject= $this->by_object['user']; + $uid = $baseobject->uid; + foreach($this->by_object as $name => $obj){ + $this->by_object[$name]->uid = $uid; + } + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/admin/users/template.tpl b/gosa-core/plugins/admin/users/template.tpl new file mode 100644 index 000000000..37237f9fc --- /dev/null +++ b/gosa-core/plugins/admin/users/template.tpl @@ -0,0 +1,60 @@ +
+ {t}Creating a new user using templates{/t} +
+ +

+ {t}Creating a new user can be assisted by using templates. Many database records will be filled automatically. Choose 'none' to skip the usage of templates.{/t} +

+ +

 

+ +
+ + + + + + + + + + + + + + + {if $got_uid eq "true"} + + + + + {/if} +
+ +
{t}Login{/t} + {if $edit_uid eq "false"} + + {else} + + {/if} +
+ +
+

+ +   + +

+ + + + + diff --git a/gosa-core/plugins/generic/references/class_reference.inc b/gosa-core/plugins/generic/references/class_reference.inc new file mode 100644 index 000000000..472e42e11 --- /dev/null +++ b/gosa-core/plugins/generic/references/class_reference.inc @@ -0,0 +1,181 @@ +config= &$config; + $this->dn= $dn; + + /* Fill translation array */ + $this->obtypes= array( "gosaAccount" => array( "text" => _("Generic"), + "image" => "penguin.png"), + "posixAccount" => array( "text" =>_("UNIX"), + "image" => "select_user.png"), + "gosaMailAccount" => array("text" => _("Mail"), + "image" => "mailto.png"), + "sambaSamAccount" => array("text" => _("Samba"), + "image" => "select_winstation.png"), + "sambaAccount" => array( "text" => _("Samba"), + "image" => "select_winstation.png"), + "goFaxAccount" => array( "text" => _("FAX"), + "image" => "fax_small.png"), + "gosaProxyAccount" => array("text" => _("Proxy"), + "image" => "select_proxy.png"), + "PureFTPdUser" => array( "text" => _("FTP"), + "image" => "select_proxy.png"), + "posixGroup" => array( "text" => _("Group"), + "image" => "select_groups.png"), + "gosaDepartment" => array( "text" => _("Department"), + "image" => "select_department.png"), + "goFonHardware" => array( "text" => _("Phone"), + "image" => "select_phone.png"), + "gosaApplication" => array("text" => _("Application"), + "image" => "select_application.png"), + "goServer" => array( "text" => _("Server"), + "image" => "select_server.png"), + "gotoTerminal" => array( "text" => _("Thin Client"), + "image" => "select_terminal.png"), + "gotoWorkstation" => array("text" => _("Workstation"), + "image" => "select_workstation.png"), + "gosaGroupOfNames" => array("text" => _("Object group"), + "image" => "select_ogroup.png"), + "gotoPrinter" => array( "text" => _("Printer"), + "image" => "select_printer.png")); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Set government mode */ + $smarty= get_smarty(); + + if (isset($_GET['show'])){ + $dn= base64_decode($_GET['show']); + if (isset($this->fold["$dn"])){ + unset($this->fold["$dn"]); + } else { + $this->fold["$dn"]= "$dn"; + } + } + + /* Fill array */ + $this->reload(); + $smarty->assign("objectList", $this->objectlist); + + /* Show main page */ + return ($smarty->fetch (get_template_path('contents.tpl', TRUE, dirname(__FILE__)))); + } + + function reload() + { + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(|(member=".$this->dn.")(memberUid=".$this->uid."))",array("memberUid","member","cn","description","objectClass")); + + $cycle= array("F5F5F5", "ECECEC"); + $id= 0; + $this->objectlist= ""; + while ($attrs= $ldap->fetch()){ + + /* Add more information? */ + $addon= ""; + if (in_array($attrs['dn'], $this->fold)){ + $memberattr= ""; + if (isset($attrs['memberUid'])){ + unset($attrs['memberUid']['count']); + $memberattr= "memberUid"; + } + if (isset($attrs['member'])){ + unset($attrs['member']['count']); + $memberattr= "member"; + } + if ($memberattr == ""){ + continue; + } + foreach ($attrs[$memberattr] as $uid){ + $content= $this->getCacheObject($uid); + if ($content === NULL) { + continue; + } + $addon.= '   '.$content['name'].''.$content['description'].''.$content['type'].' '; + } + } + + /* Build final entry */ + if (isset($attrs['description'])){ + $description= $attrs['description'][0]; + } else { + $description= "-"; + } + $content= $this->createContentString($attrs['objectClass']); + if ($addon == ""){ + $img= "images/expand.png"; + } else { + $img= "images/sort_down.png"; + } + $this->objectlist.= ' '.$attrs['cn'][0].''.$description.''.$content.' '.$addon; + + $id++; + } + + } + + function getCacheObject($dn) + { + if (!isset($this->objectCache[$dn])){ + $ldap= $this->config->get_ldap_link(); + if (preg_match('/,/', $dn)){ + $ldap->cat($dn, array("cn", "objectClass", "description","ou")); + } else { + $ldap->search("(uid=$dn)", array("cn", "objectClass", "description","ou")); + } + if ($ldap->count()){ + $attrs= $ldap->fetch(); + + if(isset($attrs['ou']) && !isset($attrs['cn'])){ + $attrs['cn'] = $attrs['ou']; + } + + if (isset($attrs['description'])){ + $description= $attrs['description'][0]; + } else { + $description= "-"; + } + $this->objectCache[$dn]= array( 'name' => $attrs['cn'][0], + 'description' => "$description", + 'type' => $this->createContentString($attrs['objectClass'])); + } else { + return NULL; + } + } + return ($this->objectCache[$dn]); + } + + function createContentString($classes) + { + $result= ""; + if(!is_null($classes)) { + foreach ($classes as $class){ + if (isset($this->obtypes[$class])){ + $result.= "\"\" ".$this->obtypes[$class]['text']." "; + } + } + } + return (preg_replace('/ $/', '', $result)); + } + +} + +?> diff --git a/gosa-core/plugins/generic/references/contents.tpl b/gosa-core/plugins/generic/references/contents.tpl new file mode 100644 index 000000000..e953da19f --- /dev/null +++ b/gosa-core/plugins/generic/references/contents.tpl @@ -0,0 +1,19 @@ +{if $objectList ne ""} + + + + + + + + + + + + + {$objectList} + +
{t}Object name{/t}{t}Description{/t}{t}Contents{/t}
+{else} +{t}This object has no relationship to other objects.{/t} +{/if} diff --git a/gosa-core/plugins/generic/welcome/main.inc b/gosa-core/plugins/generic/welcome/main.inc new file mode 100644 index 000000000..eb0c63cd9 --- /dev/null +++ b/gosa-core/plugins/generic/welcome/main.inc @@ -0,0 +1,30 @@ +assign("iconmenu", $plist->show_iconmenu()); + $smarty->assign("header", print_header(get_template_path('images/hdd_linux_unmount.png'), sprintf(_("Welcome %s!"), $ui->cn))); + $smarty->assign("year", date("Y")); + $smarty->assign("revision", get_gosa_version()); + $display= $smarty->fetch(get_template_path('welcome.tpl', TRUE)); +} + +?> diff --git a/gosa-core/plugins/generic/welcome/welcome.tpl b/gosa-core/plugins/generic/welcome/welcome.tpl new file mode 100644 index 000000000..35a27edf4 --- /dev/null +++ b/gosa-core/plugins/generic/welcome/welcome.tpl @@ -0,0 +1,19 @@ +{$header} + +

+ {t}This is the GOsa main menu. You can select your tasks from the menu on the left, or by choosing one of the pictograms below. All changes apply directly to your companies LDAP server.{/t} +

+ +

+ {t}Use 'Sign out' on the upper left to close the connection and 'Main' to get back to the pictogram view.{/t} +

+ +{$iconmenu} + +
+ + + + + diff --git a/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc b/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc new file mode 100644 index 000000000..19284661d --- /dev/null +++ b/gosa-core/plugins/gofax/blocklists/class_blocklistGeneric.inc @@ -0,0 +1,371 @@ +type = BLOCK_LIST_SEND; + + /* Load defined numbers */ + if($dn != "new"){ + + /* We will not be able to rename edited blocklists */ + $this->readonly = TRUE; + + /* Get blocklist type and defined numbers */ + if (in_array("goFaxSBlock",$this->attrs['objectClass'])){ + if(isset($this->attrs["goFaxSBlocklist"])){ + for ($i= 0; $i<$this->attrs["goFaxSBlocklist"]["count"]; $i++){ + $this->goFaxBlocklist[]= $this->attrs["goFaxSBlocklist"][$i]; + } + } + $this->type= BLOCK_LIST_SEND; + } elseif (in_array("goFaxRBlock",$this->attrs['objectClass'])){ + if(isset($this->attrs["goFaxRBlocklist"])){ + for ($i= 0; $i<$this->attrs["goFaxRBlocklist"]["count"]; $i++){ + $this->goFaxBlocklist[]= $this->attrs["goFaxRBlocklist"][$i]; + } + } + $this->type= BLOCK_LIST_RECEIVE; + } + } + + /* Set base */ + if ($this->dn == "new"){ + if(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['CurrentMainBase']; + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn); + } + } + + public function execute() + { + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","blocklist/".get_class($this),$this->dn); + } + + + /************** + * Base select dialog + **************/ + + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + + }else{ + return($this->dialog->execute()); + } + } + + + /*************** + Add numer to blocklist + ***************/ + + + /* Handle interactions: add */ + if (isset($_POST['add_number']) && $_POST['number'] != ""){ + if (is_phone_nr($_POST['number']) || preg_match ("/^[\/0-9 ()\^\.\$+*-]+$/",$_POST['number'])){ + $this->addNumber ($_POST['number']); + } else { + print_red (_("Please specify a valid phone number.")); + } + } + + + /*************** + Delete number from list + ***************/ + + /* Handle interactions: delete */ + if (isset($_POST['delete_number']) && isset($_POST['numbers']) && count($_POST['numbers']) > 0){ + $this->delNumber ($_POST['numbers']); + } + + + /*************** + Template output + ***************/ + + $smarty = get_smarty(); + foreach($this->attributes as $name){ + $smarty->assign($name,$this->$name); + } + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + $smarty->assign("goFaxBlocklist",$this->goFaxBlocklist); + $smarty->assign("cnACL",$this->getacl("cn",$this->readonly)); + $smarty->assign("typeACL",$this->getacl("type",$this->readonly)); + $smarty->assign("base",$this->base); + $smarty->assign("bases", $this->get_allowed_bases()); + $smarty->assign("types", array(BLOCK_LIST_SEND => _("send"), BLOCK_LIST_RECEIVE => _("receive"))); + $smarty->assign("type", $this->type); + return($smarty->fetch(get_template_path('generic.tpl', TRUE))); + } + + + public function save_object() + { + if(isset($_POST['blocklist_posted'])){ + $tmp_cn = $this->cn; + plugin::save_object(); + $this->cn = $tmp_cn; + + /* Save base, since this is no LDAP attribute */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + $tmp = $this->attributes; + $tmp[] = "type"; + foreach($tmp as $attr){ + if(in_array($attr,array("cn","type")) && $this->readonly){ + continue; + }elseif(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){ + $this->$attr = $_POST[$attr]; + } + } + } + } + + + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + $ldap->rmDir($this->dn); + new log("remove","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of blocklist with dn '%s' failed."),$this->dn)); + $this->handle_post_events("remove"); + } + + + /* Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* check syntax: must cn */ + if ($this->cn == ""){ + $message[]= _("Required field 'Name' is not set."); + } else { + if (!is_uid($this->cn)){ + $message[]= _("Required field 'Name' contains invalid characters"); + } + if ($this->dn == 'new'){ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ("ou=gofax,ou=systems,".$this->config->current["BASE"]); + $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))(cn=".$this->cn."))", array("cn")); + if ($ldap->count() != 0){ + $message[]= _("Specified name is already used."); + } + } + } + return $message; + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Type selection */ + if ($this->type == BLOCK_LIST_SEND){ + $type= "goFaxSBlocklist"; + $this->attrs['objectClass']= "goFaxSBlock"; + } else { + $type= "goFaxRBlocklist"; + $this->attrs['objectClass']= "goFaxRBlock"; + } + + /* Add list */ + if (count($this->goFaxBlocklist)){ + $this->attrs[$type]= $this->goFaxBlocklist; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->base); + $ldap->cat($this->dn, array('dn')); + if ($ldap->count()){ + if (!isset($this->attrs[$type])){ + $this->attrs[$type]= array(); + } + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify($this->attrs); + new log("modify","faxblocklist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("modify"); + } else { + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + new log("create","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + $this->handle_post_events("add"); + } + show_ldap_error($ldap->get_error(), sprintf(_("Saving of blocklist with dn '%s' failed."),$this->dn)); + } + + + /* Add number */ + function addNumber($number) + { + if (!in_array($number, $this->goFaxBlocklist)){ + $this->goFaxBlocklist[]= $number; + sort($this->goFaxBlocklist); + } + } + + + /* Remove number from list */ + function delNumber($numbers) + { + $tmp= array(); + foreach ($this->goFaxBlocklist as $val){ + if (!in_array($val, $numbers)){ + $tmp[]= $val; + } + } + $this->goFaxBlocklist= $tmp; + } + + + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("cn",$this->cn); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = get_post('cn'); + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* We will not be able to rename edited blocklists */ + $this->readonly = TRUE; + + /* Get blocklist type and defined numbers */ + if (in_array("goFaxSBlock",$source['objectClass'])){ + if(isset($source["goFaxSBlocklist"])){ + for ($i= 0; $i<$source["goFaxSBlocklist"]["count"]; $i++){ + $this->goFaxBlocklist[]= $source["goFaxSBlocklist"][$i]; + } + } + $this->type= BLOCK_LIST_SEND; + } elseif (in_array("goFaxRBlock",$source['objectClass'])){ + if(isset($source["goFaxRBlocklist"])){ + for ($i= 0; $i<$source["goFaxRBlocklist"]["count"]; $i++){ + $this->goFaxBlocklist[]= $source["goFaxRBlocklist"][$i]; + } + } + $this->type= BLOCK_LIST_RECEIVE; + } + + /* Set base */ + if ($this->dn == "new"){ + if(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['CurrentMainBase']; + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn); + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Fax"), + "plDescription" => _("Fax blocklists"), + "plSelfModify" => FALSE, + "plDepends" => array(), + + "plPriority" => 0, + "plSection" => array("administration" => _("FAX Blocklists")), + "plCategory" => array("gofaxlist" => array("description" => _("Fax blocklists"), + "objectClass" => array("goFaxRBlock","goFaxSBlock"))), + "plProvidedAcls" => array( + "cn" => _("Name"), + "description" => _("Description"), + "base" => _("Base"), + "goFaxBlocklist" => _("Blocklist"), + "type" => _("Blocklist type")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofax/blocklists/class_blocklistManagement.inc b/gosa-core/plugins/gofax/blocklists/class_blocklistManagement.inc new file mode 100644 index 000000000..f9b19ea2a --- /dev/null +++ b/gosa-core/plugins/gofax/blocklists/class_blocklistManagement.inc @@ -0,0 +1,477 @@ +ui = $ui; + $this->dn = ""; + $this->config = &$config; + $this->base = $_SESSION['CurrentMainBase']; + $this->DivListBlocklist = new divListBlocklist($this->config,$this); + + /* Initialize copy&paste queue */ + if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){ + $this->CopyPasteHandler= new CopyPasteHandler($this->config); + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $_SESSION['LOCK_VARS_TO_USE'] = array("/^goFaxBlocklist_/","/^act$/","/^id$/","/^remove_multiple_blocklists/","/^item_selected/"); + + /*************** + Init vars + ***************/ + + /* Get global smarty instance */ + $smarty = get_smarty(); + $s_action = ""; // Contains the action to proceed + $s_entry = ""; // The value for s_action + $base_back = ""; // The Link for Backbutton + + + /*************** + Fetch posts + ***************/ + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/^goFaxBlocklist_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/^goFaxBlocklist_del_/i","",$key); + // Post for edit + }elseif(preg_match("/^goFaxBlocklist_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/^goFaxBlocklist_edit_/i","",$key); + // Post for new + }elseif(preg_match("/^goFaxBlocklist_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/^remove_multiple_blocklists/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^copy/",$key)){ + $s_action = "copy"; + $s_entry= preg_replace("/^copy_/i", "", $key); + }elseif(preg_match("/^cut/",$key)){ + $s_action = "cut"; + $s_entry= preg_replace("/^cut_/i", "", $key); + } + + } + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + + $s_entry = preg_replace("/_.$/","",$s_entry); + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "goFaxBlocklist_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + + /*************** + Handle copy & paste + ***************/ + + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /*************** + Cancel some dialogs + ***************/ + + /* Cancel dialog */ + if (isset($_POST['edit_cancel']) || + isset($_POST['delete_blocklist_cancel']) || + isset($_POST['delete_lock'])){ + + del_lock ($this->dn); + $this->dialog = NULL; + unset($_SESSION['objectinfo']); + } + + + /*************** + Save blocklist + ***************/ + + /* What about finish? */ + if (isset($_POST['edit_finish']) || isset($_POST['edit_apply'])){ + + /* No errors, save object */ + $this->dialog->save_object(); + $message= $this->check(); + if (count ($message) == 0){ + + $this->dialog->save (); + + if (!isset($_POST['edit_apply'])){ + del_lock ($this->dn); + $this->dn= ""; + $this->dialog = NULL; + unset($_SESSION['objectinfo']); + } + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + + /*************** + Create a new blocklist (dialog) + ***************/ + + /* Create new blocklist? */ + if ($s_action=="new"){ + $this->dn= "new"; + $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); + $this->dialog->set_acl_base($this->base); + } + + + /*************** + Edit blocklist + ***************/ + + if ($s_action=="edit" && !is_object($this->dialog)){ + + $this->dn=$this->blocklists[$s_entry]['dn']; + + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message($user, $this->dn)); + }else{ + add_lock ($this->dn, $this->ui->dn); + } + $_SESSION['objectinfo']= trim($this->dn); + $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); + $this->dialog->set_acl_base($this->dn); + } + + + /*************** + Display dialog + ***************/ + + if(is_object($this->dialog) && ($this->dialog instanceof faxblocktabs)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + + $this->dns = array(); + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + foreach($ids as $id){ + $dn = $this->blocklists[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + $smarty->assign("info", sprintf(_("You're about to delete the following blocklists(s) %s"), @LDAP::fix($dns_names))); + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. */ + if (isset($_POST['delete_multiple_blocklist_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){ + $this->dn = $dn; + $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); + $this->dialog->delete(); + $this->dialog = NULL; + } else { + print_red (sprintf(_("You are not allowed to delete the blocklist '%s'!"),$dn)); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + $this->reload(); + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_blocklist_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /*************** + Remove blocklist + ***************/ + + /* Delete blocklist requested */ + if ($s_action=="del"){ + $this->dn=$this->blocklists[$s_entry]['dn']; + + /* Check locking */ + if (($user= get_lock($this->dn)) != ""){ + $_SESSION['dn']= $this->dn; + return(gen_locked_message($user, $this->dn)); + } else { + + // Lock this dn for editing + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the blocklist '%s'."), $this->dn)); + $smarty->assign("multiple", false); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /*************** + Remove blocklist confirmed + ***************/ + + /* Finally delete blocklist */ + if (isset($_POST['delete_blocklist_confirm'])){ + if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){ + $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); + $this->dialog->delete(); + $this->dialog = NULL; + del_lock ($this->dn); + } else { + print_red (_("You have no permission to remove this blocklist.")); + } + } + + /*************** + Divlist dialog + ***************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListBlocklist->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Display dialog with system list */ + $this->DivListBlocklist->parent = $this; + $this->DivListBlocklist->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListBlocklist->SubSearch){ + $this->DivListBlocklist->AddDepartments($this->DivListBlocklist->selectedBase,3,1); + } + $this->reload(); + $this->DivListBlocklist->setEntries($this->blocklists); + return($this->DivListBlocklist->Draw()); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array("ou=gofax,ou=systems,". $this->DivListBlocklist->selectedBase)); + } + + + /* Reload the list of known blocklists */ + function reload() + { + /* Init some vars */ + $filter = $filter2 = ""; + $base = $this->DivListBlocklist->selectedBase; + $Regex = $this->DivListBlocklist->Regex; + $SubSearch = $this->DivListBlocklist->SubSearch; + $ShowSendBocklists = $this->DivListBlocklist->ShowSendBocklists; + $ShowReceiveBlocklists = $this->DivListBlocklist->ShowReceiveBlocklists; + $Flags = GL_SIZELIMIT; + $res = $res2 = array(); + + /* Append subsearch to Flags */ + if($SubSearch){ + $Flags |= GL_SUBSEARCH; + }else{ + $base = "ou=gofax,ou=systems,".$base; + } + + /* Create filter */ + if ($ShowSendBocklists){ + $filter = "(&(objectClass=goFaxSBlock)(|(cn=".$Regex.")(goFaxSBlocklist=".$Regex.")))"; + $res= get_list($filter, "gofaxlist", $base,array("*"), $Flags); + } + if ($ShowReceiveBlocklists){ + $filter2= "(&(objectClass=goFaxRBlock)(|(cn=".$Regex.")(goFaxRBlocklist=".$Regex.")))"; + $res2= get_list($filter2, "gofaxlist", $base,array("*"), $Flags); + } + + $this->blocklists = array_merge($res,$res2); + + /* appen && sort */ + $tmp=array(); + foreach($this->blocklists as $tkey => $val ){ + + $acl = $this->ui ->get_permissions($base,"gofaxlist/blocklist"); + if(preg_match("/r/",$acl)){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + } + ksort($tmp); + $this->blocklists=array(); + foreach($tmp as $val){ + $this->blocklists[]=$val; + } + reset ($this->blocklists); + } + + + /* Save data to object */ + function save_object() + { + $this->DivListBlocklist->save_object(); + } + + + + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->blocklists[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"faxblocktabs","FAXBLOCKTABS","gofaxlist"); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->blocklists[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","faxblocktabs","FAXBLOCKTABS","gofaxlist"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","faxblocktabs","FAXBLOCKTABS","gofaxlist"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListBlocklist->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofax/blocklists/class_divListBlocklists.inc b/gosa-core/plugins/gofax/blocklists/class_divListBlocklists.inc new file mode 100755 index 000000000..8b8a505a6 --- /dev/null +++ b/gosa-core/plugins/gofax/blocklists/class_divListBlocklists.inc @@ -0,0 +1,291 @@ +parent = $parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of blocklists")); + $this->SetSummary(_("List of blocklists")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to create, delete and edit selected blocklists. Having a large size of lists, you might prefer the range selectors on top of the select box.")); + + $this->EnableAplhabet (true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 100; + if($this->parent->snapshotEnabled()){ + $action_col_size += 20; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Blocklist name")." / "._("Department"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" )); + + /* Add Checkboxes / SubSearch checkbox */ + $this->AddCheckBox("ShowSendBocklists" , _("Select to see send blocklists"), _("Show send blocklists"),true); + $this->AddCheckBox("ShowReceiveBlocklists" , _("Select to see receive blocklists"), _("Show receive blocklists"),true); + + $this->AddCheckBox(SEPERATOR); + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching list names"),"*" , true); + } + + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("gofaxlist"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get acls */ + $ui = get_userinfo(); + $acl = $ui->get_permissions($this->selectedBase,"gofaxlist/blocklist"); + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"gofaxlist"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* Append department selector */ + $listhead .= " "._("Base")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Blocklist")."|goFaxBlocklist_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + // User and Template Images + $blockimg = "User"; + $editlink = "%s"; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 100; + if($this->parent->snapshotEnabled()){ + $action_col_size += 20; + } + + /* Append to list */ + $ui = get_userinfo(); + foreach($list as $key => $val){ + + $acl = $ui->get_permissions($val['dn'],"gofaxlist/blocklist"); + if(!preg_match("/r/",$acl)){ + continue; + } + + /* Edit link ; requires read access */ + $action= ""; + + + /* Create snapshot ; requires write access && create access */ + if(preg_match("/w/",$acl) && preg_match("/c/",$acl)){ + $action.= $this->GetSnapShotActions($val['dn']); + } + + /* Add copy & cut icons */ + if(preg_match("/(c.*w|w.*c)/",$acl) && $this->parent->CopyPasteHandler){ + $action .= " "; + $action.= " "; + } + + + /* Delete entry ; requires remove access */ + if(preg_match("/d/",$acl)){ + $action.= ""; + } + + // Generate Array to Add + if(isset($val["description"][0])){ + $display= $val["cn"][0]." [".$val["description"][0]."]"; + }else{ + $display= $val["cn"][0]; + } + + /* Cutted objects should be displayed in light grey */ + if(isset($this->parent->CopyPasteHandler->queue) && is_array($this->parent->CopyPasteHandler->queue)){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); + $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + $this->AddElement( array($field0,$field1,$field2,$field3)); + } + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_objs = count($list); + + $num_obj_str = _("Number of listed blocklists"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow :: save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofax/blocklists/generic.tpl b/gosa-core/plugins/gofax/blocklists/generic.tpl new file mode 100644 index 000000000..df9f84a6b --- /dev/null +++ b/gosa-core/plugins/gofax/blocklists/generic.tpl @@ -0,0 +1,109 @@ +

{t}Generic{/t}

+ + + + + + + + + +
+ + + + + + + + + +
{$must} + +{render acl=$cnACL} + +{/render} +
{$must} +{render acl=$baseACL} + +{/render} + +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+
+   + + + + + + + + + + +
+{render acl=$typeACL} + +{/render} +
+{render acl=$descriptionACL} + +{/render} +
+
+ +

 

+ + + + + + + +
+

{t}Blocked numbers{/t}

+{render acl=$goFaxBlocklistACL} + +{/render} +
+{render acl=$goFaxBlocklistACL} +   +{/render} +{render acl=$goFaxBlocklistACL} +   +{/render} +{render acl=$goFaxBlocklistACL} + +{/render} +
+   + +

{t}Information{/t}

+

+ {t}Numbers can also contain wild cards.{/t} +

+
+ +

+ + + +

+ + + diff --git a/gosa-core/plugins/gofax/blocklists/main.inc b/gosa-core/plugins/gofax/blocklists/main.inc new file mode 100644 index 000000000..71c0b81a3 --- /dev/null +++ b/gosa-core/plugins/gofax/blocklists/main.inc @@ -0,0 +1,34 @@ +dn); + sess_del ('blocklist'); + } +} else { + /* Create blocklist object on demand */ + if (!isset($_SESSION['blocklist']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['blocklist']= new blocklist($config, $ui); + $_SESSION['blocklist']->set_acl_category("gofaxlist"); + } + $blocklist= $_SESSION['blocklist']; + $blocklist->save_object(); + $output= $blocklist->execute(); + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('blocklist'); + } + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management"), "\"\"align=\"middle\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management")); + } + $display.= $output; + + $_SESSION['blocklist']= $blocklist; +} +?> diff --git a/gosa-core/plugins/gofax/blocklists/paste_generic.tpl b/gosa-core/plugins/gofax/blocklists/paste_generic.tpl new file mode 100644 index 000000000..ac4cef972 --- /dev/null +++ b/gosa-core/plugins/gofax/blocklists/paste_generic.tpl @@ -0,0 +1,8 @@ + + + + + +
+ +
diff --git a/gosa-core/plugins/gofax/blocklists/remove.tpl b/gosa-core/plugins/gofax/blocklists/remove.tpl new file mode 100644 index 000000000..ebea1e3ca --- /dev/null +++ b/gosa-core/plugins/gofax/blocklists/remove.tpl @@ -0,0 +1,24 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-core/plugins/gofax/blocklists/tabs_blocklist.inc b/gosa-core/plugins/gofax/blocklists/tabs_blocklist.inc new file mode 100644 index 000000000..9293903e1 --- /dev/null +++ b/gosa-core/plugins/gofax/blocklists/tabs_blocklist.inc @@ -0,0 +1,38 @@ +addSpecialTabs(); + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['blocklistGeneric']; + + /* Check for new 'dn', in order to propagate the 'dn' to all plugins */ + $new_dn= "cn=".$baseobject->cn.",ou=gofax,ou=systems,".$baseobject->base; + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['blocklistGeneric']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + tabs::save(); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc b/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc new file mode 100644 index 000000000..eca222857 --- /dev/null +++ b/gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc @@ -0,0 +1,857 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + + /* Department list shown in the divSelectList*/ + var $departments; + + /* Fax attributes */ + var $goFaxDeliveryMode= ""; + var $facsimileTelephoneNumber= ""; + var $goFaxIsEnabled= 1; + var $goFaxPrinter= ""; + var $goFaxDivertNumber= ""; + var $goFaxLanguage= ""; + var $goFaxFormat= ""; + var $goFaxRBlocklist = array(); + var $goFaxRBlockgroups= array(); + var $goFaxSBlocklist= array(); + var $goFaxSBlockgroups= array(); + var $mail= ""; + var $facsimileAlternateTelephoneNumber= array(); + var $fax_formats = array("pdf","ps","png","mtiff","tiff"); + + /* Internal variables */ + var $printerList= array(); + var $has_mailAccount= FALSE; + var $locals_dialog= FALSE; + var $in_blocklist_dialog= FALSE; + var $out_blocklist_dialog= FALSE; + var $current_blocklist= array(); + var $view_logged = FALSE; + + /* Copy & paste variables */ + var $CopyPasteVars=array("facsimileTelephoneNumber");//,"goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups"); + + /* attribute list for save action */ + var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","facsimileAlternateTelephoneNumber","goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups","goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail","facsimileTelephoneNumber"); + + var $uid =""; + + var $objectclasses= array("goFaxAccount"); + + function gofaxAccount (&$config, $dn= NULL) + { + /* General initialization */ + plugin::plugin ($config, $dn); + + /* Set uid, it is used in handle_post_events */ + if(isset($this->attrs['uid'])){ + $this->uid = $this->attrs['uid'][0]; + } + + /* Hickert : 11.11.05 + * Added to be able to handle department selection in divSelelect + */ + if(!isset($_SESSION["Fax_Filter"])){ + $_SESSION['Fax_Filter']['depselect'] = $this->config->current['BASE']; + } + + if ($dn != "new"){ + /* Get arrays */ + foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", + "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") 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]); + } + } + } + + /* Set up has_mailAccount */ + if (in_array("gosaMailAccount", $this->attrs['objectClass'])){ + $this->has_mailAccount= TRUE; + } + } + + /* Load printer list */ + if (isset($this->config->data['SERVERS']['CUPS'])){ + $this->printerList= get_printer_list ($this->config->data['SERVERS']['CUPS']); + asort ($this->printerList); + } + + /* Check if the currently selected printer is still available. + If not, append current printer to list of available. + It could be possible, that we are not allowed to view printers and so the list is empty ... */ + if(!empty($this->goFaxPrinter) && !isset($this->printerList[$this->goFaxPrinter])) { + $this->printerList[$this->goFaxPrinter] = "[".$this->goFaxPrinter."]"; + } + + /* Get global filter config */ + if (!is_global("faxfilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $faxfilter= array( "depselect" => $base, + "fuser" => "*", + "regex" => ""); + register_global("faxfilter", $faxfilter); + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Hickert : 11.11.05 + * Added to be able to handle department selection in divSelelect + */ + if((isset($_GET['act']))&&($_GET['act']=="dep_open")){ + + if(strlen(base64_decode($_GET['dep_id']))>= strlen($this->config->current['BASE'])){ + $_SESSION['Fax_Filter']['depselect']= base64_decode($_GET['dep_id']); + }else{ + $_SESSION['Fax_Filter']['depselect']= $this->config->current['BASE']; + } + } + + /* Edit mode specifies if we are editing from my accout */ + $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit'])); + + /* Load smarty stuff */ + $smarty= get_smarty(); + + /* Check if mail account is active. We'll display an additional + mail address field if this is not the case. Some people may + want goFax, but have a mailserver which is not managed with + GOsa */ + if (!@isset($this->parent->by_object['mailAccount'])) { + $smarty->assign("has_mailaccount", $this->has_mailAccount?"true":"false"); + } elseif ( !$this->parent->by_object['mailAccount']->is_account){ + $smarty->assign("has_mailaccount", "false"); + $this->has_mailAccount= false; + } else { + $smarty->assign("has_mailaccount", "true"); + } + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This account has no fax extensions.").""; + $display.= back_to_main(); + return ($display); + } + + /* Show tab dialog headers */ + $display= ""; + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove fax account"), + _("This account has fax features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Create fax account"), + _("This account has fax features disabled. You can enable them by clicking below.")); + return ($display); + } + } + + /* Trigger Add local fax alternatives dialog */ + if (isset($_POST['add_local_alternate'])){ + if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ + $this->locals_dialog= TRUE; + $this->dialog= TRUE; + } + } + + /* Add alternatives from dialog */ + if (isset($_POST['add_locals_finish']) && isset($_POST['local_list'])){ + if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ + foreach ($_POST['local_list'] as $val){ + $this->addAlternate($val); + $this->is_modified= TRUE; + } + } + } + + /* Add alternatives */ + if (isset($_POST['add_alternate']) && !empty($_POST['forward_address']) && is_phone_nr($_POST['forward_address'])){ + if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ + $this->addAlternate($_POST['forward_address']); + } + } + + /* Delete alternate fax number */ + if (isset($_POST['delete_alternate']) && isset($_POST['alternate_list']) && count($_POST['alternate_list'])){ + if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ + $this->delAlternate ($_POST['alternate_list']); + } + } + + + /* Edit incoming blocklists */ + if (isset($_POST['edit_incoming'])){ + if($this->acl_is_writeable("goFaxRBlocklist",$edit_mode)) { + $this->current_blocklist= array_merge($this->goFaxRBlocklist,$this->goFaxRBlockgroups); + sort($this->current_blocklist); + reset($this->current_blocklist); + + $this->in_blocklist_dialog= TRUE; + $this->dialog= TRUE; + } + } + + /* Edit outgoing blocklists */ + if (isset($_POST['edit_outgoing'])){ + $this->current_blocklist= array_merge($this->goFaxSBlocklist,$this->goFaxSBlockgroups); + sort($this->current_blocklist); + reset($this->current_blocklist); + + $this->out_blocklist_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Add number to blocklist (dialog) */ + if (isset($_POST['add_blocklist_number']) && $_POST['block_number'] != ""){ + if (!is_phone_nr($_POST['block_number'])){ + print_red (_("You're trying to add an invalid phone number.")); + } else { + array_push($this->current_blocklist, $_POST['block_number']); + $this->current_blocklist= array_unique($this->current_blocklist); + sort($this->current_blocklist); + reset($this->current_blocklist); + } + } + + /* Hickert : 11.11.05 + * Add selection from divSelelect to our Blocklist + */ + /* Add list to blocklist */ + if (isset($_POST['add_blocklist'])){ + foreach($_POST as $name => $value){ + if(preg_match("/ADDLIST_/i",$name)){ + $this->current_blocklist= array_merge($this->current_blocklist, array(base64_decode($value))); + + } + } + $this->current_blocklist= array_unique($this->current_blocklist); + sort($this->current_blocklist); + reset($this->current_blocklist); + } + + /* Add list to blocklist */ + if (isset($_GET['add'])){ + if(!is_array($this->current_blocklist)) $this->current_blocklist=array(); + $this->current_blocklist= array_merge($this->current_blocklist, array( base64_decode($_GET['add']))); + $this->current_blocklist= array_unique($this->current_blocklist); + sort($this->current_blocklist); + reset($this->current_blocklist); + } + + /* Delete from blocklist */ + if (isset($_POST['delete_blocklist_number']) && isset($_POST['block_list'])){ + $tmp= array(); + foreach($this->current_blocklist as $val){ + if (!in_array($val, $_POST['block_list'])){ + $tmp[]= $val; + } + } + $this->current_blocklist= $tmp; + } + + + /* Blocklist edit finished */ + if (isset($_POST['edit_blocklists_finish'])){ + + /* Incoming or outgoing? */ + if ($this->in_blocklist_dialog){ + $this->goFaxRBlocklist = array(); + $this->goFaxRBlockgroups = array(); + + foreach ($this->current_blocklist as $val){ + if (is_phone_nr($val)){ + $this->goFaxRBlocklist[]=$val; + } else { + $this->goFaxRBlockgroups[]= $val; + } + } + } else { + $this->goFaxSBlocklist = array(); + $this->goFaxSBlockgroups = array(); + + /* Transfer values to ourself */ + foreach ($this->current_blocklist as $val){ + if (is_phone_nr($val)){ + $this->goFaxSBlocklist[]=$val; + } else { + $this->goFaxSBlockgroups[]= $val; + } + } + } + $this->is_modified= TRUE; + } + + + /* Set departments */ + if ($this->locals_dialog || $this->in_blocklist_dialog || $this->out_blocklist_dialog){ + + $list= array (); + $ldap= $this->config->get_ldap_link(); + if (isset ($_POST['department'])){ + $ldap->cd ($_POST['department']); + } else { + $ldap->cd ($this->config->current['BASE']); + } + } + + /* Cancel dialogs */ + if (isset($_POST['add_locals_cancel']) || isset($_POST['edit_blocklists_finish']) || + isset($_POST['edit_blocklists_cancel']) || isset($_POST['add_locals_finish'])){ + + $this->locals_dialog= FALSE; + $this->in_blocklist_dialog= FALSE; + $this->out_blocklist_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Manage locals dialog */ + if ($this->locals_dialog){ + + /* Save data */ + $faxfilter= get_global("faxfilter"); + foreach( array("depselect", "fuser", "regex") as $type){ + if (isset($_POST[$type])){ + $faxfilter[$type]= $_POST[$type]; + } + } + if (isset($_GET['search'])){ + $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; + if ($s == "**"){ + $s= "*"; + } + $faxfilter['fuser']= $s; + } + + if ($faxfilter['regex'] != '*' && $faxfilter['regex'] != ""){ + $regex= $faxfilter['regex']; + $filter= "(facimileTelephoneNumber=$regex)"; + } else { + $filter= ""; + } + if ($faxfilter['fuser'] != ""){ + $user= $faxfilter['fuser']; + $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))"; + } + + $base= $faxfilter['depselect']; + $res= get_list("(&(objectClass=goFaxAccount)$filter)", "gofax", $base, + array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH); + + foreach ($res as $attrs){ + $list[$attrs['facsimileTelephoneNumber'][0]]= + $attrs['sn'][0].", ". + $attrs['givenName'][0]." [". + $attrs['facsimileTelephoneNumber'][0]."]"; + } + + /* Show dialog */ + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("usearch_image", get_template_path('images/search_user.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("departments", $this->config->idepartments); + $smarty->assign("list", $list); + if (isset($_POST['depselect'])){ + $smarty->assign("depselect", $_POST['depselect']); + } + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("hint", print_sizelimit_warning()); + foreach( array("depselect", "fuser", "regex") as $type){ + $smarty->assign("$type", $faxfilter[$type]); + } + $smarty->assign("hint", print_sizelimit_warning()); + + $display.= $smarty->fetch (get_template_path('locals.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + + /* Manage incoming blocklists */ + if ($this->in_blocklist_dialog){ + + /* This handles the divSelectBox */ + + /* The base specifies the current position in the ldap tree + * The current base was specified by $_GET['dep_id'] before. Or contains the default value. + */ + $base = $_SESSION['Fax_Filter']['depselect']; + $ldap->cd($base); + + /* Ge all Blocklists */ + $ldap->search ("(objectClass=goFaxRBlock)",array("cn","description")); + while ($attrs= $ldap->fetch()){ + + /* Generate list depending on description */ + if(isset($attrs['description'][0])){ + $list[$attrs['cn'][0]]= + $attrs['description'][0]. + " [".$attrs['cn'][0]."]"; + }else{ + $list[$attrs['cn'][0]]= $attrs['cn'][0]; + } + } + + /* Create our divselect box */ + $divSel = new divSelectBox("divSelectPredefined"); + $divSel->setHeight(296); + + /* NEW LIST MANAGMENT + * We also need to search for the departments + * So we are able to navigate like in konquerer + */ + $this->departments= array(); + + /* Get all departments within the current department */ + $base = $_SESSION['Fax_Filter']['depselect']; + $ldap->ls("(objectClass=gosaDepartment)",$base); + + /* Base back is used to go one department up in our ldap tree */ + $base_back = preg_replace("/^[^,]+,/","",$base); + + /* Only show base_back if it is needed */ + if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){ + $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; + } + + /* Fetch all returned departments an add them to our divlist */ + while($value = $ldap->fetch()){ + if($value["description"][0]!=".."){ + $this->departments[$value['dn']]=@LDAP::fix(convert_department_dn($value['dn'])." - [".$value["description"][0]."]"); + }else{ + $this->departments[$value['dn']]=$value["description"][0]; + } + } + /* END NEW LIST MANAGMENT + */ + + // This links specifies the department open link + $linkopen = "%s"; + + /* Insert departments in divsel */ + foreach($this->departments as $key=> $val){ + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); + $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'"); + $divSel->AddEntry(array($field1,$field2)); + } + + /* Append predefined Blocklists */ + foreach($list as $entry => $value){ + $divSel->AddEntry(array( + array("string"=>""), + array("string"=>$value,"attach"=>"style='border:0px;'") + )); + } + + /* Show dialog */ + $smarty->assign("cblocklist", $this->current_blocklist); + $smarty->assign("departments", $this->config->idepartments); + $smarty->assign("divSelectPredefined", $divSel->DrawList()); + $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + /* Manage outgoing blocklists */ + + if ($this->out_blocklist_dialog){ + + /* This handles the divSelectBox */ + + /* The base specifies the current position in the ldap tree + * The current base was specified by $_GET['dep_id'] before. Or contains the default value. + */ + $base = $_SESSION['Fax_Filter']['depselect']; + $ldap->cd($base); + + /* Ge all Blocklists */ + $ldap->search ("(objectClass=goFaxSBlock)",array("cn","description")); + while ($attrs= $ldap->fetch()){ + if(isset($attrs['description'][0])){ + $list[$attrs['cn'][0]]= + $attrs['description'][0]. + " [".$attrs['cn'][0]."]"; + }else{ + $list[$attrs['cn'][0]]= $attrs['cn'][0]; + } + } + + /*Create DivSel*/ + $divSel = new divSelectBox("divSelectPredefined"); + $divSel->setHeight(296); + + /* NEW LIST MANAGMENT + * We also need to search for the departments + * So we are able to navigate like in konquerer + */ + $this->departments= array(); + $ldap->ls("(objectClass=gosaDepartment)",$base); + + /* Generate Back url, and append if it is needed */ + $base_back = preg_replace("/^[^,]+,/","",$base); + if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){ + $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; + } + + /* Get all departments */ + while($value = $ldap->fetch()){ + if(isset($value["description"][0])){ + $this->departments[$value['dn']]=@LDAP::fix(convert_department_dn($value['dn'])." - [".$value["description"][0]."]"); + }else{ + $this->departments[$value['dn']]=$value["description"][0]; + } + } + /* END NEW LIST MANAGMENT + */ + + // Defining Links + $linkopen = "%s"; + + /* Insert departments in divlist*/ + foreach($this->departments as $key=> $val){ + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + + $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); + $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'"); + $divSel->AddEntry(array($field1,$field2)); + } + + /* Append Blocklits */ + foreach($list as $entry => $value){ + $divSel->AddEntry(array( + array("string"=>""), + array("string"=>$value,"attach"=>"style='border:0px;'") + )); + } + + /* Show dialog */ + $smarty->assign("cblocklist", $this->current_blocklist); + $smarty->assign("departments", $this->config->idepartments); + $smarty->assign("divSelectPredefined", $divSel->DrawList()); + $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + + /* Show main page */ + $smarty->assign("languages", get_languages(TRUE)); + + $smarty->assign("formats", $this->fax_formats); + $smarty->assign("printers", $this->printerList); + + /* Load attributes */ + foreach(array("goFaxIsEnabled", "goFaxDeliveryMode", "facsimileTelephoneNumber", + "goFaxPrinter", "goFaxLanguage", "goFaxFormat", + "facsimileAlternateTelephoneNumber", "mail") as $val){ + + $smarty->assign("$val", $this->$val); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $acl => $desc){ + $smarty->assign($acl."ACL",$this->getacl($acl,$edit_mode)); + } + + /* Load checkboxes */ + if ($this->goFaxIsEnabled == "1"){ + $smarty->assign("goFaxIsEnabled", ""); + } else { + $smarty->assign("goFaxIsEnabled", "checked"); + } + /* goFaxAccount has "mail" as must! Block if no mailaddress is specified... */ + if ($this->goFaxDeliveryMode & 32) { + $smarty->assign("faxtomail", "checked"); + } else { + $smarty->assign("faxtomail", ""); + } + if ($this->goFaxDeliveryMode & 64) { + $smarty->assign("faxtoprinter", "checked"); + } else { + $smarty->assign("faxtoprinter", ""); + } + + + $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + + /* Adapt mail settings if needed */ + if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){ + unset($this->attrs['mail']); + } + + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/fax account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove',array("uid"=> $this->uid)); + } + + + /* Check formular input */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* must: facsimileTelephoneNumber */ + if ($this->facsimileTelephoneNumber == ""){ + $message[]= _("The required field 'Fax' is not set."); + } + + if (!is_phone_nr($this->facsimileTelephoneNumber)){ + $message[]= _("Please enter a valid telephone number in the 'Fax' field."); + } + + /* IF mail is specified (which is only the case if there's no mail account + present), check if it's valid.. */ + if (@isset($this->parent->by_object['mailAccount']) && + $this->goFaxDeliveryMode & 32){ + if ($this->mail == ""){ + $message[]= _("Mail delivery is checked, but no address has been specified."); + } elseif (!is_email($this->mail)){ + $message[]= _("The mail address you've entered is invalid."); + } + } + + // IE Fix, IE lets you choose disabled option, stupid browser ... + if((empty($this->goFaxPrinter))&&($this->goFaxDeliveryMode & 64)){ + $message[]= _("Deliver fax to printer, is only possible if valid printer is given. Please correct your choice."); + } + + return ($message); + } + + /* Save data to object */ + function save_object() + { + $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit'])); + if (isset($_POST['faxTab'])){ + plugin::save_object(); + + + $tmp = 0+$this->goFaxDeliveryMode; + + if($this->acl_is_writeable("faxtomail",$edit_mode)){ + if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){ + $tmp |= 32; + }elseif($tmp & 32){ + $tmp &= (!32); + } + } + if($this->acl_is_writeable("faxtoprinter",$edit_mode)){ + if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){ + $tmp |= 64; + }elseif($tmp & 64){ + $tmp &= !64; + } + } + $this->goFaxDeliveryMode = $tmp; + + if($this->acl_is_writeable("goFaxIsEnabled",$edit_mode)){ + if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){ + $this->goFaxIsEnabled= "0"; + } else { + $this->goFaxIsEnabled= "1"; + } + } + + + if (isset($_POST['mail']) && $this->acl_is_writeable("faxtomail",$edit_mode)){ + $this->mail= $_POST['mail']; + } + + /* Check if mail account is active and correct the internal + reference to represent the current status. */ + if(isset($this->parent)){ + if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){ + $this->has_mailAccount= TRUE; + } + } + } + + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Save arrays */ + foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", + "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ + + $this->attrs[$val]= $this->$val; + } + + if(!$this->attrs['goFaxDeliveryMode']){ + $this->attrs['goFaxDeliveryMode'] = 0; + } + + /* Do not save mail address ... it was possibly changed by mail plugin */ + /* Adapt mail settings if needed */ + if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){ + unset($this->attrs['mail']); + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/fax account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + if ($this->initially_was_account == $this->is_account){ + if ($this->is_modified){ + $this->handle_post_events("mofidy",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + + } + + + /* Adapt from template, using 'dn' */ + function adapt_from_template($dn) + { + plugin::adapt_from_template($dn); + + foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", + "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ + + if (isset($this->attrs[$val])){ + $this->$val= $this->attrs[$val]; + } + } + } + + + + /* Add alternate fax recipient */ + function addAlternate($number) + { + $this->facsimileAlternateTelephoneNumber[]= "$number"; + $this->facsimileAlternateTelephoneNumber= + array_unique ($this->facsimileAlternateTelephoneNumber); + + sort ($this->facsimileAlternateTelephoneNumber); + reset ($this->facsimileAlternateTelephoneNumber); + } + + function delAlternate($numbers) + { + $this->facsimileAlternateTelephoneNumber= array_remove_entries ($numbers, + $this->facsimileAlternateTelephoneNumber); + } + + function getCopyDialog() + { + $str = ""; + $smarty = get_smarty(); + $smarty->assign("facsimileTelephoneNumber", $this->facsimileTelephoneNumber); + $str['string'] = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + $str['status'] =""; + return($str); + } + + function SaveCopyDialog() + { + if(isset($_POST['facsimileTelephoneNumber'])){ + $this->facsimileTelephoneNumber = $_POST['facsimileTelephoneNumber']; + } + } + + + /* Return plugin informations for acl handling + #FIXME some attributes are still missing in this plugin acls */ + static function plInfo() + { + return (array( + "plShortName" => _("Fax"), + "plDescription" => _("Fax account settings"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 6, + "plSection" => "personal", + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "goFaxIsEnabled" => _("Enable/Disable fax"), + "goFaxRBlocklist" => _("Receive blocklist"), + "goFaxSBlocklist" => _("Send blocklist"), + "facsimileTelephoneNumber" => _("Fax number"), // goFaxDeliveryMode + "facsimileAlternateTelephoneNumber" => _("Alternate fax number"), // goFaxDeliveryMode + "faxtomail" => _("Deliver fax as mail"), + "faxtoprinter" => _("Deliver fax to printer"), + "goFaxFormat" => _("Delivery format"), + "goFaxLanguage" => _("Language")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofax/faxaccount/generic.tpl b/gosa-core/plugins/gofax/faxaccount/generic.tpl new file mode 100644 index 000000000..cb56a6c11 --- /dev/null +++ b/gosa-core/plugins/gofax/faxaccount/generic.tpl @@ -0,0 +1,145 @@ + + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + + + + + + +
{$must} + +{render acl=$facsimileTelephoneNumberACL} + +{/render} + +
+ +{render acl=$goFaxLanguageACL} + +{/render} + +
+ +{render acl=$goFaxFormatACL} + +{/render} +
+ +
+   + +

 {t}Delivery methods{/t}

+ +{render acl=$goFaxIsEnabledACL} + +{/render} + {t}Temporary disable fax usage{/t}
+ + {if $has_mailaccount eq "false"} +{render acl=$faxtomailACL} + +{/render} +   +{render acl=$faxtomailACL} + +{/render} + {else} +{render acl=$faxtomailACL} + +{/render} + {t}Deliver fax as mail{/t} + {/if} +
+ +{render acl=$faxtoprinterACL} + +{/render} + {t}Deliver fax to printer{/t}  +{render acl=$faxtoprinterACL} + +{/render} +
+ +

 

+ + + + + + +
+

 {t}Alternate fax numbers{/t}

+{render acl=$facsimileAlternateTelephoneNumberACL} + +{/render} +
+{render acl=$facsimileAlternateTelephoneNumberACL} + +{/render} +{render acl=$facsimileAlternateTelephoneNumberACL} +   +{/render} +{render acl=$facsimileAlternateTelephoneNumberACL} +   +{/render} +{render acl=$facsimileAlternateTelephoneNumberACL} + +{/render} +
+

 {t}Blocklists{/t}

+ + + + + + + + + +
{t}Blocklists for incoming fax{/t} +{render acl=$goFaxRBlocklistACL} + +{/render} +
{t}Blocklists for outgoing fax{/t} +{render acl=$goFaxSBlocklistACL} + +{/render} +
+
+ + + + + diff --git a/gosa-core/plugins/gofax/faxaccount/lists.tpl b/gosa-core/plugins/gofax/faxaccount/lists.tpl new file mode 100644 index 000000000..5817e6c7d --- /dev/null +++ b/gosa-core/plugins/gofax/faxaccount/lists.tpl @@ -0,0 +1,35 @@ + + + + + + +
+ {t}Blocked numbers/lists{/t} +
+ +
+ +   + +
+ {t}List of predefined blocklists{/t}
+ + + + +
+ {$divSelectPredefined} +
+
+
+ +

+ +   + +

+ diff --git a/gosa-core/plugins/gofax/faxaccount/locals.tpl b/gosa-core/plugins/gofax/faxaccount/locals.tpl new file mode 100644 index 000000000..ebf9a894f --- /dev/null +++ b/gosa-core/plugins/gofax/faxaccount/locals.tpl @@ -0,0 +1,64 @@ + + + + + +
+
+

+ {t}Select numbers to add{/t} {$hint}
+

+
+
+

+ +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + +
+   + +
+ + + + + +
+ + +
+ + + + + +
+ + +
+ {$apply} +
+
+ +

+ +   + +

+ diff --git a/gosa-core/plugins/gofax/faxaccount/main.inc b/gosa-core/plugins/gofax/faxaccount/main.inc new file mode 100644 index 000000000..d2786d889 --- /dev/null +++ b/gosa-core/plugins/gofax/faxaccount/main.inc @@ -0,0 +1,112 @@ +dn); + sess_del ('edit'); + sess_del ('gofaxAccount'); + } + + /* Create gofaxAccount object on demand */ + if (!isset($_SESSION['gofaxAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['gofaxAccount']= new gofaxAccount ($config, $ui->dn); + $_SESSION['gofaxAccount']->set_acl_base($ui->dn); + $_SESSION['gofaxAccount']->set_acl_category("users"); + + } + $gofaxAccount= $_SESSION['gofaxAccount']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $gofaxAccount->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $gofaxAccount->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $gofaxAccount->save (); + del_lock ($ui->dn); + sess_del ('edit'); + + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display.= $lock_msg; + }else{ + $display.= $gofaxAccount->execute (); + } + + $info= ""; + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['gofaxAccount']= $gofaxAccount; + } + + /* Show page footer depending on the mode */ + if (!$gofaxAccount->locals_dialog && + !$gofaxAccount->out_blocklist_dialog && + !$gofaxAccount->in_blocklist_dialog && + $gofaxAccount->is_account && + empty($lock_msg)){ + + $display.= "

\n"; + + /* Are we in edit mode? */ + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " \n"; + $display.= "\n"; + $info= " ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/gofaxAccount"))){ + $info.= "\"\""._("Click the 'Edit' button below to change informations in this dialog"); + $display.= ""; + } + $display.= "\n"; + } + $display.= "

"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/fax.png'), _("FAX settings"), $info).$display; + +} +?> diff --git a/gosa-core/plugins/gofax/faxaccount/paste_generic.tpl b/gosa-core/plugins/gofax/faxaccount/paste_generic.tpl new file mode 100644 index 000000000..6efca1d5b --- /dev/null +++ b/gosa-core/plugins/gofax/faxaccount/paste_generic.tpl @@ -0,0 +1,31 @@ + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {$must} + + +
+ {t}Alternate fax numbers will not be copied{/t} +
+
+ + diff --git a/gosa-core/plugins/gofax/faxreports/class_faxreport.inc b/gosa-core/plugins/gofax/faxreports/class_faxreport.inc new file mode 100644 index 000000000..41e0fc471 --- /dev/null +++ b/gosa-core/plugins/gofax/faxreports/class_faxreport.inc @@ -0,0 +1,507 @@ +config = $config; + $this->ui = &$ui; + $this->search_base = get_base_from_people($ui->dn); + $this->year = date("Y"); + $this->month = date("m"); + + /* Get global filter config and set class vars , + or create a filter */ + if (!is_global("faxreportfilter")){ + $faxreportfilter = array(); + foreach($this->attributes_SO as $name){ + $faxreportfilter[$name] = $this->$name; + } + register_global("faxreportfilter",$faxreportfilter); + }else{ + $faxreportfilter = get_global("faxreportfilter"); + foreach($this->attributes_SO as $name){ + $this->$name = $faxreportfilter[$name]; + } + } + } + + + /* Create Filter & Search & Display results */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /************ + Variable initialisation + ************/ + + /* Create months */ + $months= array(); + for($i = 1 ; $i <= 12 ; $i ++ ){ + $months[$i] = _(date("F",gmmktime(0,0,0,$i,1))); + } + + /* Create years */ + $current= date("Y"); + $years= array(); + for ($y= $current - 5; $y<=$current; $y++){ + $years[]= $y; + } + + + /************ + Set smarty defaults + ************/ + + $smarty= get_smarty(); + $smarty->assign("launchimage" , get_template_path('images/launch.png')); + $smarty->assign("search_image" , get_template_path('images/search.png')); + $smarty->assign("search_for" , $this->search_for); + $smarty->assign("bases" , $this->config->idepartments); + $smarty->assign("base_select" , $this->search_base); + $smarty->assign("months" , $months); + $smarty->assign("month_select" , $this->month); + $smarty->assign("years" , $years); + $smarty->assign("year_select" , $this->year); + $smarty->assign("search_result" , ""); + + + /************ + Check database accessibility + ************/ + + /* Some checks */ + if(!isset($this->config->data['SERVERS']['FAX'])){ + print_red(_("No fax extension defined in your server configuration, no reports can be shown!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + }elseif(!is_callable("mysql_connect")){ + print_red(_("There is no mysql extension available, please check your php setup.")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + }else{ + /* Connecting, selecting database */ + $cfg = $this->config->data['SERVERS']['FAX']; + $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); + if ($link === FALSE){ + print_red(_("Can't connect to fax database, no reports can be shown!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + if (! @mysql_select_db("gofax")){ + print_red(_("Can't select fax database for report generation!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + if (! mysql_query("SELECT * FROM faxlog;")){ + print_red(_("Can't query fax table 'faxlog' for report generation!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + } + + + /************ + Perform a deatil view + ************/ + + /* Do detail view? */ + if (isset($_GET['detail'])){ + + /* Create query */ + $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,sender_msn,receiver_id,". + "receiver_msn,pages,status_message,transfer_time FROM faxlog WHERE id=".$_GET['detail'].";"; + + /* Connecting, selecting database */ + $cfg= $this->config->data['SERVERS']['FAX']; + + /* Check if everything went ok*/ + $result = @mysql_query($query); + if ($result === false){ + print_red(_("Query for fax database failed!")); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query failed"); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + $line = mysql_fetch_array($result, MYSQL_ASSOC); + mysql_close($link); + + if (!preg_match ("/'".$line["uid"]."'/", $this->userfilter)){ + print_red (_("You have no permission to retrieve informations about this fax id!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + /* Check acls */ + $fax_uids = array_flip($this->fax_users); + $uid = $line['uid']; + $dn = $fax_uids[$uid]; + $acls = $this->ui->get_permissions($dn,"faxreport/faxreport"); + if(!preg_match("/r/",$acls)){ + print_red (_("You have no permission to retrieve informations about this fax id!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + $parts= array( "id", "uid", "queuing_time", "status", "sender_id", "sender_msn", + "receiver_id", "receiver_msn", "pages", "status_message", "transfer_time" ); + + foreach ($parts as $vname) { + + $final="fax_$vname"; + if($vname != "uid"){ + $v_acl = $this->ui->get_permissions($dn,"faxreport/faxreport",preg_replace("/_/","",$vname)); + }else{ + $v_acl = "r"; + } + + if ($line[$vname] != "" && preg_match("/r/",$v_acl)){ + $smarty->assign("$final", $line[$vname]); + } else { + $smarty->assign("$final", "-"); + } + } + $queuing_time= $line['queuing_time']; + + /* The user is allowed to download all fax images from those users + that are listed in $_SESSION['fuserfilter'] + Don't forget to check getfax.php if you change somthing here */ + $_SESSION['fuserfilter']= $this->userfilter; + $smarty->assign("plug", "?plug=".validate($_GET['plug'])); + $smarty->assign("detail", validate($_GET['detail'])); + + $format= _("Y-M-D"); + $date= preg_replace("/Y/", substr($queuing_time,0,4), $format); + $date= preg_replace("/M/", substr($queuing_time,4,2), $date); + $date= preg_replace("/D/", substr($queuing_time,6,2), $date); + $smarty->assign("date", $date); + $smarty->assign("time", substr($queuing_time,8,2).":". + substr($queuing_time,10,2).":". + substr($queuing_time,12,2)); + return($smarty->fetch(get_template_path('detail.tpl', TRUE))); + } + + + /************ + Search for uids matching the filter + ************/ + + /* Search button has been pressed */ + if ($this->search_for != ""){ + + if (is_integer (strpos($this->search_for, "*"))){ + $s= $this->search_for; + } else { + $s= "*".$this->search_for."*"; + } + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->search_base); + + /* Perform ldap search for potential users */ + $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))". + "(objectClass=goFaxAccount)". + "(|(uid=$s)(l=$s)(homePhone=$s)". + "(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)". + "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)". + "(title=$s)))"; + + $res = get_list($filter, "users", $this->search_base, array("uid"), GL_SUBSEARCH ); + + /* Check if we are allowed to collect fax data */ + $fax_users= array(); + foreach($res as $attrs){ + $acl = $this->ui->get_permissions($attrs['dn'],"users/user","uid"); + if(preg_match("/r/",$acl)){ + $fax_users[ $attrs['dn']]= $attrs["uid"][0]; + } + } + + $this->fax_users = $fax_users; + + /* Prepare SQL query */ + $this->userfilter= ""; + foreach ($fax_users as $user){ + $this->userfilter.= "uid = '$user' OR "; + } + $this->userfilter= preg_replace("/OR $/", "", $this->userfilter); + } + + /************ + Create filter + ************/ + + /* Perform SQL query */ + if ($this->userfilter){ + if ($this->sort_direction == "down"){ + $desc= "DESC"; + } else { + $desc= ""; + } + $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year)); + $end= date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year)); + $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,receiver_id,pages FROM faxlog ". + "WHERE ( ".$this->userfilter." ) AND queuing_time <= $end AND ". + "queuing_time >= $start ORDER BY ".$this->fields[$this->sort]." $desc;"; + + if(!is_callable("mysql_connect")){ + print_red("There is no mysql extension configured in your php setup."); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + + /************ + Create results + ************/ + + /* Connecting, selecting database */ + $cfg= $this->config->data['SERVERS']['FAX']; + $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); + + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + $result = @mysql_query($query); + if ($result === false){ + print_red(_("Query for fax database failed!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + $this->report_list= array(); + $user_ids = array_flip($fax_users); + while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { + + /* Check permissions for each field */ + $dn = $user_ids[$line['uid']]; + + /* Hide restricted attributes */ + foreach(array("pages","receiverid","senderid","status","queuingtime","detailedView") as $attr){ + $var = $attr."ACL"; + $$var = $this->ui->get_permissions($dn,"faxreport/faxreport",$attr); + } + + /* Restricted attributes will not be displayed, this will be displayed instead */ + $no_acl = ""._("Insufficient permissions").""; + + /* Create date */ + if((!empty($line["queuing_time"])) && preg_match("/r/",$queuingtimeACL)){ + $hour= substr($line["queuing_time"], 8, 2); + $minute=substr($line["queuing_time"], 10, 2); + $format= _("Y-M-D"); + $date= preg_replace("/Y/", substr($line["queuing_time"], 0, 4), $format); + $date= preg_replace("/M/", substr($line["queuing_time"], 4, 2), $date); + $date= preg_replace("/D/", substr($line["queuing_time"], 6, 2), $date); + $str_date = $date." ".$hour.":".$minute; + }else{ + $str_date = $no_acl; + } + + /* Create entry html str */ + + if(preg_match("/r/",$detailedViewACL)){ + $str = " + + \"\" +  ".$line["uid"]. + " + + $str_date"; + }else{ + $str = " + \"\" +  ".$line["uid"]." + $str_date"; + } + + /* Add Status td */ + if(preg_match("/r/",$statusACL)){ + $str.="".$this->status[$line["status"]].""; + }else{ + $str.="".$no_acl.""; + } + + /* Add sender_id td */ + if(preg_match("/r/",$senderidACL)){ + $str.="".$line["sender_id"].""; + }else{ + $str.="".$no_acl.""; + } + + /* Add receiver_id td */ + if(preg_match("/r/",$receiveridACL)){ + $str.="".$line["receiver_id"].""; + }else{ + $str.="".$no_acl.""; + } + + /* Add receiver_id td */ + if(preg_match("/r/",$pagesACL)){ + $str.="".$line["pages"].""; + }else{ + $str.="".$no_acl.""; + } + $this->report_list[] = $str; + } + + mysql_close($link); + } + + /************ + Create output out of results + ************/ + + /* Generate output */ + $mod= 0; + $output= ""; + foreach ($this->report_list as $val){ + if ($mod < $this->start) { + $mod++; + continue; + } + if ($mod >= ($this->start + $this->range)){ + $mod++; + break; + } + if ( ($mod++) & 1){ + $col= "background-color: #ECECEC;"; + } else { + $col= "background-color: #F5F5F5;"; + } + $output.= "$val"; + } + + + /************ + Display results + ************/ + + if (isset($fax_users) && count($fax_users)){ + $smarty->assign("search_result", $output); + $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start, $this->range,"EntriesPerPage")); + }else{ + $smarty->assign("search_result", ""); + } + + /* Show main page */ + $smarty->assign("plug", "?plug=".validate($_GET['plug'])); + for($i= 0; $i<7; $i++){ + $smarty->assign("mode$i", ""); + } + $smarty->assign("mode".$this->sort, "\"\"sort_direction. + ".png\" border=0 align=middle>"); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + + /* Save ui input, and store it in $_SESSION + to remember last search next time*/ + function save_object() + { + $faxreportfilter = get_global("faxreportfilter"); + if(isset($_POST['EntriesPerPage'])){ + $this->range = $_POST['EntriesPerPage']; + } + + if (isset($_GET['start'])){ + $this->start= (int)$_GET['start']; + } + + /* Adapt sorting */ + if (isset($_GET['sort'])){ + if ($this->sort == (int)$_GET['sort']){ + if ($this->sort_direction == "down"){ + $this->sort_direction= "up"; + } else { + $this->sort_direction= "down"; + } + } + $this->sort= (int)$_GET['sort']; + if ($this->sort < 0 || $this->sort > 5){ + $this->sort= 0; + } + } + foreach( array("year", "month", "search_for", "search_base") as $type){ + if (isset($_POST[$type])){ + $faxreportfilter[$type]= $_POST[$type]; + + /* reset start page, if filter has changed */ + if(!isset($_GET['start'])){ + $this->start = 0; + } + } + $this->$type= $faxreportfilter[$type]; + + } + foreach($this->attributes_SO as $name){ + $faxreportfilter[$name] = $this->$name; + } + register_global("faxreportfilter",$faxreportfilter); + } + + + /* Return plugin informations for acl handling + #FIXME You can only read attributes within this report plugin */ + static function plInfo() + { + + return (array( + "plShortName" => _("Fax report"), + "plDescription" => _("Fax report")." "._("All entries are readonly")."", + "plSelfModify" => TRUE, + "plDepends" => array(), + "plPriority" => 1, // Position in tabs + "plSection" => array("administration"), // This belongs to personal + "plCategory" => array("faxreport" => array("description" => _("Fax reports"), + "objectClass" => array())), + "plOptions" => array(), + + "plProvidedAcls" => array( + "detailedView" => _("Detailed view"), + "id" => _("Fax ID"), + "queuingtime" => _("Date")." / "._("Time"), + "status" => _("Status"), + "senderid" => _("Sender ID"), + "sendermsn" => _("Sender MSN"), + "receiverid" => _("Receiver ID"), + "receivermsn" => _("Receiver MSN"), + "pages" => _("Number of pages"), + "statusmessage" => _("Status Message"), + "transfertime" => _("Transfer time")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofax/faxreports/contents.tpl b/gosa-core/plugins/gofax/faxreports/contents.tpl new file mode 100644 index 000000000..197c5b8c8 --- /dev/null +++ b/gosa-core/plugins/gofax/faxreports/contents.tpl @@ -0,0 +1,59 @@ +
+

[F]{t}Filter{/t}

+
+
+

+  {t}Search for{/t} + + {t}in{/t} + + {t}during{/t} + + {t}in{/t} + +   + +

+
+ +
+ +{if $search_result ne ""} + + + + + + + + + + {$search_result} +
{t}User{/t} {$mode0}{t}Date{/t} {$mode1}{t}Status{/t} {$mode2}{t}Sender{/t} {$mode3}{t}Receiver{/t} {$mode4}{t}# pages{/t} {$mode5}
+ + + + + +
{$range_selector}
+

+   +

+ +{else} + {t}Search returned no results...{/t} +{/if} + + + + diff --git a/gosa-core/plugins/gofax/faxreports/detail.tpl b/gosa-core/plugins/gofax/faxreports/detail.tpl new file mode 100644 index 000000000..20b6123b8 --- /dev/null +++ b/gosa-core/plugins/gofax/faxreports/detail.tpl @@ -0,0 +1,69 @@ + + + + + + +
+ + {t}FAX preview - please wait{/t} + +

+ {t}Click on fax to download{/t} +

+
+   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t}FAX ID{/t}{$fax_id}
{t}User{/t}{$fax_uid}
{t}Date / Time{/t}{$date} / {$time}
{t}Sender MSN{/t}{$fax_sender_msn}
{t}Sender ID{/t}{$fax_sender_id}
{t}Receiver MSN{/t}{$fax_receiver_msn}
{t}Receiver ID{/t}{$fax_receiver_id}
{t}Status{/t}{$fax_status}
{t}Status message{/t}{$fax_status_message}
{t}Transfer time{/t}{$fax_transfer_time}
{t}# pages{/t}{$fax_pages}
+ +
+ +

+ +

+ diff --git a/gosa-core/plugins/gofax/faxreports/main.inc b/gosa-core/plugins/gofax/faxreports/main.inc new file mode 100644 index 000000000..ac80ff340 --- /dev/null +++ b/gosa-core/plugins/gofax/faxreports/main.inc @@ -0,0 +1,19 @@ +save_object(); + $display= $faxreport->execute (); + $display.= "\n"; + $display= print_header(get_template_path('images/reports.png'), _("FAX reports")).$display; + + /* Store changes in session */ + $_SESSION['faxreport']= $faxreport; +} +?> diff --git a/gosa-core/plugins/gofon/conference/class_divListConferences.inc b/gosa-core/plugins/gofon/conference/class_divListConferences.inc new file mode 100755 index 000000000..cdcdcbc9d --- /dev/null +++ b/gosa-core/plugins/gofon/conference/class_divListConferences.inc @@ -0,0 +1,317 @@ +parent = $parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of conference rooms")); + $this->SetSummary(_("List of conference rooms")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to create, delete and edit selected phone conferences. Having a large number of phone conferences, you might prefer the range selectors on top of the conferences list.")); + + $this->EnableAplhabet(true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 100; + if($this->parent->snapshotEnabled()){ + $action_col_size += 20; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" =>_("Name - Number"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'")); + $this->AddHeader(array("string" => _("PIN"), "attach" => "style='width:50px;'")); + $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); + + /* Add Checkboxes / SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching conference names"),"*" , true); + } + + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("gofonconference"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get acls */ + $acls = $ui->get_permissions($this->selectedBase,"gofonconference/conference"); + $acl_all = $ui->has_complete_category_acls($this->selectedBase,"gofonconference") ; + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* Add the rest (base select ....)*/ + $listhead .= _("Base")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $s.= "...|". + " "._("Conference")."|conference_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(is_object($this->parent->CopyPasteHandler)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acls)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + $linkopen= "%s"; + + $userimg = "User"; + $editlink = "%s"; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 100; + if($this->parent->snapshotEnabled()){ + $action_col_size += 20; + } + + /* Insert conferneces*/ + foreach($list as $conferencekey => $conference ){ + + $acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference"); + $acl_all = $this->ui->has_complete_category_acls($conference['dn'],"gofonconference"); + + /* You will need at least read access for the + current conference informations to display it */ + if(!preg_match("/r/",$acl)){ + continue; + } + + $actions =""; + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions.= " "; + $actions.= " "; + } + + /* Add edit icon - This is allowed when we have at least read access. */ + $actions.= ""; + + /* Add snapshot icon - This is allowed when we have create and write access for the current entry */ + if(preg_match("/(c.*w|w.*c)/",$acl_all)){ + $actions.= $this->GetSnapShotActions($conference['dn']); + } + + /* Create delete link - Only if we are allowed to delete this entry */ + if(preg_match("/d/",$acl)){ + $actions.= ""; + } + + /* Display PIN icon, only if we are the owner of the given conference */ + $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0]; + $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN"); + if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){ + $pin = "PIN"; + }else{ + $pin = " "; + } + + /* Display numer of the conference if we are allowed to view it */ + $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber"); + if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){ + $number = " - ".$conference['telephoneNumber'][0]; + }else{ + $number = "  - ?"; + } + + /* Get conference owner name */ + $ldap= $this->parent->config->get_ldap_link(); + $ldap->cat($conference['goFonConferenceOwner'][0], array('cn')); + $data = $ldap->fetch(); + if(isset($data['cn'][0])){ + $cn = $data['cn'][0]; + }else{ + $cn = _("Unknown"); + } + + /* Create title */ + $title = " title='".preg_replace("/ /"," ",@LDAP::fix($data['dn']))."' "; + + /* Cutted objects should be displayed in light grey */ + $display = $conference['cn'][0].$number; + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $conference['dn']) { + $display = "".$display.""; + break; + } + } + } + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'"); + $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$display), "attach" => $title." style=''"); + $a_field3 = array("string"=> $cn , "attach" => $title." style='width:200px;'"); + $a_field4 = array("string"=> $pin, "attach" => $title." style='width:50px;'"); + $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), + "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + + $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5)); + } + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_objs = count($list); + + $num_obj_str = _("Number of listed conferences"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow :: save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/conference/class_phoneConferenceGeneric.inc b/gosa-core/plugins/gofon/conference/class_phoneConferenceGeneric.inc new file mode 100644 index 000000000..e0364dc54 --- /dev/null +++ b/gosa-core/plugins/gofon/conference/class_phoneConferenceGeneric.inc @@ -0,0 +1,794 @@ +is_account = TRUE; + $this->ui = get_userinfo(); + $this->orig_dn = $dn; + + $this->languages= get_languages(TRUE,TRUE); + + + /* Check server configurations + * Load all server configuration in $this->goFonHomeServers if available + * and use first server as default if necessary. + */ + $a_SETUP= array(); + if(array_key_exists('config',$_SESSION) && + array_key_exists('SERVERS',$_SESSION['config']->data) && + array_key_exists('FON',$_SESSION['config']->data['SERVERS']) && + count($_SESSION['config']->data['SERVERS']['FON']) && + is_callable("mysql_connect") + ) { + + /* Set available server */ + $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON']; + + /* Set default server */ + if($this->dn == "new"){ + $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; + } + + /* Remember inital home server, to be able to remove old entries */ + $this->init_HomeServer = $this->goFonHomeServer; + + /* get config */ + if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){ + print_red(sprintf(_("The specified home server '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry while ignoring old accounts."),$this->goFonHomeServer, $this->goFonHomeServers[0]['DN'])); + + $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; + $this->init_HomeServer = $this->goFonHomeServers[0]['DN']; + } + $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer]; + } + + /* Set base */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + if(isset($_SESSION['CurrentMainBase'])){ + $this->base = $_SESSION['CurrentMainBase']; + }else{ + $this->base= dn2base($ui->dn); + } + } else { + + /* The base is something like this + "cn=Confis,ou=conferences,ou=asterisk,ou=configs,ou=systems," */ + $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,/", "", $this->dn); + } + + $this->goFonConferenceOwner=$this->ui->dn; + + /* Parse Options ... + * Parameter|Lifetime|number + */ + if($this->dn!="new"){ + $tmp1= split("\|",$this->attrs['goFonConferenceOption'][0]); + + for($i = 0 ; $i < strlen($tmp1[0]);$i++){ + $varname = "goFonConferenceOption_".$tmp1[0][$i]; + if($tmp1[0][$i]=="d"){ + $this->goFonConferenceOption_D = $tmp1[0][$i]; + }else{ + $this->$varname = $tmp1[0][$i]; + } + } + + $this->goFonConferenceOptionLifetime = $tmp1[1]; + if(isset($tmp1[2]) && isset($this->languages[$tmp1[2]])){ + $this->language = $tmp1[2]; + } + + $this->old_tele_number = $this->telephoneNumber; + } + $this->old_dn = $this->dn; + $this->old_cn = $this->cn; + $this->old_base = $this->base; + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log last action */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","gofonconference/".get_class($this),$this->dn); + } + + $smarty= get_smarty(); + + $smarty->assign("bases" ,$this->config->idepartments); + $smarty->assign("base" ,$this->base); + + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + foreach ($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + if(!$this->$val){ + $smarty->assign($val."CHK", ""); + }else{ + $smarty->assign($val."CHK", " checked "); + } + } + + /* Create array with goFonHomeServer */ + $tmp = array(); + foreach($this->goFonHomeServers as $dn => $val){ + if(!is_numeric($dn)){ + $tmp[$dn] = $val['SERVER']; + } + } + $smarty->assign("language",$this->language); + $smarty->assign("languages",$this->languages); + $smarty->assign("goFonHomeServers",$tmp); + $smarty->assign("goFonConferenceOptions", array("D"=>"Conference ","d"=>"Conference without PIN")); + $smarty->assign("goFonConferenceOptionFormats", array("WAV"=>"Wave","GSM"=>"GSM","WAV49"=>"Wave49")); + $smarty->assign("goFonConferenceOption", $this->goFonConferenceOption_D); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + if($this->acl_is_writeable("base")){ + $smarty->assign("baseSelect",true); + }else{ + $smarty->assign("baseSelect",false); + } + + $smarty->assign("bases" ,$this->get_allowed_bases()); + $smarty->assign("base_select" ,$this->base); + + + if($_SESSION['js']==1){ + if($this->goFonConferenceOption_P != "P"){ + $smarty->assign("goFonPINACL", $this->getacl("goFonPIN",TRUE)); + $smarty->assign("goFonPIN",""); + } + if($this->goFonConferenceOption_r != "r"){ + $smarty->assign("goFonConferenceOptionFormatACL", $this->getacl("goFonConferenceOptionr",TRUE)); + } + } + return($smarty->fetch (get_template_path('generic.tpl', TRUE))); + } + + + function remove_from_parent() + { + /* Check if 'old' home server is available in gosa FON server configuration + * Try to remove this entry from database and display errors. + */ + if(isset($this->goFonHomeServers[$this->goFonHomeServer])){ + $str = $this->SQL_remove_me(true); + if($str){ + print_red($str); + return false; + } + }else{ + print_red(_("Could not remove the conference entry from database on home server (%s). Please check your asterisk database configuration.")); + return false; + } + + /* Remove ldap entry */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->recursive_remove(); + + new log("remove","gofonconference/".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'); + } + + + /* Save data to object */ + function save_object() + { + if(isset($_POST['phoneConferenceGeneric'])){ + + /* Get selected language */ + if(isset($_POST['language']) && isset($this->languages[get_post('language')])){ + $this->language = get_post('language'); + } + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + /* Save base, since this is no LDAP attribute */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s", + "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){ + + /* Acl can't contain _ so we remove it here. */ + $acl_name = preg_replace("/_/","",$attrs); + + if($this->acl_is_writeable($acl_name)){ + + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + }else{ + $this->$attrs = false; + } + } + } + } + } + + + function check_database_accessibility() + { + /* Check if mysql extension is available */ + if(!is_callable("mysql_pconnect")){ + return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup.")); + } + + /******************** + * Check currently selected home server + ********************/ + + $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer]; + $r_current = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); + if(!$r_current){ + new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_current)); + + return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), + $cfg_Current['SERVER'],$cfg_Current['LOGIN'])); + } + $db_current = @mysql_select_db($cfg_Current['DB'],$r_current); + if(!$db_current){ + new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_current)); + mysql_close($r_current); + return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER'])); + } + + /******************** + * Check init home server + ********************/ + + if($this->goFonHomeServers != $this->init_HomeServer){ + $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ; + $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']); + if(!$r_init){ + new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init)); + + return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), + $cfg_Init['SERVER'],$cfg_Init['LOGIN'])); + } + $db_init = @mysql_select_db($cfg_Init['DB'],$r_init); + if(!$db_init){ + new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init)); + mysql_close($r_init); + return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER'])); + } + } + } + + /* Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if($this->is_number_used()){ + $message[] = $this->is_number_used(); + } + + /* Check if previously selected server is still available */ + if($this->initially_was_account && !isset($this->goFonHomeServers[$this->goFonHomeServer])){ + $message[]= sprintf(_("The previously selected asterisk home server (%s) is no longer available."),preg_replace("/,/",", ",$this->goFonHomeServer)); + return($message); + } + + if((empty($this->goFonPIN))&&($this->goFonConferenceOption_P=="P")&&($this->goFonConferenceOption_D=="D")){ + $message[]= _("Please enter a PIN."); + } + + if(empty($this->cn)){ + $message[] =_("Please enter a name for the conference."); + } + + if(!is_numeric($this->telephoneNumber)){ + $message[] =_("Only numeric chars are allowed in Number field."); + } + + if(!((is_numeric($this->goFonConferenceOptionLifetime))||(empty($this->goFonConferenceOptionLifetime)))){ + $message[] =_("Only numbers are allowed in Lifetime."); + } + + /* Check if add could be successful */ + $str = $this->SQL_add_me(false); + if(!empty($str)){ + $message[] = $str; + } + + if($this->old_cn != $this->cn || $this->base != $this->old_base){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd("ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->base); + $ldap->search("(&(objectClass=goFonConference)(cn=".$this->cn."))",array("cn")); + if($ldap->count()){ + $message[] =_("There is already a conference with this name in the current tree."); + } + } + return $message; + } + + + function SQL_add_me($save) + { + /* Check if there is at least on server configuration */ + if(!count($this->goFonHomeServers)){ + return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); + } + + /******************** + * Get configuration and try to connect + ********************/ + + /* Check if databases are reachable, returns an error string if anything fails */ + $error_str = $this->check_database_accessibility(); + if($error_str){ + return($error_str); + } + + /* Remove old entries, returns an error string if anything fails */ + $error_str = $this->SQL_remove_me($save); + if($error_str){ + return($error_str); + } + + /* Connect to current database to be able to add new entries */ + $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer] ; + $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); + $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur); + + /******************** + * Remove entries that could cause trouble + ********************/ + + /* If the current home server is different to the initial home server, + * there may be already some entries with the given telephoneNumber and/or cn. + * We must remove those entries to avoid duplicate use of the same extension name. + */ + if($this->goFonHomeServer != $this->init_HomeServer){ + $query = "SELECT id FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->telephoneNumber."' OR exten='".$this->cn."';"; + $res = @mysql_query($query,$res_cur); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + if(!$res){ + new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur)); + return(_("Can not check if there are already some entries with given telephone number and/or cn in the destination home server."). + " "._("Please have a look a the gosa logfiles.")); + } + if($save && mysql_affected_rows($res_cur)) { + $SQL = "DELETE FROM ".$cfg_Current['EXT_TABLE']." + WHERE (exten='".$this->telephoneNumber."') + OR (exten='".$this->cn."')"; + + /* Query and ensure that everything went fine */ + $res = @mysql_query($SQL,$res_cur); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$SQL, "Database query"); + if(!$res){ + new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur)); + return(_("Can not remove entries with some telephone number and/or cn from destination home server."). + " "._("Please have a look a the gosa logfiles.")); + } + } + } + + /******************** + * Add new conference entry + ********************/ + if((!empty($this->telephoneNumber))&&($save==true)){ + + /* Create string out of conference Flags */ + $parameter =""; + foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s", + "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){ + $parameter .= $this->$attrs; + } + + $i=1; + $EXT=array(); + $context="GOsa"; + // Set Language to German + $EXT[$i]['exten'] =$this->telephoneNumber; + $EXT[$i]['context'] = $context; + $EXT[$i]['priority']= $i; + $EXT[$i]['app'] ="SetLanguage"; + $EXT[$i]['appdata'] =$this->language; + $i++; + + if($this->goFonConferenceOption_r == "r"){ + + // Recordingformat for conference + $EXT[$i]['exten'] =$this->telephoneNumber; + $EXT[$i]['context'] =$context; + $EXT[$i]['priority']= $i; + $EXT[$i]['app'] ="Setvar"; + $EXT[$i]['appdata'] ="MEETME_RECORDINGFORMAT=".$this->goFonConferenceOptionFormat; + $i++; + + } + + // Answer Call + $EXT[$i]['exten'] =$this->telephoneNumber; + $EXT[$i]['context'] =$context; + $EXT[$i]['priority']=$i; + $EXT[$i]['app'] ="answer"; + $EXT[$i]['appdata'] =""; + $i++; + + // Start Conference + $EXT[$i]['exten'] =$this->telephoneNumber; + $EXT[$i]['context'] =$context; + $EXT[$i]['priority']=$i; + $EXT[$i]['app'] ="MeetMe"; + + if(empty($this->goFonPIN)) { + $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter; + }else{ + $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter."|".$this->goFonPIN; + } + $i++; + + // Start Conference + $EXT[$i]['exten'] =$this->cn; + $EXT[$i]['context'] =$context; + $EXT[$i]['priority']=1; + $EXT[$i]['app'] ="Goto"; + $EXT[$i]['appdata'] =$this->telephoneNumber."|1"; + $SQL=array(); + + foreach($EXT as $keytop => $valtop){ + $s_keys = ""; + $s_values = ""; + foreach($valtop as $key=>$val){ + $s_keys .="`".$key."`,"; + $s_values .="'".$val."',"; + } + $s_keys =preg_replace("/\,$/","",$s_keys); + $s_values =preg_replace("/\,$/","",$s_values); + $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$s_keys.") VALUES (".$s_values.");"; + } + foreach($SQL as $sqlsyn){ + mysql_query($sqlsyn,$res_cur); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$sqlsyn, "Database query"); + } + } + + @mysql_close($res_cur); + } + + + /* Remove initial entry from database + * This function checks if there is an entry in the + * initial home server that uses this->old_cn or $this->old_tele_number + * and removes this entries. + * This function is called from save and remove_from parent. + * + * The parameter '$save' is false if we just + * want to check if a remove is possible. + * And true if we realy want to remove the entries. + */ + function SQL_remove_me($save) + { + /* check database access */ + $str = $this->check_database_accessibility(); + if($str){ + return($str); + } + + /* Connect to old database */ + $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ; + $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']); + $db_init = @mysql_select_db($cfg_Init['DB'],$r_init); + + /* Check if there is an old entry */ + $query = "SELECT id FROM ".$cfg_Init['EXT_TABLE']." WHERE exten='".$this->old_tele_number."' OR exten='".$this->old_cn."';"; + $res = @mysql_query($query,$r_init); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + if(!$res){ + new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init)); + return(_("Can not check if entry exists in old database. Please have a look a the gosa logfiles.")); + } + + /* There are entries using this cn and/or phone number */ + if($save && mysql_affected_rows($r_init)) { + $SQL = "DELETE FROM ".$cfg_Init['EXT_TABLE']." + WHERE (exten='".$this->old_tele_number."') + OR (exten='".$this->old_cn."')"; + + /* Query and ensure that everything went fine */ + $res = @mysql_query($SQL,$r_init); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$SQL, "Database query"); + if(!$res){ + new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init)); + return(_("Can not remove old entries from initial home server. Please have a look a the gosa logfiles.")); + } + + }//ENDE old num availiable ... + @mysql_close($r_init); + return(false); + } + + + + /* This function checks if the given phonenumbers are available or already in use*/ + function is_number_used() + { + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid")); + while($attrs = $ldap->fetch()) { + unset($attrs['telephoneNumber']['count']); + foreach($attrs['telephoneNumber'] as $tele){ + if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn']; + if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn']; + $numbers[$tele]=$attrs; + } + } + + $num = $this->telephoneNumber; + if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!=$this->old_cn))){ + if(isset($numbers[$num]['uid'][0])){ + return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]); + }else{ + return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]); + } + } + } + + + /* Save to LDAP */ + function save() + { + + if((!isset($this->attrs['goFonPIN']))){ + $pin_use = false; + }else{ + $pin_use = true; + } + + /* Unset PIN if this is a conference without PIN */ + if((!empty($this->goFonPIN)||($this->goFonConferenceOption_P=="P"))&&($this->goFonConferenceOption_D=="d")){ + $this->goFonPIN = ""; + } + + plugin::save(); + + if(empty($this->old_tele_number)){ + $this->old_tele_number= $this->telephoneNumber; + } + + $this->SQL_add_me(true); + + if(empty($this->goFonConferenceOption_P)){ + if($pin_use){ + $this->attrs['goFonPIN']=array(); + }else{ + unset($this->attrs['goFonPIN']); + } + } + $this->attrs['goFonConferenceOption']=""; + foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s", + "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D","goFonConferenceOptionFormat") as $attrs){ + $this->attrs['goFonConferenceOption'] .= $this->$attrs; + unset($this->attrs[$attrs]); + } + + $this->attrs['goFonConferenceOption'].="|".$this->goFonConferenceOptionLifetime; + $this->attrs['goFonConferenceOption'].="|".$this->language; + unset($this->attrs['goFonConferenceOptionLifetime']); + + /* Write back to ldap */ + + unset($this->attrs['base']); + + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn, array('dn')); + + if ($ldap->count()){ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + $this->handle_post_events('modify'); + } else { + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + $this->handle_post_events('add'); + } + + /* Log last action */ + if($this->initially_was_account){ + new log("modify","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of goFonConference/generic with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->postcreate(); + } + + + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $smarty->assign("telephoneNumber" ,$this->telephoneNumber); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + if(isset($_POST['telephoneNumber'])){ + $this->telephoneNumber = $_POST['telephoneNumber']; + } + } + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source) ; + + $source_o = new conference($this->config,$source['dn']); + + foreach($this->attributes as $attr){ + $this->$attr = $source_o->$attr; + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Conference"), + "plDescription" => _("Phone conference management"), + "plSelfModify" => TRUE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("addons" => _("Addons")), + "plCategory" => array("gofonconference" => array("description" => _("GOfon conference"), + "objectClass" => "gofonConference")), + + "plProvidedAcls" => array( + "cn" => _("Name"), + "base" => _("Base"), + "description" => _("Description"), + "goFonPIN" => _("Conference PIN"), + + "goFonHomeServer" => _("Home server"), + "goFonConferenceOptionP" => _("Preset PIN"), + "goFonConferenceOptionr" => _("Record conference"), + "goFonConferenceOptionM" => _("Play music on hold"), + "goFonConferenceOptions" => _("Activate menu"), + "goFonConferenceOptioni" => _("Announce user activity"), + "goFonConferenceOptionc" => _("Count user"), + "goFonConferenceOptionD" => _("Conference type"), + + "goFonConferenceOptionFormat" => _("Format"), + "goFonConferenceOptionLifetime" => _("Lifetime"), + "telephoneNumber" => _("Telephone number"), + "goFonConferenceOwner" => _("Owner")) + )); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/conference/class_phoneConferenceManagment.inc b/gosa-core/plugins/gofon/conference/class_phoneConferenceManagment.inc new file mode 100644 index 000000000..023e52e36 --- /dev/null +++ b/gosa-core/plugins/gofon/conference/class_phoneConferenceManagment.inc @@ -0,0 +1,555 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $attributes = array(); + var $objectclasses = array(); + + var $conferences = array(); + var $conftab = false; + var $ui = NULL; + var $DivListConference = NULL; + + var $CopyPasteHandler = NULL; + var $start_pasting_copied_objects = FALSE; + + /* Initialise Class */ + function phoneConferenceManagment (&$config, $ui) + { + $this->ui = $ui; + $this->dn = ""; + $this->config = $config; + $this->DivListConference = new divListConference($this->config,$this); + + /* Copy & Paste enabled ?*/ + if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + } + + + /* Execute class and display something */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $_SESSION['LOCK_VARS_TO_USE'] = array("/^id$/","/^act$/","/^conference_/","/^item_selected/","/^remove_multiple_conferences/"); + + /*************** + Variable initialisation + ***************/ + + /* Reload departments */ + $smarty = get_smarty(); + $display = ""; + $s_action = ""; // Will contain an action, like del or edit + $s_entry = ""; // The entry name for edit delete -... + + + /*************** + Check posts + ***************/ + + foreach($_POST as $key => $post){ + if(preg_match("/^conference_new.*/i",$key)){ + $s_action = "new"; + // Post for delete + }elseif(preg_match("/^conference_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/^conference_del_/i","",$key); + $s_entry = preg_replace("/_.*$/","",$s_entry); + // Post for edit + }elseif(preg_match("/conference_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/conference_edit_/i","",$key); + $s_entry = preg_replace("/_.*$/","",$s_entry); + }elseif(preg_match("/^remove_multiple_conferences/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + $s_entry = preg_replace("/_.$/","",$s_entry); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + $s_entry = preg_replace("/_.$/","",$s_entry); + }elseif(preg_match("/^multiple_copy_objects/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_objects/",$key)){ + $s_action = "cut_multiple"; + } + } + + /* Edit Entry */ + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action = "edit"; + $s_entry = $_GET['id']; + } + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "conference_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + + /*************** + Cancel dialogs + ***************/ + + /* Reset requested? */ + if (isset($_POST['edit_cancel'])){ + if (isset($this->conftab)){ + del_lock ($this->conftab->dn); + unset ($this->conftab); + } + $this->conftab= NULL; + $this->lognames= array();; + $this->cn= ""; + unset ($_SESSION['objectinfo']); + } + + + /******************** + Copy & Paste Handling ... + ********************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->conferences[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + $smarty->assign("info", sprintf(_("You're about to delete the following user(s) %s"), @LDAP::fix($dns_names))); + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_conference_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + $this->dn = $dn; + $acl = $this->ui->get_permissions($this->dn,"gofonconference/conference"); + if(preg_match("/d/",$acl)){ + $this->remove_from_parent(); + } else { + print_red (_("You have no permission to remove this department.")); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_conference_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /*************** + Delete + ***************/ + + /* Delete Entry if Posted action (s_action) == del + * The entry which will be deleted is defined in $s_entry + */ + if ($s_action =="del"){ + + $acl = $this->ui->get_permissions($this->conferences[$s_entry]['dn'],"gofonconference/conference"); + if(preg_match("/d/",$acl)){ + $this->dn= $this->conferences[$s_entry]['dn']; + + /* Check locking */ + if (($conf= get_lock($this->dn)) != ""){ + $_SESSION['dn']= $this->dn; + return(gen_locked_message($conf, $this->dn)); + } else { + add_lock ($this->dn, $this->ui->dn); + $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), $this->dn)); + $smarty->assign("multiple", false); + $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE)); + return ($display); + } + } + } + + + /*************** + Delete confirmed + ***************/ + + /* If department deletion is accepted ... + * Finally delete department + */ + if (isset($_POST['delete_department_confirm'])){ + $acl = $this->ui->get_permissions($this->dn,"gofonconference/conference"); + if(preg_match("/d/",$acl)){ + $this->remove_from_parent(); + } else { + print_red (_("You have no permission to remove this department.")); + } + } + + + /*************** + Edit + ***************/ + + /* Edit Entry if Posted action (s_action) == edit + * The entry which will be edited is defined in $s_entry + */ + if (($s_action=="edit") && (!isset($this->conftab->config))){ + + $this->dn= $this->conferences[$s_entry]['dn']; + + if (($conf= get_lock($this->dn)) != ""){ + return(gen_locked_message ($conf, $this->dn)); + } + + /* Lock the current entry, so everyone will get the above dialog */ + add_lock ($this->dn, $this->ui->dn); + + /* Register conftab to trigger edit dialog */ + $this->conftab= new conferencetabs($this->config,$this->config->data['TABS']['CONFERENCETABS'], $this->dn,"gofonconference"); + $this->conftab->set_acl_base($this->dn); + $_SESSION['objectinfo']= $this->dn; + } + + + /*************** + Create new + ***************/ + + /* Insert new entry*/ + if($s_action == "new" ){ + + $dummy_dn = "cn=dummy,ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->DivListConference->selectedBase; + $acl = $this->ui->get_permissions($dummy_dn,"gofonconference/conference"); + if(preg_match("/c/",$acl)){ + /* Set up the users ACL's for this 'dn' */ + $this->dn= "new"; + $this->conftab= new conferencetabs($this->config,$this->config->data['TABS']['CONFERENCETABS'], $this->dn,"gofonconference"); + $this->conftab->set_acl_base($dummy_dn); + unset($_SESSION['objectinfo']); + } + } + + + /*************** + Save entry + ***************/ + + /* Edit finished, check and save changes */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->conftab->config))){ + /* Check tabs, will feed message array */ + $this->conftab->last= $this->conftab->current; + $this->conftab->save_object(); + $message= $this->conftab->check(); + + if (count($message) == 0){ + if($this->conftab->save() == 1){ + gosa_log ("goFonConference object '".$this->dn."' saving failed."); + return; + } + gosa_log ("goFonConference object '".$this->dn."' has been saved"); + + if (!isset($_POST['edit_apply'])){ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + } + + del_lock ($this->conftab->dn);; + unset ($this->conftab); + $this->conftab= NULL; + unset ($_SESSION['objectinfo']); + } else { + show_errors($message); + } + } + + + /*************** + Display dialogs + ***************/ + + /* if edit or new, show dialog */ + if(($this->conftab) && (isset($this->conftab->config))){ + $display= $this->conftab->execute(); + + /* Don't show buttons if tab dialog requests this */ + if (!$this->conftab->by_object[$this->conftab->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + return ($display); + } + + + /*************** + display divlist + ***************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListConference->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Return rendered main page */ + /* Display dialog with system list */ + $this->DivListConference->parent = $this; + $this->DivListConference->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListConference->SubSearch){ + $this->DivListConference->AddDepartments($this->DivListConference->selectedBase,5,1); + } + $this->reload(); + $this->DivListConference->setEntries($this->conferences); + return($this->DivListConference->Draw()); + } + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array("ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->DivListConference->selectedBase)); + } + + + /* Reload entries for divlist. + * reload all conferences for the current base, with the given regex + */ + function reload() + { + $Base = "ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->DivListConference->selectedBase; + $SubSearch = $this->DivListConference->SubSearch; + $Regex = $this->DivListConference->Regex; + $Flags = GL_SIZELIMIT ; + $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=goFonConference))"; + $Attrs = array("cn","goFonConferenceOwner","goFonPIN","telephoneNumber"); + + if($SubSearch){ + $Flags |= GL_SUBSEARCH; + } + + $this->conferences= get_list($Filter, "gofonconference", $Base, $Attrs, $Flags); + } + + function remove_from_parent() + { + /* Ehm what are we doinf here ? */ + + $cfg = new conference($this->config, $this->dn); + $cfg->set_acl_category("gofonconference"); + $cfg->set_acl_base($this->dn); + + $cfg->remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->recursive_remove(); + + /* Optionally execute a command after we're done */ + $this->postremove(); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new conftab($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->conferences[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"conferencetabs","CONFERENCETABS","gofonconference"); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->conferences[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","conferencetabs","CONFERENCETABS","gofonconference"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","conferencetabs","CONFERENCETABS","gofonconference"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListConference->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + function save_object() + { + $this->DivListConference->save_object(); + } + + function remove_lock() + { + if (isset($this->dn)){ + del_lock ($this->dn); + } + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/conference/generic.tpl b/gosa-core/plugins/gofon/conference/generic.tpl new file mode 100644 index 000000000..63938a43c --- /dev/null +++ b/gosa-core/plugins/gofon/conference/generic.tpl @@ -0,0 +1,249 @@ + + + + + + + + + + + + + + + + + + + + +
+

+ {t}Properties{/t} +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + {$must} + +{render acl=$cnACL} + +{/render} +
+ + {$must} + +{render acl=$goFonConferenceOptionDACL} + +{/render} +
+
+
+ + {$must} + + +{render acl=$baseACL} + +{/render} + +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} + +
{$must} +{render acl=$goFonHomeServerACL} + +{/render} +
{t}Language{/t} + + +
+
+   + + + + + + + + + + + + + + +
+ + +{render acl=$descriptionACL} + +{/render} +
+ {t}Lifetime (in days){/t} + +{render acl=$goFonConferenceOptionLifetimeACL} + +{/render} +
+ {t}Phone number{/t} + {$must} + +{render acl=$telephoneNumberACL} + +{/render} +
+ +
+

 

+
+

+ {t}Options{/t} +

+
+ + + + + + + + + + + + + + + + + +
+{render acl=$goFonConferenceOptionPACL} + +{/render} + + {t}Preset PIN{/t} +
+   + + {t}PIN{/t} +{render acl=$goFonPINACL} + +{/render} +
+{render acl=$goFonConferenceOptionrACL} + +{/render} + {t}Record conference{/t} +
+   + + {t}Sound file format{/t}  +{render acl=$goFonConferenceOptionFormatACL} + +{/render} +
+ +
+   + + + + + + + + + + + + + + + +
+{render acl=$goFonConferenceOptionMACL} + +{/render} + {t}Play music on hold{/t} +
+{render acl=$goFonConferenceOptionsACL} + +{/render} + {t}Activate session menu{/t} +
+{render acl=$goFonConferenceOptioniACL} + +{/render} + {t}Announce users joining or leaving the conference{/t} +
+{render acl=$goFonConferenceOptioncACL} + +{/render} + {t}Count users{/t} +
+ +
+ + + + + + diff --git a/gosa-core/plugins/gofon/conference/headpage.tpl b/gosa-core/plugins/gofon/conference/headpage.tpl new file mode 100644 index 000000000..5b5a95a89 --- /dev/null +++ b/gosa-core/plugins/gofon/conference/headpage.tpl @@ -0,0 +1,45 @@ + + + + + +
+
+

+ {t}List of conference rooms{/t} {$hint} +

+
+
+ {$conferencehead} +
+
+
+ {$conferences} + +
+
+
+

[i]{t}Information{/t}

+
+
+

+ {t}This menu allows you to create, delete and edit selected phone conferences. Having a large number of phone conferences, you might prefer the range selectors on top of the conferences list.{/t} +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ +
+ {$apply} +
+ + +
+ + diff --git a/gosa-core/plugins/gofon/conference/main.inc b/gosa-core/plugins/gofon/conference/main.inc new file mode 100644 index 000000000..d75fc78d9 --- /dev/null +++ b/gosa-core/plugins/gofon/conference/main.inc @@ -0,0 +1,56 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('conference'); + } +} else { + /* Create usermanagement object on demand */ + if (!isset($_SESSION['conference']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['conference']= new phoneConferenceManagment($config, $ui); + } + $conference= $_SESSION['conference']; + $conference->save_object(); + $output= $conference->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header(get_template_path('images/conference.png'), _("Conference management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/conference.png'), _("Conference management")); + } + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('conference'); + } + + /* Show and save dialog */ + $conference->save_object(); + $display.= $output; + $_SESSION['conference']= $conference; +} + +?> diff --git a/gosa-core/plugins/gofon/conference/paste_generic.tpl b/gosa-core/plugins/gofon/conference/paste_generic.tpl new file mode 100644 index 000000000..fa72f3f24 --- /dev/null +++ b/gosa-core/plugins/gofon/conference/paste_generic.tpl @@ -0,0 +1,23 @@ + + + + + + + + + +
+ + {$must} + + +
+ {t}Phone number{/t} + {$must} + + +
+ diff --git a/gosa-core/plugins/gofon/conference/remove.tpl b/gosa-core/plugins/gofon/conference/remove.tpl new file mode 100644 index 000000000..970abd4be --- /dev/null +++ b/gosa-core/plugins/gofon/conference/remove.tpl @@ -0,0 +1,24 @@ +
+  {t}Warning{/t} +
+ {$info} +

+ {t}This includes 'all' accounts, systems, etc. in this subtree. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+{if $multiple} + +   + +{else} + +   + +{/if} +

+ diff --git a/gosa-core/plugins/gofon/conference/tabs_conference.inc b/gosa-core/plugins/gofon/conference/tabs_conference.inc new file mode 100644 index 000000000..5b58065ee --- /dev/null +++ b/gosa-core/plugins/gofon/conference/tabs_conference.inc @@ -0,0 +1,41 @@ +base= $this->by_object['conference']->base; + + /* Add references/acls/snapshots */ + $this->addSpecialTabs(); + } + + function check($ignore_account= FALSE) + { + return (tabs::check(TRUE)); + } + + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['conference']; + $new_dn= 'cn='.$baseobject->cn.',ou=conferences,ou=asterisk,ou=configs,ou=systems,'.$baseobject->base; + + if(strtolower($this->dn)==strtolower($new_dn)){ + $this->dn=$new_dn; + } + + if($this->dn != $new_dn){ + $baseobject->recursive_move($this->dn, $new_dn); + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> diff --git a/gosa-core/plugins/gofon/fonreports/class_fonreport.inc b/gosa-core/plugins/gofon/fonreports/class_fonreport.inc new file mode 100644 index 000000000..a63a78f3e --- /dev/null +++ b/gosa-core/plugins/gofon/fonreports/class_fonreport.inc @@ -0,0 +1,415 @@ +config = $config; + $this->ui = $ui; + $this->search_base= get_base_from_people($ui->dn); + + $this->month = date("m"); + $this->year = date("Y"); + + /* Use filter settings if we have already searched */ + if (!is_global("fonfilter")){ + $fonfilter = array(); + foreach($this->attributes_SO as $name){ + $fonfilter[$name]=$this->$name; + } + register_global("fonfilter", $fonfilter); + }else{ + $fonfilter = get_global("fonfilter"); + foreach($this->attributes_SO as $name){ + $this->$name = $fonfilter[$name]; + } + } + } + + + /* Save ui interactions and store results in session, + to remember settings */ + function save_object() + { + $fonfilter= get_global("fonfilter"); + if(isset($_POST['EntryPerPage'])){ + $this->range = $_POST['EntryPerPage']; + } + if (isset($_GET['start'])){ + $this->start= (int)$_GET['start']; + } + foreach( array("year", "month", "search_for", "search_base") as $type){ + if (isset($_POST[$type])){ + $this->$type= $_POST[$type]; + } + } + + /* Adapt sorting */ + if (isset($_GET['sort'])){ + if ($this->sort == (int)$_GET['sort']){ + if ($this->sort_direction == "down"){ + $this->sort_direction= "up"; + } else { + $this->sort_direction= "down"; + } + } + $this->sort= (int)$_GET['sort']; + if ($this->sort < 0 || $this->sort > 6){ + $this->sort= 0; + } + } + + /* remove unwanted tags */ + $this->search_for = stripslashes(preg_replace("/[^0-9a-z\*\+ \-]/i","",$this->search_for)); + + foreach($this->attributes_SO as $name){ + $fonfilter[$name] = $this->$name; + } + register_global("fonfilter", $fonfilter); + } + + + /* Search & display results */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* GVet template engine */ + $smarty= get_smarty(); + + /* Log view */ + if(!$this->view_logged){ + $this->view_logged = TRUE; + new log("view","gofon/".get_class($this),$this->dn); + } + + /***************** + Variable Init + *****************/ + + $fields_str = ""; + + $months= array(); + for($i = 1 ; $i <= 12 ; $i ++ ){ + $months[$i] = _(date("F",gmmktime(0,0,0,$i))); + } + + /* Prepare template */ + $current= date("Y"); + $years= array(); + for ($y= $current - 5; $y<=$current; $y++){ + $years[$y]= $y; + } + + /***************** + Smarty + *****************/ + $bases = array(); + $cat_bases = $this->ui->get_module_departments("gofon"); + foreach($this->config->idepartments as $dn => $name){ + if(in_array_ics($dn,$cat_bases)){ + $bases[$dn] = $name; + } + } + + if(!isset($bases[$this->search_base])){ + $this->search_base = key($bases); + } + + $smarty->assign("plug", "?plug=".validate($_GET['plug'])); + $smarty->assign("launchimage", get_template_path('images/launch.png')); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("search_for", $this->search_for); + $smarty->assign("bases", $bases); + $smarty->assign("base_select", $this->search_base); + $smarty->assign("months", $months); + $smarty->assign("month_select", $this->month); + $smarty->assign("years", $years); + $smarty->assign("year_select", $this->year); + $smarty->assign("search_result", ""); + + + /***************** + Check Database , Table , Connection + *****************/ + + /* Connecting, selecting database */ + if (!isset($this->config->data['SERVERS']['FON'][0])){ + print_red(_("Can't connect to phone database, no reports can be shown!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + }elseif(!is_callable("mysql_connect")){ + print_red(_("There is no mysql extension available, please check your php setup.")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + }else{ + + $cfg= $this->config->data['SERVERS']['FON'][0]; + $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); + if ($link === FALSE){ + print_red(_("Can't connect to phone database, no reports can be shown!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + if (! @mysql_select_db("gophone")){ + print_red(_("Can't select phone database for report generation!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + } + + + /***************** + Get Query String && Search + *****************/ + + $query = $this->CreateQuerySyntax(); + $cfg = $this->config->data['SERVERS']['FON'][0]; + $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); + + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + + $result = @mysql_query($query); + if ($result === false){ + print_red(_("Query for phone database failed!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + /***************** + Fetch results + *****************/ + + $report_list= array(); + + /* Restricted attributes will not be displayed, this will be displayed instead */ + $no_acl = ""._("Insufficient permissions").""; + + $no_acl = " "; + + while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { + + foreach($line as $attr => $value){ + + if($attr == "duration") continue; + + $acl = $this->ui->get_permissions($this->search_base,"gofon/fonreport",$attr); + if(!preg_match("/r/",$acl)){ + $line[$attr] = $no_acl; + } + } + + if($this->ui->get_permissions($this->search_base,"gofon/fonreport","calldate")){ + $hour= substr($line["calldate"], 11, 2); + $minute=substr($line["calldate"], 14, 2); + $format= _("Y-M-D"); + $date= preg_replace("/Y/", substr($line["calldate"], 0, 4), $format); + $date= preg_replace("/M/", substr($line["calldate"], 5, 2), $date); + $date= preg_replace("/D/", substr($line["calldate"], 8, 2), $date); + $date_str = $date." ".$hour.":".$minute; + }else{ + $date_str = $no_acl; + } + + $append_str = ""; + $append_str .= "".$date_str.""; + + foreach(array("src","dst","channel","lastapp","disposition") as $atr){ + if(isset($line[$atr])){ + $append_str .= "".$line[$atr].""; + } + } + + if($this->ui->get_permissions($this->search_base,"gofon/fonreport","duration")){ + $append_str .= "".$this->gen_duration($line["duration"]).""; + }else{ + $append_str .= "".$no_acl.""; + } + $report_list[] = $append_str; + } + + $this->report_list= $report_list; + @mysql_close($link); + + + /***************** + Create list of results + *****************/ + + /* Generate output */ + $mod = 0; + $output = ""; + if(count($this->report_list) < $this->start){ + $this->start = 0; + } + foreach($this->report_list as $val){ + if ($mod < $this->start) { + $mod++; + continue; + } + if ($mod >= ($this->start + $this->range)){ + $mod++; + break; + } + if ( ($mod++) & 1){ + $col= "background-color: #ECECEC;"; + } else { + $col= "background-color: #F5F5F5;"; + } + $output.= "$val"; + } + + /***************** + Tell smarty what we have found + *****************/ + + if ($output != ""){ + $smarty->assign("search_result", $output); + $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start,$this->range,"EntryPerPage")); + } else { + $smarty->assign("search_result", ""); + } + + /* Show main page */ + for($i= 0; $i<7; $i++){ + $smarty->assign("mode$i", ""); + } + $smarty->assign("mode".$this->sort, "\"\"sort_direction.".png\" border=0 align=middle>"); + + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + + + /* Create duration string 12'11" */ + function gen_duration($seconds) + { + if ($seconds / 60 > 1){ + $minutes= (int)($seconds / 60); + $seconds= $seconds % 60; + return ("$minutes’$seconds”"); + } + return ("$seconds”"); + } + + + /* Create WHERE part for our mysql serach */ + function GetUidMatchingFilter() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->search_base); + $s = $this->search_for; + + $s = preg_replace("/\%/","",$s); + $s2 = preg_replace("/\*/","%",$s); + + $filter = "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))". + "(|(uid=$s)(l=$s)(homePhone=$s)(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)". + "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)(title=$s)))"; + + $attrs = array("uid"); + $res = get_list($filter,"users",$this->search_base,$attrs); + + $str = " AND ("; + $fields = array("dstchannel","channel"); + if(count($res)){ + foreach($res as $attrs){ + $uid = $attrs["uid"][0]; + foreach($fields as $name){ + $str .= $name." like '%".$uid."%' OR "; + } + } + } + $str .= " channel like '%".$s."%' OR + dstchannel like '%".$s."%' OR + dst like '".$s2."' OR + src like '".$s2."' OR + lastapp like '".$s2."')"; + return($str); + } + + + /* Create query string */ + function CreateQuerySyntax() + { + /* Get extended search filter which contain uids and so on */ + $uidstring = $this->GetUidMatchingFilter(); + + /* Create string with all fields seperated by ,*/ + $fields_str =""; + foreach($this->fields as $field){ + if($field == "calldate") { + continue; + } + $fields_str .= $field.", "; + } + $fields_str = preg_replace("/, $/","",$fields_str); + + /* Create Sort tag */ + if ($this->sort_direction == "down"){ + $desc= "DESC"; + } else { + $desc= "ASC"; + } + /* Create times */ + $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year)); + $end= date ("YmdHis", mktime(23,59,59,($this->month +1),0,$this->year)); + $query = "SELECT ".$fields_str.",calldate FROM cdr ". + "WHERE + calldate <= $end + AND + calldate >= $start + ". $uidstring." + ORDER BY ".$this->fields[$this->sort]." $desc;"; + return($query); + } + + + /* Return plugin informations for acl handling + #FIXME You can only read attributes within this report plugin */ + static function plInfo() + { + return (array( + "plShortName" => _("Phone reports"), + "plDescription" => _("Phone reports")." "._("All entries are readonly")."", + "plSelfModify" => TRUE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("fonreport"), + + "plProvidedAcls" => array( + "calldate" =>_("Date"), + "src" =>_("Source"), + "dst" =>_("Destination"), + "channel" =>_("Channel"), + "lastapp" =>_("Application called"), + "disposition" =>_("Disposition"), + "duration" =>_("Duration")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/fonreports/contents.tpl b/gosa-core/plugins/gofon/fonreports/contents.tpl new file mode 100644 index 000000000..d8cf0a47f --- /dev/null +++ b/gosa-core/plugins/gofon/fonreports/contents.tpl @@ -0,0 +1,59 @@ +
+

[F]{t}Filter{/t}

+
+
+

+  {t}Search for{/t} + + {t}in{/t} + + {t}during{/t} + + {t}in{/t} + +   + +

+
+ +
+ +{if $search_result } + + + + + + + + + + + {$search_result} +
{t}Date{/t} {$mode0}{t}Source{/t} {$mode1}{t}Destination{/t} {$mode2}{t}Channel{/t} {$mode3}{t}Application{/t} {$mode4}{t}Status{/t} {$mode5}{t}Duration{/t} {$mode6}
+ + + + + +
{$range_selector}
+ +

+   +

+{else} + {t}Search returned no results...{/t} +{/if} + + + diff --git a/gosa-core/plugins/gofon/fonreports/main.inc b/gosa-core/plugins/gofon/fonreports/main.inc new file mode 100644 index 000000000..5d1741db6 --- /dev/null +++ b/gosa-core/plugins/gofon/fonreports/main.inc @@ -0,0 +1,21 @@ +save_object(); + $display= $fonreport->execute (); + $display.= "\n"; + + /* Page header*/ + $display= print_header(get_template_path('images/phonereport.png'), _("Phone reports")).$display; + + /* Store changes in session */ + $_SESSION['fonreport']= $fonreport; +} +?> diff --git a/gosa-core/plugins/gofon/macro/class_divListMacros.inc b/gosa-core/plugins/gofon/macro/class_divListMacros.inc new file mode 100755 index 000000000..de822bb54 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/class_divListMacros.inc @@ -0,0 +1,298 @@ +parent = $parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of macros")); + $this->SetSummary(_("List of macros")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to add, edit and remove selected macros. You may want to use the range selector on top of the macro listbox, when working with a large number of macros.")); + + $this->EnableAplhabet (true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 100; + if($this->parent->snapshotEnabled()){ + $action_col_size += 20; + } + + /* Toggle all selected / deselected */ + $chk = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Macro name")." / "._("Department"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Visible"), "attach" => "style='width:50px;'")); + $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" )); + + /* Add Checkboxes / SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching macro names"),"*" , true); + } + + function GenHeader() + { + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ + $options= ""; + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + $first = ""; + $found = FALSE; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("gofonmacro"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + $acls = $ui->get_permissions($this->selectedBase,"gofonmacro/macro"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + $listhead .= _("Base")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acls)){ + $s.= "...|". + " "._("Macro")."|goFonMacro_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Remove")."|"."remove_multiple|\n"; + + /* Add multiple copy & cut icons */ + if(preg_match("/(c.*w|w.*c)/",$acls) && is_object( $this->parent->CopyPasteHandler)){ + $s.= "..|---|\n"; + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + + /* Add snapshot icons */ + if(preg_match("/(c.*w|w.*c)/",$acls)){ + $s .= "..|---|\n"; + $s .= $this->get_snapshot_header(TRUE); + } + + $this->SetDropDownHeaderMenu($s); + + + + + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + + $empty = ""; + $macroimg = ""._("Macro").""; + $visible = ""._("yes").""; + $invisible = ""._("no").""; + $editlink = "%s"; + + /* Dynamic action col, depending on snapshot icons */ + $action_col_size = 100; + if($this->parent->snapshotEnabled()){ + $action_col_size += 20; + } + + $ui = get_userinfo(); + + foreach($list as $key => $val){ + + $sacl = $ui->get_permissions($val['dn'],"gofonmacro/macro"); + + $action = ""; + if(!preg_match("/r/",$sacl)){ + continue; + } + + if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$sacl)){ + $action.= " "; + $action.= " "; + } + + $action.= ""; + + if(preg_match("/c/",$sacl) && preg_match("/w/",$sacl)){ + $action.= $this->GetSnapShotActions($val['dn']); + } + + if(preg_match("/d/",$sacl)){ + $action.= ""; + } + + if(isset($val['goFonMacroVisible']['0'])&&($val['goFonMacroVisible']['0'] == "1")){ + $pic1 = $visible; + }else{ + $pic1 = $invisible; + } + + $display= $val["displayName"][0]." (".$val["cn"][0].")"; + if(isset($val['description'][0])){ + + $desc = $val['description'][0]; + if(strlen($desc) > 55){ + $desc = substr($desc,0,52)."..."; + } + + $display .= " [".$desc."]"; + } + + /* Cutted objects should be displayed in light grey */ + if($this->parent->CopyPasteHandler){ + foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ + if($queue_data['dn'] == $val['dn']) { + $display = "".$display.""; + break; + } + } + } + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => sprintf($macroimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); + $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); + $field3 = array("string" => $pic1, "attach" => "style='width:50px;'"); + $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); + + $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); + } + + /* Create summary string for list footer */ + $num_deps=0; + if(!$this->SubSearch){ + $num_deps = count($this->Added_Departments); + } + $num_objs = count($list); + + $num_obj_str = _("Number of listed macros"); + $num_dep_str = _("Number of listed departments"); + + $str = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $this->set_List_Bottom_Info($str); + } + + function Save() + { + MultiSelectWindow :: Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow :: save_object(); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/macro/class_gofonMacro.inc b/gosa-core/plugins/gofon/macro/class_gofonMacro.inc new file mode 100755 index 000000000..1dbb4ee22 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/class_gofonMacro.inc @@ -0,0 +1,593 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /*! Macro attributes, */ + var $generate_error= ""; + + /*! The name of the Macro in the openldap drirectory */ + var $cn = ""; + + /*! Display error once */ + var $error_shown = false; + + /*! This ist the variable that contains the description of the macro*/ + var $description = ""; + + /*! The base of the macro, is used to save the macro in the correct directory tree */ + var $base = ""; + + /*! This is the name of the macro which the enduser will see, instead of the cn */ + var $displayName = ""; + + /*! Here is the macro content, the real macroscript */ + var $goFonMacroContent= ""; + + /*! To allow user to use this macro this var must be true, else false */ + var $goFonMacroVisible= 0; + + /*! attribute list for save action */ + var $attributes = array("cn","base", "description","displayName","goFonMacroContent","goFonMacroVisible"); + var $view_logged = FALSE; + var $orig_cn = ""; + /*! Objectclasses that this calls handles */ + var $objectclasses = array("top", "goFonMacro"); + + var $goFonHomeServers = array(); // Contains all available asterisk database server + + //! The Konstructor + /*! Konstructor, load class with attributes of the given dn*/ + function macro (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + /* This is always an account */ + $this->is_account= TRUE; + + /* Edit or new one ?*/ + if ($this->dn == "new"){ + if(isset($_SESSION['CurrentMainBase'])){ + $this->base = $_SESSION['CurrentMainBase']; + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->orig_cn=$this->cn; + $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,/", "", $this->dn); + } + + /* Check server configurations + * Load all server configuration in $this->goFonHomeServers if available + */ + $a_SETUP= array(); + if(array_key_exists('config',$_SESSION) && + array_key_exists('SERVERS',$_SESSION['config']->data) && + count($_SESSION['config']->data['SERVERS']['FON']) && + array_key_exists('FON',$_SESSION['config']->data['SERVERS'])) { + + /* Set available server */ + $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON']; + + /* Remove default entry, not necessary here */ + if(isset($this->goFonHomeServers[0])){ + unset($this->goFonHomeServers[0]); + } + } + } + + + /*! Execute this plugin */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","gofonmacro/".get_class($this),$this->dn); + } + + /* Variables */ + $vars = ""; + $tmp = array(); + $number = 0; + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* A new base was selected, check if it is a valid one */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $smarty->assign("bases", $this->get_allowed_bases()); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + if($this->acl_is_writeable("base")){ + $smarty->assign("baseSelect",true); + }else{ + $smarty->assign("baseSelect",false); + } + + + /* Assign all vars to Smarty */ + foreach($this->attributes as $ar){ + $smarty->assign($ar, $this->$ar); + } + /* Checkboxes */ + $smarty->assign("base_select", $this->base); + $smarty->assign("vars", $vars); + + if($this->goFonMacroVisible){ + $smarty->assign("goFonMacroVisibleChecked"," checked "); + }else{ + $smarty->assign("goFonMacroVisibleChecked",""); + } + + $smarty->assign("cnACL",$this->getacl("cn",$this->initially_was_account)); + $smarty->assign("cn",$this->cn); + + /* Ensure that macro content is displayed correctly encoded */ + $smarty->assign("goFonMacroContent",htmlentities(utf8_decode ($this->goFonMacroContent))); + + /* Show main page */ + return($smarty->fetch (get_template_path('generic.tpl', TRUE))); + } + + + /* This method check if all databases are reachable. + * Returns with error message or an empty string on success. + * + * - Is mysql extension available + * - Is every server reachable + * - Does the database exists/is accessible + */ + function check_database_accessibility() + { + /* Check if mysql extension is available */ + if(!is_callable("mysql_pconnect")){ + return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup.")); + } + + /******************** + * Check all home server + ********************/ + foreach($this->goFonHomeServers as $goFonHomeServer => $cfg_Current){ + $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(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), + $cfg_Current['SERVER'],$cfg_Current['LOGIN'])); + } + $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(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER'])); + } + } + } + + + /* Remove current macro from all asterisk server. + * First of all check if we have access to all databases. + * - Remove old entries + */ + function remove_from_database($save) + { + /* Check if all databases are reachable */ + $str = $this->check_database_accessibility(); + if($str){ + return($str); + } + + /* Create query string */ + $context = addslashes("macro-".$this->cn); + + /* Remove current macro from each server available */ + if($save){ + foreach($this->goFonHomeServers as $dn => $Server){ + $query = "DELETE FROM ".$Server['EXT_TABLE']." WHERE context='".$context."';"; + $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){ + new log("debug","gofonmacro/".get_class($this),"",array(),@mysql_error($r_current)); + return(sprintf(_("Removing macro from '%s' failed. Check GOsa log for mysql error."),$Server['SERVER'])); + } + @mysql_close($r_current); + } + } + } + + + /* Add current macro to all asterisk server. + * First of all check if we have access to all databases. + * - Remove old entries + * - Add new entries + */ + function add_to_database($save) + { + /* Check if all databases are reachable */ + $str = $this->check_database_accessibility(); + if($str){ + return($str); + } + + /* Remove old entries first. Else we got duplicated entries */ + $str = $this->remove_from_database($save); + if($str){ + return($str); + } + + /* Create query string */ + $context = "macro-".$this->cn; + + /************ + * Parse Macro content + ************/ + $sql = + "INSERT INTO %TABLENAME% ". + " (context,exten,priority,app,appdata) ". + " VALUES "; + + $a_contentLines = split("\n",$this->goFonMacroContent); + foreach($a_contentLines as $i_linenum => $s_linestr){ + + /* Remove the 'exten => ' string in front of the macro content line + * example line 'exten => s,2,GotoIf(${ARG3}?3:5)' + * Remove comments introduced by ; + * Skip empty lines + */ + $s_linestr = trim($s_linestr); + $s_linestr = preg_replace("/;.*$/","",$s_linestr) ; + $s_linestr = preg_replace ("/^.*=\> /","",$s_linestr); + + if(empty($s_linestr)){ + continue; + } + + /* A line that passes the check above should look like this + * s,1,SetLanguage(de) + * 3 parts seperated by , + * If there are more or less parts, abort. + * The preg_replace exclude parameters from split .. + */ + $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)); + } + /* 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 + * to each database. + */ + $exten = addslashes($tmp[0]); + $prio = addslashes($tmp[1]); + $app = addslashes(preg_replace("/\(.*\).*$/","",$tmp[2])); + $para = addslashes(preg_replace("/^.*\(/","",$tmp[2])); + $para = preg_replace("/\).*$/","",$para); + $sql.= " ('".$context."','".$exten."','".$prio."','".$app."','".$para."'),"; + } + + /* Remove last , from query string */ + $sql = preg_replace("/,$/","",$sql); + + /* Save current changes to the database */ + if($save){ + + /* Macro are spread to each asterisk server */ + foreach($this->goFonHomeServers as $dn => $cfg){ + $r_con = @mysql_pconnect($cfg['SERVER'],$cfg['LOGIN'],$cfg['PASSWORD']); + $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){ + new log("debug","gofonmacro/".get_class($this),"",array(),@mysql_error($r_con)); + return(sprintf(_("Insert of new macro failed for server '%s'."),$cfg['SERVER'])); + } + @mysql_close($r_con); + } + } + } + + + function save_object() + { + if (isset($_POST['gofonMacroGenericPosted'])){ + + $old_cn = $this->cn; + $old_visible = $this->goFonMacroVisible; + + /* Create a base backup and reset the + base directly after calling plugin::save_object(); + Base will be set seperatly a few lines below */ + $base_tmp = $this->base; + plugin::save_object(); + $this->base = $base_tmp; + + /* Save base, since this is no LDAP attribute */ + $tmp = $this->get_allowed_bases(); + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + + /* Restore old cn if we have insuficient acls to change cn ... */ + if(!$this->acl_is_writeable("cn",$this->initially_was_account)){ + $this->cn = $old_cn; + } + + /* check if we are allowed to toggle visibility */ + if($this->acl_is_writeable("goFonMacroVisible")) { + + /* Checkbox selected ? */ + if(isset($_POST['goFonMacroVisible'])) { + $this->goFonMacroVisible= 1 ; + }else { + if(isset($_POST['displayName'])){ + $this->goFonMacroVisible= 0 ; + } + } + }else{ + $this->goFonMacroVisible = $old_visible; + } + } + } + + + /*! Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(!count($this->goFonHomeServers)){ + $message[] = _("There must be at least one server with an asterisk database to save this phone macro."); + } + + /* Check if insert/replace is possible and all servers are available */ + $str = $this->add_to_database(false); + if($str){ + $message[] = $str; + } + + /* Check if cn is already used */ + if(($this->dn=="new")||($this->orig_cn!=$this->cn)){ + $ldap = $this->config->get_ldap_link(); + $ldap->search("(&(objectClass=goFonMacro)(cn=".$this->cn."))",array("cn")); + if($ldap->count()>0){ + $message[]=sprintf(_("The given cn '%s' already exists."),$this->cn); + } + } + + /* Check if display name is set */ + if(empty($this->displayName)){ + $message[] = _("You must specify the 'Display Name' in order to save this macro"); + } + /* CN is restricted to 20 chars */ + if(strlen("Makro-".$this->cn)>20 ){ + $message[]=_("The given cn is too long, to create a Makro entry, maximum 20 chars."); + } + + /* If this macro is still in use we should not change the visible for user flag to invisible */ + if(!$this->goFonMacroVisible){ + $ldap = $this->config->get_ldap_link(); + $res = $ldap->search("(&(objectClass=goFonAccount)(objectClass=gosaAccount)(goFonMacro=*))", array("goFonMacro")); + while ($val = $ldap->fetch()){ + if(strstr($val['goFonMacro'][0],$this->dn)){ + $message[] = _("This macro is still in use. It is necessary to mark this macro as visible for users."); + return($message); + } + } + } + + /* Macro content must be smaller than 100 lines */ + if(count(split("\n",$this->goFonMacroContent))>100){ + $message[] = _("Makro length must be lower than 100 lines"); + } + + /* Macro content must be smaller than 100 lines */ + if(empty($this->goFonMacroContent)){ + $message[] = _("You can't save an empty macro."); + } + return $message; + } + + + /*! Remove makro from all given databases + * and ldap too. + */ + function remove_from_parent() + { + $ldap= $this->config->get_ldap_link(); + + /* Skip remove if this macro is still in use */ + $res = $ldap->search("(&(objectClass=goFonAccount)(objectClass=gosaAccount)(goFonMacro=*))", array("goFonMacro")); + while ($val = $ldap->fetch()){ + if(strstr($val['goFonMacro'][0],$this->dn)){ + print_red(_("This macro is still in use. To delete this Macro ensure that nobody has selected it.")); + return false; + } + } + + /* Try to remove from database */ + if(count($this->goFonHomeServers)){ + $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.")); + 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)); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $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)); + } + } + + + /*! Save to LDAP */ + function save() + { + plugin::save(); + unset($this->attrs['base']); + + /* Try to add entries to databases */ + $str = $this->add_to_database(true); + if($str){ + print_red($str); + }else{ + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('dn')); + $a= $ldap->fetch(); + + if (count($a)){ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + $this->handle_post_events("modify"); + } else { + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $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)); + + /* Log last action */ + if($this->initially_was_account){ + new log("modify","gofonmacro/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","gofonmacro/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + } + } + + + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("cn" ,$this->cn); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Asterisk macro management"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("gofonmacro" => array("description" => _("GOfon macro"), + "objectClass" => "gofonMacro")), + + "plProvidedAcls" => array( + "cn" => _("Macro name"), + "base" => _("Base"), + "description" => _("Description"), + "displayName" => _("Display name"), + "goFonMacroContent" => _("Macro content and parameter"), + "goFonMacroVisible" => _("Visibility flag")) + )); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/macro/class_gofonMacroManagement.inc b/gosa-core/plugins/gofon/macro/class_gofonMacroManagement.inc new file mode 100755 index 000000000..f25f49521 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/class_gofonMacroManagement.inc @@ -0,0 +1,555 @@ +config= $config; + $this->ui= $ui; + + $this->DivListMacro = new divListMacro($this->config,$this); + + /* Copy & Paste enabled ?*/ + if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $_SESSION['LOCK_VARS_TO_USE'] = array("/^goFonMacro_/","/^act$/","/^id$/","/^item_selected/","/^remove_multiple_macros/"); + + /***************** + Variable initialisation + *****************/ + + $s_action = ""; // Contains the action to proceed + $s_entry = ""; // The value for s_action + $base_back = ""; // The Link for Backbutton + $smarty= get_smarty(); + + + /***************** + Check Posts + *****************/ + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/^goFonMacro_del/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/^goFonMacro_del_/i","",$key); + // Post for edit + }elseif(preg_match("/^goFonMacro_edit_/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/^goFonMacro_edit_/i","",$key); + // Post for new + }elseif(preg_match("/^goFonMacro_new/",$key)){ + $s_action="new"; + }elseif(preg_match("/^remove_multiple_macros/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + }elseif(preg_match("/^multiple_copy_objects/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_objects/",$key)){ + $s_action = "cut_multiple"; + } + } + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + $s_entry = preg_replace("/_.$/","",$s_entry); + + + /******************** + Copy & Paste Handling ... + ********************/ + + + /* handle C&P from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ + $s_action = "copy_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ + $s_action = "cut_multiple"; + } + if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ + $s_action = "editPaste"; + } + + /* Create options */ + if(isset($_POST['menu_action']) && $_POST['menu_action'] == "goFonMacro_new"){ + $s_action = "new"; + } + + /* handle remove from layers menu */ + if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ + $s_action = "del_multiple"; + } + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + + /***************** + Create a new Macro + *****************/ + + /* New macro? */ + if ($s_action=="new"){ + + /* By default we set 'dn' to 'new', all relevant plugins will + react on this. */ + $this->dn= "new"; + + /* Create new usertab object */ + $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn,"gofonmacro"); + $this->macrotabs->set_acl_base($this->DivListMacro->selectedBase); + } + + /***************** + Edit || Password canceled + *****************/ + + /* Cancel dialogs */ + if (isset($_POST['edit_cancel'])){ + del_lock ($this->macrotabs->dn); + unset ($this->macrotabs); + $this->macrotabs= NULL; + unset ($_SESSION['objectinfo']); + } + + + /***************** + Edit finised + *****************/ + + /* Finish mac edit is triggered by the tabulator dialog, so + the user wants to save edited data. Check and save at this + point. */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->macrotabs->config))){ + + /* Check tabs, will feed message array */ + $this->macrotabs->last= $this->macrotabs->current; + $this->macrotabs->save_object(); + $message= $this->macrotabs->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + /* Save data data to ldap */ + $this->macrotabs->save(); + + if (!isset($_POST['edit_apply'])){ + /* macro has been saved successfully, remove lock from + LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + + unset ($this->macrotabs); + $this->macrotabs= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /***************** + Edit macro + *****************/ + + /* User wants to edit data */ + if (($s_action=="edit") && (!isset($this->macrotabs->config))){ + + $dn = $this->macros[$s_entry]['dn']; + $acl = $this->ui->get_permissions($dn,"gofonmacro/macro"); + if(preg_match("/r/",$acl)){ + $this->dn = $dn; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so everyone will get the + above dialog */ + add_lock ($this->dn, $this->ui->dn); + /* Register macrotabs to trigger edit dialog */ + $this->macrotabs= new macrotabs($this->config, + $this->config->data['TABS']['MACROTABS'], $this->dn,"gofonmacro"); + $_SESSION['objectinfo']= $this->dn; + } + } + + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->macros[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* Lock the current entry, so nobody will edit it during deletion */ + $smarty->assign("intro", sprintf(_("You're about to delete the following user(s) %s"), @LDAP::fix($dns_names))); + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_macro_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $acl = $this->ui->get_permissions($dn,"gofonmacro/macro"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $dn,"gofonmacro"); + $this->macrotabs->delete (); + unset ($this->macrotabs); + $this->macrotabs= NULL; + + } else { + print_red (_("You are not allowed to delete this macro!")); + } + + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_macro_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /***************** + Remove macro + *****************/ + + /* Remove user was requested */ + if ($s_action=="del"){ + + /* Get 'dn' from posted 'uid' */ + $dn = $this->macros[$s_entry]['dn']; + $acl = $this->ui->get_permissions($dn,"gofonmacro/macro"); + + if(preg_match("/d/",$acl)){ + + $this->dn = $dn; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return (gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so nobody will edit it during deletion */ + add_lock ($this->dn, $this->ui->dn); + $smarty= get_smarty(); + $smarty->assign("intro", sprintf(_("You're about to delete the macro '%s'."), $this->dn)); + $smarty->assign("multiple", false); + return($smarty->fetch (get_template_path('remove.tpl', TRUE))); + } else { + + /* Obviously the user isn't allowed to delete. Show message and + clean session. */ + print_red (_("You are not allowed to delete this macro!")); + } + } + + + /***************** + Remove macro + *****************/ + + /* Confirmation for deletion has been passed. Macro should be deleted. */ + if (isset($_POST['delete_macro_confirm'])){ + + $acl = $this->ui->get_permissions($this->dn,"gofonmacro/macro"); + + if(preg_match("/r/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn,"gofonmacro"); + $this->macrotabs->delete (); + unset ($this->macrotabs); + $this->macrotabs= NULL; + } else { + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this macro!")); + new log("security","gofonmacro/".get_class($this),$this->dn,array(),"Tried to trick deletion."); + } + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + /***************** + Display open dialogs + *****************/ + + /* Show tab dialog if object is present */ + if (($this->macrotabs) && (isset($this->macrotabs->config))){ + $display= $this->macrotabs->execute(); + + /* Don't show buttons if tab dialog requests this */ + if (!$this->macrotabs->by_object[$this->macrotabs->current]->dialog){ + $display.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + return ($display); + } + + + /***************** + Display entry list + *****************/ + + /* Check if there is a snapshot dialog open */ + $base = $this->DivListMacro->selectedBase; + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ + return($str); + } + + /* Return rendered main page */ + /* Display dialog with system list */ + $this->DivListMacro->parent = $this; + $this->DivListMacro->execute(); + + /* Add departments if subsearch is disabled */ + if(!$this->DivListMacro->SubSearch){ + $this->DivListMacro->AddDepartments($this->DivListMacro->selectedBase,4,1); + } + $this->reload(); + $this->DivListMacro->setEntries($this->macros); + return($this->DivListMacro->Draw()); + } + + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->macros[$s_entry]['dn']; + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"macrotabs","MACROTABS","gofonmacro"); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->macros[$id]['dn']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","macrotabs","MACROTABS","gofonmacro"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","macrotabs","MACROTABS","gofonmacro"); + } + } + } + + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListMacro->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); + } + } + + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); + } + + + + /* Return departments, that will be included within snapshot detection */ + function get_used_snapshot_bases() + { + return(array("ou=macros,ou=asterisk,ou=configs,ou=systems,".$this->DivListMacro->selectedBase)); + } + + + function reload() + { + /* Set base for all searches */ + $base = $this->DivListMacro->selectedBase; + $SubSearch = $this->DivListMacro->SubSearch; + $Regex = $this->DivListMacro->Regex; + $Filter = "(&(cn=".$Regex.")(objectClass=goFonMacro))"; + $Flags = GL_SIZELIMIT; + $Attrs = array("cn","description","displayName","goFonMacroVisible"); + + /* Prepare for ls or search*/ + if($SubSearch){ + $Flags |= GL_SUBSEARCH; + }else{ + $base = "ou=macros,ou=asterisk,ou=configs,ou=systems,".$base; + } + + /* Generate macro list */ + $res= get_list($Filter, "gofonmacro", $base, $Attrs, $Flags); + + $tmp=array(); + foreach($res as $tkey => $val ){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + ksort($tmp); + $this->macros=array(); + foreach($tmp as $val){ + $this->macros[]=$val; + } + + reset ($this->macros); + } + + + /* Save data to object */ + function save_object() + { + $this->DivListMacro->save_object(); + } + + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + function adapt_from_template($dn) { } + function check() { } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/macro/class_gofonMacroParameters.inc b/gosa-core/plugins/gofon/macro/class_gofonMacroParameters.inc new file mode 100755 index 000000000..5a08d3e22 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/class_gofonMacroParameters.inc @@ -0,0 +1,414 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Parameter Count*/ + var $para_count = 0 ; + /*! macro base */ + var $base= ""; + + /*! This array contains all Parameter defined for the macro*/ + var $goFonMacroParameter =array(); + + /*! This are the available types for a macro */ + var $type_shortcut= array("string" => array("selected", "", ""), + "combo" => array("", "selected", ""), + "bool" => array("", "", "selected")); + + /*! attribute list for save action */ + var $attributes= array("base","goFonMacroParameter"); + + /*! Objectclasses needed by the class*/ + var $objectclasses= array("top", "goFonMacro"); + var $ui; + + //! The konstructor of macroParameter + /*! The konstructor of macroParameter... + - reads goFonMacroParameter and parses them to an array + - Set attributes from openldap (edit) + - Set attributes from default (new) + */ + function macroParameter (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + $tmp = array(); // temporary Var + $tmp2 = array(); // temporary Var ... + $tmp3 = ""; + $ldap= $config->get_ldap_link(); + + $this->dn = $dn; + + /* This is always an account */ + $this->is_account= TRUE; + + /* Edit or new one ?*/ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } else { + $this->base= dn2base($this->dn); + } + + /* initialising macro parameter */ + if(isset($this->attrs['goFonMacroParameter']) && + isset($this->attrs['goFonMacroParameter']['count'])){ + unset($this->attrs['goFonMacroParameter']['count']); + } + + /* Set Parameters, or a new array if ther are no parameters */ + if(isset($this->attrs['goFonMacroParameter'])){ + $this->goFonMacroParameter = $this->attrs['goFonMacroParameter']; + }else{ + $this->goFonMacroParameter =array(); + } + + /* Create an array for parameters if not given yet */ + if(!is_array($this->goFonMacroParameter)){ + $tmp3 = $this->goFonMacroParameter; + $this->goFonMacroParameter =array(); + if(!empty($tmp3)) { + $this->goFonMacroParameter[] = $tmp3; + } + } + + /* Load parametersettings*/ + foreach($this->goFonMacroParameter as $para){ + $tmp = split("!",$para); + $num = $tmp[0]; + $tmp2[$num]['name'] = base64_decode($tmp[1]); + $tmp2[$num]['type'] = $tmp[2]; + $tmp2[$num]['default'] = $tmp[3]; + $tmp2[$num]['var'] = "var".$num; + } + + + /* Assign this array */ + $this->goFonMacroParameter = $tmp2; + + $this->para_count = count ($tmp2); + + $this->ui= get_userinfo(); + } + + //! Perform Parameter check + /*! + Compares the given parameters (goFonMacroParameters) with the parameters defined in goFonContent\n + -> Decide which attrs are new and which are unused\n + -> Sort result array (containing both parameters 'goFonMacroParameters/goFonContent' and new / unused info)\n + \param $content The given goFonContent for this macro\n + \param $goFonMacroParameter Array with the already given parameters \n + */ + function check_paras($content,$goFonMacroParameter) + { + /* Check contents for parameters */ + preg_match_all("/[$]\{ARG[0-9]*\}/",$content,$res,PREG_OFFSET_CAPTURE); + + $new = array(); + + /* Detect parameters with positions */ + foreach($res[0] as $val){ + $num = preg_replace("/[^0-9]/","",$val[0]); + $new[$num]['val'] = $val[0]; + $new[$num]['num'] = $num; + } + + /* Compare content parameter and macro parameter */ + foreach($goFonMacroParameter as $gokey => $goval){ + foreach($new as $nkey => $nval){ + if($gokey == $nval['num']){ + /* sign this as OK */ + $goFonMacroParameter[$gokey]['check']= true; + } + } + } + + /* Now check if there is new parameter in the content, which is not assigned yet */ + foreach($new as $key => $val){ + /* Assign std values */ + $goFonMacroParameter[$key]['var']="var".$key; + $goFonMacroParameter[$key]['check']= true; + + /* If this is a new Parameter, name it ${ARG#} by default*/ + if((!isset($goFonMacroParameter[$key]['name']))||(empty($goFonMacroParameter[$key]['name']))){ + $goFonMacroParameter[$key]['name']="\${ARG".$key."}"; + } + } + + foreach($goFonMacroParameter as $key => $val){ + /* All attributes with check == false, are unneeded so mark them with ['check']= false */ + if(!isset($goFonMacroParameter[$key]['check'])){ + $goFonMacroParameter[$key]['check']= false; + } + /* Ah no default given assign ="" to prevent unsigned index */ + if(!isset($goFonMacroParameter[$key]['default'])){ + $goFonMacroParameter[$key]['default'] = ""; + } + } + + /* Sort output for better reading */ + asort($goFonMacroParameter); + return($goFonMacroParameter); + + } + + //! Execute this Plugin + /*! + Perform Parameter check \n + Draw paramter table\n + Show tpl \n + */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Variables */ + $vars = ""; + $tmp = array(); + $number = 0; + + /* Get acls for this tab, + there is only one attribute to write, + so we use the acls from gofon/marco */ + $ACLs = $this->ui->get_permissions($this->dn,"gofonmacro/macro","goFonMarcoContent"); + + /* get current content */ + $content = $_SESSION['macroManagment']->macrotabs->by_object['macro']->goFonMacroContent; + + if(strstr($content,"ARG")){ + $vorpos = strpos($content,"ARG"); + $rest = substr($content,$vorpos, strlen($content)); + } + + /* Do we represent a valid group? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This 'dn' is no phone macro.").""; + return ($display); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + + /* Add an empty Parameter */ + if(isset($_POST['addvar']) && preg_match("/w/",$ACLs)){ + if(!is_array($this->goFonMacroParameter)){ + $vars = $this->goFonMacroParameter; + $this->goFonMacroParameter = array(); + $this->goFonMacroParameter[]= $vars; + } + $number= count($this->goFonMacroParameter); + $number++; + $this->goFonMacroParameter[]=array("var"=>"var","name"=>"new","type"=>"string","default"=>"test"); + } + + /*generate Table which shows als parameters */ + $FonParas = $this->check_paras($content,$this->goFonMacroParameter); + + /* Sort by Parameterid, and keep keys */ + ksort($FonParas); + + + + if(!preg_match("/r/",$ACLs)){ + $smarty->assign("readable",false); + }else{ + $smarty->assign("readable",true); + foreach($FonParas as $key=>$para) { + + /* Select correct item of combobox */ + if(isset($para['type'])){ + list($sel1, $sel2, $sel3)= $this->type_shortcut[$para['type']]; + }else{ + list($sel1, $sel2, $sel3)= array("", "", ""); + } + + /* Disable all input fields if we are not allowed to change the parameters */ + $disabled = ""; + if(!preg_match("/w/",$ACLs)){ + $key = ""; + $disabled = " disabled "; + } + + /* Assemble output table */ + $vars .=" + + + ARG".$key." + + + + + + +  "; + if($para['check']==false) { + $vars.=""; + } + + $vars.=" "; + } + } + + /* Checkboxes */ + $smarty->assign("base_select", $this->base); + $smarty->assign("vars", $vars); + + /* Show main page */ + return($smarty->fetch (get_template_path('parameter.tpl', TRUE))); + } + + //! Unused here + /*! + Unused here because goFonMacro will remove this Macro\n + */ + function remove_from_parent() + { + } + + //! Save our data + /*! + Save POST data to object \n + This gives us the possibility to leave a tab, without losing our typed informations\n + \n + Read the POST fields for the parameters and saves their info the the class\n + */ + function save_object() + { + if (isset($_POST['phoneparameters'])){ + plugin::save_object(); + } + /* read out post data, and assign it to the parameters */ + /* And or delete */ + foreach($_POST as $name=>$value){ + + /* Test if there is a variable begining with "del" */ + if(preg_match("/del/",$name)){ + + /* Extract entry id to delete */ + $nr = str_replace("del","",$name) ; + + /* unset entry */ + unset($this->goFonMacroParameter[$nr]); + + }elseif(preg_match("/number/",$name)){ + + /* Set Post vars */ + $key = $_POST[$name]; + + $this->goFonMacroParameter[$key]['var'] = $_POST["var".$key]; + $this->goFonMacroParameter[$key]['name'] = $_POST["varname".$key]; + $this->goFonMacroParameter[$key]['type'] = $_POST["vartype".$key]; + $this->goFonMacroParameter[$key]['default']= $_POST["default".$key]; + } + } + + } + + + //! Checks given values + /*! + Check values\n + If a user enters an invalid value, then this function will output an error msg\n + (In better words :prepare the errormessages that will be put out )\n + */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + foreach($this->goFonMacroParameter as $key=>$val){ + if((strstr($val['default'],"!"))||(strstr($val['default'],"#"))) { + $message[] = sprintf(_("The parameter %s contains invalid char. '!,#' is used as delimiter"),$val['name']); + } + switch($val['type']){ + case 'bool' : $possible = array("","0","1"); + if(!in_array($val['default'],$possible)) { + $message[] = sprintf(_("The parameter %s has incorrect value for type bool."),$val['name']); + };break; + case 'string' : + case 'combo' : + default : ; + + } + } + return $message; + } + + //! Save changes to openldap + /*! + Save to LDAP + This function saves given attributes to the ldap + */ + function save() + { + /* Post checks */ + + plugin::save(); + + $this->attrs['goFonMacroParameter']=array(); + + foreach($this->goFonMacroParameter as $key=>$fonpara){ + $this->attrs['goFonMacroParameter'][]=$key."!".base64_encode($fonpara['name'])."!".$fonpara['type']."!".$fonpara['default']; + } + + if($this->para_count != count($this->attrs['goFonMacroParameter'])){ + print_red(_("Parameter count of the macro changed, you must update each user which are using this macro '%s'."),$this->dn); + } + + unset($this->attrs['base']); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('dn')); + $a= $ldap->fetch(); + + if (count($a)){ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + $this->handle_post_events("modify"); + } else { + if(count($this->attrs['goFonMacroParameter']==0)){ + unset($this->attrs['goFonMacroParameter']); + } + $ldap->cd($this->dn); + $ldap->create_missing_trees( $this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + $this->handle_post_events("add"); + } + show_ldap_error($ldap->get_error(), sprintf(_("Removing of goFonMacro/generic account with dn '%s' failed."),$this->dn)); + } + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $source_o = new macroParameter($this->config,$source['dn']); + $this->goFonMacroParameter = $source_o-> goFonMacroParameter; + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/macro/generic.tpl b/gosa-core/plugins/gofon/macro/generic.tpl new file mode 100755 index 000000000..7bedc5219 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/generic.tpl @@ -0,0 +1,83 @@ + + + + + + +
+ + + + + + + + + + + + + + + + +
{$must} +{render acl=$cnACL} + +{/render} +
{$must} +{render acl=$displayNameACL} + +{/render} +
+
{$must} + {render acl=$baseACL} + + {/render} + + {render acl=$baseACL disable_picture='images/folder_gray.png'} + + {/render} + +
+
+   + + + + + + + + + +
+{render acl=$descriptionACL} + +{/render} +
+{render acl=$goFonMacroVisibleACL} + {t}Visible for user{/t} +{/render} +
+
+

 

+
+{t}Macro text{/t} +
+{render acl=$goFonMacroContentACL} + +{/render} + + + + + diff --git a/gosa-core/plugins/gofon/macro/headpage.tpl b/gosa-core/plugins/gofon/macro/headpage.tpl new file mode 100755 index 000000000..79a6fa289 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/headpage.tpl @@ -0,0 +1,51 @@ + + + + + +
+
+

+ {t}List of macros{/t} {$hint} +

+
+
+ {$macroshead} +
+
+
+ {$macros} + +
+
+
+

[i]{t}Information{/t}

+
+
+

+ {t}This menu allows you to add, edit and remove selected macros. You may want to use the range selector on top of the macro listbox, when working with a large number of macros.{/t} +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + +
+ {t}Display macros matching{/t} + + +
+ {$apply} +
+
+ + diff --git a/gosa-core/plugins/gofon/macro/main.inc b/gosa-core/plugins/gofon/macro/main.inc new file mode 100755 index 000000000..f35e23b6f --- /dev/null +++ b/gosa-core/plugins/gofon/macro/main.inc @@ -0,0 +1,61 @@ +remove_lock(); + del_lock ($ui->dn); + sess_del ('macroManagment'); + } +} else { + + /* Create macroManagment object on demand */ + if (!isset($_SESSION['macroManagment']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['macroManagment']= new goFonMacro ($config, $_SESSION['ui']); + } + + /* Get object */ + $macroManagment= $_SESSION['macroManagment']; + $macroManagment->save_object(); + $output= $macroManagment->execute(); + + /* Page header*/ + if (isset($_SESSION['objectinfo'])){ + $display= print_header( get_template_path('images/macros.png'), + _("Phone macro management"), + "\"\" + ".@LDAP::fix($_SESSION['objectinfo'])); + } else { + $display= print_header(get_template_path('images/macros.png'), _("Phone macro management")); + } + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + sess_del ('macroManagment'); + } + + /* Show and save dialog */ + $display.= $output; + $_SESSION['macroManagment']= $macroManagment; +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/macro/parameter.tpl b/gosa-core/plugins/gofon/macro/parameter.tpl new file mode 100755 index 000000000..48e99cd82 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/parameter.tpl @@ -0,0 +1,28 @@ +{if $readable} + + + + + + + + + {$vars} +
{t}Argument{/t} + {t}Name{/t} + {t}type{/t} + {t}Default value{/t} + +   +
+{else} +

{t}You are not allowed to view the macro parameter settings{/t}

+{/if} + + + + diff --git a/gosa-core/plugins/gofon/macro/paste_generic.tpl b/gosa-core/plugins/gofon/macro/paste_generic.tpl new file mode 100644 index 000000000..0f5acf467 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/paste_generic.tpl @@ -0,0 +1,9 @@ + + + + + +
+ {$must} + +
diff --git a/gosa-core/plugins/gofon/macro/remove.tpl b/gosa-core/plugins/gofon/macro/remove.tpl new file mode 100755 index 000000000..4dbd248c5 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/remove.tpl @@ -0,0 +1,23 @@ +
+  {t}Warning{/t} +
+

+ {$intro} + {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-core/plugins/gofon/macro/tabs_macros.inc b/gosa-core/plugins/gofon/macro/tabs_macros.inc new file mode 100755 index 000000000..5c5bcf6c9 --- /dev/null +++ b/gosa-core/plugins/gofon/macro/tabs_macros.inc @@ -0,0 +1,40 @@ +addSpecialTabs(); + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['macro']; + + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $new_dn= "cn=".$baseobject->cn.",ou=macros,ou=asterisk,ou=configs,ou=systems,".$baseobject->base; + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['macro']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + tabs::save(); + } + +} + +?> diff --git a/gosa-core/plugins/gofon/phoneaccount/class_phoneAccount.inc b/gosa-core/plugins/gofon/phoneaccount/class_phoneAccount.inc new file mode 100644 index 000000000..6871854ed --- /dev/null +++ b/gosa-core/plugins/gofon/phoneaccount/class_phoneAccount.inc @@ -0,0 +1,1512 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $CopyPasteVars = array("phoneNumbers","macroarray","macrostillavailable"/*"phoneNumbers" -Reset- */, + "hardware_list","used_hardware"); + + var $attributes = array("goFonDeliveryMode", "goFonFormat","cn","goFonHomeServer", + "goFonHardware","goFonPIN","goFonVoicemailPIN","telephoneNumber", "goFonMacro","macro"); + var $objectclasses= array("goFonAccount"); + + var $uid; + + var $view_logged = FALSE; + + function phoneAccount (&$config, $dn= NULL, $parent= NULL) + { + plugin::plugin ($config, $dn, $parent); + + /* Assemble phone numbers */ + if (isset($this->attrs['telephoneNumber'])){ + for ($i= 0; $i<$this->attrs['telephoneNumber']['count']; $i++){ + $number= $this->attrs['telephoneNumber'][$i]; + $this->phoneNumbers[$number]= $number; + } + } + + /* Set up has_mailAccount */ + if (isset($this->attrs['objectClass'])){ + if (in_array("gosaMailAccount", $this->attrs['objectClass'])){ + $this->has_mailAccount= TRUE; + } + } + + /* Set uid */ + if((isset($this->parent->by_object['user']->uid))&&(!empty($this->parent->by_object['user']->uid))){ + $this->uid = $this->parent->by_object['user']->uid; + } + if((isset($this->parent->by_object['user']->cn))&&(!empty($this->parent->by_object['user']->cn))){ + $this->cn = $this->parent->by_object['user']->cn; + } + + /* Check server configurations + * Load all server configuration in $this->goFonHomeServers if available + * and first server as default if necessary. + * Check if connection is successfull for the selected server $this->goFonHomeServer + */ + + + /* Set available server */ + if(isset($_SESSION['config']->data['SERVERS']['FON'])){ + $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON']; + } + + $a_SETUP= array(); + if($this->is_account && + array_key_exists('config',$_SESSION) && + array_key_exists('SERVERS',$_SESSION['config']->data) && + array_key_exists('FON',$_SESSION['config']->data['SERVERS']) && + is_callable("mysql_connect") + ) { + + /* Servers defined? Watch here... */ + if (count($this->goFonHomeServers)){ + + /* Set default server */ + if(empty($this->goFonHomeServer) || $this->goFonHomeServer == "0"){ + $this->goFonHomeServer= $this->goFonHomeServers[0]['DN']; + } + + /* Remember inital home server, to be able to remove old entries */ + $this->init_HomeServer = $this->goFonHomeServer; + + /* Get config */ + if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){ + print_red(sprintf(_("The specified goFonHomeServer '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry ignoring old accounts."),$this->goFonHomeServer, $this->goFonHomeServers[0]['DN'])); + + $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; + $this->init_HomeServer = $this->goFonHomeServers[0]['DN']; + } + $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer]; + + $r_con = @mysql_pconnect($cur_cfg['SERVER'],$cur_cfg['LOGIN'],$cur_cfg['PASSWORD']); + if(!$r_con){ +# print_red( sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), +# $cur_cfg['SERVER'],$cur_cfg['LOGIN'])); + new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error()); + } + $db = @mysql_select_db($cur_cfg['DB'],$r_con); + if(!$db){ +# print_red(sprintf(_("Can't select database %s on %s."),$cur_cfg['DB'],$cur_cfg['SERVER'])); + new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error()); + } + + $first = false; + foreach($this->phoneNumbers as $key => $val){ + if(!$first){ + $first = $key; + } + } + } + } + + /* Get available phone hardware + * Search for all available phone hardware + */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); + while ($attrs= $ldap->fetch()){ + $cn= $attrs['cn'][0]; + if (isset($attrs['description'])){ + $description= " - ".$attrs['description'][0]; + } else { + $description= ""; + } + $this->hardware_list[$cn]= "$cn$description"; + } + + + /* Get available Macros + * Search for all Marcos that are visible and create + * an array with name and parameters + */ + $ldap->search("(&(objectClass=goFonMacro)(goFonMacroVisible=1))", array("*")); + + /* Add none for no macro*/ + $this->macros['none']=_("no macro"); + $this->macro ="none"; + + /* Fetch all Macros*/ + while ($attrs= $ldap->fetch()){ + + /* unset Count, we don't need that here */ + unset($attrs['displayName']['count']); + + /* Parse macro data, unset count for parameterarrays */ + if (isset($attrs['goFonMacroParameter']['count'])){ + unset($attrs['goFonMacroParameter']['count']); + } + + /* fill Selectfield variable with Macros */ + if(isset($attrs['displayName'][0])){ + $this->macros[$attrs['dn']] = $attrs['displayName'][0]." (".$attrs['cn'][0].")"; + }else{ + $this->macros[$attrs['dn']] = _("undefined"); + } + + /* Go through available parameters and parse all attributes, like parametername, type, default ...*/ + if((isset($attrs['goFonMacroParameter']))&&(is_array($attrs['goFonMacroParameter']))){ + + foreach($attrs['goFonMacroParameter'] as $pkey=>$pval){ + /* Split Data in readable values, by delimiter ! */ + $data = split("!",$attrs['goFonMacroParameter'][$pkey]); + + /* Set all attrs */ + $id = $data[0]; + $this->macroarray[$attrs['dn']][$id]['var'] ="var".$id; + $this->macroarray[$attrs['dn']][$id]['choosen']=$data[3]; + $this->macroarray[$attrs['dn']][$id]['id'] =$id; + $this->macroarray[$attrs['dn']][$id]['name'] =$data[1]; + $this->macroarray[$attrs['dn']][$id]['type'] =$data[2]; + $this->macroarray[$attrs['dn']][$id]['default']=$data[3]; + if($data[2] == "bool"){ + $this->macroarray[$attrs['dn']][$id]['choosen']=$data[3]; + } + }//foreach + }//is_array + }//while + + + /* Parse used Macro + * If we have a macro selected, parse it and set values + * in $this->macroarray[$this->macro]. + */ + $tmp = split("!",$this->goFonMacro); + if(is_array($tmp)){ + + /* First value is the macroname */ + $this->macro = $tmp[0]; + + /* Macroname saved, delete that index */ + unset($tmp[0]); + + /* Check if makro has been removed */ + if(!isset($this->macros[$this->macro])){ + $this->macrostillavailable = false; + }else{ + $this->macrostillavailable = true; + } + + /* for each parametervalues ( parameterID#value like 25#twentyfive) */ + foreach($tmp as $var){ + + /* Split this, so we have $varar[0] = parameterID $varar[1] = SelectedValue */ + $varar = split("#",$var); + + /* Only insert if the parameter still exists */ + if(isset($this->macroarray[$this->macro][$varar[0]])){ + /* Assign value */ + $this->macroarray[$this->macro][$varar[0]]['choosen']=$varar[1]; + } + } + } + + + /* Colorize phones + * Used phones will be colored in grey, + * so we must detect which phones are currently in use. + */ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware')); + while($attrs = $ldap->fetch()){ + $cn = $attrs['goFonHardware'][0]; + if(isset($this->hardware_list[$cn])){ + $this->used_hardware[$cn]= $cn; + } + } + $this->hardware_list["automatic"]= _("automatic"); + ksort($this->hardware_list); + $this->a_old_telenums = $this->phoneNumbers; + + /* Get voicemail PIN from MySQL DB + * Because every user can change his PIN directly from the phone + * without any update to the ldap + * This means, the PIN in the DB is up to date + */ + // Connect to DB server + if((is_callable("mysql_pconnect"))&&(isset($cur_cfg))&&(isset($cur_cfg['SERVER']))&&(isset($cur_cfg['LOGIN']))&&(isset($cur_cfg['PASSWORD']))){ + $r_con = @mysql_pconnect($cur_cfg['SERVER'],$cur_cfg['LOGIN'],$cur_cfg['PASSWORD']); + if($r_con){ + $r_db = @mysql_select_db($cur_cfg['DB'],$r_con); + + $query_tmp = "SELECT ".$cur_cfg['VOICE_TABLE'].".password FROM ".$cur_cfg['VOICE_TABLE'].", ". + $cur_cfg['SIP_TABLE']." WHERE customer_id = sip_users.mailbox AND name='".$this->uid."'"; + + $vp = mysql_fetch_row(mysql_query($query_tmp)); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query_tmp, "Database query"); + if((isset($vp[0]))&&(!empty($vp[0]))){ + $this->goFonPINVoice = $vp[0]; + } + } + } + $this->lastmacro=$this->macro; + + if(is_callable("mysql_close")&&(isset($r_con))&&($r_con)){ + @mysql_close($r_con) ; + } + } + + + /* This function generates the Database entries. + * The Parameter 'save' could be true or false. + * false - means only testing no database transactions. + * true - write database entries. + * + * 'sip_users','voice_mail' and 'extensions' table entries will be created. + * + * If the phone hardware is 'automatic' the table entries will only be removed + * and not added. + */ + function generate_mysql_entension_entries($save = false) + { + /* Check if there is at least one server available + * If not, return and tell the user that saving failed + */ + if(!count($this->goFonHomeServers)){ + if($save){ + print_red(_("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); + } + return(true); + } + + /* Check if Mysql extension is available */ + if(!is_callable("mysql_pconnect")){ + if($save) + print_red(_("Can't save any changes to asterisk database, there is no mysql extension available.")); + return(true); + } + + /********************** + * Attribute Initialisation + **********************/ + + $old_connection = false; + + // Get Configuration for Mysql database Server + $s_parameter = ""; // Contains paramter for selected Macro + $r_con = false; // DB connection + $r_db = false; // Selected DB + $r_res = false; // Result resource + $a_ldap_attrs = array(); // + + $s_ip = NULL; // Contains ip for Sip entry + $s_host = NULL; // Contains host for Sip entry + $s_qualify = "yes"; // Qualify entry + $s_pin = NULL; // Entry for secret + $s_type = NULL; // Entry for phone type (friend , peer ..) + + $sip_data_array = array(); // Contains complete sip entry, to generate SQL syntax + $i_old_key = false; // Contains index for first old phonenumber, to delete old entries corectly + $i_new_key = false; // Contains index for first new phonenumber, to generate new entries corectly + + $s_sip_values = ""; // Contains string with all values for given attributes in SQL syntax + $s_sip_keys = ""; // Contains all needed attributes to generate sip entry in DB + + $s_sip_key = ""; // Key for SIP entry index + $s_sip_val = ""; // Value for SIP entry index + + $b_first_deleted= false; // Only delete first entry, + $s_telenums = ""; // for each value variable + + $i_is_accounted = false; // Ensure that extension entry, for name to number is only once in table + + restore_error_handler(); + + /* Prepare some basic attributes */ + foreach($this->a_old_telenums as $tele){ + $oldnums[]= preg_replace("/[^0-9]/","",$tele); + } + foreach($this->phoneNumbers as $tele){ + $newnums[]= preg_replace("/[^0-9]/","",$tele); + } + + /* If deletion starts from userslist, cn uid are not set */ + if((isset($this->parent->by_object['user']->uid))&&(!empty($this->parent->by_object['user']->uid))){ + $this->uid = $this->parent->by_object['user']->uid; + } + if((isset($this->parent->by_object['user']->cn))&&(!empty($this->parent->by_object['user']->cn))){ + $this->cn = $this->parent->by_object['user']->cn; + } + /* Create voicemail entry + */ + if((!isset($this->cn))||(empty($this->cn))){ + $CNname= $this->uid; + }else{ + $CNname= $this->cn; + } + + if((isset($this->parent))&&(isset($this->parent->by_object['mailAccount']))&&($this->parent->by_object['mailAccount']->is_account==true)){ + $s_mail = $this->parent->by_object['mailAccount']->mail; + }else{ + $s_mail = ""; + } + /* Get phonehardware to setup sip entry */ + $ldap = $this->config->get_ldap_link(); + $r_res = $ldap->search("(&(objectClass=goFonHardware)(cn=".$this->goFonHardware."))", array('*')); + $a_ldap_attrs = $ldap->fetch(); + + /* Check selected phone hardware, is a default IP set? */ + if(((isset($a_ldap_attrs['goFonDefaultIP'][0]))&&($a_ldap_attrs['goFonDefaultIP'][0] != "dynamic"))){ + $s_ip = $a_ldap_attrs['goFonDefaultIP'][0]; + $s_host = $s_ip; + }else{ + $s_ip = NULL; + $s_host = "dynamic"; + } + + // Attribute GoFonQualify set ? + if(isset($a_ldap_attrs['goFonQualify'])){ + $s_qualify = $a_ldap_attrs['goFonQualify'][0]; + } + + // Attribute GoFonPIN set ? + if(isset($this->goFonPIN)){ + $s_pin = $this->goFonPIN; + } + + // Attribute GoFonType set ? + if(isset($a_ldap_attrs['goFonType'])){ + $s_type = $a_ldap_attrs['goFonType'][0]; + } + + if(isset($a_ldap_attrs['goFonDmtfMode'][0])){ + $sip_data_array['dtmfmode'] = $a_ldap_attrs['goFonDmtfMode'][0]; + }else{ + $sip_data_array['dtmfmode'] ="rfc2833"; + } + + /* Check if phone number is used */ + if($this->is_number_used()){ + $this->generate_error = $this->is_number_used(); + return false; + } + + + + /********************** + * Check Server Connection Information + **********************/ + + /* Create Mysql handle for the current goFonHomeServer, if possible + * Get configuration to old asterisk home server + */ + $a_New = $this->goFonHomeServers[$this->goFonHomeServer]; // DB Configuration + $new_connection = @mysql_pconnect($a_New['SERVER'],$a_New['LOGIN'],$a_New['PASSWORD']); + if(!$new_connection){ + $this->generate_error = sprintf( + _("The MySQL Server '%s' isn't reachable as user '%s'. Abort saving entries to keep the database consistent, check GOsa log for mysql error."), + $a_New['SERVER'],$a_New['LOGIN']); + new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error($new_connection)); + return false; + } + $new_database = @mysql_select_db($a_New['DB'],$new_connection); + if(!$new_database){ + $this->generate_error = sprintf( + _("Can't select database %s on %s. Abort saving entries to keep the database consistent, check GOsa log for mysql error."), + $a_New['DB'],$a_New['SERVER']); + new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error($new_connection)); + return false; + } + + /* If the home server has changed, we must remove entries from old + * server and add new entries in new server. + */ + if($this->init_HomeServer != $this->goFonHomeServer){ + + /* Get configuration to old asterisk home server */ + $a_Remove = $this->goFonHomeServers[$this->init_HomeServer]; // DB Configuration + + /* Create connection to the database that contains the old entry. + */ + $old_connection = @mysql_pconnect($a_Remove['SERVER'],$a_Remove['LOGIN'],$a_Remove['PASSWORD']); + if(!$old_connection){ + $this->generate_error = sprintf( + _("The old MySQL home server '%s' isn't reachable as user '%s'. Abort saving entries to keep the database consistent, check GOsa log for mysql error."), + $a_Remove['SERVER'],$a_Remove['LOGIN']); + new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error($old_connection)); + return false; + } + $old_database = @mysql_select_db($a_Remove['DB'],$old_connection); + if(!$old_database){ + $this->generate_error = sprintf( + _("Can't select database %s on %s. Abort saving entries to keep the database consistent, check GOsa log for mysql error."), + $a_Remove['DB'],$a_Remove['SERVER']); + new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error($old_connection)); + return false; + } + } + + /* Save means that we must save changes, not only test */ + if($save == true){ + + /********************** + * Remove entries from old home server + **********************/ + + /* Check if there is an old entry + * If there is an old entry, get callerid and remove voicemail and extensions + */ + if($old_connection){ + $query = "SELECT id,name,callerid FROM ".$a_Remove['SIP_TABLE']." WHERE name='".$this->uid."';"; + $rid = mysql_query($query,$old_connection); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + + /* Old entry found, remove it */ + $query_a = array(); + if(mysql_affected_rows($old_connection)){ + $result = mysql_fetch_assoc($rid); + $query_a[]= "DELETE FROM ".$a_Remove['SIP_TABLE']." WHERE name='".$this->uid."';"; + $query_a[]= "DELETE FROM ".$a_Remove['VOICE_TABLE']." WHERE customer_id='".$result['callerid']."';"; + $query_a[]= "DELETE FROM ".$a_Remove['EXT_TABLE']." WHERE exten='".$this->uid."';"; + foreach($oldnums as $s_telenums) { + $query_a[]= "DELETE FROM ".$a_Remove['EXT_TABLE']." WHERE exten='".$s_telenums."';"; + } + + foreach($query_a as $qry){ + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$qry, "Database query"); + if(!mysql_query($qry,$old_connection)){ + echo mysql_error($old_connection); + } + } + } + } + + /********************** + * Update / Insert sip_users entry + **********************/ + + /* Set the first given phone number as callerid */ + reset($newnums); + $i_new_key = key($newnums); + $sip_data_array['callerid'] =$newnums[$i_new_key]; + $sip_data_array['mailbox'] =$newnums[$i_new_key]; + + /* Check if there is already an entry in sip_users for this uid */ + $SQL_query_array = array(); + $query = "SELECT * FROM ".$a_New['SIP_TABLE']." WHERE name='".$this->uid."';\n"; + $rid = mysql_query($query,$new_connection); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + if(mysql_affected_rows($new_connection)){ + + /********************** + * Update sip_users entry + **********************/ + $result = mysql_fetch_assoc($rid); + $sip_data_array['host'] = $s_host; + $sip_data_array['qualify'] = $s_qualify; + $sip_data_array['secret'] = $this->goFonPIN; + $sip_data_array['type'] = $s_type ; + $sip_data_array['username'] = $this->uid; + $sip_data_array['ipaddr'] = $s_ip; + + /* Remove not changed attributes, to avoid updating table with same values */ + foreach($sip_data_array as $name => $value){ + if($result[$name] == $value){ + unset($sip_data_array[$name]); + } + } + /* Only update entry if there is something to uopdate */ + if(count($sip_data_array)){ + $query = "UPDATE ".$a_New['SIP_TABLE']." SET "; + foreach($sip_data_array as $key => $val){ + $query.= "".$key."='".$val."',"; + } + $query = preg_replace("/,$/","",$query); + $query.= " WHERE name='".$this->uid."';"; + $SQL_query_array[] = $query; + } + } else { + + /********************** + * Insert sip_users entry + **********************/ + //generate SIP entry + $sip_data_array['id'] = ""; + $sip_data_array['name'] = $this->uid; + $sip_data_array['accountcode'] = NULL; + $sip_data_array['amaflags'] = NULL; + $sip_data_array['callgroup'] = NULL; + $sip_data_array['canreinvite'] = "no"; + $sip_data_array['context'] = "default"; + $sip_data_array['defaultip'] = NULL; + $sip_data_array['fromuser'] = NULL; + $sip_data_array['fromdomain'] = NULL; + $sip_data_array['host'] = $s_host; + $sip_data_array['insecure'] = NULL; + $sip_data_array['language'] = NULL; + $sip_data_array['mailbox'] = $newnums[$i_new_key]; + $sip_data_array['md5secret'] = NULL; + $sip_data_array['nat'] = "no"; + $sip_data_array['permit'] = NULL; + $sip_data_array['deny'] = NULL; + $sip_data_array['mask'] = NULL; + $sip_data_array['pickupgroup'] = NULL; + $sip_data_array['port'] = NULL; + $sip_data_array['qualify'] = $s_qualify; + $sip_data_array['restrictcid'] = "n"; + $sip_data_array['rtptimeout'] = NULL; + $sip_data_array['rtpholdtimeout']=NULL; + $sip_data_array['secret'] = $this->goFonPIN; + $sip_data_array['type'] = $s_type ; + $sip_data_array['username'] = $this->uid; + $sip_data_array['disallow'] = NULL; + $sip_data_array['allow'] = NULL; + $sip_data_array['musiconhold'] = NULL; + $sip_data_array['regseconds'] = NULL; + $sip_data_array['ipaddr'] = $s_ip; + $sip_data_array['regexten'] = NULL; + $sip_data_array['cancallforward']=NULL; + + /* There is currently no entry for this user in the sip_users table. + * We should create one i + */ + foreach($sip_data_array as $s_sip_key=>$s_sip_val){ + if($s_sip_val === NULL) continue; + $s_sip_values.="'".$s_sip_val."',"; + $s_sip_keys .="`".$s_sip_key."`,"; + } + $s_sip_values = preg_replace("/,$/","",$s_sip_values); + $s_sip_keys = preg_replace("/,$/","",$s_sip_keys); + + /* Add sip entries to mysql queries */ + $SQL_query_array[] ="INSERT INTO ".$a_New['SIP_TABLE']." (".$s_sip_keys.") VALUES (".$s_sip_values.");"; + } + + + /********************** + * Update / Insert Voice mail entry + **********************/ + + $customer_id = $newnums[$i_new_key]; + + $voice_data_array = array( + "customer_id" => $customer_id, + "mailbox" => $customer_id, + "password" => $this->goFonVoicemailPIN, + "fullname" => $CNname, + "email" => $s_mail); + + /* Set pager number if available */ + if(isset($this->parent->by_object['user']->pager)){ + $voice_data_array['pager'] = $this->parent->by_object['user']->pager; + } + + /* Check if there is already an entry in sip_users for this uid */ + $query_tmp = "SELECT * FROM ".$a_New['VOICE_TABLE']." WHERE customer_id='".$customer_id."';\n"; + $rid = mysql_query($query_tmp,$new_connection); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query_tmp, "Database query"); + if(mysql_affected_rows($new_connection)){ + + /********************** + * Update Voice mail entry + **********************/ + $result = mysql_fetch_assoc($rid) ; + + foreach($voice_data_array as $name => $value){ + if($result[$name] == $value){ + unset($voice_data_array[$name]); + } + } + + /* Only update entry if there is something to uopdate */ + if(count($voice_data_array)){ + $query = "UPDATE ".$a_New['VOICE_TABLE']." SET "; + foreach($voice_data_array as $key => $val){ + $query.= "".$key."='".$val."',"; + } + $query = preg_replace("/,$/","",$query); + $query.= " WHERE customer_id='".$customer_id."';"; + $SQL_query_array[] = $query; + } + }else{ + + /********************** + * Insert Voice mail entry + **********************/ + $voice_data_array['context'] = "default"; + + /* There is currently no voice mail entry for this user. + * We should create one + */ + $s_voi_values = $s_voi_keys = ""; + foreach($voice_data_array as $s_voi_key=>$s_voi_val){ + if($s_voi_val === NULL) continue; + $s_voi_values.="'".$s_voi_val."',"; + $s_voi_keys .="`".$s_voi_key."`,"; + } + $s_voi_values = preg_replace("/,$/","",$s_voi_values); + $s_voi_keys = preg_replace("/,$/","",$s_voi_keys); + + /* Add sip entries to mysql queries */ + $SQL_query_array[] ="INSERT INTO ".$a_New['VOICE_TABLE']." (".$s_voi_keys.") VALUES (".$s_voi_values.");"; + } + + + /********************** + * Remove/Insert extension entries + **********************/ + + /* Remove old entries */ + $query = array(); + $query[]= "DELETE FROM ".$a_New['EXT_TABLE']." WHERE exten=\"".$this->uid."\";"; + foreach($oldnums as $s_telenums){ + $query[]= "DELETE FROM ".$a_New['EXT_TABLE']." WHERE exten=\"".$s_telenums."\";"; + } + foreach($newnums as $s_telenums){ + $query[]= "DELETE FROM ".$a_New['EXT_TABLE']." WHERE exten=\"".$s_telenums."\";"; + } + foreach($query as $qry){ + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$qry, "Database query"); + if(!mysql_query($qry,$new_connection)){ + echo mysql_error($new_connection); + } + } + + /********************** + * Insert extension entries + **********************/ + + // Get selected Macro Parameter and create parameter entry + if(isset($this->macroarray[$this->macro])){ + foreach($this->macroarray[$this->macro] as $key => $val ){ + $s_parameter .= $val['choosen']."|"; + } + $s_parameter = preg_replace("/\|$/","",$s_parameter); + } + + $i = 0; + $EXT = array(); + if(!is_numeric($this->uid)){ + $EXT[$i]['context'] = 'GOsa'; + $EXT[$i]['exten'] = $this->uid; + $EXT[$i]['priority']= 1; + $EXT[$i]['app'] = "Goto"; + $EXT[$i]['appdata'] = $newnums[$i_new_key]."|1"; + $i ++; + } + + // Entension entries Hint / Dial / Goto + foreach($newnums as $s_telenums){ + + /* Hint Entry */ + $EXT[$i]['context'] = 'GOsa'; + $EXT[$i]['exten'] = $s_telenums; + $EXT[$i]['priority']= "Hint"; + $EXT[$i]['app'] = 'SIP/'.$this->uid; + $i ++; + /* SetCID */ + //$EXT[$i]['context'] = 'GOsa'; + //$EXT[$i]['exten'] = $s_telenums; + //$EXT[$i]['priority']= 1; + //$EXT[$i]['app'] = "SetCIDName"; + //$EXT[$i]['appdata'] = $CNname; + //$i ++; + + // If no macro is selected use Dial + if($this->macro!="none"){ + $macroname = preg_replace("/,.*$/","",$this->macro); + $macroname = preg_replace("/^.*=/","",$macroname); + $s_app = "Macro";$macroname; + $s_par = $macroname."|".$s_parameter; + }else{ + $s_app = "Dial"; + $s_par = 'SIP/'.$this->uid."|20|r"; + } + + $EXT[$i]['context'] = 'GOsa'; + $EXT[$i]['exten'] = $s_telenums; + $EXT[$i]['priority']= 1; + $EXT[$i]['app'] = $s_app; + $EXT[$i]['appdata'] = $s_par; + $i ++; + } + + // Append all these Entries + foreach($EXT as $entr){ + $SQL_syn = "INSERT INTO ".$a_New['EXT_TABLE']." ("; + foreach($entr as $key2 => $val2){ + $SQL_syn.= "`".$key2."`,"; + } + $SQL_syn = preg_replace("/,$/","",$SQL_syn); + $SQL_syn .= ") VALUES ("; + foreach($entr as $key2 => $val2){ + $SQL_syn .= "'".$val2."',"; + } + $SQL_syn = preg_replace("/,$/","",$SQL_syn); + $SQL_syn .=");\n"; + + $SQL_query_array[] =$SQL_syn; + $SQL_syn =""; + } + + // Perform queries ... + if($this->goFonHardware != "automatic"){ + foreach($SQL_query_array as $query){ + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + if(!@mysql_query($query,$new_connection)){ + print_red(_("Error while performing query:")." ".mysql_error()); + return false; + } + } + } + } + @mysql_close($new_connection); + return true; + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + $display = ""; + $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + if(empty($this->macro)&&(!empty($this->goFonMacro))){ + + /* Go through already saved values, for a parameter */ + $tmp = split("!",$this->goFonMacro); + + /* it is possible that nothing has been saved yet */ + if(is_array($tmp)){ + + /* First value is the macroname */ + $this->macro = $tmp[0]; + + /* Macroname saved, delete that index */ + unset($tmp[0]); + + /* Check if macro has been removed */ + if(!isset($this->macroarray[$this->macro])){ + $this->macrostillavailable = false; + }else{ + $this->macrostillavailable = true; + } + + /* for each parametervalues ( parameterID#value like 25#twentyfive) */ + foreach($tmp as $var){ + + /* Split this, so we have $varar[0] = parameterID $varar[1] = SelectedValue */ + $varar = split("#",$var); + + /* Only insert if the parameter still exists */ + if(isset($this->macroarray[$this->macro][$varar[0]])){ + /* Assign value */ + $this->macroarray[$this->macro][$varar[0]]['choosen']=$varar[1]; + } + } + } + } + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This account has no phone extensions.").""; + $display.= back_to_main(); + return ($display); + } + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Select no macro if, state is empty, this is the case, if the selected macro is no longer available */ + if(empty($this->macro)){ + $this->macro ="none"; + } + + /* Prepare templating */ + $smarty= get_smarty(); + + /* tell user that the selected plugin is no longer available */ + if((!$this->macrostillavailable)&&($this->macro!="none")){ + print_red(_("The macro you selected, is no longer available for you, please choose another one.")); + } + + /* Assing macroselectbox values */ + $smarty->assign("macros",$this->macros); + $smarty->assign("macro", $this->macro); + + /* check if there is a FON server created */ + if(!count($this->goFonHomeServer)){ + print_red(_("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); + } + + /* Create html parameter table for selected macro parameters + * skip if no parameters given + */ + if(!isset($this->macroarray[$this->macro])){ + $macrotab=""; + }else{ + + $macrotab =""; + /* for every single parameter-> display textfile,combo, or true false switch*/ + + foreach($this->phoneNumbers as $phonenum){ + $tmp[] = $phonenum; + } + + if($this->macro != $this->lastmacro){ + /* Go through all params */ + foreach($this->macroarray[$this->macro] as $key => $paras){ + + $string = $paras['default']; + + $string=preg_replace("/%uid/i",$this->uid,$string); + + if(isset($this->cn)){ + $string=preg_replace("/%cn/i",$this->cn,$string); + } + + for($i = 0 ; $i < 10; $i++){ + if(isset($tmp[$i])){ + $string = preg_replace("/%telephoneNumber_".($i+1)."/i",$tmp[$i],$string); + } + } + if(isset($tmp[0])){ + $string = preg_replace("/%telephoneNumber/i",$tmp[0],$string); + } + $this->macroarray[$this->macro][$key]['choosen']=$string; + } + } + + foreach($this->macroarray[$this->macro] as $paras){ + + /* get al vars */ + $var = $paras['var']; + $name = $paras['name']; + $default = $paras['default']; + $type = $paras['type']; + $choosen = $paras['choosen'] ; + $str = $default; + + $dis = ""; + if(!$this->acl_is_writeable("goFonMacro",$SkipWrite)){ + $dis = " disabled "; + } + + /* in case of a combo box display a combobox with selected attr */ + $macrotab.= ""; + switch ($type){ + + case "combo": + $str= ""; + $macrotab.= ""; + + } + $macrotab.="
".base64_decode($name)."$str"; + break; + + case "bool": + if(!$choosen){ + $str="\n"; + }else{ + $str="\n"; + } + $macrotab.= "$str ".base64_decode($name).""; + break; + + case "string": + $str=""; + $macrotab.= "".base64_decode($name)."$str"; + break; + + } + $macrotab.= "
"; + }//is_array() + + /* Give smarty the table */ + $smarty->assign("macrotab",$macrotab); + + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This account has no phone extensions.").""; + $display.= back_to_main(); + return($display); + } + + $display= ""; + /* Show tab dialog headers */ + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove phone account"), + _("This account has phone features enabled. You can disable them by clicking below.")); + } else { + if(empty($this->uid)){ + $display= $this->show_enable_header(_("Create phone account"), + _("This account has phone features disabled. You can't enable them while no uid is set."),TRUE,TRUE); + }else{ + $display= $this->show_enable_header(_("Create phone account"), + _("This account has phone features disabled. You can enable them by clicking below.")); + } + return ($display); + } + } + + /* Add phone number */ + if (isset($_POST["add_phonenumber"]) && $_POST['phonenumber']){ + if (is_phone_nr($_POST['phonenumber'])){ + $number= $_POST["phonenumber"]; + $this->phoneNumbers[$number]= $number; + $this->is_modified= TRUE; + } else { + print_red(_("Please enter a valid phone number!")); + } + } + + /* Remove phone number */ + if (isset($_POST["delete_phonenumber"]) && isset($_POST["phonenumber_list"])){ + foreach ($_POST['phonenumber_list'] as $number){ + unset($this->phoneNumbers[$number]); + $this->is_modified= TRUE; + } + } + + /* Assign acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Transfer ACL's */ + foreach($this->attributes as $val){ + if(isset($this->$val)){ + $smarty->assign($val,$this->$val); + }else{ + $smarty->assign($val,""); + } + } + + /* Create home server array */ + $tmp = array(); + foreach($this->goFonHomeServers as $dn => $attrs){ + if(!is_numeric($dn)){ + $tmp[$dn] = $attrs['SERVER']; + } + } + $smarty->assign("goFonHomeServers",$tmp); + + /* Fill arrays */ + $smarty->assign ("goFonHardware", $this->goFonHardware); + if (!count($this->phoneNumbers)){ + $smarty->assign ("phoneNumbers", array()); + } else { + $smarty->assign ("phoneNumbers", $this->phoneNumbers); + } + + $dis = ""; + if(!$this->acl_is_writeable("goFonHardware",$SkipWrite)){ + $dis= " disabled "; + } + $hl= "\n"; + $smarty->assign ("hardware_list", $hl); + + /* Show main page */ + $this->lastmacro = $this->macro; + $display.= $smarty->fetch(get_template_path('generic.tpl', TRUE, dirname(__FILE__))); + return($display); + } + + + function save_object() + { + $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + if (isset($_POST["phoneTab"])){ + + plugin::save_object(); + + /* Save checkbox */ + $tmp = preg_replace("/[^a-z]/i","",$this->goFonDeliveryMode); + if($this->acl_is_writeable("goFonDeliveryMode",$SkipWrite)){ + if(isset($_POST['fon_to_mail']) && !preg_match("/M/",$this->goFonDeliveryMode)){ + $tmp .= "M"; + }elseif(!isset($_POST['fon_to_mail']) && preg_match("/M/",$this->goFonDeliveryMode)){ + $tmp = preg_replace ("/M/","",$tmp); + } + } + $this->goFonDeliveryMode= "[".$tmp."]"; + + + /* Every macro in the select box are available */ + if((isset($_POST['macro']))){ + $this->macrostillavailable=true; + } + + if(isset($_POST['macro']) && $_POST['macro'] != $this->macro){ + $this->is_modified =true; + } + + if(is_array($this->phoneNumbers)){ + foreach($this->phoneNumbers as $telenumms) { + $nummsinorder[]=$telenumms; + } + }else{ + $nummsinorder=array(""); + } + + + /* get all Postvars */ + if(isset($this->macroarray[$this->macro])){ + + if($this->acl_is_writeable("goFonMarco",$SkipWrite)){ + foreach($this->macroarray[$this->macro] as $key => $paras){ + + $backup = $this->macroarray[$this->macro][$key]; + + if(isset($_POST[$paras['var']])){ + $this->macroarray[$this->macro][$key]['choosen'] = $_POST[$paras['var']]; + } + + /* Checkboxes are special, they are not Posted if they are not selected, so the won't be changed with the above code + We need this code below to read and save checkboxes correct + */ + + if(isset($_POST['post_success'])){ + if($this->macroarray[$this->macro][$key]['type']=="bool"){ + if(isset($_POST[$this->macroarray[$this->macro][$key]['var']])) { + $this->macroarray[$this->macro][$key]['choosen']=$_POST[$paras['var']]; + }else{ + $this->macroarray[$this->macro][$key]['choosen']=false; + } + } + } + } + if(count(array_diff($this->macroarray[$this->macro][$key],$backup))){ + $this->modified = TRUE; + } + } + } + } + } + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(!count($this->goFonHomeServers)){ + $message[] = _("There must be at least one server with an asterisk database to create a phone account."); + } + + if(empty($this->goFonHomeServer)){ + $message[] = _("Please select a valid goFonHomeServer."); + } + + if((strlen($this->goFonVoicemailPIN)==0)||(strlen($this->goFonVoicemailPIN)>4)){ + $message[]=(_("Voicemail PIN must be between 1-4 characters.")); + }else{ + if(preg_match("/[^0-9]/",$this->goFonVoicemailPIN)){ + $message[]=(_("The specified Voicemail PIN contains invalid characters, only numeric values are allowed here.")); + } + } + + if(preg_match("/[^0-9a-z]/i",$this->goFonPIN)){ + $message[]=(_("The specified phone PIN contains invalid characters, only aphanumeric values are allowed here.")); + } + + if ($this->initially_was_account != $this->is_account || $this->is_modified){ + if(!$this->generate_mysql_entension_entries()){ + $message[] = $this->generate_error; + } + } + + /* We need at least one phone number */ + if (count($this->phoneNumbers) == 0){ + $message[]= sprintf(_("You need to specify at least one phone number!")); + } + + /* check for ! in any parameter setting*/ + if(isset($this->macroarray[$this->macro])){ + foreach($this->macroarray[$this->macro] as $val){ + if((strstr($val['choosen'],"!"))||(strstr($val['choosen'],"#"))){ + $message[] = sprintf(_("The parameter %s contains invalid char. '!,#' is used as delimiter"),$val['name']); + } + } + } + return ($message); + } + + + + function save() + { + plugin::save(); + + /* Force saving macro again + * This ensures that + * - the macro is available on the destiantion server. + * - the macro saved is up to date on the destination server. + */ + if(!empty($this->macro) && $this->macro != "none") { + $macro_tab= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->macro,"gofonmacro"); + $macro_tab -> save(); + } + + /* Save arrays */ + $tmp_numbers = array(); + foreach ($this->phoneNumbers as $number){ + $tmp_numbers[] = $number; + } + + /* Save settings, or remove goFonMacro attribute*/ + if($this->macro!="none"){ + $this->attrs['goFonMacro']=$this->macro; + if(isset($this->macroarray[$this->macro])){ + foreach($this->macroarray[$this->macro] as $paras) { + $this->attrs['goFonMacro'].="!".$paras['id']."#".$paras['choosen']; + } + } + }else{ + $this->attrs['goFonMacro']=array(); + } + unset($this->attrs['macro']) ; + + $this->attrs['goFonForwarding']=array(); + + if ($this->initially_was_account != $this->is_account || $this->is_modified){ + $str = $this->generate_mysql_entension_entries(true); + if(empty($str)){ + print_red($str); + } + } + + if($this->attrs['goFonMacro']==""){ + $this->attrs['goFonMacro']=array(); + } + + unset($this->attrs['cn']); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + + /* Force saving numbers, else it will be overwriten by user account. */ + $this->attrs['telephoneNumber'] =$tmp_numbers; + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/phone account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + + } + + + function adapt_from_template($dn) + { + plugin::adapt_from_template($dn); + + /* Assemble phone numbers */ + if (isset($this->attrs['telephoneNumber'])){ + for ($i= 0; $i<$this->attrs['telephoneNumber']['count']; $i++){ + $number= $this->attrs['telephoneNumber'][$i]; + $this->phoneNumbers[$number]= $number; + } + } + } + + + function remove_from_parent() + { + if(!$this->initially_was_account) return; + + foreach($this->attributes as $key=>$val){ + if(in_array($val,array("uid","cn"))){ + unset($this->attributes[$key]); + unset($this->$val); + } + } + if(count($this->goFonHomeServers) && !empty($this->init_HomeServer) && is_callable("mysql_pconnect")){ + + // Get Configuration for initial Mysql database Server + $a_SETUP = $this->goFonHomeServers[$this->init_HomeServer]; + $s_parameter =""; + + // Connect to DB server + $r_con = @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); + + // Check if we are connected correctly + if(!$r_con){ + print_red(sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), + $a_SETUP['SERVER'],$a_SETUP['LOGIN'])); + new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error()); + return false; + } + + // Select database for Extensions + $db = @mysql_select_db($a_SETUP['DB'],$r_con); + + // Test if we have the database selected correctly + if(!$db){ + print_red(sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER'])); + new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error()); + return false; + } + + $SQL=""; + + /* If deletion starts from userslist, cn uid are not set */ + if((isset($this->parent->by_object['user']->uid))&&(!empty($this->parent->by_object['user']->uid))){ + $this->uid = $this->parent->by_object['user']->uid; + } + + if((isset($this->parent->by_object['user']->cn))&&(!empty($this->parent->by_object['user']->cn))){ + $this->cn = $this->parent->by_object['user']->cn; + } + + $first_num = false; + // Delete old entries + foreach($this->a_old_telenums as $s_telenums){ + if(!$first_num){ + $first_num = $s_telenums; + } + $SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$s_telenums."';\n"; + } + + $SQL[] = "DELETE FROM ".$a_SETUP['VOICE_TABLE']." WHERE customer_id='".$first_num."';"; + $SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$this->uid."';\n"; + $SQL[] = "DELETE FROM ".$a_SETUP['SIP_TABLE']." WHERE name='".$this->uid."';\n"; + + foreach($SQL as $query){ + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + if(!@mysql_query($query,$r_con)){ + print_red(_("Stop".mysql_error())); + return false; + } + } + }else{ + print_red(_("Can't remove phone account, the mysql extension is not present in php configuration.")); + return false; + } + + /* unset macro attr, it will cause an error */ + $tmp = array_flip($this->attributes); + unset($tmp['macro']); + $this->attributes=array_flip($tmp); + + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + + /* Just keep one phone number */ + if (count($this->telephoneNumber) && $this->telephoneNumber != ""){ + $this->attrs['telephoneNumber']= $this->telephoneNumber; + } else { + $this->attrs['telephoneNumber']= array(); + } + + + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=goFonQueue)(member=*))", array("member")); + while($attr = $ldap->fetch()){ + if(in_array($this->dn,$attr['member'])){ + $new =new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'],$attr['dn']); + unset($new->by_object['ogroup']->memberList[$this->dn]); + unset($new->by_object['ogroup']->member[$this->dn]); + $new->save(); + print_red(sprintf(_("Removed user '%s' from phone queue '%s'."),$this->uid,$new->by_object['ogroup']->cn)); + } + } + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/phone account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + @mysql_close($r_con); + $this->handle_post_events('remove',array("uid"=> $this->uid)); + } + + + + /* This function checks if the given phonenumbers are available or already in use*/ + function is_number_used() + { + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid")); + while($attrs = $ldap->fetch()) { + unset($attrs['telephoneNumber']['count']); + foreach($attrs['telephoneNumber'] as $tele){ + if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn']; + if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn']; + $numbers[$tele]=$attrs; + } + } + + foreach($this->phoneNumbers as $num){ + if(!isset($this->cn)) $this->cn = ""; + + if((isset($numbers[$num]))&&(($numbers[$num]['uid'][0]!=$this->uid))){ + if(isset($numbers[$num]['uid'][0])){ + return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]); + }else{ + return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]); + } + } + } + } + + + /* Create phoneAccount part of copy & paste dialog */ + function getCopyDialog() + { + if(!$this->is_account) return(""); + $smarty = get_smarty(); + if (!count($this->phoneNumbers)){ + $smarty->assign ("phoneNumbers", array("")); + } else { + $smarty->assign ("phoneNumbers", $this->phoneNumbers); + } + + $smarty->assign("goFonVoicemailPIN",$this->goFonVoicemailPIN); + $smarty->assign("goFonPIN",$this->goFonPIN); + + $display= $smarty->fetch(get_template_path('paste_generic.tpl', TRUE, dirname(__FILE__))); + $ret =array(); + $ret['string'] = $display; + $ret['status'] = ""; + return($ret); + } + + /* Save posts from copy & paste dialog dialog */ + function saveCopyDialog() + { + if(!$this->is_account) return; + $this->execute(); + if(isset($_POST['goFonVoicemailPIN'])) { + $this->goFonVoicemailPIN = $_POST['goFonVoicemailPIN']; + } + if(isset($_POST['goFonPIN'])){ + $this->goFonPIN = $_POST['goFonPIN']; + } + } + + + function allow_remove() + { + /* Check if previously selected server is still available */ + if($this->initially_was_account && !isset($this->goFonHomeServers[$this->goFonHomeServer])){ + return sprintf(_("The previously selected asterisk home server (%s) is no longer available. Remove aborted."),preg_replace("/,/",", ",$this->goFonHomeServer)); + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Phone"), + "plDescription" => _("Phone account settings"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 7, // Position in tabs + "plSection" => "personal", // This belongs to personal + "plCategory" => array("gofonreport" => array("description" => _("GOfon reports"), + "objectClass" => "")), + + "plOptions" => array(), + + "plProvidedAcls" => array( + "telephoneNumber" => _("Telephone number"), + "goFonHomeServer" => _("Home server"), + "goFonMacro" => _("Macro settings"), + "goFonHardware" => _("Phone hardware"), + "goFonPIN" => _("Telephone pin"), + "goFonVoicemailPIN" => _("Voicemail pin")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/gofon/phoneaccount/generic.tpl b/gosa-core/plugins/gofon/phoneaccount/generic.tpl new file mode 100644 index 000000000..f034afeb7 --- /dev/null +++ b/gosa-core/plugins/gofon/phoneaccount/generic.tpl @@ -0,0 +1,113 @@ + + + + + + + + + + + + +
+

+ +  {t}Phone numbers{/t} +

+{render acl=$telephoneNumberACL} + +{/render} +
+{render acl=$telephoneNumberACL} + +{/render} +{render acl=$telephoneNumberACL} +   +{/render} +{render acl=$telephoneNumberACL} + +{/render} +
+ + + + + +
+

 {t}Telephone hardware{/t}

+ + + + + + + + + + + + + + + + + + +
{t}Telephone{/t}{$hardware_list}
{t}Home server{/t}{$must} + +{render acl=$goFonHomeServerACL} + +{/render} +
+ + +{render acl=$goFonVoicemailPINACL} + +{/render} +
+ + +{render acl=$goFonPINACL} + +{/render} +
+
+
 
+

+ +  {t}Phone macro{/t} +

+ + + + +
+{render acl=$goFonMacroACL} + +{/render} + {if $javascript eq 'false'} +{render acl=$goFonMacroACL} + +{/render} + {/if} +
+
+ {$macrotab} +
+ + + + diff --git a/gosa-core/plugins/gofon/phoneaccount/main.inc b/gosa-core/plugins/gofon/phoneaccount/main.inc new file mode 100644 index 000000000..683057ad2 --- /dev/null +++ b/gosa-core/plugins/gofon/phoneaccount/main.inc @@ -0,0 +1,125 @@ +dn); + sess_del ('edit'); + sess_del ('phoneAccount'); + } + + /* Create phoneAccount object on demand */ + if (!isset($_SESSION['phoneAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['phoneAccount']= new phoneAccount ($config, $ui->dn); + $_SESSION['phoneAccount']->set_acl_base($ui->dn); + $_SESSION['phoneAccount']->set_acl_category("users"); + } + $phoneAccount= $_SESSION['phoneAccount']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $phoneAccount->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $phoneAccount->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $phoneAccount->save (); + + del_lock ($ui->dn); + sess_del ('edit'); + + /* Write back to session */ + $_SESSION['phoneAccount']= $phoneAccount; + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display.= $lock_msg; + }else{ + $display.= $phoneAccount->execute (); + } + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['phoneAccount']= $phoneAccount; + } + + $info= ""; + if ($phoneAccount->is_account && empty($lock_msg)){ + $display.= "

"; + + /* Are we in edit mode? */ + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/phoneAccount"))){ + $info.= "\"\""._("Click the 'Edit' button below to change informations in this dialog"); + $display.= "\n"; + } + $display.= "\n"; + } + $display.= "

\n"; + $display.= "\n"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/phone.png'), _("Phone settings"), $info).$display; + +} +?> diff --git a/gosa-core/plugins/gofon/phoneaccount/paste_generic.tpl b/gosa-core/plugins/gofon/phoneaccount/paste_generic.tpl new file mode 100644 index 000000000..d643e9f69 --- /dev/null +++ b/gosa-core/plugins/gofon/phoneaccount/paste_generic.tpl @@ -0,0 +1,55 @@ +

{t}Phone settings{/t}

+ + + + + + + + +
+

+  {t}Phone numbers{/t} +

+
+ +
+ + + +
+ + + + +
+

+ +  {t}Telephone hardware{/t} +

+ + + + + + + + + +
+ + + +
+ + + +
+
+
+ +
+
diff --git a/gosa-core/plugins/personal/connectivity/class_connectivity.inc b/gosa-core/plugins/personal/connectivity/class_connectivity.inc new file mode 100644 index 000000000..70cfd87a7 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_connectivity.inc @@ -0,0 +1,190 @@ + + \version 2.30 + \date 29.03.2005 + + This class provides the functionality to read and write all attributes + relevant for connectivity settings from/to the LDAP. It does syntax checking + and displays the formulars required. + */ + +class connectivity extends plugin +{ + /* Definitions */ + var $plHeadline= "Connectivity"; + var $plDescription= "This does something"; + + /* attribute list for save action */ + var $attributes= array(); + var $objectclasses= array(); + + var $ignore_account= TRUE; + var $plugin= array(); + var $plugin_name= array(); + var $CopyPasteVars = array("plugin","plugin_name"); + + + function connectivity (&$config, $dn= NULL,$parent =NULL) + { + /* Preseed permissions */ + $this->dn= $dn; + $ui= get_userinfo(); + + /* Load accounts */ + foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){ + $name= $plug['CLASS']; + $this->plugin_name[]= $name; + $this->plugin[$name]= new $name($config, $dn,$parent); + + /* Acl base && category configuration, + these settings will be overloaded in main.inc, + if we are editing ourself */ + $this->plugin[$name]-> set_acl_category("users"); + $this->plugin[$name]-> set_acl_base($this->dn); + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $display= ""; + + /* Prepare templating */ + $smarty= get_smarty(); + + /* Do we represent a valid account? */ + if ($this->parent === NULL){ + $enabled= true; + foreach ($this->plugin_name as $name){ + if ($this->plugin[$name]->is_account){ + $enabled= true; + break; + } + } + if (!$enabled){ + $display= "\"\" ". + _("This account has no connectivity extensions.").""; + $display.= back_to_main(); + return ($display); + } + } + + /* Remove checkboxes in single edit mode */ + if ($this->parent !== NULL){ + foreach ($this->plugin_name as $name){ + $this->plugin[$name]->parent= $this->parent; + } + } + + /* Execude objects */ + $is_first= true; + + $ReadOnly = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + + foreach ($this->plugin_name as $name){ + $this->plugin[$name]->ReadOnly = $ReadOnly; + if (!$is_first){ + $display.= '

 

'; + } else { + $is_first= false; + } + $display.= $this->plugin[$name]->execute(); + } + + /* Mark me as connectivity tab */ + $display.= ""; + + return($display); + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['connectivityTab'])){ + foreach ($this->plugin_name as $name){ + $this->plugin[$name]->save_object(); + } + } + } + + function check() + { + $message= plugin::check(); + + foreach ($this->plugin_name as $name){ + $tmp= $this->plugin[$name]->check(); + + $message= array_merge($message, $tmp); + } + + return ($message); + } + + function set_acl_category($cat) + { + plugin::set_acl_category($cat); + foreach ($this->plugin_name as $name){ + $this->plugin[$name]->set_acl_category( $cat); + } + } + + function set_acl_base($base) + { + plugin::set_acl_base($base); + foreach ($this->plugin_name as $name){ + $this->plugin[$name]->set_acl_base( $base); + } + } + + /* Save to LDAP */ + function save() + { + /* Save objects */ + foreach ($this->plugin_name as $name){ + $this->plugin[$name]->dn= $this->dn; + + if ($this->plugin[$name]->is_account){ + $this->plugin[$name]->save(); + } else { + $this->plugin[$name]->remove_from_parent(); + } + } + } + + function remove_from_parent() + { + /* Remove objects */ + foreach ($this->plugin_name as $name){ + $this->plugin[$name]->dn= $this->dn; + $this->plugin[$name]->remove_from_parent(); + } + } + + function adapt_from_template($dn) + { + /* Adapt objects */ + foreach ($this->plugin_name as $name){ + $this->plugin[$name]->dn= $this->dn; + $this->plugin[$name]->adapt_from_template($dn); + } + } + + /* Prepare the connectivity obj + */ + function PrepareForCopyPaste($obj) + { + $tmp = $this->plugin; + plugin::PrepareForCopyPaste($obj); + $this->plugin = $tmp; + foreach( $this->plugin as $key => $plug){ + $this->plugin[$key]->PrepareForCopyPaste($obj); + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_intranetAccount.inc b/gosa-core/plugins/personal/connectivity/class_intranetAccount.inc new file mode 100644 index 000000000..c2b9573d3 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_intranetAccount.inc @@ -0,0 +1,213 @@ + + \version 1.00 + \date 1.07.2005 + + \brief Enables Apache authentification for Intranet through openldap with .htaccess files + */ + +class intranetAccount extends plugin +{ + /*! Definitions */ + var $plHeadline= "Intranet"; + /*! Definitions */ + var $plDescription= "This does something"; + + /* attribute list for save action */ + var $attributes= array(); + /* ObjectClasses list for save action */ + var $objectclasses= array("gosaIntranetAccount"); + var $ReadOnly = false; + + var $uid =""; + + var $view_logged = FALSE; + + /*! \brief Konstructor + + \param $config The Config Object used to initialise plugin + \param $dn The DN of the currently edited entry + \author Harald Falk + \version 1.00 + \date 1.07.2005 + */ + function intranetAccount (&$config, $dn= NULL, $parent=NULL) + { + plugin::plugin ($config, $dn,$parent); + + /* Setting uid to default */ + if(isset($this->attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + } + + /*! + \brief General execution + \author Harald Falk + \version 1.00 + \date 1.07.2005 + + Load smarty Template and assign needed smarty vars + */ + + + function execute() + { + /* Call parent execute */ + // plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + $display= ""; + + $smarty= get_smarty(); + + if ($this->is_account){ + $smarty->assign("intranetState", "checked"); + $smarty->assign("wstate", ""); + } else { + $smarty->assign("wstate", "disabled"); + $smarty->assign("intranetState", ""); + } + + //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. ) + if ($this->parent !== NULL){ + $smarty->assign("tabbed", 1); + }else{ + $smarty->assign("tabbed", 0); + } + + + $smarty->assign('gosaIntranetACL', " disabled "); + if((!$this->ReadOnly) && ( ($this->is_account && $this->acl_is_removeable()) + || (!$this->is_account && $this->acl_is_createable()))){ + $smarty->assign('gosaIntranetACL', ""); + } + + $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + /*! + \brief Delete ext from User + \author Harald Falk + \version 1.00 + \date 1.07.2005 + Handles deletion of this object + */ + function remove_from_parent() + { + if($this->acl_is_removeable() && $this->initially_was_account){ + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* Log last action */ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->postremove(array("uid"=>$this->uid)); + } + } + + + /*! + \brief handles Post data + \author Harald Falk + \version 1.00 + \date 1.07.2005 + Save data to object + */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['intranet'])){ + if (!$this->is_account && $_POST['intranet'] == "B"){ + if($this->acl_is_createable()){ + $this->is_account= TRUE; + } + } + } else { + if($this->acl_is_removeable()){ + $this->is_account= FALSE; + } + } + } + + plugin::save_object(); + if (isset($_POST["INTRANETStatus"])){ + $this->INTRANETStatus = "disabled"; + } else { + $this->INTRANETStatus = "enabled"; + } + } + + + /*! \brief Handles LDAP saves + \author Harald Falk + \version 1.00 + \date 1.07.2005 + Save objectClass for User in LDAP + + */ + function save() + { + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->postcreate(array("uid" => $this->uid)); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Intranet"), + "plDepends" => array("user"), + "plPriority" => 25, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plDescription" => _("Intranet account settings")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + + "plProvidedAcls" => array() + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_kolabAccount.inc b/gosa-core/plugins/personal/connectivity/class_kolabAccount.inc new file mode 100644 index 000000000..c72977de8 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_kolabAccount.inc @@ -0,0 +1,486 @@ +attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + /* Pull arrays */ + foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){ + if (isset($this->attrs["$attr"]["count"])){ + $tmp = array(); + for ($i= 0; $i<$this->attrs["$attr"]["count"]; $i++){ + $tmp[]=$this->attrs["$attr"][$i]; + } + $this->$attr = $tmp; + } + } + + /* If this one is empty, preset with ACT_MANUAL for anonymous users */ + if (count ($this->kolabInvitationPolicy) == 0){ + $this->kolabInvitationPolicy= array("ACT_MANUAL"); + } + + /* Check is account state */ + $this->is_account = false; + if(count($this->kolabDelegate)){ + $this->is_account = true; + } + foreach(array("calFBURL","unrestrictedMailSize") as $attr){ + if(!empty($this->$attr)){ + $this->is_account = true; + } + } + + /* Transfer account states for this union */ + if (isset($this->parent->by_object['mailAccount']) && $this->parent->by_object['mailAccount']->is_account){ + $this->mail_Account = true; + }elseif( isset($this->attrs) && isset($this->attrs['kolabHomeServer'])){ + $this->mail_Account= true; + }else{ + $this->is_account = false; + $this->mail_Account = false; + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + /* Load attributes */ + foreach($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $acl => $description){ + $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly)); + $smarty->assign($acl."_W", $this->acl_is_writeable($acl,$this->ReadOnly)); + } + $smarty->assign("is_account" , $this->is_account); + + if($this->ReadOnly){ + $smarty->assign("is_removeable",false); + $smarty->assign("is_createable",false); + }else{ + $smarty->assign("is_removeable",$this->acl_is_removeable()); + $smarty->assign("is_createable",$this->acl_is_createable()); + } + + /* Check for invitation action */ + $nr= 0; + while (isset($_POST["policy$nr"])){ + if (isset($_POST["add$nr"])){ + $this->kolabInvitationPolicy[]= ": ACT_MANUAL"; + } + if (isset($_POST["remove$nr"])){ + $new= array(); + foreach ($this->kolabInvitationPolicy as $entry){ + if (!preg_match("/^".$this->imapping[$nr].":/", $entry)){ + $new[]= $entry; + } + } + $this->kolabInvitationPolicy= $new; + } + $nr++; + } + + /* Unify addresses */ + $new= array(); + foreach($this->kolabInvitationPolicy as $value){ + $address= preg_replace('/^([^:]+:).*$/', '\1', $value); + $new[$address]= $value; + } + $this->kolabInvitationPolicy= array(); + foreach($new as $value){ + $this->kolabInvitationPolicy[]= $value; + } + + /* Add delegation */ + if (isset($_POST['add_delegation'])){ + if ($_POST['delegate_address'] != ""){ + + /* Valid email address specified? */ + $address= $_POST['delegate_address']; + $valid= FALSE; + if (!is_email($address)){ + if (!is_email($address, TRUE)){ + print_red (_("You're trying to add an invalid email address to the list of delegations.")); + } + } else { + + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search('(mail='.$address.')',array("mail")); + if ($ldap->count() == 0){ + print_red (_("The mail address you're trying to add is no primary mail address of an existing user.")); + } else { + $valid= TRUE; + } + } + + if ($valid){ + /* Add it */ + if ($this->acl_is_writeable("kolabDelegate")){ + $this->addDelegate ($address); + $this->is_modified= TRUE; + } + + } + } + } + + /* Delete forward email addresses */ + if ((isset($_POST['delete_delegation'])) && (isset($_POST['delegate_list']))){ + if (count($_POST['delegate_list']) && $this->acl_is_writeable("kolabDelegate")){ + $this->delDelegate ($_POST['delegate_list']); + } + } + + /* Assemble policies */ + $policies= array( 'ACT_ALWAYS_ACCEPT' => _("Always accept"), + 'ACT_ALWAYS_REJECT' => _("Always reject"), + 'ACT_REJECT_IF_CONFLICTS' => _("Reject if conflicts"), + 'ACT_MANUAL_IF_CONFLICTS' => _("Manual if conflicts"), + 'ACT_MANUAL' => _("Manual")); + $smarty->assign('policies', $policies); + + /* Adjust checkbox */ + if ($this->unrestrictedMailSize){ + $smarty->assign('unrestrictedMailSizeState', "checked"); + } else { + $smarty->assign('unrestrictedMailSizeState', ""); + } + + /* Transfer delegation list */ + if (!count($this->kolabDelegate)){ + /* Smarty will produce and tidy don't like that, so tell smarty to create no option (array();)*/ + $smarty->assign("kolabDelegate", array()); + } else { + $smarty->assign("kolabDelegate", $this->kolabDelegate); + } + + $smarty->assign("mail_account",$this->mail_Account); + + /* Create InvitationPolicy table */ + $invitation= ""; + $this->imapping= array(); + $nr= 0; + $changeState = ""; + foreach ($this->kolabInvitationPolicy as $entry){ + + if($this->acl_is_writeable("kolabInvitationPolicy")){ + $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n + changeState('add".$nr."'); \n changeState('remove".$nr."'); \n"; + } + + if(!$this->acl_is_writeable("kolabInvitationPolicy")){ + $dis = " disabled "; + }else{ + if($this->is_account){ + $dis = " "; + }else{ + $dis = " disabled "; + } + } + $invitation.= ""; + + if(!$this->acl_is_readable("kolabInvitationPolicy")) { + } + + /* The default entry does not have colons... */ + if (!preg_match('/:/', $entry)){ + $invitation.= _("Anonymous"); + $name= ""; + $mode= $entry; + } else { + $name= preg_replace('/:.*$/', '', $entry); + $mode= preg_replace('/^[^:]*: */', '', $entry); + + if(!$this->acl_is_readable("kolabInvitationPolicy")){ + $name=''; + } + $invitation.= ""; + } + $invitation.= ""; + + /* Add mode switch */ + $invitation.= ""; + } + if ($nr != 0) { + $button.= ""; + } + + $invitation.= " $button\n"; + $this->imapping[$nr]= $name; + $nr++; + } + $smarty->assign("invitation", $invitation); + $smarty->assign("changeState", $changeState); + $smarty->assign("kolabState",$this->is_account); + $display.= $smarty->fetch (get_template_path('kolab.tpl', TRUE, dirname(__FILE__))); + + + return ($display); + } + + function remove_from_parent() + { + if(!$this->initially_was_account){ + return; + } + + /* Optionally execute a command after we're done */ + plugin::remove_from_parent(); + + if(!in_array("kolabInetOrgPerson",$this->attrs['objectClass'])){ + $this->attrs['objectClass'][] = "kolabInetOrgPerson"; + } + + $ldap = $this->config->get_ldap_linK(); + $ldap->cd($this->config->current['BASE']); + $ldap->cd ($this->dn); + $ldap->modify($this->attrs); + + /* Log last action */ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + $this->handle_post_events('remove',array("uid" => $this->uid)); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/kolab account with dn '%s' failed."),$this->dn)); + } + + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* FBFuture is in days... */ + if ($this->kolabFreeBusyFuture != "" && !preg_match('/^[0-9]+$/', $this->kolabFreeBusyFuture)){ + $message[]= _("The value specified as Free Busy future needs to be an integer."); + } + + /* Check for URL scheme... */ + if(!empty($this->calFBURL) && !preg_match("/http+(s)*:\/\//",$this->calFBURL)){ + $message[]= _("The value specified as Free Busy Information URL is invalid."); + } + + /* Check invitation policy for existing mail addresses */ + foreach($this->kolabInvitationPolicy as $policy){ + + /* Ignore anonymous string */ + if (!preg_match('/:/', $policy)){ + continue; + } + + $address= preg_replace('/^([^:]+).*$/', '\1', $policy); + if (!is_email($address)){ + if (!is_email($address, TRUE)){ + $message[]= sprintf(_("The invitation policy entry for address '%s' is not valid."), $address); + } + } else { + + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search('(mail='.$address.')',array("mail")); + if ($ldap->count() == 0){ + $message[]= sprintf(_("There's no mail user with address '%s' for your invitation policy!"), $address); + } else { + $valid= TRUE; + } + } + } + + return ($message); + } + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + + if(isset($_POST["kolabState"])){ + if($this->acl_is_createable()){ + $this->is_account = true; + } + }else{ + if($this->acl_is_removeable()){ + $this->is_account = false; + } + } + + if ($this->acl_is_writeable("unrestrictedMailSize")){ + if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){ + $this->unrestrictedMailSize= 1; + } else { + $this->unrestrictedMailSize= 0; + } + } + } + + plugin::save_object(); + + /* Save changes done in invitation policies */ + if($this->acl_is_writeable("kolabInvitationPolicy")){ + $nr= 0; + $this->kolabInvitationPolicy= array(); + while (isset($_POST["policy$nr"])){ + + /* Anonymous? */ + if (!isset($_POST["address$nr"])){ + $this->kolabInvitationPolicy[]= $_POST["policy$nr"]; + } else { + $this->kolabInvitationPolicy[]= $_POST["address$nr"].": ".$_POST["policy$nr"]; + } + + $nr++; + } + + /* If this one is empty, preset with ACT_MANUAL for anonymous users */ + if (count ($this->kolabInvitationPolicy) == 0){ + $this->kolabInvitationPolicy= array("ACT_MANUAL"); + } + } + } + + + /* Save to LDAP */ + function save() + { + /* Check mailmethod before doing something useful */ + plugin::save(); + + /* Transfer arrays */ + $this->attrs['kolabDelegate']= $this->kolabDelegate; + $this->attrs['kolabInvitationPolicy']= $this->kolabInvitationPolicy; + + /* unrestrictedMailSize is boolean */ + if($this->attrs['unrestrictedMailSize']){ + $this->attrs['unrestrictedMailSize'] = "TRUE"; + }else{ + $this->attrs['unrestrictedMailSize'] = "FALSE"; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/kolab account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + } + + + /* Add entry to delegation list */ + function addDelegate($address) + { + $this->kolabDelegate[]= $address; + $this->kolabDelegate= array_unique ($this->kolabDelegate); + + sort ($this->kolabDelegate); + reset ($this->kolabDelegate); + $this->is_modified= TRUE; + } + + function delDelegate($addresses) + { + $this->kolabDelegate= array_remove_entries ($addresses, $this->kolabDelegate); + $this->is_modified= TRUE; + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Kolab"), + "plDescription" => _("Kolab account settings")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 20, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "kolabFreeBusyFuture" => _("Free busy future"), + "unrestrictedMailSize" => _("Mail size restriction"), + "calFBURL" => _("Free busy information"), + "kolabDelegate" => _("Delegations"), + "kolabInvitationPolicy" => _("Invitation policy")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_opengwAccount.inc b/gosa-core/plugins/personal/connectivity/class_opengwAccount.inc new file mode 100644 index 000000000..ff96e458e --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_opengwAccount.inc @@ -0,0 +1,356 @@ +ldap */ + var $attrsToUse = array( "salutation" =>"vocation", + "name" =>"sn", + "firstname" =>"givenName", + "login" =>"uid", + "degree" =>"academicTitle", + "birthday" =>"dateOfBirth", + "sex" =>"gender", + "street" =>"street", + "zip" =>"postalCode", + "value_string"=>"mail", + "number" =>"telephoneNumber" + ); + + var $serverCon = false; + var $handle = NULL; + var $is_account = false; + var $initialy_was_account = false; + var $OGWPassword = ""; + var $ReadOnly = false; + var $view_logged = FALSE; + var $uid = ""; + + function opengwAccount (&$config, $dn= NULL) + { + plugin::plugin ($config, $dn); + + /* Setting uid to default */ + if(isset($this->attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + $this->info=array(); + + /* is no account and was no account */ + $this->initialy_was_account = false; + $this->is_account = false; + + /* Get configurations */ + if($this->config->search("opengwAccount", 'USERNAME',array('tabs'))){ + $atr = array(); + $atr['LOGIN'] = $this->config->search("opengwAccount", 'USERNAME',array('tabs')); + $atr['PASSWORD']= $this->config->search("opengwAccount", 'PASSWORD',array('tabs')); + $atr['SERVER'] = $this->config->search("opengwAccount", 'DATAHOST',array('tabs')); + $atr['DB'] = $this->config->search("opengwAccount", 'DATABASE',array('tabs')); + $this->serverCon = $atr; + }elseif(isset($this->config->data['SERVERS']['OPENGROUPWARE'])){ + $this->serverCon = $this->config->data['SERVERS']['OPENGROUPWARE']; + }else{ + $this->serverCon = array(); + } + + /* check if datebase funktions are available, and if database configurations are available */ + if(is_callable("pg_connect") && count($this->serverCon)){ + + $this->handle = new ogw($this->serverCon['LOGIN'],$this->serverCon['PASSWORD'],$this->serverCon['SERVER'],$this->serverCon['DB']); + + /* Check if current configuration allows database connection */ + if($this->handle->connected){ + + /* Set login name, to check if this is_account */ + if(isset($this->attrs['uid'][0])){ + $this->handle->info['login'] = $this->attrs['uid'][0]; + }else{ + $this->handle->info['login'] = ""; + } + + /* If this is account get data from database first */ + if($this->handle->CheckExistence()){ + $this->info = $this->handle->GetInfos($this->attrs['uid'][0]); + + /* This is an account */ + $this->initialy_was_account = true; + $this->is_account= true; + }else{ + /* this is no account */ + $this->initialy_was_account = false; + $this->is_account= false; + + /* Selectable in GOsa */ + $this->info['template_user_id'] = 0; + $this->info['is_locked'] = 0; + $this->info['LocationTeamID'] = 0; + $this->info['TeamIDis'] = array(); + } + + /* Set settings from ldap */ + foreach($this->attrsToUse as $name=>$attr){ + if(isset($this->attrs[$attr][0])){ + $this->info[$name] = $this->attrs[$attr][0]; + }else{ + $this->info[$name] = false; + } + } + + /* Description is displayed as 'Nickname' */ + $this->info['description'] = $this->info['login']; + + if($this->info['sex'] == "F"){ + $this->info['sex'] = "female"; + }else{ + $this->info['sex'] = "male"; + } + + } + + /* Transmit data back to ogw handle */ + $this->handle->SetInfos($this->info); + } + } + + function execute() + { + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Show tab dialog headers */ + $display= ""; + $smarty= get_smarty(); + + $smarty->assign("serverCon",count($this->serverCon)); + $smarty->assign("validTeams",""); + $smarty->assign("is_account", " "); + $smarty->assign("OGWstate"," disabled "); + $smarty->assign("validLocationTeam",array(" ")); + $smarty->assign("validLocationTeams",array(" ")); + $smarty->assign("LocationTeam",0); + $smarty->assign("validTemplateUser",array(" ")); + $smarty->assign("validTemplateUsers",array(" ")); + $smarty->assign("TemplateUser",0); + $smarty->assign("is_lockedCHK", " "); + $smarty->assign("is_locked", " "); + + /* set default values */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $acl => $desc){ + $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly)); + } + + if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { + $smarty->assign('opengwAccountACL', ""); + }else{ + $smarty->assign('opengwAccountACL', " disabled "); + } + + if(count($this->serverCon)) + + /* Check database extension */ + if(!is_callable("pg_connect") && count($this->serverCon)){ + print_red(_("OpenGroupware: Your configuration is missing a postgresql extension. Can't perform any database queries.")); + }elseif(count($this->serverCon)){ + + /* Check if config exists */ + if($this->config->search("opengwAccount", 'DATABASE',array('tabs'))){ + print_red(_("OpenGroupware: Missing database configuration for opengroupware. Can't get or set any informations.")); + }else{ + + /* Create handle */ + $this->handle = new ogw($this->serverCon['LOGIN'],$this->serverCon['PASSWORD'],$this->serverCon['SERVER'],$this->serverCon['DB']); + + /* Check if we are successfully connected to db */ + if(!$this->handle->connected){ + print_red(_("OpenGroupware: Can't connect to specified database. Please check given configuration twice.")); + }else{ + + /* Assign LocationTeams */ + $tmp = array(""=>"none"); + foreach($this->handle->validLocationTeam as $id){ + $tmp[$id['company_id']] = $id['description']; + } + $smarty->assign("validLocationTeam",$tmp); + $smarty->assign("validLocationTeams",array_flip($tmp)); + $smarty->assign("LocationTeam",$this->info['LocationTeamID']); + + /* Assign TemplateUsers*/ + $tmp = array(); + foreach($this->handle->validTemplateUser as $id){ + $tmp[$id['company_id']] = $id['name']; + } + $smarty->assign("validTemplateUser",$tmp); + $smarty->assign("validTemplateUsers",array_flip($tmp)); + $smarty->assign("TemplateUser",$this->info['template_user_id']); + + /* Create Team membership */ + $str = ""; + if(($this->is_account)==""){ + $dis = ""; + }else{ + $dis = " disabled "; + } + + if($this->acl_is_readable("Teams")){ + foreach($this->handle->validTeams as $id){ + if(in_array($id['company_id'],$this->info['TeamIDis'])){ + $str .= "".$id['description']."
"; + }else{ + $str .= "".$id['description']."
"; + } + } + } + $smarty->assign("validTeams",$str); + + /* Assign ogw checkbox */ + if($this->is_account){ + $smarty->assign("OGWstate",""); + $smarty->assign("is_account", " checked "); + }else{ + $smarty->assign("is_account", " "); + $smarty->assign("OGWstate"," disabled "); + } + + /* Assign lock status */ + if($this->info['is_locked']){ + $smarty->assign("is_lockedCHK", " checked "); + }else{ + $smarty->assign("is_lockedCHK", " "); + } + $smarty->assign("is_locked", $this->info['is_locked']); + + } + } + } + $display.= $smarty->fetch (get_template_path('opengw.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + /* remove database entries */ + if($this->initialy_was_account){ + $this->handle = new ogw($this->serverCon['LOGIN'],$this->serverCon['PASSWORD'],$this->serverCon['SERVER'],$this->serverCon['DB']); + $this->handle->SetInfos($this->info); + $this->handle->Perform("REMOVE"); + + new log("remove","users/".get_class($this),$this->dn); + } + } + + + /* Save data to object */ + function save_object() + { + /* get post data */ + if($this->is_account){ + + /* Get selected team chkboxes */ + $this->info['TeamIDis'] = array(); + if($this->acl_is_writeable("Teams")) { + foreach($_POST as $name => $value ){ + if(preg_match("/team_/i",$name)){ + if(!in_array($value,$this->info['TeamIDis'])){ + $this->info['TeamIDis'][]=$value; + } + } + } + } + + + /* Get location Team*/ + if(isset($_POST['LocationTeam']) && $this->acl_is_writeable("LocationTeam")){ + $this->info['LocationTeamID'] = $_POST['LocationTeam']; + } + + /* Get template user */ + if(isset($_POST['TemplateUser']) && $this->acl_is_writeable("TemplateUser") ){ + $this->info['template_user_id'] = $_POST['TemplateUser']; + } + + /* get lock status */ + if($this->acl_is_writeable("Locked")){ + if(isset($_POST['is_locked'])){ + $this->info['is_locked'] = $_POST['is_locked']; + }else{ + $this->info['is_locked'] = 0; + } + } + } + + /* change account status */ + if(isset($_POST['is_account'])){ + if($this->acl_is_createable()){ + $this->is_account = $_POST['is_account']; + } + }else{ + if($this->acl_is_removeable()){ + $this->is_account = false;//$_POST['is_account']; + } + } + } + + + /* Save to LDAP */ + function save() + { + /* Save data */ + $this->handle = new ogw($this->serverCon['LOGIN'],$this->serverCon['PASSWORD'],$this->serverCon['SERVER'],$this->serverCon['DB']); + $this->handle->SetInfos($this->info); + $this->handle->checkInfos(); + if($this->initialy_was_account){ + $this->handle->Perform("EDIT"); + new log("modify","users/".get_class($this),$this->dn); + }else{ + $this->handle->Perform("ADD"); + new log("create","users/".get_class($this),$this->dn); + } + } + + + function PrepareForCopyPaste($src){ + // Nothing to do, because this object can't be copied ... yet + } + + + /* Return plugin informations for acl handling + #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */ + static function plInfo() + { + return (array( + "plShortName" => _("Opengroupware"), + "plDescription" => _("Open groupware account settings")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 26, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "LocationTeam" => _("Location team"), + "TemplateUser" => _("Template user"), + "Locked" => _("Locked"), + "Teams" => _("Teams")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_oxchangeAccount.inc b/gosa-core/plugins/personal/connectivity/class_oxchangeAccount.inc new file mode 100644 index 000000000..ce4288fbb --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_oxchangeAccount.inc @@ -0,0 +1,981 @@ +config->data['TABS']['CONNECTIVITY']);$i++){ + if($this->config->data['TABS']['CONNECTIVITY'][$i]['CLASS']=='oxchangeAccount') { + $this->oxconf=$this->config->data['TABS']['CONNECTIVITY'][$i]; + break; + } + } + + /* Setting uid to default */ + if(isset($this->attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + $this->dnmode= $this->config->current['DNMODE']; + if(isset($this->attrs[$this->dnmode][0])){ + $this->dnModeValue = $this->attrs[$this->dnmode][0]; + } + } + + function execute() + { + /* Call parent execute */ + //plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + $display=""; + + /* Show main page */ + $smarty= get_smarty(); + + if (function_exists("pg_connect")){ + $smarty->assign("pg", true); + }else{ + $smarty->assign("pg", false); + } + + /* Load attributes */ + foreach($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + if ($this->is_account){ + $smarty->assign("oxchangeState", "checked"); + $smarty->assign("oxState", ""); + } else { + $smarty->assign("oxchangeState", ""); + $smarty->assign("oxState", "disabled"); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $key => $desc){ + $smarty->assign($key."ACL",$this->getacl($key,$this->ReadOnly)); + $smarty->assign($key."_W",$this->acl_is_writeable($key)); + } + + if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) ){ + $smarty->assign('oxchangeAccountACL', ""); + }else{ + $smarty->assign('oxchangeAccountACL', " disabled "); + } + + $smarty->assign("timezones", $this->timezones); + + + if ($this->parent !== NULL){ + $smarty->assign("tabbed", 1); + }else{ + $smarty->assign("tabbed", 0); + } + + /* Trying to open a Postgresql Database Server */ + if (function_exists("pg_connect")){ + if(isset($this->oxconf["PGUSER"]) and isset($this->oxconf["PGHOST"]) and isset($this->oxconf["PGDBNAME"]) and isset($this->oxconf["PGPASSWD"])){ + $pgcon = @pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]); + if (! $pgcon){ + $smarty->assign("pg", false); + } + }else{ + $smarty->assign("pg", false); + } + }else{ + $smarty->assign("pg", false); + } + + $display.= $smarty->fetch (get_template_path('oxchange.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + if(!$this->acl_is_removeable()) return; + $this->attrs[$this->dnmode][0] = $this->dnModeValue; + $sqldeluser=array( + "delete from prg_notes where (user_right like '".$this->attrs[$this->dnmode][0]."') and (group_right like 's')", + "delete from prg_documents_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_documents_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_docufolders_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_docufolders_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_date_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_date_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_dates_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_knowledge_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_knowledge_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_knowledge_folder_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_knowledge_folder_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_pin_board_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_pin_board_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_bookmarks_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_bookmarks_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_bookmarks_folder_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_bookmarks_folder_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_tasks_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_tasks_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_tasks_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_projects_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_projects_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')", + "delete from prg_projects_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')", + "delete from oxfolder_permissions where (entity like '".$this->attrs[$this->dnmode][0]."') AND ((role = 256) OR (role = 1024))", + "delete from oxfolder_standardfolders where owner like '".$this->attrs[$this->dnmode][0]."'", + "delete from prg_forum_read where user_right = '".$this->attrs[$this->dnmode][0]."'", + "delete from prg_forum_mod where user_right = '".$this->attrs[$this->dnmode][0]."'", + "delete from prg_forum_abo where user_right = '".$this->attrs[$this->dnmode][0]."'", + "delete from prg_forum_seen where username = '".$this->attrs[$this->dnmode][0]."'", + "delete from sys_holiday where (userid like '".$this->attrs[$this->dnmode][0]."')", + "delete from usr_holiday where (userid like '".$this->attrs[$this->dnmode][0]."')"); + + /* Trying to open a Postgresql Database Server */ + if (function_exists("pg_connect")){ + if(isset($this->oxconf["PGUSER"]) and + isset($this->oxconf["PGHOST"]) and + isset($this->oxconf["PGDBNAME"]) and + isset($this->oxconf["PGPASSWD"])){ + $pgcon = @pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]); + if (! $pgcon){ + print_red(_("Connectivity")." "._("Openexchange")." :"._("Couldn't connect to postgresql database!")); + return; + } + }else{ + print_red(_("Connectivity")." "._("Openexchange")." :"._("Needed parameters for openexchange connectivity plugin are missing!")); + return; + } + }else{ + print_red(_("Connectivity")." "._("Openexchange")." :"._("PHP4 module for postgresql database is missing!")); + return; + } + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + if($ldap->dn_exists("ou=addr,".$this->dn)){ + $ldap->rmdir_recursive("ou=addr,".$this->dn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/oxchange addressbook account with dn '%s' failed."),$this->dn)); + } + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/oxchange addressbook account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->postremove(array("uid" => $this->uid)); + + /* Finally remove data from postgresql server */ + foreach ($sqldeluser as $sqls){ + @pg_exec($pgcon,$sqls); + } + pg_close(); + } + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['oxchange'])){ + if (!$this->is_account && $_POST['oxchange'] == "B") { + if($this->acl_is_createable()){ + $this->is_account= TRUE; + } + } + } else { + if($this->acl_is_removeable()){ + $this->is_account= FALSE; + } + } + } + + /* Get objects */ + foreach(array("OXTimeZone","OXTaskDays","OXAppointmentDays") as $name) { + if($this->acl_is_writeable($name) && isset($_POST[$name])){ + $this->$name = $_POST[$name]; + } + } + +// plugin::save_object(); + if (isset($_POST["oxchangeStatus"])){ + $this->oxchangeStatus = "disabled"; + } else { + $this->oxchangeStatus = "enabled"; + } + } + + + /* Save to LDAP */ + function save() + { + + $needupdate=TRUE; + $istemplate=FALSE; + + +/* print "
".print_r($this->attrs, true)."
";*/ + + + /*First at all, we must check if this is new or is updated */ + /*Also check is we have a template, if is a template, is a new user */ + if (isset($this->attrs['objectClass'])){ + foreach ($this->attrs['objectClass'] as $object){ + if($object=="OXUserObject") $needupdate=FALSE; + if($object=="gosaUserTemplate") $istemplate=TRUE; + } + } + + $uidarray=array(); + preg_match("/^(\w+(?=\=))=((\w|\s|\.)+(?=\,)),.*/",$this->dn,$uidarray); + $uid=$uidarray[2]; + if (trim($uid) == "") { + print_red(_("The Open-Xchange accountname is empty and thus invalid! Check to make sure that you are not using any strange characters in the loginname.")); + return; + } + + if ($istemplate) $needupdate=TRUE; + + if($needupdate){ + /* Trying to open a Postgresql Database Server */ + if (function_exists("pg_connect")){ + if(isset($this->oxconf["PGUSER"]) and isset($this->oxconf["PGHOST"]) and isset($this->oxconf["PGDBNAME"]) and isset($this->oxconf["PGPASSWD"])){ + $pgcon = @pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]); + if (! $pgcon){ + print_red(_("Couldn't connect to postgresql database!")); + return; + } + }else{ + print_red(_("Needed parameters for openexchange connectivity plugin are missing!")); + return; + } + }else{ + print_red(_("PHP4 module for postgresql database is missing!")); + return; + } + } + + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/oxchange account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->postcreate(array("uid" => $this->uid)); + + if($needupdate){ + $ldap->create_missing_trees("ou=addr,".$this->dn); + show_ldap_error($ldap->get_error(), sprintf(_("Creating of user/oxchange account with dn '%s' failed."),$this->dn)); + /* Finally save data to postgresql server */ + pg_set_client_encoding ("UNICODE"); + $nv = "SELECT nextval ('serial_id')"; + $ot = "insert into oxfolder_tree (fuid, parent, fname, module, type, owner, creator, creating_date, created_from, changing_date, changed_from) VALUES (%d, 1, '%s', '%s', 'private', '%s', '%s', 'now', 'System', 'now', 'System')"; + $op = "INSERT INTO oxfolder_permissions (puid, pid, role, entity, sealed, fp, orp, owp, odp) VALUES (%d, %d, 32768, '%s', 0, 128, 128, 128, 128)"; + $os = "insert into oxfolder_standardfolders (owner,module_calendar,module_contact,module_task) VALUES ('%s',%d,%d,%d)"; + $ugr= "INSERT INTO usr_general_rights SELECT creating_date, created_from, changing_date, changed_from,text('%s'), addr_u, addr_r, addr_d, cont_u, cont_r, cont_d, data_u, data_r, data_d, serie_u, serie_r, serie_d, task_u, task_r, task_d, refer, proj_u, proj_r, proj_d, dfolder_u, dfolder_r, dfolder_d, doc_u, doc_r, doc_d, knowl_u, knowl_r, knowl_d, bfolder_u, bfolder_r, bfolder_d, bookm_u, bookm_r, bookm_d, pin_u, pin_r, pin_d, forum_n, fentrie_n, setup, pin_public, internal, int_groups, kfolder_u, kfolder_r, kfolder_d, webmail FROM sys_gen_rights_template WHERE login LIKE 'default_template'"; + + $error = FALSE; + $res=@pg_exec($pgcon,$nv); + + if(!$res){ + $error = TRUE; + }else{ + $calendarid=pg_fetch_row($res); + pg_freeresult($res); + + $q=sprintf($ot,$calendarid[0],'My Appointments','calendar',$uid,$uid); + @pg_exec($pgcon,$q); + } + + $res=@pg_exec($pgcon,$nv); + + if(!$res){ + $error = TRUE; + }else{ + $nid=pg_fetch_row($res); + pg_freeresult($res); + + $q=sprintf($op,$nid[0],$calendarid[0],$uid); + @pg_exec($pgcon,$q); + } + + $res=@pg_exec($pgcon,$nv); + if(!$res){ + $error = TRUE; + }else{ + $contactsid=pg_fetch_row($res); + pg_freeresult($res); + + $q=sprintf($ot,$contactsid[0],'My Contacts','contact',$uid,$uid); + @pg_exec($pgcon,$q); + } + + $res=@pg_exec($pgcon,$nv); + if(!$res){ + $error = TRUE; + }else{ + $nid=pg_fetch_row($res); + pg_freeresult($res); + + $q=sprintf($op,$nid[0],$contactsid[0],$uid); + @pg_exec($pgcon,$q); + } + + $res=@pg_exec($pgcon,$nv); + if(!$res){ + $error = TRUE; + }else{ + $tasksid=pg_fetch_row($res); + pg_freeresult($res); + + $q=sprintf($ot,$tasksid[0],'My Tasks','task',$uid,$uid); + @pg_exec($pgcon,$q); + } + + $res=@pg_exec($pgcon,$nv); + if(!$res){ + $error = TRUE; + }else{ + $nid=pg_fetch_row($res); + pg_freeresult($res); + + $q=sprintf($op,$nid[0],$tasksid[0],$uid); + @pg_exec($pgcon,$q); + + $q=sprintf($os,$uid,$calendarid[0],$contactsid[0],$tasksid[0]); + @pg_exec($pgcon,$q); + + $q=sprintf($ugr,$uid); + @pg_exec($pgcon,$q); + } + + @pg_close($pgcon); + + if($error){ + print_red(_("Something went wrong while saving oxchange account. Please check the error log file.")); + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Open xchange"), + "plDescription" => _("Open xchange account settings")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 27, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "OXAppointmentDays" => _("OXAppointmentDays"), + "OXTaskDays" => _("OXTaskDays"), + "OXTimeZone" => _("OXTimeZone")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_phpgwAccount.inc b/gosa-core/plugins/personal/connectivity/class_phpgwAccount.inc new file mode 100644 index 000000000..7c5cf6e2c --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_phpgwAccount.inc @@ -0,0 +1,172 @@ +attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + } + + function execute() + { + /* Call parent execute */ +// plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + /* Load attributes */ + foreach($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + if ($this->is_account){ + $smarty->assign("phpgwState", "checked"); + } else { + $smarty->assign("phpgwState", ""); + } + + if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { + $smarty->assign('phpgwAccountACL', ""); + }else{ + $smarty->assign('phpgwAccountACL', " disabled "); + } + + $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + if($this->acl_is_removeable()){ + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPgw account with dn '%s' failed."),$this->dn)); + + new log("remove","users/".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',array("uid" => $this->uid)); + } + } + + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['phpgw'])){ + if (!$this->is_account && $_POST['phpgw'] == "B"){ + if($this->acl_is_createable()){ + $this->is_account= TRUE; + } + } + } else { + if($this->acl_is_removeable()){ + $this->is_account= FALSE; + } + } + } + + plugin::save_object(); + if (isset($_POST["phpgwStatus"])){ + $this->phpgwStatus = "disabled"; + } else { + $this->phpgwStatus = "enabled"; + } + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPgw account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("PHP GW"), + "plDescription" => _("PHP GW account settings")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 24, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array() + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_phpscheduleitAccount.inc b/gosa-core/plugins/personal/connectivity/class_phpscheduleitAccount.inc new file mode 100644 index 000000000..41454ea7c --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_phpscheduleitAccount.inc @@ -0,0 +1,175 @@ +is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + if ($this->is_account){ + $smarty->assign("phpscheduleitState", "checked"); + } else { + $smarty->assign("phpscheduleitState", ""); + $smarty->assign("wstate", "disabled"); + } + + if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { + $smarty->assign('gosaphpscheduleitACL', ""); + }else{ + $smarty->assign('gosaphpscheduleitACL', " disabled "); + } + + $display.= $smarty->fetch (get_template_path('phpscheduleit.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if ($this->acl_is_removeable()){ + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPscheduleit account with dn '%s' failed."),$this->dn)); + + if($this->is_account){ + new log("remove","users/".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',array("uid" => $this->uid)); + } + } + + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['phpscheduleit'])){ + if (!$this->is_account && $_POST['phpscheduleit'] == "B"){ + if($this->acl_is_createable()) { + $this->is_account= TRUE; + } + } + } else { + if($this->acl_is_removeable()){ + $this->is_account= FALSE; + } + } + } + + plugin::save_object(); + if (isset($_POST["phpscheduleitStatus"])){ + $this->pptpStatus = "disabled"; + } else { + $this->pptpStatus = "enabled"; + } + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPscheduleit account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + + } + + + /* Return plugin informations for acl handling + #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */ + static function plInfo() + { + return (array( + "plShortName" => _("PHP Schedule it"), + "plDescription" => _("PHP Schedule it settings")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 29, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + + "plOptions" => array(), + + "plProvidedAcls" => array() + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_pptpAccount.inc b/gosa-core/plugins/personal/connectivity/class_pptpAccount.inc new file mode 100644 index 000000000..0c8c659cf --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_pptpAccount.inc @@ -0,0 +1,188 @@ +attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + } + + function execute() + { + /* Call parent execute */ + // plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + if ($this->is_account){ + $smarty->assign("pptpState", "checked"); + } else { + $smarty->assign("pptpState", ""); + $smarty->assign("wstate", "disabled"); + } + + if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { + $smarty->assign('gosapptpACL', ""); + }else{ + $smarty->assign('gosapptpACL', " disabled "); + } + + $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + if($this->acl_is_removeable()){ + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* Log last action */ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PPTP account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove',array("uid" => $this->uid)); + } + } + + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['pptp'])){ + if (!$this->is_account && $_POST['pptp'] == "B"){ + if($this->acl_is_createable()){ + $this->is_account= TRUE; + } + } + } else { + if($this->acl_is_removeable()){ + $this->is_account= FALSE; + } + } + } + + plugin::save_object(); + if (isset($_POST["pptpStatus"])){ + $this->pptpStatus = "disabled"; + } else { + $this->pptpStatus = "enabled"; + } + } + + + /* Save to LDAP */ + function save() + { + if($this->acl_is_createable()){ + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PPTP account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + } + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("PPTP"), + "plDescription" => _("PPTP account")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 28, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array() + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_proxyAccount.inc b/gosa-core/plugins/personal/connectivity/class_proxyAccount.inc new file mode 100644 index 000000000..455bb53e5 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_proxyAccount.inc @@ -0,0 +1,325 @@ +attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + $display= ""; + + /* Prepare templating */ + $smarty= get_smarty(); + + $smarty->assign('proxyAccountACL', " disabled "); + + if((!$this->ReadOnly)&& (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))){ + $smarty->assign('proxyAccountACL', ""); + } + + /* Assign radio boxes */ + foreach (array("F", "T", "B", "N") as $val){ + + if (is_integer(strpos($this->gosaProxyAcctFlags, "$val"))) { + $smarty->assign("filter$val", "checked"); + + /* Add state variables for on-the-fly state-changing of checkboxes */ + $smarty->assign($val."state", ""); + + } else { + $smarty->assign("filter$val", ""); + + /* Same as above */ + if($_SESSION['js']==1){ + $smarty->assign($val."state", "disabled"); + }else{ + $smarty->assign($val."state", ""); + } + } + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $acl => $desc){ + $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly)); + $smarty->assign($acl."_W",$this->acl_is_writeable($acl,$this->ReadOnly)); + } + + /* Assign working time */ + $smarty->assign("starthour", (int)($this->gosaProxyWorkingStart / 60)); + $smarty->assign("startminute", (int)($this->gosaProxyWorkingStart % 60)); + $smarty->assign("stophour", (int)($this->gosaProxyWorkingStop / 60)); + $smarty->assign("stopminute", (int)($this->gosaProxyWorkingStop % 60)); + $hours= array(); + for($i=0; $i<24; $i++){ + $hours[]= sprintf("%02d",$i); + } + $smarty->assign("hours", $hours); + $smarty->assign("minutes", array("00","15","30","45")); + + /* Assign quota values */ + $smarty->assign("quota_unit", array("k" => _("KB"), "m" => _("MB"), "g" => _("GB"))); + $smarty->assign("quota_time", array("h" => _("hour"), "d" => _("day"), "w" => _("week"), "m" => _("month"))); + $smarty->assign("gosaProxyQuotaPeriod", $this->gosaProxyQuotaPeriod); + $smarty->assign("quota_size", preg_replace("/[a-z]$/i", "", $this->gosaProxyQuota)); + $smarty->assign("quota_u", preg_replace("/^[0-9]+/", "", $this->gosaProxyQuota)); + if ($this->is_account){ + $smarty->assign("proxyState", "checked"); + } else { + $smarty->assign("proxyState", ""); + } + + /* Prepare correct state */ + if (!$this->is_account){ + $smarty->assign("pstate", "disabled"); + } else { + $smarty->assign("pstate", ""); + } + + $changeA = ""; + + $ProxyWorkingStateChange ="\n"; + if($this->acl_is_writeable("gosaProxyFlagT")){ + $changeA .= "changeState('filterT');\n"; + + $ProxyWorkingStateChange.= "changeState('startHour'); \n"; + $ProxyWorkingStateChange.= "changeState('startMinute'); \n"; + $ProxyWorkingStateChange.= "changeState('stopHour'); \n"; + $ProxyWorkingStateChange.= "changeState('stopMinute'); \n"; + } + + if(preg_match("/F/",$this->gosaProxyAcctFlags)){ + $changeA .= $ProxyWorkingStateChange; + } + + $smarty->assign("ProxyWorkingStateChange",$ProxyWorkingStateChange); + + $changeB = ""; + if($this->acl_is_writeable("gosaProxyFlagB")){ + $changeA .= "changeState('filterB');"; + $changeB = + "changeSubselectState('filterB', 'quota_size'); + changeSubselectState('filterB', 'quota_unit'); + changeSubselectState('filterB', 'gosaProxyQuotaPeriod');"; + } + + $smarty->assign("changeB",$changeB); + $smarty->assign("changeA",$changeA); + + /* Show main page */ + $display.= $smarty->fetch(get_template_path('proxy.tpl', TRUE, dirname(__FILE__))); + return($display); + } + + function remove_from_parent() + { + if($this->acl_is_removeable() && $this->initially_was_account){ + + plugin::remove_from_parent(); + + $ldap= $this->config->get_ldap_link(); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* Log last action */ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/proxy account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove",array("uid" => $this->uid)); + } + } + + /* Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* We've got only one value to check for positive integer or emtpy field */ + if ($this->is_account){ + if($this->acl_is_writeable("gosaProxyQuota")){ + if (isset($_POST["quota_size"])){ + if ($_POST["quota_size"] == "gosaProxyQuota"){ + $message[]= _("Numerical value for Quota Setting is empty."); + }elseif ($_POST["quota_size"] <= 0){ + $message[]= _("Numerical value for Quota Setting is not valid."); + } + } + } + } + + return $message; + } + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['proxy'])){ + if (!$this->is_account && $_POST['proxy'] == "B"){ + if($this->acl_is_createable()){ + $this->is_account= TRUE; + } + } + } else { + if($this->acl_is_removeable()){ + $this->is_account= FALSE; + } + } + } + + /* Save flag value */ + if ($this->is_account){ + + $flags= ""; + $acl= ""; + foreach(array("F", "T", "B") as $key){ + if($this->acl_is_writeable("gosaProxyFlag".$key)){ + + /* Add acl */ + if (isset($_POST["filter$key"])){ + $flags.= $key; + } + }else{ + + /* Keep all flags that can't be written*/ + if(preg_match("/".$key."/",$this->gosaProxyAcctFlags)){ + $flags .=$key; + } + } + } + if ("[$flags]" != $this->gosaProxyAcctFlags){ + $this->is_modified= TRUE; + } + $this->gosaProxyAcctFlags= "[$flags]"; + + /* Save time values */ + if ($this->acl_is_writeable("gosaProxyFlagT")){ + if(isset($_POST['startMinute'])){ + $old= $this->gosaProxyWorkingStart; + $this->gosaProxyWorkingStart= $_POST["startHour"] * 60 + $_POST["startMinute"]; + $this->is_modified= ($old != $this->gosaProxyWorkingStart)?TRUE:$this->is_modified; + } + + if (isset($_POST['stopMinute'])){ + $old= $this->gosaProxyWorkingStop; + $this->gosaProxyWorkingStop = $_POST["stopHour"] * 60 + $_POST["stopMinute"]; + $this->is_modified= ($old != $this->gosaProxyWorkingStop)?TRUE:$this->is_modified; + } + } + + /* Save quota values */ + if ($this->acl_is_writeable("gosaProxyFlagB")){ + if(isset($_POST["quota_size"]) && isset($_POST["quota_unit"])){ + $this->gosaProxyQuota= $_POST["quota_size"].$_POST["quota_unit"]; + } + } + + /*Save quota period */ + if($this->acl_is_writeable("gosaProxyFlagB")){ + if(isset($_POST["gosaProxyQuotaPeriod"])){ + $this->gosaProxyQuotaPeriod = $_POST["gosaProxyQuotaPeriod"]; + } + } + } + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/proxy account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + + } + + /* Return plugin informations for acl handling + #FIME There possibly some attributes that can be combined to one acl. */ + static function plInfo() + { + return (array( + "plShortName" => _("Proxy"), + "plDescription" => _("Proxy account")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 21, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "gosaProxyFlagF" => _("Filter unwanted content"), + "gosaProxyFlagT" => _("Limit proxy access"), + "gosaProxyFlagB" => _("Restrict proxy usage by quota")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_pureftpdAccount.inc b/gosa-core/plugins/personal/connectivity/class_pureftpdAccount.inc new file mode 100644 index 000000000..68de2e881 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_pureftpdAccount.inc @@ -0,0 +1,256 @@ +attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + } + + function execute() + { + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + /* Load attributes */ + foreach($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + + + $tmp = $this->plInfo(); + $changeState = ""; + foreach($tmp['plProvidedAcls'] as $key => $desc){ + $smarty->assign($key."ACL", $this->getacl($key,$this->ReadOnly)); + $smarty->assign($key."_W", $this->acl_is_writeable($key,$this->ReadOnly)); + + if($this->acl_is_writeable($key)){ + $changeState.= " changeState('".$key."'); \n"; + } + } + $smarty->assign("changeState",$changeState); + + + $smarty->assign("fstate", ""); + if ($this->is_account){ + $smarty->assign("pureftpdState", "checked"); + $smarty->assign("fstate", ""); + } else { + $smarty->assign("pureftpdState", ""); + if($_SESSION['js']==1){ + if($this->acl!="#none#") + $smarty->assign("fstate", "disabled"); + }else{ + $smarty->assign("fstate", ""); + } + } + $smarty->assign("use_FTPStatus", ($this->FTPStatus == "disabled") ? "checked" : ""); + + if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) ){ + $smarty->assign('pureftpdACL', ""); + }else{ + $smarty->assign('pureftpdACL', " disabled "); + } + + $display.= $smarty->fetch (get_template_path('pureftpd.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){ + return; + } + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* Log last action */ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/pureftpd account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove',array("uid" => $this->uid)); + } + + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['pureftpd'])){ + if (!$this->is_account && $_POST['pureftpd'] == "B"){ + $this->is_account= TRUE; + } + } else { + $this->is_account= FALSE; + } + + plugin::save_object(); + + $old= $this->FTPStatus; + if (isset($_POST["FTPStatus"])){ + $this->FTPStatus = "disabled"; + } else { + $this->FTPStatus = "enabled"; + } + $this->is_modified= ($old != $this->FTPStatus)?TRUE:$this->is_modified; + + /* Ensure that these vars are numeric. Values starting with 0 like '0123' cause ldap errors */ + foreach(array("FTPQuotaFiles","FTPQuotaMBytes","FTPUploadRatio","FTPDownloadRatio","FTPUploadBandwidth","FTPDownloadBandwidth") as $testVar){ + $this->$testVar = (int) ($this->$testVar); + } + + + } + } + + + /* Check values */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* Check for positive integer values */ + if ($this->is_account){ + + if($this->acl_is_writeable("FTPUploadBandwidth") && !is_id($this->FTPUploadBandwidth)){ + $message[]= _("Value specified as 'Upload bandwidth' is not valid."); + } + if($this->acl_is_writeable("FTPDownloadBandwidth") && !is_id($this->FTPDownloadBandwidth)){ + $message[]= _("Value specified as 'Download bandwidth' is not valid."); + } + + if($this->acl_is_writeable("FTPQuotaFiles") && !is_id($this->FTPQuotaFiles)){ + $message[]= _("Value specified as 'Quota files' is not valid."); + } + if($this->acl_is_writeable("FTPQuotaMBytes") && !is_id($this->FTPQuotaMBytes)){ + $message[]= _("Value specified as 'Quota size' is not valid."); + } + if($this->acl_is_writeable("FTPUploadRatio") && !is_id($this->FTPUploadRatio)){ + $message[]= _("Value specified as 'Upload ratio' is not valid."); + } + if($this->acl_is_writeable("FTPDownloadRatio") && !is_id($this->FTPDownloadRatio)){ + $message[]= _("Value specified as 'Download ratio' is not valid."); + } + } + + return $message; + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $key => $desc){ + if(!$this->acl_is_writeable($key)){ + unset($this->attrs[$key]); + } + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/pureftpd account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + + } + + + /* Return plugin informations for acl handling + #FIME There possibly some attributes that can be combined to one acl. */ + static function plInfo() + { + return (array( + "plShortName" => _("Ftp"), + "plDescription" => _("Pure ftp account")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 22, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "FTPQuotaFiles" => _("Quota files"), + "FTPUploadRatio" => _("Upload ratio"), + "FTPQuotaMBytes" => _("Quota MBytes"), + "FTPDownloadRatio" => _("Download ratio"), + "FTPUploadBandwidth" => _("Upload bandwith"), + "FTPDownloadBandwidth" => _("Download bandwith"), + "FTPStatus" => _("Status")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/class_webdavAccount.inc b/gosa-core/plugins/personal/connectivity/class_webdavAccount.inc new file mode 100644 index 000000000..59fdb60ef --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/class_webdavAccount.inc @@ -0,0 +1,171 @@ +attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + } + + function execute() + { + /* Call parent execute */ +// plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + if ($this->is_account){ + $smarty->assign("webdavState", "checked"); + } else { + $smarty->assign("webdavState", ""); + $smarty->assign("wstate", "disabled"); + } + + if ($this->parent !== NULL){ + $smarty->assign("tabbed", 1); + } + + if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { + $smarty->assign('webdavAccountACL', ""); + }else{ + $smarty->assign('webdavAccountACL', " disabled "); + } + + $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + if($this->acl_is_createable() || $this->is_account){ + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* Log last action */ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/webDAV account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove',array("uid" => $this->uid)); + } + } + + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['webdav'])){ + if (!$this->is_account && $_POST['webdav'] == "B"){ + if($this->acl_is_createable()){ + $this->is_account= TRUE; + } + } + } else { + if($this->acl_is_removeable()){ + $this->is_account= FALSE; + } + } + } + + plugin::save_object(); + if (isset($_POST["WEBDAVStatus"])){ + $this->WEBDAVStatus = "disabled"; + } else { + $this->WEBDAVStatus = "enabled"; + } + } + + + /* Save to LDAP */ + function save() + { + if($this->acl_is_createable()){ + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/webDAV account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + } + } + + /* Return plugin informations for acl handling + #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */ + static function plInfo() + { + return (array( + "plShortName" => _("WebDAV"), + "plDescription" => _("WebDAV account")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 23, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array() + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/glpi.tpl b/gosa-core/plugins/personal/connectivity/glpi.tpl new file mode 100644 index 000000000..245b90303 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/glpi.tpl @@ -0,0 +1 @@ +

{if $tabbed eq 1}{/if}{t}GLPI account{/t}

diff --git a/gosa-core/plugins/personal/connectivity/intranet.tpl b/gosa-core/plugins/personal/connectivity/intranet.tpl new file mode 100644 index 000000000..f768285fe --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/intranet.tpl @@ -0,0 +1,4 @@ +

+ + {t}Intranet account{/t} +

diff --git a/gosa-core/plugins/personal/connectivity/kolab.tpl b/gosa-core/plugins/personal/connectivity/kolab.tpl new file mode 100644 index 000000000..8b7bd6ed1 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/kolab.tpl @@ -0,0 +1,104 @@ + +{if !$mail_account} +

{t}Kolab account{/t}

+ {t}The kolab account is currently disabled. It's features can be adjusted if you add a mail account.{/t} +{else} + + + + + + +{t}Kolab account{/t} +
+
+ + + + + + +
+
+{render acl=$kolabDelegateACL} + +{/render} +
+{render acl=$kolabDelegateACL} + +{/render} +{render acl=$kolabDelegateACL} +   +{/render} +{render acl=$kolabDelegateACL} + +{/render} +

+ {t}Mail size{/t}
+{render acl=$unrestrictedMailSizeACL} +   {t}No mail size restriction for this account{/t} +{/render} +

+
+   + + + {t}Free Busy information{/t}
+ + + + + + + + + +
+{render acl=$calFBURLACL} + +{/render} +
+{render acl=$kolabFreeBusyFutureACL} + + {t}days{/t} +{/render} +
+ + + {t}Invitation policy{/t}
+{render acl=$kolabInvitationPolicyACL} + + {$invitation} +
+{/render} + +
+ +{/if} diff --git a/gosa-core/plugins/personal/connectivity/main.inc b/gosa-core/plugins/personal/connectivity/main.inc new file mode 100644 index 000000000..14472f247 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/main.inc @@ -0,0 +1,124 @@ +dn); + sess_del ('edit'); + sess_del ('connectivity'); + } + + /* Create connectivity object on demand */ + if (!isset($_SESSION['connectivity']) || (isset($_GET['reset']) && + $_GET['reset'] == 1)){ + $_SESSION['connectivity']= new connectivity ($config, $ui->dn); + $_SESSION['connectivity']->enable_CSN_check(); + $_SESSION['connectivity']->set_acl_base($ui->dn); + $_SESSION['connectivity']->set_acl_category("users"); + + /* Adjust acl's to mode */ + foreach ($_SESSION['connectivity']->plugin_name as $name){ + $_SESSION['connectivity']->plugin[$name]->set_acl_category( "users"); + $_SESSION['connectivity']->plugin[$name]->set_acl_base($ui->dn); + } + } + $connectivity= $_SESSION['connectivity']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $connectivity->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if ((($username= get_lock($ui->dn)) != "") && (!isset($_SESSION['edit']))){ + $_SESSION['back_plugin']= $plug; + gen_locked_message ($username, $ui->dn); + exit (); + } + + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $connectivity->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $connectivity->save (); + del_lock ($ui->dn); + sess_del ('edit'); + + /* Remove from session */ + sess_del ('connectivity'); + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + $display= $connectivity->execute (); + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['connectivity']= $connectivity; + } + + $info= ""; + + $display.="
"; + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + $info.= "\"\""._("Click the 'Edit' button below to change informations in this dialog"); + $display.= "\n"; + $display.= "\n"; + } + $display.="
"; + + /* Page header*/ + $display= print_header(get_template_path('images/proxy.png'), + _("Connectivity"), $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/connectivity/opengw.tpl b/gosa-core/plugins/personal/connectivity/opengw.tpl new file mode 100644 index 000000000..568741719 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/opengw.tpl @@ -0,0 +1,59 @@ +

 {t}Opengroupware{/t}

+ + + + + +
+ + + + + + + + + + + + + +
+ {t}Location team{/t}   + +{render acl=$LocationTeamACL} + +{/render} +
+ {t}Template user{/t}   + +{render acl=$TemplateUserACL} + +{/render} +
+ {t}Locked{/t}   + +{render acl=$LockedACL} + +{/render} +
+
+ + + + + +
+ {t}Teams{/t}   + +{render acl=$TeamsACL} + {$validTeams} +{/render} +
+
diff --git a/gosa-core/plugins/personal/connectivity/oxchange.tpl b/gosa-core/plugins/personal/connectivity/oxchange.tpl new file mode 100644 index 000000000..2bd204907 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/oxchange.tpl @@ -0,0 +1,84 @@ +{if !$pg} +

{t}Open-Xchange Account{/t} - {t}disabled, no Postgresql support detected. Or the specified database can't be reached{/t}

+{else} +

+ +{t}Open-Xchange account{/t}

+ + + + + + + + + + +
+ + + + + + + + + + + + +
+ {t}Remember{/t} +
+ +{render acl=$OXAppointmentDaysACL} + +{/render} + {t}days{/t}
+ +{render acl=$OXTaskDaysACL} + +{/render} + + {t}days{/t} +
+
+   + + + + + + + + + + + + + +
+ {t}User Information{/t} +
+ +{render acl=$OXTimeZoneACL} + +{/render} + +
+
+{/if} diff --git a/gosa-core/plugins/personal/connectivity/phpgw.tpl b/gosa-core/plugins/personal/connectivity/phpgw.tpl new file mode 100644 index 000000000..299da6716 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/phpgw.tpl @@ -0,0 +1,4 @@ +

+ + {t}PHPGroupware account{/t} +

diff --git a/gosa-core/plugins/personal/connectivity/phpscheduleit.tpl b/gosa-core/plugins/personal/connectivity/phpscheduleit.tpl new file mode 100644 index 000000000..7e5510c3f --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/phpscheduleit.tpl @@ -0,0 +1,4 @@ +

+ + {t}PHPscheduleit account{/t} +

diff --git a/gosa-core/plugins/personal/connectivity/pptp.tpl b/gosa-core/plugins/personal/connectivity/pptp.tpl new file mode 100644 index 000000000..15d28a792 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/pptp.tpl @@ -0,0 +1,4 @@ +

+ + {t}PPTP account{/t} +

diff --git a/gosa-core/plugins/personal/connectivity/proxy.tpl b/gosa-core/plugins/personal/connectivity/proxy.tpl new file mode 100644 index 000000000..517823706 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/proxy.tpl @@ -0,0 +1,114 @@ +

+ + {t}Proxy account{/t}

+ + + + + +
+ + + + + + + +
+ +{render acl=$gosaProxyFlagFACL} + +{/render} + {t}Filter unwanted content (i.e. pornographic or violence related){/t} +
+ +{render acl=$gosaProxyFlagTACL} + +{/render} + + +
+ + + + +
+ +{render acl=$gosaProxyFlagTACL} + +{/render} +  :  +{render acl=$gosaProxyFlagTACL} + +{/render} +  -  +{render acl=$gosaProxyFlagTACL} + +{/render} +  :  +{render acl=$gosaProxyFlagTACL} + +{/render} +
+
+   + +{render acl=$gosaProxyFlagBACL} + +{/render} + +
+ + + + +
+{render acl=$gosaProxyFlagBACL} + +{/render} +   +{render acl=$gosaProxyFlagBACL} + +{/render} + + +{render acl=$gosaProxyFlagBACL} + +{/render} +
+
+
+ diff --git a/gosa-core/plugins/personal/connectivity/pureftpd.tpl b/gosa-core/plugins/personal/connectivity/pureftpd.tpl new file mode 100644 index 000000000..714ef787b --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/pureftpd.tpl @@ -0,0 +1,112 @@ +

+ + {t}FTP account{/t} +

+ + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ {t}Bandwidth{/t} +
{t}Upload bandwidth{/t} +{render acl=$FTPUploadBandwidthACL} + +{/render} + {t}kb/s{/t}
{t}Download bandwidth{/t} +{render acl=$FTPDownloadBandwidthACL} + +{/render} + {t}kb/s{/t}
+
+   + + + + + + + + + + + + + +
+ {t}Quota{/t} +
{t}Files{/t} +{render acl=$FTPQuotaFilesACL} + +{/render} +
{t}Size{/t} +{render acl=$FTPQuotaMBytesACL} + +{/render} + {t}MB{/t} +
+
+ + + + + + + + +
+ {t}Ratio{/t} +
{t}Uploaded / downloaded files{/t} + +{render acl=$FTPUploadRatioACL} + +{/render} + / +{render acl=$FTPDownloadRatioACL} + +{/render} +
+
+ + + + + + +
+ {t}Miscellaneous{/t} +
+{render acl=$FTPStatusACL} + +{/render} +{t}Temporary disable FTP access{/t}
+
+ + + diff --git a/gosa-core/plugins/personal/connectivity/webdav.tpl b/gosa-core/plugins/personal/connectivity/webdav.tpl new file mode 100644 index 000000000..ecd567cd3 --- /dev/null +++ b/gosa-core/plugins/personal/connectivity/webdav.tpl @@ -0,0 +1,4 @@ +

+ + {t}WebDAV account{/t} +

diff --git a/gosa-core/plugins/personal/environment/class_environment.inc b/gosa-core/plugins/personal/environment/class_environment.inc new file mode 100644 index 000000000..3d5de28c2 --- /dev/null +++ b/gosa-core/plugins/personal/environment/class_environment.inc @@ -0,0 +1,1367 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = FALSE; + var $plHeadline = "Environment"; + var $plDescription = "This does something"; + var $dialog = false; // Indicates that we are currently editing in an seperate dialog + + var $in_dialog = false; + var $uid = ""; + + var $is_group = false; + var $view_logged = FALSE; + + /* Attribute definition + */ + + /* profile management */ + var $useProfile = false; // Specifies if we want to use a Server + var $gotoProfileServer = ""; // Specifies the selected profile server + var $gotoProfileServers = array();// Specifies all available and selectable servers + var $gotoProfileFlags = ""; // Flags enabled ? only used to set ACL and save + var $gotoProfileFlagC = ""; // Flag is set to C if we have the profile caching fucntion enabled + + var $gotoXResolution = "auto"; // The selected resolution eg: 1024x768 + var $gotoXResolutions = array();// Contains all available resolutions for this account + var $gotoProfileFlagL = ""; // Flag is set to L to enable runtime resolution change + var $gotoProfileQuota = ""; // User Quota Settings + + /* Logon script section*/ + var $gotoLogonScripts = array();// Contains all available Logon Scripts + var $gotoLogonScript = ""; // The selected Logon Script + + /* Printer */ + var $gotoPrinter = array();// All available Printer, with their configurations + var $gotoPrinterSel = ""; // The selected Printer + var $gosaDefaultPrinter = ""; // Default printer + + /* Share */ + var $gotoShares = array();// Current Share Options + var $gotoShare = ""; // currently selected Share Option + var $gotoShareSelections= array();// Available Shares for this account in Listbox format + var $gotoAvailableShares= array();// Available Shares for this account + + /* Kiosk profile */ + var $kiosk_enabled = FALSE; + var $gotoKioskProfile = ""; // The selected Kiosk Profile + var $gotoKioskProfile_Server = ""; // The selected Kiosk Profile + var $gotoKioskProfile_Profile = ""; // The selected Kiosk Profile + var $gotoKioskProfiles = array();// All available Kiosk profiles + + /* Hotplug Devices */ + var $gotoHotplugDevice = array(); // Selected hotplug + var $gotoHotplugDevices = array();// Already configured hotplug devices + var $gotoHotplugDeviceDN= array(); + + var $NewAddedPrinters = array(); + var $NewDeletedPrinters = array(); + + /* general settings */ + // Sets the attributes which will kept on page reload, which will be saved, ... + + var $CopyPasteVars = array("gotoHotplugDevices","gotoAvailableShares","gotoShareSelections","gotoPrinterSel","gotoProfileFlagL","gotoXResolutions","gotoProfileFlagC","gotoProfileServers","useProfile","is_group","in_dialog","OrigCn","gotoKioskProfile_Server","gotoKioskProfile_Profile"); + + var $attributes = array("uid","gotoProfileServer","gotoProfileFlags","gotoHotplugDeviceDN", + "gotoXResolution","gotoProfileQuota", + "gotoLogonScripts","gotoLogonScript", + "gotoPrinter", "gosaDefaultPrinter", + "gotoShares","gotoShare", + "gotoKioskProfile"); + var $objectclasses = array("gotoEnvironment"); // Specifies the objectClass which contains the attributes edited here + var $cn; + var $OrigCn; + var $add_del_printer_member_was_called = false; + + function environment (&$config, $dn= NULL) + { + plugin::plugin ($config, $dn); + + /* Setting uid to default */ + if(isset($this->attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + /* Check : Are we currently editing a group or user dialog */ + if((isset($this->attrs['cn'][0]))&&(!isset($this->attrs['uid'][0]))){ + $suffix="Group"; + $this->uid = $this->attrs['cn'][0]; + $this->attrs['uid'] = $this->attrs['cn'][0]; + $this->OrigCn = $this->attrs['cn'][0]; + }else{ + $suffix="User"; + } + + /* Get all Printer assignments */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoPrinter)(goto".$suffix."Printer=".$this->uid."))",array("*")); + while($printer = $ldap->fetch()){ + $this->gotoPrinter[$printer['cn'][0]]=$printer; + $this->gotoPrinter[$printer['cn'][0]]['mode']="user"; + } + $ldap->search("(&(objectClass=gotoPrinter)(goto".$suffix."AdminPrinter=".$this->uid."))",array("*")); + while($printer = $ldap->fetch()){ + $this->gotoPrinter[$printer['cn'][0]]=$printer; + $this->gotoPrinter[$printer['cn'][0]]['mode']="admin"; + } + + + /* Prepare hotplugs */ + if(isset($this->attrs['gotoHotplugDeviceDN']) && is_array($this->attrs['gotoHotplugDeviceDN'])){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + for($i = 0 ; $i < $this->attrs['gotoHotplugDeviceDN']['count'] ; $i ++){ + $ldap->cat($this->attrs['gotoHotplugDeviceDN'][$i]); + if($ldap->count()){ + $attrs = $ldap->fetch(); + + if(isset($attrs['gotoHotplugDevice'][0])){ + $tmp = preg_split("/\|/",$attrs['gotoHotplugDevice'][0]); + $tmp2 = array(); + $tmp2['name'] = $attrs['cn'][0]; + $tmp2['description'] = $tmp[0]; + $tmp2['id'] = $tmp[1]; + $tmp2['produkt'] = $tmp[2]; + $tmp2['vendor'] = $tmp[3]; + $tmp2['dn'] = $attrs['dn']; + $this->gotoHotplugDevices[] = $tmp2; + } + }else{ + print_red(sprintf(_("The selected hotplug device %s is no longer available, it will be removed when you save this account."),$this->attrs['gotoHotplugDeviceDN'][$i])); + } + } + } + + + /* prepare LogonScripts */ + if((isset($this->attrs['gotoLogonScript']))&&(is_array($this->attrs['gotoLogonScript']))){ + unset($this->attrs['gotoLogonScript']['count']); + foreach($this->attrs['gotoLogonScript'] as $device){ + $tmp = $tmp2 = array(); + $tmp = split("\|",$device); + $tmp2['LogonName'] = $tmp[0]; + $tmp2['LogonPriority'] = $tmp[2]; + if(preg_match("/O/i",$tmp[1])){ + $tmp2['LogonOverload'] = "O"; + }else{ + $tmp2['LogonOverload'] = ""; + } + if(preg_match("/L/i",$tmp[1])){ + $tmp2['LogonLast'] = "L"; + }else{ + $tmp2['LogonLast'] = ""; + } + $tmp2['LogonData'] = base64_decode($tmp[3]); + $tmp2['LogonDescription'] = $tmp[4]; + $this->gotoLogonScripts[$tmp[0]]=$tmp2; + } + } + + /* Prepare Shares */ + if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){ + unset($this->attrs['gotoShare']['count']); + foreach($this->attrs['gotoShare'] as $share){ + $tmp = $tmp2 = array(); + $tmp = split("\|",$share); + $tmp2['server'] =$tmp[0]; + $tmp2['name'] =$tmp[1]; + + /* Decode base64 if needed */ + if (!preg_match('%/%', $tmp[2])){ + $tmp2['mountPoint'] =base64_decode($tmp[2]); + } else { + $tmp2['mountPoint'] =$tmp[2]; + } + + if(isset($tmp[3])){ + $tmp2['PwdHash'] =$tmp[3]; + }else{ + $tmp2['PwdHash'] =""; + } + if(isset($tmp[4])){ + $tmp2['Username'] =$tmp[4]; + }else{ + $tmp2['Username'] =""; + } + $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; + } + } + + for($i = 0 ; $i < strlen($this->gotoProfileFlags) ; $i ++){ + $chr = $this->gotoProfileFlags[$i]; + $name = "gotoProfileFlag".$chr; + $this->$name=$chr; + } + + if((!empty($this->gotoProfileServer))||($this->gotoProfileFlagC=="C")){ + $this->useProfile = true; + }else{ + $this->useProfile = false; + } + + /* Set resolutions */ + $this->gotoXResolutions = array("auto"=>_("auto"), + "640x480" => "640x480", + "800x600" => "800x600", + "1024x768" => "1024x768", + "1152x864" => "1152x864", + "1280x768" => "1280x768", + "1280x1024" => "1280x1024"); + + if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){ + $file = $this->config->data['MAIN']['RESOLUTION_HOOK']; + + if(is_readable($file)){ + $str = file_get_contents($file); + $lines = split("\n",$str); + foreach($lines as $line){ + $line = trim($line); + if(!empty($line)){ + $this->gotoXResolutions[$line]=$line; + } + } + //natcasesort($this->gotoXResolutions); + }else{ + print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file)); + } + } + + $this->gotoProfileServers= $config->getShareServerList() ; + $this->gotoShareSelections= $config->getShareList(true); + $this->gotoAvailableShares= $config->getShareList(false); + + $this->update_kiosk_profiles(); + + $this->gotoKioskProfile= preg_replace("/^.*\//i","",$this->gotoKioskProfile); + } + + + function update_kiosk_profiles() + { + $tmp1 = array("none" => array(_("disabled"))); + $tmp2 = array("none" => _("disabled")); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=goEnvironmentServer)(gotoKioskProfile=*)(cn=*))",array("cn","gotoKioskProfile")); + $cnt = 0; + while($attrs = $ldap->fetch()){ + for($i = 0 ; $i < $attrs['gotoKioskProfile']['count'] ; $i ++){ + $name = preg_replace("/^.*kiosk\//","",$attrs['gotoKioskProfile'][$i]); + $tmp1[$attrs['cn'][0]][] = $name; + } + $tmp2[$attrs['cn'][0]]= $attrs['cn'][0]; + $cnt ++; + } + + if($cnt && $this->config->search("environment","kioskpath",array('menu','tabs'))){ + $this->kiosk_enabled = TRUE; + } + + $this->gotoKioskProfiles['BY_SERVER'] = $tmp1; + $this->gotoKioskProfiles['SERVERS'] = $tmp2; + + $this->gotoKioskProfile_Server = preg_replace("/^.*:\/\/([^\/]*).*$/","\\1",$this->gotoKioskProfile); + $this->gotoKioskProfile_Profile= preg_replace("/^.*\//","",$this->gotoKioskProfile); + + $error = false; + if(!in_array($this->gotoKioskProfile_Server, $this->gotoKioskProfiles['SERVERS'])){ + $this->gotoKioskProfile_Server = key($this->gotoKioskProfiles['SERVERS']); + $error = true; + } + if(!in_array($this->gotoKioskProfile_Profile, $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server])){ + $this->gotoKioskProfile_Profile = $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server][0]; + $error = true; + } + if($error && !empty($this->gotoKioskProfile)){ + print_red(sprintf(_("The selected kiosk profile wasn't available anymore. The current profile is now 'none'."), + $this->gotoKioskProfile_Server,$this->gotoKioskProfile_Profile)); + } + } + + + /* Detect type of edited object (user|group)*/ + function detect_grouptype() + { + if((!isset($this->parent))&&(!$this->is_account)){ + $this->is_group = false; + }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){ + $this->is_group = true; + }else{ + $this->is_group = false; + } + } + + + function execute() + { + + /* Call parent execute */ + plugin::execute(); + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + if(isset($this->parent->by_object['user']) || (isset($this->attrs['objectClass']) &&in_array("gosaAccount",$this->attrs['objectClass']))){ + new log("view","users/".get_class($this),$this->dn); + }else{ + new log("view","groups/".get_class($this),$this->dn); + } + } + + /* Are we editing from MyAccount and not editing a user */ + $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']); + + /* Check profile server */ + if($this->acl_is_writeable("gotoProfileServer",$WriteOnly)){ + if(!empty($this->gotoProfileServer) && !isset($this->gotoProfileServers[$this->gotoProfileServer])){ + if(count($this->gotoProfileServers)){ + + /* Get First Profile */ + $new = key($this->gotoProfileServers); + + /* Another profile server found */ + print_red(sprintf(_("Your selected profile server '%s' is no longer available. Setting profile server to '%s'."), + $this->gotoProfileServer,$new)); + }else{ + + /* No other profile servers found */ + print_red(sprintf(_("Your selected profile server '%s' is no longer available. Profile server configuration is resetted."), + $this->gotoProfileServer)); + $this->gotoProfileServer = ""; + } + } + } + + $this->detect_grouptype(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $smarty->assign("kiosk_enabled",$this->kiosk_enabled); + $display= ""; + + $smarty->assign("is_group",$this->is_group); + + /* Prepare all variables for smarty */ + foreach($this->attributes as $s_attr){ + /* Set value*/ + $smarty->assign($s_attr,$this->$s_attr); + + /* Set checkbox state*/ + if(empty($this->$s_attr)){ + $smarty->assign($s_attr."CHK",""); + }else{ + $smarty->assign($s_attr."CHK"," checked "); + } + + /* Prepare ACL settings*/ + $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly)); + } + + /* Is accout enabled | are we editing from usermenu or admin menu + All these tab management is done here + */ + + + /* Working from Usermenu an the Account is currently disbled + * this->parent : is only set if we are working in a list of tabs + * is_account : is only true if the needed objectClass is given + */ + if((!isset($this->parent))&&(!$this->is_account)){ + /* We are currently editing this tab from usermenu, but this account is not enabled */ + $smarty->assign("is_account",$this->is_account); + /* Load template */ + $display .= $smarty->fetch(get_template_path('environment.tpl', TRUE)); + /* Avoid the "You are currently editing ...." message when you leave this tab */ + $display .= back_to_main(); + /* Display our message to the user */ + return $display; + + + /* We are currently editing from group tabs, because + * $this->parent is set + * posixAccount is not set, so we are not in usertabs. + */ + }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){ + $smarty->assign("is_account","true"); + $this->uid = $this->cn; + $this->attrs['uid'] = $this->cn; + + /* Change state if needed */ + if (isset($_POST['modify_state'])){ + if(($this->acl_is_createable() && !$this->is_account) || + ($this->acl_is_removeable() && $this->is_account)){ + $this->is_account= !$this->is_account; + } + } + /* Group Dialog with enabled environment options */ + if ($this->is_account){ + $display= $this->show_enable_header(_("Remove environment extension"), + _("Environment extension enabled. You can disable it by clicking below.")); + } else { + + /* Environment is disabled + If theres is no posixAccount enabled, you won't be able to enable + environment extensions + */ + if((isset($this->parent->by_object['group']))||(isset($this->attrs['objectClass']))&&((in_array("posixAccount",$this->attrs['objectClass'])))){ + // 4. There is a PosixAccount + $display= $this->show_enable_header(_("Add environment extension"), + _("Environment extension disabled. You can enable it by clicking below.")); + return $display; + }else{ + // 4. There is no PosixAccount + $display= $this->show_enable_header(_("Add environment extension"), + _("Environment extension disabled. You have to setup a posix account before you can enable this feature.")); + return $display; + } + } + }else{ + /* Editing from Usermenu + * Tell smarty that this accoutn is enabled + */ + $smarty->assign("is_account","true"); + + /* Change state if needed */ + if (isset($_POST['modify_state'])){ + if(($this->acl_is_createable() && !$this->is_account) || + ($this->acl_is_removeable() && $this->is_account)){ + $this->is_account= !$this->is_account; + } + } + + if(isset($this->parent)){ + + // 3. Account enabled . Editing from adminmenu + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove environment extension"), + _("Environment extension enabled. You can disable it by clicking below.")); + } else { + + if($this->parent->by_object['posixAccount']->is_account==true){ + // 4. There is a PosixAccount + $display= $this->show_disable_header(_("Add environment extension"), + _("Environment extension disabled. You can enable it by clicking below.")); + return $display; + }else{ + // 4. There is a PosixAccount + $display= $this->show_disable_header(_("Add environment extension"), + _("Environment extension disabled. You have to setup a posix account before you can enable this feature."),TRUE,TRUE); + return $display; + } + } + } + } + /* Account is Account : is_accounbt=true. + * Else we won't reach this. + */ + + /* Prepare all variables for smarty */ + foreach($this->attributes as $s_attr){ + /* Set value*/ + $smarty->assign($s_attr,$this->$s_attr); + + /* Set checkbox state*/ + if(empty($this->$s_attr)){ + $smarty->assign($s_attr."CHK",""); + }else{ + $smarty->assign($s_attr."CHK"," checked "); + } + + /* Prepare ACL settings*/ + $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly)); + } + + foreach(array("gotoHotplugDevice","gotoProfileFlagC","gotoProfileFlagL") as $s_attr){ + $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly)); + } + + if($WriteOnly) { + $smarty->assign("gotoPrinterACL","r"); + }else{ + $smarty->assign("gotoPrinterACL","rw"); + } + + if(empty($this->useProfile)){ + $smarty->assign("useProfileCHK",""); + $smarty->assign("gotoProfileServerACL" , preg_replace("/w/","",$this->getacl("gotoProfileServer",$WriteOnly))); + $smarty->assign("gotoProfileQuotaACL" , preg_replace("/w/","",$this->getacl("gotoProfileQuota",$WriteOnly))); + $smarty->assign("gotoProfileFlagCACL" , preg_replace("/w/","",$this->getacl("gotoProfileFlagC",$WriteOnly))); + }else{ + $smarty->assign("useProfileCHK"," checked "); + } + + $smarty->assign("gotoProfileServerWriteable", $this->acl_is_writeable("gotoProfileServer",$WriteOnly)); + $smarty->assign("gotoProfileACL", $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly)); + + /* HANDLE Profile Settings here + * Assign available Quota and resolution settings + * Get all available profile server + * Get cache checkbox + * Assign this all to Smarty + */ + + if(empty($this->gotoProfileFlagL)){ + $smarty->assign("gotoProfileFlagLCHK"," "); + }else{ + $smarty->assign("gotoProfileFlagLCHK"," checked "); + } + + if(empty($this->gotoProfileFlagC)){ + $smarty->assign("gotoProfileFlagCCHK"," "); + }else{ + $smarty->assign("gotoProfileFlagCCHK"," checked "); + } + + + $smarty->assign("gotoXResolutions" , $this->gotoXResolutions); + $smarty->assign("gotoXResolutionKeys" , array_flip($this->gotoXResolutions)); + + $smarty->assign("gotoProfileServers",$this->gotoProfileServers); + if(!is_array($this->gotoProfileServers)){ + $this->gotoProfileServers =array(); + } + $smarty->assign("gotoProfileServerKeys",array_flip($this->gotoProfileServers)); + + /* Handle kiosk profiles*/ + $smarty->assign("kiosk_servers" , $this->gotoKioskProfiles['SERVERS']); + $smarty->assign("kiosk_server" , $this->gotoKioskProfile_Server); + $smarty->assign("kiosk_profiles" , $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server]); + $smarty->assign("kiosk_profile" , $this->gotoKioskProfile_Profile); + + + /* Logonscript Management + * Get available LogonScripts (possibly grey out (or mark) these script that are defined for the group) + * Perform add Delete edit Posts + */ + + /* Dialog Save */ + if(isset($_POST['LogonSave'])){ + + if(!$this->acl_is_writeable("gotoLogonScript")){ + print_red(_("You are not allowed to write Logon scripts.")); + unset($this->dialog); + $this->dialog=FALSE; + $this->is_dialog=false; + }else{ + $this->dialog->save_object(); + if(count($this->dialog->check())!=0){ + foreach($this->dialog->check() as $msg){ + print_red($msg); + } + }else{ + $tmp = $this->dialog->save(); + unset($this->dialog); + $this->dialog=FALSE; + $this->is_dialog=false; + $this->gotoLogonScripts[$tmp['LogonName']]=$tmp; + } + } + } + + + /* Dialog Quit without saving */ + if(isset($_POST['LogonCancel'])){ + $this->is_dialog= false; + unset($this->dialog); + $this->dialog= FALSE; + } + + /* Check Edit Del New Posts for a selected LogonScript */ + if($this->acl_is_writeable("gotoLogonScript") && + (isset($_POST['gotoLogonScriptNew'])) || isset($_POST['gotoLogonScriptEdit']) ||isset($_POST['gotoLogonScriptDel'])){ + + /* New Logon Script: Open an edit dialog, we don't need a $_POST['gotoLogonScript'] here. + * In this case we create a new Logon Script. + */ + if(isset($_POST['gotoLogonScriptNew'])){ + $this->is_dialog = true; + $this->dialog = new logonManagementDialog($this->config,$this->dn); + } + + /* If we receive a Delete request and there is a Script selected in the selectbox, delete this one. + * We only can delete if there is an entry selected. + */ + if((isset($_POST['gotoLogonScriptDel']))&&(isset($_POST['gotoLogonScript']))){ + unset($this->gotoLogonScripts[$_POST['gotoLogonScript']]); + } + + /* In this case we want to edit an existing entry, we open a new Dialog to allow editing. + * There must be an entry selected to perform edit request. + */ + if((isset($_POST['gotoLogonScriptEdit']))&&(isset($_POST['gotoLogonScript']))){ + $is_entry = $this->gotoLogonScripts[$_POST['gotoLogonScript']]; + $this->is_dialog = true; + $this->dialog = new logonManagementDialog($this->config,$this->dn,$is_entry); + } + } + + /* Append List to smarty*/ + $ls = $this->printOutLogonScripts(); + $smarty->assign("gotoLogonScripts", $ls); + $smarty->assign("gotoLogonScriptKeys",array_flip($ls)); + $smarty->assign("gotoLogonScriptKeysCnt",count($ls)); + + /* In this section server shares will be defined + * A user can select one of the given shares and a mount point + * and attach this combination to his setup. + */ + + $smarty->assign("gotoShareSelections", $this->gotoShareSelections); + if(!is_array($this->gotoShareSelections)){ + print $this->gotoShareSelections; + $this->gotoShareSelections = array(); + } + $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections)); + + /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry + * This entry will be, a combination of mountPoint and sharedefinitions + */ + if(isset($_POST['gotoShareAdd']) && $this->acl_is_writeable("gotoShare")){ + + /* We assign a share to this user, if we don't know where to mount the share */ + if(!isset($_POST['gotoShareSelection']) || get_post('gotoShareSelection') == ""){ + print_red(_("You must select a valid share.")); + }elseif((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){ + print_red(_("You must specify a valid mount point.")); + }elseif(preg_match('/ /', $_POST['gotoShareMountPoint'])){ + print_red(_("Spaces are not allowed in the mount path!")); + }elseif(!( + preg_match("/^\//",$_POST['gotoShareMountPoint']) || + preg_match("/^~/",$_POST['gotoShareMountPoint']) || + preg_match("/^\$HOME/",$_POST['gotoShareMountPoint']) || + preg_match("/^.HOME/",$_POST['gotoShareMountPoint']) || + preg_match("/^\$USER/",$_POST['gotoShareMountPoint']) || + preg_match("/^.USER/",$_POST['gotoShareMountPoint']) || + preg_match("/^%/",$_POST['gotoShareMountPoint']) + ) + ){ + print_red(_("You must specify a valid mount point.")); + }else{ + $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']]; + $s_mount = $_POST['gotoShareMountPoint']; + $s_user = $_POST['ShareUser']; + /* Preparing the new assignment */ + $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share; + $this->gotoShares[$a_share['name']."|".$a_share['server']]['Username']=$s_user; + $this->gotoShares[$a_share['name']."|".$a_share['server']]['PwdHash']=""; + $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount; + } + } + + /* if the Post gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected) + * If there is no defined share selected, we will abort the deletion without any message + */ + $once = true; + if($this->acl_is_writeable("gotoShare")){ + foreach($_POST as $name => $value){ + if((preg_match("/^gotoShareDel_/",$name)) && ($once)){ + $once = false; + $key = preg_replace("/^gotoShareDel_/","",$name); + $key = preg_replace("/_+[xy]$/","",$key); + $key = base64_decode($key); + if(isset($this->gotoShares[$key])) { + unset($this->gotoShares[$key]); + } + + /* Remove corresponding password entry, too. This is a workaround + to get rid of old-style entries. */ + $key= preg_replace("/\|/", "|!", $key); + if(isset($this->gotoShares[$key])) { + unset($this->gotoShares[$key]); + } + } + if((preg_match("/^gotoShareResetPwd_/",$name)) && ($once)){ + $once = false; + $key = preg_replace("/^gotoShareResetPwd_/","",$name); + $key = preg_replace("/_+[xy]$/","",$key); + $key = base64_decode($key); + $this->gotoShares[$key]['PwdHash'] = ""; + if(preg_match("/^!/",$this->gotoShares[$key]['server'])){ + unset($this->gotoShares[$key]); + } + } + } + } + $divlistShares = new divSelectBox("gotoShares"); + $divlistShares->SetHeight(100); + + + $tmp = array(); + if($this->acl_is_readable("gotoShares")){ + $tmp = $this->printOutAssignedShares(); + } + + + foreach($tmp as $key => $value){ + $img = ""; + + /* Skip apssword only entries */ + if( empty($this->gotoShares[$key]['server']) && + empty($this->gotoShares[$key]['name']) && + empty($this->gotoShares[$key]['mountPoint']) && + empty($this->gotoShares[$key]['Username'])){ + continue; + } + + /* Check if entry starts with an ! */ + if(preg_match("/^!/",$this->gotoShares[$key]['server'])){ + + /* If we are currently editing groups environment, skip those ! entries */ + if($this->is_group) continue; + + /* Create pwd reset images */ + if($this->gotoShares[$key]['PwdHash'] != ""){ + $img.= ""; + } + $field1 = array("string" => "".$value."" ); + $field2 = array("string" => $img , "attach" => "style='border-right:0px;'"); + }else{ + + /* Create pwd reset img && delete image */ + if($this->gotoShares[$key]['PwdHash'] != ""){ + $img.= ""; + $img.= " "; + } + $img.= ""; + $field1 = array("string" => $value); + $field2 = array("string" => $img , "attach" => "style='border-right:0px;'"); + } + $divlistShares->AddEntry(array($field1,$field2)); + } + $smarty->assign("divlistShares",$divlistShares->DrawList()); + + /* Hotplug devices will be handled here + * There are 3 possible methods for this feature + * Create a new Hotplug, A Dialog will open where you can specify some hotplug information + * Delete will erase an entry, the entry must be selcted in the ListBox first + * Editing an entry will open a dialog where the informations about the selcted entry can be changed + */ + + /* We have to delete the selected hotplug from the list*/ + if((isset($_POST['gotoHotplugDeviceDel']))&&(isset($_POST['gotoHotplugDevice_post'])) && $this->acl_is_writeable("gotoHotplugDevice")){ + if($this->acl_is_writeable("gotoHotplugDevice")){ + foreach($_POST['gotoHotplugDevice_post'] as $name){ + unset($this->gotoHotplugDevices[$name]); + } + } + } + + /* There are already defined hotplugs from other users we could use */ + if(isset($_POST['gotoHotplugDeviceUse']) && $this->acl_is_writeable("gotoHotplugDevice")){ + $tmp =array(); + foreach($this->gotoHotplugDevices as $plugs){ + $tmp[] = $plugs['name']; + } + $this->dialog = new hotplugDialog($this->config,$tmp); + $this->is_dialog = true; + } + + /* Dialog Aborted */ + if(isset($_POST['HotPlugCancel'])){ + unset($this->dialog); + $this->dialog= FALSE; + $this->is_dialog = false; + } + + /* Dialod saved */ + if(isset($_POST['HotPlugSave'])){ + + $this->dialog->save_object(); + if(count($this->dialog->check())!=0){ + foreach($this->dialog->check() as $msg){ + print_red($msg); + } + }else{ + $this->dialog->save_object(); + $a_tmp = $this->dialog->save(); + + if(is_array($a_tmp)){ + foreach($a_tmp as $name => $hotplug){ + $this->gotoHotplugDevices[$name]= $hotplug; + } + } + unset($this->dialog); + $this->dialog= FALSE; + $this->is_dialog = false; + } + } + $smarty->assign("gotoHotplugDevices",$this->printOutHotPlugDevices()); + $smarty->assign("gotoHotplugDeviceKeys",array_flip($this->printOutHotPlugDevices())); + + /* Printer Assignment will managed below + * A printer can be assigned in two different ways and two different types + * There are 2 types of users assigned to a printer : user and admin + * They only differ in the member attribute they will be assigned to. user: gotoUserPrinter admin: gotoadminPrinter + * The different types of assigning a user are : 1 assigning a user to a printer 2. assigning a group to a printer + */ + + /* First handle Add Post. Open a dialog that allows us to select a printer or two */ + if(isset($_POST['gotoPrinterAdd'])){ + + $this->is_dialog=true; + $this->dialog = new selectPrinterDialog($this->config,$this->dn,$this->gotoPrinter); + } + + if(isset($_POST['PrinterCancel'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=FALSE; + } + + if(isset($_POST['PrinterSave'])){ + if(count($this->dialog->check())!=0){ + $tmp = $this->dialog->check(); + foreach($tmp as $msg){ + print_red($msg); + } + }else{ + $this->dialog->save_object(); + $tmp = $this->dialog->save(); + $tmp2= $this->dialog->getPrinter(true); + + foreach($tmp as $pname){ + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn'],"printer"); + $printerObj->set_acl_base($tmp2[$pname]['dn']); + + $type = false; + + if($this->is_group){ + if($this->dn == "new"){ + $type = "AddGroup"; + }elseif(isset($this->NewDeletedPrinters[$pname])){ + $type = "AddGroup"; + }elseif($printerObj->by_object['printgeneric']->AddMember("AddGroup",$this->dn)){ + $type = "AddGroup"; + } + }else{ + if(isset($this->NewDeletedPrinters[$pname])){ + $type = "AddUser"; + }elseif($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){ + $type = "AddUser"; + } + } + + if($type){ + $this->gotoPrinter[$pname]=$tmp2[$pname]; + $this->gotoPrinter[$pname]['mode']="user"; + $this->add_del_printer_member_was_called = true; + + $this->NewAddedPrinters[$pname] = $pname; + if(isset($this->NewDeletedPrinters[$pname])){ + unset($this->NewDeletedPrinters[$pname]); + } + } + } + + $this->is_dialog=false; + unset($this->dialog); + $this->dialog =FALSE; + } + } + + if((isset($_POST['gotoPrinterDel']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){ + $printer = $_POST['gotoPrinterSel']; + foreach($printer as $pname){ + + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$this->gotoPrinter[$pname]['dn'],"printer"); + $printerObj->set_acl_base($this->gotoPrinter[$pname]['dn']); + + $type = false; + if($this->is_group){ + if(isset($this->NewAddedPrinters[$pname])){ + $type = "Group"; + }elseif($printerObj->by_object['printgeneric']->DelMember("AddGroup",$this->cn)){ + $type = "Group"; + } + }else{ + if(isset($this->NewAddedPrinters[$pname])){ + $type = "User"; + }elseif($printerObj->by_object['printgeneric']->DelMember("AddUser",$this->uid)){ + $type = "User"; + } + } + if($type){ + $this->add_del_printer_member_was_called = true; + unset($this->gotoPrinter[$pname]); + + $this->NewDeletedPrinters[$pname] = $pname; + if(isset($this->NewAddedPrinters[$pname])){ + UNSET($this->NewAddedPrinters[$pname]); + } + } + } + } + + if((isset($_POST['gotoPrinterEdit']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){ + $printers = $_POST['gotoPrinterSel']; + $this->add_del_printer_member_was_called = true; + foreach($printers as $printer){ + if($this->gotoPrinter[$printer]['mode']=="user"){ + $this->gotoPrinter[$printer]['mode']="admin"; + }else{ + $this->gotoPrinter[$printer]['mode']="user"; + } + } + } + + if((isset($_POST['gotoPrinterDefault']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){ + if($this->is_group){ + print_red(_("GOsa default printer flag is not allowed within groups.")); + }else{ + if ($this->gosaDefaultPrinter == $_POST['gotoPrinterSel'][0]){ + $this->gosaDefaultPrinter= ""; + } else { + $this->gosaDefaultPrinter= $_POST['gotoPrinterSel'][0]; + } + } + } + + $smarty->assign("gotoPrinter",$this->printOutPrinterDevices()); + $smarty->assign("gotoPrinterKeys",array_flip($this->printOutPrinterDevices())); + + /* General behavior */ + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $disp =$this->dialog->execute(); + return($disp); + } + + /* Als smarty vars are set. Get smarty template and generate output */ + $display.= $smarty->fetch(get_template_path('environment.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + function remove_from_parent() + { + /* only if it was an account*/ + if (!$this->initially_was_account){ + return; + } + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + /* Don't save our template variables */ + $skip = array("uid","gotoLogonScripts","gotoPrinter","gotoShares","gotoHotplugDevices" ); + + /* Skip all these attributes */ + foreach($skip as $del){ + unset($this->attrs[$del]); + } + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save"); + + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + if($this->is_group){ + new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/environment account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove",array("uid" => $this->uid)); + } + + + /* Save data to object */ + function save_object() + { + /* Get all Posted vars + * Setup checkboxes + */ + $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']); + if(isset($_POST['iamposted'])){ + + $PACL = $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly); + + if(isset($_POST['kiosk_server'])){ + $tmp = $_POST['kiosk_server']; + if(isset($this->gotoKioskProfiles['SERVERS'][$tmp])){ + $this->gotoKioskProfile_Server = $_POST['kiosk_server']; + } + } + if(isset($_POST['kiosk_profile'])){ + $tmp = $_POST['kiosk_profile']; + if(in_array($tmp,$this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server])){ + $this->gotoKioskProfile_Profile = $_POST['kiosk_profile']; + } + } + + if(preg_match("/w/",$PACL)){ + if(isset($_POST['useProfile'])){ + $this->useProfile = true; + }else{ + $this->useProfile = false; + } + } + + if($this->acl_is_writeable("gotoProfileFlagC")){ + if(isset($_POST['gotoProfileFlagC'])){ + $this->gotoProfileFlagC = $_POST['gotoProfileFlagC']; + }else{ + $this->gotoProfileFlagC = false; + } + } + + if($this->acl_is_writeable("gotoProfileFlagL")){ + if(isset($_POST['gotoProfileFlagL'])){ + $this->gotoProfileFlagL = $_POST['gotoProfileFlagL']; + }else{ + $this->gotoProfileFlagL = false; + } + } + + plugin::save_object(); + foreach($this->attributes as $s_attr){ + if((!isset($_POST[$s_attr])) || + in_array($s_attr,array("gosaDefaultPrinter","gotoShares","gotoHotplugDevices","gotoPrinter","gotoLogonScripts","uid"))) continue; + if(!$this->acl_is_writeable($s_attr)){ + continue; + }else{ + if(isset($_POST[$s_attr])){ + $this->$s_attr = $_POST[$s_attr]; + }else{ + $this->$s_attr = false; + } + } + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + $this->detect_grouptype(); + + if(preg_match("/[^0-9]/",$this->gotoProfileQuota)) { + $message[]=_("Please set a valid profile quota size."); + } + if(!isset($this->attrs['objectClass'])){ + $this->attrs['objectClass']=array(); + } + if(!$this->is_group){ + if((!((in_array("posixAccount",$this->attrs['objectClass']))||($this->parent->by_object['posixAccount']->is_account==true)))&&(!$this->is_group)){ + $message[]=(_("You need to setup a valid posix extension in order to enable evironment features.")); + } + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* If group was renamed, all printer settings get lost + */ + /* only save changed variables ....*/ + if ($this->gotoKioskProfile_Server != "none"){ + if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ + $method="https://".$this->gotoKioskProfile_Server."/kiosk/".$this->gotoKioskProfile_Profile; + }else{ + $method="http://".$this->gotoKioskProfile_Server."/kiosk/".$this->gotoKioskProfile_Profile; + } + $this->gotoKioskProfile= $method; + }else{ + $this->gotoKioskProfile= array(); + } + + plugin::save(); + $ldap= $this->config->get_ldap_link(); + + $realyUsedAttrs= array(); + + /* Save already used objectClasses */ + $ocs = $this->attrs['objectClass']; + unset($ocs['count']); + $this->attrs = array(); + $this->attrs['objectClass']= gosa_array_merge($ocs,$this->objectclasses); + + /* 1. Search all printers that have our uid/cn as member + * 2. Delete this uid/cn from every single entry and save it again. + * 2.1 There are different types of members: Users / Groups, this will be defined in $suffix + * 2.2 And each type has two modes, Admin (e.g. 'gotoUserAdminPrinter') and Normal + */ + + $this->detect_grouptype(); + + if($this->add_del_printer_member_was_called){ + + $types = array( "gotoUserPrinter" => "AddUser", + "gotoGroupPrinter" => "AddGroup", + "gotoUserAdminPrinter" => "AddAdminUser", + "gotoGroupAdminPrinter" => "AddAdminGroup"); + + if($this->is_group){ + $s_suffix = "Group"; + $useVar = "cn"; + }else{ + $useVar = "uid"; + $s_suffix = "User"; + } + + /* Remove old entries */ + $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->$useVar."))",array("*")); + while($attr = $ldap->fetch()){ + $printerObj = NULL; + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer"); + $printerObj->set_acl_base($attr['dn']); + $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->$useVar); + $printerObj->by_object['printgeneric']->save(); + } + + $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->$useVar."))",array("*")); + while($attr = $ldap->fetch()){ + $printerObj = NULL; + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer"); + $printerObj->set_acl_base($attr['dn']); + $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->$useVar); + $printerObj->by_object['printgeneric']->save(); + } + + foreach($this->gotoPrinter as $printer){ + $printerObj = NULL; + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn'],"printer"); + $printerObj->set_acl_base($printer['dn']); + + + if($printer['mode'] == "admin") { + $attribute = "goto".$s_suffix."AdminPrinter"; + }else{ + $attribute = "goto".$s_suffix."Printer"; + } + + $printerObj->by_object['printgeneric']->AddMember($types[$attribute],$this->dn); + $printerObj->by_object['printgeneric']->save(); + } + } + + /* Prepare HotPlug devices */ + $this->attrs['gotoHotplugDeviceDN'] = array(); + foreach($this->gotoHotplugDevices as $name => $device){ + $this->attrs['gotoHotplugDeviceDN'][]= $device['dn']; + } + + /* Prepare LogonScripts */ + $this->attrs['gotoLogonScript'] = array(); + foreach($this->gotoLogonScripts as $name => $script){ + $this->attrs['gotoLogonScript'][] = $script['LogonName']."|". + $script['LogonOverload'].$script['LogonLast']."|". + $script['LogonPriority']."|". + base64_encode($script['LogonData'])."|". + $script['LogonDescription']; + } + + /* Prepare Shares */ + $this->attrs['gotoShare']=array(); + foreach($this->gotoShares as $name => $share){ + $mntp= $share['mountPoint']; + if (!preg_match('=^[a-z0-9+\._/%-]+$=i', $mntp)){ + $mntp= base64_encode($mntp); + } + $this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$mntp."|".$share['PwdHash']."|".$share['Username']; + } + + + if($this->gotoXResolution == "auto") $this->gotoXResolution =""; + $saveThis = array("gotoProfileQuota","gotoXResolution","gotoProfileServer","gotoKioskProfile","gosaDefaultPrinter"); + + foreach($saveThis as $tosave){ + if(!empty($this->$tosave)){ + $this->attrs[$tosave]=$this->$tosave; + }else{ + $this->attrs[$tosave]=array(); + } + } + + /* Prepare Flags */ + $this->attrs['gotoProfileFlags'] = array($this->gotoProfileFlagC.$this->gotoProfileFlagL); + if(empty($this->attrs['gotoProfileFlags'][0])){ + $this->attrs['gotoProfileFlags']=array(); + } + + if($this->useProfile == false){ + $this->attrs['gotoProfileFlags'] = preg_replace("/C/i","",$this->attrs['gotoProfileFlags']); + $this->attrs['gotoProfileServer']= array(); + } + + $ldap->cat ($this->dn, array('dn')); + if ($ldap->fetch()){ + $mode= "modify"; + } else { + $mode= "add"; + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + } + + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->$mode($this->attrs); + + $cat = "users"; + if($this->is_group){ + $cat = "groups"; + } + + /* Log last action */ + if($this->initially_was_account){ + new log("modify",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/environment account with dn '%s' failed."),$this->dn)); + $this->handle_post_events($mode,array("uid"=>$this->uid)); + } + + /* Generate ListBox frindly output for the defined shares + * Possibly Add or remove an attribute here, + */ + function printOutAssignedShares() + { + $a_return = array(); + if(is_array($this->gotoShares)){ + foreach($this->gotoShares as $share){ + if(preg_match("/^!/",$share['server'])){ + $a_return[$share['name']."|".$share['server']]= preg_replace("/^!/","",$share['server'])."://".$share['name']." - "._("group share"); + }else{ + $a_return[$share['name']."|".$share['server']]= $share['server']."://".$share['name']." on ".$share['mountPoint']." as ".$share['Username']; + } + } + natcasesort($a_return); + } + return($a_return); + } + + /* Generate ListBox frindly output for the definedhotplugs + * Possibly Add or remove an attribute here, + */ + function printOutHotPlugDevices() + { + $a_return= array(); + if(is_array($this->gotoHotplugDevices)){ + foreach($this->gotoHotplugDevices as $key=>$device){ + $a_return[$key] = $device['name']." - ".$device['id']; + } + } + return($a_return); + } + + /* Generates ListBox frienly output of used printer devices + * Append ' - admin' if printer is used in admin mode + */ + function printOutPrinterDevices() + { + $a_return = array(); + + if($this->acl_is_readable("gotoPrinter")){ + + if(is_array($this->gotoPrinter)){ + foreach($this->gotoPrinter as $printer){ + if($printer['mode'] == "admin"){ + $a_return[$printer['cn'][0]]= $printer['cn'][0]." - "._("Administrator"); + }else{ + $a_return[$printer['cn'][0]]= $printer['cn'][0]; + } + if ($printer['cn'][0] == $this->gosaDefaultPrinter){ + $a_return[$printer['cn'][0]].=" - "._("Default printer"); + } + } + } + } + return($a_return); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $class= get_class($this); + $o_source = new $class($this->config,$source['dn']); + foreach($this->CopyPasteVars as $attr){ + $this->$attr = $o_source->$attr; + } + } + + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + $this->uid = $_POST['cn']; + } + } + + + /* Generates ListBox frienly output of used logonscripts + */ + function printOutLogonScripts() + { + $a_return = array(); + if(is_array($this->gotoLogonScripts)){ + foreach($this->gotoLogonScripts as $script){ + $a_return[$script['LogonName']]= $script['LogonPriority']." - ".$script['LogonName']; + } + } + return($a_return); + } + + + /* Return plugin informations for acl handling +#FIXME these ACLs should work for groups too */ + static function plInfo() + { + return (array("plShortName" => _("Environment"), + "plDescription" => _("Environment settings"), // Description + "plSelfModify" => TRUE, + "plDepends" => array("user", "posixAccount"), // This plugin depends on + "plPriority" => 3, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users", + "groups"), + "plOptions" => array("resolution_hook" => array("type" => "string", + "description" => _("Command to extend the list of possible screen resolutions"))), + + "plProvidedAcls" => array( + + "gotoProfileFlagL" => _("Resolution changeable during session") , + "gotoProfileFlagC" => _("Cache profile localy") , + + "gotoProfileQuota" => _("Profile quota") , + "gotoProfileServer" => _("Profile server") , + + "gotoXResolution" => _("Resolution") , + "gotoKioskProfile" => _("Kiosk profile") , + + "gosaDefaultPrinter" => _("Default printer") , + "gotoLogonScript" => _("Logon script") , + "gotoHotplugDevice" => _("Hotplug devices"), + "gotoShare" => _("Shares")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/environment/class_hotplugDialog.inc b/gosa-core/plugins/personal/environment/class_hotplugDialog.inc new file mode 100644 index 000000000..0dd418e13 --- /dev/null +++ b/gosa-core/plugins/personal/environment/class_hotplugDialog.inc @@ -0,0 +1,112 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $hotplugDevices = ""; + var $hotplugDeviceList = array(); + var $regex = "*"; + var $depselect = "/"; + var $deplist = "/"; + var $skipThese = array(); + + function hotplugDialog (&$config,$skipThese = array()) + { + $this->skipThese = $skipThese; + $this->config = $config; + $this->depselect = $_SESSION['CurrentMainBase']; + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + if(isset($_POST['dialogissubmitted'])){ + $this->regex=$_POST['regexHot']; + $this->depselect = $_POST['depselectHot']; + } + + if((isset($_GET['search']))&&(!empty($_GET['search']))){ + $this->regex=$_GET['search']."*"; + $this->regex=preg_replace("/\*\*/","*",$this->regex); + } + + $this->deplist=$this->config->idepartments; + + $this->hotplugDevices = $this->getHotplugs(); + $smarty->assign("regexHot" ,$this->regex); + $smarty->assign("deplistHot" ,$this->deplist); + $smarty->assign("depselectHot",$this->depselect); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("deplist", $this->config->idepartments); + + + $smarty->assign("hotplugDevices",$this->hotplugDevices); + $smarty->assign("hotplugDeviceKeys",array_flip($this->hotplugDevices)); + $display.= $smarty->fetch(get_template_path('hotplugDialog.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + + /* Save to LDAP */ + function save() + { + $entries = array(); + foreach($_POST['hotplugName'] as $name){ + $entries[$name] = $this->hotplugDeviceList[$name]; + } + return $entries; + } + + function getHotplugs() + { + $ldap= $this->config->get_ldap_link(); + $ldap->cd("ou=devices,".$this->depselect); + $ldap->search("(&(objectClass=gotoDevice)(|(cn=".$this->regex.")(description=".$this->regex.")))",array("gotoHotplugDevice","cn","dn")); + + $a_return = array(); + $this->hotplugDeviceList = array(); + while($attr = $ldap->fetch()){ + + if(isset($attr['gotoHotplugDevice'][0])){ + + $hot_plug = $attr['gotoHotplugDevice'][0]; + $tmp = preg_split("/\|/",$hot_plug); + $tmp2 = array(); + + if(in_array($attr['cn'][0],$this->skipThese)){ + continue; + } + + $tmp2['name'] = $attr['cn'][0]; + $tmp2['description'] = $tmp[0]; + $tmp2['id'] = $tmp[1]; + $tmp2['produkt'] = $tmp[2]; + $tmp2['vendor'] = $tmp[3]; + $tmp2['dn'] = $attr['dn']; + + $a_return[$attr['cn'][0]]= $attr['cn'][0]." [".$tmp[0]."] ".$tmp[1]; + + $this->hotplugDeviceList[$attr['cn'][0]]=$tmp2; + } + } + return($a_return); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/environment/class_logonManagementDialog.inc b/gosa-core/plugins/personal/environment/class_logonManagementDialog.inc new file mode 100644 index 000000000..f125ad096 --- /dev/null +++ b/gosa-core/plugins/personal/environment/class_logonManagementDialog.inc @@ -0,0 +1,139 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("LogonName","LogonPriority","LogonLast","LogonOverload","LogonData","LogonDescription"); + var $objectclasses = array("whatever"); + var $use_existing = false; + + var $LogonName =""; // Name for the LogonScript + var $LogonPriority =""; // Priority defines the order in which the scripts will be processed + var $LogonLast =""; // Is this script marked as the last, all following scripts will be skipped + var $LogonOverload =""; // If Overload is activated this script is overlaodable by a group script with same prio + var $LogonData =""; // The script itself + var $LogonDescription =""; + + var $nameIsEditable = true; + + var $real_LogonName = ""; + + function logonManagementDialog (&$config, $dn= NULL,$data=false) + { + plugin::plugin ($config, $dn); + + if($data){ + $this->LogonName = $data['LogonName']; + $this->LogonPriority = $data['LogonPriority']; + $this->LogonOverload = $data['LogonOverload']; + $this->LogonLast = $data['LogonLast']; + $this->LogonData = $data['LogonData']; + $this->LogonDescription = $data['LogonDescription']; + $this->nameIsEditable = false; + $this->real_LogonName = $data['LogonName']; + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $smarty= get_smarty(); + $display= ""; + + if((isset($_POST['StartImport']))&&(isset($_FILES['importFile']))){ + $this->LogonData = file_get_contents($_FILES['importFile']['tmp_name']); + @unlink($_FILES['importFile']['tmp_name']); + } + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + if($this->$attr){ + $smarty->assign($attr."CHK"," checked "); + }else{ + $smarty->assign($attr."CHK",""); + } + } + $prios=array(1,2,3,4,5,6,7,8,9,10); + $smarty->assign("LogonPrioritys",$prios); + $smarty->assign("LogonPriorityKeys",$prios); + + if(!$this->nameIsEditable){ + $smarty->assign("LogonNameACL"," disabled "); + }else{ + $smarty->assign("LogonNameACL",""); + } + + + $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + function save_object() + { + if(isset($_POST['dialogissubmitted'])){ + foreach($this->attributes as $attr){ + + if(!$this->nameIsEditable && $attr == 'LogonName'){ + continue; + } + if(isset($_POST[$attr])){ + $this->$attr = stripslashes($_POST[$attr]); + } + } + + foreach(array("LogonLast","LogonOverload") as $checkBoxes){ + if(isset($_POST[$checkBoxes])){ + $this->$checkBoxes = stripslashes($_POST[$checkBoxes]); + }else{ + $this->$checkBoxes = ""; + } + + } + } + } + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(preg_match("/[^a-zA-Z]/",$this->LogonName)){ + $message[] = _("Specified name should only consist of upper-/lowercase characters."); + } + + if(empty($this->LogonName)){ + $message[] = _("Please specify a valid script name."); + } + + if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){ + $message[] = _("Specified description contains invalid characters."); + } + + return $message; + } + + + function save() + { + $a_return= array(); + foreach($this->attributes as $attr){ + $a_return[$attr]=$this->$attr; + } + + if(!$this->nameIsEditable){ + $a_return['LogonName']=$this->real_LogonName; + } + + return($a_return); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/environment/class_selectPrinterDialog.inc b/gosa-core/plugins/personal/environment/class_selectPrinterDialog.inc new file mode 100644 index 000000000..fea177be4 --- /dev/null +++ b/gosa-core/plugins/personal/environment/class_selectPrinterDialog.inc @@ -0,0 +1,169 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); + var $AlreadyAssigned = array(); + var $regex = "*"; + var $depselect = "/"; + var $deplist = array("/"); + var $module = array("printer"); + var $ui = NULL; + var $subtreesearch = FALSE; + + function selectPrinterDialog (&$config, $dn= NULL,$alreadyused=array() ) + { + $this->AlreadyAssigned = $alreadyused; + plugin::plugin ($config, $dn); + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + + /* Load possible departments */ + $ui= get_userinfo(); + $this->ui = $ui; + $tdeps= $ui->get_module_departments("users"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + $res = array(); + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + $res[$dep] = $ids[$dep]; //$tdeps[$dep]; + } + } + $this->deplist = $res; + $this->depselect = key($res); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + if(isset($_POST['dialogissubmitted'])){ + foreach(array('regexPrinter' => 'regex','depselectPrinter'=>'depselect') as $attr => $name){ + if(isset($_POST[$attr])){ + $this->$name =$_POST[$attr]; + } + } + } + + if(isset($_POST['subtrees'])){ + $this->subtreesearch= TRUE; + } else { + $this->subtreesearch= FALSE; + } + + if((isset($_GET['search']))&&(!empty($_GET['search']))){ + $this->regex=$_GET['search']."*"; + $this->regex=preg_replace("/\*\*/","*",$this->regex); + } + + $smarty->assign("regexPrinter" ,$this->regex); + $smarty->assign("deplistPrinter" ,$this->deplist); + $smarty->assign("depselectPrinter",$this->depselect); + $smarty->assign("gotoPrinters",$this->getPrinter()); + $smarty->assign("gotoPrinterKeys",array_flip($this->getPrinter())); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("subtrees", $this->subtreesearch?"checked":""); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("deplist", $this->config->idepartments); + + $display.= $smarty->fetch(get_template_path('selectPrinterDialog.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + function check(){ + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(empty($_POST['gotoPrinter'])){ + $message[] = _("Please select a printer or press cancel."); + } + return $message; + } + + /* Save to LDAP */ + function save() + { + return($_POST['gotoPrinter']); + } + + /* This function generates the Printerlist + * All printers are returned that match regex and and depselect + */ + function getPrinter($detailed = false) + { + $a_return=array(); + + + $filter = "(&(objectClass=gotoPrinter)(cn=".$this->regex."))"; + $module = $this->module; + $base = $this->depselect; + $attrs = array("cn","description"); + if ($this->subtreesearch){ + $res = get_list($filter,$module,$base,$attrs, GL_SIZELIMIT, GL_SUBSEARCH); + } else { + $base= "ou=printers,ou=systems,".$base; + $res = get_list($filter,$module,$base,$attrs, GL_SIZELIMIT); + } + + foreach($res as $printer) { + + $acl = $this->ui->get_permissions($printer['dn'],"printer/printgeneric","gotoUserPrinter"); + + if(!preg_match("/w/",$acl)){ + continue; + } + + if(isset($this->AlreadyAssigned[$printer['cn'][0]])) continue; + + if($detailed ==true){ + $a_return[$printer['cn'][0]] = $printer; + }else{ + if(isset($printer['description'][0])){ + $a_return[$printer['cn'][0]] = $printer['cn'][0]." - ".$printer['description'][0]; + }else{ + $a_return[$printer['cn'][0]] = $printer['cn'][0]; + } + } + } + return($a_return); + } +} + + + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/environment/environment.tpl b/gosa-core/plugins/personal/environment/environment.tpl new file mode 100644 index 000000000..ba6c35623 --- /dev/null +++ b/gosa-core/plugins/personal/environment/environment.tpl @@ -0,0 +1,294 @@ +{if $is_account ne 'true'} + + {t}The environment extension is currently disabled.{/t} +{else} + + + + +

+ + {t}Profiles{/t} +

+ + + + + + +
+ + + + + + + + + +
+{render acl=$gotoProfileACL} + +{/render} + + +
  + + + + + + + + + + + + + +
+ + +{render acl=$gotoProfileServerACL} + +{if $gotoProfileServerWriteable} + +{else} + +{/if} +{/render} +
+ +
+
+
+{render acl=$gotoProfileQuotaACL} + {t}MB{/t} +{/render} +
+
+
+{render acl=$gotoProfileFlagCACL} +   +{/render} + +
+
+
+ + +{if $kiosk_enabled } + + + + + + + + {else} + + + + +{/if} + + + + + + + +
+ +
+ {t}Server{/t} + + + {if $kiosk_server != "none"} + {t}Profile{/t} + + {else} +   + {/if} +
+ + + + +
+
+{render acl=$gotoProfileFlagLACL} + +{/render} + +
+ + +{render acl=$gotoXResolutionACL} + +{/render} +
+ + + + + + +
+ +

 

+ + + + + + +
+

+   + +

+ + + + +
+ +{render acl=$gotoShareACL} + {$divlistShares} +{/render} +{render acl=$gotoShareACL} + @ +{/render} +{render acl=$gotoShareACL} + +{/render} + : +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} + +
+
+

+   + +

+ + + + +
+{render acl=$gotoLogonScriptACL} + +{/render} + +
+{render acl=$gotoLogonScriptACL} + +{/render} +{render acl=$gotoLogonScriptACL} + +{/render} +{render acl=$gotoLogonScriptACL} + +{/render} +
+
+ +

 

+ + + + + + +
+

+   + +

+ + + + + + + +
+{render acl=$gotoHotplugDeviceACL} + +{/render} +
+{render acl=$gotoHotplugDeviceACL} + +{/render} +{render acl=$gotoHotplugDeviceACL} + +{/render} +
+
+

+   + +

+ + + + +
+{render acl=$gotoPrinterACL} + +{/render} +
+{render acl=$gotoPrinterACL} + +{/render} +{render acl=$gotoPrinterACL} + +{/render} +{render acl=$gotoPrinterACL} + +{/render} +{render acl=$gosaDefaultPrinterACL} + +{/render} +
+
+ +{/if} + diff --git a/gosa-core/plugins/personal/environment/hotplugDialog.tpl b/gosa-core/plugins/personal/environment/hotplugDialog.tpl new file mode 100644 index 000000000..868e72b00 --- /dev/null +++ b/gosa-core/plugins/personal/environment/hotplugDialog.tpl @@ -0,0 +1,70 @@ +

 {t}Add hotplug devices{/t}

+ + + + + + + + + + +
+
+

+ +

+
+
+

+
+

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + +
+   + +
+ + + + + +
+ + + +
+ {$apply} +
+
+ +

 

+ +

+ + +

+ diff --git a/gosa-core/plugins/personal/environment/logonManagement.tpl b/gosa-core/plugins/personal/environment/logonManagement.tpl new file mode 100644 index 000000000..746be6fe1 --- /dev/null +++ b/gosa-core/plugins/personal/environment/logonManagement.tpl @@ -0,0 +1,84 @@ +

 {t}Logon script management{/t}

+ + + + + + + + +
+ + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+ + + + + + + +
+ + +
+ + +
+
+

 

+ + + + +
+

 {t}Script{/t}

+ + + + + + + +
+ +
+ + +
+
+ +

 

+

+ + +

+ + + diff --git a/gosa-core/plugins/personal/environment/main.inc b/gosa-core/plugins/personal/environment/main.inc new file mode 100644 index 000000000..6b5d9366c --- /dev/null +++ b/gosa-core/plugins/personal/environment/main.inc @@ -0,0 +1,125 @@ +dn); + sess_del ('edit'); + sess_del ('environment'); + } + + /* Create mail object on demand */ + if (!isset($_SESSION['environment']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['environment']= new environment ($config, $ui->dn); + $_SESSION['environment']->enable_CSN_check(); + $_SESSION['environment']->set_acl_category('users'); + $_SESSION['environment']->set_acl_base($ui->dn); + } + $environment= $_SESSION['environment']; + + /* save changes back to object */ + if (isset($_SESSION['edit'])){ + $environment->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $environment->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $environment->save (); + del_lock ($ui->dn); + sess_del ('edit'); + + /* Remove object */ + sess_del ('environment'); + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display = $lock_msg; + }else{ + $display = $environment->execute(); + } + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['environment']= $environment; + } + + $info= ""; + /* Show page footer depending on the mode */ + if (!$environment->in_dialog && $environment->is_account && empty($lock_msg)){ + $display.= "

"; + + /* Are we in edit mode? */ + if ((isset($_SESSION['edit']))&&($environment->dialog===NULL)){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/environment"))){ + $info.= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); + $display.= "\n"; + } + $display.= "\n"; + } + $display.= "

\n"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/email.png'), _("User environment settings"), $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/environment/selectPrinterDialog.tpl b/gosa-core/plugins/personal/environment/selectPrinterDialog.tpl new file mode 100644 index 000000000..f07674d39 --- /dev/null +++ b/gosa-core/plugins/personal/environment/selectPrinterDialog.tpl @@ -0,0 +1,72 @@ +

 {t}Add printer devcies{/t}

+ + + + + + + + +
+
+

+ +

+
+
+

+
+

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + +
+   + +
+ + +
+ {t}Search in subtrees{/t} +
+ + + + + +
+ + + +
+ {$apply} +
+
+ +

 

+

+ + +

+ diff --git a/gosa-core/plugins/personal/generic/class_user.inc b/gosa-core/plugins/personal/generic/class_user.inc new file mode 100644 index 000000000..57414ef0c --- /dev/null +++ b/gosa-core/plugins/personal/generic/class_user.inc @@ -0,0 +1,1572 @@ + + \version 2.00 + \date 24.07.2003 + + This class provides the functionality to read and write all attributes + relevant for person, organizationalPerson, inetOrgPerson and gosaAccount + from/to the LDAP. It does syntax checking and displays the formulars required. + */ + +class user extends plugin +{ + /* Definitions */ + var $plHeadline= "Generic"; + var $plDescription= "This does something"; + + /* CLI vars */ + var $cli_summary= "Handling of GOsa's user base object"; + var $cli_description= "Some longer text\nfor help"; + var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Plugin specific values */ + var $base= ""; + var $orig_base= ""; + var $cn= ""; + var $new_dn= ""; + var $personalTitle= ""; + var $academicTitle= ""; + var $homePostalAddress= ""; + var $homePhone= ""; + var $labeledURI= ""; + var $o= ""; + var $ou= ""; + var $departmentNumber= ""; + var $employeeNumber= ""; + var $employeeType= ""; + var $roomNumber= ""; + var $telephoneNumber= ""; + var $facsimileTelephoneNumber= ""; + var $mobile= ""; + var $pager= ""; + var $l= ""; + var $st= ""; + var $postalAddress= ""; + var $dateOfBirth; + var $use_dob= "0"; + var $gender="0"; + var $preferredLanguage="0"; + + var $jpegPhoto= "*removed*"; + var $photoData= ""; + var $old_jpegPhoto= ""; + var $old_photoData= ""; + var $cert_dialog= FALSE; + var $picture_dialog= FALSE; + var $pwObject= NULL; + + var $userPKCS12= ""; + var $userSMIMECertificate= ""; + var $userCertificate= ""; + var $certificateSerialNumber= ""; + var $old_certificateSerialNumber= ""; + var $old_userPKCS12= ""; + var $old_userSMIMECertificate= ""; + var $old_userCertificate= ""; + + var $gouvernmentOrganizationalUnit= ""; + var $houseIdentifier= ""; + var $street= ""; + var $postalCode= ""; + var $vocation= ""; + var $ivbbLastDeliveryCollective= ""; + var $gouvernmentOrganizationalPersonLocality= ""; + var $gouvernmentOrganizationalUnitDescription= ""; + var $gouvernmentOrganizationalUnitSubjectArea= ""; + var $functionalTitle= ""; + var $role= ""; + var $publicVisible= ""; + + var $orig_dn; + var $dialog; + + /* variables to trigger password changes */ + var $pw_storage= "crypt"; + var $last_pw_storage= "unset"; + var $had_userCertificate= FALSE; + + var $view_logged = FALSE; + + /* attribute list for save action */ + var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle", + "homePostalAddress", "homePhone", "labeledURI", "ou", "o", "dateOfBirth", "gender","preferredLanguage", + "departmentNumber", "employeeNumber", "employeeType", "l", "st","jpegPhoto", + "roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12", + "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate"); + + var $objectclasses= array("top", "person", "organizationalPerson", "inetOrgPerson", + "gosaAccount"); + + /* attributes that are part of the government mode */ + var $govattrs= array("gouvernmentOrganizationalUnit", "houseIdentifier", "vocation", + "ivbbLastDeliveryCollective", "gouvernmentOrganizationalPersonLocality", + "gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea", + "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role", + "postalCode"); + + var $multiple_support = TRUE; + + /* constructor, if 'dn' is set, the node loads the given + 'dn' from LDAP */ + function user (&$config, $dn= NULL) + { + $this->config= $config; + /* Configuration is fine, allways */ + if ($this->config->current['GOVERNMENTMODE']){ + $this->attributes=array_merge($this->attributes,$this->govattrs); + } + + /* Load base attributes */ + plugin::plugin ($config, $dn); + + $this->orig_dn = $this->dn; + $this->new_dn = $dn; + + if ($this->config->current['GOVERNMENTMODE']){ + /* Fix public visible attribute if unset */ + if (!isset($this->attrs['publicVisible'])){ + $this->publicVisible == "nein"; + } + } + + /* Load government mode attributes */ + if ($this->config->current['GOVERNMENTMODE']){ + /* Copy all attributs */ + foreach ($this->govattrs as $val){ + if (isset($this->attrs["$val"][0])){ + $this->$val= $this->attrs["$val"][0]; + } + } + } + + /* Create me for new accounts */ + if ($dn == "new"){ + $this->is_account= TRUE; + } + + /* Make hash default to md5 if not set in config */ + if (!isset($this->config->current['HASH'])){ + $hash= "md5"; + } else { + $hash= $this->config->current['HASH']; + } + + /* Load data from LDAP? */ + if ($dn !== NULL){ + + /* Do base conversation */ + if ($this->dn == "new"){ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } else { + $this->base= dn2base($dn); + } + + /* get password storage type */ + if (isset ($this->attrs['userPassword'][0])){ + /* Initialize local array */ + $matches= array(); + if (preg_match ("/^{([^}]+)}(.+)/", $this->attrs['userPassword'][0], $matches)){ + $this->pw_storage= strtolower($matches[1]); + } else { + if ($this->attrs['userPassword'][0] != ""){ + $this->pw_storage= "clear"; + } else { + $this->pw_storage= $hash; + } + } + } else { + /* Preset with vaule from configuration */ + $this->pw_storage= $hash; + } + + /* Load extra attributes: certificate and picture */ + $this->load_cert(); + $this->load_picture(); + if ($this->userCertificate != ""){ + $this->had_userCertificate= TRUE; + } + } + + /* Reset password storage indicator, used by password_change_needed() */ + if ($dn == "new"){ + $this->last_pw_storage= "unset"; + } else { + $this->last_pw_storage= $this->pw_storage; + } + + /* Generate dateOfBirth entry */ + if (isset ($this->attrs['dateOfBirth'])){ + /* This entry is ISO 8601 conform */ + list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3); + + $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year); + $this->use_dob= "1"; + } else { + $this->use_dob= "0"; + } + + /* Put gender attribute to upper case */ + if (isset ($this->attrs['gender'])){ + $this->gender= strtoupper($this->attrs['gender'][0]); + } + + $this->orig_base = $this->base; + } + + + + + /* execute generates the html output for this node */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + $smarty= get_smarty(); + + /* Fill calendar */ + if ($this->dateOfBirth == "0"){ + $date= getdate(); + } else { + if(is_array($this->dateOfBirth)){ + $date = $this->dateOfBirth; + + // Trigger on dates like 1985-04-01, getdate only understands timestamps + } else if (!empty($this->dateOfBirth) && !is_numeric($this->dateOfBirth)){ + $date= getdate(strtotime($this->dateOfBirth)); + + } else { + $date = getdate($this->dateOfBirth); + } + } + + $days= array(); + for($d= 1; $d<32; $d++){ + $days[$d]= $d; + } + $years= array(); + + if(($date['year']-100)<1901){ + $start = 1901; + }else{ + $start = $date['year']-100; + } + + $end = $start +100; + + for($y= $start; $y<=$end; $y++){ + $years[]= $y; + } + $years['-']= "- "; + $months= array(_("January"), _("February"), _("March"), _("April"), + _("May"), _("June"), _("July"), _("August"), _("September"), + _("October"), _("November"), _("December"), '-' => '- '); + $smarty->assign("day", $date["mday"]); + $smarty->assign("days", $days); + $smarty->assign("months", $months); + $smarty->assign("month", $date["mon"]-1); + $smarty->assign("years", $years); + $smarty->assign("year", $date["year"]); + + /* Assign sex */ + $sex= array(0 => " ", "F" => _("female"), "M" => _("male")); + $smarty->assign("gender_list", $sex); + $language= array_merge(array(0 => " ") ,get_languages(TRUE)); + $smarty->assign("preferredLanguage_list", $language); + + /* Get random number for pictures */ + srand((double)microtime()*1000000); + $smarty->assign("rand", rand(0, 10000)); + + + /* Do we represent a valid gosaAccount? */ + if (!$this->is_account){ + echo "\"\" ". + _("This account has no valid GOsa extensions.").""; + return; + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo()); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Password configure dialog handling */ + if(is_object($this->pwObject) && $this->pwObject->display){ + $output= $this->pwObject->configure(); + if ($output != ""){ + $this->dialog= TRUE; + return $output; + } + $this->dialog= false; + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + + /* check if selected base is allowed to move to / create a new object */ + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$this->dialog->isSelected()])){ + $this->base = $this->dialog->isSelected(); + } + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + + /* Want password method editing? */ + if ($this->acl_is_writeable("userPassword")){ + if (isset($_POST['edit_pw_method'])){ + if (!is_object($this->pwObject) || $this->pw_storage != $this->pwObject->get_hash_name()){ + $temp= passwordMethod::get_available_methods(); + $this->pwObject= new $temp[$this->pw_storage]($this->config,$this->dn); + } + $this->pwObject->display = TRUE; + $this->dialog= TRUE; + return ($this->pwObject->configure()); + } + } + + /* Want picture edit dialog? */ + if($this->acl_is_writeable("userPicture")) { + if (isset($_POST['edit_picture'])){ + /* Save values for later recovery, in case some presses + the cancel button. */ + $this->old_jpegPhoto= $this->jpegPhoto; + $this->old_photoData= $this->photoData; + $this->picture_dialog= TRUE; + $this->dialog= TRUE; + } + } + + /* Remove picture? */ + if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){ + if (isset($_POST['picture_remove'])){ + $this->set_picture (); + $this->jpegPhoto= "*removed*"; + $this->is_modified= TRUE; + return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__)))); + } + } + + /* Save picture */ + if (isset($_POST['picture_edit_finish'])){ + + /* Check for clean upload */ + if ($_FILES['picture_file']['name'] != ""){ + if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) { + print_red(_("The specified file has not been uploaded via HTTP POST! Aborted.")); + }else{ + /* Activate new picture */ + $this->set_picture($_FILES['picture_file']['tmp_name']); + } + } + $this->picture_dialog= FALSE; + $this->dialog= FALSE; + $this->is_modified= TRUE; + } + + + /* Cancel picture */ + if (isset($_POST['picture_edit_cancel'])){ + + /* Restore values */ + $this->jpegPhoto= $this->old_jpegPhoto; + $this->photoData= $this->old_photoData; + + /* Update picture */ + $_SESSION['binary']= $this->photoData; + $_SESSION['binarytype']= "image/jpeg"; + $this->picture_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Toggle dateOfBirth information */ + if (isset($_POST['set_dob'])){ + $this->use_dob= ($this->use_dob == "0")?"1":"0"; + } + + + /* Want certificate= */ + if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){ + + /* Save original values for later reconstruction */ + foreach (array("certificateSerialNumber", "userCertificate", + "userSMIMECertificate", "userPKCS12") as $val){ + + $oval= "old_$val"; + $this->$oval= $this->$val; + } + + $this->cert_dialog= TRUE; + $this->dialog= TRUE; + } + + + /* Cancel certificate dialog */ + if (isset($_POST['cert_edit_cancel'])){ + + /* Restore original values in case of 'cancel' */ + foreach (array("certificateSerialNumber", "userCertificate", + "userSMIMECertificate", "userPKCS12") as $val){ + + $oval= "old_$val"; + $this->$val= $this->$oval; + } + $this->cert_dialog= FALSE; + $this->dialog= FALSE; + } + + + /* Remove certificate? */ + if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ + foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){ + if (isset($_POST["remove_$val"])){ + + /* Reset specified cert*/ + $this->$val= ""; + $this->is_modified= TRUE; + } + } + } + + /* Upload new cert and close dialog? */ + if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ + if (isset($_POST['cert_edit_finish'])){ + + /* for all certificates do */ + foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") + as $val){ + + /* Check for clean upload */ + if (array_key_exists($val."_file", $_FILES) && + array_key_exists('name', $_FILES[$val."_file"]) && + $_FILES[$val."_file"]['name'] != "" && + is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) { + $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']); + } + } + + /* Save serial number */ + if (isset($_POST["certificateSerialNumber"]) && + $_POST["certificateSerialNumber"] != ""){ + + if (!is_id($_POST["certificateSerialNumber"])){ + print_red (_("Please enter a valid serial number")); + + foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){ + if ($this->$cert != ""){ + $smarty->assign("$cert"."_state", "true"); + } else { + $smarty->assign("$cert"."_state", ""); + } + } + return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__)))); + } + + $this->certificateSerialNumber= $_POST["certificateSerialNumber"]; + $this->is_modified= TRUE; + } + + $this->cert_dialog= FALSE; + $this->dialog= FALSE; + } + } + /* Display picture dialog */ + if ($this->picture_dialog){ + return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__)))); + } + + /* Display cert dialog */ + if ($this->cert_dialog){ + $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))); + $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate")); + + foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){ + if ($this->$cert != ""){ + /* import certificate */ + $certificate = new certificate; + $certificate->import($this->$cert); + + /* Read out data*/ + $timeto = $certificate->getvalidto_date(); + $timefrom = $certificate->getvalidfrom_date(); + + + /* Additional info if start end time is '0' */ + $add_str_info = ""; + if($timeto == 0 && $timefrom == 0){ + $add_str_info = "
"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)").""; + } + + $str = " + + + + +
CN".preg_replace("/ /", " ", $certificate->getname())."

". + + sprintf(_("Certificate is valid from %s to %s and is currently %s."), + "".date('d M Y',$timefrom)."", + "".date('d M Y',$timeto)."", + $certificate->isvalid()?""._("valid")."": + ""._("invalid")."").$add_str_info; + + $smarty->assign($cert."info",$str); + $smarty->assign($cert."_state","true"); + } else { + $smarty->assign($cert."info", ""._("No certificate installed").""); + $smarty->assign($cert."_state",""); + } + } + $smarty->assign("governmentmode", "false"); + return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__)))); + } + + /* Prepare password hashes */ + if ($this->pw_storage == ""){ + $this->pw_storage= $this->config->current['HASH']; + } + + $temp= passwordMethod::get_available_methods(); + $is_configurable= FALSE; + $hashes = $temp['name']; + if(isset($temp[$this->pw_storage])){ + $test= new $temp[$this->pw_storage]($this->config); + $is_configurable= $test->is_configurable(); + }else{ + new msg_dialog(_("Password method"),_("The selected password method is no longer available."),WARNING_DIALOG); + } + + /* Load attributes and acl's */ + $ui =get_userinfo(); + foreach($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + if(in_array($val,$this->multi_boxes)){ + $smarty->assign("use_".$val,TRUE); + }else{ + $smarty->assign("use_".$val,FALSE); + } + } + foreach(array("base","pw_storage","edit_picture") as $val){ + if(in_array($val,$this->multi_boxes)){ + $smarty->assign("use_".$val,TRUE); + }else{ + $smarty->assign("use_".$val,FALSE); + } + } + + /* Set acls */ + $tmp = $this->plinfo(); + foreach($tmp['plProvidedAcls'] as $val => $translation){ + $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit'])))); + } + + $smarty->assign("pwmode", $hashes); + $smarty->assign("pwmode_select", $this->pw_storage); + $smarty->assign("pw_configurable", $is_configurable); + $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit'])))); + $smarty->assign("base_select", $this->base); + $smarty->assign("CertificatesACL", $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))); + $smarty->assign("userPictureACL", $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit'])))); + $smarty->assign("userPicture_is_readable", $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit'])))); + + /* Create base acls */ + $tmp = @$this->allowedBasesToMoveTo(); + $smarty->assign("bases", $tmp); + + /* Save government mode attributes */ + if (isset($this->config->current['GOVERNMENTMODE']) && + preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){ + $smarty->assign("governmentmode", "true"); + $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet", + "internet,ivbv", "internet,testa", "internet,ivbv,testa"); + $smarty->assign("ivbbmodes", $ivbbmodes); + foreach ($this->govattrs as $val){ + $smarty->assign("$val", $this->$val); + $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit'])))); + } + } else { + $smarty->assign("governmentmode", "false"); + } + + /* Special mode for uid */ + $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit']))); + if (isset ($this->dn)){ + if ($this->dn != "new"){ + $uidACL= preg_replace("/w/","",$uidACL); + } + } else { + $uidACL= preg_replace("/w/","",$uidACL); + } + + $smarty->assign("uidACL", $uidACL); + $smarty->assign("is_template", $this->is_template); + $smarty->assign("use_dob", $this->use_dob); + + if (isset($this->parent)){ + if (isset($this->parent->by_object['phoneAccount']) && + $this->parent->by_object['phoneAccount']->is_account){ + $smarty->assign("has_phoneaccount", "true"); + } else { + $smarty->assign("has_phoneaccount", "false"); + } + } else { + $smarty->assign("has_phoneaccount", "false"); + } + $smarty->assign("multiple_support" , $this->multiple_support_active); + return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__)))); + } + + + /* remove object from parent */ + function remove_from_parent() + { + /* Remove password extension */ + $temp= passwordMethod::get_available_methods(); + $this->pwObject= new $temp[$this->pw_storage]($this->config,$this->dn); + $this->pwObject->remove_from_parent(); + + /* Remove user */ + $ldap= $this->config->get_ldap_link(); + $ldap->rmdir ($this->dn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn)); + + new log("remove","users/".get_class($this),$this->dn,$this->attributes,$ldap->get_error()); + + /* Delete references to groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid")); + while ($ldap->fetch()){ + $g= new group($this->config, $ldap->getDN()); + $g->removeUser($this->uid); + $g->save (); + } + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + } + + /* If needed, let the password method do some cleanup */ + $tmp = new passwordMethod($_SESSION['config']); + $available = $tmp->get_available_methods(); + if (in_array_ics($this->pw_storage, $available['name'])){ + $test= new $available[$this->pw_storage]($this->config); + $test->attrs= $this->attrs; + $test->dn= $this->dn; + $test->remove_from_parent(); + } + + /* Remove ACL dependencies too */ + $tmp = new acl($this->config,$this->parent,$this->dn); + $tmp->remove_acl(); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove",array("uid" => $this->uid)); + } + + + /* Save data to object */ + function save_object() + { + if(isset($_POST['generic']) || isset($_POST['multiple_user_posted'])){ + + /* Make a backup of the current selected base */ + $base_tmp = $this->base; + + /* Parents save function */ + plugin::save_object (); + + /* Save government mode attributes */ + if ($this->config->current['GOVERNMENTMODE']){ + foreach ($this->govattrs as $val){ + if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){ + $data= stripcslashes($_POST["$val"]); + if ($data != $this->$val){ + $this->is_modified= TRUE; + } + $this->$val= $data; + } + } + } + + /* In template mode, the uid is autogenerated... */ + if ($this->is_template){ + $this->uid= strtolower($this->sn); + $this->givenName= $this->sn; + } + + /* Save base and pw_storage, since these are no LDAP attributes */ + if (isset($_POST['base'])){ + + $tmp = $this->get_allowed_bases(); + if(isset($tmp[$_POST['base']])){ + $base= validate($_POST['base']); + if ($base != $this->base){ + $this->is_modified= TRUE; + } + $this->base= $base; + }else{ + $this->base = $base_tmp; + print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base']))); + $this->set_acl_base('dummy,'.$this->base); + } + } + + /* Get pw_storage mode */ + if (isset($_POST['pw_storage'])){ + foreach(array("pw_storage") as $val){ + if(isset($_POST[$val])){ + $data= validate($_POST[$val]); + if ($data != $this->$val){ + $this->is_modified= TRUE; + } + $this->$val= $data; + } + } + } + + $this->set_acl_base('dummy,'.$this->base); + } + } + + function rebind($ldap, $referral) + { + $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']); + if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) { + $this->error = "Success"; + $this->hascon=true; + $this->reconnect= true; + return (0); + } else { + $this->error = "Could not bind to " . $credentials['ADMIN']; + return NULL; + } + } + + + /* Save data to LDAP, depending on is_account we save or delete */ + function save() + { + /* Only force save of changes .... + If this attributes aren't changed, avoid saving. + */ + if($this->gender=="0") $this->gender =""; + if($this->preferredLanguage=="0") $this->preferredLanguage =""; + + /* First use parents methods to do some basic fillup in $this->attrs */ + plugin::save (); + + if ($this->use_dob == "1"){ + /* If it is an array, the generic page has never been loaded - so there's no difference. Using an array would cause an error btw. */ + if(!is_array($this->attrs['dateOfBirth'])) { + $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth); + } + } + + /* Remove additional objectClasses */ + $tmp= array(); + foreach ($this->attrs['objectClass'] as $key => $set){ + $found= false; + foreach (array("ivbbentry", "gosaUserTemplate") as $val){ + if (preg_match ("/^$set$/i", $val)){ + $found= true; + break; + } + } + if (!$found){ + $tmp[]= $set; + } + } + + /* Replace the objectClass array. This is done because of the + separation into government and normal mode. */ + $this->attrs['objectClass']= $tmp; + + /* Add objectClasss for template mode? */ + if ($this->is_template){ + $this->attrs['objectClass'][]= "gosaUserTemplate"; + } + + /* Hard coded government mode? */ + if ($this->config->current['GOVERNMENTMODE'] != 'false'){ + $this->attrs['objectClass'][]= "ivbbentry"; + + /* Copy standard attributes */ + foreach ($this->govattrs as $val){ + if ($this->$val != ""){ + $this->attrs["$val"]= $this->$val; + } elseif (!$this->is_new) { + $this->attrs["$val"]= array(); + } + } + + /* Remove attribute if set to "nein" */ + if ($this->publicVisible == "nein"){ + $this->attrs['publicVisible']= array(); + if($this->is_new){ + unset($this->attrs['publicVisible']); + }else{ + $this->attrs['publicVisible']=array(); + } + + } + + } + + /* Special handling for attribute userCertificate needed */ + if ($this->userCertificate != ""){ + $this->attrs["userCertificate;binary"]= $this->userCertificate; + $remove_userCertificate= false; + } else { + $remove_userCertificate= true; + } + + /* Special handling for dateOfBirth value */ + if ($this->use_dob != "1"){ + if ($this->is_new) { + unset($this->attrs["dateOfBirth"]); + } else { + $this->attrs["dateOfBirth"]= array(); + } + } + if (!$this->gender){ + if ($this->is_new) { + unset($this->attrs["gender"]); + } else { + $this->attrs["gender"]= array(); + } + } + if (!$this->preferredLanguage){ + if ($this->is_new) { + unset($this->attrs["preferredLanguage"]); + } else { + $this->attrs["preferredLanguage"]= array(); + } + } + + /* Special handling for attribute jpegPhote needed, scale image via + image magick to 147x200 pixels and inject resulting data. */ + if ($this->jpegPhoto == "*removed*"){ + + /* Reset attribute to avoid writing *removed* as value */ + $this->attrs["jpegPhoto"] = array(); + + } else { + + /* Fallback if there's no image magick inside PHP */ + if (!function_exists("imagick_blob2image")){ + /* Get temporary file name for conversation */ + $fname = tempnam ("/tmp", "GOsa"); + + /* Open file and write out photoData */ + $fp = fopen ($fname, "w"); + fwrite ($fp, $this->photoData); + fclose ($fp); + + /* Build conversation query. Filename is generated automatically, so + we do not need any special security checks. Exec command and save + output. For PHP safe mode, you'll need a configuration which respects + image magick as executable... */ + $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -"; + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, + $query, "Execute"); + + /* Read data written by convert */ + $output= ""; + $sh= popen($query, 'r'); + while (!feof($sh)){ + $output.= fread($sh, 4096); + } + pclose($sh); + + unlink($fname); + + /* Save attribute */ + $this->attrs["jpegPhoto"] = $output; + + } else { + + /* Load the new uploaded Photo */ + if(!$handle = imagick_blob2image($this->photoData)) { + new log("debug","users/".get_class($this),$this->dn,array(),"Could not access uploaded image"); + } + + /* Resizing image to 147x200 and blur */ + if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){ + new log("debug","users/".get_class($this),$this->dn,array(),"Could not resize uploaded image"); + } + + /* Converting image to JPEG */ + if(!imagick_convert($handle,"JPEG")) { + new log("debug","users/".get_class($this),$this->dn,array(),"Could not convert uploaded image to jepg"); + } + + /* Creating binary Code for the Image */ + if(!$dump = imagick_image2blob($handle)){ + new log("debug","users/".get_class($this),$this->dn,array(),"Could not create new user image"); + } + + /* Sending Image */ + $output= $dump; + + /* Save attribute */ + $this->attrs["jpegPhoto"] = $output; + } + + } + + /* This only gets called when user is renaming himself */ + $ldap= $this->config->get_ldap_link(); + if ($this->dn != $this->new_dn){ + + /* Write entry on new 'dn' */ + $this->update_acls($this->dn,$this->new_dn); + $this->move($this->dn, $this->new_dn); + + /* Happen to use the new one */ + change_ui_dn($this->dn, $this->new_dn); + $this->dn= $this->new_dn; + } + + + /* Save data. Using 'modify' implies that the entry is already present, use 'add' for + new entries. So do a check first... */ + $ldap->cat ($this->dn, array('dn')); + if ($ldap->fetch()){ + $mode= "modify"; + } else { + $mode= "add"; + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + } + + /* Set password to some junk stuff in case of templates */ + if ($this->is_template){ + $this->attrs['userPassword']= '{crypt}N0T$3T4N0W'; + } + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save via $mode"); + + /* Finally write data with selected 'mode' */ + $this->cleanup(); + + if(isset($this->attrs['preferredLanguage'])){ + $_SESSION['ui']->language = $this->preferredLanguage; + $_SESSION['Last_init_lang'] = "update"; + } + + $ldap->cd ($this->dn); + $ldap->$mode ($this->attrs); + if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){ + return (1); + } + + /* Remove ACL dependencies too */ + if($this->dn != $this->orig_dn && $this->orig_dn != "new"){ + $tmp = new acl($this->config,$this->parent,$this->dn); + $tmp->update_acl_membership($this->orig_dn,$this->dn); + } + + if($mode == "modify"){ + 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()); + } + + /* Remove cert? + For some reason, the 'ldap' class doesn't want to remove binary entries, so I need + to work around myself. */ + if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){ + + /* Reset array, assemble new, this should be reworked */ + $this->attrs= array(); + $this->attrs['userCertificate;binary']= array(); + + /* Prepare connection */ + if (!($ds = ldap_connect($this->config->current['SERVER']))) { + die ("Could not connect to LDAP server"); + } + ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") { + ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1); + ldap_set_rebind_proc($ds, array(&$this, "rebind")); + } + if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){ + ldap_start_tls($ds); + } + if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'], + $this->config->current['PASSWORD']))) { + die ("Could not bind to LDAP"); + } + + /* Modify using attrs */ + ldap_mod_del($ds,$this->dn,$this->attrs); + ldap_close($ds); + } + + /* If needed, let the password method do some cleanup */ + if ($this->pw_storage != $this->last_pw_storage){ + $tmp = new passwordMethod($_SESSION['config']); + $available = $tmp->get_available_methods(); + if (in_array_ics($this->last_pw_storage, $available['name'])){ + $test= new $available[$this->last_pw_storage]($this->config,$this->dn); + $test->attrs= $this->attrs; + $test->remove_from_parent(); + } + } + + /* Maybe the current password method want's to do some changes... */ + if (is_object($this->pwObject)){ + $this->pwObject->save($this->dn); + } + + /* Optionally execute a command after we're done */ + if ($mode == "add"){ + $this->handle_post_events("add", array("uid" => $this->uid)); + } elseif ($this->is_modified){ + $this->handle_post_events("modify", array("uid" => $this->uid)); + } + + /* Fix tagging if needed */ + $this->handle_object_tagging(); + + return (0); + } + + + function update_new_dn() + { + $pt= ""; + if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){ + if(!empty($this->personalTitle)){ + $pt = $this->personalTitle." "; + } + } + $this->cn= $pt.$this->givenName." ".$this->sn; + + /* Permissions for that base? */ + if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){ + $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base; + } else { + /* Don't touch dn, if cn hasn't changed */ + if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn && + $this->orig_base == $this->base ){ + $this->new_dn= $this->dn; + } else { + $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base); + } + } + } + + + /* Check formular input */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + $this->update_new_dn(); + + /* Set the new acl base */ + if($this->dn == "new") { + $this->set_acl_base($this->base); + } + + /* UID already used? */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(uid=$this->uid)", array("uid")); + $ldap->fetch(); + if ($ldap->count() != 0 && $this->dn == 'new'){ + $message[]= _("There's already a person with this 'Login' in the database."); + } + + /* In template mode, the uid and givenName are autogenerated... */ + if (!$this->is_template){ + if ($this->sn == ""){ + $message[]= _("The required field 'Name' is not set."); + } + if ($this->givenName == ""){ + $message[]= _("The required field 'Given name' is not set."); + } + if ($this->uid == ""){ + $message[]= _("The required field 'Login' is not set."); + } + if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){ + $ldap->cat($this->new_dn); + if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){ + $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database."); + } + } + } + + /* Check for valid input */ + if ($this->is_modified && !is_uid($this->uid)){ + $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed."); + } + if (!is_url($this->labeledURI)){ + $message[]= _("The field 'Homepage' contains an invalid URL definition."); + } + if (preg_match ("/[\\\\]/", $this->sn)){ + $message[]= _("The field 'Name' contains invalid characters."); + } + if (preg_match ("/[\\\\]/", $this->givenName)){ + $message[]= _("The field 'Given name' contains invalid characters."); + } + + /* Check phone numbers */ + if (!is_phone_nr($this->telephoneNumber)){ + $message[]= _("The field 'Phone' contains an invalid phone number."); + } + if (!is_phone_nr($this->facsimileTelephoneNumber)){ + $message[]= _("The field 'Fax' contains an invalid phone number."); + } + if (!is_phone_nr($this->mobile)){ + $message[]= _("The field 'Mobile' contains an invalid phone number."); + } + if (!is_phone_nr($this->pager)){ + $message[]= _("The field 'Pager' contains an invalid phone number."); + } + + /* Check for reserved characers */ + if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){ + $message[]= _("The field 'Given name' contains invalid characters."); + } + if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){ + $message[]= _("The field 'Name' contains invalid characters."); + } + + return $message; + } + + + /* Indicate whether a password change is needed or not */ + function password_change_needed() + { + if(in_array("pw_storage",$this->multi_boxes)){ + return(TRUE); + } + return($this->pw_storage != $this->last_pw_storage); + } + + + /* Load a jpegPhoto from LDAP, this is going to be simplified later on */ + function load_picture() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $data = $ldap->get_attribute($this->dn,"jpegPhoto"); + + if((!$data) || ($data == "*removed*")){ + + /* In case we don't get an entry, load a default picture */ + $this->set_picture ();//"./images/default.jpg"); + $this->jpegPhoto= "*removed*"; + }else{ + + /* Set picture */ + $this->photoData= $data; + $_SESSION['binary']= $this->photoData; + $_SESSION['binarytype']= "image/jpeg"; + $this->jpegPhoto= ""; + } + } + + + /* Load a certificate from LDAP, this is going to be simplified later on */ + function load_cert() + { + $ds= ldap_connect($this->config->current['SERVER']); + ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") { + ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1); + ldap_set_rebind_proc($ds, array(&$this, "rebind")); + } + if(isset($this->config->current['TLS']) && + $this->config->current['TLS'] == "true"){ + + ldap_start_tls($ds); + } + + $r= ldap_bind($ds); + $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate")); + + if ($sr) { + $ei= @ldap_first_entry($ds, $sr); + + if ($ei) { + if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){ + $this->userCertificate= ""; + } else { + $this->userCertificate= $info[0]; + } + } + } else { + $this->userCertificate= ""; + } + + ldap_unbind($ds); + } + + + /* Load picture from file to object */ + function set_picture($filename ="") + { + if (!is_file($filename) || $filename =="" ){ + $filename= "./images/default.jpg"; + $this->jpegPhoto= "*removed*"; + } + + $fd = fopen ($filename, "rb"); + $this->photoData= fread ($fd, filesize ($filename)); + $_SESSION['binary']= $this->photoData; + $_SESSION['binarytype']= "image/jpeg"; + $this->jpegPhoto= ""; + + fclose ($fd); + } + + + /* Load certificate from file to object */ + function set_cert($cert, $filename) + { + if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return; + $fd = fopen ($filename, "rb"); + if (filesize($filename)>0) { + $this->$cert= fread ($fd, filesize ($filename)); + fclose ($fd); + $this->is_modified= TRUE; + } else { + print_red(_("Could not open specified certificate!")); + } + } + + /* Adapt from given 'dn' */ + function adapt_from_template($dn) + { + plugin::adapt_from_template($dn); + + /* Get base */ + $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn); + + if ($this->config->current['GOVERNMENTMODE']){ + + /* Walk through govattrs */ + foreach ($this->govattrs as $val){ + + if (isset($this->attrs["$val"][0])){ + + /* If attribute is set, replace dynamic parts: + %sn, %givenName and %uid. Fill these in our local variables. */ + $value= $this->attrs["$val"][0]; + + foreach (array("sn", "givenName", "uid") as $repl){ + if (preg_match("/%$repl/i", $value)){ + $value= preg_replace ("/%$repl/i", + $this->parent->$repl, $value); + } + } + $this->$val= $value; + } + } + } + + /* Get back uid/sn/givenName */ + if ($this->parent !== NULL){ + $this->uid= $this->parent->uid; + $this->sn= $this->parent->sn; + $this->givenName= $this->parent->givenName; + } + } + + + /* This avoids that users move themselves out of their rights. + */ + function allowedBasesToMoveTo() + { + /* Get bases */ + $bases = $this->get_allowed_bases(); + return($bases); + } + + + function getCopyDialog() + { + $str = ""; + + $_SESSION['binary'] = $this->photoData; + $_SESSION['binarytype']= "image/jpeg"; + + /* Get random number for pictures */ + srand((double)microtime()*1000000); + $rand = rand(0, 10000); + + $smarty = get_smarty(); + + $smarty->assign("passwordTodo","clear"); + + if(isset($_POST['passwordTodo'])){ + $smarty->assign("passwordTodo",$_POST['passwordTodo']); + } + + $smarty->assign("sn", $this->sn); + $smarty->assign("givenName",$this->givenName); + $smarty->assign("uid", $this->uid); + $smarty->assign("rand", $rand); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + + + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + function saveCopyDialog() + { + /* Set_acl_base */ + $this->set_acl_base("cn=dummy,".get_people_ou().$this->base); + + if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){ + $this->set_picture($_FILES['picture_file']['tmp_name']); + } + + /* Remove picture? */ + if (isset($_POST['picture_remove'])){ + $this->jpegPhoto= "*removed*"; + $this->set_picture ("./images/default.jpg"); + $this->is_modified= TRUE; + } + + $attrs = array("uid","givenName","sn"); + foreach($attrs as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Reset certificate information addepted from source user + to avoid setting the same user certificate for the destination user. */ + $this->userPKCS12= ""; + $this->userSMIMECertificate= ""; + $this->userCertificate= ""; + $this->certificateSerialNumber= ""; + $this->old_certificateSerialNumber= ""; + $this->old_userPKCS12= ""; + $this->old_userSMIMECertificate= ""; + $this->old_userCertificate= ""; + } + + + static function plInfo() + { + + $govattrs= array( + "gouvernmentOrganizationalUnit" => _("Unit"), + "houseIdentifier" => _("House identifier"), + "vocation" => _("Vocation"), + "ivbbLastDeliveryCollective" => _("Last delivery"), + "gouvernmentOrganizationalPersonLocality" => _("Person locality"), + "gouvernmentOrganizationalUnitDescription" => _("Unit description"), + "gouvernmentOrganizationalUnitSubjectArea" => _("Subject area"), + "functionalTitle" => _("Functional title"), + "certificateSerialNumber" => _("Certificate serial number"), + "publicVisible" => _("Public visible"), + "street" => _("Street"), + "role" => _("Role"), + "postalCode" => _("Postal code")); + + $ret = array( + "plShortName" => _("Generic"), + "plDescription" => _("Generic user settings"), + "plSelfModify" => TRUE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users" => array("description" => _("Users"), + "objectClass" => "gosaAccount")), + + "plProvidedAcls" => array( + "base" => _("Base"), + "userPassword" => _("User password"), + "sn" => _("Surename"), + "givenName" => _("Given name"), + "uid" => _("User identification"), + "personalTitle" => _("Personal title"), + "academicTitle" => _("Academic title"), + "homePostalAddress" => _("Home postal address"), + "homePhone" => _("Home phone number"), + "labeledURI" => _("Homepage"), + "o" => _("Organization"), + "ou" => _("Department"), + "dateOfBirth" => _("Date of birth"), + "gender" => _("Gender"), + "preferredLanguage" => _("Preferred language"), + "departmentNumber" => _("Department number"), + "employeeNumber" => _("Employee number"), + "employeeType" => _("Employee type"), + "l" => _("Location"), + "st" => _("State"), + "userPicture" => _("User picture"), + "roomNumber" => _("Room number"), + "telephoneNumber" => _("Telefon number"), + "mobile" => _("Mobile number"), + "pager" => _("Pager number"), + "Certificate" => _("User certificates"), + + "postalAddress" => _("Postal address"), + "facsimileTelephoneNumber" => _("Fax number")) + ); + + /* Append government attributes if required */ + global $config; + if (isset($config->current['GOVERNMENTMODE']) && preg_match('/true/i', $config->current['GOVERNMENTMODE'])){ + foreach($govattrs as $attr => $desc){ + $ret["plProvidedAcls"][$attr] = $desc; + } + } + return($ret); + } + + function get_multi_edit_values() + { + $ret = plugin::get_multi_edit_values(); + if(in_array("pw_storage",$this->multi_boxes)){ + $ret['pw_storage'] = $this->pw_storage; + } + if(in_array("edit_picture",$this->multi_boxes)){ + $ret['jpegPhoto'] = $this->jpegPhoto; + $ret['photoData'] = $this->photoData; + $ret['old_jpegPhoto'] = $this->old_jpegPhoto; + $ret['old_photoData'] = $this->old_photoData; + } + if(isset($ret['dateOfBirth'])){ + unset($ret['dateOfBirth']); + } + if(isset($ret['cn'])){ + unset($ret['cn']); + } + $ret['is_modified'] = $this->is_modified; + if(in_array("base",$this->multi_boxes)){ + $ret['orig_base']="Changed_by_Multi_Plug"; + $ret['base']=$this->base; + } + return($ret); + } + + + function multiple_save_object() + { + plugin::multiple_save_object(); + + /* Get pw_storage mode */ + if (isset($_POST['pw_storage'])){ + foreach(array("pw_storage") as $val){ + if(isset($_POST[$val])){ + $data= validate(get_post($val)); + if ($data != $this->$val){ + $this->is_modified= TRUE; + } + $this->$val= $data; + } + } + } + if(isset($_POST['base'])){ + $this->base = get_post('base'); + } + + if(isset($_POST['user_mulitple_edit'])){ + foreach(array("base","pw_storage","edit_picture") as $val){ + if(isset($_POST["use_".$val])){ + $this->multi_boxes[] = $val; + } + } + } + } + + + function multiple_check() + { + /* Call check() to set new_dn correctly ... */ + $message = plugin::multiple_check(); + + /* Set the new acl base */ + if($this->dn == "new") { + $this->set_acl_base($this->base); + } + if (!is_url($this->labeledURI) && in_array("labeledURI",$this->multi_boxes)){ + $message[]= _("The field 'Homepage' contains an invalid URL definition."); + } + if (preg_match ("/[\\\\]/", $this->sn) && in_array("sn",$this->multi_boxes)){ + $message[]= _("The field 'Name' contains invalid characters."); + } + if (preg_match ("/[\\\\]/", $this->givenName) && in_array("givenName",$this->multi_boxes)){ + $message[]= _("The field 'Given name' contains invalid characters."); + } + if (!is_phone_nr($this->telephoneNumber) && in_array("telephoneNumber",$this->multi_boxes)){ + $message[]= _("The field 'Phone' contains an invalid phone number."); + } + if (!is_phone_nr($this->facsimileTelephoneNumber) && in_array("facsimileTelephoneNumber",$this->multi_boxes)){ + $message[]= _("The field 'Fax' contains an invalid phone number."); + } + if (!is_phone_nr($this->mobile) && in_array("mobile",$this->multi_boxes)){ + $message[]= _("The field 'Mobile' contains an invalid phone number."); + } + if (!is_phone_nr($this->pager) && in_array("pager",$this->multi_boxes)){ + $message[]= _("The field 'Pager' contains an invalid phone number."); + } + if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName) && in_array("givenName",$this->multi_boxes)){ + $message[]= _("The field 'Given name' contains invalid characters."); + } + if (preg_match ('/[,+"?\'()=<>;]/', $this->sn) && in_array("sn",$this->multi_boxes)){ + $message[]= _("The field 'Name' contains invalid characters."); + } + return($message); + } + + + + function multiple_execute() + { + return($this->execute()); + } + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/generic/generic.tpl b/gosa-core/plugins/personal/generic/generic.tpl new file mode 100644 index 000000000..1127e9441 --- /dev/null +++ b/gosa-core/plugins/personal/generic/generic.tpl @@ -0,0 +1,568 @@ + + + + + + + + + + + + + + + + + + + + +
+

{t}Personal information{/t}

+
+ + + + + + + +
+ {if !$userPicture_is_readable} + {t}Personal picture{/t} + {else} + {t}Personal picture{/t} + {/if} +
+{render acl=$userPictureACL checkbox=$multiple_support checked=$use_edit_picture} + +{/render} +
+
+ + {if $is_template ne "true"} + + + + + {else} + + + + + {/if} + + {if $is_template ne "true"} + + + + + + + + + {/if} + + + + + + + + + +{if !$multiple_support} + + + + + + + + +{/if} + + + + + + + + +
+{if $multiple_support} + +{else} +{render acl=$snACL} + +{/render} +{/if} +
{render acl=$snACL}{/render}
+ +{if $multiple_support} + +{else} +{render acl=$givenNameACL} + +{/render} +{/if} +
+ {if !$multiple_support} +{render acl=$uidACL} + +{/render} + {else} + + {/if} +
+
+ +
+
+{render acl=$personalTitleACL checkbox=$multiple_support checked=$use_personalTitle} + +{/render} +
+{render acl=$academicTitleACL checkbox=$multiple_support checked=$use_academicTitle} + +{/render} +
+
+ +
+
+{render acl=$dateOfBirthACL} + {if $use_dob eq 1} + + + + + + {else} + + {/if} +{/render} +
+ + +{render acl=$genderACL} + +{/render} +
+ + +{render acl=$preferredLanguageACL checkbox=$multiple_support checked=$use_preferredLanguage} + +{/render} +
+
+ +
+
+{render acl=$baseACL checkbox=$multiple_support checked=$use_base} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+
+   + + + + + + + + + + + + + + + + + + + + + + + + {if $is_template ne "true" && !$multiple_support} + + + + + {/if} + +
+{render acl=$homePostalAddressACL checkbox=$multiple_support checked=$use_homePostalAddress} + +{/render} +
+ +{render acl=$homePhoneACL checkbox=$multiple_support checked=$use_homePhone} + +{/render} +
+{render acl=$labeledURIACL checkbox=$multiple_support checked=$use_labeledURI} + +{/render} +
+
+
+{render acl=$passwordStorageACL checkbox=$multiple_support checked=$use_pw_storage} + + {if $pw_configurable eq "true"} +   + {/if} +{/render} +
+{render acl=$CertificatesACL mode=read_active} + +{/render} +
+
+ +

 

+ + + + + + + + + + + + {if $governmentmode ne "true"} + + + + + + + + + + + + + + {else} + + + + + + + + + + {/if} + +
+

 {t}Organizational information{/t}

+
+ + + + + + + + + + + + + + + + + + + + + +
+{render acl=$oACL checkbox=$multiple_support checked=$use_o} + +{/render} +
+{render acl=$ouACL checkbox=$multiple_support checked=$use_ou} + +{/render} +
+{render acl=$departmentNumberACL checkbox=$multiple_support checked=$use_departmentNumber} + +{/render} +
+{render acl=$employeeNumberACL checkbox=$multiple_support checked=$use_employeeNumber} + +{/render} +
+{render acl=$employeeTypeACL checkbox=$multiple_support checked=$use_employeeType} + +{/render} +
+
+   + + + + + + + {if $has_phoneaccount ne "true"} + + + + + {/if} + + + + + + + + + + + + +
+{render acl=$roomNumberACL checkbox=$multiple_support checked=$use_roomNumber} + +{/render} +
+{render acl=$telephoneNumberACL checkbox=$multiple_support checked=$use_telephoneNumber} + +{/render} +
+{render acl=$mobileACL checkbox=$multiple_support checked=$use_mobile} + +{/render} +
+{render acl=$pagerACL checkbox=$multiple_support checked=$use_pager} + +{/render} +
+{render acl=$facsimileTelephoneNumberACL checkbox=$multiple_support checked=$use_facsimileTelephoneNumber} + +{/render} +
+
+   + + + + + + + + + + + + + + +
+{render acl=$lACL checkbox=$multiple_support checked=$use_l} + +{/render} +
+{render acl=$stACL checkbox=$multiple_support checked=$use_st} + +{/render} +
+{render acl=$postalAddressACL checkbox=$multiple_support checked=$use_postalAddress} + +{/render} +
+
+ + + + + + + + + + + + + + + + + + + + + +
+{render acl=$vocationACL checkbox=$multiple_support checked=$use_vocation} + +{/render} +
+{render acl=$gouvernmentOrganizationalUnitDescriptionACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnitDescription} + +{/render} +
+{render acl=$gouvernmentOrganizationalUnitSubjectAreaACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnitSubjectArea} + +{/render} +
+{render acl=$functionalTitleACL checkbox=$multiple_support checked=$use_functionalTitle} + +{/render} +
+{render acl=$roleACL checkbox=$multiple_support checked=$use_role} + +{/render} +
+
+ + + + + + + + + + + + + + + + + + + + + +
+{render acl=$gouvernmentOrganizationalPersonLocalityACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalPersonLocality} + +{/render} +
+{render acl=$gouvernmentOrganizationalUnitACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnit} + +{/render} +
+{render acl=$streetACL checkbox=$multiple_support checked=$use_street} + +{/render} +
+{render acl=$postalCodeACL checkbox=$multiple_support checked=$use_postalCode} + +{/render} +
+{render acl=$houseIdentifierACL checkbox=$multiple_support checked=$use_houseIdentifier} + +{/render} +
+
+ + + + + + + + + + + + + + + + + + + + + +
+{render acl=$roomNumberACL checkbox=$multiple_support checked=$use_roomNumber} + +{/render} +
+{render acl=$telephoneNumberACL checkbox=$multiple_support checked=$use_telephoneNumber} + {if $has_phoneaccount ne "true"} + + {else} + {t}Please use the phone tab{/t} + {/if} +{/render} +
+{render acl=$facsimileTelephoneNumberACL checkbox=$multiple_support checked=$use_facsimileTelephoneNumber} + +{/render} +
+{render acl=$ivbbLastDeliveryCollectiveACL checkbox=$multiple_support checked=$use_ivbbLastDeliveryCollective} + +{/render} +
+{render acl=$publicVisibleACL checkbox=$multiple_support checked=$use_publicVisible} + +{/render} +
+
+ +{if $multiple_support} + +{/if} + + + + diff --git a/gosa-core/plugins/personal/generic/generic_certs.tpl b/gosa-core/plugins/personal/generic/generic_certs.tpl new file mode 100644 index 000000000..0b5e7597c --- /dev/null +++ b/gosa-core/plugins/personal/generic/generic_certs.tpl @@ -0,0 +1,96 @@ + + +

{t}Certificates{/t}

+ + + + + + + + +
+ {t}Standard certificate{/t} + + + + {if $userCertificate_state ne "true"} + {render acl=$CertificateACL} + + {/render} + {else} + {render acl=$CertificateACL} + + {/render} + {/if} +
+ +
+ + + + + + + +
+ {t}S/MIME certificate{/t} + + + + {if $userSMIMECertificate_state ne "true"} + {render acl=$CertificateACL} + + {/render} + {else} + {render acl=$CertificateACL} + + {/render} + {/if} +
+ +
+ + + + + + + + + {if $governmentmode eq "true"} + + + + + {/if} +
+ {t}PKCS12 certificate{/t} + + + + {if $userPKCS12_state ne "true"} + {render acl=$CertificateACL} + + {/render} + {else} + {render acl=$CertificateACL} + + {/render} + {/if} +
+ + + {render acl=$CertificateACL} + + {/render} +
+ +

+ {render acl=$CertificateACL} + + {/render} +   + +

+ diff --git a/gosa-core/plugins/personal/generic/generic_picture.tpl b/gosa-core/plugins/personal/generic/generic_picture.tpl new file mode 100644 index 000000000..0e2b06cff --- /dev/null +++ b/gosa-core/plugins/personal/generic/generic_picture.tpl @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + +
+

{t}Personal picture{/t}

+
+ + + + +
+ {t}Personal picture{/t} +
+
+ + +   + +
+
+

+ +   + +

+ diff --git a/gosa-core/plugins/personal/generic/main.inc b/gosa-core/plugins/personal/generic/main.inc new file mode 100644 index 000000000..e35ee1eed --- /dev/null +++ b/gosa-core/plugins/personal/generic/main.inc @@ -0,0 +1,198 @@ +dn); + sess_del ('edit'); + sess_del ('user'); + } + + /* Create user object on demand */ + if (!isset($_SESSION['user']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['user']= new user ($config, $ui->dn); + $_SESSION['user']->enable_CSN_check(); + $_SESSION['user']->set_acl_base($ui->dn); + $_SESSION['user']->set_acl_category("users"); + } + $user= $_SESSION['user']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $user->save_object (); + } + + /* Enter edit mode? */ + if ((isset($_POST['edit'])) && (!isset( $_SESSION['edit'])) &&preg_match("/w/",$ui->get_permissions($ui->dn,"users/user"))){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + } + + /* Perform password change */ + if (isset($_POST['password_finish'])){ + + /* For security reasons, check if user is allowed to set password again */ + if ($user->acl_is_writeable("userPassword") || $user->acl_is_createable()){ + + /* Check input and feed errors into 'message' */ + $message= array(); + + /* Sanity checks... */ + if ($_POST['new_password'] != $_POST['repeated_password']){ + + /* Matching passwords in new and repeated? */ + $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match."); + } else { + + /* Empty password is not permitted by default. */ + if ($_POST['new_password'] == ""){ + $message[]= _("The password you've entered as 'New password' is empty."); + } + } + + /* Errors, or change password? */ + if (count($message) != 0){ + + /* Show error message and continue editing */ + show_errors ($message); + $display.= $smarty->fetch(get_template_path('password.tpl', TRUE)); + return ($display); + } + change_password ($user->dn, $_POST['new_password'], 0, $user->pw_storage); + new log("modify","users/password","",array(),"Password has been changed"); + + } else { + + /* Missing permissions, show message */ + print_red (_("You are not allowed to set your password!")); + } + + del_lock ($ui->dn); + sess_del ('user'); + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $user->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $user->save (); + del_lock ($ui->dn); + sess_del ('edit'); + + /* Need to reset the password? */ + if($user->password_change_needed()){ + /* Save object */ + $_SESSION['user']= $user; + + $display.= $smarty->fetch(get_template_path('password.tpl', TRUE)); + return ($display); + } else { + sess_del ('user'); + } + + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display.= $lock_msg; + }else{ + $display.= $user->execute (); + } + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['user']= $user; + } + + $info = ""; + + /* Show page footer depending on the mode */ + if (!$user->cert_dialog && !$user->picture_dialog && !$user->dialog && $user->is_account && empty($lock_msg)){ + $display.= "

"; + + /* Are we in edit mode? */ + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + + $info= "\"\" ".$ui->dn." "; + } else { + /* 'viewid' may be set by i.e. the phonelist plugin. This + means that we want to go back... */ + if (isset ($viewid)){ + $str= _("Back"); + $fn = "back"; + } else { + $str= _("Edit"); + $fn = "edit"; + $info= "\"\" ".$ui->dn." "; + } + + /* Only display edit button if there is at least one attribute editable */ + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/user"))){ + if ($fn == "edit"){ + $info.= "\"\" ". + _("Click the 'Edit' button below to change informations in this dialog"); + $display.= "\n"; + } + } + + $display.= "\n"; + } + $display.= "

\n"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/personal.png'), + _("Generic user information"), $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/generic/multiple_generic.tpl b/gosa-core/plugins/personal/generic/multiple_generic.tpl new file mode 100644 index 000000000..d6f4f030b --- /dev/null +++ b/gosa-core/plugins/personal/generic/multiple_generic.tpl @@ -0,0 +1,482 @@ + + + + + + + + + +
+ +

{t}Personal information{/t}

+
+ + + + +
+ {t}Personal picture{/t} +
+
+ + + + + + + + + + + + + +
+ + + + +
+ + + + +
+
+
+ +
+
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+
+
+
+
+

+ + + + + + + + {if $governmentmode ne "true"} + + + + + + + + + {else} + + + + + + + {/if} + +
+

+ +  {t}Organizational information{/t}

+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+
+   + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+
+   + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+
+ + + diff --git a/gosa-core/plugins/personal/generic/password.tpl b/gosa-core/plugins/personal/generic/password.tpl new file mode 100644 index 000000000..3d26511fc --- /dev/null +++ b/gosa-core/plugins/personal/generic/password.tpl @@ -0,0 +1,28 @@ +

+ {t}You have changed the method your password is stored in the ldap database. For that reason you've to enter your password at this point again. GOsa will then encode it with the selected method.{/t} +

+ + + + + + + + + + +
+
+

+ +   + +

+ + + diff --git a/gosa-core/plugins/personal/generic/paste_generic.tpl b/gosa-core/plugins/personal/generic/paste_generic.tpl new file mode 100644 index 000000000..0fc160888 --- /dev/null +++ b/gosa-core/plugins/personal/generic/paste_generic.tpl @@ -0,0 +1,59 @@ +

{t}User settings{/t}

+ + + + + +
+ + + + + + + + + + + + + + + + + +
+ {t}Password{/t} + + {t}Clear password{/t}
+ {t}Set new password{/t} +
+
+ + + + + + + + + + +
+ + + + +
+ {t}Personal picture{/t} +
+
+ + {t}User picture{/t} + + +   + +
+
+
diff --git a/gosa-core/plugins/personal/mail/class_mailAccount.inc b/gosa-core/plugins/personal/mail/class_mailAccount.inc new file mode 100644 index 000000000..4b6a7b9ef --- /dev/null +++ b/gosa-core/plugins/personal/mail/class_mailAccount.inc @@ -0,0 +1,1208 @@ + + \version 2.00 + \date 24.07.2003 + + This class provides the functionality to read and write all attributes + relevant for gosaMailAccounts from/to the LDAP. It does syntax checking + and displays the formulars required. + */ + +class mailAccount extends plugin +{ + /* Definitions */ + var $plHeadline = "Mail"; + var $plDescription = "This does something"; + var $method = "mailMethod"; + + /* CLI vars */ + var $gosaVacationStart = 0; + var $gosaVacationStop = 0; + var $view_logged = FALSE; + + /* plugin specific values */ + var $mail = ""; + var $gosaMailAlternateAddress = array(); + var $gosaMailForwardingAddress = array(); + var $gosaMailDeliveryMode = "[L ]"; + var $gosaMailServer = ""; + var $gosaMailQuota = ""; + var $gosaMailMaxSize = ""; + var $gosaVacationMessage = ""; + var $gosaSpamSortLevel = ""; + var $gosaSpamMailbox = ""; + + var $quotaUsage = 0; + var $forward_dialog = FALSE; + var $folder_prefix = ""; + var $mailboxList = array("INBOX"); + var $default_permissions = "none"; + var $member_permissions = "post"; + var $members = array(); + var $admins = array(); + var $vacations = array(); + var $perms = array( "lrs" => "read", + "lrsp" => "post", + "lrsip" => "append", + "lrswipcd" => "write", + "lrswipcda" => "all" ); + + /* attribute list for save action */ + var $attributes= array("mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize","gosaMailForwardingAddress", + "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox","gosaMailAlternateAddress","gosaVacationStart","gosaVacationStop", + "gosaVacationMessage", "gosaMailAlternateAddress", "gosaMailForwardingAddress"); + var $objectclasses= array("gosaMailAccount"); + var $uid = ""; + + var $sieve_management = NULL; + + /* constructor, if 'dn' is set, the node loads the given + 'dn' from LDAP */ + function mailAccount (&$config, $dn= NULL) + { + global $class_mapping; + + /* Load bases attributes */ + plugin::plugin($config, $dn); + + /* Set uid */ + if(isset($this->attrs['uid'])){ + $this->uid = $this->attrs['uid'][0]; + } + + if(is_array($this->gosaMailServer) && isset($this->gosaMailServer[0])){ + $this->gosaMailServer = $this->gosaMailServer[0]; + } + + /* Save initial account state */ + $this->initially_was_account= $this->is_account; + + /* Set mailMethod to the one defined in gosa.conf */ + if (isset($this->config->current['MAILMETHOD'])){ + $method= $this->config->current['MAILMETHOD']; + + $cls = get_correct_class_name("mailMethod$method"); + if ($cls && class_exists($cls)){ + $this->method= $cls; + } else { + print_red(sprintf(_("There is no mail method '%s' specified in your gosa.conf available."), $method)); + } + } + + + /* Create the account prefix user. user/ + Preset folder prefix. Will change it later to respect + altnamespace. */ + if (isset($this->config->current['CYRUSUNIXSTYLE']) && $this->config->current['CYRUSUNIXSTYLE'] == "true"){ + $this->folder_prefix= "user/"; + }elseif (isset($this->config->data['MAIN']['CYRUSUNIXSTYLE']) && $this->config->data['MAIN']['CYRUSUNIXSTYLE'] == "true"){ + $this->folder_prefix= "user/"; + } else { + $this->folder_prefix= "user."; + } + + /* This is not a new account, parse additional attributes */ + if (($dn !== NULL) && ($dn != "new") && $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]); + } + } + } + + + /* Only do IMAP actions if gosaMailServer attribute is set */ + if (isset ($this->attrs["gosaMailServer"][0])){ + + $method = new $this->method($this->config); + $id = $method->uattrib; + + /* Adapt attributes if needed */ + $method->fixAttributesOnLoad($this); + + /* FixAttributesOnLoad possibly creates an array out of gosaMailServer. + If the mail tab wasn't opened once before saving, the account can't be saved */ + if(is_array($this->gosaMailServer)){ + $this->gosaMailServer = $this->gosaMailServer[0]; + } + + if ($method->connect($this->attrs["gosaMailServer"][0])){ + + /* Update quota values */ + $quota= $method->getQuota($this->folder_prefix.$this->$id); + + if($quota){ + if ($quota['gosaMailQuota'] == 2147483647){ + $this->quotaUsage = ""; + $this->gosaMailQuota = ""; + } else { + $this->quotaUsage = $quota['quotaUsage']; + $this->gosaMailQuota = $quota['gosaMailQuota']; + } + }else{ + $this->quotaUsage = ""; + $this->gosaMailQuota = ""; +// print_red(sprintf(_("Can't get quota information for '%s'."),$this->folder_prefix.$this->$id)); + } + + /* Get mailboxes / folder like INBOX ..*/ + $this->mailboxList= $method->getMailboxList($this->folder_prefix.$this->$id,$this->$id); + + $method->disconnect(); + }else{ + /* Could not connect to ldap. + */ + if (isset($this->attrs['gosaMailQuota'][0])){ + $this->gosaMailQuota = $this->attrs['gosaMailQuota'][0]; + } + } + } + } + + /* Fill vacation array */ + $this->vacation= array(); + if (isset($this->config->current['VACATIONDIR'])){ + $dir= $this->config->current['VACATIONDIR']; + if (is_dir($dir) && is_readable($dir)){ + + /* Look for files and build the vacation array */ + $dh= opendir($dir); + while ($file = readdir($dh)){ + $description= $this->parse_vacation("$dir/$file"); + if ($description != ""){ + $this->vacation["$dir/$file"]= $description; + } + } + closedir($dh); + } + } + + /* Create sieve management class */ + $method = new $this->method($this->config); + $id = $method->uattrib; + $this->sieve_management = new sieveManagement($this->config,$this->dn,$this,$id); + + /* Get global filter config */ + if (!is_global("mailfilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $mailfilter= array( "depselect" => $base, + "muser" => "", + "regex" => "*"); + register_global("mailfilter", $mailfilter); + } + } + + + function parse_vacation($file) + { + $desc= ""; + + if (is_file($file)){ + $fh = fopen($file, "r"); + $line= fgets($fh, 256); + + if (!preg_match('/^DESC:/', $line)){ + print_red (_("No DESC tag in vacation file:")." $file"); + return $desc; + } + fclose ($fh); + + $desc= trim(preg_replace('/^DESC:\s*/', '', $line)); + } + + return $desc; + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Initialise vars */ + + /* Load templating engine */ + $smarty= get_smarty(); + $display= ""; + + /* Get available mailserver */ + $mailserver= array(); + foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){ + $mailserver[]= $key; + } + + /* + * Sieve Management + */ + if(isset($_POST['sieveManagement']) + && preg_match("/C/",$this->gosaMailDeliveryMode) + && $this->acl_is_writeable("sieveManagement")) { + + $this->dialog = $this->sieve_management; + } + + /* Cancel sieve edit */ + if(isset($_POST['sieve_cancel'])){ + $this->dialog = FALSE; + } + + /* Save sieve changes */ + if(isset($_POST['sieve_finish'])){ + $this->sieve_management = $this->dialog; + $this->dialog = FALSE; + } + + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + + /* Handle account state */ + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This account has no mail extensions.").""; + + $display.= back_to_main(); + return ($display); + } + + /* Show tab dialog headers */ + if ($this->parent !== NULL){ + if ($this->is_account){ + if($this->accountDelegationsConfigured()){ + $display= $this->show_disable_header(_("Remove mail account"), + _("This account can't be removed while there are delegations configured. Remove those delegations first."),TRUE,TRUE); + }else{ + $display= $this->show_disable_header(_("Remove mail account"), + _("This account has mail features enabled. You can disable them by clicking below.")); + } + } else { + $display= $this->show_enable_header(_("Create mail account"), _("This account has mail features disabled. You can enable them by clicking below.")); + return ($display); + } + } + + + /* Forwarder subdialog */ + + /* Trigger forward add dialog? */ + if (isset($_POST['add_local_forwarder'])){ + $this->forward_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Cancel forward add dialog? */ + if (isset($_POST['add_locals_cancel'])){ + $this->forward_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Finished adding of locals? */ + if (isset($_POST['add_locals_finish'])){ + + /* Check if we are able to write gosaMailForwardingAddress */ + if($this->acl_is_writeable("gosaMailForwardingAddress")){ + + /* Walk through list of forwarders, ignore own addresses */ + foreach ($_POST['local_list'] as $val){ + if (!in_array ($val, $this->gosaMailAlternateAddress) && + $val != $this->mail){ + + $this->addForwarder($val); + $this->is_modified= TRUE; + } + } + } + $this->forward_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Add forward email addresses */ + if (isset($_POST['add_forwarder'])){ + if ($_POST['forward_address'] != ""){ + + /* Valid email address specified? */ + $address= $_POST['forward_address']; + $valid= FALSE; + if (!is_email($address)){ + if (!is_email($address, TRUE)){ + if ($this->is_template){ + $valid= TRUE; + } else { + print_red (_("You're trying to add an invalid email address to the list of forwarders.")); + } + } + } elseif ($address == $this->mail + || in_array($address, $this->gosaMailAlternateAddress)) { + + print_red (_("Adding your one of your own addresses to the forwarders makes no sense.")); + + } else { + $valid= TRUE; + } + + if ($valid){ + + /* Add it, if we are able to write gosaMailForwardingAddress */ + if($this->acl_is_writeable("gosaMailForwardingAddress")){ + $this->addForwarder ($address); + $this->is_modified= TRUE; + } + } + } + } + + /* Delete forward email addresses */ + if (isset($_POST['delete_forwarder'])){ + $this->delForwarder ($_POST['forwarder_list']); + } + + + /* Add alternate email addresses */ + if (isset($_POST['add_alternate'])){ + + $valid= FALSE; + if (!is_email($_POST['alternate_address'])){ + if ($this->is_template){ + if (!(is_email($_POST['alternate_address'], TRUE))){ + print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); + } else { + $valid= TRUE; + } + } else { + print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); + } + + } else { + $valid= TRUE; + } + + if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){ + $ui= get_userinfo(); + if ($user != $ui->username){ + print_red (_("The address you're trying to add is already used by user")." '$user'."); + } + } + } + + /* Delete alternate email addresses */ + if (isset($_POST['delete_alternate']) && isset($_POST['alternates_list'])){ + $this->delAlternate ($_POST['alternates_list']); + } + + + /* Vacation message */ + + /* Import vacation message? */ + if (isset($_POST["import_vacation"]) && isset($this->vacation[$_POST["vacation_template"]])){ + $contents= ""; + $lines= file($_POST["vacation_template"]); + foreach ($lines as $line){ + if (!preg_match('/^DESC:/', $line)){ + $contents.= $line; + } + } + + /* Replace attributes */ + $attrs= $this->parent->by_object['user']->attributes; + foreach ($attrs as $val){ + + if(preg_match("/dateOfBirth/",$val)){ + if($this->parent->by_object['user']->use_dob){ + $contents= preg_replace("/%$val/",date("Y-d-m",$this->parent->by_object['user']->dateOfBirth),$contents); + } + }else { + $contents= preg_replace("/%$val/", + $this->parent->by_object['user']->$val, $contents); + } + + /* Replace vacation start and end time */ + if(preg_match("/%start/",$contents)){ + $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents); + } + if(preg_match("/%end/",$contents)){ + $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents); + } + } + + /* Save message */ + $this->gosaVacationMessage= htmlspecialchars($contents); + } + + + /* Display forward dialog if requested above */ + + /* Show forward add dialog */ + if ($this->forward_dialog){ + $ldap= $this->config->get_ldap_link(); + + /* Save data */ + $mailfilter= get_global("mailfilter"); + foreach( array("depselect", "muser", "regex") as $type){ + if (isset($_POST[$type])){ + $mailfilter[$type]= $_POST[$type]; + } + } + if (isset($_GET['search'])){ + $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; + if ($s == "**"){ + $s= "*"; + } + $mailfilter['regex']= $s; + } + register_global("mailfilter", $mailfilter); + + /* Get actual list */ + $mailusers= array (); + if ($mailfilter['regex'] != '*' && $mailfilter['regex'] != ""){ + $regex= $mailfilter['regex']; + $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))"; + } else { + $filter= ""; + } + if ($mailfilter['muser'] != ""){ + $user= $mailfilter['muser']; + $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))"; + } + + /* Add already present people to the filter */ + $exclude= ""; + foreach ($this->gosaMailForwardingAddress as $mail){ + $exclude.= "(mail=$mail)"; + } + if ($exclude != ""){ + $filter.= "(!(|$exclude))"; + } + + $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $mailfilter['depselect'], + array("sn", "mail", "givenName"), GL_SIZELIMIT | GL_SUBSEARCH); + $ldap->cd($mailfilter['depselect']); + $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName")); + error_reporting (0); + while ($attrs= $ldap->fetch()){ + if(preg_match('/%/', $attrs['mail'][0])){ + continue; + } + $name= $this->make_name($attrs); + $mailusers[$attrs['mail'][0]]= $name."<". + $attrs['mail'][0].">"; + } + error_reporting (E_ALL | E_STRICT); + natcasesort ($mailusers); + reset ($mailusers); + + /* Show dialog */ + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("usearch_image", get_template_path('images/search_user.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("infoimage", get_template_path('images/info.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("mailusers", $mailusers); + if (isset($_POST['depselect'])){ + $smarty->assign("depselect", $_POST['depselect']); + } + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("apply", apply_filter()); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("hint", print_sizelimit_warning()); + foreach( array("depselect", "muser", "regex") as $type){ + $smarty->assign("$type", $mailfilter[$type]); + } + $smarty->assign("hint", print_sizelimit_warning()); + + $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + /* Display mail account tab */ + + $smarty->assign("mailServers", $mailserver); + $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $transl){ + $smarty->assign("$name"."ACL", $this->getacl($name,$SkipWrite)); + } + + foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail", + "gosaMailAlternateAddress", "gosaMailForwardingAddress", + "gosaVacationMessage", "gosaMailDeliveryMode", "gosaVacationStart", + "gosaVacationStop", "gosaMailMaxSize", "gosaSpamSortLevel", "gosaSpamMailbox") as $val){ + $smarty->assign("$val", $this->$val); + } + + if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){ + $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true)); + $smarty->assign("quotadefined", "true"); + } else { + $smarty->assign("quotadefined", "false"); + } + + /* Disable mail field if needed */ + $method= new $this->method($this->config); + if ($method->uattrib == "mail" && $this->initially_was_account){ + $smarty->assign("mailACL", preg_replace("/w/","",$this->getacl("mail",$SkipWrite))); + } + + /* Disable/Enable range select, but do not disable them twice + * if they are already diabled by "use own sieve script" + */ + if (preg_match('/V/', $this->gosaMailDeliveryMode) || preg_match("/C/",$this->gosaMailDeliveryMode)){ + $smarty->assign('rangeEnabled', ""); + } else { + $smarty->assign('rangeEnabled', "disabled"); + } + + if (!preg_match("/L/", $this->gosaMailDeliveryMode)) { + $smarty->assign("only_local", "checked"); + } else { + $smarty->assign("only_local", ""); + } + + $types = array( + "V"=>"use_vacation", + "S"=>"use_spam_filter", + "R"=>"use_mailsize_limit", + "I"=>"drop_own_mails", + "C"=>"own_script"); + + /* Fill checkboxes */ + foreach($types as $option => $varname){ + if (preg_match("/".$option."/", $this->gosaMailDeliveryMode)) { + $smarty->assign($varname, "checked"); + } else { + $smarty->assign($varname, ""); + } + } + + /* Display mail account tab */ + if($this->gosaVacationStart ==0){ + $date= getdate(time()); + }else{ + $date= getdate($this->gosaVacationStart); + } + $days= array(); + for($d= 1; $d<32; $d++){ + $days[$d]= $d; + } + $years= array(); + for($y= $date['year']-10; $y<$date['year']+10; $y++){ + $years[]= $y; + } + $months= array(_("January"), _("February"), _("March"), _("April"), + _("May"), _("June"), _("July"), _("August"), _("September"), + _("October"), _("November"), _("December")); + $smarty->assign("start_day", $date["mday"]); + $smarty->assign("days", $days); + $smarty->assign("months", $months); + $smarty->assign("start_month", $date["mon"]-1); + $smarty->assign("years", $years); + $smarty->assign("start_year", $date["year"]); + + if($this->gosaVacationStop ==0){ + $date= getdate(time()); + $date["mday"]++; + }else{ + $date= getdate($this->gosaVacationStop); + } + $smarty->assign("end_day", $date["mday"]); + $smarty->assign("end_month", $date["mon"]-1); + $smarty->assign("end_year", $date["year"]); + + + + /* Have vacation templates? */ + $smarty->assign("template", ""); + if (count($this->vacation)){ + $smarty->assign("show_templates", "true"); + $smarty->assign("vacationtemplates", $this->vacation); + if (isset($_POST['vacation_template'])){ + $smarty->assign("template", $_POST['vacation_template']); + } + } else { + $smarty->assign("show_templates", "false"); + } + + /* Fill spam selector */ + $spamlevel= array(); + for ($i= 0; $i<21; $i++){ + $spamlevel[]= $i; + } + $smarty->assign("spamlevel", $spamlevel); + $smarty->assign("spambox", $this->mailboxList); + + $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + + /* remove object from parent */ + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + /* Zero arrays */ + $this->attrs['gosaMailAlternateAddress']= array(); + $this->attrs['gosaMailForwardingAddress']= array(); + + /* Adapt attributes if needed */ + $method= new $this->method($this->config); + $method->fixAttributesOnRemove($this); + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + + $ldap->modify ($this->attrs); + + /* Add "view" to logging class */ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/mail account with dn '%s' failed."),$this->dn)); + + /* Connect to IMAP server for account deletion */ + if ($this->gosaMailServer != ""){ + $method= new $this->method($this->config); + $id= $method->uattrib; + if ($method->connect($this->gosaMailServer)){ + + /* Remove account from IMAP server */ + $method->deleteMailbox($this->folder_prefix.$this->$id); + $method->disconnect(); + } + } + + /* Update shared folder membership, ACL may need to be updated */ + $this->updateSharedFolder(); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove",array("uid" => $this->uid)); + } + + + /* check if we have some delegations configured, those delegations must be removed first */ + function accountDelegationsConfigured() + { + /* We are in administrational edit mode. + Check tab configurations directly */ + if(isset($this->attrs)){ + $checkArray = array("kolabInvitationPolicy","unrestrictedMailSize", "calFBURL","kolabDelegate","kolabFreeBusyFuture"); + foreach($checkArray as $index){ + if(isset($this->attrs[$index])){ + return(true); + } + } + } + return(false); + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['mailTab'])){ + + /* Save ldap attributes */ + plugin::save_object(); + + + if(isset($_POST['own_script'])){ + + if(!preg_match("/C/",$this->gosaMailDeliveryMode)){ + $str= preg_replace("/[\[\]]/","",$this->gosaMailDeliveryMode); + $this->gosaMailDeliveryMode = "[".$str."C]"; + } + + }else{ + + /* Assemble mail delivery mode + The mode field in ldap consists of values between braces, this must + be called when 'mail' is set, because checkboxes may not be set when + we're in some other dialog. + + Example for gosaMailDeliveryMode [LR ] + L: Local delivery + R: Reject when exceeding mailsize limit + S: Use spam filter + V: Use vacation message + C: Use custm sieve script + I: Only insider delivery */ + + $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode); + + + /* Handle delivery flags */ + if($this->acl_is_writeable("gosaMailDeliveryModeL")){ + if(!preg_match("/L/",$tmp) && !isset($_POST['only_local'])){ + $tmp.="L"; + }elseif(preg_match("/L/",$tmp) && isset($_POST['only_local'])){ + $tmp = preg_replace("/L/","",$tmp); + } + } + + $opts = array( + "R" => "use_mailsize_limit", + "S" => "use_spam_filter", + "V" => "use_vacation", + "C" => "own_script", + "I" => "drop_own_mails"); + + foreach($opts as $flag => $post){ + if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){ + if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){ + $tmp.= $flag; + }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){ + $tmp = preg_replace("/".$flag."/","",$tmp); + } + } + } + + $tmp= "[$tmp]"; + if ($this->gosaMailDeliveryMode != $tmp){ + $this->is_modified= TRUE; + } + $this->gosaMailDeliveryMode= $tmp; + } + } + + } + + + /* Save data to LDAP, depending on is_account we save or delete */ + function save() + { + $ldap= $this->config->get_ldap_link(); + + /* Call parents save to prepare $this->attrs */ + plugin::save(); + + /* Save arrays */ + $this->attrs['gosaMailAlternateAddress']= $this->gosaMailAlternateAddress; + $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress; + + /* Adapt attributes if needed */ + $method= new $this->method($this->config); + $id= $method->uattrib; + + $method->fixAttributesOnStore($this); + + /* Remove Mailquota if = "" or "0" */ + if((isset($this->attrs['gosaMailQuota']))&&(!$this->attrs['gosaMailQuota'])) { + $this->attrs['gosaMailQuota']=0; + } + + if(empty($this->attrs['gosaSpamMailbox'])){ + unset($this->attrs['gosaSpamMailbox']); + } + + $this->attrs['mail'] = strtolower($this->attrs['mail']); + + /* Remove attributes - if not needed */ + if (!preg_match('/V/', $this->gosaMailDeliveryMode)){ + unset($this->attrs['gosaVacationStart']); + unset($this->attrs['gosaVacationStop']); + } + + + /* Remove attributes - if not needed */ + if (!preg_match('/V/', $this->gosaMailDeliveryMode)){ + unset($this->attrs['gosaVacationStart']); + unset($this->attrs['gosaVacationStop']); + } + + /* Save data to LDAP */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/mail account with dn '%s' failed."),$this->dn)); + + /* 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()); + } + + /* Only do IMAP actions if we are not a template */ + if (!$this->is_template){ + + if ($method->connect($this->gosaMailServer)){ + $method->updateMailbox($this->folder_prefix.$this->$id); + + $method->setQuota($this->folder_prefix.$this->$id, $this->gosaMailQuota); + $method->disconnect(); + + /* Ensure that this is an existing account */ + if(1==1 || $this->initially_was_account){ + + /* Write sieve information only if not in C mode */ + if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){ + $method->configureFilter($this->$id, + $this->gosaMailDeliveryMode, + $this->mail, + $this->gosaMailAlternateAddress, + $this->gosaMailMaxSize, + $this->gosaSpamMailbox, + $this->gosaSpamSortLevel, + $this->gosaVacationMessage); + $this->is_modified = TRUE; + }else{ + $this->sieve_management->save(); + } + } + } + } + + /* 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", array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add", array("uid" => $this->uid)); + } + + $this->updateSharedFolder(); + } + + + /* Check formular input */ + 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(); + + if(empty($this->gosaMailServer)){ + $message[]= _("There is no valid mailserver specified, please add one in the system setup."); + } + + /* must: mail */ + if ($this->mail == ""){ + $message[]= _("The required field 'Primary address' is not set."); + } + if ($this->is_template){ + if (!is_email($this->mail, TRUE)){ + $message[]= _("Please enter a valid email address in 'Primary address' field."); + } + } else { + if (!is_email($this->mail)){ + $message[]= _("Please enter a valid email address in 'Primary address' field."); + } + } + $ldap->cd($this->config->current['BASE']); + $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid")); + if ($ldap->count() != 0){ + $message[]= _("The primary address you've entered is already in use."); + } + + /* Check quota */ + if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){ + if (!is_numeric($this->gosaMailQuota)) { + $message[]= _("Value in 'Quota size' is not valid."); + } else { + $this->gosaMailQuota= (int) $this->gosaMailQuota; + } + } + + /* Check rejectsize for integer */ + if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailMaxSize")){ + if (!is_numeric($this->gosaMailMaxSize)){ + $message[]= _("Please specify a vaild mail size for mails to be rejected."); + } else { + $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize; + } + } + + /* Need gosaMailMaxSize if use_mailsize_limit is checked */ + if (is_integer(strpos($this->gosaMailDeliveryMode, "R")) && + $this->gosaMailMaxSize == ""){ + + $message[]= _("You need to set the maximum mail size in order to reject anything."); + } + + if((preg_match("/S/", $this->gosaMailDeliveryMode))&&(empty($this->gosaSpamMailbox))) { + $message[]= _("You specified Spam settings, but there is no Folder specified."); + } + + if (preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){ + $message[]= _("Time interval to show vacation message is not valid."); + } + + return ($message); + } + + + /* Adapt from template, using 'dn' */ + function adapt_from_template($dn) + { + plugin::adapt_from_template($dn); + + foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){ + $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); + } + } + array_push($this->$val, strtolower(rewrite($value))); + } + } + } + $this->mail= strtolower(rewrite($this->mail)); + } + + + /* Add entry to forwarder list */ + function addForwarder($address) + { + if($this->acl_is_writeable("gosaMailForwardingAddress")){ + $this->gosaMailForwardingAddress[]= $address; + $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress); + sort ($this->gosaMailForwardingAddress); + reset ($this->gosaMailForwardingAddress); + $this->is_modified= TRUE; + }else{ + print_red(_("You are not allowed to write mail forwarding.")); + } + } + + + /* Remove list of addresses from forwarder list */ + function delForwarder($addresses) + { + if($this->acl_is_writeable("gosaMailForwardingAddress")){ + $this->gosaMailForwardingAddress= array_remove_entries ($addresses, $this->gosaMailForwardingAddress); + $this->is_modified= TRUE; + }else{ + print_red(_("You are not allowed to write mail forwarding.")); + } + } + + + /* 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($this->acl_is_writeable("gosaMailAlternateAddress")){ + $ldap= $this->config->get_ldap_link(); + $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("uid")); + $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid")); + + if ($ldap->count() > 0){ + $attrs= $ldap->fetch (); + return ($attrs["uid"][0]); + } + + /* Add to list of alternates */ + if (!in_array($address, $this->gosaMailAlternateAddress)){ + $this->gosaMailAlternateAddress[]= $address; + $this->is_modified= TRUE; + } + + sort ($this->gosaMailAlternateAddress); + reset ($this->gosaMailAlternateAddress); + return (""); + }else{ + print_red(_("You are not allowed to write mail alternate address.")); + } + } + + + function delAlternate($addresses) + { + if($this->acl_is_writeable("gosaMailAlternateAddress")){ + $this->gosaMailAlternateAddress= array_remove_entries ($addresses,$this->gosaMailAlternateAddress); + $this->is_modified= TRUE; + }else{ + print_red(_("You are not allowed to write mail alternate address.")); + } + } + + 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.= " "; + } + + return ($name); + } + + + /* Create the mail part for the copy & paste dialog */ + function getCopyDialog() + { + if(!$this->is_account) return(""); + $smarty = get_smarty(); + $smarty->assign("mail",$this->mail); + $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress); + $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress); + $str = $smarty->fetch(get_template_path("copypaste.tpl",TRUE, dirname(__FILE__))); + + $ret = array(); + $ret['status'] = ""; + $ret['string'] = $str; + return($ret); + } + + function saveCopyDialog() + { + if(!$this->is_account) return; + + /* Execute to save mailAlternateAddress && gosaMailForwardingAddress */ + $this->execute(); + + if(isset($_POST['mail'])){ + $this->mail = $_POST['mail']; + } + + } + + function allow_remove() + { + if (isset($this->config->current['MAILMETHOD'])){ + $method= $this->config->current['MAILMETHOD']; + if(preg_match("/olab/i",$method)){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn); + if($ldap->count()){ + $attrs = $ldap->fetch(); + if(isset($attrs['kolabDeleteFlag'])){ + return(_("Waiting for kolab to remove mail properties.")); + }elseif(in_array("gosaMailAccount",$attrs['objectClass'])){ + return(_("Please remove the mail account first, to allow kolab to call its remove methods.")); + } + } + } + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Reset alternate mail addresses */ + $this->gosaMailAlternateAddress = array(); + } + + + static function plInfo() + { + return (array( + "plShortName" => _("Mail"), + "plDescription" => _("Mail settings"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), // This plugin depends on + "plPriority" => 4, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "mail" => _("Mail address"), + "gosaMailServer" => _("Mail server"), + "gosaMailQuota" => _("Quota size"), + + "gosaMailDeliveryModeV" => _("Add vacation information"), // This is flag of gosaMailDeliveryMode + "gosaVacationMessage" => _("Vacation message"), + + "gosaMailDeliveryModeS" => _("Use spam filter"), // This is flag of gosaMailDeliveryMode + "gosaSpamSortLevel" => _("Spam level"), + "gosaSpamMailbox" => _("Spam mail box"), + + "sieveManagement" => _("Sieve management"), + + "gosaMailDeliveryModeR" => _("Reject due to mailsize"), // This is flag of gosaMailDeliveryMode + "gosaMailMaxSize" => _("Mail max size"), + + "gosaMailForwardingAddress" => _("Forwarding address"), + "gosaMailDeliveryModeL" => _("Local delivery"), // This is flag of gosaMailDeliveryMode + "gosaMailDeliveryModeI" => _("No delivery to own mailbox "), // This is flag of gosaMailDeliveryMode + "gosaMailAlternateAddress" => _("Mail alternative addresses"), + + "gosaMailForwardingAddress" => _("Forwarding address"), + "gosaMailDeliveryModeC" => _("Use custom sieve script")) // This is flag of gosaMailDeliveryMode + )); + } + + /* Upated shared folder ACLs + */ + function updateSharedFolder() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array('dn','cn')); + if(class_exists("grouptabs")){ + while($attrs = $ldap->fetch()){ + $tmp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']); + if(isset($tmp->by_object['mailgroup'])){ + $tmp->by_object['mailgroup']->members= $tmp->by_object['group']->memberUid; + if(!$this->is_account){ + $tmp->by_object['mailgroup']->removeUserAcl($this->uid); + $tmp->by_object['mailgroup']->removeUserAcl($this->mail); + } + $tmp->by_object['mailgroup']->save(); + } + } + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/mail/copypaste.tpl b/gosa-core/plugins/personal/mail/copypaste.tpl new file mode 100644 index 000000000..56ec107ff --- /dev/null +++ b/gosa-core/plugins/personal/mail/copypaste.tpl @@ -0,0 +1,70 @@ +

{t}Mail settings{/t}

+ + + + + + + + + +
+ + + + + + + + +
{$must}
+

+ +

+
+
+ + + + +
+

+ + +

+
+
+ + + + +
+ +
+ +   +   + +
+
+ + + + +
+ +
+ + + +
+
+
+
diff --git a/gosa-core/plugins/personal/mail/generic.tpl b/gosa-core/plugins/personal/mail/generic.tpl new file mode 100644 index 000000000..785fd44f6 --- /dev/null +++ b/gosa-core/plugins/personal/mail/generic.tpl @@ -0,0 +1,314 @@ + + + + + + + + +
+ +

 {t}Generic{/t}

+ + + + + + + + + + + + + + + + + +
{$must} +{render acl=$mailACL} + +{/render} +
+{render acl=$gosaMailServerACL} + +{/render} +
+
+ {t}Quota usage{/t} +
+
+ {if $quotadefined eq "true"} + {$quotausage} + {else} + {t}not defined{/t} + {/if} +
+{render acl=$gosaMailQuotaACL} + MB +{/render} +
+
+   + +

+{render acl=$gosaMailAlternateAddressACL} + +
+{render acl=$gosaMailAlternateAddressACL} + +{/render} +{render acl=$gosaMailAlternateAddressACL} + +{/render} +{render acl=$gosaMailAlternateAddressACL} + +{/render} +
+ +

 

+

 {t}Mail options{/t}

+ + + + + + + +
+{render acl=$gosaMailDeliveryModeCACL} + {t}Use custom sieve script{/t} ({t}disables all Mail options!{/t}) +{/render} +
+{render acl=$sieveManagementACL} + +{/render} +
+ + +

 

+ + + + + + + + + +
+{render acl=$gosaMailDeliveryModeIACL} + {t}No delivery to own mailbox{/t} +{/render} + +
+{render acl=$gosaMailDeliveryModeVACL} + {t}Activate vacation message{/t} +{/render} + +
+ + + + + + + + + + +
+ {t}from{/t} + +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} + +
+ {t}till{/t} + +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} + +
+ + +
+   + +{render acl=$gosaMailDeliveryModeSACL} + +{/render} + + +{render acl=$gosaSpamSortLevelACL} + +{/render} + +{render acl=$gosaSpamMailboxACL} + +{/render} +
+{render acl=$gosaMailDeliveryModeRACL} + +{/render} + +{render acl=$gosaMailMaxSizeACL} + {t}MB{/t} +{/render} +
+

+ +

+{render acl=$gosaVacationMessageACL} + +{/render} +
+ + {if $show_templates eq "true"} +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} + {/if} +
+

+ +

+{render acl=$gosaMailForwardingAddressACL} + +{/render} +
+{render acl=$gosaMailForwardingAddressACL} + +{/render} +{render acl=$gosaMailForwardingAddressACL} +   +{/render} +{render acl=$gosaMailForwardingAddressACL} +   +{/render} +{render acl=$gosaMailForwardingAddressACL} + +{/render} +
+

 

+ +

 {t}Advanced mail options{/t}

+ + + + + +
+{render acl=$gosaMailDeliveryModeLACL} + +{/render} + {t}User is only allowed to send and receive local mails{/t} +
+ + + + + diff --git a/gosa-core/plugins/personal/mail/mail_locals.tpl b/gosa-core/plugins/personal/mail/mail_locals.tpl new file mode 100644 index 000000000..d277ceb45 --- /dev/null +++ b/gosa-core/plugins/personal/mail/mail_locals.tpl @@ -0,0 +1,81 @@ + + + + + +
+
+

+ + + {$hint} + +
+

+
+
+

+ +

+
+
+
+

+ [F] + {t}Filters{/t} +

+
+
+ + {$alphabet} +
+ + + + +
+ +   + +
+ + + + + + +
+ + + +
+ + + + + + +
+ {t}Display addresses of user{/t} + + +
+ {$apply} +
+
+ +

+ +   + +

+ diff --git a/gosa-core/plugins/personal/mail/main.inc b/gosa-core/plugins/personal/mail/main.inc new file mode 100644 index 000000000..dda8cd770 --- /dev/null +++ b/gosa-core/plugins/personal/mail/main.inc @@ -0,0 +1,130 @@ +dn); + sess_del ('edit'); + sess_del ('mailAccount'); + } + + /* Create mail object on demand */ + if (!isset($_SESSION['mailAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['mailAccount']= new mailAccount ($config, $ui->dn); + $_SESSION['mailAccount']->enable_CSN_check(); + $_SESSION['mailAccount']->set_acl_base($ui->dn); + $_SESSION['mailAccount']->set_acl_category("users"); + } + $mailAccount= $_SESSION['mailAccount']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $mailAccount->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit']) && preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $mailAccount->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $mailAccount->save (); + del_lock ($ui->dn); + sess_del ('edit'); + + /* Remove object */ + sess_del ('mailAccount'); + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display.= $lock_msg; + }else{ + $display.= $mailAccount->execute (); + } + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['mailAccount']= $mailAccount; + } + + $info= ""; + /* Show page footer depending on the mode */ + if (!$mailAccount->forward_dialog && $mailAccount->is_account && empty($lock_msg)){ + $display.= "

"; + + /* Are we in edit mode? */ + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + $info.= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); + + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){ + $display.= "\n"; + } + + $display.= "\n"; + } + $display.= "

\n"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/email.png'), _("User mail settings"), $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/mail/sieve-discard.txt b/gosa-core/plugins/personal/mail/sieve-discard.txt new file mode 100644 index 000000000..8ac4db68a --- /dev/null +++ b/gosa-core/plugins/personal/mail/sieve-discard.txt @@ -0,0 +1,3 @@ +# Do not deliver to own mailbox +discard; + diff --git a/gosa-core/plugins/personal/mail/sieve-header.txt b/gosa-core/plugins/personal/mail/sieve-header.txt new file mode 100644 index 000000000..5222282e5 --- /dev/null +++ b/gosa-core/plugins/personal/mail/sieve-header.txt @@ -0,0 +1,3 @@ +###GOSA +require ["fileinto", "reject", "vacation"]; + diff --git a/gosa-core/plugins/personal/mail/sieve-mailsize.txt b/gosa-core/plugins/personal/mail/sieve-mailsize.txt new file mode 100644 index 000000000..de639c26c --- /dev/null +++ b/gosa-core/plugins/personal/mail/sieve-mailsize.txt @@ -0,0 +1,17 @@ +# Reject mails with bigger size +if size :over {$maxsize}M{ + reject text: +Dear sender, + +the mail you sent to our mailsystem has been rejected due +to a user configured maximum mail size ($maxsize MB). + +Either ask the user to remove the sizelimit, or send smaller pieces. + +Thank you, + the mailserver +. + ; + discard; +} + diff --git a/gosa-core/plugins/personal/mail/sieve-spam.txt b/gosa-core/plugins/personal/mail/sieve-spam.txt new file mode 100644 index 000000000..63392d011 --- /dev/null +++ b/gosa-core/plugins/personal/mail/sieve-spam.txt @@ -0,0 +1,5 @@ +# Sort mails with higher spam level +if header :contains "X-Spam-Level" "$spamlevel" { + fileinto "$spambox"; +} + diff --git a/gosa-core/plugins/personal/mail/sieve-vacation.txt b/gosa-core/plugins/personal/mail/sieve-vacation.txt new file mode 100644 index 000000000..3aed3a916 --- /dev/null +++ b/gosa-core/plugins/personal/mail/sieve-vacation.txt @@ -0,0 +1,4 @@ +# Vacation message +vacation :addresses [$addrlist] +"$vacmsg" ; + diff --git a/gosa-core/plugins/personal/nagios/class_nagiosAccount.inc b/gosa-core/plugins/personal/nagios/class_nagiosAccount.inc new file mode 100644 index 000000000..41b2de34c --- /dev/null +++ b/gosa-core/plugins/personal/nagios/class_nagiosAccount.inc @@ -0,0 +1,313 @@ + + \author Benoit Mortier + \author Vincent Seynhaeve + \version 1.00 + \date 25.09.2005 + + This class provides the functionality to read and write all attributes + relevant for nagiosAccount from/to the LDAP. It does syntax checking + and displays the formulars required. + */ + +class nagiosAccount extends plugin +{ + /* Definitions */ + var $plHeadline= "Nagios"; + var $plDescription= "This does something"; + + /* CLI vars */ + var $cli_summary= "Manage users nagios account"; + var $cli_description= "Manage Account and autorization\nfor Nagios"; + var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* plugin specific values */ + var $NagiosAlias = ""; + var $NagiosPager = ""; + var $NagiosMail = ""; + + var $HostNotificationOptions = ""; + var $HostNotificationPeriod = ""; + var $ServiceNotificationPeriod = ""; + var $ServiceNotitificationPeriod = ""; + var $HostNotificationCommands = ""; + var $ServiceNotificationCommands = ""; + var $HostNotitificationOptions = ""; + var $ServiceNotificationOptions = ""; + + var $AuthorizedAllHosts = "unchecked"; + var $AuthorizedAllServices = "unchecked"; + var $AuthorizedSystemCommands = "unchecked"; + var $AuthorizedAllHostCommands = "unchecked"; + var $AuthorizedAllServiceCommands = "unchecked"; + var $AuthorizedConfigurationInformation = "unchecked"; + var $AuthorizedSystemInformation = "unchecked"; + + /* attribute list for save action */ + + var $attributes= array("NagiosAlias", "NagiosPager", "NagiosMail", "HostNotificationPeriod", + "ServiceNotificationPeriod", "HostNotificationCommands", "ServiceNotificationCommands", + "HostNotificationOptions", "ServiceNotificationOptions", "AuthorizedAllHosts", "AuthorizedAllServices", + "AuthorizedSystemCommands", "AuthorizedAllHostCommands", "AuthorizedAllServiceCommands", + "AuthorizedConfigurationInformation", "AuthorizedSystemInformation"); + + var $is_chk_box = array("AuthorizedAllHosts","AuthorizedAllServices","AuthorizedSystemCommands", + "AuthorizedAllHostCommands","AuthorizedAllServiceCommands", + "AuthorizedConfigurationInformation","AuthorizedSystemInformation"); + + var $objectclasses= array("nagiosContact","nagiosAuth"); + + var $uid = ""; + var $view_logged = FALSE; + + /* constructor, if 'dn' is set, the node loads the given + 'dn' from LDAP */ + function nagiosAccount (&$config, $dn= NULL) + { + /* Configuration is fine, allways */ + $this->config= $config; + + plugin::plugin ($config, $dn); + + /* Setting uid to default */ + if(isset($this->attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + /* Save initial account state */ + $this->initially_was_account= $this->is_account; + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Load templating engine */ + $smarty= get_smarty(); + $display= ""; + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\"src=\"images/stop.png\" ". + _("This account has no nagios extensions.").""; + + $display.= back_to_main(); + return ($display); + } + + /* Show tab dialog headers */ + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove nagios account"), + _("This account has nagios features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Create nagios account"), _("This account has nagios features disabled. You can enable them by clicking below.")); + return($display); + } + } + + /* Assign acls */ + $tmp = $this->plInfo(); + $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + foreach($tmp['plProvidedAcls'] as $acl => $desc){ + $smarty->assign($acl."ACL",$this->getacl($acl,$SkipWrite)); + } + + /* Assign attributes an ACL to smarty */ + foreach($this->attributes as $val) { + $smarty->assign("$val", $this->$val); + if(in_array($val,$this->is_chk_box)){ + if($this->$val == "checked"){ + $smarty->assign($val."CHK", " checked "); + }else{ + $smarty->assign($val."CHK", ""); + } + } + } + $smarty->assign('ServiceNotificationOptionsValues' ,array("d,u,r,v"=>"d,u,r,v" ,"d,u,r"=>"d,u,r" ,"d,u"=>"d,u")); + $smarty->assign('HostNotificationOptionsValues' ,array("w,u,c,r"=>"w,u,c,r" ,"w,u,c"=>"w,u,c" ,"c,w"=>"c,w")); + $smarty->assign('ServiceNotificationPeriodValues' ,array("24x7"=>"24x7" ,"24x5"=>"24x5" ,"8x5"=>"8x5")); + $smarty->assign('HostNotificationPeriodValues' ,array("24x7"=>"24x7" ,"24x5"=>"24x5" ,"8x5"=>"8x5")); + $display.= $smarty->fetch (get_template_path('nagios.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + /* Save to LDAP */ + function save() + { + $ldap= $this->config->get_ldap_link(); + + /* Call parents save to prepare $this->attrs */ + plugin::save(); + + /* Adapt attributes if needed */ + //$method= new $this->method($this->config); + //$id= $method->uattrib; + //$method->fixAttributesOnStore($this); + + /* Write back to ldap */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/nagios account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add", array("uid" => $this->uid)); + } + } + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + $ldap= $this->config->get_ldap_link(); + /* must: mail */ + if ($this->NagiosAlias == ""){ + $message[]= _("The required field 'NagiosAlias' is not set."); + } + if ($this->NagiosMail == ""){ + $message[]= _("The required field 'NagiosMail' is not set."); + } + if ($this->is_template){ + if (!is_email($this->NagiosMail, TRUE)){ + $message[]= _("Please enter a valid email address in 'NagiosMail' field."); + } + } else { + if (!is_email($this->NagiosMail)){ + $message[]= _("Please enter a valid email address in 'NagiosMail' field."); + } + } + return($message); + } + + + /* Use Save_object for every Post handling */ + function save_object() + { + if (isset($_POST['nagiosTab'])){ + /* Save ldap attributes */ + plugin::save_object(); + + /* Specialhandling for checkboxes */ + foreach($this->is_chk_box as $val){ + if($this->acl_is_writeable($val)){ + if(isset($_POST[$val])){ + $this->$val = "checked"; + }else{ + $this->$val = "unchecked"; + } + } + } + } + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + /* Adapt attributes if needed */ + // $method= new $this->method($this->config); + // $method->fixAttributesOnRemove($this); + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + new log("view","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/nagios account with dn '%s' failed."),$this->dn)); + + /* remove the entry from LDAP */ + unset ($this->attrs['uid']); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove',array("uid" => $this->uid)); + } + + + + static function plInfo() + { + return (array( + "plShortName" => _("Nagios"), + "plDescription" => _("Nagios account settings"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 8, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + + "NagiosAlias" => _("Alias"), + "NagiosPager" => _("Pager number"), + "NagiosMail" => _("Mail address"), + + "HostNotificationCommands" => _("Host notification commands"), + "HostNotificationOptions" => _("Host notification options"), + "HostNotificationPeriod" => _("Host notification period"), + + "ServiceNotificationCommands" => _("Service notification commands"), + "ServiceNotificationOptions" => _("Service notification options"), + "ServiceNotificationPeriod" => _("Service notification period"), + + "AuthorizedAllHosts" => _("View all hosts"), + "AuthorizedAllServices" => _("View all services"), + + "AuthorizedSystemCommands" => _("Trigger system commands"), + "AuthorizedAllHostCommands" => _("Trigger all host commands"), + "AuthorizedAllServiceCommands" => _("Trigger all service commands"), + + "AuthorizedConfigurationInformation"=> _("View configuration information"), + "AuthorizedSystemInformation" => _("View system informations")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: + +?> diff --git a/gosa-core/plugins/personal/nagios/main.inc b/gosa-core/plugins/personal/nagios/main.inc new file mode 100644 index 000000000..c6a61b3b9 --- /dev/null +++ b/gosa-core/plugins/personal/nagios/main.inc @@ -0,0 +1,129 @@ +dn); + sess_del ('edit'); + sess_del ('nagiosAccount'); + } + + /* Create mail object on demand */ + if (!isset($_SESSION['nagiosAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['nagiosAccount']= new nagiosAccount ($config, $ui->dn); + $_SESSION['nagiosAccount']->enable_CSN_check(); + $_SESSION['nagiosAccount']->set_acl_base($ui->dn); + $_SESSION['nagiosAccount']->set_acl_category("users"); + } + $nagiosAccount= $_SESSION['nagiosAccount']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $nagiosAccount->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $nagiosAccount->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $nagiosAccount->save (); + del_lock ($ui->dn); + sess_del ('edit'); + + /* Remove object */ + sess_del ('nagiosAccount'); + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display.= $lock_msg; + }else{ + $display.= $nagiosAccount->execute (); + } + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['nagiosAccount']= $nagiosAccount; + } + + $info= ""; + /* Show page footer depending on the mode */ + if ($nagiosAccount->is_account && empty($lock_msg)){ + $display.= "

"; + + /* Are we in edit mode? */ + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/nagiosAccount"))){ + $info.= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); + $display.= "\n"; + } + $display.= "\n"; + } + $display.= "

\n"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/monitoring.png'), _("Nagios settings"), $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/nagios/nagios.tpl b/gosa-core/plugins/personal/nagios/nagios.tpl new file mode 100644 index 000000000..e77529add --- /dev/null +++ b/gosa-core/plugins/personal/nagios/nagios.tpl @@ -0,0 +1,192 @@ + + + + + + +
+

+  {t}Nagios Account{/t}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$must} +{render acl=$NagiosAliasACL} + +{/render} +
{$must} +{render acl=$NagiosMailACL} + +{/render} +
+ {$must} + +{render acl=$HostNotificationPeriodACL} + +{/render} +
+ {$must} + +{render acl=$ServiceNotificationPeriodACL} + +{/render} +
+ {$must} + +{render acl=$ServiceNotificationOptionsACL} + +{/render} +
+ {$must} + +{render acl=$HostNotificationOptionsACL} + +{/render} +
+ + +{render acl=$NagiosPagerACL} + +{/render} +
+ + +{render acl=$ServiceNotificationCommandsACL} + +{/render} +
+ + +{render acl=$HostNotificationCommandsACL} + +{/render} +
+
+   + +

+  {t}Nagios authentification{/t} +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+{render acl=$AuthorizedSystemInformationACL} + {t}view system informations{/t} +{/render} +
+{render acl=$AuthorizedConfigurationInformationACL} + {t}view configuration information{/t} +{/render} +
+{render acl=$AuthorizedSystemCommandsACL} + {t}trigger system commands{/t} +{/render} +
+{render acl=$AuthorizedAllServicesACL} + {t}view all services{/t} +{/render} +
+{render acl=$AuthorizedAllHostsACL} + {t}view all hosts{/t} +{/render} +
+{render acl=$AuthorizedAllServiceCommandsACL} + {t}trigger all service commands{/t} +{/render} +
+{render acl=$AuthorizedAllHostCommandsACL} + {t}trigger all host commands{/t} +{/render} +
+
+ + + + + + diff --git a/gosa-core/plugins/personal/netatalk/class_netatalk.inc b/gosa-core/plugins/personal/netatalk/class_netatalk.inc new file mode 100644 index 000000000..3693fda79 --- /dev/null +++ b/gosa-core/plugins/personal/netatalk/class_netatalk.inc @@ -0,0 +1,387 @@ + + Copyright (C) 2006 Bernd Zeimetz + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/*! \brief netatalk plugin + \author Gina Haeussge + \author Bernd Zeimetz + \version 0.1 + \date 21.3.2006 + + This class provides the functionality to read and write all attributes + relevant for netatalk from/to the LDAP. It does syntax checking + and displays the formulars required. + */ + +class netatalk extends plugin { + + /* Definitions */ + var $plHeadline = "Netatalk"; + var $plDescription = "Manage netatalk account"; + + /* CLI vars */ + var $cli_summary = "Manage netatalk account"; + var $cli_description = "Manage Account \nfor netatalk"; + var $cli_parameters = array ("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + var $view_logged = FALSE; + + /* Plugin specific values */ + var $apple_user_homepath_raw = ""; + var $apple_user_homeurl_raw = ""; + var $apple_user_homeurl_xml = ""; + var $apple_user_homeurl = ""; + var $apple_user_homeDirectory = ""; + var $apple_user_share = ""; + var $shares = array(); + var $shares_settings = array(); + var $selectedshare = ""; + var $mountDirectory = "/Network/Servers"; + + /* Attributes to save to LDAP */ + var $attributes = array ("apple-user-homeurl", "apple-user-homeDirectory"); + var $CopyPasteVars= array("apple_user_homeurl", "apple_user_homeDirectory","apple_user_share","shares_settings","apple_user_homepath_raw", + "apple_user_homeurl_raw","apple_user_homeurl_xml","apple_user_homeurl","selectedshare","mountDirectory"); + + /* Attributes to use in smarty template */ + var $smarty_attributes = array ("apple_user_homepath_raw", "shares", "selectedshare"); + + /* Attributes to save from $_POST */ + var $post_attributes = array ("apple_user_share", "apple_user_homepath_raw"); + + /* Objectclasses */ + var $objectclasses = array ("apple-user"); + + /* Checkboxes */ + var $is_chk_box = array (); + + var $uid =""; + + /* The constructor just saves a copy of the config. You may add what ever you need. */ + function netatalk(&$config, $dn = NULL) { + + /* Include config object */ + $this->config = $config; + plugin::plugin($config, $dn); + + /* set user id */ + if(isset($this->attrs['uid'])){ + $this->uid = $this->attrs['uid'][0]; + } + + /* Copy needed attributes */ + foreach($this->attributes as $val) { + if (isset($this->attrs["$val"][0])) { + $name = str_replace('-', '_', $val); + $this->$name = $this->attrs["$val"][0]; + } + } + + if (strlen($this->apple_user_homeDirectory) >0) { + $this->apple_user_homepath_raw = substr($this->apple_user_homeDirectory, strrpos($this->apple_user_homeDirectory, '/') + 1 ); + } + + /* get share list an set default values */ + $this->get_netatalk_shares(); + $this->apple_user_share = $this->selectedshare; + + /* Save initial account state */ + $this->initially_was_account = $this->is_account; + } + + + + /* Get netatalk shares */ + function get_netatalk_shares() + { + /* Get netatalk shares */ + $this->shares = array(); + $ldap = $this->config->get_ldap_link(); + + if($this->dn === "new" || $this->dn === NULL) { + $base = $_SESSION['CurrentMainBase']; + } else { + $base = preg_replace("/^[^,]+,".normalizePreg(get_people_ou())."/","",$this->dn); + } + + $ldap->cd($base); + $ldap->search ("(&(objectClass=mount)(|(mountType=url)(mountType=nfs))(cn=*))"); + + while ($attrs = $ldap->fetch()){ + $tmp = split(":", $attrs["cn"][0]); + $host = trim($tmp[0]); + $dir = trim($tmp[1]); + $mountType = trim($attrs["mountType"][0]); + if ($mountType == "url") { + $mountTypeReal = "netatalk"; + } else { + $mountTypeReal = $mountType; + } + $share = $attrs["cn"][0]. " (" . $mountTypeReal . ")"; + $this->shares[$share] = $share; + $this->shares_settings[$share]["mountType"]=$mountType; + $this->shares_settings[$share]["dir"]=$dir; + $this->shares_settings[$share]["host"]=$host; + + $oldShare=substr($this->apple_user_homeDirectory, 0, strrpos($this->apple_user_homeDirectory, '/')); + $newShare=($this->mountDirectory . "/". $host . $dir ); + if (strcmp($oldShare, $newShare)==0) { + $this->selectedshare = $share; + } + } + asort($this->shares); + } + + + /* Execute the plugin, produce the output. */ + function execute() + { + plugin :: execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Use the smarty templating engine here... */ + $smarty = get_smarty(); + $display = ""; + + /* Do we need to flip is_account state? */ + if (isset ($_POST['modify_state'])) { + $this->is_account = !$this->is_account; + } + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL) { + $display = "\"\"src=\"images/stop.png\" "._("This account has no netatalk extensions.").""; + + $display .= back_to_main(); + return ($display); + } + + /* Show tab dialog headers */ + if ($this->parent !== NULL) { + if ($this->is_account) { + $display = $this->show_disable_header(_("Remove netatalk account"), _("This account has netatalk features enabled. You can disable them by clicking below.")); + } else { + $errmsg=""; + $obj = $this->parent->by_object['posixAccount']; + if (!($obj->is_account) ) { + $errmsg.="Posix features are needed for netatalk accounts, enable them first. "; + } + if (count($this->shares)== 0) { + $errmsg.="At least one share with netatalk or NFS mount entry needed."; + } + if($errmsg==""){ + $display = $this->show_enable_header(_("Create netatalk account"), _("This account has netatalk features disabled. You can enable them by clicking below.")); + } else { + $display = $this->show_enable_header(_("Create netatalk account"), _($errmsg), TRUE); + } + return ($display); + } + } + + /* Assign attributes and ACL to smarty */ + $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + $smarty->assign("netatalkShareACL", $this->getacl("netatalkShare",$SkipWrite)); + $smarty->assign("netatalkUserHomepathACL", $this->getacl("netatalkUserHomepath",$SkipWrite)); + + foreach ($this->smarty_attributes as $val) { + $smarty->assign("$val", $this-> $val); + if (in_array($val, $this->is_chk_box)) { + if ($this-> $val == "checked") { + $smarty->assign($val."CHK", " checked "); + } else { + $smarty->assign($val."CHK", ""); + } + } + } + + /* Let smarty fetch and process the page. */ + $display .= ($smarty->fetch(get_template_path('netatalk.tpl', TRUE, dirname(__FILE__)))); + return ($display); + } + + + /* Check if we have correct data */ + function check() { + $message = array (); + + if (strlen($this->apple_user_share) == 0) { + $message[] = _("You must select a share to use."); + } + + return ($message); + } + + /* Save to LDAP */ + function save() { + /* remove a / at the end of the homepath, we neither need it there nor + * do we want to check for it later. + */ + if(substr($this->apple_user_homepath_raw, -1, 1) === '/') { + $this->apple_user_homepath_raw=substr($this->apple_user_homepath_raw, 0, -1); + } + + $mountType=$this->shares_settings[$this->apple_user_share]["mountType"]; + $dir=$this->shares_settings[$this->apple_user_share]["dir"]; + $host=$this->shares_settings[$this->apple_user_share]["host"]; + + /* Convert raw data to wished format */ + if ($this->is_account) { + if($mountType=="url") { + $this->apple_user_homeurl_xml = 'afp://'.$host.$dir . ''.$this->apple_user_homepath_raw.''; + $this->apple_user_homeurl = base64_encode($this->apple_user_homeurl_xml); + } else { + $this->apple_user_homeurl = ""; + } + $this->apple_user_homeDirectory = $this->mountDirectory . '/' . $host .$dir . '/' . $this->apple_user_homepath_raw; + } else { + $this->apple_user_homeurl = ""; + $this->apple_user_homeDirectory = ""; + } + + $ldap = $this->config->get_ldap_link(); + + /* Reset array of used attributes, because plugin::save() + will not work with '-' in attributes names + after calling save restore attributes array */ + $attributes = $this->attributes; + $this->attributes = array(); + plugin :: save(); + $this->attributes = $attributes; + + /* Do attribute conversion */ + foreach ($this->attributes as $val) { + $name = str_replace('-', '_', $val); + if ($this->$name != "") { + $this->attrs[$val] = $this->$name; + } else { + $this->attrs[$val] = array(); + } + unset ($this->attrs[$name]); + } + + /* Write back to ldap */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify($this->attrs); + + 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/netatalk account with dn '%s' failed."),$this->dn)); + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + } + + /* Use Save_object for every Post handling */ + function save_object() { + if (isset ($_POST['netatalkTab'])) { + /* Save ldap attributes */ + plugin :: save_object(); + + foreach($this->post_attributes as $val) { + if (isset ($_POST[$val])) { + $this->$val = $_POST[$val]; + } else { + $this->$val = ""; + } + } + + /* Specialhandling for checkboxes */ + foreach ($this->is_chk_box as $val) { + if (isset ($_POST[$val])) { + $this-> $val = "checked"; + } else { + $this-> $val = "unchecked"; + } + } + + $this->apple_user_homeurl_raw = 'afp://' . $this->apple_user_share; + } + } + + function remove_from_parent() { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account) { + return; + } + + /* include global link_info */ + $ldap = $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin :: remove_from_parent(); + + /* Adapt attributes if needed */ + // $method= new $this->method($this->config); + // $method->fixAttributesOnRemove($this); + + @ DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify($this->attrs); + + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/netatalk account with dn '%s' failed."),$this->dn)); + + /* remove the entry from LDAP */ + unset ($this->attrs['uid']); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove', array("uid" => $this->uid)); + } + + + /* Return plugin informations for acl handling*/ + static function plInfo() + { + return (array( + "plDescription" => _("Netatalk"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 6, + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "netatalkUserHomepath" => _("User home path"), + "netatalkShare" => _("Share")) + )); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/netatalk/main.inc b/gosa-core/plugins/personal/netatalk/main.inc new file mode 100644 index 000000000..e1a62c965 --- /dev/null +++ b/gosa-core/plugins/personal/netatalk/main.inc @@ -0,0 +1,117 @@ + + Copyright (C) 2006 Bernd Zeimetz + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +if (!$remove_lock) { + /* Reset requested? */ + if (isset ($_POST['edit_cancel']) || (isset ($_GET['reset']) && $_GET['reset'] == 1)) { + del_lock($ui->dn); + sess_del('edit'); + sess_del('netatalk'); + } + + /* Create netatalk object on demand */ + if (!isset ($_SESSION['netatalk']) || (isset ($_GET['reset']) && $_GET['reset'] == 1)) { + $_SESSION['netatalk'] = new netatalk($config, $ui->dn); + $_SESSION['netatalk']->enable_CSN_check(); + $_SESSION['netatalk']->set_acl_base($ui->dn); + $_SESSION['netatalk']->set_acl_category("users"); + } + $netatalk = $_SESSION['netatalk']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])) { + $netatalk->save_object(); + } + + /* Enter edit mode? */ + if (isset ($_POST['edit'])) { + + /* Check locking */ + if (($username = get_lock($ui->dn)) != "") { + $_SESSION['back_plugin'] = $plug; + gen_locked_message($username, $ui->dn); + exit (); + } + + /* Lock the current entry */ + add_lock($ui->dn, $ui->dn); + $_SESSION['dn'] = $ui->dn; + $_SESSION['edit'] = TRUE; + } + + /* save changes to LDAP and disable edit mode */ + if (isset ($_POST['edit_finish'])) { + + /* Perform checks */ + $message = $netatalk->check(); + + /* No errors, save object */ + if (count($message) == 0) { + $netatalk->save(); + del_lock($ui->dn); + sess_del('edit'); + + /* Remove object */ + sess_del('netatalk'); + } else { + /* Errors found, show message */ + show_errors($message); + } + } + + /* Execute formular */ + $display = $netatalk->execute(); + + /* Store changes in session */ + if (isset ($_SESSION['edit'])) { + $_SESSION['netatalk'] = $netatalk; + } + + $info = ""; + /* Show page footer depending on the mode */ + if ($netatalk->is_account) { + $display .= "

"; + + /* Are we in edit mode? */ + if (isset ($_SESSION['edit'])) { + $display .= "\n"; + $display .= " "; + $display .= "\n"; + $info = "\"\" ".$ui->dn." "; + } else { + $info = "\"\" ".$ui->dn." "; + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/netatalk"))){ + $info .= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); + $display .= "\n"; + } + + $display .= "\n"; + } + $display .= "

\n"; + } + + /* Page header*/ + $display = print_header(get_template_path('images/netatalk.png'), _("Netatalk settings"), $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/netatalk/netatalk.tpl b/gosa-core/plugins/personal/netatalk/netatalk.tpl new file mode 100644 index 000000000..c5bcc8ecc --- /dev/null +++ b/gosa-core/plugins/personal/netatalk/netatalk.tpl @@ -0,0 +1,33 @@ + + + + + + + + +
+ + + +{render acl=$netatalkShareACL} + +{/render} +
+ + +{render acl=$netatalkUserHomepathACL} + +{/render} +
+ + + + + diff --git a/gosa-core/plugins/personal/password/changed.tpl b/gosa-core/plugins/personal/password/changed.tpl new file mode 100644 index 000000000..16db30001 --- /dev/null +++ b/gosa-core/plugins/personal/password/changed.tpl @@ -0,0 +1,12 @@ + +

+ {t}You've successfully changed your password. Remember to change all programms configured to use it as well.{/t} +

+ +
+ +

+ +

+ + diff --git a/gosa-core/plugins/personal/password/class_password.inc b/gosa-core/plugins/personal/password/class_password.inc new file mode 100644 index 000000000..f9d5ac44a --- /dev/null +++ b/gosa-core/plugins/personal/password/class_password.inc @@ -0,0 +1,154 @@ +get_permissions($ui->dn,"users/password"); + $smarty->assign("ChangeACL" , $password_ACLS); + $smarty->assign("NotAllowed" , !preg_match("/w/i",$password_ACLS)); + + /* Display expiration template */ + if((isset($this->config->data['MAIN']['ACCOUNT_EXPIRATION'])) && + preg_match('/true/i', $this->config->data['MAIN']['ACCOUNT_EXPIRATION'])){ + $expired= ldap_expired_account($this->config, $ui->dn, $ui->username); + if($expired == 4){ + return($smarty->fetch(get_template_path("nochange.tpl", TRUE))); + } + } + + /* Pwd change requested */ + if (isset($_POST['password_finish'])){ + + /* Should we check different characters in new password */ + $check_differ = isset($this->config->data['MAIN']['PWDIFFER']); + $differ = @$this->config->data['MAIN']['PWDIFFER']; + + /* Enable length check ? */ + $check_length = isset($this->config->data['MAIN']['PWMINLEN']); + $length = @$this->config->data['MAIN']['PWMINLEN']; + + /* Call external password quality hook ?*/ + $check_hook = isset($this->config->data['MAIN']['EXTERNALPWDHOOK']); + $hook = @$this->config->data['MAIN']['EXTERNALPWDHOOK']." ".$ui->username." ".$_POST['current_password']." ".$_POST['new_password']; + if($check_hook){ + exec($hook,$resarr); + $check_hook_output = ""; + if(count($resarr) > 0) { + $check_hook_output= join('\n', $resarr); + } + } + + /* Check given values */ + if(!isset($_POST['current_password']) || empty($_POST['current_password'])){ + msg_dialog::display(_("User password"), + _("You need to specify your current password in order to proceed."),WARNING_DIALOG); + }elseif ($_POST['new_password'] != $_POST['repeated_password']){ + msg_dialog::display(_("User password"), + _("The passwords you've entered as 'New password' and 'Repeated new password' do not match."),WARNING_DIALOG); + } elseif ($_POST['new_password'] == ""){ + msg_dialog::display(_("User password"), + _("The password you've entered as 'New password' is empty."),WARNING_DIALOG); + }elseif($check_differ && (substr($_POST['current_password'], 0, $differ) == substr($_POST['new_password'], 0, $differ))){ + msg_dialog::display(_("User password"), + _("The password used as new and current are too similar."),WARNING_DIALOG); + }elseif($check_length && (strlen($_POST['new_password']) < $length)){ + msg_dialog::display(_("User password"), + _("The password used as new is to short."),WARNING_DIALOG); + }elseif($check_hook && $check_hook_output != ""){ + msg_dialog::display(_("User password"), + sprintf(_("External password changer reported a problem: %s."),$check_hook_output),WARNING_DIALOG); + }else{ + + /* Try to connect via current password */ + $tldap = new LDAP( + $ui->dn, + $_POST['current_password'], + $this->config->current['SERVER'], + isset($this->config->current['RECURSIVE']) && preg_match("/true/i",$this->config->current['RECURSIVE']), + isset($this->config->current['TLS']) && preg_match("/true/i",$this->config->current['TLS'])); + + /* connection Successfull ? */ + if ($tldap->error != "Success"){ + msg_dialog::display(_("User password"), + _("The password you've entered as your current password doesn't match the real one."),WARNING_DIALOG); + }else{ + + /* Check GOsa permissions */ + if (!preg_match("/w/i",$password_ACLS)){ + msg_dialog::display(_("User password"), + _("You have no permissions to change your password."),WARNING_DIALOG); + }else{ + change_password ($ui->dn, $_POST['new_password']); + gosa_log ("User/password has been changed"); + $ui->password= $_POST['new_password']; + $_SESSION['ui']= $ui; +#$this->handle_post_events("modify",array("userPassword" => $_POST['new_password'])); + return($smarty->fetch(get_template_path("changed.tpl", TRUE))); + } + } + } + } + return($smarty->fetch(get_template_path("password.tpl", TRUE))); + } + + function remove_from_parent() + { + $this->handle_post_events("remove"); + } + + function save() + { + } + + static function plInfo() + { + return (array( + "plDescription" => _("User password"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 10, + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array()) + ); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/password/main.inc b/gosa-core/plugins/personal/password/main.inc new file mode 100644 index 000000000..b8135bc6a --- /dev/null +++ b/gosa-core/plugins/personal/password/main.inc @@ -0,0 +1,51 @@ +dn); + sess_del ('edit'); + sess_del ('password'); + } + + /* Create password object on demand */ + if (!isset($_SESSION['password']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['password']= new password ($config, $ui->dn); + } + $password= $_SESSION['password']; + + /* Execute formular */ + $display.= $password->execute (); + + /* Page header*/ + $display= print_header(get_template_path('images/password.png'), + _("Password settings"), "").$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/password/nochange.tpl b/gosa-core/plugins/personal/password/nochange.tpl new file mode 100644 index 000000000..d7164f67e --- /dev/null +++ b/gosa-core/plugins/personal/password/nochange.tpl @@ -0,0 +1,11 @@ +
+ {t}Password change not allowed{/t}> +
+ +

+ {t}You are not allowed to change your password at this time{/t} +

+ +
+ + diff --git a/gosa-core/plugins/personal/password/password.tpl b/gosa-core/plugins/personal/password/password.tpl new file mode 100644 index 000000000..0787b7056 --- /dev/null +++ b/gosa-core/plugins/personal/password/password.tpl @@ -0,0 +1,44 @@ +

+ {t}To change your personal password use the fields below. The changes take effect immediately. Please memorize the new password, because you wouldn't be able to login without it.{/t} +

+ +

+ {t}Changing the password affects your authentification on mail, proxy, samba and unix services.{/t} +

+ + + + + + + + + + + + + + +
+ +
+ +

+ +   + +

+ + + + + + diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc new file mode 100644 index 000000000..e1a5412c9 --- /dev/null +++ b/gosa-core/plugins/personal/posix/class_posixAccount.inc @@ -0,0 +1,1433 @@ + + \version 2.00 + \date 24.07.2003 + + This class provides the functionality to read and write all attributes + relevant for posixAccounts and shadowAccounts from/to the LDAP. It + does syntax checking and displays the formulars required. + */ + +class posixAccount extends plugin +{ + /* Definitions */ + var $plHeadline= "UNIX"; + var $plDescription= "This does something"; + + /* CLI vars */ + var $cli_summary= "Manage users posix account"; + var $cli_description= "Some longer text\nfor help"; + var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Plugin specific values */ + var $homeDirectory= ""; + var $loginShell= "/bin/bash"; + var $uidNumber= ""; + var $gidNumber= ""; + var $gecos= ""; + var $shadowMin= "0"; + var $shadowMax= "0"; + var $shadowWarning= "0"; + var $shadowLastChange= "0"; + var $shadowInactive= "0"; + var $shadowExpire= "0"; + var $gosaDefaultPrinter= ""; + var $accessTo= array(); + var $trustModel= ""; + + var $glist=array(); + var $status= ""; + var $loginShellList= array(); + var $groupMembership= array(); + var $savedGroupMembership= array(); + var $savedUidNumber= ""; + var $savedGidNumber= ""; + var $use_shadowMin= "0"; + var $use_shadowMax= "0"; + var $use_shadowWarning= "0"; + var $use_shadowInactive= "0"; + var $use_shadowExpire= "0"; + var $mustchangepassword= "0"; + var $force_ids= 0; + var $group_dialog= FALSE; + var $show_ws_dialog= FALSE; + var $secondaryGroups= array(); + var $primaryGroup= 0; + var $was_trust_account= FALSE; + var $memberGroup = array(); + var $grouplist = array(); + var $ui = array(); + + var $GroupRegex = "*"; + var $GroupUserRegex = "*"; + var $SubSearch = false; + + var $view_logged = FALSE; + + /* attribute list for save action */ + var $CopyPasteVars = + array("grouplist","groupMembership","use_shadowMin", + "use_shadowMax","use_shadowWarning","use_shadowInactive","use_shadowExpire", + "must_change_password","printerList","grouplist","savedGidNumber","savedUidNumber"); + + var $attributes = array("homeDirectory", "loginShell", "uidNumber", "gidNumber", "gecos", + "shadowMin", "shadowMax", "shadowWarning", "shadowInactive", "shadowLastChange", + "shadowExpire", "gosaDefaultPrinter", "uid","accessTo","trustModel"); + + var $objectclasses= array("posixAccount", "shadowAccount"); + + var $uid= ""; + var $multiple_support = TRUE; + + /* constructor, if 'dn' is set, the node loads the given + 'dn' from LDAP */ + function posixAccount (&$config, $dn= NULL) + { + /* Configuration is fine, allways */ + $this->config= $config; + + /* Load bases attributes */ + plugin::plugin($config, $dn); + + /* Setting uid to default */ + if(isset($this->attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + $ldap= $this->config->get_ldap_link(); + + if ($dn !== NULL){ + + /* Correct is_account. shadowAccount is not required. */ + if (isset($this->attrs['objectClass']) && + in_array ('posixAccount', $this->attrs['objectClass'])){ + + $this->is_account= TRUE; + } + + /* Is this account a trustAccount? */ + if ($this->is_account && isset($this->attrs['trustModel'])){ + $this->trustModel= $this->attrs['trustModel'][0]; + $this->was_trust_account= TRUE; + } else { + $this->was_trust_account= FALSE; + $this->trustModel= ""; + } + + $this->accessTo = array(); + if ($this->is_account && isset($this->attrs['accessTo'])){ + for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){ + $tmp= $this->attrs['accessTo'][$i]; + $this->accessTo[$tmp]= $tmp; + } + } + $this->initially_was_account= $this->is_account; + + /* Fill group */ + $this->primaryGroup= $this->gidNumber; + + /* Generate status text */ + $current= date("U"); + + $current= floor($current / 60 /60 / 24); + + if (($current >= $this->shadowExpire) && $this->shadowExpire){ + $this->status= _("expired"); + if (($current - $this->shadowExpire) < $this->shadowInactive){ + $this->status.= ", "._("grace time active"); + } + } elseif (($this->shadowLastChange + $this->shadowMin) >= $current){ + $this->status= _("active, password not changable"); + } elseif (($this->shadowLastChange + $this->shadowMax) >= $current){ + $this->status= _("active, password expired"); + } else { + $this->status= _("active"); + } + + /* Get group membership */ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("cn", "description")); + + while ($this->attrs= $ldap->fetch()){ + if (!isset($this->attrs["description"][0])){ + $entry= $this->attrs["cn"][0]; + } else { + $dsc= preg_replace ('/^Group of user/', _("Group of user"), $this->attrs["description"][0]); + $entry= $this->attrs["cn"][0]." [$dsc]"; + } + $this->groupMembership[$ldap->getDN()]= $entry; + } + asort($this->groupMembership); + reset($this->groupMembership); + $this->savedGroupMembership= $this->groupMembership; + $this->savedUidNumber= $this->uidNumber; + $this->savedGidNumber= $this->gidNumber; + } + + /* Adjust shadow checkboxes */ + foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive", + "shadowExpire") as $val){ + + if ($this->$val != 0){ + $oval= "use_".$val; + $this->$oval= "1"; + } + } + + /* Convert to seconds */ + $this->shadowExpire= $this->convertToSeconds($this->shadowExpire); + + /* Generate shell list from CONFIG_DIR./shells */ + if (file_exists(CONFIG_DIR.'/shells')){ + $shells = file (CONFIG_DIR.'/shells'); + foreach ($shells as $line){ + if (!preg_match ("/^#/", $line)){ + $this->loginShellList[]= trim($line); + } + } + } else { + if ($this->loginShell == ""){ + $this->loginShellList[]= _("unconfigured"); + } + } + + /* Insert possibly missing loginShell */ + if ($this->loginShell != "" && !in_array($this->loginShell, $this->loginShellList)){ + $this->loginShellList[]= $this->loginShell; + } + + /* Generate group list */ + $this->ui = get_userinfo(); + $this->secondaryGroups[]= "- "._("automatic")." -"; + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=posixGroup)", array("cn", "gidNumber")); + while($attrs = $ldap->fetch()){ + $this->secondaryGroups[$attrs['gidNumber'][0]]= $attrs['cn'][0]; + } + asort ($this->secondaryGroups); + + /* Get global filter config */ + if (!is_global("sysfilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $sysfilter= array( "depselect" => $base, + "regex" => "*"); + register_global("sysfilter", $sysfilter); + } + $this->ui = get_userinfo(); + } + + + /* execute generates the html output for this node */ + function execute($isCopyPaste = false) + { + /* Call parent execute */ + plugin::execute(); + $display= ""; + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Department has changed? */ + if(isset($_POST['depselect'])){ + $_SESSION['CurrentMainBase']= validate($_POST['depselect']); + } + + if($this->multiple_support_active){ + $this->is_account = TRUE; + } + + if(!$isCopyPaste && ! $this->multiple_support_active){ + + /* Do we need to flip is_account state? */ + 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; + } + } + + /* Do we represent a valid posixAccount? */ + if (!$this->is_account && $this->parent === NULL ){ + $display= "\"\" ". + _("This account has no unix extensions.").""; + $display.= back_to_main(); + return ($display); + } + + + /* Show tab dialog headers */ + if ($this->parent !== NULL){ + if ($this->is_account){ + if (isset($this->parent->by_object['sambaAccount'])){ + $obj= $this->parent->by_object['sambaAccount']; + } + if (isset($obj) && $obj->is_account == TRUE && + ((isset($this->parent->by_object['sambaAccount']))&&($this->parent->by_object['sambaAccount']->is_account)) + ||(isset($this->parent->by_object['environment'] ))&&($this->parent->by_object['environment'] ->is_account)){ + + /* Samba3 dependency on posix accounts are enabled + in the moment, because I need to rely on unique + uidNumbers. There'll be a better solution later + on. */ + $display= $this->show_disable_header(_("Remove posix account"), + _("This account has unix features enabled. To disable them, you'll need to remove the samba / environment account first."), TRUE); + } else { + $display= $this->show_disable_header(_("Remove posix account"), + _("This account has posix features enabled. You can disable them by clicking below.")); + } + } else { + $display= $this->show_enable_header(_("Create posix account"), + _("This account has posix features disabled. You can enable them by clicking below.")); + return($display); + } + } + } + /* Trigger group edit? */ + if (isset($_POST['edit_groupmembership'])){ + $this->group_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Cancel group edit? */ + if (isset($_POST['add_groups_cancel']) || + isset($_POST['add_groups_finish'])){ + $this->group_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Add selected groups */ + if (isset($_POST['add_groups_finish']) && isset($_POST['groups']) && + count($_POST['groups'])){ + + $this->addGroup ($_POST['groups']); + } + + /* Delete selected groups */ + if (isset($_POST['delete_groupmembership']) && + isset($_POST['group_list']) && count($_POST['group_list'])){ + + $this->delGroup ($_POST['group_list']); + } + + /* Add user workstation? */ + if (isset($_POST["add_ws"])){ + $this->show_ws_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Add user workstation? */ + if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){ + foreach($_POST['wslist'] as $ws){ + $this->accessTo[$ws]= $ws; + } + ksort($this->accessTo); + $this->is_modified= TRUE; + } + + /* Remove user workstations? */ + if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){ + foreach($_POST['workstation_list'] as $name){ + unset ($this->accessTo[$name]); + } + $this->is_modified= TRUE; + } + + /* Add user workstation finished? */ + if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){ + $this->show_ws_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Templates now! */ + $smarty= get_smarty(); + + /* Show ws dialog */ + if ($this->show_ws_dialog){ + /* Save data */ + $sysfilter= get_global("sysfilter"); + foreach( array("depselect", "regex") as $type){ + if (isset($_POST[$type])){ + $sysfilter[$type]= $_POST[$type]; + } + } + if (isset($_GET['search'])){ + $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; + if ($s == "**"){ + $s= "*"; + } + $sysfilter['regex']= $s; + } + register_global("sysfilter", $sysfilter); + + /* Get workstation list */ + $exclude= ""; + foreach($this->accessTo as $ws){ + $exclude.= "(cn=$ws)"; + } + if ($exclude != ""){ + $exclude= "(!(|$exclude))"; + } + $regex= $sysfilter['regex']; + $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))"; + $res= get_list($filter, "groups", $sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT); + $wslist= array(); + foreach ($res as $attrs){ + $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]); + } + asort($wslist); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("alphabet", generate_alphabet()); + foreach( array("depselect", "regex") as $type){ + $smarty->assign("$type", $sysfilter[$type]); + } + $smarty->assign("hint", print_sizelimit_warning()); + $smarty->assign("wslist", $wslist); + $smarty->assign("apply", apply_filter()); + $display= $smarty->fetch (get_template_path('trust_machines.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + /* Manage group add dialog */ + if ($this->group_dialog){ + + /* Get global filter config */ + $this->reload(); + + /* remove already assigned groups */ + $glist= array(); + foreach ($this->grouplist as $key => $value){ + if (!isset($this->groupMembership[$key]) && obj_is_writable($key,"groups/group","memberUid")){ + $glist[$key]= $value; + } + } + + if($this->SubSearch){ + $smarty->assign("SubSearchCHK"," checked "); + }else{ + $smarty->assign("SubSearchCHK",""); + } + + $smarty->assign("regex",$this->GroupRegex); + $smarty->assign("guser",$this->GroupUserRegex); + $smarty->assign("groups", $glist); + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("depselect",$_SESSION['CurrentMainBase']); + $smarty->assign("hint", print_sizelimit_warning()); + + $smarty->assign("apply", apply_filter()); + $display.= $smarty->fetch (get_template_path('posix_groups.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + /* Show main page */ + $smarty= get_smarty(); + + /* In 'MyAccount' mode, we must remove write acls if we are not in editing mode. */ + $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + + /* Depending on pwmode, currently hardcoded because there are no other methods */ + if ( 1 == 1 ){ + $smarty->assign("pwmode", dirname(__FILE__)."/posix_shadow"); + + $shadowMinACL = $this->getacl("shadowMin",$SkipWrite); + $smarty->assign("shadowmins", sprintf(_("Password can't be changed up to %s days after last change"), + "shadowMin."\">")); + + $shadowMaxACL = $this->getacl("shadowMax",$SkipWrite); + $smarty->assign("shadowmaxs", sprintf(_("Password must be changed after %s days"), + "shadowMax."\">")); + + $shadowInactiveACL= $this->getacl("shadowInactive",$SkipWrite); + $smarty->assign("shadowinactives", sprintf(_("Disable account after %s days of inactivity after password expiery"), + "shadowInactive."\">")); + + $shadowWarningACL = $this->getacl("shadowWarning",$SkipWrite); + $smarty->assign("shadowwarnings", sprintf(_("Warn user %s days before password expiery"), + "shadowWarning."\">")); + + foreach( array("use_shadowMin", "use_shadowMax", + "use_shadowExpire", "use_shadowInactive","use_shadowWarning") as $val){ + if ($this->$val == 1){ + $smarty->assign("$val", "checked"); + } else { + $smarty->assign("$val", ""); + } + $smarty->assign("$val"."ACL", $this->getacl($val,$SkipWrite)); + } + + if($this->mustchangepassword){ + $smarty->assign("mustchangepassword", "checked"); + } else { + $smarty->assign("mustchangepassword", ""); + } + $smarty->assign("mustchangepasswordACL", $this->getacl("mustchangepassword",$SkipWrite)); + } + + /* Fill calendar */ + /* If this $this->shadowExpire is empty + use current date as base for calculating selectbox values. + (This attribute is empty if this is a new user )*/ + if(empty($this->shadowExpire)){ + $date= getdate(time()); + }else{ + $date= getdate($this->shadowExpire); + } + + $days= array(); + for($d= 1; $d<32; $d++){ + $days[$d]= $d; + } + $years= array(); + for($y= $date['year']-10; $y<$date['year']+10; $y++){ + $years[]= $y; + } + $months= array(_("January"), _("February"), _("March"), _("April"), + _("May"), _("June"), _("July"), _("August"), _("September"), + _("October"), _("November"), _("December")); + $smarty->assign("day", $date["mday"]); + $smarty->assign("days", $days); + $smarty->assign("months", $months); + $smarty->assign("month", $date["mon"]-1); + $smarty->assign("years", $years); + $smarty->assign("year", $date["year"]); + + /* Fill arrays */ + $smarty->assign("shells", $this->loginShellList); + $smarty->assign("secondaryGroups", $this->secondaryGroups); + $smarty->assign("primaryGroup", $this->primaryGroup); + if (!count($this->groupMembership)){ + $smarty->assign("groupMembership", array(" ")); + } else { + $smarty->assign("groupMembership", $this->groupMembership); + } + if (count($this->groupMembership) > 16){ + $smarty->assign("groups", "too_many_for_nfs"); + } else { + $smarty->assign("groups", ""); + } + + /* Avoid "Undefined index: forceMode" */ + $smarty->assign("forceMode", ""); + + /* Checkboxes */ + if ($this->force_ids == 1){ + $smarty->assign("force_ids", "checked"); + if ($_SESSION['js']){ + $smarty->assign("forceMode", ""); + } + } else { + if ($_SESSION['js']){ + $smarty->assign("forceMode", "disabled"); + } + $smarty->assign("force_ids", ""); + } + + + + $smarty->assign("force_idsACL", $this->getacl("uidNumber",$SkipWrite).$this->getacl("gidNumber",$SkipWrite)); + + foreach(array("primaryGroup") as $val){ + if(in_array($val,$this->multi_boxes)){ + $smarty->assign("use_".$val,TRUE); + }else{ + $smarty->assign("use_".$val,FALSE); + } + } + + + /* Load attributes and acl's */ + foreach($this->attributes as $val){ + if(in_array($val,$this->multi_boxes)){ + $smarty->assign("use_".$val,TRUE); + }else{ + $smarty->assign("use_".$val,FALSE); + } + + if(($_SESSION["js"])&&(($val=="uidNumber")||($val=="gidNumber"))) + { + $smarty->assign("$val"."ACL",$this->getacl($val,$SkipWrite)); + $smarty->assign("$val", $this->$val); + continue; + } + $smarty->assign("$val", $this->$val); + $smarty->assign("$val"."ACL", $this->getacl($val,$SkipWrite)); + } + if($SkipWrite){ + $smarty->assign("groupMembershipACL","r"); + }else{ + $smarty->assign("groupMembershipACL","rw"); + } + $smarty->assign("status", $this->status); + + /* Work on trust modes */ + $smarty->assign("trusthide", " disabled "); + $smarty->assign("trustmodeACL", $this->getacl("trustModel",$SkipWrite)); + if ($this->trustModel == "fullaccess"){ + $trustmode= 1; + // pervent double disable tag in html code, this will disturb our clean w3c html + $smarty->assign("trustmode", $this->getacl("trustModel",$SkipWrite)); + + } elseif ($this->trustModel == "byhost"){ + $trustmode= 2; + $smarty->assign("trusthide", ""); + } else { + // pervent double disable tag in html code, this will disturb our clean w3c html + $smarty->assign("trustmode", $this->getacl("trustModel",$SkipWrite)); + $trustmode= 0; + } + $smarty->assign("trustmode", $trustmode); + $smarty->assign("trustmodes", array( 0 => _("disabled"), 1 => _("full access"), + 2 => _("allow access to these hosts"))); + + + + if((count($this->accessTo))==0) + $smarty->assign("emptyArrAccess",true); + else + $smarty->assign("emptyArrAccess",false); + + + + $smarty->assign("workstations", $this->accessTo); + + $smarty->assign("apply", apply_filter()); + $smarty->assign("multiple_support" , $this->multiple_support_active); + $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); + return($display); + } + + + /* remove object from parent */ + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){ + return; + } + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + /* Zero out array */ + $this->attrs['gosaHostACL']= array(); + + /* Keep uid, because we need it for authentification! */ + unset($this->attrs['uid']); + unset($this->attrs['trustModel']); + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/posix account with dn '%s' failed."),$this->dn)); + + /* Delete group only if cn is uid and there are no other + members inside */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn", "memberUid")); + if ($ldap->count() != 0){ + $attrs= $ldap->fetch(); + if ($attrs['cn'][0] == $this->uid && + !isset($this->attrs['memberUid'])){ + + $ldap->rmDir($ldap->getDN()); + } + } + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove",array("uid" => $this->uid)); + } + + + function save_object() + { + if (isset($_POST['posixTab'])){ + /* Save values to object */ + plugin::save_object(); + + + /* Save force GID checkbox */ + if($this->acl_is_writeable("gidNumber") || $this->acl_is_writeable("uidNumber")){ + if (isset ($_POST['force_ids'])){ + $data= 1; + } else { + $data= 0; + } + if ($this->force_ids != $data){ + $this->is_modified= TRUE; + } + $this->force_ids= $data; + } + + /*Save primary group settings */ + if($this->acl_is_writeable("primaryGroup") && isset($_POST['primaryGroup'])){ + $data= $_POST['primaryGroup']; + if ($this->primaryGroup != $data){ + $this->is_modified= TRUE; + } + $this->primaryGroup= $_POST['primaryGroup']; + } + + foreach(array("shadowMin","shadowMax","shadowExpire","shadowInactive","shadowWarning","mustchangepassword") as $var) { + if($this->acl_is_writeable($var)){ + $use_var = "use_".$var; + if(isset($_POST['use_'.$var])){ + $this->$use_var = true; + $this->$var = $_POST[$var]; + }else{ + $this->$use_var = false; + $this->$var = 0; + } + } + } + + /* Trust mode - special handling */ + if($this->acl_is_writeable("trustModel")){ + if (isset($_POST['trustmode'])){ + $saved= $this->trustModel; + if ($_POST['trustmode'] == "1"){ + $this->trustModel= "fullaccess"; + } elseif ($_POST['trustmode'] == "2"){ + $this->trustModel= "byhost"; + } else { + $this->trustModel= ""; + } + if ($this->trustModel != $saved){ + $this->is_modified= TRUE; + } + } + } + } + + /* Get regex from alphabet */ + if(isset($_GET['search'])){ + $this->GroupRegex = $_GET['search']."*"; + } + + /* Check checkboxes and regexes */ + if(isset($_POST["PosixGroupDialogPosted"])){ + + if(isset($_POST['SubSearch']) && ($_POST['SubSearch'])){ + $this->SubSearch = true; + }else{ + $this->SubSearch = false; + } + if(isset($_POST['guser'])){ + $this->GroupUserRegex = $_POST['guser']; + } + if(isset($_POST['regex'])){ + $this->GroupRegex = $_POST['regex']; + } + } + $this->GroupRegex = preg_replace("/\*\**/","*",$this->GroupRegex); + $this->GroupUserRegex = preg_replace("/\*\**/","*",$this->GroupUserRegex); + } + + + /* Save data to LDAP, depending on is_account we save or delete */ + function save() + { + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Adapt shadow values */ + if (!$this->use_shadowExpire){ + $this->shadowExpire= "0"; + } else { + /* Transform seconds to days here */ + $this->shadowExpire= (int)($this->shadowExpire / (60 * 60 * 24)) ; + } + if (!$this->use_shadowMax){ + $this->shadowMax= "0"; + } + if ($this->mustchangepassword){ + $this->shadowLastChange= (int)(date("U") / 86400) - $this->shadowMax - 1; + } else { + $this->shadowLastChange= (int)(date("U") / 86400); + } + if (!$this->use_shadowWarning){ + $this->shadowWarning= "0"; + } + + /* Check what to do with ID's */ + if ($this->force_ids == 0){ + + /* Use id's that are already set */ + if ($this->savedUidNumber != ""){ + $this->uidNumber= $this->savedUidNumber; + $this->gidNumber= $this->savedGidNumber; + } else { + + /* Calculate new id's. We need to place a lock before calling get_next_id + to get real unique values. */ + $wait= 10; + while (get_lock("uidnumber") != ""){ + sleep (1); + + /* Oups - timed out */ + if ($wait-- == 0){ + print_red (_("Failed: overriding lock")); + break; + } + } + + add_lock ("uidnumber", "gosa"); + $this->uidNumber= $this->get_next_id("uidNumber", $this->dn); + if ($this->savedGidNumber != ""){ + $this->gidNumber= $this->savedGidNumber; + } else { + $this->gidNumber= $this->get_next_id("gidNumber", $this->dn); + } + } + + if ($this->primaryGroup != 0){ + $this->gidNumber= $this->primaryGroup; + } + } + + if ($this->use_shadowMin != "1" ) { + $this->shadowMin = ""; + } + + if (($this->use_shadowMax != "1") && ($this->mustchangepassword != "1")) { + $this->shadowMax = ""; + } + + if ($this->use_shadowWarning != "1" ) { + $this->shadowWarning = ""; + } + + if ($this->use_shadowInactive != "1" ) { + $this->shadowInactive = ""; + } + + if ($this->use_shadowExpire != "1" ) { + $this->shadowExpire = ""; + } + + /* Fill gecos */ + if (isset($this->parent) && $this->parent !== NULL){ + $this->gecos= rewrite($this->parent->by_object['user']->cn); + if (!preg_match('/^[a-z0-9 -]+$/i', $this->gecos)){ + $this->gecos= ""; + } + } + + foreach(array("shadowMin","shadowMax","shadowWarning","shadowInactive","shadowExpire") as $attr){ + $this->$attr = (int) $this->$attr; + } + /* Call parents save to prepare $this->attrs */ + plugin::save(); + + /* Trust accounts */ + $objectclasses= array(); + foreach ($this->attrs['objectClass'] as $key => $class){ + if (preg_match('/trustAccount/i', $class)){ + continue; + } + $objectclasses[]= $this->attrs['objectClass'][$key]; + } + $this->attrs['objectClass']= $objectclasses; + if ($this->trustModel != ""){ + $this->attrs['objectClass'][]= "trustAccount"; + $this->attrs['trustModel']= $this->trustModel; + $this->attrs['accessTo']= array(); + if ($this->trustModel == "byhost"){ + foreach ($this->accessTo as $host){ + $this->attrs['accessTo'][]= $host; + } + } + } else { + if ($this->was_trust_account){ + $this->attrs['accessTo']= array(); + $this->attrs['trustModel']= array(); + } + } + + if(empty($this->attrs['gosaDefaultPrinter'])){ + $thid->attrs['gosaDefaultPrinter']=array(); + } + + + /* Save data to LDAP */ + $ldap->cd($this->dn); + $this->cleanup(); + unset($this->attrs['uid']); + $ldap->modify ($this->attrs); + + /* 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/posix account with dn '%s' failed."),$this->dn)); + + /* Remove lock needed for unique id generation */ + del_lock ("uidnumber"); + + /* Posix accounts have group interrelationship, + take care about these here if this is a new user without forced gidNumber. */ + if ($this->force_ids == 0 && $this->primaryGroup == 0 && !$this->initially_was_account){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn")); + + /* Create group if it doesn't exist */ + if ($ldap->count() == 0){ + $groupdn= preg_replace ('/^'.$this->config->current['DNMODE'].'=[^,]+,'.get_people_ou().'/i', 'cn='.$this->uid.','.get_groups_ou(), $this->dn); + + $g= new group($this->config, $groupdn); + $g->cn= $this->uid; + $g->force_gid= 1; + $g->gidNumber= $this->gidNumber; + $g->description= "Group of user ".$this->givenName." ".$this->sn; + $g->save (); + } + } + + /* Take care about groupMembership values: add to groups */ + foreach ($this->groupMembership as $key => $value){ + if (!isset($this->savedGroupMembership[$key])){ + $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key,"groups"); + $g->set_acl_base($key); + $g->by_object['group']->addUser($this->uid); + $g->save(); + } + } + + /* Remove from groups not listed in groupMembership */ + foreach ($this->savedGroupMembership as $key => $value){ + if (!isset($this->groupMembership[$key])){ + $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key,"groups"); + $g->set_acl_base($key); + $g->by_object['group']->removeUser ($this->uid); + $g->save(); + } + } + + /* 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",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add" ,array("uid"=> $this->uid)); + } + } + + /* Check formular input */ + function check() + { + /* Include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Append groups as memberGroup: to check hook + */ + $tmp_attributes = $this->attributes; + $this->attributes[] = "memberGroup"; + $this->memberGroup = array(); + foreach($this->groupMembership as $dn => $name){ + $this->memberGroup[] = $name; + } + + /* Call common method to give check the hook */ + $message= plugin::check(); + $this->attributes = $tmp_attributes; + + /* must: homeDirectory */ + if ($this->homeDirectory == ""){ + $message[]= _("The required field 'Home directory' is not set."); + } + if (!is_path($this->homeDirectory)){ + $message[]= _("Please enter a valid path in 'Home directory' field."); + } + + /* Check ID's if they are forced by user */ + if ($this->force_ids == "1"){ + + /* Valid uid/gid? */ + if (!is_id($this->uidNumber)){ + $message[]= _("Value specified as 'UID' is not valid."); + } else { + if ($this->uidNumber < $this->config->current['MINID']){ + $message[]= _("Value specified as 'UID' is too small."); + } + } + if (!is_id($this->gidNumber)){ + $message[]= _("Value specified as 'GID' is not valid."); + } else { + if ($this->gidNumber < $this->config->current['MINID']){ + $message[]= _("Value specified as 'GID' is too small."); + } + } + } + + /* Check shadow settings, well I like spaghetties... */ + if ($this->use_shadowMin){ + if (!is_id($this->shadowMin)){ + $message[]= _("Value specified as 'shadowMin' is not valid."); + } + } + if ($this->use_shadowMax){ + if (!is_id($this->shadowMax)){ + $message[]= _("Value specified as 'shadowMax' is not valid."); + } + } + if ($this->use_shadowWarning){ + if (!is_id($this->shadowWarning)){ + $message[]= _("Value specified as 'shadowWarning' is not valid."); + } + if (!$this->use_shadowMax){ + $message[]= _("'shadowWarning' without 'shadowMax' makes no sense."); + } + if ($this->shadowWarning > $this->shadowMax){ + $message[]= _("Value specified as 'shadowWarning' should be smaller than 'shadowMax'."); + } + if ($this->use_shadowMin && $this->shadowWarning < $this->shadowMin){ + $message[]= _("Value specified as 'shadowWarning' should be greater than 'shadowMin'."); + } + } + if ($this->use_shadowInactive){ + if (!is_id($this->shadowInactive)){ + $message[]= _("Value specified as 'shadowInactive' is not valid."); + } + if (!$this->use_shadowMax){ + $message[]= _("'shadowInactive' without 'shadowMax' makes no sense."); + } + } + if ($this->use_shadowMin && $this->use_shadowMax){ + if ($this->shadowMin > $this->shadowMax){ + $message[]= _("Value specified as 'shadowMin' should be smaller than 'shadowMax'."); + } + } + + // if(empty($this->gosaDefaultPrinter)){ + // $message[]= _("You need to specify a valid default printer."); + // } + + return ($message); + } + + function addGroup ($groups) + { + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Walk through groups and add the descriptive entry if not exists */ + foreach ($groups as $value){ + if (!array_key_exists($value, $this->groupMembership)){ + $ldap->cat($value, array('cn', 'description', 'dn')); + $attrs= $ldap->fetch(); + error_reporting (0); + if (!isset($attrs['description'][0])){ + $entry= $attrs["cn"][0]; + } else { + $dsc= preg_replace ('/^Group of user/', _("Group of user"), $attrs["description"][0]); + $entry= $attrs["cn"][0]." [$dsc]"; + } + error_reporting (E_ALL | E_STRICT); + + if(obj_is_writable($attrs['dn'],"groups/group","memberUid")){ + $this->groupMembership[$attrs['dn']]= $entry; + } + } + } + + /* Sort groups */ + asort ($this->groupMembership); + reset ($this->groupMembership); + } + + + /* Del posix user from some groups */ + function delGroup ($groups) + { + $dest= array(); + foreach($groups as $dn_to_del){ + if(isset($this->groupMembership[$dn_to_del]) && obj_is_writable($dn_to_del,"groups/group","memberUid")){ + unset($this->groupMembership[$dn_to_del]); + } + } + } + + + /* Adapt from template, using 'dn' */ + function adapt_from_template($dn) + { + /* Include global link_info */ + $ldap= $this->config->get_ldap_link(); + + plugin::adapt_from_template($dn); + $template= $this->attrs['uid'][0]; + + /* Adapt group membership */ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->attrs["uid"][0]."))", array("description", "cn")); + + while ($this->attrs= $ldap->fetch()){ + if (!isset($this->attrs["description"][0])){ + $entry= $this->attrs["cn"][0]; + } else { + $entry= $this->attrs["cn"][0]." [".$this->attrs["description"][0]."]"; + } + $this->groupMembership[$ldap->getDN()]= $entry; + } + + /* Fix primary group settings */ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=posixGroup)(cn=$template)(gidNumber=".$this->gidNumber."))", array("cn")); + if ($ldap->count() != 1){ + $this->primaryGroup= $this->gidNumber; + } + + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaUserTemplate)(uid=".$template.")(accessTo=*))", array("cn","accessTo")); + while($attr = $ldap->fetch()){ + $tmp = $attr['accessTo']; + unset ($tmp['count']); + $this->accessTo = $tmp; + } + + /* Adjust shadow checkboxes */ + foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive") as $val){ + if ($this->$val != 0){ + $oval= "use_".$val; + $this->$oval= "1"; + } + } + + /* FIXME: NEED review of this section */ + /* Need to check shadowExpire separately */ + + /* + * If shadowExpire is not enabled in the template, it's a UNIX timestamp - so don't convert it to seconds. + * The check is a hack - if difference between timestamp generated above and here is max 1 day. + */ + if(abs($this->shadowExpire - time())>86400) { + $this->shadowExpire= $this->convertToSeconds($this->shadowExpire); + } + + /* Only enable checkbox, if shadowExpire is in the future */ + if($this->shadowExpire > time()) { + $this->use_shadowExpire= "1"; + } + } + + function convertToSeconds($val) + { + if ($val != 0){ + $val*= 60 * 60 * 24; + } else { + $date= getdate(); + $val= floor($date[0] / (60*60*24)) * 60 * 60 * 24; + } + return($val); + } + + + function get_next_id($attrib, $dn) + { + $ids= array(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd ($this->config->current['BASE']); + if (preg_match('/gidNumber/i', $attrib)){ + $oc= "posixGroup"; + } else { + $oc= "posixAccount"; + } + $ldap->search ("(&(objectClass=$oc)($attrib=*))", array("$attrib")); + + /* Get list of ids */ + while ($attrs= $ldap->fetch()){ + $ids[]= (int)$attrs["$attrib"][0]; + } + + /* Add the nobody id */ + $ids[]= 65534; + + /* get the ranges */ + $tmp = array('0'=> 1000); + if (preg_match('/posixAccount/', $oc) && isset($this->config->current['UIDBASE'])) { + $tmp= split('-',$this->config->current['UIDBASE']); + } elseif(isset($this->config->current['GIDBASE'])){ + $tmp= split('-',$this->config->current['GIDBASE']); + } + + /* Set hwm to max if not set - for backward compatibility */ + $lwm= $tmp[0]; + if (isset($tmp[1])){ + $hwm= $tmp[1]; + } else { + $hwm= pow(2,32); + } + + /* Find out next free id near to UID_BASE */ + if (!isset($this->config->current['BASE_HOOK'])){ + $base= $lwm; + } else { + /* Call base hook */ + $base= get_base_from_hook($dn, $attrib); + } + for ($id= $base; $id++; $id < pow(2,32)){ + if (!in_array($id, $ids)){ + return ($id); + } + } + + /* Should not happen */ + if ($id == $hwm){ + print_red(_("Too many users, can't allocate a free ID!")); + exit; + } + + } + + function reload() + { + /* Set base for all searches */ + $base = $_SESSION['CurrentMainBase']; + $base = $base; + $ldap = $this->config->get_ldap_link(); + $attrs = array("cn", "description", "gidNumber"); + $Flags = GL_SIZELIMIT; + + /* Get groups */ + if ($this->GroupUserRegex == '*'){ + $filter = "(&(objectClass=posixGroup)(cn=".$this->GroupRegex."))"; + } else { + $filter= "(&(objectClass=posixGroup)(cn=".$this->GroupRegex.")(memberUid=".$this->GroupUserRegex."))"; + } + if($this->SubSearch){ + $Flags |= GL_SUBSEARCH; + }else{ + $base = get_groups_ou().$base; + } + + $res= get_list($filter, "groups", $base,$attrs, $Flags); + + /* check sizelimit */ + if (preg_match("/size limit/i", $ldap->error)){ + $_SESSION['limit_exceeded']= TRUE; + } + + /* Create a list of users */ + $this->grouplist = array(); + foreach ($res as $value){ + $this->grouplist[$value['gidNumber'][0]]= $value; + } + + $tmp=array(); + foreach($this->grouplist as $tkey => $val ){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + + /* Sort index */ + ksort($tmp); + + /* Recreate index array[dn]=cn[description]*/ + $this->grouplist=array(); + foreach($tmp as $val){ + if(isset($val['description'])){ + $this->grouplist[$val['dn']]=$val['cn'][0]." [".$val['description'][0]."]"; + }else{ + $this->grouplist[$val['dn']]=$val['cn'][0]; + } + } + + reset ($this->grouplist); + } + + + /* Get posts from copy & paste dialog */ + function saveCopyDialog() + { + if(isset($_POST['homeDirectory'])){ + $this->homeDirectory = $_POST['homeDirectory']; + if (isset ($_POST['force_ids'])){ + $data= 1; + $this->gidNumber = $_POST['gidNumber']; + $this->uidNumber = $_POST['uidNumber']; + } else { + $data= 0; + } + if ($this->force_ids != $data){ + $this->is_modified= TRUE; + } + $this->force_ids= $data; + } + } + + + /* Create the posix dialog part for copy & paste */ + function getCopyDialog() + { + /* Skip dialog creation if this is not a valid account*/ + if(!$this->is_account) return(""); + if ($this->force_ids == 1){ + $force_ids = "checked"; + if ($_SESSION['js']){ + $forceMode = ""; + } + } else { + if ($_SESSION['js']){ + if($this->acl != "#none#") + $forceMode ="disabled"; + } + $force_ids = ""; + } + + $sta = ""; + + /* Open group add dialog */ + if(isset($_POST['edit_groupmembership'])){ + $this->group_dialog = TRUE; + $sta = "SubDialog"; + } + + /* If the group-add dialog is closed, call execute + to ensure that the membership is updatd */ + if(isset($_POST['add_groups_finish']) || isset($_POST['add_groups_cancel'])){ + $this->execute(); + $this->group_dialog =FALSE; + } + + if($this->group_dialog){ + $str = $this->execute(true); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = $sta; + return($ret); + } + + /* If a group member should be deleted, simply call execute */ + if(isset($_POST['delete_groupmembership'])){ + $this->execute(); + } + + /* Assigned informations to smarty */ + $smarty = get_smarty(); + $smarty->assign("homeDirectory",$this->homeDirectory); + $smarty->assign("uidNumber",$this->uidNumber); + $smarty->assign("gidNumber",$this->gidNumber); + $smarty->assign("forceMode",$forceMode); + $smarty->assign("force_ids",$force_ids); + if (!count($this->groupMembership)){ + $smarty->assign("groupMembership", array(" ")); + } else { + $smarty->assign("groupMembership", $this->groupMembership); + } + + /* Display wars message if there are more than 16 group members */ + if (count($this->groupMembership) > 16){ + $smarty->assign("groups", "too_many_for_nfs"); + } else { + $smarty->assign("groups", ""); + } + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + + $ret = array(); + $ret['string'] = $str; + $ret['status'] = $sta; + return($ret); + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + /* Avoid using the same gid/uid number as source user */ + $this->savedUidNumber = $this->get_next_id("gidNumber", $this->dn); + $this->savedGidNumber = $this->get_next_id("uidNumber", $this->dn); + } + + + function multiple_execute() + { + return($this->execute()); + } + + + static function plInfo() + { + return (array( + "plDescription" => _("POSIX account"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 2, + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + + "homeDirectory" => _("Home directory"), + "loginShell" => _("Shell"), + "uidNumber" => _("User ID"), + "gidNumber" => _("Group ID"), + + "mustchangepassword"=> _("Force password change on login"), + "shadowMin" => _("Shadow min"), + "shadowMax" => _("Shadow max"), + "shadowWarning" => _("Shadow warning"), + "shadowInactive" => _("Shadow inactive"), + "shadowExpire" => _("Shadow expire"), + "trustModel" => _("System trust model"))) + ); + } + + function get_multi_edit_values() + { + $ret = plugin::get_multi_edit_values(); + return($ret); + } + + + function multiple_save_object() + { + if(isset($_POST['posix_mulitple_edit'])){ + plugin::multiple_save_object(); + foreach(array("primaryGroup") as $val){ + if(isset($_POST["use_".$val])){ + $this->multi_boxes[] = $val; + } + } + + /* Save primary group settings */ + if($this->acl_is_writeable("primaryGroup") && isset($_POST['primaryGroup'])){ + $data= $_POST['primaryGroup']; + if ($this->primaryGroup != $data){ + $this->is_modified= TRUE; + } + $this->primaryGroup= $_POST['primaryGroup']; + } + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/posix/generic.tpl b/gosa-core/plugins/personal/posix/generic.tpl new file mode 100644 index 000000000..c9dc98d47 --- /dev/null +++ b/gosa-core/plugins/personal/posix/generic.tpl @@ -0,0 +1,156 @@ + + + + + + +
+

{t}Generic{/t}

+ + + + + + + + + + + + + +{if !$multiple_support} + + + + +{/if} +
{$must} +{render acl=$homeDirectoryACL checkbox=$multiple_support checked=$use_homeDirectory} + +{/render} +
+{render acl=$loginShellACL checkbox=$multiple_support checked=$use_loginShell} + +{/render} +
+{render acl=$gidNumberACL checkbox=$multiple_support checked=$use_primaryGroup} + +{/render} +
{t}Status{/t}{$status}
+ +{if !$multiple_support} + + + + + + + + + + + + + + +
+{render acl=$force_idsACL} + +{/render} + + + + + +{render acl=$uidNumberACL} + +{/render} +
+ + +{render acl=$gidNumberACL} + +{/render} +
+{/if} +
+   + +

{t}Group membership{/t}

+ {if $groups eq "too_many_for_nfs"} + {t}(Warning: more than 16 groups are not supported by NFS!){/t} +
+ {/if} +{render acl=$groupMembershipACL} + +{/render} +
+{render acl=$groupMembershipACL} +   +{/render} +{render acl=$groupMembershipACL} + +{/render} +
+ +

 

+ + + + + + + +
+

{t}Account{/t}

+ {include file="$pwmode.tpl"} +
+   + +

{t}System trust{/t}

+ {t}Trust mode{/t}  +{render acl=$trustmodeACL} + +{/render} +{render acl=$trustmodeACL} + +{/render} +
+{render acl=$trustmodeACL} +   +{/render} +{render acl=$trustmodeACL} + +{/render} +
+{if $multiple_support} + +{/if} + + + + + diff --git a/gosa-core/plugins/personal/posix/main.inc b/gosa-core/plugins/personal/posix/main.inc new file mode 100644 index 000000000..31994ef3f --- /dev/null +++ b/gosa-core/plugins/personal/posix/main.inc @@ -0,0 +1,133 @@ +dn); + sess_del ('edit'); + sess_del ('posixAccount'); + } + + /* Create posixAccount object on demand */ + if (!isset($_SESSION['posixAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['posixAccount']= new posixAccount ($config, $ui->dn); + $_SESSION['posixAccount']->enable_CSN_check(); + $_SESSION['posixAccount']->set_acl_base($ui->dn); + $_SESSION['posixAccount']->set_acl_category("users"); + } + $posixAccount= $_SESSION['posixAccount']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $posixAccount->save_object (); + } + + /* Enter edit mode? */ + if ((isset($_POST['edit'])) && (!isset($_SESSION['edit']))){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + } + + /* save changes to LDAP and disable edit mode */ + $info= ""; + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $posixAccount->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $posixAccount->save (); + del_lock ($ui->dn); + sess_del ('edit'); + + /* Remove from session */ + sess_del ('posixAccount'); + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display = $lock_msg; + }else{ + $display.= $posixAccount->execute (); + } + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['posixAccount']= $posixAccount; + } + + /* Show page footer depending on the mode */ + if (!$posixAccount->group_dialog && !$posixAccount->show_ws_dialog && $posixAccount->is_account && empty($lock_msg)){ + + $display.= "

"; + + /* Are we in edit mode? */ + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + /* Only display edit button if there is at least one attribute editable */ + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/posixAccount"))){ + $info.= "\"\" ". + _("Click the 'Edit' button below to change informations in this dialog"); + + $display.= "\n"; + } + $display.= "\n"; + } + $display.= "

\n"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/posix.png'), + _("Unix settings"), $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/posix/paste_generic.tpl b/gosa-core/plugins/personal/posix/paste_generic.tpl new file mode 100644 index 000000000..b08feb59c --- /dev/null +++ b/gosa-core/plugins/personal/posix/paste_generic.tpl @@ -0,0 +1,70 @@ + + + + +
+

{t}Posix settings{/t}

+ + + + + +
+ + + +
+ + + + + + + + + + + + + +
+ + + +   + + + +
  + + + +
+ + + + + + + +
+

{t}Group membership{/t}

+
+ + {if $groups eq "too_many_for_nfs"} + {t}(Warning: more than 16 groups are not supported by NFS!){/t} +
+ {/if} + +
+   + +
+
+
+
diff --git a/gosa-core/plugins/personal/posix/posix_groups.tpl b/gosa-core/plugins/personal/posix/posix_groups.tpl new file mode 100644 index 000000000..841d8a87a --- /dev/null +++ b/gosa-core/plugins/personal/posix/posix_groups.tpl @@ -0,0 +1,83 @@ + + + + + +
+
+

+ {t}Select groups to add{/t} {$hint} +

+
+
+

+ + +

+
+
+
+

+ [F]{t}Filters{/t} +

+
+
+ + {$alphabet} +
+ + + + + + +
+  {t}Display groups of department{/t} + + +
+ + + + + +
+  {t}Display groups matching{/t} + + +
+ + + + + +
+  {t}Display groups of user{/t} + + +
+ + + + +
+ + {t}Search in subtrees{/t} +
+ {$apply} +
+
+ +

+ +   + +

+ diff --git a/gosa-core/plugins/personal/posix/posix_shadow.tpl b/gosa-core/plugins/personal/posix/posix_shadow.tpl new file mode 100644 index 000000000..bd7862c6d --- /dev/null +++ b/gosa-core/plugins/personal/posix/posix_shadow.tpl @@ -0,0 +1,79 @@ + + + + +
+ + +{render acl=$mustchangepasswordACL} + +{/render} + {t}User must change password on first login{/t} +
+ + +{render acl=$shadowMinACL} + +{/render} +{render acl=$shadowMinACL} + {$shadowmins} +{/render} +
+ + +{render acl=$shadowMaxACL} + +{/render} +{render acl=$shadowMaxACL} + {$shadowmaxs} +{/render} +
+ + +{render acl=$shadowExpireACL} + +{/render} + {t}Password expires on{/t} +{render acl=$shadowExpireACL} + +{/render} +{render acl=$shadowExpireACL} + +{/render} +{render acl=$shadowExpireACL} + + +{/render} +
+ + +{render acl=$shadowInactiveACL} + +{/render} +{render acl=$shadowInactiveACL} + {$shadowinactives} +{/render} +
+ + +{render acl=$shadowWarningACL} + +{/render} +{render acl=$shadowWarningACL} + {$shadowwarnings} +{/render} +
+ + + diff --git a/gosa-core/plugins/personal/posix/trust_machines.tpl b/gosa-core/plugins/personal/posix/trust_machines.tpl new file mode 100644 index 000000000..3550fcf29 --- /dev/null +++ b/gosa-core/plugins/personal/posix/trust_machines.tpl @@ -0,0 +1,42 @@ + + + + + +
+
+

+ {t}Select systems to add{/t} {$hint}
+

+
+
+

+ +

+
+
+
+

[F]{ +t}Filters{/t}

+
+
+ + {$alphabet} +
+ +
 {t}Display systems of department{/t}
+ +
 {t}Display systems matching{/t}
+ {$apply} +
+
+ +

+ +   + +

diff --git a/gosa-core/plugins/personal/samba/class_sambaAccount.inc b/gosa-core/plugins/personal/samba/class_sambaAccount.inc new file mode 100644 index 000000000..bd71c8f7a --- /dev/null +++ b/gosa-core/plugins/personal/samba/class_sambaAccount.inc @@ -0,0 +1,1142 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* Switch for Samba version */ + var $samba3= FALSE; + var $uidNumber= 65535; + var $gidNumber= 65535; + + /* Samba 2 attributes */ + var $pwdLastSet= "0"; + var $logonTime= "0"; + var $logoffTime= "2147483647"; + var $kickoffTime= "2147483647"; + var $pwdCanChange= "0"; + var $pwdMustChange= "0"; + var $password_expires= 0; + var $acctFlags= "[UX ]"; + var $smbHome= ""; + var $homeDrive= ""; + var $scriptPath= ""; + var $profilePath= ""; + var $rid= ""; + var $primaryGroupID= ""; + + /* Samba 3 attributes */ + var $SID= ""; + var $ridBase= 0; + var $sambaSID= ""; + var $sambaPwdLastSet= "0"; + var $sambaLogonTime= "0"; + var $sambaLogoffTime= "2147483647"; + var $sambaKickoffTime= "2147483647"; + var $sambaPwdCanChange= ""; + var $sambaPwdMustChange= "0"; + var $sambaAcctFlags= "[UX ]"; + var $sambaHomePath= ""; + var $sambaHomeDrive= ""; + var $sambaLogonScript= ""; + var $sambaProfilePath= ""; + var $sambaPrimaryGroupSID= ""; + var $sambaDomainName= ""; + var $sambaUserWorkstations= ""; + var $sambaBadPasswordCount= ""; + var $sambaBadPasswordTime= ""; + var $sambaPasswordHistory= ""; + var $sambaLogonHours= ""; + var $orig_sambaDomainName= ""; + var $sambaMungedDial= ""; + var $mungedObject; + + /* Helper */ + var $show_ws_dialog= FALSE; + var $logon_time_set= 0; + var $logoff_time_set= 0; + var $kickoff_time_set= 0; + + /* attribute list for save action */ + var $ctxattributes= array(); + var $attributes= array(); + var $objectclasses= array(); + + var $uid= ""; + var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName"); + + function sambaAccount (&$config, $dn= NULL) + { + /* Load attributes depending on the samba version */ + $this->samba3= ($config->current['SAMBAVERSION'] == 3); + + if ($this->samba3){ + $this->attributes= array ("sambaSID", "sambaPwdLastSet", "sambaLogonTime", + "sambaLogoffTime", "sambaKickoffTime", "sambaPwdCanChange", + "sambaPwdMustChange", "sambaAcctFlags", "uid", "sambaMungedDial", + "sambaHomePath", "sambaHomeDrive", "sambaLogonScript", + "sambaProfilePath", "sambaPrimaryGroupSID", "sambaDomainName", + "sambaUserWorkstations", "sambaPasswordHistory", + "sambaLogonHours", "sambaBadPasswordTime", + "sambaBadPasswordCount"); + $this->objectclasses= array ("sambaSamAccount"); + $this->mungedObject= new sambaMungedDial; + $this->ctxattributes= $this->mungedObject->ctxattributes; + } else { + $this->attributes= array ("pwdLastSet", "logonTime", "logoffTime", "kickoffTime", + "pwdCanChange", "pwdMustChange", "acctFlags", "profilePath", "uid", + "smbHome", "homeDrive", "scriptPath", "rid", "primaryGroupID"); + $this->objectclasses= array ("sambaAccount"); + } + + plugin::plugin ($config, $dn); + + /* Setting uid to default */ + if(isset($this->attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + /* Get samba Domain in case of samba 3 */ + if ($this->samba3 && $this->sambaSID != ""){ + $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID); + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase","sambaDomainName")); + if ($ldap->count() != 0){ + $attrs= $ldap->fetch(); + $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0]; + if ($this->sambaDomainName == ""){ + $this->sambaDomainName= $attrs['sambaDomainName'][0]; + } + } else { + if ($this->sambaDomainName == ""){ + $this->sambaDomainName= "DEFAULT"; + } + $this->ridBase= $this->config->current['RIDBASE']; + $this->SID= $this->config->current['SID']; + } + + /* Save in order to compare later on */ + $this->orig_sambaDomainName= $this->sambaDomainName; + } + + /* Fill mungedDial field */ + if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){ + $this->mungedObject->load($this->sambaMungedDial); + } + + /* Password expiery */ + if(isset($this->attrs['sambaPwdMustChange']) && + $this->attrs['sambaPwdMustChange'][0] != 0){ + $this->password_expires= 1; + } + + if(isset($this->attrs['sambaLogonTime']) && ! ( + $this->attrs['sambaLogonTime'][0] == 0 || + $this->attrs['sambaLogonTime'][0] == 2147483647 + )){ + $this->logon_time_set= 1; + } + if(isset($this->attrs['sambaLogoffTime']) && ! ( + $this->attrs['sambaLogoffTime'][0] == 0 || + $this->attrs['sambaLogoffTime'][0] == 2147483647 + )){ + $this->logoff_time_set= 1; + } + + /* Account expiery */ + if(isset($this->attrs['sambaKickoffTime']) && ! ( + $this->attrs['sambaKickoffTime'][0] == 0 || + $this->attrs['sambaKickoffTime'][0] == 2147483647 + )){ + $this->kickoff_time_set= 1; + } + + /* Get global filter config */ + if (!is_global("sambafilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $sambafilter= array( "depselect" => $base, "regex" => "*"); + register_global("sambafilter", $sambafilter); + } + + /* Save initial account state */ + $this->initially_was_account= $this->is_account; + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\"src=\"images/stop.png\" ". + _("This account has no samba extensions.").""; + $display.= back_to_main(); + return ($display); + } + + /* Show tab dialog headers */ + $display= ""; + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove samba account"), + _("This account has samba features enabled. You can disable them by clicking below.")); + } else { + $obj= $this->parent->by_object['posixAccount']; + + /* Samba3 dependency on posix accounts are enabled + in the moment, because I need to rely on unique + uidNumbers. There'll be a better solution later + on. */ + if ($obj->is_account){ + + $display= $this->show_enable_header(_("Create samba account"), + _("This account has samba features disabled. You can enable them by clicking below.")); + } else { + $display= $this->show_enable_header(_("Create samba account"), + _("This account has samba features disabled. Posix features are needed for samba accounts, enable them first."), TRUE); + } + return ($display); + } + } + + $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + + /* Open Samaba Logong hours dialog */ + if(isset($_POST['SetSambaLogonHours']) && $this->samba3 && $this->acl_is_writeable("sambaLogonHours")){ + $this->dialog = new sambaLogonHours($this->config,$this->dn,$this->sambaLogonHours); + } + + /* Cancel dialog */ + if(isset($_POST['cancel_logonHours'])){ + $this->dialog = FALSE; + } + + /* Save selected logon hours */ + if(isset($_POST['save_logonHours'])){ + $this->dialog->save_object(); + if($this->acl_is_writeable("sambaLogonHours")){ + $this->sambaLogonHours = $this->dialog->save(); + } + $this->dialog = FALSE; + } + + /* Display dialog */ + if((isset($this->dialog)) && (is_object($this->dialog))){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + + /* Prepare templating */ + $smarty= get_smarty(); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $var => $rest){ + $smarty->assign($var."ACL",$this->getacl($var,$SkipWrite)); + } + + if ($this->sambaPwdMustChange=="0"){ + $date= getdate(); + } else { + $date= getdate($this->sambaPwdMustChange); + } + + if ($this->sambaLogonTime=="2147483647" || $this->sambaLogonTime=="0"){ + $sambaLogonTime_date= getdate(); + } else { + $sambaLogonTime_date= getdate($this->sambaLogonTime); + } + + if ($this->sambaLogoffTime=="2147483647" || $this->sambaLogoffTime=="0"){ + $sambaLogoffTime_date= getdate(); + } else { + $sambaLogoffTime_date= getdate($this->sambaLogoffTime); + } + + if ($this->sambaKickoffTime=="2147483647" || $this->sambaKickoffTime=="0"){ + $sambaKickoffTime_date= getdate(); + } else { + $sambaKickoffTime_date= getdate($this->sambaKickoffTime); + } + + /* Remove user workstations? */ + if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){ + + if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){ + + $tmp= $this->sambaUserWorkstations; + foreach($_POST['workstation_list'] as $name){ + $tmp= preg_replace("/$name/", '', $tmp); + $this->is_modified= TRUE; + } + $tmp= preg_replace('/,+/', ',', $tmp); + $this->sambaUserWorkstations= trim($tmp, ','); + } + } + + /* Add user workstation? */ + if (isset($_POST["add_ws"])){ + if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){ + $this->show_ws_dialog= TRUE; + $this->dialog= TRUE; + } + } + + /* Add user workstation finished? */ + if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){ + $this->show_ws_dialog= FALSE; + $this->dialog= FALSE; + } + + /* Add user workstation? */ + if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){ + $tmp= $this->sambaUserWorkstations; + foreach($_POST['wslist'] as $ws){ + $tmp.= ",$ws"; + } + $tmp= preg_replace('/,+/', ',', $tmp); + $this->sambaUserWorkstations= trim($tmp, ','); + $this->is_modified= TRUE; + } + + /* Show ws dialog */ + if ($this->show_ws_dialog){ + + /* Save data */ + $sambafilter= get_global("sambafilter"); + foreach( array("depselect", "regex") as $type){ + if (isset($_POST[$type])){ + $sambafilter[$type]= $_POST[$type]; + } + } + if (isset($_GET['search'])){ + $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; + if ($s == "**"){ + $s= "*"; + } + $sambafilter['regex']= $s; + } + register_global("sambafilter", $sambafilter); + + /* Get workstation list */ + $exclude= ""; + foreach(split(',', $this->sambaUserWorkstations) as $ws){ + $exclude.= "(cn=$ws$)"; + } + if ($exclude != ""){ + $exclude= "(!(|$exclude))"; + } + $regex= $sambafilter['regex']; + $filter= "(&(objectClass=sambaSAMAccount)$exclude(uid=*$)(|(uid=$regex)(cn=$regex)))"; + $res= get_list($filter, "winworkstation", $sambafilter['depselect'], array("uid"), GL_SUBSEARCH | GL_SIZELIMIT); + + $wslist= array(); + foreach ($res as $attrs){ + $wslist[]= preg_replace('/\$/', '', $attrs['uid'][0]); + } + asort($wslist); + + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("deplist", $this->config->idepartments); + $smarty->assign("alphabet", generate_alphabet()); + foreach( array("depselect", "regex") as $type){ + $smarty->assign("$type", $sambafilter[$type]); + } + $smarty->assign("hint", print_sizelimit_warning()); + $smarty->assign("wslist", $wslist); + $smarty->assign("apply", apply_filter()); + $display= $smarty->fetch (get_template_path('samba3_workstations.tpl', TRUE, + dirname(__FILE__))); + return ($display); + } + + /* Fill calendar */ + $days= array(); + for($d= 1; $d<32; $d++){ + $days[]= $d; + } + $years= array(); + for($y= $date['year']-4; $y<$date['year']+4; $y++){ + $years[]= $y; + } + $months= array(_("January"), _("February"), _("March"), _("April"), + _("May"), _("June"), _("July"), _("August"), _("September"), + _("October"), _("November"), _("December")); + $smarty->assign("day", $date["mday"]); + $smarty->assign("days", $days); + $smarty->assign("months", $months); + $smarty->assign("month", $date["mon"]-1); + $smarty->assign("years", $years); + $smarty->assign("year", $date["year"]); + + $sambaLogonTime_days= array(); + for($d= 1; $d<32; $d++){ + $sambaLogonTime_days[]= $d; + } + $sambaLogonTime_years= array(); + for($y= $date['year']-4; $y<$date['year']+4; $y++){ + $sambaLogonTime_years[]= $y; + } + $sambaLogonTime_months= array(_("January"), _("February"), _("March"), _("April"), + _("May"), _("June"), _("July"), _("August"), _("September"), + _("October"), _("November"), _("December")); + $smarty->assign("sambaLogonTime_day", $sambaLogonTime_date["mday"]); + $smarty->assign("sambaLogonTime_days", $sambaLogonTime_days); + $smarty->assign("sambaLogonTime_months", $sambaLogonTime_months); + $smarty->assign("sambaLogonTime_month", $sambaLogonTime_date["mon"]-1); + $smarty->assign("sambaLogonTime_years", $sambaLogonTime_years); + $smarty->assign("sambaLogonTime_year", $sambaLogonTime_date["year"]); + + $sambaLogoffTime_days= array(); + for($d= 1; $d<32; $d++){ + $sambaLogoffTime_days[]= $d; + } + $sambaLogoffTime_years= array(); + for($y= $date['year']-4; $y<$date['year']+4; $y++){ + $sambaLogoffTime_years[]= $y; + } + $sambaLogoffTime_months= array(_("January"), _("February"), _("March"), _("April"), + _("May"), _("June"), _("July"), _("August"), _("September"), + _("October"), _("November"), _("December")); + $smarty->assign("sambaLogoffTime_day", $sambaLogoffTime_date["mday"]); + $smarty->assign("sambaLogoffTime_days", $sambaLogoffTime_days); + $smarty->assign("sambaLogoffTime_months", $sambaLogoffTime_months); + $smarty->assign("sambaLogoffTime_month", $sambaLogoffTime_date["mon"]-1); + $smarty->assign("sambaLogoffTime_years", $sambaLogoffTime_years); + $smarty->assign("sambaLogoffTime_year", $sambaLogoffTime_date["year"]); + + $sambaKickoffTime_days= array(); + for($d= 1; $d<32; $d++){ + $sambaKickoffTime_days[]= $d; + } + $sambaKickoffTime_years= array(); + for($y= $date['year']-4; $y<$date['year']+4; $y++){ + $sambaKickoffTime_years[]= $y; + } + $sambaKickoffTime_months= array(_("January"), _("February"), _("March"), _("April"), + _("May"), _("June"), _("July"), _("August"), _("September"), + _("October"), _("November"), _("December")); + //$smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]-1); + $smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]); // hickert + $smarty->assign("sambaKickoffTime_days", $sambaKickoffTime_days); + $smarty->assign("sambaKickoffTime_months", $sambaKickoffTime_months); + $smarty->assign("sambaKickoffTime_month", $sambaKickoffTime_date["mon"]-1); + $smarty->assign("sambaKickoffTime_years", $sambaKickoffTime_years); + $smarty->assign("sambaKickoffTime_year", $sambaKickoffTime_date["year"]); + + /* Fill boxes */ + if ($this->samba3){ + $domains= array(); + foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){ + $domains[]= $name; + } + $smarty->assign("domains", $domains); + } + $letters= array(); + for ($i= 68; $i<91; $i++){ + $letters[]= chr($i).":"; + } + $smarty->assign("drives", $letters); + + /* Fill terminal server settings */ + if ($this->samba3){ + foreach ($this->ctxattributes as $attr){ + /* Fill common attributes */ + if (isset($this->mungedObject->ctx[$attr])){ + $smarty->assign("$attr", $this->mungedObject->ctx[$attr]); + // Set field to blank if value is 0 + if(in_array($attr, array("CtxMaxConnectionTime", "CtxMaxDisconnectionTime", "CtxMaxIdleTime"))) { + if($this->mungedObject->ctx[$attr] == 0) { + $smarty->assign("$attr", ""); + } + } + } else { + $smarty->assign("$attr", ""); + } + } + + /* Assign enum values for preset items */ + $shadowModeVals= array( "0" => _("disabled"), + "1" => _("input on, notify on"), + "2" => _("input on, notify off"), + "3" => _("input off, notify on"), + "4" => _("input off, nofify off")); + + $brokenConnModeVals= array( "0" => _("disconnect"), + "1" => _("reset")); + + $reConnModeVals= array( "0" => _("from any client"), + "1" => _("from previous client only")); + + /* Fill preset items */ + $smarty->assign("shadow", $shadowModeVals); + $smarty->assign("brokenconn", $brokenConnModeVals); + $smarty->assign("reconn", $reConnModeVals); + + /* Fill preset items with values */ + $smarty->assign("shadowmode", $this->mungedObject->getShadow()); + $smarty->assign("brokenconnmode", $this->mungedObject->getBrokenConn()); + $smarty->assign("reconnmode", $this->mungedObject->getReConn()); + + if($_SESSION['js']){ + /* Set form elements to disabled/enable state */ + $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled"); + + $smarty->assign("inheritstate", ""); + if($this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){ + $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":""); + } + + + + }else{ + $smarty->assign("tsloginstate", ""); + $smarty->assign("inheritstate", ""); + } + + /* Set checkboxes to checked or unchecked state */ + $smarty->assign("tslogin", $this->mungedObject->getTsLogin()?"checked":""); + $smarty->assign("inherit", $this->mungedObject->getInheritMode()?"checked":""); + $smarty->assign("connectclientdrives", + $this->mungedObject->getConnectClientDrives()?"checked":""); + $smarty->assign("connectclientprinters", + $this->mungedObject->getConnectClientPrinters()?"checked":""); + $smarty->assign("defaultprinter", + $this->mungedObject->getDefaultPrinter()?"checked":""); + $smarty->assign("CtxMaxConnectionTimeF", + $this->mungedObject->getCtxMaxConnectionTimeF()?"checked":""); + $smarty->assign("CtxMaxDisconnectionTimeF", + $this->mungedObject->getCtxMaxDisconnectionTimeF()?"checked":""); + $smarty->assign("CtxMaxIdleTimeF", + $this->mungedObject->getCtxMaxIdleTimeF()?"checked":""); + + /* Fill sambaUserWorkstations */ + $ws= split(",", $this->sambaUserWorkstations); + sort($ws); + + /* Tidy checks for empty option, and smarty will produce one if array[0]="" */ + if(($ws[0]=="")&&(count($ws)==1)) $ws=array(); + + + $smarty->assign("workstations", $ws); + } + + /* Variables */ + foreach($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + + /* 'sambaAcctFlags' checkboxes */ + /* Check for 'lock-account'-flag: 'D' or 'L' */ + if (is_integer(strpos($this->sambaAcctFlags, "D")) || + is_integer(strpos($this->sambaAcctFlags, "L"))) { + $smarty->assign("flagsD", "checked"); + } else { + $smarty->assign("flagsD", ""); + } + + /* Check for no_password_required flag 'N' */ + if (is_integer(strpos($this->sambaAcctFlags, "N"))) { + $smarty->assign("flagsN", "checked"); + } else { + $smarty->assign("flagsN", ""); + } + + if($this->samba3){ + if ($this->sambaPwdCanChange=="1"){ + $smarty->assign("flagsP", "checked"); + } else { + $smarty->assign("flagsP", ""); + } + }else{ + if ($this->pwdCanChange=="1"){ + $smarty->assign("flagsP", "checked"); + } else { + $smarty->assign("flagsP", ""); + } + } + + if ($this->password_expires=="1"){ + $smarty->assign("flagsC", "checked"); + } else { + $smarty->assign("flagsC", ""); + } + if ($this->logon_time_set=="1"){ + $smarty->assign("flagsT", "checked"); + } else { + $smarty->assign("flagsT", ""); + } + if ($this->logoff_time_set=="1"){ + $smarty->assign("flagsO", "checked"); + } else { + $smarty->assign("flagsO", ""); + } + if ($this->kickoff_time_set=="1"){ + $smarty->assign("flagsK", "checked"); + } else { + $smarty->assign("flagsK", ""); + } + + + /* In case of javascript, disable some fields on demand */ + if ($this->samba3){ + foreach($this->mungedObject->getOnDemandFlags() as $key => $value) { + $smarty->assign("$key", "$value"); + } + } + + /* Show main page */ + if ($this->samba3){ + $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__))); + } else { + $display.= $smarty->fetch (get_template_path('samba2.tpl', TRUE, dirname(__FILE__))); + } + + return ($display); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + plugin::remove_from_parent(); + + /* Keep uid attribute for gosaAccount */ + unset($this->attrs['uid']); + unset($this->attrs['uidNumber']); + unset($this->attrs['gidNumber']); + + /* Remove objectClass for sambaIdmapEntry */ + $tmp= array(); + for ($i= 0; $iattrs["objectClass"]); $i++){ + if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){ + $tmp[]= $this->attrs['objectClass'][$i]; + } + } + $this->attrs['objectClass']= $tmp; + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/samba account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove", array("uid" => $this->uid)); + } + + + /* Check for input problems */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if ($this->samba3){ + + /* Strings */ + foreach (array( "sambaHomePath" => _("Home directory"), + "sambaProfilePath" => _("Profile path")) as $key => $val){ + if (!$this->mungedObject->is_samba_path($this->$key)){ + $message[]= sprintf(_("The value specified as '%s' contains invalid characters!"), $val); + } + } + + /* Numeric values */ + foreach (array( "CtxMaxConnectionTime" => _("Connection"), + "CtxMaxDisconnectionTime" => _("Disconnection"), + "CtxMaxIdleTime" => _("IDLE")) as $key => $val){ + + if (isset($this->mungedObject->ctx[$key]) && !is_id($this->mungedObject->ctx[$key]) && $val != 0){ + $message[]= sprintf(_("The timeout property '%s' is checked and contains invalid or no characters!"), $val); + } + } + + /* Too many workstations? Windows usrmgr only supports eight */ + if (substr_count($this->sambaUserWorkstations, ",") >= 8){ + $message[]= _("The windows user manager only allows eight clients. You've specified more than eight."); + } + } + + return ($message); + } + + + /* Save data to object */ + function save_object() + { + + $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); + + /* We only care if we are on the sambaTab... */ + if (isset($_POST['sambaTab'])){ + plugin::save_object(); + + /* Take care about access options */ + if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){ + if ($this->samba3){ + $attrname= "sambaPwdCanChange"; + } else { + $attrname= "pwdCanChange"; + } + if (isset($_POST["allow_pwchange"]) && $_POST["allow_pwchange"] == 1){ + $tmp= 1; + } else { + $tmp= 0; + } + if ($this->$attrname != $tmp){ + $this->is_modified= TRUE; + } + $this->pwdCanChange= $tmp; + $this->sambaPwdCanChange= $tmp; + } + $tmp= "UX"; + if (isset($_POST["no_password_required"])){ + if ($_POST["no_password_required"] == 1){ + $tmp.= "N"; + } + } + if (isset($_POST["password_expires"])){ + if ($_POST["password_expires"] == 1){ + $this->password_expires= 1; + } + } else { + $this->password_expires= 0; + } + if (isset($_POST["temporary_disable"])){ + if ($_POST["temporary_disable"] == 1){ + if (is_integer(strpos($this->sambaAcctFlags, "L"))) { + $tmp.= "L"; + } else { + $tmp.= "D"; + } + } + } + if (isset($_POST["logon_time_set"])){ + if ($_POST["logon_time_set"] == 1){ + $this->logon_time_set= 1; + } + } else { + $this->logon_time_set= 0; + } + if (isset($_POST["logoff_time_set"])){ + if ($_POST["logoff_time_set"] == 1){ + $this->logoff_time_set= 1; + } + } else { + $this->logoff_time_set= 0; + } + if (isset($_POST["kickoff_time_set"])){ + if ($_POST["kickoff_time_set"] == 1){ + $this->kickoff_time_set= 1; + } + } else { + $this->kickoff_time_set= 0; + } + + $fill= ""; + for ($i= strlen($tmp); $i<12; $i++){ + $fill.= " "; + } + + $tmp= "[$tmp$fill]"; + + /* Only save if acl's are set */ + if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){ + if ($this->samba3){ + $attrname= "sambaAcctFlags"; + } else { + $attrname= "acctFlags"; + } + if ($this->$attrname != $tmp){ + $this->is_modified= TRUE; + } + $this->$attrname= $tmp; + } + + /* Save sambaDomain attribute */ + if ($this->acl_is_writeable("sambaDomainName",$SkipWrite) && $this->samba3 && isset ($_POST['sambaDomainName'],$SkipWrite)){ + $this->sambaDomainName= validate($_POST['sambaDomainName']); + } + + /* Save CTX values */ + if ($this->samba3){ + + /* Save obvious values */ + foreach($this->ctxattributes as $val){ + if (isset($_POST[$val]) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){ + if (get_magic_quotes_gpc()) { + $this->mungedObject->ctx[$val]= stripcslashes(validate($_POST[$val])); + } else { + $this->mungedObject->ctx[$val]= validate($_POST[$val]); + } + } + } + + /* Save checkbox states. */ + $this->mungedObject->setTsLogin(!isset($_POST['tslogin']) + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + // Need to do some index checking to avoid messages like "index ... not found" + if(isset($_POST['brokenconn'])) { + $this->mungedObject->setBrokenConn($_POST['brokenconn'] == '1' + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + } + if(isset($_POST['reconn'])) { + $this->mungedObject->setReConn($_POST['reconn'] == '1' + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + } + $this->mungedObject->setInheritMode(isset($_POST['inherit']) + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + $this->mungedObject->setCtxMaxConnectionTimeF(!isset($_POST['CtxMaxConnectionTimeF']) + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + $this->mungedObject->setCtxMaxDisconnectionTimeF( + !isset($_POST['CtxMaxDisconnectionTimeF']) + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + $this->mungedObject->setCtxMaxIdleTimeF(!isset($_POST['CtxMaxIdleTimeF']) + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + $this->mungedObject->setConnectClientDrives(isset($_POST['connectclientdrives']) + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + $this->mungedObject->setConnectClientPrinters(isset($_POST['connectclientprinters']) + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + $this->mungedObject->setDefaultPrinter(isset($_POST['defaultprinter']) + && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); + + /* Save combo boxes. Takes two values */ + if(isset($_POST['reconn'])) { + $this->mungedObject->setShadow(isset($_POST['shadow']) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite),$_POST['shadow']); + } + + /* Check for changes */ + if ($this->sambaMungedDial != $this->mungedObject->getMunged()){ + $this->is_modified= TRUE; + } + } + } + } + + + /* Save to LDAP */ + function save() + { + /* Load uid and gid of this 'dn' */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn, array('uidNumber', 'gidNumber')); + $tmp= $ldap->fetch(); + $this->uidNumber= $tmp['uidNumber'][0]; + $this->gidNumber= $tmp['gidNumber'][0]; + + plugin::save(); + + /* Remove objectClass for sambaIdmapEntry */ + $tmp= array(); + for ($i= 0; $iattrs["objectClass"]); $i++){ + if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){ + $tmp[]= $this->attrs['objectClass'][$i]; + } + } + $this->attrs['objectClass']= $tmp; + + /* Generate rid / primaryGroupId */ + if ($this->samba3){ + if (!isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){ + print_red (_("Warning: This account has an undefined samba SID assigned. The problem can not be fixed by GOsa!")); + } else { + $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID']; + $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE']; + } + + /* Need to generate a new uniqe uid/gid combination? */ + if ($this->sambaSID == "" || $this->orig_sambaDomainName != $this->sambaDomainName){ + $uidNumber= $this->uidNumber; + while(TRUE){ + $sid= $this->SID."-".($uidNumber*2 + $this->ridBase); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(sambaSID=$sid)", array("sambaSID")); + if ($ldap->count() == 0){ + break; + } + $uidNumber++; + } + $this->attrs['sambaSID']= $sid; + + /* Check for users primary group */ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn")); + if ($ldap->count() != 1){ + print_red(_("Warning: Can't identify users primary group - no conversion to a samba group possible!")); + } else { + $attrs= $ldap->fetch(); + $g= new group($this->config, $ldap->getDN()); + if ($g->sambaSID == ""){ + $g->sambaDomainName= $this->sambaDomainName; + $g->smbgroup= TRUE; + $g->save (); + } + $this->attrs['sambaPrimaryGroupSID']= $g->sambaSID; + } + } + + if ($this->sambaHomeDrive == ""){ + $this->attrs["sambaHomeDrive"]= array(); + } + + /* Generate munged dial value */ + $this->attrs["sambaMungedDial"]= $this->mungedObject->getMunged(); + + /* User wants me to fake the idMappings? This is useful for + making winbind resolve the user names in a reasonable amount + of time in combination with larger databases. */ + if (isset($this->config->current['SAMBAIDMAPPING']) && + preg_match('/true/i', $this->config->current['SAMBAIDMAPPING'])){ + $this->attrs['objectClass'][]= "sambaIdmapEntry"; + } + + + /* Password expiery */ + if ($this->password_expires == "1"){ + $this->attrs['sambaPwdMustChange']= $this->sambaPwdMustChange; + } else { + $this->attrs['sambaPwdMustChange']= array(); + } + /* Make sure not to save zero in sambaPwdLastset */ + if ($this->sambaPwdLastSet != "0"){ + $this->attrs['sambaPwdLastSet']= $this->sambaPwdLastSet; + } else { + $this->attrs['sambaPwdLastSet']= array(); + } + /* Account expiery */ + if ($this->logon_time_set == "1"){ + $this->attrs['sambaLogonTime']= $this->sambaLogonTime; + } else { + $this->attrs['sambaLogonTime']= array(); + } + if ($this->logoff_time_set == "1"){ + $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime; + } else { + $this->attrs['sambaLogoffTime']= array(); + } + if ($this->kickoff_time_set == "1"){ + # Add one day in unixtime format to be compatible with usrmgr + //$this->attrs['sambaKickoffTime']= $this->sambaKickoffTime + 86400; + $this->attrs['sambaKickoffTime']= $this->sambaKickoffTime; //hickert + } else { + $this->attrs['sambaKickoffTime']= array(); + } + } else { + /* Not samba3 */ + $this->attrs['rid']= $this->uidNumber*2 + 1000; + $this->attrs['primaryGroupID']= $this->gidNumber*2 +1001; + + if ($this->homeDrive == ""){ + $this->attrs["homeDrive"]= array(); + } + + /* Password expiery */ + if ($this->password_expires == "1"){ + $this->attrs['pwdMustChange']= $this->pwdMustChange; + } else { + $this->attrs['pwdMustChange']= 2147483647; + } + /* Make sure not to save zero in pwdLastset */ + if ($this->pwdLastSet != "0"){ + $this->attrs['pwdLastSet']= $this->pwdLastSet; + } else { + $this->attrs['pwdLastSet']= array(); + } + /* Account expiery */ + if ($this->logon_time_set == "1"){ + $this->attrs['logonTime']= $this->logonTime; + } else { + $this->attrs['logonTime']= array(); + } + if ($this->logoff_time_set == "1"){ + $this->attrs['logoffTime']= $this->logoffTime; + } else { + $this->attrs['logoffTime']= array(); + } + if ($this->kickoff_time_set == "1"){ + # Add one day in unixtime format to be compatible with usrmgr + $this->attrs['kickoffTime']= $this->kickoffTime + 86400; + } else { + $this->attrs['kickoffTime']= array(); + } + } + + /* Write back to ldap */ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + 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()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/samba account with dn '%s' failed."),$this->dn)); + + /* 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", array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add", array("uid" => $this->uid)); + } + } + + + /* Force password set, if this account doesn't have any samba passwords */ + function password_change_needed() + { + if(!$this->initially_was_account && $this->is_account){ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn,array("sambaLMPassword","sambaNTPassword")); + $attrs = $ldap->fetch(); + if(!isset($attrs['sambaLMPassword']) || !isset($attrs['sambaNTPassword'])){ + return(TRUE); + } + } + return(FALSE); + } + + + function adapt_from_template($dn) + { + plugin::adapt_from_template($dn); + $this->sambaSID= ""; + $this->sambaPrimaryGroupSID= ""; + + /* Fill mungedDial field */ + if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){ + $this->mungedObject->load($this->sambaMungedDial); + } + + /* Password expiery */ + if(isset($this->attrs['sambaPwdMustChange']) && + $this->attrs['sambaPwdMustChange'][0] != 0){ + $this->password_expires= 1; + } + + if(isset($this->attrs['sambaLogonTime']) && ! ( + $this->attrs['sambaLogonTime'][0] == 0 || + $this->attrs['sambaLogonTime'][0] == 2147483647 + )){ + $this->logon_time_set= 1; + } + if(isset($this->attrs['sambaLogoffTime']) && ! ( + $this->attrs['sambaLogoffTime'][0] == 0 || + $this->attrs['sambaLogoffTime'][0] == 2147483647 + )){ + $this->logoff_time_set= 1; + } + + /* Account expiery */ + if(isset($this->attrs['sambaKickoffTime']) && ! ( + $this->attrs['sambaKickoffTime'][0] == 0 || + $this->attrs['sambaKickoffTime'][0] == 2147483647 + )){ + $this->kickoff_time_set= 1; + } + + /* Get global filter config */ + if (!is_global("sambafilter")){ + $ui= get_userinfo(); + $base= get_base_from_people($ui->dn); + $sambafilter= array( "depselect" => $base, "regex" => "*"); + register_global("sambafilter", $sambafilter); + } + } + + + static function plInfo() + { + return (array( + "plShortName" => _("Samba"), + "plDescription" => _("Samba settings"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 5, + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "AllowLoginOnTerminalServer" => _("Allow login on terminal server"), + "InheritClientConfig" => _("Inherit client config"), + + "sambaPwdCanChange" => _("Allow user to change password") , + "sambaAcctFlagsN" => _("Login from windows client requires no password"), + "sambaAcctFlagsL" => _("Lock samba account"), + + + "sambaKickoffTime" => _("Account expires") , + "sambaPwdMustChange" => _("Password expires") , + + "sambaLogonTime" => _("Limit Logon Time") , + "sambaLogoffTime" => _("Limit Logoff Time") , + "sambaLogonHours" => _("Logon hours") , + + "sambaHomePath" => _("Generic home directory") , + "sambaHomeDrive" => _("Generic samba home drive") , + "sambaLogonScript" => _("Generic script path") , + "sambaProfilePath" => _("Generic profile path") , + "sambaDomainName" => _("Domain") , + "sambaUserWorkstations" => _("Allow connection from"))) + ); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/samba/class_sambaLogonHours.inc b/gosa-core/plugins/personal/samba/class_sambaLogonHours.inc new file mode 100644 index 000000000..95de60d0a --- /dev/null +++ b/gosa-core/plugins/personal/samba/class_sambaLogonHours.inc @@ -0,0 +1,148 @@ +sambaLogonHours = $slh; + + /* Get default timezone */ + $zone = get_default_timezone(); + $this->timezone = $zone['value']; + + /* Convert to bin */ + $tmp = ''; + for($i = 0 ; $i < strlen($slh) ; $i ++){ + $tmp .= str_pad(base_convert($slh[$i],16,2),4,'0',STR_PAD_LEFT); + } + $slh = $tmp; + + /* Set to default if value is empty or seams to be broken */ + if(strlen($slh) != 168){ + $slh = str_pad('',168 , "1"); + } + + /* Rework string, because it was stored in little endian */ + $new = ''; + for($i = 0 ; $i < 21 ; $i ++ ){ + $part = strrev(substr($slh, $i * 8, 8)); + $byte['hi'] = substr($part,0,4); + $byte['low'] = substr($part,4,4); + $new .= $byte['hi'].$byte['low']; + } + + /* Shift string to match given timezone settings */ + $shift_by = (168 + $this->timezone) % 168; + for($i = 0 ; $i < $shift_by; $i ++){ + $new = $new[167].$new; + $new = substr($new,0,168); + } + + /* Create matrix */ + $this->Matrix = array(); + for($day = 0 ; $day < 7 ; $day ++ ){ + for($hour = 0 ; $hour < 24 ; $hour ++){ + $bitpos = ($day * 24 + $hour) % 168; + $this->Matrix[$day][$hour] = $new[$bitpos]; + } + } + } + + function execute() + { + + $week_days = array(); + $week_days[0]= _("Sunday"); + $week_days[1]= _("Monday"); + $week_days[2]= _("Tuesday"); + $week_days[3]= _("Wednesday"); + $week_days[4]= _("Thursday"); + $week_days[5]= _("Friday"); + $week_days[6]= _("Saturday"); + + $hours = array(); + for($i = 0 ; $i <24 ; $i++ ){ + $hours[$i] = $i ; + } + $ui =get_userinfo(); + + $smarty = get_smarty(); + $smarty->assign("sambaLogonHoursACL",$ui->get_permissions($this->acl_base,"user/generic","sambaLogonHours")); + $smarty->assign("Matrix",$this->Matrix); + $smarty->assign("Days" ,$week_days); + $smarty->assign("Hours" ,$hours); + return($smarty->fetch(get_template_path("sambaLogonHours.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + /* Get userinfo */ + $ui = get_userinfo(); + + /* Check if dialog was opened and if there were any changes */ + if(isset($_POST['sambaLogonHoursPosted']) && preg_match("/w/i",$ui->get_permissions($this->acl_base,"user/generic","sambaLogonHours"))){ + foreach($this->Matrix as $day_key => $days){ + foreach($days as $hour_key => $hour){ + if(isset($_POST['day_'.$day_key.'_'.$hour_key])){ + $this->Matrix[$day_key][$hour_key] = 1; + }else{ + $this->Matrix[$day_key][$hour_key] = 0; + } + } + } + } + } + + function save() + { + + /* Convert Matrix to Hex */ + $slh = ""; + foreach($this->Matrix as $day_key => $days){ + foreach($days as $hour_key => $hour){ + $slh .= $hour; + } + } + + /* Shift string to match given timezone settings */ + $shift_by = (168 + ($this->timezone*(-1))) % 168; + for($i = 0 ; $i < $shift_by; $i ++){ + $slh = $slh[167].$slh; + $slh = substr($slh,0,168); + } + + /* Rework string, because it was stored in little endian */ + $new = ''; + for($i = 0 ; $i < 21 ; $i ++ ){ + $part = strrev(substr($slh, $i * 8, 8)); + $byte['hi'] = substr($part,0,4); + $byte['low'] = substr($part,4,4); + $new .= $byte['hi'].$byte['low']; + } + + /* Convert to bin */ + $tmp = ''; + for($i = 0 ; $i < 21 ; $i ++){ + $tmp .= str_pad(base_convert(substr($new,$i*8,8),2,16),2,'0',STR_PAD_LEFT); + } + + /* Create uppercase HEX chars */ + $ret = strtoupper( $tmp); + + /* All hours and days selected */ + if(substr_count($ret,'F') == 42){ + $ret = ""; + } + + return($ret); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/samba/main.inc b/gosa-core/plugins/personal/samba/main.inc new file mode 100644 index 000000000..0c198dc3e --- /dev/null +++ b/gosa-core/plugins/personal/samba/main.inc @@ -0,0 +1,130 @@ +dn); + sess_del ('edit'); + sess_del ('sambaAccount'); + } + + /* Create sambaAccount object on demand */ + if (!isset($_SESSION['sambaAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['sambaAccount']= new sambaAccount ($config, $ui->dn); + $_SESSION['sambaAccount']->enable_CSN_check(); + $_SESSION['sambaAccount']->set_acl_base($ui->dn); + $_SESSION['sambaAccount']->set_acl_category("users"); + } + $sambaAccount= $_SESSION['sambaAccount']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $sambaAccount->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $sambaAccount->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $sambaAccount->save (); + del_lock ($ui->dn); + sess_del ('edit'); + + /* Remove from session */ + sess_del ('sambaAccount'); + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + if($lock_msg){ + $display.= $lock_msg; + }else{ + $display.= $sambaAccount->execute (); + } + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['sambaAccount']= $sambaAccount; + } + + $info= ""; + if (($sambaAccount->is_account) && (!$sambaAccount->show_ws_dialog) && empty($lock_msg)){ + $display.= "

"; + + /* Are we in edit mode? */ + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/sambaAccount"))){ + + $info.= "\"\" ". + _("Click the 'Edit' button below to change informations in this dialog"); + $display.= "\n"; + } + $display.= "\n"; + } + $display.= "

\n"; + } + + /* Page header*/ + $display= print_header(get_template_path('images/samba.png'), _("Samba settings"), + $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/samba/samba2.tpl b/gosa-core/plugins/personal/samba/samba2.tpl new file mode 100644 index 000000000..11b28d8e2 --- /dev/null +++ b/gosa-core/plugins/personal/samba/samba2.tpl @@ -0,0 +1,116 @@ + + + + + + + + + + + +
+

 {t}Generic{/t}

+
+ + + + + +
+ +{render acl=$smbHomeACL} + +{/render} + +{render acl=$smbDriveACL} + +{/render} + +
+
+   + + + + + + + + + + +
+{render acl=$scriptPathACL} + +{/render} +
+{render acl=$profilePathACL} + +{/render} +
+
+ +

 

+ +

 {t}Access options{/t}

+ + + + + + + +
+{render acl=$allow_pwchangeACL} + +{/render} + +
+{render acl=$no_password_requiredACL} + +{/render} + +
+{render acl=$temporary_disableACL} + +{/render} + +
+
+   + +{render acl=$password_expiresACL} + +{/render} + +{render acl=$sambaPwdMustChangeACL} + +{/render} +{render acl=$sambaPwdMustChangeACL} + +{/render} +{render acl=$sambaPwdMustChangeACL} + +{/render} + +
+ + + + + diff --git a/gosa-core/plugins/personal/samba/samba3.tpl b/gosa-core/plugins/personal/samba/samba3.tpl new file mode 100644 index 000000000..251cf5354 --- /dev/null +++ b/gosa-core/plugins/personal/samba/samba3.tpl @@ -0,0 +1,434 @@ + + + + + + + + + + + +
+

 {t}Generic{/t}

+
+ + + + + + + + + +
+{render acl=$sambaHomePathACL} + +{/render} +{render acl=$sambaHomeDriveACL} + +{/render} +
+{render acl=$sambaDomainNameACL} + +{/render} +
+
+   + + + + + + + + + + +
+{render acl=$sambaLogonScriptACL} + +{/render} +
+{render acl=$sambaProfilePathACL} + +{/render} +
+
+ +

 

+ +

 {t}Terminal Server{/t}

+ + + + + + + +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} + {t}Allow login on terminal server{/t} + + + + + + + + + +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+
+   + +{render acl=$AllowLoginOnTerminalServerACL} + +{/render} + {t}Inherit client config{/t} + + + + + + + + + +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+
+ +

 

+ + + + + + + + + +
+ {t}Timeout settings (in minutes){/t} + + + + + + + + + + + + + +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} + + + +{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} + + +{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} + + +{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+
+   + + + {t}Client devices{/t} + + + + + + + + + + +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} + +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} + +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} + +
+ +
+   + + {t}Miscellaneous{/t} + + + + + + + + + + + + + +
+ + +{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+{render acl=$AllowLoginOnTerminalServerACL} + +{/render} +
+ +
+ +

 

+ +

 {t}Access options{/t}

+ + + + + + + +
+{render acl=$sambaPwdCanChangeACL} + +{/render} + +
+{render acl=$sambaAcctFlagsNACL} + +{/render} + +
+{render acl=$sambaAcctFlagsLACL} + +{/render} + +
+{render acl=$sambaPwdMustChangeACL} + +{/render} + +{render acl=$sambaPwdMustChangeACL} + +{/render} +{render acl=$sambaPwdMustChangeACL} + +{/render} +{render acl=$sambaPwdMustChangeACL} + +{/render} +
+{render acl=$sambaLogonTimeACL} + +{/render} + +{render acl=$sambaLogonTimeACL} + +{/render} +{render acl=$sambaLogonTimeACL} + +{/render} +{render acl=$sambaLogonTimeACL} + +{/render} +
+{render acl=$sambaLogoffTimeACL} + +{/render} + +{render acl=$sambaLogoffTimeACL} + +{/render} +{render acl=$sambaLogoffTimeACL} + +{/render} +{render acl=$sambaLogoffTimeACL} + +{/render} +
+ +{render acl=$sambaKickoffTimeACL} + +{/render} + +{render acl=$sambaKickoffTimeACL} + +{/render} +{render acl=$sambaKickoffTimeACL} + +{/render} +{render acl=$sambaKickoffTimeACL} + +{/render} +
+ + + + +
+{render acl=$sambaLogonHoursACL mode=read_active} + {t}Samba logon times{/t}  +{/render} + +
+   + + +
+{render acl=$sambaUserWorkstationsACL} + +{/render} +
+{render acl=$sambaUserWorkstationsACL} + +{/render} +{render acl=$sambaUserWorkstationsACL} + +{/render} +
+ + + + + diff --git a/gosa-core/plugins/personal/samba/samba3_workstations.tpl b/gosa-core/plugins/personal/samba/samba3_workstations.tpl new file mode 100644 index 000000000..f2ecfcc0b --- /dev/null +++ b/gosa-core/plugins/personal/samba/samba3_workstations.tpl @@ -0,0 +1,42 @@ + + + + + +
+
+

+ {$hint}
+

+
+
+

+ +

+
+
+
+

[F] + {t}Filters{/t}

+
+
+ + {$alphabet} +
+
{t}Display workstations of department{/t}  +
+ +
 
+ {$apply} +
+
+ +

+ +   + +

diff --git a/gosa-core/plugins/personal/samba/sambaLogonHours.tpl b/gosa-core/plugins/personal/samba/sambaLogonHours.tpl new file mode 100644 index 000000000..1eb730608 --- /dev/null +++ b/gosa-core/plugins/personal/samba/sambaLogonHours.tpl @@ -0,0 +1,111 @@ + + + + +

{t}Specify the hours this user is allowed to log in{/t}

+
+ + + + + + + + + {foreach from=$Hours item=hours key=key_hours} + {if (($hours)%2) == 0 } + + {/foreach} + + + + + + {foreach from=$Hours item=hours key=key_hours} + {if (($hours)%2) == 0 } + + {/foreach} + + + + +{foreach from=$Matrix item=days key=key_day} + + + {foreach from=$days item=hours key=key_hour} + {if (($key_hour)%2) == 0 } + + {/foreach} + + + + +{/foreach} +
 {t}Hour{/t}
  + {else} + + {/if} + {$hours} +
+   + + {else} + + {/if} + +{render acl=$sambaLogonHoursACL} + +{/render} + + +{render acl=$sambaLogonHoursACL} + +{/render} +
+ {$Days[$key_day]} + + {else} + + {/if} + {if $Matrix[$key_day].$key_hour} +{render acl=$sambaLogonHoursACL} + +{/render} + {else} +{render acl=$sambaLogonHoursACL} + +{/render} + {/if} + +{render acl=$sambaLogonHoursACL} + +{/render} +
+
+ +
+

+ +   + +

+ + diff --git a/gosa-core/plugins/personal/scalix/class_scalixAccount.inc b/gosa-core/plugins/personal/scalix/class_scalixAccount.inc new file mode 100644 index 000000000..2d85f0d88 --- /dev/null +++ b/gosa-core/plugins/personal/scalix/class_scalixAccount.inc @@ -0,0 +1,509 @@ +, + based on work by Cajus Pollmeier + \version 0.01 + \date 20.10.2006 + + This class provides the functionality to read and write all attributes + relevant for scalixAccounts from/to the LDAP. It does syntax checking + and displays the formulars required. + */ + +class scalixAccount extends plugin +{ + /* Definitions */ + var $plHeadline = "Scalix"; + var $plDescription= "This does something"; + + /* plugin specific values - scalixUserClass */ + /* MUST */ + var $scalixScalixObject= TRUE; //TRUE or FALSE + var $scalixMailnode= ""; + /* INDIRECT MUST, scalix will complain if no email was specified */ + + /* MAY */ + var $scalixAdministrator= FALSE; + var $scalixMailboxAdministrator = FALSE; + var $scalixServerLanguage= ""; + var $scalixEmailAddress= array(); + var $scalixLimitMailboxSize= ""; + var $scalixLimitOutboundMail= FALSE; + var $scalixLimitInboundMail= FALSE; + var $scalixLimitNotifyUser= FALSE; + var $scalixHideUserEntry= FALSE; + var $scalixMailboxClass= ""; + + var $uid =""; + var $default_permissions= "none"; + var $member_permissions= "post"; + var $members= array(); + var $admins= array(); + var $vacations= array(); + var $perms= array( "lrs" => "read", + "lrsp" => "post", + "lrsip" => "append", + "lrswipcd" => "write", + "lrswipcda" => "all" ); + + /* attribute list for save action */ + var $attributes = array("scalixMailnode", "scalixServerLanguage", "scalixLimitMailboxSize", "scalixMailboxClass"); + var $fakeBooleanAttributes= array("scalixAdministrator", "scalixMailboxAdministrator", "scalixLimitOutboundMail", + "scalixLimitInboundMail", "scalixLimitNotifyUser", "scalixHideUserEntry"); + var $objectclasses = array("scalixUserClass"); + + + /* constructor, if 'dn' is set, the node loads the given + 'dn' from LDAP */ + function scalixAccount (&$config, $dn= NULL) + { + /* dn shouldn't be NULL */ + if($dn === NULL){ + trigger_error("Initialising scalixAccount without valid dn."); + } + + /* Load bases attributes */ + plugin::plugin($config, $dn); + + /* Load attributes */ + if ($dn != "new"){ + + /* Set user id */ + if(isset($this->attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + foreach ($this->fakeBooleanAttributes as $val){ + if (isset($this->attrs["$val"][0])&&$this->attrs["$val"][0]=="TRUE"){ + $this->$val = TRUE; + } else { + $this->$val = FALSE; + } + } + + /* Load attributes containing arrays */ + foreach (array("scalixEmailAddress") as $val){ + if (isset($this->attrs["$val"]["count"])){ + for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){ + array_push($this->$val, $this->attrs["$val"][$i]); + } + } + } + } + + /* Save initial account state */ + $this->initially_was_account= $this->is_account; + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Load templating engine */ + $smarty= get_smarty(); + $display= ""; + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Show main page */ + $mailboxClasses = array("", "LIMITED", "FULL"); + $serverLanguages= array("", "GERMAN", "ENGLISH"); + + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent === NULL){ + $display= "\"\" ". + _("This account has no scalix extensions.").""; + + $display.= back_to_main(); + return ($display); + } + + /* Show tab dialog headers */ + if ($this->parent !== NULL){ + if ($this->is_account){ + $display= $this->show_disable_header(_("Remove scalix account"), + _("This account has scalix synchronization enabled. You can disable it by clicking below.")); + } else { + $display= $this->show_enable_header(_("Create scalix account"), _("This account has scalix synchronization disabled. You can enable it by clicking below.")); + return ($display); + } + } + + /* Trigger forward add dialog? */ + if (isset($_POST['add_local_forwarder'])){ + $this->forward_dialog= TRUE; + $this->dialog= TRUE; + } + + /* Cancel forward add dialog? */ + if (isset($_POST['add_locals_cancel'])){ + $this->forward_dialog= FALSE; + $this->dialog= FALSE; + } + + + $smarty->assign("mailboxClasses", $mailboxClasses); + $smarty->assign("serverLanguages", $serverLanguages); + foreach(array("perms", "scalixScalixObject", "scalixMailnode", "scalixAdministrator", "scalixMailboxAdministrator", + "scalixServerLanguage", "scalixLimitMailboxSize", "scalixLimitOutboundMail", "scalixEmailAddress", + "scalixLimitInboundMail", "scalixLimitNotifyUser", "scalixHideUserEntry", "scalixMailboxClass") as $val){ + + $smarty->assign("$val", $this->$val); + $smarty->assign("$val"."ACL", $this->getacl($val)); + } + + /* Fill checkboxes */ + if ($this->scalixAdministrator) { + $smarty->assign("scalixAdministrator", "checked"); + } else { + $smarty->assign("scalixAdministrator", ""); + } + if ($this->scalixMailboxAdministrator) { + $smarty->assign("scalixMailboxAdministrator", "checked"); + } else { + $smarty->assign("scalixMailboxAdministrator", ""); + } + if ($this->scalixLimitOutboundMail) { + $smarty->assign("scalixLimitOutboundMail", "checked"); + } else { + $smarty->assign("scalixLimitOutboundMail", ""); + } + if ($this->scalixLimitInboundMail) { + $smarty->assign("scalixLimitInboundMail", "checked"); + } else { + $smarty->assign("scalixLimitInboundMail", ""); + } + if ($this->scalixLimitNotifyUser) { + $smarty->assign("scalixLimitNotifyUser", "checked"); + } else { + $smarty->assign("scalixLimitNotifyUser", ""); + } + if ($this->scalixHideUserEntry) { + $smarty->assign("scalixHideUserEntry", "checked"); + } else { + $smarty->assign("scalixHideUserEntry", ""); + } + + $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + + /* remove object from parent */ + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + /* include global link_info */ + $ldap= $this->config->get_ldap_link(); + + /* Remove and write to LDAP */ + plugin::remove_from_parent(); + + /* Zero arrays */ + $this->attrs['scalixEmailAddress']= array(); + + /* Unset fake boolean attributes from entry */ + foreach ($this->fakeBooleanAttributes as $val){ + $this->attrs["$val"]= array(); + } + + /*unset scalixScalixObject*/ + $this->attrs['scalixScalixObject']=array(); + + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save"); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove"); + } + + + /* Save data to object */ + function save_object() + { + if (isset($_POST['scalixTab'])){ + + /* Save ldap attributes */ + plugin::save_object(); + + /* Save fakeBooleanAttributes*/ + foreach ($this->fakeBooleanAttributes as $val){ + if ($this->acl_is_writeable($val)) { + if( isset ($_POST["$val"])) { + $data = TRUE; + } else { + $data = FALSE; + } + if ($this->$val != $data){ + $this->is_modified= TRUE; + } + + $this->$val= $data; + } + } + } + } + + + /* Save data to LDAP, depending on is_account we save or delete */ + function save() + { + $ldap= $this->config->get_ldap_link(); + + /* Call parents save to prepare $this->attrs */ + plugin::save(); + + /* Save arrays */ + $this->attrs['scalixEmailAddress']= $this->scalixEmailAddress; + + /* Save boolean vars ... the scalix schema expects them as strings */ + $this->attrs['scalixScalixObject'] = $this->scalixScalixObject?"TRUE":"FALSE"; + $this->attrs['scalixAdministrator'] = $this->scalixAdministrator?"TRUE":"FALSE"; + $this->attrs['scalixMailboxAdministrator'] = $this->scalixMailboxAdministrator?"TRUE":"FALSE"; + $this->attrs['scalixLimitOutboundMail'] = $this->scalixLimitOutboundMail?"TRUE":"FALSE"; + $this->attrs['scalixLimitInboundMail'] = $this->scalixLimitInboundMail?"TRUE":"FALSE"; + $this->attrs['scalixLimitNotifyUser'] = $this->scalixLimitNotifyUser?"TRUE":"FALSE"; + $this->attrs['scalixHideUserEntry'] = $this->scalixHideUserEntry?"TRUE":"FALSE"; + + /* Remove Mailquota if = "" */ + if((isset($this->attrs['scalixLimitMailboxSize']))&&($this->attrs['scalixLimitMailboxSize']=="")) { + $this->attrs['scalixLimitMailboxSize']=array(); + } + + /* Save data to LDAP */ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($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"); + } + } else { + $this->handle_post_events("add"); + } + + } + + /* Check formular input */ + function check() + { + $ldap= $this->config->get_ldap_link(); + + $message= array(); + + if(empty($this->scalixMailnode)){ + $message[]= _("There is no scalix mailnode specified."); + } + if(empty($this->scalixScalixObject)){ + $message[]= _("scalixScalixObject must be set!"); + } + + $ldap->cd($this->config->current['BASE']); + foreach($this->scalixEmailAddress as $k => $mail) { + $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=scalixUserClass)(scalixEmailAddress=". + $mail.")(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid")); + + if ($ldap->count() != 0){ + $message[]= _("The email address '$mail' you've entered is already in use."); + } + } + + /* Check quota */ + if ($this->scalixLimitMailboxSize != '' && $this->acl_is_writeable("scalixLimitMailboxSize")){ + if (!is_numeric($this->scalixLimitMailboxSize)) { + $message[]= _("Value in 'Limit Mailbox size' is not valid."); + } else { + $this->scalixLimitMailboxSize= (int) $this->scalixLimitMailboxSize; + } + } + + return ($message); + } + + /* Adapt from template, using 'dn' */ + function adapt_from_template($dn) + { + plugin::adapt_from_template($dn); + + foreach (array("scalixEmailAddress") as $val){ + $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); + } + } + array_push($this->$val, strtolower(rewrite($value))); + } + } + } + $this->mail= strtolower(rewrite($this->mail)); + } + + function addEmail($address) + { + $ldap= $this->config->get_ldap_link(); + + $address= strtolower($address); + + /* Is this address already assigned in LDAP? */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=scalixUserClass)(|(scalixEmailAddress=$address)". + "(scalixEmailAddress=$address)))", array("uid")); + + if ($ldap->count() > 0){ + $attrs= $ldap->fetch (); + return ($attrs["uid"][0]); + } + + /* Add to list of alternates */ + if (!in_array($address, $this->scalixEmailAddress)){ + $this->scalixEmailAddress[]= $address; + $this->is_modified= TRUE; + } + + //sort ($this->scalixEmailAddress); //scalix makes the first email the destination, all others can receive + reset ($this->scalixEmailAddress); + + return (""); + } + + + function delEmail($addresses) + { + $this->scalixEmailAddress= array_remove_entries ($addresses, $this->scalixEmailAddress); + $this->is_modified= TRUE; + } + + + static function plInfo() + { + return (array( + "plDescription" => _("Scalix account"), + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 2, + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + + "scalixMailnode" => _("Scalix Mail node"), + "scalixMailboxClass" => _("Mailbox class"), + "scalixServerLanguage" => _("Server language"), + "scalixAdministrator" => _("Administrator"), + "scalixMailboxAdministrator"=> _("Mailbox administrator"), + "scalixHideUserEntry" => _("Hide user entry in Scalix"), + "scalixLimitMailboxSize" => _("Mailbox size limitations"), + "scalixLimitOutboundMail" => _("Limit outbound"), + "scalixLimitInboundMail" => _("Limit inbound"), + "scalixLimitNotifyUser" => _("Notify user"), + "scalixEmailAddress" => _("Scalix email addresses")) + + )); + } + + + function saveCopyDialog() + { + if (isset($_POST['scalixTab'])){ + + /* Add email addresses */ + if (isset($_POST['add_email'])){ + + /* Check write access */ +# if(!$this->acl_is_writeable("scalixEmailAddress")){ +# print_red(_("You are not allowed to modify alternate addresses")); +# }else{ + + /* Check if given value is not empty */ + if ($_POST['email_address'] != ""){ + $valid= FALSE; + + /* Valid mail address */ + if( ($this->is_template && !is_email($_POST['email_address'], TRUE)) || + (!$this->is_template && !is_email($_POST['email_address'])) ){ + print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); + }else{ + $valid = TRUE; + } + + /* Mail address already in use ? */ + if ($valid && ($user= $this->addEmail ($_POST['email_address'])) != ""){ + $ui= get_userinfo(); + if ($user != $ui->username){ + print_red (_("The address you're trying to add is already used by user")." '$user'."); + } + } +# } + } + } + + /* Delete email addresses */ + if (isset($_POST['delete_email']) && isset ($_POST['emails_list'])){ +# if(!$this->acl_is_writeable("scalixEmailAddress")){ +# print_red(_("You are not allowed to modify alternate addresses")); +# }else{ + if (count($_POST['emails_list'])){ + $this->delEmail ($_POST['emails_list']); +# } + } + } + } + } + + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + foreach ($this->fakeBooleanAttributes as $val){ + if (isset($source["$val"][0])&&$source["$val"][0]=="TRUE"){ + $this->$val = TRUE; + } else { + $this->$val = FALSE; + } + } + + /* Load attributes containing arrays */ + foreach (array("scalixEmailAddress") as $val){ + if (isset($source["$val"]["count"])){ + for ($i= 0; $i<$source["$val"]["count"]; $i++){ + array_push($this->$val, $source["$val"][$i]); + } + } + } + } + + + /* Create the posix dialog part for copy & paste */ + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("scalixEmailAddress",$this->scalixEmailAddress); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:rulere +?> diff --git a/gosa-core/plugins/personal/scalix/generic.tpl b/gosa-core/plugins/personal/scalix/generic.tpl new file mode 100644 index 000000000..669d2ea17 --- /dev/null +++ b/gosa-core/plugins/personal/scalix/generic.tpl @@ -0,0 +1,127 @@ + + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + + + + + +
{$must} +{render acl=$scalixMailnodeACL} + +{/render} +
+{render acl=$scalixMailboxClassACL} + +{/render} +
+{render acl=$scalixServerLanguageACL} + +{/render} +
+ +

 

+ + + +
+{render acl=$scalixAdministratorACL} + {t}Scalix Administrator{/t} +{/render} +
+{render acl=$scalixMailboxAdministratorACL} + {t}Scalix Mailbox Administrator{/t} +{/render} +
+{render acl=$scalixHideUserEntryACL} + {t}Hide this user entry in Scalix{/t} +{/render} +
+
+ +

 

+ + + + + + + + + +
+{render acl=$scalixLimitMailboxSizeACL} +  {t}MB{/t} +{/render} +
+{render acl=$scalixLimitOutboundMailACL} + {t}Limit Outbound Mail{/t} +{/render} +
+{render acl=$scalixLimitInboundMailACL} + {t}Limit Inbound Mail{/t} +{/render} +
+{render acl=$scalixLimitNotifyUserACL} + {t}Notify User{/t} +{/render} +
+
+
+   + +

+{render acl=$scalixEmailAddressACL} + +{/render} +
+{render acl=$scalixEmailAddressACL} + +{/render} +{render acl=$scalixEmailAddressACL} +   +{/render} +{render acl=$scalixEmailAddressACL} + +{/render} +
+ + + + + diff --git a/gosa-core/plugins/personal/scalix/main.inc b/gosa-core/plugins/personal/scalix/main.inc new file mode 100644 index 000000000..0d2558a8a --- /dev/null +++ b/gosa-core/plugins/personal/scalix/main.inc @@ -0,0 +1,129 @@ +dn); + sess_del ('edit'); + sess_del ('scalixAccount'); + } + + /* Create mail object on demand */ + if (!isset($_SESSION['scalixAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['scalixAccount']= new scalixAccount ($config, $ui->dn); + $_SESSION['scalixAccount']->enable_CSN_check(); + $_SESSION['scalixAccount']->set_acl_base($ui->dn); + $_SESSION['scalixAccount']->set_acl_category("users"); + } + $scalixAccount= $_SESSION['scalixAccount']; + + /* save changes back to object */ + if (isset ($_SESSION['edit'])){ + $scalixAccount->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + $_SESSION['back_plugin']= $plug; + $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); + $lock_msg = gen_locked_message ($username, $ui->dn); + + }else{ + + /* Lock the current entry */ + add_lock ($ui->dn, $ui->dn); + $_SESSION['dn']= $ui->dn; + $_SESSION['edit']= TRUE; + } + } + + /* save changes to LDAP and disable edit mode */ + if (isset($_POST['edit_finish'])){ + + /* Perform checks */ + $message= $scalixAccount->check (); + + /* No errors, save object */ + if (count ($message) == 0){ + $scalixAccount->save (); + gosa_log ("User/scalix object'".$ui->dn."' has been saved"); + $scalixAccount->acl= "#none#"; + del_lock ($ui->dn); + sess_del ('edit'); + + /* Remove object */ + sess_del ('scalixAccount'); + } else { + /* Errors found, show message */ + show_errors ($message); + } + } + + /* Execute formular */ + $display= $scalixAccount->execute (); + + /* Store changes in session */ + if (isset ($_SESSION['edit'])){ + $_SESSION['scalixAccount']= $scalixAccount; + } + + /* Show page footer depending on the mode */ + if ($scalixAccount->is_account){ + + $display.= "

"; + + /* Are we in edit mode? */ + if (isset($_SESSION['edit'])){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/scalix"))){ + $info.= "\"\" ". + _("Click the 'Edit' button below to change informations in this dialog"); + + $display.= "\n"; + } + $display.= "\n"; + } + $display.= "

\n"; + } + + + $info= ""; + + /* Page header*/ + $display= print_header(get_template_path('images/scalix.png'), _("Scalix settings"), $info).$display; + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/plugins/personal/scalix/paste_generic.tpl b/gosa-core/plugins/personal/scalix/paste_generic.tpl new file mode 100644 index 000000000..4bdf489aa --- /dev/null +++ b/gosa-core/plugins/personal/scalix/paste_generic.tpl @@ -0,0 +1,25 @@ + + + + +
+

+ +
+ +   + +
+ + + + + diff --git a/gosa-core/setup/class_setup.inc b/gosa-core/setup/class_setup.inc new file mode 100644 index 000000000..753751c52 --- /dev/null +++ b/gosa-core/setup/class_setup.inc @@ -0,0 +1,306 @@ +o_steps[$i++] = new Step_Welcome(); + $this->o_steps[$i++] = new Step_Language(); + $this->o_steps[$i++] = new Step_Checks(); + $this->o_steps[$i++] = new Step_License(); + $this->o_steps[$i++] = new Step_Ldap(); + $this->o_steps[$i++] = new Step_Schema(); + $this->o_steps[$i++] = new Step_Config1(); + $this->o_steps[$i++] = new Step_Config2(); + $this->o_steps[$i++] = new Step_Config3(); + $this->o_steps[$i++] = new Step_Migrate(); + $this->o_steps[$i++] = new Step_Feedback(); + $this->o_steps[$i++] = new Step_Finish(); + $this->i_steps = $i-1; + + /* Ensure that setup is not reachable if gosa.conf (CONFIG_FILE) */ + if(file_exists(CONFIG_DIR."/".CONFIG_FILE)){ + session_destroy(); + header("Location: index.php") ; + exit(); + } + + foreach($this->o_steps as $key => $step){ + $this->o_steps[$key]->parent = &$this; + } + } + + function execute() + { + /* Display phpinfo() dialog when $_GET['info'] is set, + * but only do this, if user is allowed to use the setup. + * If setupStep_Welcome is_completed, we are allowed to view those infos- + */ + if(isset($_GET['info']) && preg_match("/Step_Welcome/i",get_class($this->o_steps[1])) && $this->o_steps[1]->is_completed()){ + phpinfo(); + exit(); + } + + /* display step error msgs */ + $msgs = $this->o_steps[$this->i_current]->check(); + foreach($msgs as $msg){ + print_red($msg); + } + + $this->o_steps[$this->i_last]->set_active(FALSE); + $this->o_steps[$this->i_current]->set_active(); + $content = $this->o_steps[$this->i_current]->execute(); + return($content); + } + + + /* Save posted attributes */ + function save_object() + { + /* Call save_object for current setup step */ + $this->o_steps[$this->i_current] -> save_object(); + + /* Get attributes from setup step */ + $tmp = $this->o_steps[$this->i_current]->get_attributes(); + foreach($tmp as $name => $value){ + $this->captured_values[$name] = $value; + } + + /* Set parent */ + foreach($this->o_steps as $key => $value){ + $this->o_steps[$key]->parent = $this; + } + + /* Check if image button requests next page */ + foreach($_POST as $name => $value){ + if(preg_match("/^next_(x|y)/",$name)){ + $_POST['next'] = TRUE; + } + if(preg_match("/^last_(x|y)/",$name)){ + $_POST['last'] = TRUE; + } + } + + /* Check if step was selected */ + if(isset($_GET['step']) || isset($_POST['next']) || isset($_POST['last'])){ + + /* check if current setup step is completed now + and activate the next step if possible */ + for($i = 1 ; $i <= $this->i_steps ; $i ++ ){ + if($this->o_steps[$i]->is_completed()){ + if(isset($this->o_steps[($i+1)])){ + $this->o_steps[($i+1)]->set_enabled(); + } + }else{ + $this->disable_steps_from($i+1); + } + } + } + + /* Disable all following steps, if one step isn't compelted right now .*/ + for($i = 1 ; $i <= $this->i_steps ; $i ++ ){ + if($this->o_steps[$i]->is_completed()){ + }else{ + $this->disable_steps_from($i+1); + } + } + + $step = -1; + + if(isset($_POST['setup_goto_step'])){ + $step= $_POST['setup_goto_step']; + } + + if(isset($_GET['step'])){ + $step = $_GET['step']; + }elseif(isset($_POST['next'])){ + $step = $this->i_current + 1; + }elseif(isset($_POST['last'])){ + $step = $this->i_current - 1; + } + + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^step_[0-9]*$/",$name) && $once ){ + $step = preg_replace("/^step_/","",$name); + } + } + + if($this->selectable_step($step)){ + $this->i_last = $this->i_current; + $this->i_current = $step; + } + } + + + function disable_steps_from($start) + { + $found = false; + foreach($this->o_steps as $key => $step){ + if($key == $start){ + $found = true; + } + + if($found){ + $this->o_steps[$key]->set_enabled(false); + $this->o_steps[$key]->set_completed(false); + } + } + } + + + /* Create navigation menu */ + function get_navigation_html() + { + $str = ""; + foreach($this->o_steps as $key => $step){ + + $step -> update_strings(); + + $s_title = $step -> get_title(); + $s_info = $step -> get_small_info(); + $b_active = $step -> is_active(); + $b_enabled = $step -> is_enabled(); + $b_completed= $step -> is_completed(); + + if($b_completed){ + $s = ""._("Completed")." "; + }else{ + $s = "  "; + } + + if($_SESSION['js']){ + + $str .="
"; + + if($b_enabled){ + if($b_active){ + $str .= ""; + }else{ + $str .= ""; + } + }else{ + $str .= ""; + } + $str .= "
" ; + }else{ + $str .="
"; + if($b_enabled){ + if($b_active){ + $str .= ""; + }else{ + $str .= ""; + } + }else{ + $str .= ""; + } + $str .= "
" ; + } + } + return($str); + } + + + + function get_bottom_html() + { + /* Skip adding forward/backward button, + * if the currently opened step is a sub dialog + */ + if($this->o_steps[$this->i_current]->dialog){ + $str =""; + }else{ + $str ="

 

"; + $str.="
"; + if(isset($this->o_steps[$this->i_current -1]) && $this->o_steps[$this->i_current -1]->is_enabled()){ + $str .= ""; + }else{ + $str .= ""; + } + $str.= " "; + $str .= ""; + $str .="
"; + } + return($str); + } + + + /* Create header entry */ + function get_header_html() + { + $str= $this->o_steps[$this->i_current]->print_header(); + return ($str); + } + + + /* Check if the given step id is valid and selectable */ + function selectable_step($id) + { + if(isset($this->o_steps[$id]) && $this->o_steps[$id]->is_enabled()){ + return(true); + } + return(false); + } + + function step_name_to_id($name) + { + foreach($this->o_steps as $id => $class){ + if(get_class($class) == $name){ + return($id); + } + } + return(0); + } + +} + + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep.inc b/gosa-core/setup/class_setupStep.inc new file mode 100644 index 000000000..5364187e4 --- /dev/null +++ b/gosa-core/setup/class_setupStep.inc @@ -0,0 +1,130 @@ +s_title); + } + + function get_long_title() + { + return($this->s_title_long); + } + + function get_small_info() + { + return($this->s_info); + } + + function is_active() + { + return($this->is_active); + } + + function is_enabled() + { + return($this->is_enabled); + } + + function is_completed() + { + return($this->is_completed); + } + + function set_active($value = TRUE) + { + if($value){ + $this->is_active = TRUE; + }else{ + $this->is_active = FALSE; + } + } + + function set_enabled($value = TRUE) + { + if($value){ + $this->is_enabled = TRUE; + }else{ + $this->is_enabled = FALSE; + } + } + + function set_completed($value = TRUE) + { + if($value){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + } + + /* Return attributes handled by this setup step */ + function get_attributes() + { + $tmp = array(); + foreach($this->attributes as $attr){ + $tmp[$attr] = $this->$attr; + } + return($tmp); + } + + function print_header() + { + $image= get_template_path($this->header_image); + $display= "
"; + $display.= "

\"*\" ".$this->s_title_long."

\n"; + $display.= "
\n"; + + return($display); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Checks.inc b/gosa-core/setup/class_setupStep_Checks.inc new file mode 100644 index 000000000..99e34ddfa --- /dev/null +++ b/gosa-core/setup/class_setupStep_Checks.inc @@ -0,0 +1,312 @@ +update_strings(); + } + + + function update_strings() + { + $this->s_title = _("Installation check"); + $this->s_title_long = _("Installation check"); + $this->s_info = _("Basic checks for PHP version and required extensions."); + } + + + /* Execute and display template */ + function execute() + { + $this->run_checks(); + $smarty = get_smarty(); + $smarty->assign("basic" ,$this->basic_checks); + $smarty->assign("config" ,$this->config_checks); + $smarty->assign("is_writeable",$this->is_writeable); + return($smarty->fetch(get_template_path("setup_checks.tpl",TRUE,dirname(__FILE__)))); + } + + + /* Execute all checks */ + function run_checks() + { + $this->basic_checks = array(); + $this->config_checks = array(); + $this->is_writeable = array(); + + /* PHP version check */ + $N = _("Checking PHP version"); + $D = sprintf(_("PHP must be of version %s or above."), "5.2.0"); + $S = _("GOsa requires functionality that is not available (or buggy) in older PHP versions. Please update to a supported version."); + $R = $this->check_php_version(); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking imap extension */ + $N = _("Checking for LDAP support"); + $D = _("This is the main extension used by GOsa and therefore really required."); + $S = _("The ldap extension (php5-ldap) is required to communicate with your LDAP server."); + $R = is_callable("ldap_bind"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check for gettext support */ + $N = _("Checking for gettext support"); + $D = _("Gettext support is required for internationalization."); + $S = _("Please make sure that the extension is activated."); + $R = is_callable("bindtextdomain"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checing for iconv */ + $N = _("Checking for iconv support"); + $D = _("This module is used by GOsa to convert samba munged dial informations and is therefore required. "); + $S = _("Please make sure that the extension is activated."); + $R = is_callable("iconv"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check for installed mhash module */ + $N = _("Checking for mhash support"); + $D = _("You'll need this module to make use of SSHA encryption"); + $S = _("The mhash module for PHP 5 is not available.Please install php5-mhash."); + $R = is_callable("mhash"); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Is imap module available */ + $N = _("Checking for IMAP support"); + $D = _("The IMAP module is needed to communicate with the IMAP server. GOsa retrieves status information, creates and deletes mail users, etc."); + $S = _("This module is used to communicate with your mail server. Please install php5-imap."); + $R = is_callable("imap_open"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check getacl in imap module */ + $N = _("Checking for getacl in IMAP implementation"); + $D = _("The getacl support is needed to handle shared folder permissions. Old IMAP extensions are not capable of reading acl's. You need a recent PHP version to use this feature."); + $S = $D; + $R = is_callable("imap_getacl"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Mysql module loaded ? */ + $N = _("Checking for MySQL support"); + $D = _("MySQL support is needed to communicate with several supported databases."); + $S = _("This module is required to communicate with database servers (GOfax, asterisk, GLPI, etc.). Please install php5-mysql"); + $R = is_callable("mysql_query"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking for kadm5 module */ + $N = _("Checking for kadm5 support"); + $D = _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network."); + $S = _("This module is required to manage user in kerberos, it is downloadable via PEAR network"); + $R = is_callable("kadm5_init_with_password"); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Snmp module available ? */ + $N = _("Checking for SNMP support"); + $D = _("The simple network management protocol is needed to get status information from clients."); + $S = _("This module is required for client monitoring. Please install php5-snmp."); + $R = is_callable("snmpget"); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking for Cups module */ + $N = _("Checking for CUPS support"); + $D = _("In order to read available printers via the IPP protocol instead of printcap files, you've to install the CUPS module."); + $S = $D; + $R = is_callable("cups_get_dest_list"); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking for F ping utility */ + $query= "LC_ALL=C LANG=C fping -v 2>&1"; + $output= shell_exec ($query); + $N = _("Checking for fping utility"); + $D = _("The fping utility is used if you've got a thin client based terminal environment."); + $S = _("The fping utility is only used in thin client based terminal environment."); + $R = preg_match("/^fping:/", $output); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking generate LM/NT password hashes */ + $query= "mkntpwd 2>&1"; + $output= shell_exec ($query); + $have_mkntpwd= preg_match("/^Usage: mkntpwd /", $output); + if (!$have_mkntpwd){ + $query= 'LC_ALL=C LANG=C perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen $ARGV[0]), $/;" &>/dev/null'; + system ($query, $ret); + $have_mkntpwd |= ($ret == 0); + } + + $N = _("SAMBA password hash generation"); + $D = _("In order to use SAMBA 2/3 passwords, you've to install additional packages to generate password hashes."); + $S = _("In order to use SAMBA 2/3 you've to install additional perl libraries. Take a look at mkntpasswd."); + $R = $have_mkntpwd; + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + + /* PHP Configuration checks + */ + + /* Register_globals off */ + $N = "register_globals = "._("Off").""; + $D = _("register_globals is a PHP mechanism to register all global variables to be accessible from scripts without changing the scope. This may be a security risk."); + $S = _("Search for 'register_globals' in your php.ini and switch it to 'Off'."); + $R = ini_get("register_globals") == 0; + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + + /* session lifetime set to >=86400 seconds ? */ + $N = "session.gc_maxlifetime >= 86400"; + $D = _("PHP uses this value for the garbage collector to delete old sessions.")." ". + _("Setting this value to one day will prevent loosing session and cookies before they really timeout."); + $S = _("Search for 'session.gc_maxlifetime' in your php.ini and set it to 86400 or higher."); + $R = ini_get("session.gc_maxlifetime") >= 86400; + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Session auto start must be turned off */ + $session_auto_start = ini_get('session.auto_start'); + $N = "session.auto_start = "._("Off").""; + $D = _("In Order to use GOsa without any trouble, the session.auto_register option in your php.ini should be set to 'Off'."); + $S = _("Search for 'session.auto_start' in your php.ini and set it to 'Off'."); + $R = !$session_auto_start['local_value']; + $M = TRUE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check if memory limit is set to 32 or > */ + $N = "memory_limit >= 32"; + $D = _("GOsa needs at least 32MB of memory. Setting it below this limit may cause errors that are not reproducable! Increase it for larger setups."); + $S = _("Search for 'memory_limit' in your php.ini and set it to '32M' or higher."); + $R = ini_get('memory_limit') >= 32 ; + $M = TRUE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Implicit Flush disabled can increase performance */ + $N = "implicit_flush = "._("Off").""; + $D = _("This option influences the PHP output handling. Turn this Option off, to increase performance."); + $S = _("Search for 'implicit_flush' in your php.ini and set it to 'Off'."); + $R = !ini_get('implicit_flush'); + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check if execution time is set to 30 */ + $N = "max_execution_time >= 30"; + $D = _("The Execution time should be at least 30 seconds."); + $S = _("Search for 'max_execution_time' in your php.ini and set it to '30' or higher."); + $R = ini_get("max_execution_time") >= 30 ; + $M = TRUE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Expose php should be set to off */ + $N = "expose_php = "._("Off").""; + $D = _("Increase the server security by setting expose_php to 'off'. PHP won't send any information about the server you are running in this case."); + $S = _("Search for 'expose_php' in your php.ini and set if to 'Off'."); + $R = !ini_get("expose_php"); + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Automatic quoting must be turned on */ + $N = "magic_quotes_gpc = "._("On").""; + $D = _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case."); + $S = _("Search for 'magic_quotes_gpc' in your php.ini and set it to 'On'."); + $R = ini_get('magic_quotes_gpc'); + $M = TRUE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Emulating old stuff? */ + $N = "zend.ze1_compatibility_mode = "._("Off").""; + $D = _("Increase your server performance by setting magic_quotes_gpc to 'off'."); + $S = _("Search for 'zend.ze1_compatibility_mode' in your php.ini and set it to 'Off'."); + $R = !ini_get('zend.ze1_compatibility_mode'); + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + + /* Configuration file + */ + + /* Check if we can create a config file.*/ + $N = _("Configuration writeable"); + $D = _("The configuration file can't be written"); + $S = sprintf(_("GOsa reads its configuration from a file located in (%s/%s). The setup can write the configuration directly if it is writeable."),CONFIG_DIR,CONFIG_FILE); + $R = ( file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR."/".CONFIG_FILE)) // is there a config file ? + || (!file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR)); // There is non, but can we create a file there ? + $M = FALSE; + $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* If we have writeaccess to the config dir, check if there is already a config file */ +# if($R){ +# +# /* check if there is already a config file. */ +# $N = _("No old configuration file."); +# $D = "";//_(""); +# $S = _("If there is already a configuration file, this file will be overwritten when GOsa setup finishes. Please move your old config file away."); +# $R = !file_exists(CONFIG_DIR."/".CONFIG_FILE); +# $M = FALSE; +# $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); +# } + } + + + function save_object() + { + /* If everything is fine, set this step to completed + * and allow switching to next setup step + */ + $failed = false; + foreach(array("basic_checks","config_checks","is_writeable") as $type){ + foreach($this->$type as $obj){ + + if($obj['MUST'] && !$obj['RESULT']){ + $failed = true; + break; + } + } + } + $this->is_completed = !$failed; + } + + + /* Check if current PHP version is compatible + with the current version of GOsa */ + function check_php_version() + { + return(version_compare(phpversion(),"5.2.0",">=")); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Config1.inc b/gosa-core/setup/class_setupStep_Config1.inc new file mode 100644 index 000000000..1087b6a2b --- /dev/null +++ b/gosa-core/setup/class_setupStep_Config1.inc @@ -0,0 +1,245 @@ + 6, + "pwminlen_active" => FALSE, + "pwdiffer" => 5, + "pwdiffer_active" => FALSE, + "externalpwdhook" => "", + "externalpwdhook_active" => FALSE); + + var $id_settings = array( "idgen" => "{%sn}-{%givenName[2-4]}", + "idgen_active" => FALSE, + "minid" => "100", + "minid_active" => FALSE); + + var $crypt_methods = array(); + + var $attributes = array("compressed","peopleou","groupou","peopledn","uidbase","encryption","theme","krbsasl", + "base_hook","base_hook_active","account_expiration","strict","include_personal_title"); + + function Step_Config1() + { + $this->update_strings(); + + $tmp = @passwordMethod::get_available_methods(); + foreach($tmp['name'] as $name){ + $this->crypt_methods[$name] = $name; + } + } + + + function update_strings() + { + $this->s_title = _("GOsa settings 1/3"); + $this->s_title_long = _("GOsa settings 1/3"); + $this->s_info = _("GOsa generic settings"); + } + + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("peopledns",array("uid","cn")); + $smarty->assign("id_settings",$this->id_settings); + $smarty->assign("crypt_methods",$this->crypt_methods); + $smarty->assign("themes",$this->get_themes()); + $smarty->assign("pwd_rules",$this->pwd_rules); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* !!! Attention strict is inverse. If you change this, + * don't forget to change save_object too + */ + $smarty->assign("strict",!$this->strict); + return($smarty -> fetch (get_template_path("../setup/setup_config1.tpl"))); + } + + + function get_themes() + { + $dir = opendir( "../ihtml/themes/"); + $themes = array(); + while (($file = readdir($dir)) !== false){ + if(is_dir("../ihtml/themes/".$file) && !preg_match("/^\./",$file)){ + $themes[$file] = $file; + } + } + return($themes); + } + + function check() + { + $message = array(); + + if(isset($this->id_settings['minid_active']) && !is_numeric($this->id_settings['minid'])){ + $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id")); + } + + if(preg_match("/,$/",$this->peopleou)){ + $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("People storage ou")); + } + + if(preg_match("/,$/",$this->groupou)){ + $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("Group storage ou")); + } + + if(!is_numeric($this->uidbase)){ + $message[] = _("Uid base must be numeric"); + } + + if(($this->pwd_rules['pwminlen_active']) && !is_numeric($this->pwd_rules['pwminlen'])){ + $message[] = _("The given password minimum length is not numeric."); + } + if(($this->pwd_rules['pwdiffer_active']) && !is_numeric($this->pwd_rules['pwdiffer'])){ + $message[] = _("The given password differ value is not numeric."); + } + return($message); + } + + function save_object() + { + if(isset($_POST['step5_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate(get_post($attr)); + } + } + + /* !!! Attention strict is inverse. If you change this, + * don't forget to change the smarty assignment too + */ + if(isset($_POST['strict'])){ + if($_POST['strict']){ + $this->strict = FALSE; + }else{ + $this->strict = TRUE; + } + } + + if(isset($_POST['minid_active'])){ + $this->id_settings['minid_active'] = TRUE; + if(isset($_POST['minid'])){ + $this->id_settings['minid'] = get_post('minid'); + } + }else{ + $this->id_settings['minid_active'] = FALSE; + } + + /* Generic settings */ + if(isset($_POST['idgen_active'])){ + $this->id_settings['idgen_active'] = TRUE; + if(isset($_POST['idgen'])){ + $this->id_settings['idgen'] = get_post('idgen'); + } + }else{ + $this->id_settings['idgen_active'] = FALSE; + } + + /* Get password settings */ + if(isset($_POST['pwdiffer_active'])){ + $this->pwd_rules['pwdiffer_active'] = TRUE; + if(isset($_POST['pwdiffer'])){ + $this->pwd_rules['pwdiffer'] = get_post('pwdiffer'); + } + }else{ + $this->pwd_rules['pwdiffer_active'] = FALSE; + } + + /* Get password minimum length posts */ + if(isset($_POST['pwminlen_active'])){ + $this->pwd_rules['pwminlen_active'] = TRUE; + if(isset($_POST['pwminlen'])){ + $this->pwd_rules['pwminlen'] = get_post('pwminlen'); + } + }else{ + $this->pwd_rules['pwminlen_active'] = FALSE; + } + + /* External pwd settings */ + if(isset($_POST['externalpwdhook_active'])){ + $this->pwd_rules['externalpwdhook_active'] = TRUE; + if(isset($_POST['externalpwdhook'])){ + $this->pwd_rules['externalpwdhook'] = get_post('externalpwdhook'); + } + }else{ + $this->pwd_rules['externalpwdhook_active'] = FALSE; + } + + /* base hook settings */ + if(isset($_POST['base_hook_active'])){ + $this->pwd_rules['base_hook_active'] = TRUE; + if(isset($_POST['base_hook'])){ + $this->pwd_rules['base_hook'] = get_post('base_hook'); + } + }else{ + $this->pwd_rules['base_hook_active'] = FALSE; + } + } + + $tmp = $this->check(); + if(count($tmp) == 0){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + }// if tempalte posted + + + /* Attributes that are interesting for configuration generation */ + function get_attributes() + { + $tmp = setup_step::get_attributes(); + foreach(array("pwd_rules","id_settings") as $attr){ + $tmp[$attr]= $this->$attr; + } + return($tmp); + } +}// CLass + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Config2.inc b/gosa-core/setup/class_setupStep_Config2.inc new file mode 100644 index 000000000..e6b96b10c --- /dev/null +++ b/gosa-core/setup/class_setupStep_Config2.inc @@ -0,0 +1,312 @@ + "/etc/gosa/vacation", + "vacationdir_active" => FALSE); + + var $generic_settings = array( "enableCopyPaste" => false, + "enableDNS" => false, + "enableDHCP" => false, + "wws_ou" => "ou=winstations", + "wws_ou_active" => FALSE, + "snapshot_active" => FALSE, + "snapshot_base" => "ou=snapshots,%base%", + "snapshot_user" => "%admin%", + "snapshot_password" => "", + "snapshot_server" => "%connection%"); + + var $samba_settings = array( "samba_sid" => "0-815-4711", + "samba_sid_active" => FALSE, + "samba_rid" => 1000, + "smbhash" => 'SMBHASH', + "samba_rid_active" => FALSE); + + var $sambaDomain_found = FALSE; + var $use_netatalk = FALSE; + var $enableFAI_management = FALSE; + var $enableMimeType = FALSE; + + var $timezone = "Europe/Berlin"; + var $timezones = array(); + + var $attributes = array("governmentmode","sambaidmapping","cyrusunixstyle","mail","use_netatalk","enableFAI_management","timezone","enableMimeType"); + var $called = FALSE; + + function Step_Config2() + { + $this->update_strings(); + $tmp = $this->get_available_mail_classes(); + foreach($tmp['name'] as $name){ + $this->mail_methods[$name] = $name; + } + + /* Look for samba password generation method */ + if(file_exists("/usr/bin/mkntpasswd")){ + $pwdhash = "/usr/bin/mkntpasswd"; + } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){ + $pwdhash= "mkntpwd"; + } else { + $pwdhash= 'perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;"'; + } + + $this->timezones = _get_tz_zones(); + $this->samba_settings['smbhash'] = $pwdhash; + } + + + function update_strings() + { + $this->s_title = _("GOsa settings 2/3"); + $this->s_title_long = _("GOsa settings 2/3"); + $this->s_info = _("Customize special parameters"); + } + + + function execute() + { + /* On first call check for rid/sid base */ + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + $ldap->search("(objectClass=sambaDomain)",array("dn")); + if($ldap->count()){ + $this->sambaDomain_found =TRUE; + }else{ + $this->sambaDomain_found =FALSE; + } + + if(!$this->called){ + if(!$this->sambaDomain_found){ + $this->samba_settings['samba_sid_active'] = TRUE; + $this->samba_settings['samba_rid_active'] = TRUE; + } + + /* Check if we can enable netatalk plugin */ + $tmp = $ldap->get_objectclasses(); + if(is_array($tmp) && isset($tmp['apple-user'])) { + $this->use_netatalk = TRUE; + } + + /* Check the FAI schema is used */ + if(is_array($tmp) && isset($tmp['FAIclass'])){ +# $this->enableFAI_management = TRUE; + } + + /* Check the MimeType schema is used */ + if(is_array($tmp) && isset($tmp['gotoMimeType'])){ + $this->enableMimeType = TRUE; + } + + if(is_array($tmp) && isset($tmp['dhcpClass'])){ + $this->generic_settings['enableDHCP'] = TRUE; + } + + if(is_array($tmp) && isset($tmp['dNSZone'])){ + $this->generic_settings['enableDNS'] = TRUE; + } + + $this->called = TRUE; + } + + /* Update snapshot values, with already collected values */ + foreach($this->generic_settings as $key => $value){ + foreach(array("snapshot_base","snapshot_user","snapshot_server") as $attr){ + foreach($this->parent->captured_values as $replace_name => $replace_value){ + if(is_string($replace_value)) { + $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]); + } + } + } + } + + $smarty = get_smarty(); + $smarty->assign("sambaDomain_found",$this->sambaDomain_found); + $smarty->assign("generic_settings",$this->generic_settings); + $smarty->assign("mail_settings",$this->mail_settings); + $smarty->assign("mail_methods",$this->mail_methods); + $smarty->assign("samba_settings",$this->samba_settings); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $smarty->assign("timezone" ,$this->timezone); + $smarty->assign("timezones" ,$this->timezones); + return($smarty -> fetch (get_template_path("../setup/setup_config2.tpl"))); + } + + function save_object() + { + if(isset($_POST['step6_posted'])){ + + if(isset($_POST['timezone']) && isset($this->timezones['TIMEZONES'][$_POST['timezone']])){ + $this->timezone = $_POST['timezone']; + } + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate(get_post($attr)); + } + } + + /* Mail settings */ + if(isset($_POST['vacationdir_active'])){ + $this->mail_settings['vacationdir_active'] = TRUE; + if(isset($_POST['vacationdir'])){ + $this->mail_settings['vacationdir'] = get_post('vacationdir'); + } + }else{ + $this->mail_settings['vacationdir_active'] = FALSE; + } + + if(isset($_POST['enableCopyPaste'])){ + $this->generic_settings['enableCopyPaste'] = get_post('enableCopyPaste'); + } + if(isset($_POST['enableDNS'])){ + $this->generic_settings['enableDNS'] = get_post('enableDNS'); + } + if(isset($_POST['enableDHCP'])){ + $this->generic_settings['enableDHCP'] = get_post('enableDHCP'); + } + + if(isset($_POST['wws_ou_active'])){ + $this->generic_settings['wws_ou_active'] = TRUE; + if(isset($_POST['wws_ou'])){ + $this->generic_settings['wws_ou'] = get_post('wws_ou'); + } + }else{ + $this->generic_settings['wws_ou_active'] = FALSE; + } + + if(isset($_POST['snapshot_active'])){ + $this->generic_settings['snapshot_active'] = TRUE; + if(isset($_POST['snapshot_base'])){ + $this->generic_settings['snapshot_base'] = get_post('snapshot_base'); + } + if(isset($_POST['snapshot_user'])){ + $this->generic_settings['snapshot_user'] = get_post('snapshot_user'); + } + if(isset($_POST['snapshot_password'])){ + $this->generic_settings['snapshot_password'] = get_post('snapshot_password'); + } + if(isset($_POST['snapshot_server'])){ + $this->generic_settings['snapshot_server'] = get_post('snapshot_server'); + } + }else{ + $this->generic_settings['snapshot_active'] = FALSE; + } + + /* Samba settings */ + if(isset($_POST['samba_sid_active'])){ + $this->samba_settings['samba_sid_active'] = TRUE; + if(isset($_POST['samba_sid'])){ + $this->samba_settings['samba_sid'] = get_post('samba_sid'); + } + }else{ + $this->samba_settings['samba_sid_active'] = FALSE; + } + if(isset($_POST['samba_rid_active'])){ + $this->samba_settings['samba_rid_active'] = TRUE; + if(isset($_POST['samba_rid'])){ + $this->samba_settings['samba_rid'] = get_post('samba_rid'); + } + }else{ + $this->samba_settings['samba_rid_active'] = FALSE; + } + if(isset($_POST['smbhash'])){ + $this->samba_settings['smbhash'] = get_post('smbhash'); + } + + if(!$this->sambaDomain_found){ + $this->samba_settings['samba_sid_active'] = TRUE; + $this->samba_settings['samba_rid_active'] = TRUE; + } + } + + $tmp = $this->check(); + if(count($tmp) == 0){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + } + + + function check() + { + $message = array(); + return($message); + } + + + /* Attributes that are interesting for configuration generation */ + function get_attributes() + { + $tmp = setup_step::get_attributes(); + foreach(array("samba_settings","generic_settings","mail_settings") as $attr){ + $tmp[$attr]= $this->$attr; + } + return($tmp); + } + +/* Returns the classnames auf the mail classes */ + function get_available_mail_classes() + { + $dir = opendir( "../include"); + $methods = array(); + $suffix = "class_mail-methods-"; + $lensuf = strlen($suffix); + $prefix = ".inc"; + $lenpre = strlen($prefix); + $i = 0; + while (($file = readdir($dir)) !== false){ + + if(stristr($file,$suffix)) { + $lenfile = strlen($file); + $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre); + $methods['file'][$i] = $file; + $methods[$i]['file'] = $file; + $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre); + $i++; + } + } + return($methods); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Config3.inc b/gosa-core/setup/class_setupStep_Config3.inc new file mode 100644 index 000000000..eaa5368b1 --- /dev/null +++ b/gosa-core/setup/class_setupStep_Config3.inc @@ -0,0 +1,229 @@ + "uid", + "mail" => "mail", + "uid,mail" => "both"); + var $optional = array( + "login_attribute" => "uid", + "strict_units" => false, + "list_summary" => false, + "forceglobals" => true, + "forcessl" => false, + "ldapstats" => false, + "warnssl" => true, + "user_filter_cookie" => true, + "ppd_path" => "/var/spool/ppd/", + "ppd_path_active" => FALSE, + "compile" => "/var/spool/gosa", + "snmpcommunity" => "goto", + "debuglevel" => 0, + "session_lifetime" => 7200, + "max_ldap_query_time" => "5.0", + "max_ldap_query_time_active" => FALSE, + + "mailQueueScriptPath" => "/usr/bin/sudo /usr/local/sbin/mailqueue %action %id %server", + "mailQueueScriptPath_active" => FALSE, + + "auto_network_hook" => "/usr/bin/net-resolver.sh", + "auto_network_hook_active" => FALSE, + + "notifydir" => "", + "notifydir_active" => FALSE, + + "uniq_identifier" => "entryCSN", + "uniq_identifier_active" => TRUE, + + "kioskpath" => "/var/spool/kiosk", + "kioskpath_active" => FALSE, + + "gotomasses_file" => "/etc/gosa/gotomasses", + "gotomasses_active" => FALSE, + + "noprimarygroup" => FALSE); + + var $attributes = array("errorlvl"); + + function Step_Config3() + { + $this->update_strings(); + } + + + function update_strings() + { + $this->s_title = _("GOsa settings 3/3"); + $this->s_title_long = _("GOsa settings 3/3"); + $this->s_info = _("Tweak some GOsa core behaviour"); + } + + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + $smarty->assign("uniq_identifiers",array( "entryCNS" => "entryCSN", + "contextCSN"=>"contextCSN" )); + $smarty->assign("optional", $this->optional); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $smarty->assign("login_attributes",$this->login_attributes); + return($smarty -> fetch (get_template_path("../setup/setup_config3.tpl"))); + } + + + function save_object() + { + if(isset($_POST['step6a_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate(get_post($attr)); + } + } + + foreach(array("login_attribute","list_summary","strict_units","snmpcommunity","noprimarygroup","forceglobals","forcessl","ldapstats","user_filter_cookie","warnssl","compile","debuglevel","session_lifetime") as $name){ + if(isset($_POST[$name])){ + $this->optional[$name] = get_post($name); + } + } + + if(isset($_POST['ppd_path_active'])){ + $this->optional['ppd_path_active'] = TRUE; + if(isset($_POST['ppd_path'])){ + $this->optional['ppd_path'] = get_post('ppd_path'); + } + }else{ + $this->optional['ppd_path_active'] = FALSE; + } + + if(isset($_POST['max_ldap_query_time_active'])){ + $this->optional['max_ldap_query_time_active'] = TRUE; + if(isset($_POST['max_ldap_query_time'])){ + $this->optional['max_ldap_query_time'] = get_post('max_ldap_query_time'); + } + }else{ + $this->optional['max_ldap_query_time_active'] = FALSE; + } + + if(isset($_POST['mailQueueScriptPath_active'])){ + $this->optional['mailQueueScriptPath_active'] = TRUE; + if(isset($_POST['mailQueueScriptPath'])){ + $this->optional['mailQueueScriptPath'] = get_post('mailQueueScriptPath'); + } + }else{ + $this->optional['mailQueueScriptPath_active'] = FALSE; + } + + if(isset($_POST['kioskpath_active'])){ + $this->optional['kioskpath_active'] = TRUE; + if(isset($_POST['kioskpath'])){ + $this->optional['kioskpath'] = get_post('kioskpath'); + } + }else{ + $this->optional['kioskpath_active'] = FALSE; + } + + if(isset($_POST['gotomasses_active'])){ + $this->optional['gotomasses_active'] = TRUE; + if(isset($_POST['gotomasses_file'])){ + $this->optional['gotomasses_file'] = get_post('gotomasses_file'); + } + }else{ + $this->optional['gotomasses_active'] = FALSE; + } + + if(isset($_POST['auto_network_hook_active'])){ + $this->optional['auto_network_hook_active'] = TRUE; + if(isset($_POST['auto_network_hook'])){ + $this->optional['auto_network_hook'] = get_post('auto_network_hook'); + } + }else{ + $this->optional['auto_network_hook_active'] = FALSE; + } + + if(isset($_POST['notifydir_active'])){ + $this->optional['notifydir_active'] = TRUE; + if(isset($_POST['notifydir'])){ + $this->optional['notifydir'] = get_post('notifydir'); + } + }else{ + $this->optional['notifydir_active'] = FALSE; + } + + if(isset($_POST['uniq_identifier_active'])){ + $this->optional['uniq_identifier_active'] = TRUE; + if(isset($_POST['uniq_identifier'])){ + $this->optional['uniq_identifier'] = get_post('uniq_identifier'); + } + }else{ + $this->optional['uniq_identifier_active'] = FALSE; + } + } + + $tmp = $this->check(); + if(count($tmp) == 0){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + } + + + function check() + { + $message = array(); + + if(!is_numeric( $this->optional['session_lifetime'])){ + $message[] = _("Session lifetime must be a numeric value."); + } + + if(!is_numeric( $this->optional['max_ldap_query_time'])){ + $message[] = _("Maximal ldap query time must be a numeric value. "); + } + + return($message); + } + + + /* Attributes that are interesting for configuration generation */ + function get_attributes() + { + $tmp = setup_step::get_attributes(); + foreach(array("optional") as $attr){ + $tmp[$attr]= $this->$attr; + } + return($tmp); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Feedback.inc b/gosa-core/setup/class_setupStep_Feedback.inc new file mode 100644 index 000000000..fbcfb4c97 --- /dev/null +++ b/gosa-core/setup/class_setupStep_Feedback.inc @@ -0,0 +1,274 @@ +is_enabled = TRUE; + $this->is_active = TRUE; + $this->update_strings(); + } + + + function init() + { + $cv = $this->parent->captured_values; + + /* Initialize values */ + $this->use_since = date("Y"); + $this->organization = preg_replace("/^[^=]*+=(.*),.*$/","\\1",$cv['base']); + $this->distribution = ""; + $this->web_server = $_SERVER['SERVER_SOFTWARE']; + $this->php_version = PHP_VERSION; + + /* On first call check for rid/sid base */ + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + $ldap->cd($cv['base']); + $ldap->search("(objectClass=*)",array("dn")); + $this->object_count=$ldap->count(); + + /* Preselect used features */ + $oc = $ldap->get_objectclasses(); + $this->features_used = array(); + $this->features_used['posix'] = array("USED" => isset($oc['posixAccount']) , + "NAME" => _("UNIX accounts/groups")); + $this->features_used['samba'] = array("USED" => isset($oc['sambaSamAccount']) || isset($oc['sambaAccount']) , + "NAME" => _("Samba management")); + $this->features_used['mail'] = array("USED" => $cv['mail'] != "none", + "NAME" => _("Mailsystem management")); + $this->features_used['fax'] = array("USED" => isset($oc['goFaxAccount']) , + "NAME" => _("FAX system administration")); + $this->features_used['asterisk'] = array("USED" => isset($oc['goFonAccount']), + "NAME" => _("Asterisk administration")); + $this->features_used['inventory'] = array("USED" => isset($oc['glpiAccount']) , + "NAME" => _("System inventory")); + $this->features_used['system'] = array("USED" => FALSE , + "NAME" => _("System-/Configmanagement")); + $this->features_used['addressbook'] = array("USED" => FALSE , + "NAME" => _("Addressbook")); + } + + + function update_strings() + { + $this->s_title = _("Notification and feedback"); + $this->s_info = _("Get notifications or send feedback"); + $this->s_title_long = _("Notification and feedback"); + } + + + function execute() + { + if(!$this->initialized){ + $this->initialized = TRUE; + $this->init(); + } + + $additional_info =""; + + if(isset($_POST['send_feedback'])){ + + $msgs = $this->check_feedback(); + if(count($msgs)){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $str = $this->create_serialise_data_string(); + $feedback_url = $this->feedback_url."?data=".base64_encode($str); + + $ret = @fopen($feedback_url,"r"); + + if(!$ret){ + print_red(sprintf(_("Could not connect to feedback server (%s). There is possibly no connection to the internet."),$this->feedback_url)); + }else{ + $ret_value=""; + while($ret && !feof($ret)){ + $ret_value.= fgets($ret,256); + } + if(!preg_match("/successful/i",$ret_value)){ + print_red(_("Error while sending your feedback. The service is possible temporary unavailable")); + }else{ + $additional_info = ""._("Feedback sucessfully send").""; + } + } + @fclose($ret); + } + } + + $years = array(); + for($i = date("Y") ; $i >= 2001; $i--){ + $years[$i] = $i; + } + + $this->is_completed=TRUE; + $smarty = get_smarty(); + + foreach($this->attributes as $attr){ + $smarty->assign($attr, $this->$attr); + } + $smarty->assign("years",$years); + $smarty->assign("features_used",$this->features_used); + $smarty->assign("additional_info",$additional_info); + $smarty->assign ("must", "*"); + return($smarty->fetch(get_template_path("setup_feedback.tpl",TRUE,dirname(__FILE__)))); + } + + + function check_feedback() + { + $msgs = array(); + if(!is_email($this->eMail) || empty($this->eMail)){ + $msgs[] = _("Please specify a valid email address."); + } + + if(!$this->subscribe && !$this->use_gosa_announce){ + $msgs[] = _("You should have enabled at least one option, to subscribe or send your feedback."); + } + + return($msgs); + } + + + function save_object() + { + if(isset($_POST['step_feedback'])){ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = get_post($attr); + } + } + + if(isset($_POST['subscribe'])){ + $this->subscribe = TRUE; + }else{ + $this->subscribe = FALSE; + } + + if(isset($_POST['use_gosa_announce'])){ + $this->use_gosa_announce = TRUE; + }else{ + $this->use_gosa_announce = FALSE; + } + + foreach($this->features_used as $key => $data){ + if(isset($_POST['feature_'.$key])){ + $this->features_used[$key]['USED'] = TRUE; + }else{ + $this->features_used[$key]['USED'] = FALSE; + } + } + } + } + + + function create_serialise_data_string() + { + $str = "#FEEDBACK ".date("H:i:s d:m:Y"); + if($this->subscribe){ + + $str.= "\n\nSubscribe"; + $str .= "\nOrganization: ".$this->organization; + $str .= "\nName: ".$this->name; + $str .= "\neMail: ".$this->eMail; + } + + if($this->use_gosa_announce){ + + $str.= "\n\nFeedback"; + + if($this->get_started) { + $str .= "\nGet started: TRUE"; + }else{ + $str .= "\nGet started: FALSE"; + } + $str .= "\nProblems : ".($this->problems_encountered); + + if($this->first_use){ + $str .= "\nFirst use: TRUE"; + }else{ + $str .= "\nFirst use: FALSE"; + } + $str .= "\nUsing GOsa since: ".$this->use_since; + + $str .="\nDistribution: ".$this->distribution; + $str .="\nWeb Server: ".$this->web_server; + $str .="\nPHP_Version: ".$this->php_version; + $str .="\nLDAP Server: ".$this->ldap_server; + $str .="\nObject count: ".$this->object_count; + $str .="\nMissing features: ".($this->want_to_see_next); + } + + $str .= "\n\nFeatures used"; + foreach($this->features_used as $name => $data){ + $str.="\n".$name.": "; + if($data['USED']){ + $str .= "TRUE"; + }else{ + $str .= "FALSE"; + } + } + + return($str); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Finish.inc b/gosa-core/setup/class_setupStep_Finish.inc new file mode 100644 index 000000000..3898c55c5 --- /dev/null +++ b/gosa-core/setup/class_setupStep_Finish.inc @@ -0,0 +1,143 @@ +update_strings(); + } + + + function update_strings() + { + $this->s_title = _("Finish"); + $this->s_info = _("Write configuration file"); + $this->s_title_long = _("Finish - write the configuration file"); + } + + + function get_conf_data() + { + $smarty = get_smarty(); + $smarty->assign("cv",$this->parent->captured_values); + $str = $smarty->fetch(CONFIG_TEMPLATE_DIR.$this->gosa_conf_contrib); + return($str); + } + + + function execute() + { + + $info= posix_getgrgid(posix_getgid()); + $webgroup = $info['name']; + + + /* Check if there is currently an active gosa.conf + */ + $exists = file_exists(CONFIG_DIR."/".CONFIG_FILE); + + /* Redirect to GOsa login, if : + * - gosa.conf exists + * - Permisssion are set correctly + */ + if(isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){ + session_destroy(); + header("Location: index.php"); + exit(); + } + + /* Downlaod config */ + if(isset($_POST['getconf'])){ + + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + header("Cache-Control: no-cache"); + header("Pragma: no-cache"); + header("Cache-Control: post-check=0, pre-check=0"); + header("Content-type: text/plain"); + + if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) || + preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){ + header('Content-Disposition: filename="'.CONFIG_FILE.'"'); + } else { + header('Content-Disposition: attachment; filename="'.CONFIG_FILE.'"'); + } + + $str = $this->get_conf_data(); + $str = preg_replace("/\n[ ]*\n/","",$str); + + echo $this->get_conf_data(); + exit(); + } + + $err_msg= ""; + + if($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){ + $err_msg = _("Your configuration file is currently world readable. Please updated the file permissions!"); + }elseif(!$exists){ + $err_msg = _("The configuration is currently not readable or it does not exists."); + } + + $smarty = get_smarty(); + $smarty->assign("err_msg",$err_msg); + $smarty->assign("webgroup", $webgroup); + $smarty->assign("CONFIG_DIR",CONFIG_DIR); + $smarty->assign("CONFIG_FILE" , CONFIG_FILE); + + $smarty->assign("msg2", sprintf(_("After downloading and placing the file under %s, please make sure that the user the webserver is running with is able to read %s, while other users shouldn't. You may want to execute these commands to achieve this requirement:"),CONFIG_DIR,CONFIG_FILE)); + + $smarty->assign("cv",$this->parent->captured_values); + return($smarty -> fetch (get_template_path("../setup/setup_finish.tpl"))); + } + + + /* check if given file is world readable */ + function is_world_readable($file) + { + clearstatcache(); + $p = fileperms($file); + $w_r = (decbin($p & 4) == TRUE); + return($w_r); + } + + + function save_object() + { + if(isset($_POST['step8_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate($_POST[$attr]); + } + } + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Language.inc b/gosa-core/setup/class_setupStep_Language.inc new file mode 100644 index 000000000..e1b5e72ab --- /dev/null +++ b/gosa-core/setup/class_setupStep_Language.inc @@ -0,0 +1,72 @@ +lang = get_browser_language(); + $this->lang_selected = ""; + $this->update_strings(); + } + + function update_strings() + { + $this->s_title = _("Language setup"); + $this->s_title_long = _("Language setup"); + $this->s_info = _("This step allows you to select your preferred language."); + } + + function execute() + { + $this->languages = array_merge(array("" => _("Automatic")),get_languages(TRUE)); + asort($this->languages); + $smarty = get_smarty(); + $smarty->assign("languages", $this->languages); + $smarty->assign("lang", $this->lang); + $smarty->assign("lang_selected",$this->lang_selected); + return($smarty->fetch(get_template_path("setup_language.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + if((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) { + $this->lang_selected = $_POST['lang_selected']; + $this->is_completed = TRUE; + + if($this->lang_selected != ""){ + $_SESSION['lang'] = $this->lang_selected; + }else{ + $_SESSION['lang'] = $this->lang; + } + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Ldap.inc b/gosa-core/setup/class_setupStep_Ldap.inc new file mode 100644 index 000000000..9b5f670ea --- /dev/null +++ b/gosa-core/setup/class_setupStep_Ldap.inc @@ -0,0 +1,208 @@ +update_strings(); + } + + + function update_strings() + { + $this->s_title = _("LDAP setup"); + $this->s_title_long = _("LDAP connection setup"); + $this->s_info = _("This dialog performs the basic configuration of the LDAP connectivity for GOsa."); + } + + + function execute() + { + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign connection status */ + $smarty->assign("connection_status",$this->get_connection_status()); + + /* Handle namingContext detection */ + $attr = @LDAP::get_naming_contexts($this->connection); + unset($attr['count']); + $smarty->assign("namingContexts",$attr); + $smarty->assign("namingContextsCount",count($attr)); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + + /* Addign resolved users */ + $smarty->assign("resolve_user",$this->resolve_user); + if($this->resolve_user){ + $tmp = $this->resolve_user(); + $smarty->assign("resolved_users",$tmp); + $smarty->assign("resolved_users_count",count($tmp)); + $smarty->assign("resolve_filter",$this->resolve_filter); + } + + $base_to_append = $this->base; + if(strlen($base_to_append) > 20){ + $base_to_append = substr($base_to_append,0,17)."..."; + } + $smarty->assign("base_to_append",$base_to_append); + return($smarty -> fetch (get_template_path("../setup/setup_ldap.tpl"))); + } + + function get_connection_status() + { + $this->connect_id = FALSE; + $this->bind_id = FALSE; + + @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); + $this->connect_id = @ldap_connect($this->connection); + + @ldap_set_option($this->connect_id, LDAP_OPT_PROTOCOL_VERSION, 3); + $this->bind_id = @ldap_bind($this->connect_id, $this->admin, $this->password); + + if(!$this->bind_id){ + $str = sprintf(_("Anonymous bind failed on server '%s'."),$this->connection); + if(!empty($this->admin)){ + $str = sprintf(_("Bind as user '%s' failed on server '%s'."),$this->admin,$this->connection); + } + return("".$str.""); + }else{ + if(empty($this->admin)){ + $str = sprintf(_("Anonymous bind on server '%s' succeeded."), $this->connection); + return("".$str." "._("Please specify user and password.").""); + }else{ + $str = sprintf(_("Bind as user '%s' on server '%s' succeeded."),$this->admin,$this->connection); + return("".$str.""); + } + } + } + + + function resolve_user() + { + $filter = $this->resolve_filter; + $ldap = new LDAP("","",$this->connection); + $ldap->cd($this->base); + $ldap->search("(&(objectClass=person)(|(uid=".$filter.")(cn=".$filter.")))"); + $tmp = array(); + while($attrs = $ldap->fetch()){ + $tmp[base64_encode($attrs['dn'])]= @LDAP::fix($attrs['dn']); + natcasesort($tmp); + } + return($tmp); + } + + + function save_object() + { + $reset = FALSE; + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + if(in_array($attr,array("base","connection")) && $this->$attr != get_post($attr)){ + $reset = TRUE; + } + $this->$attr = get_post($attr); + } + } + + if($reset){ + $this->parent->disable_steps_from(($this->parent->step_name_to_id(get_class($this))) +1); + $attr = @LDAP::get_naming_contexts($this->connection); + if(is_array($attr) && !in_array(get_post("base"),$attr)){ + if(isset($attr[0])){ + $this->base = $attr[0]; + } + } + } + + if(isset($_POST['resolve_user_x'])){ + $this->resolve_user = !$this->resolve_user; + } + if(isset($_POST['resolve_user'])){ + $this->resolve_user = !$this->resolve_user; + } + + /* Hide backward forward button*/ + $this->dialog = $this->resolve_user; + + if(isset($_POST['resolve_filter'])){ + $this->resolve_filter = get_post('resolve_filter'); + } + + if(isset($_POST['use_selected_user'])){ + + if(isset($_POST['admin_to_use'])){ + $this->admin = base64_decode(get_post('admin_to_use')); + $this->resolve_user = false; + } + } + + if(isset($_POST['append_base_to_admin_dn'])){ + $this->append_base_to_admin_dn = TRUE; + }else{ + $this->append_base_to_admin_dn = FALSE; + } + + if($this->append_base_to_admin_dn){ + $base = $this->base; + if(!preg_match("/,$/",$this->admin_given)){ + $base = ",".$base; + } + $this->admin = $this->admin_given.$base; + }else{ + $this->admin = $this->admin_given; + } + + $this->get_connection_status(); + if($this->bind_id && !empty($this->admin) && !empty($this->base)){ + $this->is_completed =TRUE; + }else{ + $this->is_completed =FALSE; + } + + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_License.inc b/gosa-core/setup/class_setupStep_License.inc new file mode 100644 index 000000000..d46768ca6 --- /dev/null +++ b/gosa-core/setup/class_setupStep_License.inc @@ -0,0 +1,94 @@ +update_strings(); + } + + + function load_license() + { + if(!file_exists("../setup/license.txt")){ + $this->License = "License not found. Setup stops here."; + $this->license_found = false; + }else{ + $fp = fopen("../setup/license.txt","r"); + $this->License = ""; + while (!feof($fp)){ + $this->License .= fread($fp, 255); + } + $this->license_found = true; + } + } + + + function update_strings() + { + $this->s_title = _("License"); + $this->s_title_long = _("License"); + $this->s_info = _("Terms and conditions for usage"); + } + + + function execute() + { + $this->load_license(); + + $smarty = get_smarty(); + $smarty -> assign("License",nl2br($this->License)); + $smarty -> assign("license_found",$this->license_found); + $smarty -> assign("accepted",$this->accepted); + + return($smarty -> fetch (get_template_path("../setup/setup_license.tpl"))); + } + + + function save_object() + { + if(isset($_POST['step_license'])){ + if(isset($_POST['accepted'])){ + $this->accepted = TRUE; + }else{ + $this->accepted = FALSE; + } + } + + if($this->license_found && $this->accepted){ + $this->is_completed = true; + }else{ + $this->is_completed = false; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Migrate.inc b/gosa-core/setup/class_setupStep_Migrate.inc new file mode 100644 index 000000000..5dcd8e649 --- /dev/null +++ b/gosa-core/setup/class_setupStep_Migrate.inc @@ -0,0 +1,1946 @@ +update_strings(); + } + + function update_strings() + { + $this->s_title = _("LDAP inspection"); + $this->s_title_long = _("LDAP inspection"); + $this->s_info = _("Analyze your current LDAP for GOsa compatibility"); + } + + function initialize_checks() + { + $this->checks = array(); + $this->checks['root']['TITLE'] = _("Checking for root object"); + $this->checks['root']['STATUS'] = FALSE; + $this->checks['root']['STATUS_MSG']= ""; + $this->checks['root']['ERROR_MSG'] = ""; + $this->checkBase(); + + $this->checks['permissions']['TITLE'] = _("Checking permissions on LDAP database"); + $this->checks['permissions']['STATUS'] = FALSE; + $this->checks['permissions']['STATUS_MSG']= ""; + $this->checks['permissions']['ERROR_MSG'] = ""; + $this->check_ldap_permissions(); + + $this->checks['deps_visible']['TITLE'] = _("Checking for invisible deparmtments"); + $this->checks['deps_visible']['STATUS'] = FALSE; + $this->checks['deps_visible']['STATUS_MSG']= ""; + $this->checks['deps_visible']['ERROR_MSG'] = ""; + $this->check_organizationalUnits(); + + $this->checks['users_visible']['TITLE'] = _("Checking for invisible users"); + $this->checks['users_visible']['STATUS'] = FALSE; + $this->checks['users_visible']['STATUS_MSG']= ""; + $this->checks['users_visible']['ERROR_MSG'] = ""; + $this->check_gosaAccounts(); + + $this->checks['acls']['TITLE'] = _("Checking for super administrator"); + $this->checks['acls']['STATUS'] = FALSE; + $this->checks['acls']['STATUS_MSG']= ""; + $this->checks['acls']['ERROR_MSG'] = ""; + $this->check_administrativeAccount(); + + $this->checks['outside_users']['TITLE'] = _("Checking for users outside the people tree"); + $this->checks['outside_users']['STATUS'] = FALSE; + $this->checks['outside_users']['STATUS_MSG']= ""; + $this->checks['outside_users']['ERROR_MSG'] = ""; + $this->search_outside_users(); + + $this->checks['outside_groups']['TITLE'] = _("Checking for groups outside the groups tree"); + $this->checks['outside_groups']['STATUS'] = FALSE; + $this->checks['outside_groups']['STATUS_MSG']= ""; + $this->checks['outside_groups']['ERROR_MSG'] = ""; + $this->search_outside_groups(); + + $this->checks['outside_winstations']['TITLE'] = _("Checking for windows workstations outside the winstation tree"); + $this->checks['outside_winstations']['STATUS'] = FALSE; + $this->checks['outside_winstations']['STATUS_MSG']= ""; + $this->checks['outside_winstations']['ERROR_MSG'] = ""; + $this->search_outside_winstations(); + + $this->checks['uidNumber_usage']['TITLE'] = _("Checking for duplicate uid numbers"); + $this->checks['uidNumber_usage']['STATUS'] = FALSE; + $this->checks['uidNumber_usage']['STATUS_MSG']= ""; + $this->checks['uidNumber_usage']['ERROR_MSG'] = ""; + $this->check_uidNumber(); + + $this->checks['gidNumber_usage']['TITLE'] = _("Checking for duplicate gid numbers"); + $this->checks['gidNumber_usage']['STATUS'] = FALSE; + $this->checks['gidNumber_usage']['STATUS_MSG']= ""; + $this->checks['gidNumber_usage']['ERROR_MSG'] = ""; + $this->check_gidNumber(); + } + + + /* Check if there are uidNumbers which are used more than once. + */ + function check_uidNumber() + { + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + $res = $ldap->search("uidNumber=*",array("dn","uidNumber")); + if(!$res){ + $this->checks['uidNumber_usage']['STATUS'] = FALSE; + $this->checks['uidNumber_usage']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['uidNumber_usage']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + return(false); + } + + $this->check_uidNumbers= array(); + $tmp = array(); + while($attrs = $ldap->fetch()){ + $tmp[$attrs['uidNumber'][0]][] = $attrs; + } + + foreach($tmp as $id => $entries){ + if(count($entries) > 1){ + foreach($entries as $entry){ + $this->check_uidNumbers[base64_encode($entry['dn'])] = $entry; + } + } + } + + if($this->check_uidNumbers){ + $this->checks['uidNumber_usage']['STATUS'] = FALSE; + $this->checks['uidNumber_usage']['STATUS_MSG']= ""._("Warning").""; + $this->checks['uidNumber_usage']['ERROR_MSG'] = + sprintf(_("Found %s duplicate values for attribute 'uidNumber'."),count($this->check_uidNumbers)); + return(false); + }else{ + $this->checks['uidNumber_usage']['STATUS'] = TRUE; + $this->checks['uidNumber_usage']['STATUS_MSG']= _("Ok"); + $this->checks['uidNumber_usage']['ERROR_MSG'] = ""; + return(TRUE); + } + } + + + /* Check if there are duplicated gidNumbers present in ldap + */ + function check_gidNumber() + { + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + $res = $ldap->search("(&(objectClass=posixGroup)(gidNumber=*))",array("dn","gidNumber")); + if(!$res){ + $this->checks['gidNumber_usage']['STATUS'] = FALSE; + $this->checks['gidNumber_usage']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['gidNumber_usage']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + return(false); + } + + $this->check_gidNumbers= array(); + $tmp = array(); + while($attrs = $ldap->fetch()){ + $tmp[$attrs['gidNumber'][0]][] = $attrs; + } + + foreach($tmp as $id => $entries){ + if(count($entries) > 1){ + foreach($entries as $entry){ + $this->check_gidNumbers[base64_encode($entry['dn'])] = $entry; + } + } + } + + if($this->check_gidNumbers){ + $this->checks['gidNumber_usage']['STATUS'] = FALSE; + $this->checks['gidNumber_usage']['STATUS_MSG']= ""._("Warning").""; + $this->checks['gidNumber_usage']['ERROR_MSG'] = + sprintf(_("Found %s duplicate values for attribute 'gidNumber'."),count($this->check_gidNumbers)); + return(false); + }else{ + $this->checks['gidNumber_usage']['STATUS'] = TRUE; + $this->checks['gidNumber_usage']['STATUS_MSG']= _("Ok"); + $this->checks['gidNumber_usage']['ERROR_MSG'] = ""; + return(TRUE); + } + } + + + /* Search for winstations outside the winstation ou + */ + function search_outside_winstations() + { + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Get winstation ou */ + if($cv['generic_settings']['wws_ou_active']) { + $winstation_ou = $cv['generic_settings']['ws_ou']; + }else{ + $winstation_ou = "ou=winstations"; + } + + if($cv['samba_version'] == 3){ + $oc = "sambaSamAccount"; + }else{ + $oc = "sambaAccount"; + } + + $ldap->cd($cv['base']); + $res = $ldap->search("(&(objectClass=".$oc.")(uid=*$))",array("dn","sambaSID")); + if(!$res){ + $this->checks['outside_winstations']['STATUS'] = FALSE; + $this->checks['outside_winstations']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['outside_winstations']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + return(false); + } + + $this->outside_winstations = array(); + while($attrs = $ldap->fetch()){ + if((!preg_match("/^[^,]+,".normalizePreg($winstation_ou)."/",$attrs['dn'])) && !preg_match("/,dc=addressbook,/",$attrs['dn'])){ + $attrs['selected'] = FALSE; + $attrs['ldif'] = ""; + $this->outside_winstations[base64_encode($attrs['dn'])] = $attrs; + } + } + + if(count($this->outside_winstations)){ + $this->checks['outside_winstations']['STATUS'] = FALSE; + $this->checks['outside_winstations']['STATUS_MSG']= _("Failed"); + $this->checks['outside_winstations']['ERROR_MSG'] = + sprintf(_("Found %s winstations outside the predefined winstation department ou '%s'."),count($this->outside_winstations),$winstation_ou); + $this->checks['outside_winstations']['ERROR_MSG'].= ""; + return(false); + }else{ + $this->checks['outside_winstations']['STATUS'] = TRUE; + $this->checks['outside_winstations']['STATUS_MSG']= _("Ok"); + $this->checks['outside_winstations']['ERROR_MSG'] = ""; + return(TRUE); + } + } + + + /* Search for groups outside the group ou + */ + function search_outside_groups() + { + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $group_ou = $cv['groupou']; + $ldap->cd($cv['base']); + + /*********** + * Get all gosaDepartments to be able to + * validate correct ldap tree position of every single user + ***********/ + $valid_deps = array(); + $valid_deps['/'] = $cv['base']; + $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn","ou")); + while($attrs = $ldap->fetch()){ + $valid_deps[] = $attrs['dn']; + } + + /*********** + * Get all groups + ***********/ + $res = $ldap->search("(objectClass=posixGroup)",array("dn")); + if(!$res){ + $this->checks['outside_groups']['STATUS'] = FALSE; + $this->checks['outside_groups']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['outside_groups']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + return(false); + } + + $this->outside_groups = array(); + while($attrs = $ldap->fetch()){ + $group_db_base = preg_replace("/^[^,]+,".normalizePreg($group_ou)."+,/i","",$attrs['dn']); + + /* Check if entry is not an addressbook only user + * and verify that he is in a valid department + */ + if( !preg_match("/".normalizePreg("dc=addressbook,")."/",$group_db_base) && + !in_array($group_db_base,$valid_deps) + ){ + $attrs['selected'] = FALSE; + $attrs['ldif'] = ""; + $this->outside_groups[base64_encode($attrs['dn'])] = $attrs; + } + } + + if(count($this->outside_groups)){ + $this->checks['outside_groups']['STATUS'] = FALSE; + $this->checks['outside_groups']['STATUS_MSG']= ""._("Warning").""; + $this->checks['outside_groups']['ERROR_MSG'] = + sprintf(_("Found %s groups outside the configured tree '%s'."),count($this->outside_groups),$group_ou); + $this->checks['outside_groups']['ERROR_MSG'].= " "; + return(false); + }else{ + $this->checks['outside_groups']['STATUS'] = TRUE; + $this->checks['outside_groups']['STATUS_MSG']= _("Ok"); + $this->checks['outside_groups']['ERROR_MSG'] = ""; + return(TRUE); + } + } + + /* Search for users outside the people ou + */ + function search_outside_users() + { + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + + + /*********** + * Get all gosaDepartments to be able to + * validate correct ldap tree position of every single user + ***********/ + $valid_deps = array(); + $valid_deps['/'] = $cv['base']; + $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn","ou")); + while($attrs = $ldap->fetch()){ + $valid_deps[] = $attrs['dn']; + } + + /*********** + * Search for all users + ***********/ + $res = $ldap->search("(&(objectClass=gosaAccount)(!(uid=*$)))",array("dn")); + if(!$res){ + $this->checks['outside_users']['STATUS'] = FALSE; + $this->checks['outside_users']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['outside_users']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + return(false); + } + + /*********** + * Check if returned users are within a valid GOsa deparmtment. (peopleou,gosaDepartment,base) + ***********/ + $this->outside_users = array(); + $people_ou = trim($cv['peopleou']); + if(!empty($people_ou)){ + $people_ou = $people_ou.","; + } + + while($attrs = $ldap->fetch()){ + $people_db_base = preg_replace("/^[^,]+,".normalizePreg($people_ou)."/i","",$attrs['dn']); + + /* Check if entry is not an addressbook only user + * and verify that he is in a valid department + */ + if( !preg_match("/".normalizePreg("dc=addressbook,")."/",$people_db_base) && + !in_array($people_db_base,$valid_deps) + ){ + $attrs['selected'] = FALSE; + $attrs['ldif'] = ""; + $this->outside_users[base64_encode($attrs['dn'])] = $attrs; + } + } + + if(count($this->outside_users)){ + $this->checks['outside_users']['STATUS'] = FALSE; + $this->checks['outside_users']['STATUS_MSG']= ""._("Warning").""; + $this->checks['outside_users']['ERROR_MSG'] = + sprintf(_("Found %s user(s) outside the configured tree '%s'."),count($this->outside_users),$people_ou); + $this->checks['outside_users']['ERROR_MSG'].= ""; + return(false); + }else{ + $this->checks['outside_users']['STATUS'] = TRUE; + $this->checks['outside_users']['STATUS_MSG']= _("Ok"); + $this->checks['outside_users']['ERROR_MSG'] = ""; + return(TRUE); + } + } + + + /* Check ldap accessibility + * Create and remove a dummy object, + * to ensure that we have the necessary permissions + */ + function check_ldap_permissions() + { + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Create dummy entry + */ + $name = "GOsa_setup_text_entry_".session_id().rand(0,999999); + $dn = "ou=".$name.",".$cv['base']; + $testEntry= array(); + $testEntry['objectClass'][]= "top"; + $testEntry['objectClass'][]= "organizationalUnit"; + $testEntry['objectClass'][]= "gosaDepartment"; + $testEntry['description']= "Created by GOsa setup, this object can be removed."; + $testEntry['ou'] = $name; + + /* check if simple ldap cat will be successful + */ + $res = $ldap->cat($cv['base']); + if(!$res){ + $this->checks['permissions']['STATUS'] = FALSE; + $this->checks['permissions']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['permissions']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + return(false); + } + + /* Try to create dummy object + */ + $ldap->cd ($dn); + $ldap->create_missing_trees($dn); + $res = $ldap->add($testEntry); + $ldap->cat($dn); + if(!$ldap->count()){ + new log("view","setup/".get_class($this),$dn,array(),$ldap->get_error()); + + $this->checks['permissions']['STATUS'] = FALSE; + $this->checks['permissions']['STATUS_MSG']= _("Failed"); + $this->checks['permissions']['ERROR_MSG'] = + sprintf(_("The specified user '%s' does not have full access to your ldap database."),$cv['admin']); + return(false); + } + + /* Try to remove created entry + */ + $res = $ldap->rmDir($dn); + $ldap->cat($dn); + if($ldap->count()){ + new log("view","setup/".get_class($this),$dn,array(),$ldap->get_error()); + $this->checks['permissions']['STATUS'] = FALSE; + $this->checks['permissions']['STATUS_MSG']= _("Failed"); + $this->checks['permissions']['ERROR_MSG'] = + sprintf(_("The specified user '%s' does not have full access to your ldap database."),$cv['admin']); + return(false); + } + + /* Create & remove of dummy object was successful */ + $this->checks['permissions']['STATUS'] = TRUE; + $this->checks['permissions']['STATUS_MSG']= _("Ok"); + $this->checks['permissions']['ERROR_MSG'] = ""; + return(true); + } + + + /* Check if there are users which will + * be invisible for GOsa + */ + function check_gosaAccounts() + { + /* Remember old list of ivisible users, to be able to set + * the 'html checked' status for the checkboxes again + */ + $cnt_ok = 0; + $old = $this->users_to_migrate; + $this->users_to_migrate = array(); + + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Get all invisible users + */ + $ldap->cd($cv['base']); + $res =$ldap->search("(&(|(objectClass=posixAccount)(&(objectClass=inetOrgPerson)(objectClass=organizationalPerson)))(!(objectClass=gosaAccount))(uid=*))",array("sn","givenName","cn","uid")); + while($attrs = $ldap->fetch()){ + if(!preg_match("/,dc=addressbook,/",$attrs['dn'])){ + $attrs['checked'] = FALSE; + $attrs['before'] = ""; + $attrs['after'] = ""; + + /* Set objects to selected, that were selected before reload */ + if(isset($old[base64_encode($attrs['dn'])])){ + $attrs['checked'] = $old[base64_encode($attrs['dn'])]['checked']; + } + $this->users_to_migrate[base64_encode($attrs['dn'])] = $attrs; + } + } + + /* No invisible */ + if(!$res){ + $this->checks['users_visible']['STATUS'] = FALSE; + $this->checks['users_visible']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['users_visible']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + }elseif(count($this->users_to_migrate) == 0){ + $this->checks['users_visible']['STATUS'] = TRUE; + $this->checks['users_visible']['STATUS_MSG']= _("Ok"); + $this->checks['users_visible']['ERROR_MSG'] = ""; + }else{ + $this->checks['users_visible']['STATUS'] = FALSE; + $this->checks['users_visible']['STATUS_MSG']= ""._("Warning").""; + $this->checks['users_visible']['ERROR_MSG'] = sprintf(_("Found %s user(s) that will not be visible in GOsa."), + count($this->users_to_migrate)); + $this->checks['users_visible']['ERROR_MSG'] .= ""; + } + } + + + /* Start user account migration + */ + function migrate_gosaAccounts($only_ldif = FALSE) + { + $this->show_details= $only_ldif; + + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Add gosaAccount objectClass to the selected users + */ + foreach($this->users_to_migrate as $key => $dep){ + if($dep['checked']){ + + /* Get old objectClasses */ + $ldap->cat($dep['dn'],array("objectClass")); + $attrs = $ldap->fetch(); + + /* Create new objectClass array */ + $new_attrs = array(); + $new_attrs['objectClass']= array("gosaAccount","inetOrgPerson","organizationalPerson"); + for($i = 0 ; $i < $attrs['objectClass']['count']; $i ++ ){ + if(!in_array_ics($attrs['objectClass'][$i], $new_attrs['objectClass'])){ + $new_attrs['objectClass'][] = $attrs['objectClass'][$i]; + } + } + + /* Set info attributes for current object, + * or write changes to the ldap database + */ + if($only_ldif){ + $this->users_to_migrate[$key]['before'] = $this->array_to_ldif($attrs); + $this->users_to_migrate[$key]['after'] = $this->array_to_ldif($new_attrs); + }else{ + $ldap->cd($attrs['dn']); + if(!$ldap->modify($new_attrs)){ + print_red(sprintf(_("Failed to migrate the department '%s' into GOsa, error message is as follows '%s'."),$attrs['dn'],$ldap->get_error())); + return(false); + } + } + } + } + return(TRUE); + } + + + /* Check if there are invisible organizational Units + */ + function check_organizationalUnits() + { + $cnt_ok = 0; + $old = $this->deps_to_migrate; + $this->deps_to_migrate = array(); + + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Skip GOsa internal departments */ + $skip_dns = array("/".$cv['peopleou']."/","/".$cv['groupou']."/","/^ou=people,/","/^ou=groups,/", + "/(,|)ou=configs,/","/(,|)ou=systems,/", + "/(,|)ou=apps,/","/(,|)ou=mime,/","/(,|)ou=devices/","/^ou=aclroles,/","/^ou=incoming,/", + "/ou=snapshots,/","/(,|)dc=addressbook,/","/^(,|)ou=machineaccounts,/", + "/(,|)ou=winstations,/"); + + /* Get all invisible departments */ + $ldap->cd($cv['base']); + $res = $ldap->search("(&(objectClass=organizationalUnit)(!(objectClass=gosaDepartment)))",array("ou","description","dn")); + while($attrs = $ldap->fetch()){ + $attrs['checked'] = FALSE; + $attrs['before'] = ""; + $attrs['after'] = ""; + + /* Set objects to selected, that were selected before reload */ + if(isset($old[base64_encode($attrs['dn'])])){ + $attrs['checked'] = $old[base64_encode($attrs['dn'])]['checked']; + } + $this->deps_to_migrate[base64_encode($attrs['dn'])] = $attrs; + } + + /* Filter returned list of departments and ensure that + * GOsa internal departments will not be listed + */ + foreach($this->deps_to_migrate as $key => $attrs){ + $dn = $attrs['dn']; + $skip = false;; + foreach($skip_dns as $skip_dn){ + if(preg_match($skip_dn,$dn)){ + $skip = true; + } + } + if($skip){ + unset($this->deps_to_migrate[$key]); + } + } + + /* If we have no invisible departments found + * tell the user that everything is ok + */ + if(!$res){ + $this->checks['deps_visible']['STATUS'] = FALSE; + $this->checks['deps_visible']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['deps_visible']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + }elseif(count($this->deps_to_migrate) == 0 ){ + $this->checks['deps_visible']['STATUS'] = TRUE; + $this->checks['deps_visible']['STATUS_MSG']= _("Ok"); + $this->checks['deps_visible']['ERROR_MSG'] = ""; + }else{ + $this->checks['deps_visible']['STATUS'] = TRUE; + $this->checks['deps_visible']['STATUS_MSG']= ''._("Warning").''; + $this->checks['deps_visible']['ERROR_MSG'] = sprintf(_("Found %s department(s) that will not be visible in GOsa."),count($this->deps_to_migrate)); + $this->checks['deps_visible']['ERROR_MSG'] .= " "; + } + } + + + + /* Start deparmtment migration */ + function migrate_organizationalUnits($only_ldif = FALSE) + { + $this->show_details= $only_ldif; + + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Add gosaDepartment objectClass to each selected entry + */ + foreach($this->deps_to_migrate as $key => $dep){ + if($dep['checked']){ + + /* Get current objectClasses */ + $ldap->cat($dep['dn'],array("objectClass","description")); + $attrs = $ldap->fetch(); + + /* Create new objectClass attribute including gosaDepartment*/ + $new_attrs = array(); + for($i = 0 ; $i < $attrs['objectClass']['count']; $i ++ ){ + $new_attrs['objectClass'][] = $attrs['objectClass'][$i]; + } + $new_attrs['objectClass'][] = "gosaDepartment"; + + /* Append description it is missing */ + if(!isset($attrs['description'])){ + $new_attrs['description'][] = "GOsa department"; + } + + /* Depending on the parameter >only_diff< we save the changes as ldif + * or we write our changes directly to the ldap database + */ + if($only_ldif){ + $this->deps_to_migrate[$key]['before'] = $this->array_to_ldif($attrs); + $this->deps_to_migrate[$key]['after'] = $this->array_to_ldif($new_attrs); + }else{ + $ldap->cd($attrs['dn']); + if(!$ldap->modify($new_attrs)){ + print_red(sprintf(_("Failed to migrate the department '%s' into GOsa, error message is as follows '%s'."),$attrs['dn'],$ldap->get_error())); + return(false); + } + } + } + } + return(TRUE); + } + + + /* Check Acls if there is at least one object with acls defined + */ + function check_administrativeAccount() + { + /* Establish ldap connection */ + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Search for gosaAcls */ + $ldap->cd($cv['base']); + $res = $ldap->cat($cv['base']); + + if(!$res){ + $this->checks['acls']['STATUS'] = FALSE; + $this->checks['acls']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['acls']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + }else{ + $found = false; + $username = ""; + $attrs = $ldap->fetch(); + if(isset($attrs['gosaAclEntry'])){ + $acls = $attrs['gosaAclEntry']; + for($i = 0 ; $i < $acls['count'] ; $i++){ + $acl = $acls[$i]; + $tmp = split(":",$acl); + if($tmp[1] == "psub"){ + $members = split(",",$tmp[2]); + foreach($members as $member){ + $member = base64_decode($member); + + /* Check if acl owner is a valid GOsa user account */ + $ldap->cat($member,array("objectClass","uid","cn")); + $ret = $ldap->fetch(); + + if(isset($ret['objectClass']) && in_array("posixGroup",$ret['objectClass'])){ + $found = TRUE; + $username .= "ACL-Group: ".$ret['cn'][0]."
"; + }elseif(isset($ret['objectClass']) && in_array("gosaAccount",$ret['objectClass']) && + in_array("organizationalPerson",$ret['objectClass']) && + in_array("inetOrgPerson",$ret['objectClass'])){ + $found = TRUE; + $username .= "ACL: ".$ret['uid'][0]."
"; + } + } + }elseif($tmp[1] == "role"){ + + /* Check if acl owner is a valid GOsa user account */ + $ldap->cat(base64_decode($tmp[2]),array("gosaAclTemplate")); + $ret = $ldap->fetch(); + + if(isset($ret['gosaAclTemplate'])){ + $cnt = $ret['gosaAclTemplate']['count']; + for($e = 0 ; $e < $cnt ; $e++){ + + $a_str = $ret['gosaAclTemplate'][$e]; + if(preg_match("/^[0-9]*:psub:/",$a_str) && preg_match("/:all;cmdrw$/",$a_str)){ + + $members = split(",",$tmp[3]); + foreach($members as $member){ + $member = base64_decode($member); + + /* Check if acl owner is a valid GOsa user account */ + $ldap->cat($member,array("objectClass","uid")); + $ret = $ldap->fetch(); + + if(isset($ret['objectClass']) && in_array("gosaAccount",$ret['objectClass']) && + in_array("organizationalPerson",$ret['objectClass']) && + in_array("inetOrgPerson",$ret['objectClass'])){ + $found = TRUE; + $username .= "ACL Role: ".$ret['uid'][0]."
"; + } + } + } + } + } + } + } + } + + # For debugging + #echo $username; + + if($found){ + $this->checks['acls']['STATUS'] = TRUE; + $this->checks['acls']['STATUS_MSG']= _("Ok"); + $this->checks['acls']['ERROR_MSG'] = ""; + }else{ + $this->checks['acls']['STATUS'] = FALSE; + $this->checks['acls']['STATUS_MSG']= _("Failed"); + $this->checks['acls']['ERROR_MSG']= _("There is no GOsa administrator account inside your LDAP.")." "; + $this->checks['acls']['ERROR_MSG'].= ""; + } + } + return($ldap->count()>=1); + } + + + + function create_admin($only_ldif = FALSE) + { + /* Reset '' */ + $this->acl_create_changes=""; + + /* Object that should receive admin acls */ + $dn = $this->acl_create_selected; + + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Get current base attributes */ + $ldap->cd($cv['base']); + $ldap->cat($cv['base'],array("dn","objectClass","gosaAclEntry")); + $attrs = $ldap->fetch(); + + /* Add acls for the selcted user to the base */ + $attrs_new['objectClass'] = array("gosaACL"); + + for($i = 0; $i < $attrs['objectClass']['count']; $i ++){ + if(!in_array_ics($attrs['objectClass'][$i],$attrs_new['objectClass'])){ + $attrs_new['objectClass'][] = $attrs['objectClass'][$i]; + } + } + + $acl = "0:psub:".base64_encode($dn).":all;cmdrw"; + $attrs_new['gosaAclEntry'][] = $acl; + if(isset($attrs['gosaAclEntry'])){ + for($i = 0 ; $i < $attrs['gosaAclEntry']['count']; $i ++){ + + $prio = preg_replace("/[:].*$/","",$attrs['gosaAclEntry'][$i]); + $rest = preg_replace("/^[^:]/","",$attrs['gosaAclEntry'][$i]); + + $data = ($prio+1).$rest; + $attrs_new['gosaAclEntry'][] = $data; + } + } + + if($only_ldif){ + $this->acl_create_changes ="\n".($ldap->fix($cv['base']))."\n"; + $this->acl_create_changes.=$this->array_to_ldif($attrs)."\n"; + $this->acl_create_changes.="\n".($ldap->fix($cv['base']))."\n"; + $this->acl_create_changes.=$this->array_to_ldif($attrs_new); + }else{ + + $ldap->cd($cv['base']); + if(!$ldap->modify($attrs_new)){ + print_red(sprintf(_("Adding acls for user '%s' failed, ldap says '%s'."),$dn,$ldap->get_error())); + return(FALSE); + }else{ + return(TRUE); + } + } + } + + + function create_admin_user() + { + $pw1 = $pw2 = ""; + $uid = ""; + + if(isset($_POST['new_user_uid'])){ + $uid = $_POST['new_user_uid']; + } + if(isset($_POST['new_user_password'])){ + $pw1 = $_POST['new_user_password']; + } + if(isset($_POST['new_user_password2'])){ + $pw2 = $_POST['new_user_password2']; + } + + if(empty($pw1) || empty($pw2) | ($pw1 != $pw2)){ + print_red(_("Specified passwords are empty or not equal.")); + return false; + } + + if(!is_uid($uid) || empty($uid)){ + print_red(_("Please specify a valid uid.")); + return false; + } + + + /* Establish ldap connection */ + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Get current base attributes */ + $ldap->cd($cv['base']); + + $people_ou = trim($cv['peopleou']); + if(!empty($people_ou)){ + $people_ou = trim($people_ou).","; + } + + if($cv['peopledn'] == "cn"){ + $dn = "cn=System Administrator,".$people_ou.$cv['base']; + }else{ + $dn = "uid=".$uid.",".$people_ou.$cv['base']; + } + + $methods = @passwordMethod::get_available_methods(); + $p_m = $methods[$cv['encryption']]; + $p_c = new $p_m(array()); + $hash = $p_c->generate_hash($pw2); + + $new_user=array(); + $new_user['objectClass']= array("top","person","gosaAccount","organizationalPerson","inetOrgPerson"); + $new_user['givenName'] = "System"; + $new_user['sn'] = "Administrator"; + $new_user['cn'] = "System Administrator"; + $new_user['uid'] = $uid; + $new_user['userPassword'] = $hash; + + $ldap->cd($cv['base']); + + $ldap->cat($dn,array("dn")); + if($ldap->count()){ + print_red(sprintf(_("Could not add administrative user, there is already an object with the same dn '%s' in your ldap database."),$dn)); + return(FALSE); + } + + $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$dn)); + $ldap->cd($dn); + $res = $ldap->add($new_user); + $this->acl_create_selected = $dn; + $this->create_admin(); + + if(!$res){ + print_red($ldap->get_error()); + return(FALSE); + } + + $this->acl_create_dialog=FALSE; + $this->check_administrativeAccount(); + return(TRUE); + } + + + function migrate_outside_winstations($perform = FALSE) + { + /* Establish ldap connection */ + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + + /* Check if there was a destination department posted */ + if(isset($_POST['move_winstation_to'])){ + $destination_dep = $_POST['move_winstation_to']; + }else{ + print_red(_("Couldn't move users to specified department.")); + return(false); + } + + foreach($this->outside_winstations as $b_dn => $data){ + $this->outside_winstations[$b_dn]['ldif'] =""; + if($data['selected']){ + $dn = base64_decode($b_dn); + $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn); + if(!$perform){ + $this->outside_winstations[$b_dn]['ldif'] = _("Winstation will be moved from").":
\t".($ldap->fix($dn))."
"._("to").":
\t".($ldap->fix($d_dn)); + + + /* Check if there are references to this object */ + $ldap->search("(&(member=".$dn.")(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))",array('dn')); + $refs = ""; + while($attrs = $ldap->fetch()){ + $ref_dn = $attrs['dn']; + $refs .= "
\t".$ref_dn; + } + if(!empty($refs)){ + $this->outside_winstations[$b_dn]['ldif'] .= "

"._("Updating following references too").":".$refs; + } + + }else{ + $this->move($dn,$d_dn); + } + } + } + } + + + function migrate_outside_groups($perform = FALSE) + { + /* Establish ldap connection */ + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + + /* Check if there was a destination department posted */ + if(isset($_POST['move_group_to'])){ + $destination_dep = $_POST['move_group_to']; + }else{ + print_red(_("Couldn't move users to specified department.")); + return(false); + } + + foreach($this->outside_groups as $b_dn => $data){ + $this->outside_groups[$b_dn]['ldif'] =""; + if($data['selected']){ + $dn = base64_decode($b_dn); + $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn); + if(!$perform){ + + $this->outside_groups[$b_dn]['ldif'] = _("Group will be moved from").":
\t".($ldap->fix($dn))."
"._("to").":
\t".($ldap->fix($d_dn)); + + /* Check if there are references to this object */ + $ldap->search("(&(member=".$dn.")(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))",array('dn')); + $refs = ""; + while($attrs = $ldap->fetch()){ + $ref_dn = $attrs['dn']; + $refs .= "
\t".$ref_dn; + } + if(!empty($refs)){ + $this->outside_groups[$b_dn]['ldif'] .= "

"._("Updating following references too").":".$refs; + } + + }else{ + $this->move($dn,$d_dn); + } + } + } + } + + + function migrate_outside_users($perform = FALSE) + { + /* Establish ldap connection */ + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + + /* Check if there was a destination department posted */ + if(isset($_POST['move_user_to'])){ + $destination_dep = $_POST['move_user_to']; + }else{ + print_red(_("Couldn't move users to specified department.")); + return(false); + } + + foreach($this->outside_users as $b_dn => $data){ + $this->outside_users[$b_dn]['ldif'] =""; + if($data['selected']){ + $dn = base64_decode($b_dn); + $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn); + if(!$perform){ + $this->outside_users[$b_dn]['ldif'] = _("User will be moved from").":
\t".($ldap->fix($dn))."
"._("to").":
\t".($ldap->fix($d_dn)); + + /* Check if there are references to this object */ + $ldap->search("(&(member=".$dn.")(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))",array('dn')); + $refs = ""; + while($attrs = $ldap->fetch()){ + $ref_dn = $attrs['dn']; + $refs .= "
\t".$ref_dn; + } + if(!empty($refs)){ + $this->outside_users[$b_dn]['ldif'] .= "

"._("The following references will be updated").":".$refs; + } + + }else{ + $this->move($dn,$d_dn); + } + } + } + } + + + function execute() + { + /* Initialise checks if this is the first call */ + if(!$this->checks_initialised || isset($_POST['reload'])){ + $this->initialize_checks(); + $this->checks_initialised = TRUE; + } + + /************* + * Winstations outside the group ou + *************/ + + if(isset($_POST['outside_winstations_dialog_cancel'])){ + $this->outside_winstations_dialog = FALSE; + $this->dialog = FALSE; + $this->show_details = FALSE; + } + + if(isset($_POST['outside_winstations_dialog_whats_done'])){ + $this->migrate_outside_winstations(FALSE); + } + + if(isset($_POST['outside_winstations_dialog_perform'])){ + $this->migrate_outside_winstations(TRUE); + $this->search_outside_winstations(); + $this->dialog = FALSE; + $this->show_details = FALSE; + $this->outside_winstations_dialog = FALSE; + } + + if(isset($_POST['outside_winstations_dialog'])){ + $this->outside_winstations_dialog = TRUE; + $this->dialog = TRUE; + } + + if($this->outside_winstations_dialog){ + + /* Fix displayed dn syntax */ + $tmp = $this->outside_winstations; + foreach($tmp as $key => $data){ + $tmp[$key]['dn'] = @LDAP::fix($data['dn']); + } + + $smarty = get_smarty(); + $smarty->assign("ous",$this->get_all_winstation_ous()); + $smarty->assign("method","outside_winstations"); + $smarty->assign("outside_winstations",$tmp); + return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); + } + /************* + * Groups outside the group ou + *************/ + + if(isset($_POST['outside_groups_dialog_cancel'])){ + $this->outside_groups_dialog = FALSE; + $this->show_details = FALSE; + $this->dialog = FALSE; + } + + if(isset($_POST['outside_groups_dialog_whats_done'])){ + $this->show_details= TRUE; + $this->migrate_outside_groups(FALSE); + } + + if(isset($_POST['outside_groups_dialog_refresh'])){ + $this->show_details= FALSE; + } + + if(isset($_POST['outside_groups_dialog_perform'])){ + $this->migrate_outside_groups(TRUE); + $this->dialog = FALSE; + $this->show_details = FALSE; + $this->outside_groups_dialog = FALSE; + $this->initialize_checks(); + } + + if(isset($_POST['outside_groups_dialog'])){ + $this->outside_groups_dialog = TRUE; + $this->dialog = TRUE; + } + + if($this->outside_groups_dialog){ + + /* Fix displayed dn syntax */ + $tmp = $this->outside_groups; + foreach($tmp as $key => $data){ + $tmp[$key]['dn'] = @LDAP::fix($data['dn']); + } + + $smarty = get_smarty(); + $smarty->assign("ous",$this->get_all_group_ous()); + $smarty->assign("method","outside_groups"); + $smarty->assign("outside_groups",$tmp); + $smarty->assign("group_details", $this->show_details); + return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); + } + + /************* + * User outside the people ou + *************/ + + if(isset($_POST['outside_users_dialog_cancel'])){ + $this->outside_users_dialog = FALSE; + $this->dialog = FALSE; + $this->show_details = FALSE; + } + + if(isset($_POST['outside_users_dialog_whats_done'])){ + $this->show_details= TRUE; + $this->migrate_outside_users(FALSE); + } + + if(isset($_POST['outside_users_dialog_perform'])){ + $this->migrate_outside_users(TRUE); + $this->initialize_checks(); + $this->dialog = FALSE; + $this->show_details = FALSE; + $this->outside_users_dialog = FALSE; + } + + if (isset($_POST['outside_users_dialog_refresh'])){ + $this->show_details= FALSE; + } + + if(isset($_POST['outside_users_dialog'])){ + $this->outside_users_dialog = TRUE; + $this->dialog = TRUE; + } + + if($this->outside_users_dialog){ + + /* Fix displayed dn syntax */ + $tmp = $this->outside_users; + foreach($tmp as $key => $data){ + $tmp[$key]['dn'] = @LDAP::fix($data['dn']); + } + + $smarty = get_smarty(); + $smarty->assign("ous",$this->get_all_people_ous()); + $smarty->assign("method","outside_users"); + $smarty->assign("outside_users",$tmp); + $smarty->assign("user_details", $this->show_details); + return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); + } + + /************* + * Root object check + *************/ + + if(isset($_POST['retry_root_create'])){ + + $state = $this->checks['root']['STATUS']; + $this->checkBase(FALSE); + if($state != $this->checks['root']['STATUS']){ + $this->initialize_checks(); + } + } + + /************* + * User Migration handling + *************/ + + if(isset($_POST['retry_acls'])){ + $this->check_administrativeAccount(); + } + + if(isset($_POST['create_acls'])){ + $this->acl_create_dialog = TRUE; + $this->dialog = TRUE; + } + + if(isset($_POST['create_acls_cancel'])){ + $this->acl_create_dialog = FALSE; + $this->dialog = FALSE; + $this->show_details = FALSE; + } + +# if(isset($_POST['create_acls_create_confirmed'])){ +# if($this->create_admin()){ +# $this->acl_create_dialog = FALSE; +# $this->dialog = FALSE; +# $this->show_details = FALSE; +# $this->initialize_checks(); +# } +# } + + if(isset($_POST['create_acls_create'])){ + $this->create_admin(TRUE); + } + + if(isset($_POST['create_admin_user'])){ + if($this->create_admin_user()){ + $this->dialog = FALSE; + $this->show_details = FALSE; + } + } + + if($this->acl_create_dialog){ + $smarty = get_smarty(); + + $uid = "admin"; + if(isset($_POST['new_user_uid'])){ + $uid = $_POST['new_user_uid']; + } + + $smarty->assign("new_user_uid",$uid); + $smarty->assign("new_user_password",@$_POST['new_user_password']); + $smarty->assign("new_user_password2",@$_POST['new_user_password2']); + $smarty->assign("method","create_acls"); + $smarty->assign("acl_create_selected",$this->acl_create_selected); + $smarty->assign("what_will_be_done_now",$this->acl_create_changes); + return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); + } + + /************* + * User Migration handling + *************/ + + /* Refresh list of deparments */ + if(isset($_POST['users_visible_migrate_refresh'])){ + $this->check_gosaAccounts(); + } + + /* Open migration dialog */ + if(isset($_POST['users_visible_migrate'])){ + $this->show_details= FALSE; + $this->users_migration_dialog = TRUE; + $this->dialog =TRUE; + } + + /* Close migration dialog */ + if(isset($_POST['users_visible_migrate_close'])){ + $this->users_migration_dialog = FALSE; + $this->dialog =FALSE; + $this->show_details = FALSE; + } + + /* Start migration */ + if(isset($_POST['users_visible_migrate_migrate'])){ + if($this->migrate_gosaAccounts()){ + $this->initialize_checks(); + $this->dialog = FALSE; + $this->show_details = FALSE; + $this->users_migration_dialog = FALSE; + } + } + + /* Start migration */ + if(isset($_POST['users_visible_migrate_whatsdone'])){ + $this->migrate_gosaAccounts(TRUE); + } + + /* Display migration dialog */ + if($this->users_migration_dialog){ + + /* Fix displayed dn syntax */ + $tmp = $this->users_to_migrate; + foreach($tmp as $key => $data){ + $tmp[$key]['dn'] = @LDAP::fix($data['dn']); + } + + $smarty = get_smarty(); + $smarty->assign("users_to_migrate",$tmp); + $smarty->assign("method","migrate_users"); + $smarty->assign("user_details", $this->show_details); + return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); + } + + + /************* + * Department Migration handling + *************/ + + /* Refresh list of deparments */ + if(isset($_POST['deps_visible_migrate_refresh'])){ + $this->check_organizationalUnits(); + $this->show_details= FALSE; + } + + /* Open migration dialog */ + if(isset($_POST['deps_visible_migrate'])){ + $this->dep_migration_dialog = TRUE; + $this->dialog =TRUE; + } + + /* Close migration dialog */ + if(isset($_POST['deps_visible_migrate_close'])){ + $this->dep_migration_dialog = FALSE; + $this->dialog =FALSE; + $this->show_details = FALSE; + } + + /* Start migration */ + if(isset($_POST['deps_visible_migrate_migrate'])){ + if($this->migrate_organizationalUnits()){ + $this->show_details= FALSE; + $this->check_organizationalUnits(); + $this->dialog = FALSE; + $this->dep_migration_dialog = FALSE; + } + } + + /* Start migration */ + if(isset($_POST['deps_visible_migrate_whatsdone'])){ + $this->migrate_organizationalUnits(TRUE); + } + + /* Display migration dialog */ + if($this->dep_migration_dialog){ + $smarty = get_smarty(); + + /* Fix displayed dn syntax */ + $tmp = $this->deps_to_migrate; + foreach($tmp as $key => $data){ + $tmp[$key]['dn'] = @LDAP::fix($data['dn']); + } + + $smarty->assign("deps_to_migrate",$tmp); + $smarty->assign("method","migrate_deps"); + $smarty->assign("deps_details", $this->show_details); + return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); + } + + $smarty = get_smarty(); + $smarty->assign("checks",$this->checks); + $smarty->assign("method","default"); + return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); + } + + + function save_object() + { + $this->is_completed= TRUE; + + /* Capture all selected winstations from outside_winstations_dialog */ + if($this->outside_winstations_dialog){ + foreach($this->outside_winstations as $dn => $data){ + if(isset($_POST['select_winstation_'.$dn])){ + $this->outside_winstations[$dn]['selected'] = TRUE; + }else{ + $this->outside_winstations[$dn]['selected'] = FALSE; + } + } + } + + /* Capture all selected groups from outside_groups_dialog */ + if($this->outside_groups_dialog){ + foreach($this->outside_groups as $dn => $data){ + if(isset($_POST['select_group_'.$dn])){ + $this->outside_groups[$dn]['selected'] = TRUE; + }else{ + $this->outside_groups[$dn]['selected'] = FALSE; + } + } + } + + /* Capture all selected users from outside_users_dialog */ + if($this->outside_users_dialog){ + foreach($this->outside_users as $dn => $data){ + if(isset($_POST['select_user_'.$dn])){ + $this->outside_users[$dn]['selected'] = TRUE; + }else{ + $this->outside_users[$dn]['selected'] = FALSE; + } + } + } + + /* Get "create acl" dialog posts */ + if($this->acl_create_dialog){ + + if(isset($_POST['create_acls_create_abort'])){ + $this->acl_create_selected = ""; + } + } + + /* Get selected departments */ + if($this->dep_migration_dialog){ + foreach($this->deps_to_migrate as $id => $data){ + if(isset($_POST['migrate_'.$id])){ + $this->deps_to_migrate[$id]['checked'] = TRUE; + }else{ + $this->deps_to_migrate[$id]['checked'] = FALSE; + } + } + } + + /* Get selected users */ + if($this->users_migration_dialog){ + foreach($this->users_to_migrate as $id => $data){ + if(isset($_POST['migrate_'.$id])){ + $this->users_to_migrate[$id]['checked'] = TRUE; + }else{ + $this->users_to_migrate[$id]['checked'] = FALSE; + } + } + } + } + + + /* Check if the root object exists. + * If the parameter just_check is true, then just check if the + * root object is missing and update the info messages. + * If the Parameter is false, try to create a new root object. + */ + function checkBase($just_check = TRUE) + { + /* Get collected setup informations */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Check if root object exists */ + $ldap->cd($cv['base']); + $res = $ldap->search("(objectClass=*)"); + $err = ldap_errno($ldap->cid); + + if( !$res || + $err == 0x20 || # LDAP_NO_SUCH_OBJECT + $err == 0x40) { # LDAP_NAMING_VIOLATION + + /* Root object doesn't exists + */ + if($just_check){ + $this->checks['root']['STATUS'] = FALSE; + $this->checks['root']['STATUS_MSG']= _("Failed"); + $this->checks['root']['ERROR_MSG'] = _("The LDAP root object is missing. It is required to use your LDAP service.").' '; + $this->checks['root']['ERROR_MSG'].= ""; + return(FALSE); + }else{ + + /* Add root object */ + $ldap->cd($cv['base']); + $res = $ldap->create_missing_trees($cv['base']); + + /* If adding failed, tell the user */ + if(!$res){ + $this->checks['root']['STATUS'] = FALSE; + $this->checks['root']['STATUS_MSG']= _("Failed"); + $this->checks['root']['ERROR_MSG'] = _("Root object couldn't be created, you should try it on your own."); + $this->checks['root']['ERROR_MSG'].= " "; + return($res);; + } + } + } + + /* Create & remove of dummy object was successful */ + $this->checks['root']['STATUS'] = TRUE; + $this->checks['root']['STATUS_MSG']= _("Ok"); + } + + + /* Return ldif information for a + * given attribute array + */ + function array_to_ldif($atts) + { + $ret = ""; + unset($atts['count']); + unset($atts['dn']); + foreach($atts as $name => $value){ + if(is_numeric($name)) { + continue; + } + if(is_array($value)){ + unset($value['count']); + foreach($value as $a_val){ + $ret .= $name.": ". $a_val."\n"; + } + }else{ + $ret .= $name.": ". $value."\n"; + } + } + return(preg_replace("/\n$/","",$ret)); + } + + + function get_user_list() + { + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + $ldap->search("(objectClass=gosaAccount)",array("dn")); + + $tmp = array(); + while($attrs = $ldap->fetch()){ + $tmp[base64_encode($attrs['dn'])] = @LDAP::fix($attrs['dn']); + } + return($tmp); + } + + + function get_all_people_ous() + { + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + $people_ou = trim($cv['peopleou']); + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + + /***************** + * If people ou is NOT empty + * search for for all objects matching the given container + *****************/ + if(!empty($people_ou)){ + $ldap->search("(".$people_ou.")",array("dn")); + + /* Create people ou if there is currently none */ + if($ldap->count() == 0 ){ + $add_dn = $cv['peopleou'].",".$cv['base']; + $naming_attr = preg_replace("/=.*$/","",$add_dn); + $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn); + $add = array(); + $add['objectClass'] = array("organizationalUnit"); + $add[$naming_attr] = $naming_value; + $ldap->cd($cv['base']); + $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn)); + $ldap->cd($add_dn); + $ldap->add($add); + } + + /* Create result */ + $ldap->search("(".$cv['peopleou'].")",array("dn")); + $tmp = array(); + while($attrs= $ldap->fetch()){ + if(!preg_match("/ou=snapshots,/",$attrs['dn'])){ + $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']); + } + } + } else{ + + /************ + * If people ou is empty + * Get all valid gosaDepartments + ************/ + $ldap->cd($cv['base']); + $tmp = array(); + $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn")); + $tmp[base64_encode($cv['base'])] = $ldap->fix($cv['base']); + while($attrs = $ldap->fetch()){ + $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);; + } + } + return($tmp); + } + + + function get_all_winstation_ous() + { + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Get winstation ou */ + if($cv['generic_settings']['wws_ou_active']) { + $winstation_ou = $cv['generic_settings']['ws_ou']; + }else{ + $winstation_ou = "ou=winstations"; + } + + $ldap->cd($cv['base']); + $ldap->search("(".$winstation_ou.")",array("dn")); + + if($ldap->count() == 0 ){ + $add_dn = $winstation_ou.",ou=systems,".$cv['base']; + $naming_attr = preg_replace("/=.*$/","",$add_dn); + $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn); + $add = array(); + $add['objectClass'] = array("organizationalUnit"); + $add[$naming_attr] = $naming_value; + + $ldap->cd($cv['base']); + $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn)); + $ldap->cd($add_dn); + $ldap->add($add); + } + + $ldap->search("(".$winstation_ou.")",array("dn")); + $tmp = array(); + while($attrs= $ldap->fetch()){ + if(!preg_match("/ou=snapshots,/",$attrs['dn'])){ + $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']); + } + } + return($tmp); + } + + + function get_all_group_ous() + { + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $group_ou = trim($cv['groupou']); + if(!empty($group_ou)){ + $group_ou = trim($group_ou); + } + + /************ + * If group ou is NOT empty + * Get all valid group ous, create one if necessary + ************/ + $ldap->cd($cv['base']); + if(!empty($group_ou)){ + $ldap->search("(".$group_ou.")",array("dn")); + if($ldap->count() == 0 ){ + $add_dn = $group_ou.$cv['base']; + $naming_attr = preg_replace("/=.*$/","",$add_dn); + $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn); + $add = array(); + $add['objectClass'] = array("organizationalUnit"); + $add[$naming_attr] = $naming_value; + + $ldap->cd($cv['base']); + $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn)); + $ldap->cd($add_dn); + $ldap->add($add); + } + $ldap->search("(".$group_ou.")",array("dn")); + $tmp = array(); + while($attrs= $ldap->fetch()){ + if(!preg_match("/ou=snapshots,/",$attrs['dn'])){ + $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']); + } + } + }else{ + /************ + * If group ou is empty + * Get all valid gosaDepartments + ************/ + $ldap->cd($cv['base']); + $tmp = array(); + $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn")); + $tmp[base64_encode($cv['base'])] = $ldap->fix($cv['base']); + while($attrs = $ldap->fetch()){ + $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);; + } + } + return($tmp); + } + + + function get_group_list() + { + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap->cd($cv['base']); + $ldap->search("(objectClass=posixGroup)",array("dn")); + + $tmp = array(); + while($attrs = $ldap->fetch()){ + $tmp[base64_encode($attrs['dn'])] = @LDAP::fix($attrs['dn']); + } + return($tmp); + } + + + function move($source,$destination) + { + /* Get collected configuration settings */ + $cv = $this->parent->captured_values; + + /* Establish ldap connection */ + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + /* Update object references in gosaGroupOfNames */ + $ogs_to_fix = array(); + $ldap->cd($cv['base']); + $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::fix($source).'))', array('cn','member')); + while ($attrs= $ldap->fetch()){ + $dn = $attrs['dn']; + $attrs = $this->cleanup_array($attrs); + $member_new = array($destination); + foreach($attrs['member'] as $member){ + if($member != $source){ + $member_new[] = $member; + } + } + $attrs['member'] = $member_new; + $ogs_to_fix[$dn] = $attrs; + } + + /* Copy source to destination dn */ + $ldap->cat($source); + $new_data = $this->cleanup_array($ldap->fetch()); + $ldap->cd($destination); + $res = $ldap->add($new_data); + + /* Display warning if copy failed */ + if(!$res){ + print_red(_("Failed to copy '%s' to '%s'. LDAP says '%s'."),$source,$destination,$ldap->get_error()); + }else{ + $res = $ldap->rmDir($source); + show_ldap_error($ldap->get_error(),_("Something went wrong while copying dns.")); + + /* Object is copied, so update its references */ + foreach($ogs_to_fix as $dn => $data){ + $ldap->cd($dn); + $ldap->modify($data); + } + } + } + + + /* Cleanup ldap result to be able to write it be to ldap */ + function cleanup_array($attrs) + { + foreach($attrs as $key => $value) { + if(is_numeric($key) || in_array($key,array("count","dn"))){ + unset($attrs[$key]); + } + if(is_array($value) && isset($value['count'])){ + unset($attrs[$key]['count']); + } + } + return($attrs); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Schema.inc b/gosa-core/setup/class_setupStep_Schema.inc new file mode 100644 index 000000000..2008128a4 --- /dev/null +++ b/gosa-core/setup/class_setupStep_Schema.inc @@ -0,0 +1,110 @@ +update_strings(); + } + + + function update_strings() + { + $this->s_title = _("LDAP schema check"); + $this->s_title_long = _("LDAP schema check"); + $this->s_info = _("Perform test on your current LDAP schema"); + } + + + function execute() + { + $this->check_schema(); + $failed_checks = 0 ; + foreach($this->checked as $val) { + if(!$val['STATUS']){ + $failed_checks ++; + } + } + + if($failed_checks == 0){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = TRUE; + } + + $smarty = get_smarty(); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + $smarty->assign("schema_readable",$this->schema_readable); + $smarty->assign("enable_schema_check",$this->enable_schema_check); + $smarty->assign("checks",$this->checked); + $smarty->assign("not_checked",$this->not_checked); + $smarty->assign("failed_checks",$failed_checks); + return($smarty -> fetch (get_template_path("../setup/setup_schema.tpl"))); + } + + function save_object() + { + if(isset($_POST['step7_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate($_POST[$attr]); + } + } + } + } + + function check_schema() + { + $cfg = $this->parent->captured_values; + $rfc2307bis = $cfg['rfc2307bis']; + $this->checked = check_schema($cfg,$rfc2307bis); + + /* Get objectclasses */ + $ldap = new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['tls']); + $objectclasses = $ldap->get_objectclasses(); + if(count($objectclasses) == 0){ + print_red(_("Can't get schema information from server. No schema check possible!")); + } + + /* Which samba version do we use? */ + if(isset($objectclasses['sambaSamAccount'])){ + $this->samba_version = 3; + } elseif(isset($objectclasses['sambaAccount'])) { + $this->samba_version = 2; + }else{ + $this->samba_version = 0; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/class_setupStep_Welcome.inc b/gosa-core/setup/class_setupStep_Welcome.inc new file mode 100644 index 000000000..f030f3121 --- /dev/null +++ b/gosa-core/setup/class_setupStep_Welcome.inc @@ -0,0 +1,71 @@ +is_enabled = TRUE; + $this->is_active = TRUE; + $this->update_strings(); + } + + function update_strings() + { + $this->s_title = _("Welcome"); + $this->s_info = _("The welcome message"); + $this->s_title_long = _("Welcome to GOsa setup wizard"); + } + + function execute() + { + $smarty = get_smarty(); + $smarty->assign('auth_id', session_id()); + return($smarty->fetch(get_template_path("setup_welcome.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + $id = ""; + + /* Get auth ID from file */ + if (file_exists('/tmp/gosa.auth') && is_readable('/tmp/gosa.auth')){ + $contents= file('/tmp/gosa.auth'); + $id= chop($contents[0]); + } + + /* Continue if we've the correct ID */ + if ($id == session_id()){ + $this->is_completed = true; + } else { + $this->is_completed = false; + } + + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/license.txt b/gosa-core/setup/license.txt new file mode 100644 index 000000000..9140f02bf --- /dev/null +++ b/gosa-core/setup/license.txt @@ -0,0 +1,147 @@ +Table of Contents + + * GNU GENERAL PUBLIC LICENSE + o Preamble + o TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + o How to Apply These Terms to Your New Programs + +GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + * a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + * b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + * c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + * a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + * b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + * c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + +one line to give the program's name and an idea of what it does. +Copyright (C) yyyy name of author + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details +type `show w'. This is free software, and you are welcome +to redistribute it under certain conditions; type `show c' +for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright +interest in the program `Gnomovision' +(which makes passes at compilers) written +by James Hacker. + +signature of Ty Coon, 1 April 1989 +Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. + +Linking Joomla! statically or dynamically with other modules is making a combined work based on Joomla!. Thus, the terms and conditions of the GNU General Public License cover the whole combination. + +In addition, as a special exception, the copyright holders of Joomla! give you permission to combine Joomla! with free software programs or libraries that are released under the GNU LGPL and with independent modules that communicate with Joomla! solely through the Joomla! extension interface. You may copy and distribute such a system following the terms of the GNU GPL for Joomla! and the licenses of the other code concerned, provided that you include the source code of that other code when and as the GNU GPL requires distribution of source code. + +Note that people who make modified versions of Joomla! are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU General Public License gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. diff --git a/gosa-core/setup/main.inc b/gosa-core/setup/main.inc new file mode 100644 index 000000000..bce41ef68 --- /dev/null +++ b/gosa-core/setup/main.inc @@ -0,0 +1,35 @@ +save_object(); +$display= $setup->execute(); + +/* Store changes in session */ +$_SESSION['setup']= $setup; + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-core/setup/setup.tpl b/gosa-core/setup/setup.tpl new file mode 100644 index 000000000..3bb21f795 --- /dev/null +++ b/gosa-core/setup/setup.tpl @@ -0,0 +1,4 @@ +
+{$php_errors} +sadffasdsdfa +
diff --git a/gosa-core/setup/setup_checks.tpl b/gosa-core/setup/setup_checks.tpl new file mode 100644 index 000000000..90275fc27 --- /dev/null +++ b/gosa-core/setup/setup_checks.tpl @@ -0,0 +1,122 @@ + +
+ + +
+ +

{t}PHP module and extension checks{/t}

+ + {foreach from=$basic item=val key=key} + + {if $basic[$key].SOLUTION != "" && !$basic[$key].RESULT} + + +
+ {else} + + +
+ {/if} + +
{$basic[$key].NAME}
+
+ + {if $basic[$key].RESULT} +
{t}Ok{/t}
+ {else} + {if $basic[$key].MUST} +
{t}Error{/t}
+ {else} +
{t}Warning{/t}
+ {/if} + {if $basic[$key].SOLUTION != ""} + + +
+ {if $basic[$key].MUST} +
+ {$basic[$key].SOLUTION} + {t}GOsa will NOT run without fixing this.{/t} + {else} +
+ {$basic[$key].SOLUTION} + {t}GOsa will run without fixing this.{/t} + {/if} +
+
+ {/if} + {/if} +
+
+ {/foreach} +
+
+ + + +
+ + +
+ + +

{t}PHP setup configuration{/t} ({t}show information{/t})

+ + + {foreach from=$config item=val key=key} + + + {if $config[$key].SOLUTION != "" && !$config[$key].RESULT} + + +
+ {else} + + +
+ {/if} + + +
{$config[$key].NAME}
+
+ {if $config[$key].RESULT} +
{t}Ok{/t}
+ {else} + + {if $config[$key].MUST} +
{t}Error{/t}
+ {else} +
{t}Warning{/t}
+ {/if} + + {if $config[$key].SOLUTION != ""} + + +
+ {if $config[$key].MUST} +
+ {$config[$key].SOLUTION} + {t}GOsa will NOT run without fixing this.{/t} + {else} +
+ {$config[$key].SOLUTION} + {t}GOsa will run without fixing this.{/t} + {/if} +
+
+ {/if} + {/if} +
+
+ {/foreach} + + +
+
+ +
+ diff --git a/gosa-core/setup/setup_config1.tpl b/gosa-core/setup/setup_config1.tpl new file mode 100644 index 000000000..d041ae35f --- /dev/null +++ b/gosa-core/setup/setup_config1.tpl @@ -0,0 +1,225 @@ +
+

{t}Look and feel{/t}

+ +
+
+ {t}Theme{/t} +
+
+ +
+
+ +

{t}Apache{/t}

+ +
+
+ {t}Compress output send to browser{/t} +
+
+ +
+
+

{t}People and group storage{/t}

+
+
+ {t}People DN attribute{/t} +
+
+ +
+
+ +
+
+ {t}People storage subtree{/t} +
+
+ +
+
+ +
+
+ {t}Group storage subtree{/t} +
+
+ +
+
+ +
+
+ {t}Include personal title in user DN{/t} +
+
+ +
+
+ +
+
+ {t}Relaxed naming policies{/t} +
+
+ +
+
+ +
+
+ {t}Automatic uids{/t} +
+
+ {if $id_settings.idgen_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}GID / UID min id{/t} +
+
+ {if $id_settings.minid_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Number base for people/groups{/t} +
+
+ +
+
+
+
+ {t}Hook for number base{/t} +
+
+ {if $base_hook_active == FALSE} + + + {else} + + + {/if} +
+
+
+ +

{t}Password settings{/t}

+ +
+
+ {t}Password encryption algorithm{/t} +
+
+ +
+
+ +
+
+ {t}Password restrictions{/t} +
+
+ + {if $pwd_rules.pwminlen_active == FALSE} + + {t}Password minimum length{/t} + + {else} + + {t}Password minimum length{/t} + + {/if} +
+ {if $pwd_rules.pwdiffer_active == FALSE} + + {t}Different characters from old password{/t} + + {else} + + {t}Different characters from old password{/t} + + {/if} + +
+
+ +
+
+ {t}Password change hook{/t} +
+
+ {if $pwd_rules.externalpwdhook_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Use SASL for kerberos{/t} +
+
+ +
+
+ +
+
+ {t}Use account expiration{/t} +
+
+ +
+
+ + + + + diff --git a/gosa-core/setup/setup_config2.tpl b/gosa-core/setup/setup_config2.tpl new file mode 100644 index 000000000..80c5cf6aa --- /dev/null +++ b/gosa-core/setup/setup_config2.tpl @@ -0,0 +1,323 @@ +
+

{t}Samba settings{/t}

+ +
+
+ {t}Samba hash generator{/t} +
+
+ +
+
+ +
+
+ {t}Samba SID{/t} +
+
+ {if $samba_settings.samba_sid_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}RID base{/t} +
+
+ {if $samba_settings.samba_rid_active == FALSE} + + + {else} + + + {/if} +
+
+
+
+ {t}Workstation container{/t} +
+
+ {if $generic_settings.wws_ou_active == FALSE} + + + {else} + + + {/if} +
+
+
+
+ {t}Samba SID mapping{/t} +
+
+ +
+
+
+
+ {t}Timezone{/t} +
+
+ +
+
+ + +

{t}Additional GOsa settings{/t}

+ +
+
+ {t}Enable Copy & Paste{/t} +
+
+ + +
+
+ +
+
+ {t}Enable DNS extension{/t} +
+
+ + +
+
+ +
+
+ {t}Enable DHCP extension{/t} +
+
+ + +
+
+ +
+
+ {t}Enable mime type management{/t} +
+
+ + +
+
+ +
+
+ {t}Enable FAI release management{/t} +
+
+ + +
+
+ +
+
+ {t}Enable user netatalk plugin{/t} +
+
+ +
+
+ +
+
+ {t}Government mode{/t} +
+
+ +
+
+ +

{t}Mail settings{/t}

+ +
+
+ {t}Mail method{/t} +
+
+ +
+
+
+
+ +
+
+ {t}Vacation templates{/t} +
+
+ {if $mail_settings.vacationdir_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Use Cyrus UNIX style{/t} +
+
+ +
+
+ + +

{t}Snapshots / Undo{/t}

+ {if $generic_settings.snapshot_active == FALSE} +
+
+ {t}Enable snapshots{/t} +
+
+
+
+
+ {t}Snapshot base{/t} +
+
+ +
+
+
+
+ {t}Server{/t} +
+
+ +
+
+
+
+ {t}User{/t} +
+
+ +
+
+
+
+ {t}Password{/t} +
+
+ +
+
+
+ + {else} +
+
+ {t}Enable snapshots{/t} +
+
+
+
+
+ {t}Snapshot base{/t} +
+
+ +
+
+
+
+ {t}Server{/t} +
+
+ +
+
+
+
+ {t}User{/t} +
+
+ +
+
+
+
+ {t}Password{/t} +
+
+ +
+
+
+ {/if} +
+ + +
diff --git a/gosa-core/setup/setup_config3.tpl b/gosa-core/setup/setup_config3.tpl new file mode 100644 index 000000000..a3d2a55c3 --- /dev/null +++ b/gosa-core/setup/setup_config3.tpl @@ -0,0 +1,324 @@ +
+

{t}GOsa core settings{/t}

+ +
+
+ {t}Disable primary group filter{/t} +
+
+ + +
+
+ +
+
+ {t}Display summary in listings{/t} +
+
+ + +
+
+ +
+
+ {t}Honour administrative units{/t} +
+
+ + +
+
+ +
+
+ {t}Smarty compile directory{/t} +
+
+ +
+
+
+
+ {t}SNMP community{/t} +
+
+ +
+
+
+
+ {t}Path for PPD storage{/t} +
+
+ {if $optional.ppd_path_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Path for kiosk profile storage{/t} +
+
+ {if $optional.kioskpath_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Enable system deployment{/t} +
+
+ {if $optional.gotomasses_active == FALSE} + + + {else} + + + {/if} +
+
+ + +
+
+ {t}Network resolv hook{/t} +
+
+ {if $optional.auto_network_hook_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Mail queue script{/t} +
+
+ {if $optional.mailQueueScriptPath_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Notification script{/t} +
+
+ {if $optional.notifydir_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Enable edit locking{/t} +
+
+ {if $optional.uniq_identifier_active == FALSE} + + + {else} + + + {/if} +
+
+ +

{t}Login and session{/t}

+
+
+ {t}Login attribute{/t} +
+
+ +
+
+ +
+
+ {t}Enforce register_globals to be deactivated{/t} +
+
+ + +
+
+ +
+
+ {t}Enforce encrypted connections{/t} +
+
+ + +
+
+ +
+
+ {t}Warn if session is not encrypted{/t} +
+
+ + +
+
+ +
+
+ {t}Remember dialog filter settings{/t} +
+
+ + +
+
+ +
+
+ {t}Session lifetime{/t} +
+
+ +
+
+ +

{t}Debugging{/t}

+ +
+
+ {t}Show PHP errors{/t} +
+
+ +
+
+ + +
+
+ {t}Maximum LDAP query time{/t} +
+
+ {if $optional.max_ldap_query_time_active == FALSE} + + + {else} + + + {/if} +
+
+ +
+
+ {t}Log LDAP statistics{/t} +
+
+ + +
+
+ +
+
+ {t}Debug level{/t} +
+
+ +
+
+
+ + diff --git a/gosa-core/setup/setup_feedback.tpl b/gosa-core/setup/setup_feedback.tpl new file mode 100644 index 000000000..20fae54e6 --- /dev/null +++ b/gosa-core/setup/setup_feedback.tpl @@ -0,0 +1,144 @@ +
+ +

{$additional_info}

+ +

+  {t}Subscribe to the gosa-announce mailinglist{/t} +

+

+ {t}When checking this option, GOsa will try to connect http://oss.gonicus.de in order to subscribe you to the gosa-announce mailing list. You've to confirm this by mail.{/t} +

+ + + + + + + + + + + + + +
+ {t}Organization{/t} + + +
+ {t}Name{/t} + + +
+ {t}Mail address{/t}{$must} + + +
+ + +

 

+

+  {t}Send feedback to the GOsa project team{/t} +

+

+ {t}When checking this option, GOsa will try to connect http://oss.gonicus.de in order to submit your form anonymously.{/t} +

+ {t}Generic{/t} + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {t}Did the setup procedure help you to get started?{/t} + + {t}Yes{/t} +
+ {t}No{/t} +
+ {t}If not, what problems did you encounter{/t}: + + +
+ {t}Is this the first time you use GOsa?{/t} + + {t}Yes{/t} +
+ {t}No{/t}, + {t}I use it since{/t} + +
+ {t}What operating system / distribution do you use?{/t} + + +
+ {t}What web server do you use?{/t} + + +
+ {t}What PHP version do you use?{/t} + + +
+ +
{t}LDAP{/t} + + + + + + + + + +
+ {t}What kind of LDAP server(s) do you use?{/t} + +
{t}How many objects are in your LDAP?{/t} + +
+ +
{t}Features{/t} + + + + + + + + + +
{t}What features of GOsa do you use?{/t} + + {foreach from=$features_used item=data key=key} + + {$data.NAME}
+ {/foreach} +
{t}What features do you want to see in future versions of GOsa?{/t} + +
+
+ + diff --git a/gosa-core/setup/setup_finish.tpl b/gosa-core/setup/setup_finish.tpl new file mode 100644 index 000000000..87b6732d3 --- /dev/null +++ b/gosa-core/setup/setup_finish.tpl @@ -0,0 +1,23 @@ +
+

+ {t}Create your configuration file{/t} +

+

+ {$msg2} +

+ + chown root.{$webgroup} {$CONFIG_DIR}/{$CONFIG_FILE}
+ chmod 640 {$CONFIG_DIR}/{$CONFIG_FILE} +
+

+ +

+ {if $err_msg != ""} +

 

+
+ {t}Status: {/t} + {$err_msg} + {/if} + +
+ diff --git a/gosa-core/setup/setup_frame.tpl b/gosa-core/setup/setup_frame.tpl new file mode 100644 index 000000000..7da520583 --- /dev/null +++ b/gosa-core/setup/setup_frame.tpl @@ -0,0 +1,47 @@ + +{$php_errors} +
+ {$msg_dialogs} + +
+
+
GOsa
+
{$version}
+
+
+ {t}GOsa setup wizard{/t} +
+ +
+ +
+
+ {t}Installation{/t}  {t}Steps{/t} +
+ {$navigation} +
+ +
+
+ {$errors} + {$header} +
+
+ {$contents} + {$bottom} +
+
+
+
+
+
+ + + +
+ + + + diff --git a/gosa-core/setup/setup_language.tpl b/gosa-core/setup/setup_language.tpl new file mode 100644 index 000000000..6d1b30b98 --- /dev/null +++ b/gosa-core/setup/setup_language.tpl @@ -0,0 +1,13 @@ +
+
+

{t}Please select the preferred language{/t}

+

+ {t}At this point, you can select the site wide default language. Choosing 'automatic' will use the language requested by the browser. This setting can be overriden per user.{/t} +

+
+
+ +
+
diff --git a/gosa-core/setup/setup_ldap.tpl b/gosa-core/setup/setup_ldap.tpl new file mode 100644 index 000000000..b1ef46ee1 --- /dev/null +++ b/gosa-core/setup/setup_ldap.tpl @@ -0,0 +1,136 @@ +
+ + {if $resolve_user} + +
+

+ {t}Please choose the LDAP user to be used by GOsa{/t} +

+ + + +

 

+
+ + +
+
+ +
+ + {else} +

+ {t}LDAP connection{/t} +

+
+
+ {t}Location name{/t} +
+
+ +
+
+
+
+
{t}Connection URL{/t}
+
+
+ +
+
+
+
+ {t}TLS connection{/t} +
+
+ +
+
+
+
+ {t}Base{/t} +
+
+ {if $namingContextsCount >= 1} + + {else} + + {/if} + +
+
+

+ {t}Authentication{/t} +

+
+
+ {t}Admin DN{/t} +
+
+ + {if $append_base_to_admin_dn},{$base_to_append}{/if} + +
+
+ +
+
+
+
+  {t}Automatically append LDAP base to admin DN{/t} +
+
+ + +
+
+ {t}Admin password{/t} +
+
+ +
+
+ +

+ {t}Schema based settings{/t} +

+
+
+ {t}Use rfc2307bis compliant groups{/t} +
+
+ +
+
+ {/if} + + {if ! $resolve_user} +

+ {t}Current status{/t} +

+
+
+ {t}Information{/t} +
+
+ {$connection_status} +
+
+ {/if} + +
+ + + diff --git a/gosa-core/setup/setup_license.tpl b/gosa-core/setup/setup_license.tpl new file mode 100644 index 000000000..47e7937cc --- /dev/null +++ b/gosa-core/setup/setup_license.tpl @@ -0,0 +1,11 @@ +
+
+
+ {$License} +
+
+
+ {t}I have read the license and accept it{/t} +
+
+ diff --git a/gosa-core/setup/setup_migrate.tpl b/gosa-core/setup/setup_migrate.tpl new file mode 100644 index 000000000..a1652162b --- /dev/null +++ b/gosa-core/setup/setup_migrate.tpl @@ -0,0 +1,364 @@ +
+
+ + {if $method == "default"} +

{t}During the LDAP inspection, we're going to check for several common pitfalls that may occur when migration to GOsa base LDAP administration. You may want to fix the problems below, in order to provide smooth services.{/t} +

+ + {foreach from=$checks item=val key=key} +
+ + {if $checks.$key.ERROR_MSG} + +
+ {else} + +
+ {/if} +
{$checks.$key.TITLE}
+
+ {if $checks.$key.STATUS} +
{$checks.$key.STATUS_MSG}
+ {else} +
{$checks.$key.STATUS_MSG}
+ {/if} +
+ {if $checks.$key.ERROR_MSG} + {$checks.$key.ERROR_MSG} + {/if} +
+
+ {/foreach} +
+ + + {elseif $method == "outside_winstations"} + +

{t}Move windows workstations into a valid windows workstation department{/t}

+ + {t}This dialog allows you to move the displayed windows workstations into a valid department{/t} +
+ {t}Be careful with this tool, there may be references pointing to this workstations that can't be migrated.{/t} +
+
+ + {foreach from=$outside_winstations item=val key=key} + {if $outside_winstations.$key.selected} + + {else} + + {/if} + +  {$outside_winstations.$key.dn} + {if $outside_winstations.$key.ldif != ""} +
+
+
+								{$outside_winstations.$key.ldif}
+							
+
+
+ {/if} +
+ {/foreach} + + {t}Select all{/t} +

+ {t}Move selected windows workstations into the following GOsa department{/t} : + +
+ + +

+ + +

 

+
+ +
+ + + {elseif $method == "outside_groups"} + +

{t}Move groups into configured group tree{/t}

+ +

+ {t}This dialog allows moving a couple of groups to the configured group tree. Doing this may straighten your LDAP service.{/t} +

+

+ {t}Be careful with this option! There may be references pointing to these groups. The GOsa setup can't migrate references, so you may want to cancel the migration in this case in this case.{/t} +

+

+ {t}Move selected groups into this group tree{/t}: + +

+ + {foreach from=$outside_groups item=val key=key} + {if $outside_groups.$key.selected} + + {else} + + {/if} + +  {$outside_groups.$key.dn} + {if $outside_groups.$key.ldif != "" && $group_details} +
+
+
+{$outside_groups.$key.ldif}
+
+
+
+ {/if} +
+ {/foreach} + + + {t}Select all{/t} +
+

+ {if $group_details} + + {else} + + {/if} +

+ +

 

+
+ +   + +
+ + {elseif $method == "outside_users"} + +

{t}Move users into configured user tree{/t}

+

+ {t}This dialog allows moving a couple of users to the configured user tree. Doing this may straighten your LDAP service.{/t} +

+

+ {t}Be careful with this option! There may be references pointing to these users. The GOsa setup can't migrate references, so you may want to cancel the migration in this case.{/t} +

+

+ {t}Move selected users into this people tree{/t}: + +

+ {foreach from=$outside_users item=val key=key} + {if $outside_users.$key.selected} + + {else} + + {/if} + +  {$outside_users.$key.dn} + {if $outside_users.$key.ldif != "" && $user_details} +
+
+
+{$outside_users.$key.ldif}
+
+
+
+ {/if} +
+ {/foreach} + + {t}Select all{/t} +
+ + {if $user_details} + + {else} + + {/if} + +

 

+
+ +   + +
+ + + {elseif $method == "create_acls"} + + {if $acl_create_selected != "" && $what_will_be_done_now!=""} +
+
+{$what_will_be_done_now}
+
+
+ + + {else} +

{t}Create a new GOsa administrator account{/t}

+ +

+ {t}This dialog will automatically add a new super administrator to your LDAP tree.{/t} +

+ + + + + + + + + + + + + + + + + +
+ {t}Name{/t}:  + + System administrator +
+ {t}User ID{/t}:  + +
+
+ {t}Password{/t}:  + +
+
+ {t}Password (again){/t}:  + +
+
+ + + + +

 

+
+ + +
+ {/if} + {elseif $method == "migrate_deps"} + +

Department migration

+ +

{t}The listed departments are currenlty invisble in the GOsa user interface. If you want to change this for a couple of entries, select them and use the migrate button below.{/t}

+

{t}If you want to know what will be done when migrating the selected entries, use the 'Show changes' button to see the LDIF.{/t}

+ + {foreach from=$deps_to_migrate item=val key=key} + + {if $deps_to_migrate.$key.checked} + + {$deps_to_migrate.$key.dn} + {if $deps_to_migrate.$key.after != ""} +
+ +{t}Current{/t} +
+
+dn: {$deps_to_migrate.$key.dn}
+{$deps_to_migrate.$key.before}
+
+
+{t}After migration{/t} +
+
+dn: {$deps_to_migrate.$key.dn}
+{$deps_to_migrate.$key.after}
+
+
+
+ {/if} + {else} + + {$deps_to_migrate.$key.dn} + {/if} + +
+ {/foreach} + + {t}Select all{/t} +
+ + {if $deps_details} + + {else} + + {/if} + +

 

+ +
+ +   + +
+ {elseif $method == "migrate_users"} + +

User migration

+ +

{t}The listed users are currenlty invisble in the GOsa user interface. If you want to change this for a couple of users, just select them and use the 'Migrate' button below.{/t}

+

{t}If you want to know what will be done when migrating the selected entries, use the 'Show changes' button to see the LDIF.{/t}

+ {foreach from=$users_to_migrate item=val key=key} + + {if $users_to_migrate.$key.checked} + + {$users_to_migrate.$key.dn} + {if $users_to_migrate.$key.after != ""} +
+ +{t}Current{/t} +
+
+dn: {$users_to_migrate.$key.dn}
+{$users_to_migrate.$key.before}
+
+
+{t}After migration{/t} +
+
+dn: {$users_to_migrate.$key.dn}
+{$users_to_migrate.$key.after}
+
+
+
+ {/if} + {else} + + {$users_to_migrate.$key.dn} + {/if} +
+ {/foreach} + + {t}Select all{/t} +
+ + {if $user_details} + + {else} + + {/if} + +

 

+ +
+ +   + +
+ {/if} +
+
diff --git a/gosa-core/setup/setup_schema.tpl b/gosa-core/setup/setup_schema.tpl new file mode 100644 index 000000000..e56538b1e --- /dev/null +++ b/gosa-core/setup/setup_schema.tpl @@ -0,0 +1,40 @@ +
+

+ {t}Schema specific settings{/t} +

+
+
+ {t}Enable schema validation when logging in{/t} +
+
+ +
+
+

+ {t}Check status{/t} +

+
+ {if $failed_checks == 0} + {t}Schema check succeeded{/t} + {else} + + {t}Schema check failed{/t} + {/if} +
+
+ {foreach from=$checks item=val key=key} + {if !$checks[$key].STATUS} +
+ {if $checks[$key].IS_MUST_HAVE} + {$checks[$key].MSG} + {else} + {$checks[$key].MSG} + {/if} +
+ {/if} + {/foreach} +
+
+ diff --git a/gosa-core/setup/setup_welcome.tpl b/gosa-core/setup/setup_welcome.tpl new file mode 100644 index 000000000..e6f76c7b6 --- /dev/null +++ b/gosa-core/setup/setup_welcome.tpl @@ -0,0 +1,37 @@ +
+
+

+ {t}This seems to be the first time you start GOsa - we didn't find any configuration right now. This simple wizard intends to help you while setting it up.{/t} +

+ +

+ {t}What will the wizard do for you?{/t} +

+
    +
  • {t}Create a basic, single site configuration{/t}
  • +
  • {t}Tries to find problems within your PHP and LDAP setup{/t}
  • +
  • {t}Let you choose from a set of basic and advanced configuration switches{/t}
  • +
  • {t}Guided migration of existing LDAP trees{/t}
  • +
+

+ {t}What will the wizard NOT do for you?{/t} +

+
    +
  • {t}Find every possible configuration error{/t}
  • +
  • {t}Migrate every possible LDAP setup - create backup dumps!{/t}
  • +
+ +

+ {t}To continue...{/t} +

+

+ {t}For security reasons you need to authenticate for the installation by creating the file '/tmp/gosa.auth', containing the current session ID on the servers local filesystem. This can be done by executing the following command:{/t} +

+ + echo -n {$auth_id} > /tmp/gosa.auth + +

+ {t}Click the 'Continue' button when you've finished.{/t} +

+
+
diff --git a/plugins/addons/addressbook/address_edit.tpl b/plugins/addons/addressbook/address_edit.tpl deleted file mode 100644 index 8b51230f8..000000000 --- a/plugins/addons/addressbook/address_edit.tpl +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - -
- - - - - X - -
- - - - - - - - -
-

- -  {t}Personal{/t} -

- - - - - - - - - - - - -
- , - - -{render acl=$snACL} - , -{/render} -{render acl=$givenNameACL} - -{/render} - -
- - -{render acl=$initialsACL} - -{/render} -
- - -{render acl=$titleACL} - -{/render} -
-
-

- -  {t}Private{/t} -

- - - - - - - - - - - - - - - - - -
- -
-
-
-{render acl=$homePostalAddressACL} - -{/render} -
- - -{render acl=$homePhoneACL} - -{/render} -
- - -{render acl=$mobileACL} - -{/render} -
- - -{render acl=$mailACL} - -{/render} -
-
-

- -  {t}Organizational{/t} -

- - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - -{render acl=$oACL} - -{/render} -
- - -{render acl=$ouACL} - -{/render} -
- - -{render acl=$lACL} - -{/render} -
- - -{render acl=$postalCodeACL} - -{/render} -
- - -{render acl=$stACL} - -{/render} -
-
- - - - - - - - - - - - - - - - - -
- -
-
-
-{render acl=$postalAddressACL} - -{/render} -
- - -{render acl=$telephoneNumberACL} - -{/render} -
- - -{render acl=$facsimileTelephoneNumberACL} - -{/render} -
- - -{render acl=$pagerACL} - -{/render} -
-
-
- -

- - -

- -
- - diff --git a/plugins/addons/addressbook/address_info.tpl b/plugins/addons/addressbook/address_info.tpl deleted file mode 100644 index 3bb3a2242..000000000 --- a/plugins/addons/addressbook/address_info.tpl +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - -
{$storage_info} - - X -
- - - - - - - - - - -
-

- - {t}Personal{/t} -

- - - - - - - - - - - - - - -
- {t}Name{/t} - - {$info_sn}, {$info_givenName} -
- {t}Initials{/t} - - {$info_initials} -
- {t}Personal title{/t} - - {$info_title} -
- -
- -

- - {t}Private{/t} -

- - - - - - - - - - - - - - - - - - -
- {t}Address{/t} - - {$info_homePostalAddress} -
- {t}Phone{/t} - - {$info_homePhone} -
- {t}Mobile{/t} - - {$info_mobile} -
- {t}Email{/t} - - {$info_mail} -
- -
- -

- - {t}Organizational{/t} -

- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- {t}Company{/t} - - {$info_o} -
- {t}Department{/t} - - {$info_ou} -
- {t}City{/t} - - {$info_l} -
- {t}Postal code{/t} - - {$info_postalCode} -
- {t}Country{/t} - - {$info_st} -
- -
- - - - - - - - - - - - - - - - - - -
- {t}Address{/t} - - {$info_postalAddress} -
- {t}Phone{/t} - - {$info_telephoneNumber} -
- {t}FAX{/t} - - {$info_facsimileTelephoneNumber} -
- {t}Pager{/t} - - {$info_pager} -
-
- -
- -
diff --git a/plugins/addons/addressbook/class_addressbook.inc b/plugins/addons/addressbook/class_addressbook.inc deleted file mode 100644 index 67bb3455e..000000000 --- a/plugins/addons/addressbook/class_addressbook.inc +++ /dev/null @@ -1,835 +0,0 @@ -config= &$config; - - /* Check if there is a special ldap-sub-tree specified, instead of dc=addressbook, */ - $aoc = $this->config->search("addressbook", "LDAP_OBJECT_CLASS",array('menu')); - if ($aoc != ""){ - $this->abobjectclass = $aoc; - } - - /* Get global filter config */ - if (!is_global("phonefilter")){ - $ui = get_userinfo(); - $base = get_base_from_people($ui->dn); - $phonefilter= array( - "search_base" => $base, - "organizational" => "checked", - "global" => "checked", - "search_for" => "*", - "object_type" => "*"); - register_global("phonefilter", $phonefilter); - } - - $this->ui = get_userinfo(); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - $smarty= get_smarty(); - - /* Prevent empty variables for smarty */ - foreach($this->attributes as $atr) { - $smarty->assign($atr,""); - } - - /* Save formular information */ - $phonefilter= get_global("phonefilter"); - foreach( array("search_for", "search_base", "object_type") as $type){ - if (isset($_POST[$type])){ - $phonefilter[$type]= $_POST[$type]; - } - $this->$type= $phonefilter[$type]; - } - if (isset($_POST['search_base'])){ - foreach( array("organizational", "global") as $type){ - if (isset($_POST[$type])){ - $phonefilter[$type]= "checked"; - } else { - $phonefilter[$type]= ""; - } - } - } - - /* Search string */ - $s= $phonefilter['search_for']; - if ($s == "") { - $s= "*"; - } - if (isset($_GET['search'])){ - $s= validate(mb_substr($_GET['search'], 0, 1, "UTF8"))."*"; - if ($s == "**"){ - $s= "*"; - } - $this->search_for= $s; - $phonefilter['search_for']= $s; - } - register_global("phonefilter", $phonefilter); - - /* Assign create acl */ - $acl = $this->get_entry_acls($this->abobjectclass.",".$phonefilter['search_base']); - $smarty->assign("internal_createable", preg_match("/c/",$acl)); - $smarty->assign("internal_removeable", preg_match("/d/",$acl)); - $smarty->assign("internal_editable", preg_match("/w/",$acl)); - - /* Perform actions with CTI hook */ - if (isset($_GET['target']) - && isset($_GET['dial']) - && isset($this->config->current['CTIHOOK'])){ - - $dialmode= $_GET['dial']; - if ($dialmode == "telephoneNumber" || - $dialmode == "mobile" || - $dialmode == "homePhone"){ - - /* Get target */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat(base64_decode($_GET['target']), array('telephoneNumber', 'mobile', 'homePhone')); - $attrs= $ldap->fetch(); - if (isset($attrs["$dialmode"])){ - $target= $attrs[$dialmode][0]; - } else { - $target= ""; - } - - /* Get source */ - $ui= get_userinfo(); - $ldap->cat($ui->dn, array('telephoneNumber')); - $attrs= $ldap->fetch(); - if (isset($attrs["telephoneNumber"])){ - $source= $attrs['telephoneNumber'][0]; - } else { - $source= ""; - } - - /* Save to session */ - $_SESSION['source']= $source; - $_SESSION['target']= $target; - - /* Perform call */ - if ($target != "" && $source != ""){ - $smarty->assign("phone_image", get_template_path('images/phone.png')); - $smarty->assign("dial_info", sprintf(_("Dial from %s to %s now?"), "".$source."", "".$target."")); - return($smarty->fetch(get_template_path('dial.tpl', TRUE))); - return; - } else { - print_red (_("You have no personal phone number set. Please change that in order to perform direct dials.")); - } - } - - } - - /* Finally dial */ - if (isset($_POST['dial']) && isset($_SESSION['source']) && isset($_SESSION['target'])){ - exec ($this->config->current['CTIHOOK']." '".$_SESSION['source']."' '".$_SESSION['target']."'", $dummy, $retval); - unset($_SESSION['source']); - unset($_SESSION['target']); - } - - - /* Delete entry? */ - if (isset($_POST['delete_entry_confirm'])){ - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - - $acl = $this->get_entry_acls($this->dn); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $ldap= $this->config->get_ldap_link(); - $ldap->rmdir ($this->dn); - new log("remove","addressbook/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of addressbook entry '%s' failed."),$this->dn)); - new log("remove","addressbook/".get_class($this),$this->dn,array(),"Address book object'".$this->dn."' has been removed"); - - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this entry!")); - new log("remove","addressbook/".get_class($this),$this->dn,array(),"Warning: '".$this->ui->uid."' tried to trick address book deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - - /* Clean up */ - if (isset($_SESSION['saved_start'])){ - $_GET['start']= $_SESSION['saved_start']; - } - unset($_SESSION['show_info']); - unset($_SESSION['saved_start']); - } - - - /* Delete entry? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - } - - - /* Save address entry? */ - if (isset($_POST['save'])){ - $this->save_object(); - $this->storage_base= $_POST['storage_base']; - - /* Perform checks */ - $message= $this->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $this->save(); - - /* Clean up */ - if (isset($_SESSION['saved_start'])){ - $_GET['start']= $_SESSION['saved_start']; - } - $_SESSION['show_info']= $this->dn; - unset($_SESSION['saved_start']); - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - - /* Close info window */ - if (isset($_GET['close']) || isset($_POST['cancel'])){ - if (isset($_SESSION['saved_start'])){ - $_GET['start']= $_SESSION['saved_start']; - } - unset($_SESSION['show_info']); - unset($_SESSION['saved_start']); - } - - - /* Start address book edit mode? */ - if (isset($_GET['global'])){ - if (!isset($_SESSION['saved_start']) && isset($_GET['start'])){ - $_SESSION['saved_start']= $_GET['start']; - } - switch ($_GET['global']){ - case "add": - $this->dn= "new"; - $this->orig_cn= ""; - - /* Clean values */ - foreach ($this->attributes as $name){ - $this->$name= ""; - } - $this->saved_attributes= array(); - $this->storage_base= $this->config->current["BASE"]; - break; - - case "edit": - /* Clean values */ - foreach ($this->attributes as $name){ - $this->$name= ""; - } - $this->dn= $_SESSION['show_info']; - $this->load(); - $this->orig_cn= $this->cn; - break; - case "remove": - $this->dn= $_SESSION['show_info']; - $this->load(); - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $acl = $this->get_entry_acls($this->dn); - if(preg_match("/d/",$acl)){ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - $ui= get_userinfo(); - add_lock ($this->dn, $ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the entry %s."), $this->dn)); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this entry!")); - } - } - $_SESSION['show_info']= "ADD"; - } - - - /* Open info window */ - if (isset($_GET['show'])){ - if (!isset($_SESSION['saved_start'])){ - $_SESSION['saved_start']= $_GET['start']; - } - $this->dn = base64_decode($_GET['show']); - $this->view_logged =FALSE; - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","addressbook/".get_class($this),$this->dn); - } - $_SESSION['show_info']= base64_decode($_GET['show']); - } - - - /* Get ldap link / build filter */ - $ldap= $this->config->get_ldap_link(); - $this->telephone_list= array (); - - - /* Assemble bases - (Depending on checkboxes, we search for organisational entries or seperated - adressbook entries within dc=adressbook, ) */ - $bases= array(); - $filter= ""; - if ($phonefilter['global'] == "checked"){ - $bases[]= preg_replace("/".$this->config->current['BASE']."/", $this->abobjectclass.",".$this->config->current['BASE'], $this->search_base); - } else { - $filter= '(objectClass=gosaAccount)'; - } - if ($phonefilter['organizational'] == "checked"){ - $bases[]= $this->search_base; - } - - - /* Only display those entries that have at least on of this attributes set */ - $must_have_this = array("telephoneNumber","facsimileTelephoneNumber","mobile","homePhone","mail"); - - /* Requested attributes in ldap search */ - $attributes = array("sn", "givenName", "telephoneNumber", "facsimileTelephoneNumber", "mobile", "homePhone", "uid", "mail", "cn"); - - /* Create attribute filter part */ - $attribute_filter = ""; - foreach($attributes as $att){ - $attribute_filter .= "(".$att."=".$s.")"; - } - - /* Walk through bases an check for usable entries */ - foreach ($bases as $base){ - - $ldap->cd ($base); - - if ($phonefilter['object_type'] == '*'){ - $ldap->search ( - "(&(objectClass=person)$filter(!(objectClass=gosaUserTemplate))". // Skip templates etc .. - "(!(uid=*$))". // Skip entries with ...$ as uid - "(|".$attribute_filter."))" - ,$attributes); - } else { - $ldap->search ("(&$filter(!(uid=*$))(!(objectClass=gosaUserTemplate))". //array - "(".$phonefilter['object_type']."=$s))", $attributes); - } - - /* Walk through LDAP results */ - while ($attrs= $ldap->fetch()){ - - /* prevent empty vaiables */ - foreach($this->attributes as $atr) { - if(!isset($attrs[$atr][0])) { - $attrs[$atr][0] = ""; - } - } - - /* Check if page number was posted */ - if(!isset($_GET['start'])) { - $_GET['start']=""; - } - - /* Check if at least one attribute is specified */ - $skip = false; - - foreach($must_have_this as $attr) { - if(isset($attrs[$attr][0]) && !empty($attrs[$attr][0])){ - $skip =false; - break; - } - } - - /* Skip all attributes that we are not allowed to read */ - $any = false; - foreach($attributes as $attr){ - - $acls = $this->get_entry_acls($attrs['dn'],$attr); - if(!preg_match("/r/",$acls)){ - $attrs[$attr][0] = ""; - }else{ - $any = true; - } - } - - /* Only show lines that have set any mail or phone informations */ - if(!$skip && $any){ - - $this->telephone_list[$attrs['sn'][0].$attrs['dn']]= - - " - ". - $attrs['sn'][0].", ".$attrs['givenName'][0]. - " -   - - ".$attrs['telephoneNumber'][0]." - -   - - ".$attrs['facsimileTelephoneNumber'][0]." -   - - ".$attrs['mobile'][0]." - -   - - ".$attrs['homePhone'][0]." - -   - - - \"vcf\" - "; - - - if(preg_match("/r/",$this->get_entry_acls($attrs['dn'],"mail"))){ - if (isset($attrs['mail'][0]) && !empty($attrs['mail'][0])){ - $dest= sprintf(_("Send mail to %s"), $attrs['mail'][0]); - $this->telephone_list[$attrs['sn'][0].$attrs['dn']].= - - "". - "\"vcf\""; - } - } - $this->telephone_list[$attrs['sn'][0].$attrs['dn']].= " "; - } - } - error_reporting(E_ALL | E_STRICT); - } - - /* Sort up list */ - ksort ($this->telephone_list); - reset ($this->telephone_list); - - /* Fill template variables */ - $smarty->assign("search_for", $this->search_for); - $smarty->assign("object_type", $this->object_type); - - $this->base = $phonefilter['search_base']; - $smarty->assign("deplist", $this->get_allowed_bases()); - $smarty->assign("depselect", $this->search_base); - $smarty->assign("global", $phonefilter['global']); - $smarty->assign("organizational", $phonefilter['organizational']); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("obj_image", get_template_path('images/list_ogroup.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info.png')); - $smarty->assign("actionimage", get_template_path('images/action.png')); - $smarty->assign("launchimage", get_template_path('images/launch.png')); - - /* Generate alphabet */ - $alphabet= generate_alphabet(); - - /* Build list output */ - $output= ""; - $mod= 0; - - - /* View detailed infos */ - $smarty->assign("show_info", ""); - if (isset($_SESSION['show_info'])){ - - $range= 4; - $smarty->assign("show_info", "1"); - $smarty->assign("url", "main.php?plug=".validate($_GET['plug'])."&close=1"); - - $tmp = $this->plInfo(); - - if(isset($_POST['storage_base'])){ - $this->storage_base = $_POST['storage_base']; - } - - switch ($_SESSION['show_info']){ - - case "ADD": - - $a_bases = $this->get_allowed_bases(); - - if(!isset($a_bases[$this->storage_base])){ - $base = key($this->get_allowed_bases()); - $this->storage_base = $base; - } - - $smarty->assign ('storage_base', $this->storage_base); - $smarty->assign ('address_info', get_template_path('address_edit.tpl', TRUE)); - - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->get_entry_acls($this->abobjectclass.",".$base,$name)); - } - break; - - default: - $smarty->assign ('address_info', get_template_path('address_info.tpl', TRUE)); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->get_entry_acls($this->dn,$name)); - } - break; - } - - /* Fill variables from LDAP */ - if ($_SESSION['show_info'] != "ADD"){ - $ldap->cat($_SESSION['show_info'], $this->attributes); - $info= $ldap->fetch(); - } - foreach ($this->attributes as $name){ - - /* Skip entries we are not allowed to read */ - if(!preg_match("/r/",$this->get_entry_acls($this->dn,$name))){ - $smarty->assign("info_$name", ""); - }else - - if ($_SESSION['show_info'] != "ADD" && isset($info["$name"][0])){ - error_reporting(0); - /* Special treatment for phone attributes */ - if ($name == "mobile" || - $name == "homePhone" || - $name == "telephoneNumber"){ - $smarty->assign("info_$name", - "".$info["$name"][0].""); - } else { - $smarty->assign("info_$name", preg_replace("/\n/", "
", $info["$name"][0])); - } - error_reporting(E_ALL | E_STRICT); - } elseif ($_SESSION['show_info'] == "ADD" && isset($this->$name)) { - $smarty->assign("info_$name", $this->$name); - } else { - $smarty->assign("info_$name", "-"); - } - } - if (preg_match("/,".$this->abobjectclass.",/", $_SESSION['show_info'])){ - $storage= _("global addressbook"); - $smarty->assign("internal", 0); - } else { - $storage= _("user database"); - $smarty->assign("internal", 1); - } - if ($_SESSION['show_info'] != "ADD"){ - $smarty->assign("storage_info", sprintf(_("Contact stored in '%s'"), $storage)); - } else { - $smarty->assign("storage_info", _("Creating new entry in")); - } - } else { - - - if(isset($_POST['EntryPerPage'])){ - $this->range = $_POST['EntryPerPage']; - } - $range = $this->range; - $smarty->assign("internal", 1); - } - if (isset($_GET['start'])){ - $this->start= validate($_GET['start']); - } - foreach ($this->telephone_list as $val){ - if ($mod < $this->start) { - $mod++; - continue; - } - if ($mod >= ($this->start + $range)){ - $mod++; - break; - } - if ( ($mod++) & 1){ - $col= "style=\"background-color: #ECECEC;\""; - } else { - $col= "style=\"background-color: #F5F5F5;\""; - } - $output.= "\n$val\n"; - } - - $smarty->assign("search_result", $output); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", $alphabet); - if($range < 20){ - $smarty->assign("range_selector", range_selector(count($this->telephone_list), $this->start, $range)); - }else{ - $smarty->assign("range_selector", range_selector(count($this->telephone_list), $this->start, $range, "EntryPerPage")); - } - $tmp= array("*" => _("All"), "sn" => _("Name"), "givenName" => _("Given name"), - "telephoneNumber" => _("Work phone"), "mobile" => _("Cell phone"), - "homePhone" => _("Home phone"), "uid" => _("User ID")); - natsort($tmp); - $smarty->assign("objlist", $tmp); - - /* Show main page */ - $smarty->assign ('personal_image', get_template_path('images/addr_personal.png')); - $smarty->assign ('home_image', get_template_path('images/addr_home.png')); - $smarty->assign ('company_image', get_template_path('images/addr_company.png')); - $smarty->assign ('add_image', get_template_path('images/editpaste.png')); - $smarty->assign ('edit_image', get_template_path('images/edit.png')); - $smarty->assign ('delete_image', get_template_path('images/editdelete.png')); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - function save_object() - { - plugin::save_object(); - foreach($this->attributes as $attr){ - - /* save attributes depending on acls */ - $acl = $this->get_entry_acls($this->dn,$attr); - - if(preg_match("/w/",$acl)){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - - } - } - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* must: sn, givenName */ - if ($this->sn == ""){ - $message[]= _("The required field 'Name' is not set."); - return ($message); - } - if ($this->givenName == ""){ - $message[]= _("The required field 'Given name' is not set."); - return ($message); - } - - /* Check for valid name definition */ - if (preg_match ("/[\\\\]/", $this->sn)){ - $message[]= _("The field 'Name' contains invalid characters."); - } - if (preg_match ("/[\\\\]/", $this->givenName)){ - $message[]= _("The field 'Given name' contains invalid characters."); - } - - /* Check phone numbers */ - if (!is_phone_nr($this->homePhone)){ - $message[]= _("The field 'Phone' contains an invalid phone number."); - } - if (!is_phone_nr($this->telephoneNumber)){ - $message[]= _("The field 'Phone' contains an invalid phone number."); - } - if (!is_phone_nr($this->facsimileTelephoneNumber)){ - $message[]= _("The field 'Fax' contains an invalid phone number."); - } - if (!is_phone_nr($this->mobile)){ - $message[]= _("The field 'Mobile' contains an invalid phone number."); - } - if (!is_phone_nr($this->pager)){ - $message[]= _("The field 'Pager' contains an invalid phone number."); - } - - /* Check for reserved characers */ - if (preg_match ('/[,+"<>;]/', $this->givenName)){ - $message[]= _("The field 'Given name' contains invalid characters."); - } - if (preg_match ('/[,+"<>;]/', $this->sn)){ - $message[]= _("The field 'Name' contains invalid characters."); - } - - /* Check mail */ - if (!is_email($this->mail)){ - $message[]= _("Please enter a valid email address in 'Primary address' field."); - } - - /* Assemble cn/dn */ - $this->cn= $this->givenName." ".$this->sn; - if ($this->orig_cn != $this->cn || $this->storage_base != $this->orig_storage_base){ - $this->new_dn= $this->create_unique_dn("cn", preg_replace("/,*".$this->config->current['BASE']."$/", "", $this->storage_base).",".$this->abobjectclass.",".$this->config->current['BASE']); - if ($this->new_dn == "none"){ - $message[]= _("Cannot create a unique DN for your entry. Please fill more formular fields."); - return ($message); - } - } else { - $this->new_dn= $this->dn; - } - - return ($message); - } - - - function load() - { - /* Load base attributes */ - plugin::plugin ($this->config, $this->dn); - $this->view_logged = FALSE; - $this->storage_base= preg_replace('/^[^,]+,/', '', preg_replace('/'.$this->abobjectclass.',/', '', $this->dn)); - } - - - function save() - { - /* First use parents methods to do some basic fillup in $this->attrs */ - plugin::save (); - - $this->attrs['cn']= $this->cn; - $this->attrs['displayName']= $this->givenName." ".$this->sn; - - /* Move entry if it got another name... */ - if ($this->dn != "new" && $this->dn != $this->new_dn){ - $this->move($this->dn, $this->new_dn); - } - $this->dn= $this->new_dn; - - /* Save data. Using 'modify' implies that the entry is already present, use 'add' for - new entries. So do a check first... */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat ($this->dn,array('dn')); - if ($ldap->fetch()){ - $mode= "modify"; - } else { - $mode= "add"; - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - } - - /* Finally write data with selected 'mode' */ - $ldap->cd ($this->dn); - $this->cleanup(); - $ldap->$mode ($this->attrs); - if (show_ldap_error($ldap->get_error(), sprintf(_("Removing of addressbook entry '%s' failed."),$this->dn))){ - return (1); - } - - if($mode == "add"){ - new log("create","addressbook/".get_class($this),$this->dn, array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("modify","addressbook/".get_class($this),$this->dn, array_keys($this->attrs),$ldap->get_error()); - } - } - - - /* Return entry acls */ - function get_entry_acls($dn,$attr = "") - { - $acls = ""; - - /* Use addressbook acls */ - if(preg_match("/".normalizePreg($this->abobjectclass)."/",$dn)) { - $dn = preg_replace("/".normalizePreg($this->abobjectclass).",/","",$dn); - $acls = $this->ui->get_permissions($dn,"addressbook/addressbook",$attr); - } - - /* Use Organizational Person acls */ - else{ - $acls = $this->ui->get_permissions($dn,"users/user",$attr); - } - - return($acls); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Addressbook"), - "plDescription" => _("Addressbook entry acls"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("addons" => _("Addons")), - "plCategory" => array("addressbook" => array("objectClass" => "inetOrgPerson", "description" => _("Addressbook"))), - - "plProvidedAcls" => array( - "sn" => _("Surename"), - "givenName" => _("Given name"), - "telephoneNumber" => _("Telefon number"), - "facsimileTelephoneNumber" => _("Fax number"), - "mobile" => _("Mobile number"), - "homePhone" => _("Home phone number"), - "uid" => _("User identification"), - "mail" => _("Mail address"), - "pager" => _("Pager"), - "o" => _("Organization"), - "ou" => _("Department"), - "l" => _("Location"), - "postalAddress" => _("Postal address"), - "postalCode" => _("Postal address"), - "st" => _("State"), - "initials" => _("Initials"), - "title" => _("Title"), - "homePostalAddress" => _("Home postal address"), - "cn" => _("Common name")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/addressbook/contents.tpl b/plugins/addons/addressbook/contents.tpl deleted file mode 100644 index 004e3d2ae..000000000 --- a/plugins/addons/addressbook/contents.tpl +++ /dev/null @@ -1,127 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - {$search_result} -
{t}Name{/t}{t}Phone{/t}{t}Fax{/t}{t}Mobile{/t}{t}Private{/t}{t}Contact{/t}
- - - - - -
{$range_selector}
- - {if $show_info eq 1} - {include file=$address_info} - {/if} - -
-
-

[i]{t}Information{/t}

-
-
-

- {t}The telephone list plugin provides list and search facilities for the people in your site. You may want to specify the asterisk [*] like in 'Go*us' to find 'Gonicus'. Use the filters below to narrow down your search.{/t} -

-
-
-
-

[a]{t}Actions{/t}

-
-
-

-{if $internal_createable} -   - {t}Add entry{/t}
-{/if} - -{if $internal eq 0} - {if $internal_editable} -   - {t}Edit entry{/t}
- {/if} - {if $internal_removeable} -   - {t}Remove entry{/t}
- {/if} -{/if} -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - -
-{t}Show organizational entries{/t}
- {t}Show addressbook entries{/t}
-
- - - - - - -
- - - -
- - - - - -
- - - -
- - - - - -
- - -
- {$apply} -
-
- - - diff --git a/plugins/addons/addressbook/dial.tpl b/plugins/addons/addressbook/dial.tpl deleted file mode 100644 index b10b8db88..000000000 --- a/plugins/addons/addressbook/dial.tpl +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - -
-
 
- {$dial_info} -
 
-   - -
diff --git a/plugins/addons/addressbook/main.inc b/plugins/addons/addressbook/main.inc deleted file mode 100644 index dbfd76022..000000000 --- a/plugins/addons/addressbook/main.inc +++ /dev/null @@ -1,41 +0,0 @@ -set_acl_base($ui->dn); - $_SESSION['addressbook']->set_acl_category("addressbook"); - unset($_SESSION['show_info']); - } - $addressbook= $_SESSION['addressbook']; - - /* Execute formular */ - $display= $addressbook->execute (); - $display.= "\n"; - - /* Page header*/ - $display= print_header(get_template_path('images/addressbook.png'), _("Address book")).$display; - - /* Store changes in session */ - $_SESSION['addressbook']= $addressbook; -} -?> diff --git a/plugins/addons/addressbook/remove.tpl b/plugins/addons/addressbook/remove.tpl deleted file mode 100644 index ba3768537..000000000 --- a/plugins/addons/addressbook/remove.tpl +++ /dev/null @@ -1,18 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}This includes all addressbook data in this entry. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- -   - -

- diff --git a/plugins/addons/bugsubmitter/class_bugsubmitter.inc b/plugins/addons/bugsubmitter/class_bugsubmitter.inc deleted file mode 100644 index c9dbebda4..000000000 --- a/plugins/addons/bugsubmitter/class_bugsubmitter.inc +++ /dev/null @@ -1,8 +0,0 @@ -Bugsubmitter"; -} - -?> diff --git a/plugins/addons/bugsubmitter/main.inc b/plugins/addons/bugsubmitter/main.inc deleted file mode 100644 index 82efded1d..000000000 --- a/plugins/addons/bugsubmitter/main.inc +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/plugins/addons/godfs/class_dfsManagment.inc b/plugins/addons/godfs/class_dfsManagment.inc deleted file mode 100644 index 913b2707e..000000000 --- a/plugins/addons/godfs/class_dfsManagment.inc +++ /dev/null @@ -1,263 +0,0 @@ -config = &$config; - $this->ui = &$ui; - - } - - /* Execute is the function all plugins need. It fills the plugin with life and produces the output. */ - function execute() { - - /* Normally you would react to user input here. */ - plugin::execute(); - - $action = ""; - $s_action= ""; - $options = ""; - $regex = ""; - - $icon = 'folder.gif'; - $expandedIcon = 'folder-expanded.gif'; - $base = get_base_from_people($this->ui->dn); - $smarty= get_smarty(); - - foreach ($_POST as $key => $val) { - # delete - if (preg_match("/dfs_del.*/", $key)) { - $s_action = "del"; - $s_entry = preg_replace("/dfs_".$s_action."_/i", "", $key); - $s_entry = preg_replace("/_.*$/", "", $s_entry); - $s_entry = base64_decode($s_entry); - # edit - } elseif (preg_match("/dfs_edit.*/", $key)) { - $s_action = "edit"; - $s_entry = preg_replace("/dfs_".$s_action."_/i", "", $key); - $s_entry = preg_replace("/_.*$/", "", $s_entry); - $s_entry = base64_decode($s_entry); - # new - } elseif (preg_match("/dfs_new.*/", $key)) { - $s_action = "new"; - # back - } elseif (preg_match("/dfs_back.*/", $key)) { - $s_action = "back"; - # home - } elseif (preg_match("/dfs_home.*/", $key)) { - $s_action = "home"; - # root - } elseif (preg_match("/dfs_root.*/", $key)) { - $s_action = "root"; - } - } - - $tree = new HTML_TreeMenu(); - - if ((isset($_GET['act'])) && ($_GET['act'] == "edit_entry")) { - $s_action = "edit"; - $dfs_share = $_GET['id']; - } - - # new - if ($s_action == "new") { - $this->dn = "new"; - $this->dfstab = new dfstabs($this->config, $this->config->data['TABS']['DFSTABS'], $this->dn); - } - - # edit - if (($_SERVER['REQUEST_METHOD'] == "POST") || ($_SERVER['REQUEST_METHOD'] == "GET")) { - if ($s_action == "edit") { - - $this->dn = $dfs_share; - - if (($user = get_lock($this->dn)) != "") { - return (gen_locked_message ($user, $this->dn)); - } else { - add_lock ($this->dn, $this->ui->dn); - } - - $this->acl = get_permissions($this->dn, $this->ui->subtreeACL); - - $this->dfstab = new dfstabs($this->config, $this->config->data['TABS']['DFSTABS'], $this->dn); - $this->dfstab->set_acl($this->acl); - $this->dfstab->save_object(); - $_SESSION['objectinfo']= $this->dn; - } - } - - # save pressed - if (isset($_POST['edit_finish'])) { - $this->dfstab->last = $this->dfstab->current; - $this->dfstab->save_object(); - #$disp = $this->by_object['']; - #var_dump($disp); - - $message = $this->dfstab->check(); - - # any errors? - if (count($message) == 0) { - # write to ldap - $this->dfstab->save(); - } else { - show_errors($message); - } - } - - # cancel pressed - if (isset($_POST['edit_cancel'])) { - del_lock ($_SESSION['objectinfo']); - unset ($this->dfstab); - $this->dfstab = NULL; - $this->dn = ""; - unset($_SESSION['objectinfo']); - } - - # delete pressed - if (isset($_POST['edit_delete'])) { - - # get the current values - $this->sambasharename = $_POST['sambaShareName']; - $this->sharedescription = $_POST['description']; - $this->fileserver = $_POST['fileserver']; - $this->share = $_POST['fileservershare']; - $this->loc = $_POST['location']; - - $base = get_base_from_people($this->ui->dn); - $ou = get_ou("DFS"); - $this->basedn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->basedn); - $ldap->rmdir($this->basedn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of DFS share with dn '%s' failed."),$this->dn)); - - del_lock ($_SESSION['objectinfo']); - unset ($this->dfstab); - $this->dfstab = NULL; - $this->dn = ""; - unset($_SESSION['objectinfo']); - } - - # generate main page no tabs - - $ldap = $this->config->get_ldap_link(); - - $ou = get_ou("DFS"); - - $ldap->cd("$ou$base"); - $ldap->search(("ou=*"), array("dn")); - - if ($ldap->count() == 0) { - $message[] = _("No DFS entries found"); - show_errors ($message); - } else { - $have_tree= false; - while ($dfs = $ldap->fetch()) { - if (preg_match("/^ou=DFS.*/", $dfs["dn"])) { - $dfs_root_node = new HTML_TreeNode(array('text' => "DFS", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => false)); - $have_tree= true; - } elseif ($have_tree) { - preg_match("/^ou=(.*),/U", $dfs["dn"], $reg); - $loc = $reg[1]; - $node = $dfs_root_node->addItem(new HTML_TreeNode(array('text' => "$loc", 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - - $sub_node_ldap = $this->config->get_ldap_link(); - $sub_node_ldap->cd("ou=$loc, $ou$base"); - $sub_node_ldap->search("(objectclass=sambaShare)", array("sambaShareName", "description", "documentLocation")); - - while ($dfs_loc = $sub_node_ldap->fetch()) { - $share_name = $dfs_loc["sambaShareName"][0]; - $desc = $dfs_loc["description"][0]; - $srv_loc = preg_replace("/msdfs:/", "", $dfs_loc["documentLocation"][0]); - #$srv_loc = preg_replace("/\\/", "\\\\", $srv_loc); - $link = "main.php\?plug=".$_GET['plug']."\&id=$loc\/$share_name\&act=edit_entry"; - $share_node = &$node->addItem(new HTML_TreeNode(array('text' => "$share_name - $desc", 'link' => "$link", 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - $srv_loc_node = &$share_node->addItem(new HTML_TreeNode(array('text' => "$srv_loc", 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - } - } - } - } - - $tree->addItem($dfs_root_node); - - // Create the presentation class - $treeMenu = new HTML_TreeMenu_DHTML($tree, array('images' => 'images', 'defaultClass' => 'treeMenuDefault')); - $tree_html = $treeMenu->toHTML(); - - if ($this->dfstab === NULL) { - - if (($message = check_sizelimit()) != "") { - return ($message); - } - - $listhead = "
". - "  ". - "  ". - "  ". - "  ". - _("Base")." ". - "  
"; - - - /* Use the smarty templating engine here... */ - - $smarty->assign('tree', $tree_html); - $smarty->assign('search_image', get_template_path('images/search.png')); - $smarty->assign('infoimage', get_template_path('images/info.png')); - $smarty->assign('launchimage', get_template_path('images/launch.png')); - $smarty->assign('alphabet', generate_alphabet()); - $smarty->assign('hint', print_sizelimit_warning()); - $smarty->assign('apply', apply_filter()); - $smarty->assign('dfshead', $listhead); - - /* Let smarty fetch and process the page. Always seperate PHP and HTML as much as - you can. */ - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - /* TABS */ - - $display = $this->dfstab->execute(); - - $display .= "

\n"; - $display .= " \n"; - $display .= " \n"; - $display .= " \n"; - $display .= " \n"; - $display .= " \n"; - $display .= " \n"; - $display .= "
\n"; - $display .= " \n"; - $display .= "  \n"; - $display .= " \n"; - $display .= "
\n"; - $display .= "

\n"; - - return ($display); - - } - - function remove_lock() { - if (isset($this->dn)) { - del_lock ($this->dn); - } - } - -} -?> diff --git a/plugins/addons/godfs/class_dfsgeneric.inc b/plugins/addons/godfs/class_dfsgeneric.inc deleted file mode 100644 index 12a2ed2df..000000000 --- a/plugins/addons/godfs/class_dfsgeneric.inc +++ /dev/null @@ -1,223 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Needed values and lists */ - var $base = ""; - var $cn = ""; - - /* attribute list for save action */ - var $attributes = array(); - var $objectclasses = array(); - - function dfsgeneric(&$config, $dn) { - plugin::plugin($config, $dn); - $this->dn = $dn; - $this->orig_dn = $dn; - } - - function execute() { - /* Call parent execute */ - plugin::execute(); - - $smarty= get_smarty(); - - if (($this->dn == "new") || ($this->dn == "")) { - $smarty->assign("sambasharename", ""); - $smarty->assign("sharedescription", ""); - $smarty->assign("fileserver", ""); - $smarty->assign("fileservershare", ""); - $smarty->assign("location", ""); - $smarty->assign("dfsdescription", ""); - } else { - $ldap = $this->config->get_ldap_link(); - - $base = get_base_from_people($this->dn); - $ou = get_ou("DFS"); - - $tmp = preg_split('/\//', $this->dn, 2); - $this->loc = $tmp[0]; - $this->sambasharename = $tmp[1]; - - $ldap->cd("$ou $base"); - $ldap->search(("ou=$this->loc"), array("description")); - $dfs_desc = $ldap->fetch(); - $this->dfsdescription = $dfs_desc['description'][0]; - - $ldap->cd("ou=$this->loc, $ou $base"); - $ldap->search("(&(sambaShareName=$this->sambasharename)(objectclass=sambaShare))", array("description", "documentLocation")); - - $details = $ldap->fetch(); - $this->sharedescription = $details['description'][0]; - $tmp = preg_split('/\\\\/', $details['documentLocation'][0], 2); - - $this->fileserver = preg_replace("/msdfs:/", "", $tmp[0]); - $this->share = preg_replace("/\\\/", "", $tmp[1]); - - #var_dump($this->dn); - #echo "
\n"; - - /* Fill array */ - #$this->reload(); - $smarty->assign("sambasharename", $this->sambasharename); - $smarty->assign("sharedescription", $this->sharedescription); - $smarty->assign("fileserver", $this->fileserver); - $smarty->assign("fileservershare", $this->share); - $smarty->assign("location", $this->loc); - $smarty->assign("dfsdescription", $this->dfsdescription); - } - - /* Show main page */ - return ($smarty->fetch (get_template_path('generic.tpl', TRUE))); - #, dirname(__FILE__)))); - } - - function check() - { - plugin::check(); - $message = array(); - - ## permission - #if (chkacl($this->acl, "create") != "") { - # $message[] = _("You have no premissions to create a dfs share."); - #} - - # existance - - $ldap = $this->config->get_ldap_link(); - $base = get_base_from_people($this->ui->dn); - $ou = get_ou("DFS"); - $dn_explode = explode("/", $this->dn); - $sub_ou = $dn_explode[0]; - $sambaShareName = $dn_explode[1] . "/" . $dn_explode[2] . "/" . $dn_explode[3]; - $dn = "sambaShareName=$sambaShareName,ou=$sub_ou,$ou$base"; - $ldap->cat($dn); - $attrs = $ldap->fetch(); - - if ($this->orig_dn == "new" && !($attrs == FALSE)) { - $message[] = _("Dfs share already exists."); - } elseif ($this->orig_dn != $this->dn && !($attrs == FALSE)) { - $message[] = _("Dfs share already exists."); - } - - if ($this->dn == "new" || $this->dn == "") { - $this->sambasharename = $_POST['sambaShareName']; - $this->sharedescription = $_POST['description']; - $this->fileserver = $_POST['fileserver']; - $this->share = $_POST['fileservershare']; - $this->loc = $_POST['location']; - } - - # required fields set? - if ($this->sambasharename == "") { - $message[] = _("Required Field \"Name of dfs Share\" is not set."); - } - if ($this->sharedescription == "") { - $message[] = _("Required Field \"Description\" is not set."); - } - if ($this->fileserver == "") { - $message[] = _("Required Field \"Fileserver\" is not set."); - } - if ($this->share == "") { - $message[] = _("Required Field \"Share on fileserver\" is not set."); - } - if ($this->loc == "") { - $message[] = _("Required Field \"Location\" is not set."); - } - - return $message; - } - - function save() { - - plugin::save(); - - # get the current values - $this->sambasharename = $_POST['sambaShareName']; - $this->sharedescription = $_POST['description']; - $this->fileserver = $_POST['fileserver']; - $this->share = $_POST['fileservershare']; - $this->loc = $_POST['location']; - - # set the attribs - $this->attrs["sambaShareName"] = "$this->sambasharename,ou=$this->loc,$ou$base"; - $this->attrs["objectClass"][] = "top"; - $this->attrs["objectClass"][] = "SambaShare"; - $this->attrs["objectClass"][] = "extensibleObject"; - $this->attrs["sambaShareName"] = $this->sambasharename; - $this->attrs["description"] = $this->sharedescription; - $this->attrs["documentLocation"] = "msdfs:$this->fileserver\\\\$this->share"; - - $ldap = $this->config->get_ldap_link(); - - if ($this->dn == "new" || $this->dn == "") { - echo "new
\n"; - $base = get_base_from_people($this->ui->dn); - $ou = get_ou("DFS"); - $this->basedn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; - $ldap->cd($this->basedn); - $ldap->add($this->attrs); - } else { - # try to find entry - $base = get_base_from_people($this->ui->dn); - $ou = get_ou("DFS"); - #$dn_explode = explode("/", $this->sambasharename); - #$sub_ou = $dn_explode[0]; - #$sambaShareName = $dn_explode[1] . "/" . $dn_explode[2] . "/" . $dn_explode[3]; - $dn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; - $ldap->cat($dn); - $attrs = $ldap->fetch(); - - $this->basedn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; - $ldap->cd($this->basedn); - $nr = count($attrs); - - if (count($attrs)) { - # modify if found - $ldap->modify($this->attrs); - } else { - # add - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving dfs/generic with dn '%s' failed."),$this->basedn)); - } - } - - function save_object() { - #if (isset($_POST['base'])) { - plugin::save_object(); - #echo "base = ".$_POST['base']."
\n"; - #} -# if (chkacl($this->acl, "create") == "") { - $this->base = $_POST['base']; -# } - } - - function delete() { - - plugin::delete(); - - # get the current values - $this->sambasharename = $_POST['sambaShareName']; - $this->sharedescription = $_POST['description']; - $this->fileserver = $_POST['fileserver']; - $this->share = $_POST['fileservershare']; - $this->loc = $_POST['location']; - - $base = get_base_from_people($this->ui->dn); - $ou = get_ou("DFS"); - $this->basedn = "sambaShareName=$this->sambasharename,ou=$this->loc,$ou$base"; - echo "BASEDN: $this->basedn
\n"; - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->basedn); - $ldap->rmdir($this->basedn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing dfs/generic with dn '%s' failed."),$this->basedn)); - } - - } - diff --git a/plugins/addons/godfs/contents.tpl b/plugins/addons/godfs/contents.tpl deleted file mode 100644 index e5f2206ab..000000000 --- a/plugins/addons/godfs/contents.tpl +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - -
-
-

- {t}DFS Shares{/t} {$hint} -

-
-
- {$dfshead} -
-
-
- {$tree} - -
-
-
-

[i]{t}Information{/t}

-
-
-

- {t}This menu allows you to create, delete and edit selected dfs shares. Having a large numbers of dfs shares, you might prefer the range selectors on top of the dfs share list.{/t} -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - -
- - - -
- {$apply} -
-
- - diff --git a/plugins/addons/godfs/generic.tpl b/plugins/addons/godfs/generic.tpl deleted file mode 100644 index 4f3ded4d2..000000000 --- a/plugins/addons/godfs/generic.tpl +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - -
-

{t}DFS Properties{/t}

- - - - - - - - - - - - - - - - - - -
{$must}
{$must}
{$must}
{$must}
- -
-   - -

{t}DFS Location{/t}

- - - - - - - - - - -
{$must}
- -
- - - diff --git a/plugins/addons/godfs/main.inc b/plugins/addons/godfs/main.inc deleted file mode 100644 index 56fc3c0e4..000000000 --- a/plugins/addons/godfs/main.inc +++ /dev/null @@ -1,42 +0,0 @@ -remove_lock(); - del_lock($ui->dn); - sess_del('dfsManagment'); - } - } else { - # create dfsManagment object - if (!isset($_SESSION['dfsManagment']) || - (isset($_GET['reset']) && $_GET['reset'] == 1)) { - $_SESSION['dfsManagment'] = new dfsManagment($config, $_SESSION['ui']); - } - $dfsManagment = $_SESSION['dfsManagment']; - $output = $dfsManagment->execute(); - - # do we have to reset - if (isset($_GET['reset']) && $_GET['reset'] == 1) { - del_lock ($ui->dn); - sess_del('dfsManagment'); - } - - # create page header - if (isset($_SESSION['objectinfo'])) { - $display = print_header(get_template_path('images/dfs.png'), - _("Distributed File System Administration"), - "\"\" ".$_SESSION['objectinfo']); - } else { - $display = print_header(get_template_path('images/dfs.png'), - _("Distributed File System Administration")); - } - - $display.= $output; - - # show page - $_SESSION['dfsManagment'] = $dfsManagment; - } - -?> diff --git a/plugins/addons/godfs/tabs_dfs.inc b/plugins/addons/godfs/tabs_dfs.inc deleted file mode 100644 index ef5950ebe..000000000 --- a/plugins/addons/godfs/tabs_dfs.inc +++ /dev/null @@ -1,39 +0,0 @@ -base = $this->by_object['dfsManagment']->base; - } - - #function save_object() { - # if (isset($_POST['base'])) { - # plugin::save_object(); - # } else { - # $this->base = $_POST['base']; - # } - #} - - - - - function check($ignore_account= FALSE) { - return (tabs::check(TRUE)); - } - - function save($ignore_account= FALSE) - { - $baseobject = $this->by_object['dfsManagment']; - return tabs::save(TRUE); - } - - function del() { - $baseobject = $this->by_object['dfsManagment']; - return tabs::delete(TRUE); - } - -} - -?> diff --git a/plugins/addons/gotomasses/class_divListMasses.inc b/plugins/addons/gotomasses/class_divListMasses.inc deleted file mode 100644 index f32f76b51..000000000 --- a/plugins/addons/gotomasses/class_divListMasses.inc +++ /dev/null @@ -1,170 +0,0 @@ -parent = $parent; - $this->ui = get_userinfo(); - $this->SetSummary(_("List of system deployment tasks")); - $this->SetHeadpageMode(); - $this->EnableCloseButton(FALSE); - $this->EnableSaveButton(FALSE); - $this->SetInformation(_("This menu allows you to add, remove and change the properties of system deployment tasks.")); - - foreach($this->parent->get_actions() as $name => $desc){ - $this->$name = TRUE; - $this->AddCheckBox($name,sprintf(_("Display entries with action %s."),$desc), - sprintf(_("Display entries with action %s."),$desc),TRUE); - } - $plug = $_GET['plug']; - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>""._("#")."", - "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>""._("Target")." / ". - ""._("Task")."")); - $this->AddHeader(array("string"=>""._("Schedule")."", - "attach"=>"style='width:100px;'")); - $this->AddHeader(array("string"=>""._("Type")."", - "attach"=>"style='width:80px;'")); - $this->AddHeader(array("string"=>_("Action"), - "attach"=>"style='border-right:0px;width:120px;'")); - } - - function GenHeader() - { - - /* Display add button if allowed */ - $header = "
"; - if($this->parent->acl_is_createable()){ - $header .= " "; - } - - /* Display add button if allowed */ - if($this->parent->acl_is_removeable()){ - $header .= " "; - } - - /* Add priority options */ - if(preg_match("/w/",$this->parent->getacl(""))){ - $header .= " "; - $header .= " "; - $header .= " "; - $header .= " "; - } - $header .= "
"; - - /* Create divlist */ - $this->SetListHeader($header); - - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - - function setEntries($tasks) - { - /* Create edit link */ - $plug = $_GET['plug']; - $edit_link = ""; - - /* Create action filter array, to sort out those actions we do not want to see */ - $allowed_action = array(); - foreach($this->parent->get_actions() as $name => $desc){ - if($this->$name){ - $allowed_action[] = $name; - } - } - - $colors[0] = "#DDDDDD"; - $colors[1] = "#EEEEEE"; - $c_keys = array(); - $last_c = 0; - if($this->parent->sort_dir=="down"){ - $last_c = !$last_c; - } - - foreach($tasks as $key => $task){ - - /* Skip unchecked actions */ - if(!in_array($task['Action'],$allowed_action)){ - continue; - } - - /* Handle coloring */ - $color=""; - if($this->parent->sort_by == "TaskID"){ - if(!in_array($task['TASK_ID'],$c_keys)){ - $c_keys[] = $task['TASK_ID']; - $last_c = !$last_c; - } - $color = "background-color: ".$colors[$last_c]; - } - - /* Create actions */ - $id = $task['ID']; - $queue_pos = $task['Queue_Position']; - $prio_actions = " "; - $prio_actions.= " "; - $prio_actions.= " "; - $prio_actions.= " "; - $action = ""; - if($this->parent->acl_is_removeable()){ - $action.= ""; - } - - $display = preg_replace(array("/%id%/","/%str%/"),array($id,$this->parent->target_to_string($task)),$edit_link); - $display2= $this->parent->get_additional_entry_informations($task); - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;".$color."'"); - $field0a= array("string" => $queue_pos ,"attach" => "style='width:20px;".$color."'"); - $field1 = array("string" => $display, - "attach" => "style='".$color."'"); - $field1a= array("string" => $display2, - "attach" => "style='".$color.";width:80px;'"); - $field2 = array("string" => $this->parent->time_to_string($task),"attach" => "style='".$color.";width:100px;'"); - $field3 = array("string" => $this->parent->action_to_string($task),"attach" => "style='".$color.";width:80px;'"); - $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'"); - $this->AddElement(array($field0,$field0a,$field1,$field1a,$field2,$field3,$field4)); - } - } - - - function Save() - { - MultiSelectWindow :: Save(); - } - - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/gotomasses/class_goto_task.inc b/plugins/addons/gotomasses/class_goto_task.inc deleted file mode 100644 index d53a4c2b4..000000000 --- a/plugins/addons/gotomasses/class_goto_task.inc +++ /dev/null @@ -1,485 +0,0 @@ -parent = &$parent; - - /* Intialize plugin */ - $this->config = &$config; - if(count($data)){ - $tmp = $this->get_array_values(); - foreach($this->attributes as $attr){ - if(!isset($data[$attr])){ - trigger_error("Missing parameter: '".$attr."' for goto_task contruction."); - }else{ - $this->$attr = $data[$attr]; - } - } - }else{ - $this->new = TRUE; - } - - if(!empty($this->Zone) && !preg_match("/^\"\"$/",$this->Zone)){ - $this->configure_dns = TRUE; - } - if(!empty($this->Section) && !preg_match("/^\"\"$/",$this->Section)){ - $this->configure_dhcp = TRUE; - } - - /* Set dns and dhcp attributes */ - foreach(getAvailableZones($this->config) as $zone){ - $name = preg_replace("#^[^/]+/#","",$zone); - $this->Zones[$name] = $zone; - } - $this->Sections = $this->get_dhcp_sections(); - - /* Create ogroup select list */ - $this->OGroups = array("\"\"" => "["._("Keep current")."]"); - $this->OGroups = array_merge($this->OGroups,$this->parent->get_object_groups()); - - /* Prepare list of available actions */ - $this->Actions = $this->parent->get_actions(); - } - - - function execute() - { - /******** - * Handle Posts - ********/ - - /* Handle Target options */ - foreach($_POST as $name => $value){ - if(preg_match("/^remove_/",$name)){ - $value = preg_replace("/^remove_([0-9]*)_(x|y)$/i","\\1",$name); - if(isset($this->Target[$value]) && $this->Action != "initial_install"){ - unset($this->Target[$value]); - }elseif(isset($this->Initial_Target[$value]) && $this->Action == "initial_install"){ - unset($this->Initial_Target[$value]); - } - } - } - - if($this->Action != "initial_install"){ - - /* Add target */ - if($this->ID == 0 && isset($_POST['add_target']) && !empty($_POST['target_text'])){ - $target = get_post("target_text"); - if($this->is_valid_target($target) && !in_array($target,$this->Target)){ - $this->Target[] = $target; - }else{ - print_red(_("You must specify a valid MAC address or host name.")); - } - } - }else{ - - /* Add target */ - if($this->ID ==0 && isset($_POST['add_target']) && !empty($_POST['task_MAC'])){ - $MAC = $_POST['task_MAC']; - $NAME= ""; - $IP = ""; - $DNS = ""; - $DHCP = ""; - if(isset($_POST['task_Name'])){ - $NAME = $_POST['task_Name']; - } - if(isset($_POST['task_IP']) && is_ip($_POST['task_IP'])){ - $IP = $_POST['task_IP']; - } - if(isset($_POST['configure_dns']) && isset($_POST['Zone']) && isset($this->Zones[$_POST['Zone']])){ - $DNS = $_POST['Zone']; - } - if(isset($_POST['configure_dhcp']) && isset($_POST['Section']) && isset($this->Sections[$_POST['Section']])){ - $DHCP = $_POST['Section']; - } - if(is_mac($MAC)){ - $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME); - } - } - } - - /* Add via csv */ - if($this->ID == 0 && isset($_FILES['import_file'])){ - $file = $_FILES['import_file']['tmp_name']; - if(file_exists($file) && is_readable($file)){ - $str =""; - $fp = fopen($file,"r"); - while(!feof($fp)){ - $line = fgets($fp,512); - $tmp = preg_split("/(,|;)/",$line); - - $MAC = $IP = $NAME; - if(isset($tmp[0])){ - $MAC = trim($tmp[0]); - } - if(isset($tmp[1])){ - $IP = trim($tmp[1]); - } - if(isset($tmp[2])){ - $NAME = trim($tmp[2]); - } - if(is_mac($MAC)){ - $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME); - } - } - } - } - - /******** - * Add target from list - ********/ - - /* If add from list is was requsted, display this list */ - if(isset($_POST['add_from_list'])){ - $this->dialog = new target_list($this->config,$this->Target); - } - - /* Save selected objects as target */ - if(isset($_POST['SaveMultiSelectWindow']) && is_object($this->dialog)){ - $this->dialog->save_object(); - $ret = $this->dialog->save(); - foreach($ret as $entry){ - $this->Target[] = $entry['cn'][0]; - } - $this->dialog = FALSE; - } - - /* Cancel object listing */ - if(isset($_POST['CloseMultiSelectWindow'])){ - $this->dialog = FALSE; - } - - /* Display object Listing */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - /******** - * Display this plugin - ********/ - - $divlist = new divlist("goto_task"); -# $divlist->SetPluginMode(); - $divlist->setHeight(200); - $divlist->SetWidth("100%"); - $divlist->SetEntriesPerPage(0); - - $acl_target = $this->parent->getacl("Target"); - if(preg_match("/w/i",$acl_target)){ - $field_del = array("string" => "" , - "attach" => "style='width:44px;border-right:0px;'"); - }else{ - $field_del = array("string" => "", - "attach" => "style='width:44px;border-right:0px;'"); - } - - /* Add entries to divlist */ - if($this->Action == "initial_install"){ - $divlist->SetHeader(array( - array("string" => _("Target systems") ,"attach" => "style='width:120px;'"), - array("string" => _("IP") , "attach" => "style='width:90px;'"), - array("string" => _("Name") , "attach" => "style='width:150px;'"), - array("string" => _("Actions") , "attach" => "style='width:44px;border-right:0px;text-align:right;'"))); - foreach($this->Initial_Target as $key => $target){ - $field1 = array("string" => $target['MAC'] ,"attach" => "style='width:120px;'"); - $field2 = array("string" => $target['IP'] ,"attach" => "style='width:90px;'"); - $field3 = array("string" => $target['NAME'] ,"attach" => "style='width:150px;'"); - $divlist->AddEntry(array($field1,$field2,$field3,preg_replace("/%KEY%/",$key,$field_del))); - } - }else{ - $divlist->SetHeader(array( - array("string" => "Target", "attach" => "style=''"), - array("string" => "Actions" , "attach" => "style='width:44px;border-right:0px;text-align:right;'"))); - foreach($this->Target as $key => $target){ - $field1 = array("string" => $target); - $divlist->AddEntry(array($field1,preg_replace("/%KEY%/",$key,$field_del))); - } - } - - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr."ACL", $this->parent->getacl($attr)); - $smarty->assign($attr,$this->$attr); - } - - $smarty->assign("Zones", $this->Zones); - $smarty->assign("Sections", $this->Sections); - - $smarty->assign("ID",$this->ID); - - $smarty->assign("Zone", $this->Zone); - $smarty->assign("Section", $this->Section); - - $smarty->assign("configure_dhcp", $this->configure_dhcp); - $smarty->assign("configure_dns", $this->configure_dns); - - $tmp = $this->get_array_values(); - $smarty->assign("JS" , $_SESSION['js']); - $smarty->assign("Minutes" , $tmp['Minute']); - $smarty->assign("Hours" , $tmp['Hour']); - $smarty->assign("Days" , $tmp['Day']); - $smarty->assign("Months" , $tmp['Month']); - $smarty->assign("Weekdays", $tmp['Weekday']); - $smarty->assign("OGroups" , $this->OGroups); - $smarty->assign("Actions" , $this->Actions); - $smarty->assign("Target_list" , $divlist->DrawList()); - $smarty->assign("new" , $this->new); - return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE))); - } - - - function create_tree($arr,$base,$current = "") - { - $ret = array(); - foreach($arr as $r => $name){ - $base_part = str_replace($base,"",$r); - if(preg_match("/^[a-z]*=".normalizePreg($name)."(|,)$/i",$base_part)){ - $ret[$r] = $current.$name; - $tmp = $this->create_tree($arr,$r,$current.". "); - foreach($tmp as $sub_key => $sub_name){ - $ret[$sub_key] = $sub_name; - } - } - } - return($ret); - } - - - - function get_dhcp_sections() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=dhcpService)",array("dhcpPrimaryDN")); - - $tmp = array(); - $tmp2 = array(); - - $dhcp_dns = array(); - while($attr = $ldap->fetch()){ - $dhcp_dns[$attr['dn']] = $attr['dhcpPrimaryDN'][0]; - } - - foreach($dhcp_dns as $key => $pri_dns){ - $ldap->cat($pri_dns,array("cn")); - $tmp = $ldap->fetch(); - $dhcp_dns[$key] = $tmp['cn'][0]; - } - - foreach($dhcp_dns as $dn => $cn){ - $ldap->cd($dn); - $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpGroup)". - "(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork))",array("cn")); - $tmp = array(); - while($attr = $ldap->fetch()){ - $tmp[$attr['dn']] = $attr['cn'][0]; - } - $tmp2 = $this->create_tree($tmp,preg_replace("/^[^,]+,/i","",$dn),"(".$cn.") "); - } - $ret = array(); - foreach($tmp2 as $key => $label){ - $ret[$tmp[$key]] = $label; - } - return($ret); - } - - - /* check given values */ - function check() - { - $message = plugin::check(); - $tmp = array( - "OGroup" => _("Object group") ,"Minute" => _("Minute"), - "Hour" => _("Hour") ,"Day" => _("Day"), - "Month" => _("Month") ,"Weekday"=> _("Week day"), - "Action" => _("Action") ,"Comment"=> _("Description")); - - foreach($tmp as $name => $desc){ - if(empty($this->$name) && $this->$name != 0){ - $message[] = sprintf(_("The given value for attribute '%s' is invalid."),$desc); - } - } - if(count($this->Target) == 0 && $this->Action != "initial_install"){ - $message[] = sprintf(_("You must specify at least one target")); - } - if(count($this->Initial_Target) == 0 && $this->Action == "initial_install"){ - $message[] = sprintf(_("You must specify at least one target")); - } - return($message); - } - - - /* Map acl function, to be able to use plugin::save_object() */ - function acl_is_writeable($attribute,$skip_write = FALSE) - { - return($this->parent->acl_is_writeable($attribute,$skip_write)); - } - - - function save_object() - { - if(isset($_POST['goto_task_posted'])){ - - if($this->Action == "initial_install"){ - if(isset($_POST['configure_dns'])){ - $this->configure_dns = TRUE; - if(isset($_POST['Zone'])){ - $this->Zone = get_post("Zone"); - } - }else{ - $this->Zone = "\"\""; - $this->configure_dns = FALSE; - } - - if(isset($_POST['configure_dhcp'])){ - $this->configure_dhcp = TRUE; - if(isset($_POST['Section'])){ - $this->Section = get_post("Section"); - } - }else{ - $this->configure_dhcp = FALSE; - $this->Section = "\"\""; - } - } - plugin::save_object(); - } - } - - - /* Check if given target is vald. - * It must either be a valid MAC address or an existing object group - */ - function is_valid_target($str) - { - if(is_mac($str)){ - return(TRUE); - }else{ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClassgosaGroupOfNames)(cn=".$str."))",array("cn")); - if($ldap->count()){ - return(TRUE); - } - } - } - - function save() - { - $tmp = array(); - foreach($this->attributes as $attr){ - $tmp[$attr] = $this->$attr; - } - - if($this->Action != "initial_install" || !$this->configure_dns){ - $tmp['Zone'] = "\"\""; - } - if($this->Action != "initial_install" || !$this->configure_dhcp){ - $tmp['Section'] = "\"\""; - } - return($tmp); - } - - - /* Return values for listboxes. - */ - function get_array_values() - { - $ret = array(); - - /* Create minute array */ - $Minute = array( "*" => "*", - "*/1" => "*/1", - "*/3" => "*/3", - "*/5" => "*/5", - "*/10" => "*/10", - "*/15" => "*/15", - "*/30" => "*/30", - "*/45" => "*/45", - "*/60" => "*/60"); - for($i = 0; $i < 60 ; $i ++){ - $Minute[$i] = $i; - } - - /* Create hour array */ - $Hour = array( "*" => "*"); - for($i = 1 ; $i < 24 ; $i ++ ){ - $Hour["*/".$i] = "*/".$i; - } - for($i = 0 ; $i < 24 ; $i ++ ){ - $Hour[$i] = $i; - } - - /* Create hour array */ - $Day = array( "*" => "*"); - for($i = 1 ; $i < 32 ; $i ++ ){ - $Day["*/".$i] = "*/".$i; - } - for($i = 1 ; $i < 32 ; $i ++ ){ - $Day[$i] = $i; - } - - /* Create month array */ - $Month = array( "*" => "*"); - for($i = 1 ; $i <= 12 ; $i ++ ){ - $Month["*/".$i] = "*/".$i; - } - for($i = 1 ; $i <= 12 ; $i ++ ){ - $Month[$i] = $i; - } - - /* Create week day array */ - $Weekday = array( "*" => "*"); - for($i = 1 ; $i <= 7 ; $i ++ ){ - $Weekday["*/".$i] = "*/".$i; - } - for($i = 0 ; $i <= 7 ; $i ++ ){ - $Weekday[$i] = $i; - } - - foreach(array("Minute","Weekday","Hour","Day","Month") as $var){ - $ret[$var] = $$var; - } - return($ret); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/gotomasses/class_gotomasses.inc b/plugins/addons/gotomasses/class_gotomasses.inc deleted file mode 100644 index adf221859..000000000 --- a/plugins/addons/gotomasses/class_gotomasses.inc +++ /dev/null @@ -1,431 +0,0 @@ -config= &$config; - $this->divlist = new divListMasses($this->config,$this); - $this->o_queue = new hostActionQueue(&$config); - } - - - function execute() - { - $smarty = get_smarty(); - /************ - * Handle posts - ************/ - - $s_entry = $s_action = ""; - $arr = array( - "/^prio_top_/" => "prio_top", - "/^prio_increase_/" => "prio_increase", - "/^prio_decrease_/" => "prio_decrease", - "/^prio_bottom_/" => "prio_bottom", - - "/^multiple_prio_top_/" => "mprio_top", - "/^multiple_prio_increase_/" => "mprio_increase", - "/^multiple_prio_decrease_/" => "mprio_decrease", - "/^multiple_prio_bottom_/" => "mprio_bottom", - - "/^edit_task_/"=>"edit","/^remove_task_/"=>"remove", - "/^new_task_/"=>"new_task","/^remove_multiple_task_/" => "remove_multiple"); - foreach($arr as $regex => $action){ - foreach($_POST as $name => $value){ - if(preg_match($regex,$name)){ - $s_action = $action; - $s_entry = preg_replace($regex,"",$name); - $s_entry = preg_replace("/_(x|y)$/","",$s_entry); - } - } - } - - /* Edit posted from list link */ - if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){ - $s_action = "edit"; - $s_entry = $_GET['id']; - } - - /************ - * REMOVE - ************/ - - if(preg_match("/^mprio_/",$s_action) || preg_match("/^prio_/",$s_action)){ - - switch($s_action){ - case 'mprio_top' : foreach($this->list_get_selected_items() as $id ){ - $this->o_queue->max_entry_priority($id); - } - break; - case 'mprio_increase' : foreach($this->list_get_selected_items() as $id ){ - $this->o_queue->increase_entry_priority($id); - } - break; - case 'mprio_decrease' : foreach($this->list_get_selected_items() as $id ){ - $this->o_queue->decrease_entry_priority($id); - } - break; - case 'mprio_bottom' : foreach($this->list_get_selected_items() as $id ){ - $this->o_queue->min_entry_priority($id); - } - break; - case 'prio_top' : $this->o_queue->max_entry_priority($s_entry);break; - case 'prio_increase' : $this->o_queue->increase_entry_priority($s_entry);break; - case 'prio_decrease' : $this->o_queue->decrease_entry_priority($s_entry);break; - case 'prio_bottom' : $this->o_queue->min_entry_priority($s_entry);break; - default : trigger_error("Undefined priority setting used."); - } - if($this->o_queue->is_error()){ - print_red($this->o_queue->get_error()); - } - } - - /************ - * REMOVE - ************/ - - /* Remove multiple */ - if($s_action == "remove_multiple" || $s_action == "remove"){ - - if(!$this->acl_is_removeable()){ - print_red(_("You are not allowed to remove a task.")); - }else{ - - if($s_action == "remove"){ - $ids = array($s_entry); - }else{ - $ids = $this->list_get_selected_items(); - } - - - $this->ids_to_remove = $ids; - $tmp = ""; - foreach($this->ids_to_remove as $key => $id){ - if($this->o_queue->id_exists($id)){ - $task = $this->o_queue->get_entry($id); - $tmp.= "\n".$this->target_to_string($task); - }else{ - unset($this->ids_to_remove[$key]); - } - } - $smarty->assign("multiple", TRUE); - $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),"
".$tmp."
")); - $this->current = $s_entry; - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - /* Remove specified tasks */ - if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){ - foreach($this->ids_to_remove as $id){ - if($this->o_queue->id_exists($id)){ - $this->o_queue->remove_entry($id); - } - } - $this->save(); - } - - /* Remove aborted */ - if(isset($_POST['delete_cancel'])){ - $this->ids_to_remove = array();; - } - - - /************ - * EDIT - ************/ - - /* Edit selected entry */ - if($s_action == "edit"){ - $entry = $this->o_queue->get_entry($s_entry); - if($entry){ - $this->dialog = new goto_task($this->config,$this,$entry); - $this->current = $s_entry; - } - } - - /* New entry */ - if($s_action== "new_task" && $this->acl_is_createable()){ - $this->dialog = new goto_task($this->config,$this); - $this->current = -1; - } - - /* Close dialog */ - if(isset($_POST['close_goto_task'])){ - $this->dialog = FALSE; - $this->current = -1; - } - - /* Close dialog */ - if((isset($_POST['save_goto_task']) || isset($_POST['apply_goto_task'])) && is_object($this->dialog) ){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - - if($this->o_queue->id_exists($this->current)){ - $this->o_queue->update_entry($this->current,$this->dialog->save()); - }else{ - $tmp = $this->dialog->save(); - $tmp2= array(); - $targets =$tmp['Target']; - foreach($targets as $target){ - $tmp['Target'] = array($target); - $tmp2[] = $tmp; - } - if(!$this->o_queue->add_multiple($tmp2)){ - print_red($this->o_queue->get_error()); - } - } - if(!isset($_POST['apply_goto_task'])){ - $this->dialog = FALSE; - $this->current = -1; - } - $this->save(); - } - } - - /* Display dialogs if currently opened */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - /************ - * Handle Divlist - ************/ - - $this->divlist->execute(); - $this->divlist->SetEntries($this->get_queue_entries()); - $str = - ""; - return($str.$this->divlist->Draw()); - } - - - function get_queue_entries() - { - if(!$this->o_queue->load()){ - print_red("ERROR:".$this->o_queue->get_error()); - return(array()); - } - - $queue_pos = 1; - $tasks = array(); - $ret = array(); - while($entry = $this->o_queue->fetch()){ - $task = $entry['TASK_ID']; - if(!isset($tasks[$task])){ - $tasks[$task] = dechex(rand(100,240)).dechex(rand(100,240)).dechex(rand(100,240)); - } - $entry['Queue_Position'] = $queue_pos; - $entry['color'] = $tasks[$task]; - $ret[]= $entry; - $queue_pos ++; - } - - /* Sort entries */ - $simple_map = array("QueuePosition" => "Queue_Position", - "Action" => "Action", - "TaskID" => "TASK_ID"); - $sort_arr = array(); - if(isset($simple_map[$this->sort_by])){ - foreach($ret as $id => $entry){ - $sort_arr[$entry[$simple_map[$this->sort_by]]][] = $id; - } - } - if($this->sort_by == "TargetName"){ - foreach($ret as $id => $entry){ - $name = $this->target_to_string($entry); - $sort_arr[$name][] = $id; - } - } - if($this->sort_by == "Schedule"){ - foreach($ret as $id => $entry){ - $name = $entry['Minute'].$entry['Hour'].$entry['Day'].$entry['Month'].$entry['Weekday']; - $sort_arr[$name][] = $id; - } - } - if($this->sort_dir == "up"){ - ksort($sort_arr); - }else{ - krsort($sort_arr); - } - $ret2 = array(); - foreach($sort_arr as $key => $entries){ - foreach($entries as $entry_id){ - $ret2[] = $ret[$entry_id]; - } - } - return($ret2); - } - - - function get_additional_entry_informations($data) - { - $i = rand(0,3); - if($i == 0){ - return("
 
"); - } - if($i == 1){ - return("Failed"); - } - if($i == 1){ - return("OK"); - } - return("-"); - } - - - function target_to_string($data) - { - $ret = ""; - if($data['Action'] == "initial_install"){ - foreach($data['Initial_Target'] as $target){ - $ret .= $target['MAC'].", "; - } - }else{ - foreach($data['Target'] as $target){ - $ret .= $target.", "; - } - } - return(preg_replace("/, $/","",$ret)); - } - - - function time_to_string($data) - { - return($data['Minute']." ".$data['Hour']." ".$data['Day']." ".$data['Month']." ".$data['Weekday']); - } - - - function action_to_string($data) - { - $tmp = $this->get_actions(); - if(isset($tmp[$data['Action']])){ - return($tmp[$data['Action']]); - }else{ - return(_("Unknown")); - } - } - - - function save_object() - { - $this->divlist->save_object(); - $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID"); - if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){ - $sort = $_GET['sort']; - if($this->sort_by == $sort){ - if($this->sort_dir == "up"){ - $this->sort_dir = "down"; - }else{ - $this->sort_dir = "up"; - } - } - $this->sort_by = $sort; - } - } - - - /* Return list of object groups */ - function get_object_groups() - { - $ret = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn")); - while($attrs = $ldap->fetch()){ - $ret[$attrs['cn'][0]] = $attrs['cn'][0]; - } - return($ret); - } - - - function save() - { - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function get_actions() - { - /* Prepare list of available actions */ - $actions = array( "reboot" => _("Reboot"), - "localboot" => _("Localboot"), - "halt" => _("Halt system"), - "initial_install" => _("Initial installation"), - "update" => _("Update"), - "reinstall" => _("(Re)Install"), - "rescan" => _("Rescan"), - "wake" => _("Wake"), - "memcheck" => _("Memory check")); - return($actions); - } - - - static function plInfo() - { - return (array( - "plShortName" => _("System mass deployment"), - "plDescription" => _("Provide a mechanism to automatically activate a set of systems"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("addon"), - "plCategory" => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))), - "plProvidedAcls" => array("Comment" => _("Description"), - "Action" => _("Action"), - "Day" => _("Day"), - "Minute" => _("Minute"), - "Hour" => _("Hour"), - "Month" => _("Month"), - "Weekday" => _("Week day"), - "Target" => _("Target")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/gotomasses/class_target_list.inc b/plugins/addons/gotomasses/class_target_list.inc deleted file mode 100644 index 6ecd300ef..000000000 --- a/plugins/addons/gotomasses/class_target_list.inc +++ /dev/null @@ -1,303 +0,0 @@ -AddCheckBox */ - var $ogroups ; - var $servers ; - var $workstations ; - - - /* Subsearch checkbox */ - var $SubSearch ; - var $IPMatch ; - var $parent ; - var $ui ; - - - function target_list(&$config,$Targets_used) - { - MultiSelectWindow::MultiSelectWindow($config, "Targetselection", array("ogroup","gotomasses")); - - $this->Targets_used = $Targets_used; - - $this->SetInformation( _("Select the target objects for your scheduled action.")); - $this->SetTitle( _("Available targets")); - $this->SetSummary( _("Available targets")); - $this->SetHeadpageMode(FALSE); - - /* set Page header */ - $chk = ""; - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Object name"), "attach" => "style=''")); - - /* Text ,Value, Name, Is selected */ - $this->AddCheckBox("ogroups", _("Select to see object groups"), _("Show object groups"), true); - $this->AddCheckBox("servers", _("Select to see servers") , _("Show servers"), true); - $this->AddCheckBox("workstations", _("Select to see workstations"),_("Show workstations"), true); - - /* Add SubSearch checkbox */ - $this->AddCheckBox(SEPERATOR); - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - $this->AddCheckBox("IPMatch", _("Select to search for a specific IP range only"), _("Match IP range"), false); - - /* Name,Text,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true); - $this->AddRegex ("IP_start", _("IP range start"), "0.0.0.0" , true); - $this->AddRegex ("IP_end", _("IP range end"), "255.255.255.255" , true); - $this->EnableAplhabet(TRUE); - } - - - function GenHeader() - { - $options= ""; - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("ogroups"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get copy & paste icon */ - $acls = $ui->get_permissions($this->selectedBase,"ogroups/ogroup"); - $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* Add department selector */ - $listhead .= _("Base")." ". - "  "; - $listhead .="
"; - - $this->SetListHeader($listhead); - } - - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - $this->reload(); - $this->SetEntries($this->list); - return($this->Draw()); - } - - - function SetEntries($list) - { - /* Add Copy & Paste buttons if copy&paste is enabled - */ - // Defining Links - $linkopen = "%s"; - $editlink = "%s"; - - $ui = get_userinfo(); - - // Assigning ogroups - foreach($list as $key => $val){ - - if(in_array($val['cn'][0],$this->Targets_used) || - isset($val['macAddress'][0]) && in_array($val['macAddress'][0],$this->Targets_used)) continue; - - $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; - if(!isset($val['description'][0])){ - $desc = ""; - }else{ - $desc = " - [ ".$val['description'][0]." ]"; - } - if(!isset($val['ipHostNumber'][0])){ - $desc.= ""; - }else{ - $desc.= " - ".$val['ipHostNumber'][0].""; - } - - - $img ="Hmm"; - if(in_array("goServer",$val['objectClass'])){ - $img = ""._("Server").""; - }elseif(in_array("gotoWorkstation",$val['objectClass'])){ - $img = ""._("Workstation").""; - }elseif(in_array("gosaGroupOfNames",$val['objectClass'])){ - $img = ""._("Object group").""; - } - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => $img, - "attach" => "style='text- align:center;width: 20px;'"); - $field2 = array("string" => $val['cn'][0].$desc, - "attach" => "style='border-right:0px;' ".$title); - - $this->AddElement(array($field0,$field1,$field2)); - } - } - - - function save() - { - $ret = array(); - $items = $this->list_get_selected_items(); - foreach($items as $item){ - $ret[] = $this->list[$item]; - } - return($ret); - } - - - function save_object() - { - MultiSelectWindow::save_object(); - } - - - function reload() - { - /* Set base for all searches && initialise some vars */ - $this->list= array(); - $base = $this->selectedBase; - $filter = ""; - $Regex = $this->Regex; - $IP_start = $this->IP_start; - $IP_end = $this->IP_end; - - if($this->IPMatch){ - if(!is_ip($IP_start)){ - print_red(_("Please specify a valid IP range.")); - return; - } - if(!is_ip($IP_end)){ - print_red(_("Please specify a valid IP range.")); - return; - } - } - - - $chk = array( - "ogroups" => "(&(objectClass=gosaGroupOfNames)(|(gosaGroupObjects=*S*)(gosaGroupObjects=*W*)))" , - "servers" => "(objectClass=goServer)" , - "workstations" => "(objectClass=gotoWorkstation)"); - - /* Create filter */ - foreach($chk as $chkBox => $FilterPart){ - if($this->$chkBox){ - $filter .= $FilterPart; - } - } - $filter= "(&(cn=".$Regex.")(|".$filter."))"; - - if($this->SubSearch){ - $res= get_list($filter, array("ogroups","workstations","servers"), $base, - array("cn","objectClass","gosaGroupObjects","ipHostNumber","description"), GL_SIZELIMIT | GL_SUBSEARCH); - }else{ - $res= get_list($filter, "ogroups", get_groups_ou().$base, - array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT ); - $res= array_merge($res,get_list($filter, "workstation", "ou=workstations,ou=systems,".$base, - array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT )); - $res= array_merge($res,get_list($filter, "server", "ou=servers,ou=systems,".$base, - array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT )); - } - - $this->list= $res; - ksort ($this->list); - reset ($this->list); - $tmp=array(); - foreach($this->list as $tkey => $val ){ - - if($this->IPMatch){ - if(isset($val['ipHostNumber'][0])){ - if(is_ip_range($IP_start,$val['ipHostNumber'][0]) && is_ip_range($val['ipHostNumber'][0],$IP_end)){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - } - }else{ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - } - ksort($tmp); - $this->list=array(); - foreach($tmp as $val){ - $this->list[]=$val; - } - reset ($this->list); - } - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } -} - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/gotomasses/goto_task.tpl b/plugins/addons/gotomasses/goto_task.tpl deleted file mode 100644 index f841a4fd8..000000000 --- a/plugins/addons/gotomasses/goto_task.tpl +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - - -
-

{t}Generic{/t}

-
- - - - - - - - - - {if $Action == "initial_install"} - - - - - - - - - {/if} -
- {t}Description{/t} - - {render acl=$CommentACL} - - {/render} -
- {t}Object group membership{/t} - - {render acl=$OGroupACL} - - {/render} -
- - - -
- - - -
-
- - - - - -
- {t}Action{/t} - - {render acl=$ActionACL} - - {/render} - {if !$JS} - - {/if} -
- -
-{if $Action == "initial_install"} -{if $ID == 0} -

 

- - - - - - - - - - - -
-

{t}Systems{/t}

-
- - - - -
- {render acl=$TargetACL} - {$Target_list} - {/render} -
-
- - - - - - - - - - - - - -
{t}MAC address{/t}{$must} - -
{t}Name{/t} - -
{t}IP address{/t} - - {render acl=$TargetACL} - - {/render} -
-
- - - - - - - - -
{t}CVS import from file{/t}
-   -
- - - {render acl=$TargetACL} - - {/render} -
-
-{/if} -{else} -

 

- - - - - - - -
-

{t}Schedule{/t}

-
- {t}Minute{/t} - {render acl=$MinuteACL} - - {/render} - {t}Hour{/t} - {render acl=$HourACL} - - {/render} - {t}Day{/t} - {render acl=$DayACL} - - {/render} - {t}Month{/t} - {render acl=$MonthACL} - - {/render} - {t}Week day{/t} - {render acl=$WeekdayACL} - - {/render} -
-{if $ID == 0} -

 

- - - - - - - -
-

{t}Target systems{/t}

-
- - - - -
- {render acl=$TargetACL} - {$Target_list} - {/render} -
- {render acl=$TargetACL} - - {/render} - {render acl=$TargetACL} - - {/render} - {render acl=$TargetACL} - - {/render} - -
-{/if} -{/if} -

 

- -

- -{if !$new} - -{/if} - -

diff --git a/plugins/addons/gotomasses/main.inc b/plugins/addons/gotomasses/main.inc deleted file mode 100644 index abe913f4b..000000000 --- a/plugins/addons/gotomasses/main.inc +++ /dev/null @@ -1,55 +0,0 @@ -set_acl_category("gotomasses"); - - /* Check root dn and user dn for acl informations */ - $_SESSION['gotomasses']->set_acl_base($config->current['BASE']); - if($_SESSION['gotomasses']->getacl("") == ""){ - $_SESSION['gotomasses']->set_acl_base($ui->dn); - } - - /* Check if we have acl on our own base */ - if($_SESSION['gotomasses']->getacl("") == ""){ - $_SESSION['gotomasses']->set_acl_base(dn2base($ui->dn)); - } - - - } - $gotomasses= $_SESSION['gotomasses']; - - /* Execute formular */ - $display= $gotomasses->save_object(); - if(isset($_POST['save_gotomass_changes'])){ - $gotomasses->save(); - } - $display= $gotomasses->execute (); - - /* Page header*/ - $display= print_header(get_template_path('images/system.png'), _("System deployment")).$display; - - /* Store changes in session */ - $_SESSION['gotomasses']= $gotomasses; -} diff --git a/plugins/addons/gotomasses/remove.tpl b/plugins/addons/gotomasses/remove.tpl deleted file mode 100644 index 023142f97..000000000 --- a/plugins/addons/gotomasses/remove.tpl +++ /dev/null @@ -1,21 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

-{if $multiple} - -{else} - -{/if} - -

- diff --git a/plugins/addons/ldapmanager/class_csvimport.inc b/plugins/addons/ldapmanager/class_csvimport.inc deleted file mode 100644 index 66131ca21..000000000 --- a/plugins/addons/ldapmanager/class_csvimport.inc +++ /dev/null @@ -1,508 +0,0 @@ -config= &$config; - - $this->ui = get_userinfo(); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","all/".get_class($this),$this->dn); - } - - /* initiate smarty */ - $smarty= get_smarty(); - $smarty->assign("selectedattrs",array(0=>"")); - $smarty->assign("data",array(0=>"")); - $smarty->assign("head",array(0=>"")); - $smarty->assign("sorted",0); - $smarty->assign("fileup",0); - - /* Get the LDAP link, to generate the Export */ - $ldap = $this->config->get_ldap_link(); - - $arrtemplates = array(); - $tempvar =0; - - /* Array to fill in Formfields */ - $arrtemplates[$tempvar] = "None"; - if(!is_array($this->csvinfo)){ - $this->csvinfo=array(); - } - - /* Set Usertemplate information and get all Attribute from userclass */ - unset ($this->csvinfo['arrtemplates']); - unset ($this->csvinfo['arrtempls']); - - /* Generate Template Array, Attribute Array */ - if(!isset($this->csvinfo['arrtempls'])){ - - /* Generating attributes */ - $attrs = @get_class_vars("user"); - $this->csvinfo['attr'] = $attrs['attributes']; - - /* Attach the choise none to discard a csv col */ - $new = array(); - $new[0]="none"; - $new[1]="userPassword"; - for($c = 0; $c < count($this->csvinfo['attr']);$c++){ - $new[$c+2]=$this->csvinfo['attr'][$c]; - } - - $this->csvinfo['attr'] = $new; - - /* Search all Templates */ - $this->csvinfo['templates'] = $ldap->search("(objectClass=gosaUserTemplate)",array("*")); - - /* Array to handle selected Form fiels */ - $this->csvinfo['arrtempls'][$tempvar]['name'] = ""; - $this->csvinfo['arrtempls'][$tempvar]['dn'] = ""; - - $this->csvinfo['arrtemplates'][]="None"; - - while($temp = $ldap->fetch($this->csvinfo['templates'])){ - $tempvar ++; - $this->csvinfo['arrtemplates'][$tempvar] = $temp['sn'][0]." - ".$this->config->idepartments[preg_replace("/^[^,]+,".get_people_ou()."/i", "", $temp['dn'])]; - $this->csvinfo['arrtempls'] [$tempvar]['name'] = $temp['sn'][0]; - $this->csvinfo['arrtempls'] [$tempvar]['dn'] = $temp['dn']; - } - } - - $arr_temp = array_flip($this->csvinfo['attr']); - $this->csvinfo['arr_selected']= array($arr_temp['uid'],$arr_temp['sn'],$arr_temp['givenName'],$arr_temp['userPassword']); - - $smarty->assign("templates",$this->csvinfo['arrtemplates']); - $smarty->assign("attrs",$this->csvinfo['attr']); - - /* Check permissions for import */ - $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all"); - if(!preg_match("/w/",$acl)){ - if(isset($_POST['userfile']) || isset($_POST['sorted']) || isset($_POST['fileup'])){ - print_red(_("You've no permission to do CSV imports.")); - } - return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE))); - } - - /* If the given dat from the csv File are sorted by the attributes */ - if(isset($_POST['sorted'])) { - - /* Template Handling */ - $smarty->assign("fileup",TRUE); - $smarty->assign("sorted",TRUE); - - for($i = 0 ; $i < $this->csvinfo['rows'];$i++){ - /* Preparing given Data */ - $this->csvinfo['sorteddata'][$i]=array(); - - /* Go through every col */ - for($a = 0; $a <= ($this->csvinfo['cols']); $a ++) { - /* Append a status col at last, to show possibly errors */ - if($a==($this->csvinfo['cols'])){ - $this->csvinfo['sorteddata'][$i]["status"]="-"; - } else { - $cc = ($i * ($this->csvinfo['cols']))+$a; - - /* If theres a Attribut given for this col */ - if(!empty($_POST[('row'.($a))])) { - $this->csvinfo['sorteddata'][$i][$this->csvinfo['attr'][$_POST[('row'.($a))]]]=$this->csvinfo['data'][($cc)]; - } - } - } - } - - /* aleast one entry */ - $rowcnt=0; - if(isset($this->csvinfo['sorteddata'])){ - $rowcnt ++; - - /* Set the col count */ - $tblcolcount= count ($this->csvinfo['cols']); - - /* entrie count */ - $tbl_entries= count ($this->csvinfo['count']); - - /* row count */ - $tbl_rows = $tbl_entries / $tblcolcount; - - /* No error occurred */ - $failing = FALSE; - - /* For every row */ - for($i = 0; $i < $this->csvinfo['rows']; $i++){ - - /* Get elemenet */ - $dat = $this->csvinfo['sorteddata'][$i]; - - /* If not all needed vars set .... */ - if( ( empty($dat['sn']))||( empty($dat['givenName']))||( empty($dat['uid']))|| - (!isset($dat['sn']))||(!isset($dat['givenName']))||(!isset($dat['uid']))){ - - /* Output Error */ - - print_red (_("Need 'sn','givenName' and 'uid' to create user.")); - } else { - - /* Register usertab to trigger edit dialog */ - $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], 'new'); - $keys = array_keys($dat); - - - /* Set all submitted vars */ - if(is_array($keys)) - foreach($keys as $key) { - if($key != "status"){ - $this->usertab->$key = $dat[$key]; - } - } - - /* Initialize template */ - if($this->csvinfo['tplid']!=0){ - $this->usertab->adapt_from_template($this->csvinfo['arrtempls'][$this->csvinfo['tplid']]['dn']); - $this->usertab->save_object(); - } else { - - /* Reset vars */ - if(is_array($keys)) - foreach($keys as $key) { - if($key != "status"){ - $this->usertab->by_object['user']->$key = $dat[$key]; - } - } - } - - // Setting user Password - if((isset($dat['userPassword']))&&(!empty($dat['userPassword']))) - $password = $dat['userPassword']; - else - { - $rand_str=""; - $feed = "0123456789abcdefghijklmnopqrstuvwxyz"; - for ($i=0; $i < 8; $i++) - { - $rand_str .= substr($feed, rand(0, strlen($feed)-1), 1); - } - $password = $rand_str; - } - - /* Insert in the LDAP tree */ - if(count($this->usertab->check())) { - show_errors($this->usertab->check()); - $this->csvinfo['sorteddata'][$i]['status']=""._("failed").""; - $failing = $i+1; - break; - } else { - $this->csvinfo['sorteddata'][$i]['status']=_("ok"); - $this->usertab->save(); - change_password($this->usertab->dn,$password); - } - } - } - - $pointsbefore = FALSE; - $pointsafter = FALSE; - - /* Get Attributs for Tableheadline */ - $this->csvinfo['colsstr'] = array(); - for($i =0; $i <= $this->csvinfo['cols']; $i++) { - if(!empty($_POST[('row'.$i)])){ - $this->csvinfo['colsstr'][$i] = $this->csvinfo['attr'][$_POST[('row'.$i)]]; - } - } - - /*Create array with data for the template */ - if($failing == FALSE){ - - $dataouts= array(); - for($i =1; $i <= $this->csvinfo['shownrowscount']; $i++) { - if(is_array($this->csvinfo['sorteddata'][($i-1)])){ - foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){ - $dataouts[]=$dat; - } - } - } - - if($this->csvinfo['rows']> $this->csvinfo['shownrowscount']){ - $pointsafter = TRUE; - } - } else { - $pointsbefore = TRUE; - $pointsafter = TRUE; - - $begin = $failing -3; - - if($begin <0) { - $begin =0; - $pointsbefore = FALSE; - } - - $end = $failing + 2; - - if($end > $this->csvinfo['rows']) { - $end = $this->csvinfo['rows']+1; - $pointsafter = FALSE; - } - $this->csvinfo['shownrowscount']=$end - $begin; - - if($this->csvinfo['shownrowscount']> $this->csvinfo['rows'])$this->csvinfo['shownrowscount']=$this->csvinfo['rows']; - - $dataouts = array(); - for($i =$begin; $i <= $end; $i++) { - if(is_array($this->csvinfo['sorteddata'][($i-1)])){ - foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){ - $dataouts[]=$dat; - } - } - } - } - $tmparr2 = $this->csvinfo['colsstr']; - $tmparr2[]=_("status"); - - /* Error? */ - if ($failing){ - print_red(sprintf(_("An Error Occured while inserting entry %s - process aborted"), $failing)); - } - $smarty->assign("error",$failing); - - /* Set vars to smarty */ - $smarty->assign("cols",count($tmparr2)); - $smarty->assign("anz" ,$this->csvinfo['count']); - $smarty->assign("rows",$this->csvinfo['shownrowscount']); - - - $cnt = 0 ; - $tmp2 = $tmp3 = array(); - if(is_array($dataouts)) - foreach($dataouts as $tmp){ - $tmp2[] = $tmp; - $cnt ++ ; - if($cnt >= count($tmparr2)){ - $tmp3[] = $tmp2; - $tmp2= array(); - $cnt = 0; - } - } - $smarty->assign("head",$tmparr2); - $smarty->assign("data",$tmp3); - - /* Set other vars */ - $smarty->assign("i",1); - $smarty->assign("ie",0); - $smarty->assign("tplid",$this->csvinfo['tplid']); - - $smarty->assign("pointsafter",$pointsafter); - $smarty->assign("pointsbefore",$pointsbefore); - } else { - /* Set Template ID */ - $tplid = $_POST['tplid']; - - - $smarty->assign("tpl",$arrtemplates[$tplid]); - print_red (_("Nothing to import!")); - } - - /* If theres a File uploaded */ - } else { - /* Check if theres a file uploaded */ - if(!empty($_FILES['userfile']['name'])){ - - $handle = NULL; - - if((!isset($_FILES['userfile']['name']))||(!isset($_POST['fileup']))) - { - print_red(_("There is no file uploaded.")); - $smarty->assign("LDIFError",TRUE); - } - elseif(!$_FILES['userfile']['size'] > 0 ) - { - print_red(_("The specified file is empty.")); - $smarty->assign("LDIFError",TRUE); - } - /* Is there a tmp file, which we can use ? */ - elseif(!file_exists($_FILES['userfile']['tmp_name'])) - { - print_red(_("There is no file uploaded.")); - $smarty->assign("LDIFError",TRUE); - } - elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r")) - { - print_red(_("There is no file uploaded.")); - $smarty->assign("LDIFError",TRUE); - } - else - { - $smarty->assign("fileup",TRUE); - $str = ""; - - - /* Reading content */ - while(!feof($handle)) { - $str .= fread($handle,1024); - } - - $lines = split("\n",$str); - $anz = 0; - $rest = 0; - $data = array(); - - /* check colum count */ - if(is_array($lines)) - foreach($lines as $line) { - /* continue if theres a comment */ - if(substr(trim($line),0,1)=="#"){ - continue; - } - - $line= str_replace ("\t","",$line); - $cells = split(",",$line ) ; - - if(count($cells)> $anz ){ - $anz = count($cells); - } - } - - /* At least one entry */ - if($anz >1) { - - /* Generate array with outpu info */ - if(is_array($lines)) - foreach($lines as $line) { - $rest = 0; - $cnt = 0; - - /* dont use comments or empty lines */ - if((substr(trim($line),0,1)=="#")||(empty($line))){ - continue; - } - - /* replace \t to , */ - $line= str_replace ("\t" ,"" ,$line); - - /* get all elements */ - $cells = split(",",$line ) ; - - /* attach all elements to data array */ - if(is_array($cells)) - foreach($cells as $cell) { - if(!empty($cell)) { - $cnt++; - $data[]=trim($cell); - } - } - - /* cell count less than anz, attach some empty fields */ - if(($cnt != $anz)&&(!empty($cnt))) { - $rest = $anz - $cnt; - for($i = 0 ; $i < $rest ; $i ++){ - $data[] = " "; - } - } - } - - unset($this->csvinfo['sorteddata']); - unset($this->csvinfo['colsstr']); - unset($this->csvinfo['sorteddata']); - - $this->csvinfo['cols'] = $anz; - $this->csvinfo['data'] = array(); - $this->csvinfo['data'] = $data; - $this->csvinfo['count'] = count($this->csvinfo['data']); - - if($this->csvinfo['count']> (6* $this->csvinfo['cols'])) { - /* only show 6 rows in ouptuttablei */ - $datouttemp = array_chunk($this->csvinfo['data'],(6* $this->csvinfo['cols'])); - $this->csvinfo['dataout']=$datouttemp[0]; - $this->csvinfo['shownrowscount'] = 6; - } else { - $this->csvinfo['shownrowscount'] = (count($this->csvinfo['data']))/$this->csvinfo['cols']; - $this->csvinfo['dataout']= $this->csvinfo['data']; - } - - $this->csvinfo['tplid'] = $_POST['template']; - $this->csvinfo['templatestr'] = $this->csvinfo['arrtemplates' ][$this->csvinfo['tplid']]; - $this->csvinfo['count'] = count($this->csvinfo['data']); - $this->csvinfo['rows'] = (count($this->csvinfo['data'])/$anz); - - $i = 0; - $tmp = $tmp2= array(); - if(is_array($this->csvinfo['dataout'])) - foreach($this->csvinfo['dataout'] as $dat){ - $tmp[]= $dat; - $i++; - if($i >=$this->csvinfo['cols']){ - $i = 0; - $tmp2[] = $tmp; - $tmp = array(); - } - - } - - /* Set Templateid */ - $smarty->assign("tplid",$this->csvinfo['tplid']); - - /* Set Template */ - $smarty->assign("tpl",$this->csvinfo['templatestr']); - - /* Temp var 1 */ - $smarty->assign("ia",1); - - /* Temp var 2 */ - $smarty->assign("i",0); - - /* Num rows */ - $smarty->assign("rows",$this->csvinfo['shownrowscount']); - - - for($i = 0 ; $i < $anz; $i ++) - $this->csvinfo['arr_selected'][]="0"; - - $smarty->assign("selectedattrs",$this->csvinfo['arr_selected']); - - /* Entrie count5 */ - $smarty->assign("anz",$this->csvinfo['cols']); - - /* Array with data */ - $smarty->assign("data",$tmp2); - - @fclose($handle); - } else { - $smarty->assign("tpl",$this->csvinfo['attr'][$_POST['template']]); - $smarty->assign("LDIFError",TRUE); - $smarty->assign("fileup",FALSE); - print_red(_("The selected file does not contain any CSV Data...")); - } - } - } - } - - /* Show main page */ - return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE))); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/ldapmanager/class_export.inc b/plugins/addons/ldapmanager/class_export.inc deleted file mode 100644 index aa988a312..000000000 --- a/plugins/addons/ldapmanager/class_export.inc +++ /dev/null @@ -1,125 +0,0 @@ -config= &$config; - $this->ui = get_userinfo(); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","all/".get_class($this),$this->dn); - } - - /* Set government mode */ - $smarty= get_smarty(); - - $smarty->assign("type",FALSE); - $smarty->assign("depselectivbb",""); - - // fill in old vars in the Export form - if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){ - $smarty->assign("single",$_POST['single']); - $smarty->assign("type","single"); - $dn = $_POST['single']; - } - if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){ - $smarty->assign("depselectfull",$_POST['selfull']); - $smarty->assign("type","full"); - $dn = $_POST['selfull']; - } else { - $smarty->assign("depselectfull", ""); - } - if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){ - $smarty->assign("depselectivbb",$_POST['selivbb']); - $smarty->assign("type","ivbb"); - $dn = $_POST['selivbb']; - } else { - $smarty->assign("depselectivbb", ""); - } - - // Set values for optionlist in form - $bases = array(); - $acl_bases = $this->ui->get_module_departments("all"); - foreach($this->config->idepartments as $base_dn => $name){ - if(in_array_ics($base_dn,$acl_bases)){ - $bases[$base_dn] = $name; - } - } - $smarty->assign("deplist", $bases); - - // Get the LDAP link, to generate the Export - $ldap = $this->config->get_ldap_link(); - - if ($this->config->current['GOVERNMENTMODE'] == 'true'){ - $smarty->assign ("govmode", "true"); - } else { - $smarty->assign ("govmode", "false"); - } - - $smarty->assign("LDIFError",FALSE); - - if(isset($dn)) - { - if(!($ldap->dn_exists($dn) && $dn != "")){ - $smarty->assign("LDIFError",TRUE); - print_red (_("Error while exporting the requested entries!")); - } - } - - /* check alcs for given dn */ - $acls =""; - if(isset($dn)){ - $acls = $this->ui->get_permissions($dn,"all/all"); - } - if((!preg_match("/r/",$acls)) && (isset($dn))){ - - /* Show error msg */ - print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn))); - - /* Show main page */ - $smarty->assign("LDIFError",TRUE); - $smarty->assign("para",""); - }else{ - - // Export a single LDAP entry - if(isset($_POST['sfrmgetsingle'])) - { - $smarty->assign("para","?ivbb=2&dn=".base64_encode($_POST['single'])); - } - elseif(isset($_POST['sfrmgetfull'])) - { - $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull'])); - } - elseif(isset($_POST['sfrmgetivbb'])) - { - $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb'])); - } - } - - /* Show main page */ - return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE))); - } -} - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/ldapmanager/class_exportxls.inc b/plugins/addons/ldapmanager/class_exportxls.inc deleted file mode 100644 index 3331cbacd..000000000 --- a/plugins/addons/ldapmanager/class_exportxls.inc +++ /dev/null @@ -1,142 +0,0 @@ -config= &$config; - - $this->ui = get_userinfo(); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","all/".get_class($this),$this->dn); - } - - $dn = $this->config->current['BASE']; - - /* Set government mode */ - $smarty= get_smarty(); - $smarty->assign("type",FALSE); - $smarty->assign("depselectivbb",""); - - if(!isset($_POST['selfull'])) $_POST['selfull'] = "Somehow not posted"; - - /* Check permissions for export */ - // fill in old vars in the Export form - if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){ - $smarty->assign("single",$_POST['single']); - $smarty->assign("type","single"); - $a=$_POST['single']; - $b=$_POST['selfull']; - - } - if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){ - $smarty->assign("depselectfull",$_POST['selfull']); - $smarty->assign("type","full"); - $dn = $_POST['selfull']; - } else { - $smarty->assign("depselectfull", ""); - } - if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){ - $smarty->assign("depselectivbb",$_POST['selivbb']); - $smarty->assign("type","ivbb"); - $dn = $_POST['selivbb']; - } else { - $smarty->assign("depselectivbb", ""); - } - - // Set values for optionlist in form - $bases = array(); - $acl_bases = $this->ui->get_module_departments("all"); - foreach($this->config->idepartments as $base_dn => $name){ - if(in_array_ics($base_dn,$acl_bases)){ - $bases[$base_dn] = $name; - } - } - $smarty->assign("deplist", $bases); - $smarty->assign("choicelist",array( get_people_ou() =>"users" , - "ou=groups," =>"groups" , - "ou=systems," =>"computers", - "ou=servers,ou=systems," =>"servers", - "dc=addressbook," =>"addressbook")); - - // Get the LDAP link, to generate the Export - $ldap = $this->config->get_ldap_link(); - - if ($this->config->current['GOVERNMENTMODE'] == 'true'){ - $smarty->assign ("govmode", "true"); - } else { - $smarty->assign ("govmode", "false"); - } - - $smarty->assign("LDIFError",FALSE); - - if(isset($dn)) - { - if(!($ldap->dn_exists($dn) && $dn != "")){ - $smarty->assign("LDIFError",TRUE); - print_red (_("Error while exporting the requested entries!")); - } - } - - /* check alcs for given dn */ - $acls =""; - if(isset($dn)){ - $acls = $this->ui->get_permissions($dn,"all/all"); - } - - if(!preg_match("/r/",$acls) && (isset($_POST['sfrmgetsingle']) || isset($_POST['sfrmgetfull']) || isset($_POST['sfrmgetivbb']))){ - - /* Show error msg */ - print_red(sprintf(_("You are not allowed to export the given ldap entry (%s)"),@LDAP::fix($dn))); - - /* Show main page */ - $smarty->assign("LDIFError",TRUE); - $smarty->assign("para",""); - }else{ - - // Export a single LDAP entry - if(isset($_POST['sfrmgetsingle'])) - { - $smarty->assign("para","?ivbb=2&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull'])); - } - elseif(isset($_POST['sfrmgetfull'])) - { - $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull'])); - } - elseif(isset($_POST['sfrmgetivbb'])) - { - $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb'])); - } - } - - /* Show main page */ - return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE))); - } - -} - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/ldapmanager/class_import.inc b/plugins/addons/ldapmanager/class_import.inc deleted file mode 100644 index 71edbb2a2..000000000 --- a/plugins/addons/ldapmanager/class_import.inc +++ /dev/null @@ -1,120 +0,0 @@ -config= &$config; - - $this->ui = get_userinfo(); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","all/".get_class($this),$this->dn); - } - - /* Set government mode */ - $smarty= get_smarty(); - - // Get the LDAP link, to generate the Export - $ldap = $this->config->get_ldap_link(); - - $smarty->assign("LDIFError",FALSE); - $smarty->assign("type",FALSE); - - /* Get acls */ - $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all"); - - /* Import requested check file and acls */ - if((isset($_FILES['userfile']['name']))&&(isset($_POST['fileup']))){ - - /* Check acls */ - if(!preg_match("/w/",$acl)){ - print_red(_("You need full access to all objects, to execute the import command.")); - }else{ - - $smarty->assign("type","importfile"); - $handle = NULL; - - // Check if there is a file submitted - if(!$_FILES['userfile']['size'] > 0 ) - { - print_red(_("The specified file is empty.")); - $smarty->assign("LDIFError",TRUE); - } - - // Is there a tmp file, which we can use ? - elseif(!file_exists($_FILES['userfile']['tmp_name'])) - { - print_red(_("There is no file uploaded.")); - $smarty->assign("LDIFError",TRUE); - - } - - // Can we open the tmp file, for reading - elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r")) - { - print_red(_("There is no file uploaded.")); - $smarty->assign("LDIFError",TRUE); - } - else - { - // Everything just fine :) - $str = ""; - - // Reading content - while(!feof($handle)) - { - $str .= fread($handle,1024); - } - @fclose($handle); - - // Should we use Overwrite ? - if(!empty($_POST['overwrite'])) $overwrite = true; else $overwrite = false;; - if(!empty($_POST['cleanup'])) $cleanup = true; else $cleanup = false; - - $ErrorStr=""; - $check = $ldap->import_complete_ldif($str,$ErrorStr,$overwrite,$cleanup); - - if($check == INSERT_OK ) - $smarty->assign("LDIFError",FALSE); - else - $smarty->assign("LDIFError",TRUE); - - switch($check) - { - case INSERT_OK : break; - case ALREADY_EXISTING_ENTRY : print_red($ErrorStr); break; - case UNKNOWN_TOKEN_IN_LDIF_FILE : print_red($ErrorStr);break; - - default : print_red(_("Unknown Error"));break; - } - } - } - } - return ($smarty->fetch (get_template_path('contentimport.tpl', TRUE))); - } -} - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/ldapmanager/class_ldif.inc b/plugins/addons/ldapmanager/class_ldif.inc deleted file mode 100644 index 3451f8179..000000000 --- a/plugins/addons/ldapmanager/class_ldif.inc +++ /dev/null @@ -1,52 +0,0 @@ -ldif= new ldiftab($config, $config->data['TABS']['LDIFTAB'], ""); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Show main page */ - return ($this->ldif->execute()); - } - - /* Return plugin informations for acl handling - #FIXME You can only read attributes within this report plugin */ - static function plInfo() - { - return (array( - "plShortName" => _("Ldap manager"), - "plDescription" => "Dummy entry for menu creation functions, later", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("addon"), - "plCategory" => array("ldapmanager" => array("objectClass" => "none", "description" => _("Ldap manager addon"))), - - "plProvidedAcls" => array() - )); - } - - - -} - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/ldapmanager/contentcsv.tpl b/plugins/addons/ldapmanager/contentcsv.tpl deleted file mode 100644 index fbfdfef0b..000000000 --- a/plugins/addons/ldapmanager/contentcsv.tpl +++ /dev/null @@ -1,118 +0,0 @@ -

- {t}The CSV import plugin provides methods to generate user accounts from a file containing Comma Seperated Values. The administrator can decide which columns should be transfered to which attribute. Note that you must have at least the UID, GIVENNAME and SURENAME set.{/t} -

-

 

- -{if $fileup != TRUE} - - - - - - - - - - -
- - - - -
- - - -
-{elseif $sorted != FALSE} - - -
- {if $error == FALSE} - {t}All entries have been written to the LDAP database successfully.{/t} - {else} - {t}Oups. There was an error during the import of your data.{/t} - {/if} - -{t}Here is the status report for the import:{/t} -
-
- - - - - {foreach from=$head item=h} - - {/foreach} - - {if $pointsbefore == TRUE} - - - - {/if} - - {foreach from=$data item=row key=key} - - {foreach from=$data[$key] item=col key=key2} - - {/foreach} - - {/foreach} - {if $pointsafter == TRUE} - - - - {/if} - -
- {$h} -
- ... -
- {$data[$key][$key2]} -
- ... -
- -{else} -
{t}Selected Template{/t}: {$tpl} -
-
- - - {foreach from=$data[0] item=item key=key} - - {/foreach} - - {foreach from=$data item=val key=key} - - {foreach from=$data[$key] item=val2 key=key2} - - {/foreach} - - {/foreach} - -
- -
- {$data[$key][$key2]}  -
- - -{/if} -

-{if $fileup != TRUE} - -{else} -{if $sorted == FALSE} - -{else} - -{/if} -{/if} -

- diff --git a/plugins/addons/ldapmanager/contentexport.tpl b/plugins/addons/ldapmanager/contentexport.tpl deleted file mode 100644 index 5cd2301d9..000000000 --- a/plugins/addons/ldapmanager/contentexport.tpl +++ /dev/null @@ -1,73 +0,0 @@ -{if $LDIFError != FALSE || $type == FALSE} -

- {t}The LDIF export plugin provides methods to download a complete snapshot of the running LDAP directory as ldif. You may save these files for backup purpose or when initializing a new server.{/t} -

-

 

- - - - - - - - - - - - - -{if $govmode eq "true"} - - - - - -{/if} -
- - - - - -
- - - - - -
- - - - - -
- - -{else} - - -
-

{t}Export successful{/t}

-
- -
- -
-{/if} -

-   -

- - diff --git a/plugins/addons/ldapmanager/contentexportxls.tpl b/plugins/addons/ldapmanager/contentexportxls.tpl deleted file mode 100644 index bb115c7b5..000000000 --- a/plugins/addons/ldapmanager/contentexportxls.tpl +++ /dev/null @@ -1,76 +0,0 @@ -{if $LDIFError != FALSE || $type == FALSE} -

- {t}The XLS export plugin provides methods to download a complete snapshot of the running LDAP directory as xls. You may save these files for documentation.{/t} -

-

 

- - - - - - - - - - - - - -{if $govmode eq "true"} - - - - - -{/if} -
- - - {**} - - - -
- - - - - -
- - - - - -
- - -{else} - - -
-

{t}Export successful{/t}

-
- -
- -
-{/if} -

-   -

- - diff --git a/plugins/addons/ldapmanager/contentimport.tpl b/plugins/addons/ldapmanager/contentimport.tpl deleted file mode 100644 index b7d5afc8d..000000000 --- a/plugins/addons/ldapmanager/contentimport.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{if $type == FALSE || $LDIFError != FALSE} -

- {t}The LDIF import plugin provides methods to upload a set of entries to your running LDAP directory as ldif. You may use this to add new or modify existing entries. Remember that GOsa will not check your ldifs for GOsa conformance.{/t} -

- -

 

- - - - - - - - - - - - - -
- - - - - -
-   - - - {t}Modify existing objects, keep untouched attributes{/t}
- {t}Overwrite existing objects, all not listed attributes will be removed{/t} -
-   - - - -
-{else} - -
-

{t}Import successful{/t}

-
- -
- -
- -{/if} -

- -

- diff --git a/plugins/addons/ldapmanager/main.inc b/plugins/addons/ldapmanager/main.inc deleted file mode 100644 index 696c14add..000000000 --- a/plugins/addons/ldapmanager/main.inc +++ /dev/null @@ -1,39 +0,0 @@ -set_acl_category("logview"); - } - $ldif= $_SESSION['ldif']; - - /* Execute formular */ - $display= $ldif->execute (); - $display.= "\n"; - - /* Page header*/ - $display= print_header(get_template_path('images/ldif.png'), _("LDAP manager")).$display; - - /* Store changes in session */ - $_SESSION['ldif']= $ldif; -} -?> diff --git a/plugins/addons/ldapmanager/tabs_ldif.inc b/plugins/addons/ldapmanager/tabs_ldif.inc deleted file mode 100644 index 2f6b70f0d..000000000 --- a/plugins/addons/ldapmanager/tabs_ldif.inc +++ /dev/null @@ -1,24 +0,0 @@ - diff --git a/plugins/addons/logview/class_gosa_logview.inc b/plugins/addons/logview/class_gosa_logview.inc deleted file mode 100644 index 87d234a4d..000000000 --- a/plugins/addons/logview/class_gosa_logview.inc +++ /dev/null @@ -1,398 +0,0 @@ -config= &$config; - $this->ui = get_userinfo(); - - /* Restore last filter settings */ - foreach(array("action","server","time","regex") as $attr){ - if(isset($_SESSION['logview']['gosa_log'][$attr])){ - $this->$attr = $_SESSION['logview']['gosa_log'][$attr]; - } - } - - $tz = get_default_timezone(); - $this->timezone_offset = $tz['value'] * 60 * 60 ; - - $ldap = $this->config->get_ldap_link(); - $ldap->search("(&(objectClass=person)(uid=*))",array("uid","dn")); - while($attrs = $ldap->fetch()){ - $this->uid_map[$attrs['dn']] = $attrs['uid'][0]; - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","logview/".get_class($this),$this->dn); - } - - /* Time interval */ - $date_select = array( - "0" => _("one hour"), "1" => _("6 hours"), - "2" => _("12 hours"), "3" => _("24 hours"), - "4" => _("2 days"), "5" => _("one week"), - "6" => _("2 weeks"), "7" => _("one month")); - - - $time = time(); - $date_select_ = array( - "0" => $time - 3600, - "1" => $time - 21600, - "2" => $time - 43200, - "3" => $time - 86400, - "4" => $time - 172800, - "5" => $time - 604800, - "6" => $time - 1209600, - "7" => $time - 2419200); - - $smarty= get_smarty(); - $smarty->assign("search_result", ""); - $smarty->assign("plug", "?plug=".validate($_GET['plug'])); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("time_image", get_template_path('images/time.png')); - $smarty->assign("server_image", get_template_path('images/server.png')); - $smarty->assign("log_image", get_template_path('images/log_warning.png')); - $smarty->assign("ruleset_image", get_template_path('images/edit.png')); - $smarty->assign("launchimage", get_template_path('images/launch.png')); - $smarty->assign("date_select", $date_select); - $smarty->assign("actions", array()); - $smarty->assign("direction", "up"); - $smarty->assign("mode0", ""); - $smarty->assign("mode1", ""); - $smarty->assign("mode2", ""); - $smarty->assign("mode3", ""); - $smarty->assign("mode4", ""); - $smarty->assign("mode5", ""); - $smarty->assign("mode6", ""); - - /* Assign select option content */ - foreach( array("server", "action", "time", "regex") as $type){ - $smarty->assign("$type", $this->$type); - } - - /**** - * Check if defined servers - * and mysql extension - ****/ - if (!isset($this->config->data['SERVERS']['LOGGING']) || !count($this->config->data['SERVERS']['LOGGING'])){ - print_red (_("No GOsa LOG servers defined!")); - return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); - } - - if(!is_callable("mysql_connect")){ - print_red(_("There is no mysql extension available, please check your php setup.")); - return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); - } - - /**** - * Get Configurations - ****/ - $list_of_servers = $this->config->data['SERVERS']['LOGGING']; - $servers = array(); - foreach($list_of_servers as $servername => $data){ - $servers[$servername] = $servername; - } - $smarty->assign("servers", $servers); - - /* Set a default server, if there is currently no valid server selected */ - if(empty($this->server) || !in_array($this->server,$servers)){ - $this->server = key($servers); - } - - /**** - * Connect to currently selected server - ****/ - $cfg = $list_of_servers[$this->server]; - $link = @mysql_pconnect($this->server, $cfg['USER'], $cfg['PWD']); - if ($link === FALSE){ - print_red(_("Can't connect to log database, no logs can be shown!")); - new log("debug","logview","",array(),@mysql_error()); - return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); - } - - /* check of log database is available */ - if (! @mysql_select_db($cfg['DB'])){ - print_red(_("Can't select log database for log generation!")); - new log("debug","logview","",array(),@mysql_error()); - return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); - } - - - /**** - * Get all action types - ****/ - - $actions = array("!ALL" => _("All")); - $query = "SELECT distinct(action) FROM gosa_log;"; - $res = @mysql_query($query); - while($attrs = @mysql_fetch_assoc($res)){ - $actions[$attrs['action']] = $attrs['action']; - } - - - /**** - * Check Acls - ****/ - - $ui = get_userinfo(); - $dn = $list_of_servers[$this->server]['DN']; - $acls = $ui->get_permissions($dn,"server/gosaLogServer","viewEntries"); - - if(!preg_match("/r/",$acls)){ - $res = " - - "._("You have insufficient permissions to view syslog entries.")." - - "; - - /* Show main page */ - $smarty->assign("range_selector", ""); - $smarty->assign("search_result", $res); - return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); - } - - - /**** - * Query stuff - ****/ - $res= ""; - $cfg = $list_of_servers[$this->server]; - $link = @mysql_pconnect($this->server, $cfg['USER'], $cfg['PWD']); - - /* Test connection object && create up query string */ - if ($link === FALSE){ - print_red(_("Can't connect to log database, no logs can be shown!")); - new log("debug","logview","",array(),@mysql_error()); - } else { - - if (! @mysql_select_db($cfg['DB'])){ - print_red(_("Can't select log database for log generation!")); - new log("debug","logview","",array(),@mysql_error()); - } else { - - /* Prepare order setting */ - if ($this->sort_direction == "down"){ - $desc= "DESC"; - $sort_sign = "\/"; - } else { - $desc= ""; - $sort_sign = "/\"; - } - - /* Get start time */ - $start = $date_select_[$this->time]; - - /* Prepare search filter */ - $sql_regex =trim(preg_replace("/\*/","%",$this->regex)); - $sql_regex = "%".trim($sql_regex,"%")."%"; - - /* Create search filter */ - $query_base= "FROM gosa_log WHERE timestamp >= $start "; - - /* Append action filter */ - if($this->action != "!ALL"){ - $query_base .=" AND action like '".$this->action."' "; - } - - /* Append search filter */ - if($sql_regex != "%%"){ - $query_base .=" AND ( result like '".$sql_regex."' OR user like '".$sql_regex."') "; - } - - /* Get number of entries */ - $query= "SELECT COUNT(`user`) ".$query_base.";"; - $result = mysql_query($query); - if(!$result){ - new log("debug","logview","",array(),@mysql_error()); - } - $line= mysql_fetch_array($result, MYSQL_ASSOC); - $count= $line['COUNT(`user`)']; - if ($count > 25){ - $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage")); - } else { - $smarty->assign("range_selector", ""); - } - - /* Query results that will be displayed */ - $query= "SELECT * ".$query_base." ORDER BY ".$this->fields[$this->sort]." ".$desc." LIMIT ".$this->start.",".$this->range.";"; - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query"); - $result = @mysql_query($query); - if(!$result){ - new log("debug","logview","",array(),@mysql_error()); - } - - /* Display results */ - $mod= 0; - - /* Add entries to result str */ - while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){ - - /* Toggle background color */ - if ( ($mod++) & 1){ - $col= "background-color: #ECECEC;"; - } else { - $col= "background-color: #F5F5F5;"; - } - - $base = ", ".substr($this->config->current['BASE'],0,5)."..."; - - if(isset($this->uid_map[$line['user']])){ - $user = $this->uid_map[$line['user']]; - }else{ - $user = preg_replace("/,".normalizePreg($this->config->current['BASE'])."/",$base,$line['user']); - } - $object = preg_replace("/,".normalizePreg($this->config->current['BASE'])."/",$base,$line['object']); - - $res.=" \n"; - $res.=" ".$line['action'].""; - $res.=" ".date("H:i:s d.m.Y",($line['timestamp'] + $this->timezone_offset)).""; - $res.=" ".preg_replace("/,/",", ",$user).""; - $res.=" ".$line['objecttype'].""; - $res.=" ".preg_replace("/,/",", ",$object).""; - $res.=" ".$line['result'].""; -# if($line['repeated'] == 1){ -# $res.=" -"; -# }else{ -# $res.=" ".($line['repeated']-1).""; -# } - $res.=" \n"; - } - mysql_close($link); - $smarty->assign("mode".$this->sort, $sort_sign); - $smarty->assign("search_result", $res); - } - } - - $smarty->assign("regex", $this->regex); - $smarty->assign("server",$this->server); - $smarty->assign("servers",$servers); - $smarty->assign("action",$this->action); - $smarty->assign("actions",$actions); - $smarty->assign("date_select", $date_select); - - $smarty->assign("direction", $this->sort_direction); - - /* Show main page */ - return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE))); - } - - - function save_object() - { - if(isset($_POST['gosa_log_contents_posted'])){ - - /* Get submitted range */ - if(isset($_POST['EntriesPerPage'])){ - if(is_numeric($_POST['EntriesPerPage'])){ - $this->range = $_POST['EntriesPerPage']; - } - } - - /* Get actual select boxe values */ - $logfilter_changed = FALSE; - foreach( array("server", "action","time","regex") as $type){ - if(isset($_POST[$type])){ - $this->$type = $_POST[$type]; - } - } - - /* Filter regex values */ - if ($this->regex == ""){ - $this->regex= '*'; - } else { - $new = preg_replace('/\*\**/', '*', $this->regex); - $this->regex= $new; - } - - /* Set start value */ - if (isset($_GET['start'])){ - $this->start= (int)$_GET['start']; - } - - /* Reset page number if filter has changed */ - if ($logfilter_changed > 0){ - $this->start= 0; - } - - /* Adapt sorting */ - if (isset($_GET['sort'])){ - - if($_GET['direction'] == "up"){ - $this->sort_direction = "down"; - }else{ - $this->sort_direction = "up"; - } - - $this->sort= (int)$_GET['sort']; - if ($this->sort < 0 || $this->sort > count($this->fields)){ - $this->sort= 0; - } - } - - /* Save attributes in Sessiob, so we are able to recontruct filter on plugin reload */ - $_SESSION['logview']['gosa_log'] = array(); - foreach(array("action","server","time","regex") as $attr){ - $_SESSION['logview']['gosa_log'][$attr] = $this->$attr; - } - - } - } - - - /* Return plugin informations for acl handling - #FIXME You can only read attributes within this report plugin - static function plInfo() - { - return (array( - "plShortName" => _("Log view"), - "plDescription" => _("Log view addon"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("addon"), - "plCategory" => array("logview" => array("objectClass" => "none", "description" => _("System logs"))), - - "plProvidedAcls" => array() - )); - } - */ -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/logview/class_logview.inc b/plugins/addons/logview/class_logview.inc deleted file mode 100644 index 8716ee7e9..000000000 --- a/plugins/addons/logview/class_logview.inc +++ /dev/null @@ -1,415 +0,0 @@ -config= &$config; - - /* Get global filter config */ - if (!is_global("logfilter")){ - $logfilter= array( - "time" => "1", - "log_level" => "!All", - "host" => "!All", - "regex" => "*"); - - register_global("logfilter", $logfilter); - } - - $this->ui = get_userinfo(); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","logview/".get_class($this),$this->dn); - } - - $logfilter= get_global("logfilter"); - $smarty= get_smarty(); - $smarty->assign("search_result", ""); - $smarty->assign("plug", "?plug=".validate($_GET['plug'])); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("time_image", get_template_path('images/time.png')); - $smarty->assign("server_image", get_template_path('images/server.png')); - $smarty->assign("log_image", get_template_path('images/log_warning.png')); - $smarty->assign("ruleset_image", get_template_path('images/edit.png')); - $smarty->assign("launchimage", get_template_path('images/launch.png')); - $smarty->assign("hostlist", $this->hostlist); - $smarty->assign("loglevellist", $this->loglevellist); - $smarty->assign("tilist", $this->tilist); - $smarty->assign("mode0", ""); - $smarty->assign("mode1", ""); - $smarty->assign("mode2", ""); - $smarty->assign("mode3", ""); - - /* Assign select option content */ - foreach( array("host", "log_level", "time", "regex") as $type){ - $smarty->assign("$type", $logfilter[$type]); - } - - /* Test connection to log database */ - if (!isset($this->config->data['SERVERS']['LOG'])){ - print_red (_("No LOG servers defined!")); - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - - }elseif(!is_callable("mysql_connect")){ - print_red(_("There is no mysql extension available, please check your php setup.")); - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - - }else{ - - /* Cehck connection informations */ - $cfg= $this->config->data['SERVERS']['LOG']; - - /* Open link to database and check if it is valid */ - $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); - if ($link === FALSE){ - print_red(_("Can't connect to log database, no logs can be shown!")); - new log("debug","logview","",array(),@mysql_error()); - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - /* check of log database is available */ - if (! @mysql_select_db("gomon")){ - print_red(_("Can't select log database for log generation!")); - new log("debug","logview","",array(),@mysql_error()); - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - /* Get Host list, if still empty */ - if(count($this->hostlist) == 0){ - - /* Query database and check results */ - $query= "SELECT DISTINCT host FROM golog LIMIT 200;"; - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query"); - $result = @mysql_query($query); - if ($result === false){ - print_red(_("Query for log database failed!. Requesting host names failed.")); - new log("debug","logview","",array(),@mysql_error()); - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - /* Add hostnames to list */ - while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){ - $this->hostlist[$line['host']]= $line['host']; - } - $this->hostlist['!All']= _("All"); - ksort($this->hostlist); - $smarty->assign("hostlist", $this->hostlist); - } - - /* Get log level list */ - if(count($this->loglevellist) == 0){ - - /* Try to get all used log level types */ - $query= "SELECT DISTINCT log_level FROM golog LIMIT 200;"; - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query"); - $result = @mysql_query($query); - if ($result === false){ - new log("debug","logview","",array(),@mysql_error()); - print_red(_("Query for log database failed!")); - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - /* Add each etry to log level list */ - while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){ - $this->loglevellist[$line['log_level']]= $line['log_level']; - } - $this->loglevellist['!All']= _("All"); - ksort($this->loglevellist); - $smarty->assign("loglevellist", $this->loglevellist); - } - } - - /* Set list of available time sequences */ - if(count($this->tilist) == 0){ - - /* Time interval */ - $this->tilist= array("0" => _("one hour"), "1" => _("6 hours"), - "2" => _("12 hours"), "3" => _("24 hours"), - "4" => _("2 days"), "5" => _("one week"), - "6" => _("2 weeks"), "7" => _("one month")); - $smarty->assign("tilist", $this->tilist); - } - - $smarty->assign("regex", $logfilter['regex']); - - - /* Get acls */ - - $tmp_cat_bases = $this->ui->get_module_departments("logview"); - $all_acls = ""; - foreach($tmp_cat_bases as $acl_base){ - $all_acls .= $this->ui->get_permissions($acl_base,"logview/logview"); - } - if(count($tmp_cat_bases) == 0 || !preg_match("/r/",$all_acls)){ - $res = " - - "._("You have insufficient permissions to view syslog entries.")." - - "; - - /* Show main page */ - $smarty->assign("range_selector", ""); - $smarty->assign("search_result", $res); - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - /* Query stuff */ - $res= ""; - $cfg = $this->config->data['SERVERS']['LOG']; - $tmp = set_error_handler('dummy_error_handler'); - $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); - set_error_handler($tmp); - - /* Test connection object && create up query string */ - if ($link === FALSE){ - print_red(_("Can't connect to log database, no logs can be shown!")); - new log("debug","logview","",array(),@mysql_error()); - } else { - if (! @mysql_select_db("gomon")){ - print_red(_("Can't select log database for log generation!")); - new log("debug","logview","",array(),@mysql_error()); - } else { - - /* Assemble time query */ - switch ($logfilter['time']){ - case '0': - $start= date ("YmdHis", time() - 3600); - break; - ;; - case '1': - $start= date ("YmdHis", time() - 21600); - break; - ;; - case '2': - $start= date ("YmdHis", time() - 43200); - break; - ;; - case '3': - $start= date ("YmdHis", time() - 86400); - break; - ;; - case '4': - $start= date ("YmdHis", time() - 172800); - break; - ;; - case '5': - $start= date ("YmdHis", time() - 604800); - break; - ;; - case '6': - $start= date ("YmdHis", time() - 1209600); - break; - ;; - case '7': - $start= date ("YmdHis", time() - 2419200); - break; - ;; - } - - /* Assemble log level query */ - if ($logfilter['log_level'] == '!All'){ - $ll= ""; - } else { - $ll= "AND log_level='".$logfilter['log_level']."'"; - } - if ($logfilter['host'] == '!All'){ - $hf= ""; - } else { - $hf= "AND host='".$logfilter['host']."'"; - } - - /* Order setting */ - if ($this->sort_direction == "down"){ - $desc= "DESC"; - $sort_sign = "\\/"; - } else { - $desc= ""; - $sort_sign="/\\"; - } - $end= date ("YmdHis"); - $query_base= " FROM - golog - WHERE - message like '".preg_replace("/\*/","%",$logfilter['regex'])."' - $ll - $hf - AND - time_stamp <= $end AND time_stamp >= $start"; - - /* Get number of entries */ - $query= "SELECT COUNT(*)".$query_base.";"; - $result = @mysql_query($query); - if(!$result){ - new log("debug","logview","",array(),@mysql_error()); - } - $line= mysql_fetch_array($result, MYSQL_ASSOC); - $count= $line['COUNT(*)']; - if ($count > 25){ - $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage")); - } else { - $smarty->assign("range_selector", ""); - } - - /* Query results */ - $query= "SELECT *".$query_base." ORDER BY ".$this->fields[$this->sort]." $desc LIMIT ".$this->start.",".$this->range.";"; - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query"); - $result = @mysql_query($query); - if(!$result){ - new log("debug","logview","",array(),@mysql_error()); - } - /* Display results */ - $mod= 0; - - /* Add entries to result str */ - while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){ - - /* Toggle background color */ - if ( ($mod++) & 1){ - $col= "background-color: #ECECEC;"; - } else { - $col= "background-color: #F5F5F5;"; - } - - $res.=" \n"; - $res.=" - \"".$line['log_level']."\" - "; - $res.=" ". - $line['host']." - "; - $res.=" ". - $line['time_stamp']." - "; - $res .= "". - $line['message']." - "; - $res.=" \n"; - } - mysql_close($link); - $smarty->assign("mode".$this->sort, $sort_sign); - $smarty->assign("host", $logfilter['host']); - $smarty->assign("log_level", $logfilter['log_level']); - - $smarty->assign("search_result", $res); - } - } - - /* Show main page */ - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - - function save_object() - { - /* Get submitted range */ - if(isset($_POST['EntriesPerPage'])){ - if(is_numeric($_POST['EntriesPerPage'])){ - $this->range = $_POST['EntriesPerPage']; - } - } - - /* Save data */ - $logfilter= get_global("logfilter"); - - /* Get actual select boxe values */ - $logfilter_changed = 0; - foreach( array("host", "time", "log_level", "regex") as $type){ - - /* Set new value and test if value has changed */ - $last[$type] = $logfilter[$type]; - if (isset($_POST[$type])){ - $logfilter[$type]= $_POST[$type]; - } - - if ($last[$type] != $logfilter[$type]){ - $logfilter_changed = 1; - } - } - - /* Filter regex values */ - if ($logfilter['regex'] == ""){ - $logfilter['regex']= '%'; - } else { - $new = preg_replace('/\*\**/', '*', $logfilter['regex']); - $logfilter['regex']= $new; - } - - /* Store filter values */ - register_global("logfilter", $logfilter); - - /* Set start value */ - if (isset($_GET['start'])){ - $this->start= (int)$_GET['start']; - } - - /* Reset page number if filter has changed */ - if ($logfilter_changed > 0){ - $this->start= 0; - } - - /* Adapt sorting */ - if (isset($_GET['sort'])){ - if ($this->sort == (int)$_GET['sort']){ - if ($this->sort_direction == "down"){ - $this->sort_direction= "up"; - } else { - $this->sort_direction= "down"; - } - } - $this->sort= (int)$_GET['sort']; - if ($this->sort < 0 || $this->sort > 3){ - $this->sort= 0; - } - } - } - - - /* Return plugin informations for acl handling - #FIXME You can only read attributes within this report plugin */ - static function plInfo() - { - return (array( - "plShortName" => _("Log view"), - "plDescription" => _("Log view addon"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("addon"), - "plCategory" => array("logview" => array("objectClass" => "none", "description" => _("System logs"))), - - "plProvidedAcls" => array() - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/logview/contents.tpl b/plugins/addons/logview/contents.tpl deleted file mode 100644 index 9a03544f3..000000000 --- a/plugins/addons/logview/contents.tpl +++ /dev/null @@ -1,105 +0,0 @@ -
-

[F]{t}Filter{/t}

-
-
- - - - - - - - - - - - -
- - - - - - - - - -
  - -
  - -
-
-   - - - - - - - - - - -
  - -
 
-
-   - - - - - - -
- -
-
-
- -
- -{if $search_result ne ""} - - - - - - - - {$search_result} -
{t}Level{/t} {$mode0}{t}Hostname{/t} {$mode1}{t}Date{/t} {$mode2}{t}Message{/t} {$mode3}
- - - - - -
{$range_selector}
- -{else} - {t}Search returned no results...{/t} -{/if} - - - diff --git a/plugins/addons/logview/gosa_log_contents.tpl b/plugins/addons/logview/gosa_log_contents.tpl deleted file mode 100644 index 5d71d8103..000000000 --- a/plugins/addons/logview/gosa_log_contents.tpl +++ /dev/null @@ -1,107 +0,0 @@ -
-

[F]{t}Filter{/t}

-
-
- - - - - - - - - - - - -
- - - - - - - - - -
  - -
  - -
-
-   - - - - - - - - - - -
  - -
 
-
-   - - - - - - -
- -
-
-
- -
- -{if $search_result ne ""} - - - - - - - - - - {$search_result} -
{t}Action{/t} {$mode0}{t}Date{/t} {$mode1}{t}User{/t} {$mode2}{t}Object type{/t} {$mode3}{t}Object{/t} {$mode4}{t}Message{/t} {$mode5}
- - - - - -
{$range_selector}
- -{else} - {t}Search returned no results...{/t} -{/if} - - - diff --git a/plugins/addons/logview/main.inc b/plugins/addons/logview/main.inc deleted file mode 100644 index 9ecb3161d..000000000 --- a/plugins/addons/logview/main.inc +++ /dev/null @@ -1,39 +0,0 @@ -data['TABS']['LOGTABS'],""); - } - $log_tabs= $_SESSION['log_tabs']; - - /* Execute formular */ -# $display= $log_tabs->save_object(); - $display= $log_tabs->execute (); - $display.= "\n"; - - /* Page header*/ - $display= print_header(get_template_path('images/logview.png'), _("System log view")).$display; - - /* Store changes in session */ - $_SESSION['log_tabs']= $log_tabs; -} -?> diff --git a/plugins/addons/logview/tabs_log.inc b/plugins/addons/logview/tabs_log.inc deleted file mode 100644 index bb855d28b..000000000 --- a/plugins/addons/logview/tabs_log.inc +++ /dev/null @@ -1,24 +0,0 @@ - diff --git a/plugins/addons/mailqueue/class_mailqueue.inc b/plugins/addons/mailqueue/class_mailqueue.inc deleted file mode 100644 index 6b1e6e46e..000000000 --- a/plugins/addons/mailqueue/class_mailqueue.inc +++ /dev/null @@ -1,418 +0,0 @@ -config = &$config; - if (isset($this->config->current['MAILQUEUESCRIPTPATH'])){ - $this->mailQueueScript = $this->config->current['MAILQUEUESCRIPTPATH']; - } - - if(isset($this->config->data['MAIN']['MAILQUEUESCRIPTPATH'])){ - $this->mailQueueScript = $this->config->data['MAIN']['MAILQUEUESCRIPTPATH']; - } - - $this->Server = "all"; - } - - - function pass_cmd($str) - { -// print_red($str); - return(shell_exec($str)); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","mailqueue/".get_class($this),$this->dn); - } - - if(isset($_POST['EntriesPerPage'])){ - $this->range = $_POST['EntriesPerPage']; - } - - $smarty= get_smarty(); - $error =false; - - if(empty($this->mailQueueScript)){ - print_red(_("Please check your 'gosa.conf', there is no 'MAILQUEUESCRIPTPATH' specified.")); - $error = true; - }else{ - - /* If we have more than one server selected (all), - create a string with all servers separated by ', ' - */ - if($this->Server=="all"){ - $se = $this->getServer(); - - unset($se['all']); - $se_str = ""; - foreach($se as $server) { - $se_str .= $server." "; - } - }else{ - /* We have only one server selected */ - $se_str = $this->Server; - } - - /* Check all post that will effect all entries */ - $only_once = true; - foreach(array("unhold_all","hold_all","del_all","requeue_all") as $attr){ - foreach($_POST as $name => $value){ - if((preg_match("/".$attr."/",$name))&&($only_once)){ - if(!$this->acl_is_readable($attr)){ - $only_once = false; - print_red(sprintf(_("You do not have permission to execute the command '%s' on the mailqueue."),$attr)); - }else{ - $only_once = false; - $act = preg_replace("/_.*$/i","",$attr); - $r_cmd = preg_replace("/%action/" , $act ,$this->mailQueueScript); - $r_cmd = preg_replace("/%server/" , $se_str ,$r_cmd); - $r_cmd = preg_replace("/%id/" , "ALL" ,$r_cmd); - if($this->pass_cmd($r_cmd)==false){ - print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); - } - } - } - } - } - - /* Check single entry manipulation posts */ - $only_once = true; - - /* act specifies the command to execute */ - if(isset($_GET['act'])){ - $opt = $_GET['act']; - - /* The option to exec should be one of these */ - if(in_array($opt,array("unhold","hold","del","requeue","query","header"))){ - $only_once = false; - - if(!$this->acl_is_readable($opt)){ - print_red(sprintf(_("You do not have permission to execute the command '%s' on the mailqueue."),$opt)); - }else{ - /* Create cmd */ - $r_cmd = preg_replace("/%action/" , $opt ,$this->mailQueueScript); - $r_cmd = preg_replace("/%server/" , $this->Server ,$r_cmd); - $r_cmd = preg_replace("/%id/" , $_GET['id'] ,$r_cmd); - - /* Execute cmd */ - if(!$str = $this->pass_cmd($r_cmd)){ - print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); - }else{ - - /* Special handling for option='header' */ - if($opt == "header"){ - - /* Create table which displays the header informations */ - $this->disp_header ="\n"; - foreach(split("\n",$str) as $line){ - $line = trim($line); - if(empty($line)) { - continue; - } - $this->disp_header .= "\n"; - $tmp0 = preg_replace("/:.*$/","",$line); - $tmp1 = preg_replace("/^.*:/","",$line); - $this->disp_header .= "\n"; - $this->disp_header .= "\n"; - } - $this->disp_header .= "\n
".$tmp0."".$tmp1."
"; - } - } - } - } - } - - - /* Back is posted from the header display page */ - if(isset($_POST['back'])){ - $this->disp_header = false; - } - - /* If there is a header in disp_header, then display it */ - if($this->disp_header){ - $smarty->assign("header",$this->disp_header); - return ($smarty->fetch (get_template_path('header.tpl', TRUE))); - } - - /* tell smarty to display the search results*/ - $smarty->assign("all_ok" , "true"); - - /* A single server is selected */ - if($this->Server != "all"){ - - /* Create Query cmd */ - $q_cmd = preg_replace("/%action/" ,"query" ,$this->mailQueueScript); - $q_cmd = preg_replace("/%server/" ,$this->Server,$q_cmd); - $q_cmd = preg_replace("/%id/" ,"all" ,$q_cmd); - - if(!$this->acl_is_readable("query")){ - print_red(sprintf(_("You do not have permission to execute the command '%s' on the mailqueue."),"query")); - $mailQueueParser = new parseMailQueue("",$this->Server); - }else{ - - /* Only display this if the query cmd is executeable */ - if($str = @$this->pass_cmd ($q_cmd)){ - /* Parse returned data */ - $mailQueueParser = new parseMailQueue($str,$this->Server); - }else{ - /* On error/ no return value / false return value */ - print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$q_cmd)); - $error = true; - } - } - }else{ - $mailQueueParser = NULL; - foreach($this->getServer() as $ServerID=>$ServerName){ - - /* Don't query the server named all :) */ - if($ServerID == "all") continue; - - /* Prepare query cmd */ - $q_cmd = preg_replace("/%action/" ,"query" ,$this->mailQueueScript); - $q_cmd = preg_replace("/%server/" ,$ServerName ,$q_cmd); - $q_cmd = preg_replace("/%id/" ,"ALL" ,$q_cmd); - - - if(!$this->acl_is_readable("query")){ - print_red(sprintf(_("You do not have permission to execute the command '%s' on the mailqueue."),"query")); - $mailQueueParser = new parseMailQueue("",$this->Server); - }else{ - - /* Shell exec this cmd */ - if($str = @$this->pass_cmd ($q_cmd)){ - - /* If there is no parser available, create one */ - if($mailQueueParser === NULL){ - $mailQueueParser = new parseMailQueue($str,$ServerID); - }else{ - $mailQueueParser->parseAdditionalQueue($str,$ServerID); - } - /* On error/ no return value / false return value */ - }else{ - print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$q_cmd)); - $error = true; - } - } - } - } - - /* Check for existing servers - objectClass=goMailServer is required at least for one server. - Else display error */ - $server = $this->getServer(); - if((count($server) == 1 ) && (isset($server['all']))){ - print_red(_("There are no mail server specified.")); - $error = true; - } - - if(!$error){ - - /* Filter data with the given */ - $mailQueueParser->OrderBy($this->OrderBy,$this->SortType); - $mailQueueParser->OnlyDaysAgo($this->Time); - $mailQueueParser->CreateDate(); - - if($this->Stat == "hold"){ - $mailQueueParser->Search(true,array("Hold"),true); - } - if($this->Stat == "unhold"){ - $mailQueueParser->Search(false,array("Hold"),true); - } - if($this->Stat == "active"){ - $mailQueueParser->Search(true,array("Active"),true); - } - if($this->Stat == "nonactive"){ - $mailQueueParser->Search(false,array("Active"),true); - } - - $mailQueueParser->Search($this->Search,array("MailID","Size","Sender","Recipient","Error","Arrival")); - - /* */ - $entries = $mailQueueParser->GetAll(); - - if(count($entries) ==0 ){ - $smarty->assign("all_ok",false); - } - - $smarty->assign("entries" , array_slice($entries,$this->Page,$this->range)); - $smarty->assign("plug" , "?plug=".$_GET['plug']); - $smarty->assign("r_stats" , $this->getStats()); - $smarty->assign("stats" , array_flip($this->getStats())); - $smarty->assign("stat" , $this->Stat); - $smarty->assign("p_server" , $this->Server); - $smarty->assign("p_servers" , $this->getServer()); - $smarty->assign("p_serverKeys" , array_flip($this->getServer())); - $smarty->assign("p_time" , $this->Time); - $smarty->assign("p_times" , $this->getTimes()); - $smarty->assign("p_timeKeys" , array_flip($this->getTimes())); - $smarty->assign("search_for" , $this->Search); - $smarty->assign("range_selector", range_selector(count($entries), $this->Page, $this->range,"EntriesPerPage")); - $smarty->assign("OrderBy" , $this->OrderBy); - - /* Display sort arrow */ - if($this->SortType == "up"){ - $smarty->assign("SortType",""._("up").""); - }else{ - $smarty->assign("SortType",""._("down").""); - } - } - } - - /* In case of an error */ - if($error){ - $smarty->assign("all_ok" , "false"); - $smarty->assign("r_stats" , $this->getStats()); - $smarty->assign("stats" , array_flip($this->getStats())); - $smarty->assign("stat" , $this->Stat); - $smarty->assign("plug" , "?plug=".$_GET['plug']); - $smarty->assign("p_server" , $this->Server); - $smarty->assign("p_servers" , $this->getServer()); - $smarty->assign("p_serverKeys" , array_flip($this->getServer())); - $smarty->assign("p_time" , $this->Time); - $smarty->assign("p_times" , $this->getTimes()); - $smarty->assign("p_timeKeys" , array_flip($this->getTimes())); - $smarty->assign("search_for" , $this->Search); - $smarty->assign("OrderBy" , $this->OrderBy); - } - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - - /* return selectable server */ - function getServer() - { - $ret= array("all"=>_("All")); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=goMailServer)",array("cn")); - while($tmp = $ldap->fetch()){ - $ret[$tmp['cn'][0]]= $tmp['cn'][0]; - } - return($ret); - } - - - /* Return selectable times*/ - function getTimes() - { - $ret = array(); - $ret['nolimit']=_("no limit"); - foreach(array(1,2,4,8,12,24,36,48) as $i){ - if($i == 1){ - $ret[$i] = $i." "._("hour"); - }else{ - $ret[$i] = $i." "._("hours"); - } - } - return($ret); - } - - - /* Save post values*/ - function save_object($save_current= FALSE) - { - if(isset($_POST['p_server'])){ - $this->Server = $_POST['p_server']; - } - if(isset($_POST['p_time'])){ - $this->Time = $_POST['p_time']; - } - if(isset($_POST['search_for'])){ - $this->Search = $_POST['search_for']; - } - if(isset($_POST['Stat'])){ - $this->Stat = $_POST['Stat']; - } - if((isset($_GET['start']))&&(is_numeric($_GET['start']))&&($_GET['start']>=0)){ - $this->Page = $_GET['start']; - } - - if((isset($_GET['sort']))&&(!empty($_GET['sort']))){ - $old = $this->OrderBy; - $this->OrderBy = $_GET['sort']; - if($this->OrderBy == $old) - { - if($this->SortType== "up"){ - $this->SortType = "down"; - }else{ - $this->SortType = "up"; - } - } - } - - } - - /* Return stats */ - function getStats() - { - return(array( - "all" =>_("All"), - "hold" =>_("Hold"), - "unhold" =>_("Un hold"), - "active" =>_("Active"), - "nonactive" =>_("Not active") - )); - } - - /* Return plugin informations for acl handling - #FIXME You can only read attributes within this report plugin */ - static function plInfo() - { - return (array( - "plShortName" => _("Mailqueue"), - "plDescription" => _("Mailqueue addon"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("addon"), - "plCategory" => array("mailqueue" => array("objectClass" => "none", "description" => _("Mail queue addon"))), - - "plProvidedAcls" => array( - "unhold_all" => _("Unhold all messages"), - "hold_all" => _("Hold all messages"), - "del_all" => _("Delete all messages"), - "requeue_all" => _("Requeue all messages"), - "unhold" => _("Unhold message"), - "hold" => _("Hold message"), - "del" => _("Delete message"), - "requeue" => _("Requeue message"), - "query" => _("Gathering queue data"), - "header" => _("Get header information") - ) - )); - } - - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/mailqueue/class_parseMailQueue.inc b/plugins/addons/mailqueue/class_parseMailQueue.inc deleted file mode 100644 index b510cb3a7..000000000 --- a/plugins/addons/mailqueue/class_parseMailQueue.inc +++ /dev/null @@ -1,237 +0,0 @@ -s_dataToParse = $s_data; - $this->a_parsedData = array(); - $this->_parse($s_data,$server); - } - - - /* Remove all entries which are older than the last x hours - */ - function OnlyDaysAgo($str) - { - /* Get current time */ - $cur = time(); - - /* Only perform this filter, if the given parameter is valid */ - if((is_numeric($str))&&($str != 0)){ - - /* hours are given as parameter */ - $cur = $cur - ($str*(60*60)); - - /* Remove old entries */ - foreach($this->a_parsedData as $key => $data){ - if($data['Arrival'] < $cur){ - unset($this->a_parsedData[$key]); - } - } - } - } - - - /* Only keep entries that contains the $filter - * in any of the given $fields - */ - function Search($filter,$fields,$bool = false) - { - /* Go through all entries */ - foreach($this->a_parsedData as $key => $data){ - - /* not found yet */ - $found = false; - - foreach($fields as $attr){ - if(($bool)&&($data[$attr]==$filter)){ - $found = true; - }elseif(preg_match("/".str_replace("*",".*",$filter)."/i",$data[$attr])){ - $found= true; - } - } - - /* if nothing found, delete this entry */ - if($found == false){ - unset($this->a_parsedData[$key]); - } - } - } - - /* Convert date from timestamp to human readable */ - function CreateDate() - { - foreach($this->a_parsedData as $key => $data){ - $this->a_parsedData[$key]['Arrival'] = date("d.m.Y H:i:s",$data['Arrival']); - } - } - - /* Order by specified field */ - function OrderBy($str = "Arrival",$type = "up" ) - { - $tmp = array(); - /* If the given field is not valid */ - if(!in_array($str,array("MailID","Size","Sender","Recipient","Arrival","Error","Server"))){ - return(false); - } - - /* Size need special handling, cause it contains numbers - */ - if($str == "Size"){ - foreach($this->a_parsedData as $data){ - $struse = ""; - for($i = strlen($data['Size']); $i < 10 ; $i++ ){ - $struse .="0"; - } - $struse .= $data[$str].$data['MailID'].$data['Server']; - $tmp[$struse]= $data; - } - }else{ - foreach($this->a_parsedData as $data){ - $tmp[strtolower($data[$str]).$data['MailID']."-".$data['Server']]= $data; - } - } - ksort($tmp); - if($type != "up"){ - $tmp = array_reverse($tmp); - } - $this->a_parsedData = array(); - foreach($tmp as $data){ - $this->a_parsedData[$data['MailID']."-".$data['Server']] = $data; - } - return(true); - } - - function GetAll() - { - return($this->a_parsedData); - } - - /* Checks if the given MailID exists */ - function IDExists($id) - { - foreach($this->a_parsedData as $entry){ - if($entry['MailID'] == $id) return(true); - } - return(false); - } - - function parseAdditionalQueue($str, $server) - { - $this->_parse($str, $server); - } - - /* This function parses the given data - * it creates an array with all given queue entries - */ - function _parse($str, $server) - { - $i = 0; // Temp var - $entries = array(); // Contains an array with the raw data for every single entry - $s_tmp = ""; // Buffer - - $s_mailID = ""; // Queue ID - $s_Size = ""; // Mail size - $s_Arrival = ""; // Arrival time - $s_Sender = ""; // Sender - $s_Recipient = ""; // Recipient - $s_Error = ""; // Occured error - - /* Remove header - */ - $this->s_dataToParse = preg_replace("/^.*------\n/","",$str); - - /* Create array with single entries - */ - $entries = split("\n\n",$this->s_dataToParse); - - /* The last entry in this array is not realy an valid entry, its some kind of status. - * It would be something like this : -- 795 Kbytes in 124 Requests. - */ - $this->i_count = (count($entries))-1; - - for($i = 0 ; $i < $this->i_count; $i ++ ){ - - while(strstr($entries[$i]," ")){ - $entries[$i] = str_replace(" "," ",$entries[$i]); - } - - $s_buffer = split("\n",preg_replace("/[\\n\\r\\t]/s","\n",$entries[$i])); - - /* Get mailID */ - $tmp = split(" ",$s_buffer[0]); - - /* Get values */ - $s_mailID = $tmp[0]; - $s_Size = $tmp[1]; - $s_Sender = $tmp[6]; - - /* Parse time */ - $tmp3 = split(":",$tmp[5]); - $tmp2 = strtotime($tmp[4]." ".$tmp[3]." ".date("Y")); - $s_Arrival= mktime($tmp3[0],$tmp3[1],$tmp3[2],date("d",$tmp2),date("m",$tmp2),date("Y",$tmp2)); - - $s_Error = $s_buffer[1]; - $s_Recipient = $s_buffer[2]; - - /* - * The message is in the active queue, i.e. the message is - selected for delivery. - - ! The message is in the hold queue, i.e. no further deliv-delivery - ery attempt will be made until the mail is taken off - hold. - */ - - $s_Hold = false; - if(preg_match("/\!/",$s_mailID)){ - $s_mailID = preg_replace("/\!/","",$s_mailID); - $s_Hold = "true"; - } - - $s_Active = false; - if(preg_match("/\*/",$s_mailID)){ - $s_mailID = preg_replace("/\*/","",$s_mailID); - $s_Active = true; - } - - /* Append data */ - $this->a_parsedData[$s_mailID."-".$server]['Server'] = $server; - $this->a_parsedData[$s_mailID."-".$server]['MailID'] = $s_mailID; - $this->a_parsedData[$s_mailID."-".$server]['Size'] = $s_Size; - $this->a_parsedData[$s_mailID."-".$server]['Arrival'] = $s_Arrival; - $this->a_parsedData[$s_mailID."-".$server]['Sender'] = $s_Sender; - $this->a_parsedData[$s_mailID."-".$server]['Recipient'] = $s_Recipient; - $this->a_parsedData[$s_mailID."-".$server]['Hold'] = $s_Hold; - $this->a_parsedData[$s_mailID."-".$server]['Active'] = $s_Active; - $this->a_parsedData[$s_mailID."-".$server]['Error'] = $this->_parseError($s_Error); - } - return($this->a_parsedData); - } - - /* Parse Error part of the entry */ - function _parseError($str) - { - $str = trim(preg_replace("/[()]/","",$str)); - $tmp2 = split(":",$str); - $tmp = array_reverse($tmp2); - $err = preg_replace("/#.*$/","",$tmp[0]); - $text = preg_replace("/said$/i","",trim($tmp2[0])); - return($err); - } - -} - - - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/mailqueue/contents.tpl b/plugins/addons/mailqueue/contents.tpl deleted file mode 100644 index 139bcd481..000000000 --- a/plugins/addons/mailqueue/contents.tpl +++ /dev/null @@ -1,130 +0,0 @@ -
 
-
-

[F]Filter

-
-
-
- - - - - -
- {t}Search{/t} -  {t}Search for{/t} - -  in - - {t}with status{/t} : - -  {t}within the last{/t}  - -   - -   - - - - -
-
-
-
- - -{if $all_ok != "true"} -{t}Search returned no results{/t}... -{else} - - - - - - - - - - - - - -{counter start=0 assign=i start=1} -{foreach from=$entries item=val key=key} - - {if ($i%2)== 0 } - - {else} - - {/if} - - - - - - - - - - {counter} -{/foreach} -
{t}ID{/t} {if $OrderBy == "MailID"} {$SortType}{/if}{t}Server{/t} {if $OrderBy == "Server"} {$SortType}{/if}{t}Size{/t} {if $OrderBy == "Size"} {$SortType}{/if}{t}Arrival{/t} {if $OrderBy == "Arrival"} {$SortType}{/if}{t}Sender{/t} {if $OrderBy == "Sender"} {$SortType}{/if}{t}Recipient{/t} {if $OrderBy == "Recipient"}{$SortType}{/if}{t}Error{/t} {if $OrderBy == "Error"} {$SortType}{/if} 
- - {if $entries[$key].Active == true} - {t}Active{/t} - {/if} - - {$entries[$key].MailID} - - {$entries[$key].Server} - {$entries[$key].Size} - {$entries[$key].Arrival} - {$entries[$key].Sender} - {$entries[$key].Recipient}{$entries[$key].Error} - - {t}delete{/t} - - {if $entries[$key].Hold == true} - - {t}unhold{/t} - - {else} - - {t}hold{/t} - - {/if} - - {t}requeue{/t} - - - {t}header{/t} - -
- - - - - -
{$range_selector}
-

 

- -{/if} - - diff --git a/plugins/addons/mailqueue/header.tpl b/plugins/addons/mailqueue/header.tpl deleted file mode 100644 index eeb8bcfbc..000000000 --- a/plugins/addons/mailqueue/header.tpl +++ /dev/null @@ -1,6 +0,0 @@ -{$header} - -

 

-
- -
diff --git a/plugins/addons/mailqueue/main.inc b/plugins/addons/mailqueue/main.inc deleted file mode 100644 index 09bbe568c..000000000 --- a/plugins/addons/mailqueue/main.inc +++ /dev/null @@ -1,47 +0,0 @@ -set_acl_category("mailqueue"); - - /* Check root dn and user dn for acl informations */ - $_SESSION['mailqueue']->set_acl_base($config->current['BASE']); - if($_SESSION['mailqueue']->getacl("") == ""){ - $_SESSION['mailqueue']->set_acl_base($ui->dn); - } - } - $mailqueue= $_SESSION['mailqueue']; - - /* Execute formular */ - $mailqueue->save_object(); - $display= $mailqueue->execute (); - $display.= "\n"; - - /* Page header*/ - $display= print_header(get_template_path('images/mailqueue.png'), _("Mail queue")).$display; - - /* Store changes in session */ - $_SESSION['mailqueue']= $mailqueue; -} -?> diff --git a/plugins/addons/notifications/class_msgplug.inc b/plugins/addons/notifications/class_msgplug.inc deleted file mode 100644 index edbab55ee..000000000 --- a/plugins/addons/notifications/class_msgplug.inc +++ /dev/null @@ -1,258 +0,0 @@ -config= &$config; - $ui= get_userinfo(); - $tag= $ui->gosaUnitTag; - - /* Preset values */ - $this->targets= array("user" => _("Users"), "group" => _("Groups")); - asort($this->targets); - - $res = get_list("(objectClass=gosaAccount)", "users", $this->config->current['BASE'],array('uid', 'cn'),GL_SUBSEARCH); - foreach($res as $key => $attrs){ - $this->users['U:'.$attrs['uid'][0]]= $attrs['cn'][0].' ['.$attrs['uid'][0].']'; - } - ksort($this->users); - - $res = get_list("(objectClass=posixGroup)", "groups", $this->config->current['BASE'],array('cn','description')); - foreach($res as $key => $attrs){ - $dsc= ""; - if (isset($attrs['description'][0])){ - $dsc= $attrs['description'][0]; - } - $this->groups['G:'.$attrs['cn'][0]]= $attrs['cn'][0].' ['.$dsc.']'; - } - ksort($this->users); - - - /* Load templates */ - if (isset($this->config->current['NOTIFYDIR'])){ - $dir= $this->config->current['NOTIFYDIR']; - if (is_dir($dir) && is_readable($dir)){ - - /* Look for files and build the vacation array */ - $dh= opendir($dir); - while ($file = readdir($dh)){ - $description= $this->parse_notification("$dir/$file"); - if ($description != ""){ - $this->templates["$dir/$file"]= $description; - } - } - closedir($dh); - } - - /* Enable templates if there are some... */ - if (count($this->templates)){ - $this->show_templates= true; - } - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","msgplug/".get_class($this),$this->dn); - } - - /* Send message? */ - if (isset($_POST['send']) && $this->acl_is_writeable("notify")){ - - /* Do we have recipients? */ - if (count($this->recipients)){ - - /*Permissions ok? */ - if (!$this->acl_is_writeable('notify')){ - print_red(_("You have no permissions to send a message!")); - } else { - $cmd= $this->config->search("msgplug", "NOTIFY_COMMAND",array('menu')); - if ($cmd == ""){ - print_red(_("No NOTIFY_COMMAND definition found in your gosa.conf")); - } else { - $parameters= base64_encode($this->nmessage) ." "; - foreach ($this->recipients as $key => $value){ - $parameters.= "$key "; - } - exec ("$cmd $parameters", $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } - $this->finalized= true; - } - } - } else { - print_red(_("Please specify at least one recipient to send a message!")); - } - } - - /* Bounce back to the original dialog */ - if (isset($_POST['continue'])){ - $this->finalized= false; - } - - /* Add to list? */ - if (isset($_POST['add']) && isset($_POST['source']) && $this->acl_is_writeable("notify")){ - foreach ($_POST['source'] as $key){ - if ($this->target == 'user'){ - if(isset($this->users[$key])){ - $this->recipients[$key]= $this->users[$key]; - } - } - if ($this->target == 'group'){ - if(isset($this->groups[$key])){ - $this->recipients[$key]= $this->groups[$key]; - } - } - } - ksort($this->recipients); - } - - /* Remove from list? */ - if (isset($_POST['del']) && isset($_POST['recipient'])){ - foreach ($_POST['recipient'] as $key){ - unset($this->recipients[$key]); - } - } - - /* Import message? */ - if (isset($_POST["import_template"]) && isset($this->templates[$_POST["nmessage_template"]])){ - $contents= ""; - $lines= file($_POST["nmessage_template"]); - foreach ($lines as $line){ - if (!preg_match('/^DESC:/', $line)){ - $contents.= $line; - } - } - - /* Replace attributes */ - $ui= get_userinfo(); - $contents= preg_replace('/%self/', $ui->cn, $contents); - - /* Save message */ - $this->nmessage= htmlspecialchars($contents); - } - - $smarty= get_smarty(); - - /* Assign possible target types */ - $smarty->assign("targets", $this->targets); - foreach ($this->attributes as $attr){ - $smarty->assign($attr, $this->$attr); - } - - /* Generate list */ - $tmp= array(); - foreach (array("user" => "users", "group" => "groups") as $field => $arr){ - if ($this->target == $field){ - foreach ($this->$arr as $key => $value){ - if (!isset($this->recipients[$key])){ - $tmp[$key]= $value; - } - } - } - } - $smarty->assign('sources', $tmp); - $smarty->assign('recipients', $this->recipients); - - /* Assign ACL */ - $smarty->assign('nmessageACL', $this->getacl("notify")); - - /* Handle templates */ - $smarty->assign('show_templates', $this->show_templates?"true":"false"); - $smarty->assign('message_templates', $this->templates); - $smarty->assign('template', $this->template); - $smarty->assign('finished', $this->finalized?"true":"false"); - - /* Show main page */ - return ($smarty->fetch (get_template_path('contents.tpl', TRUE))); - } - - - function parse_notification($file) - { - $desc= ""; - - if (is_file($file)){ - $fh = fopen($file, "r"); - $line= fgets($fh, 256); - - if (!preg_match('/^DESC:/', $line)){ - print_red (_("No DESC tag in message file:")." $file"); - return $desc; - } - fclose ($fh); - - $desc= trim(preg_replace('/^DESC:\s*/', '', $line)); - } - - return $desc; - } - - - function save_object() - { - plugin::save_object(); - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Notification"), - "plDescription" => _("Notification plugin"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 89, - "plSection" => array("addon"), - "plCategory" => array("msgplug" => array("objectClass" => "none", "description" => _("Notification plugin"))), - - "plProvidedAcls" => array( - "notify" => _("Allow sending notifications") - ) - )); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/addons/notifications/contents.tpl b/plugins/addons/notifications/contents.tpl deleted file mode 100644 index 689869613..000000000 --- a/plugins/addons/notifications/contents.tpl +++ /dev/null @@ -1,80 +0,0 @@ -{if $finished eq "false"} -

{t}Notification target{/t}

- - - - - - - - - - - - -
- {t}Use target from{/t} - - {if $javascript eq 'false'}{/if}

-
- -
- {t}Available recipients{/t}
- -
- -

- -
- {t}Recipients{/t}
- -
- - -

 

-

{t}Message{/t}

-{render acl=$nmessageACL} - -{/render} - -{if $show_templates eq "true"} - - -{/if} - -

 

-
-{render acl=$nmessageACL} - -{/render} -
- - - - -{else} -

{t}Notification send!{/t}

-

 

-
-{t}Your message has been sent successfully. Press the continue button to get back to the notification plugin.{/t} -

 

-
- -
-{/if} diff --git a/plugins/addons/notifications/main.inc b/plugins/addons/notifications/main.inc deleted file mode 100644 index c73698541..000000000 --- a/plugins/addons/notifications/main.inc +++ /dev/null @@ -1,51 +0,0 @@ -set_acl_category("msgplug"); - - /* Check root dn and user dn for acl informations */ - $_SESSION['msgplug']->set_acl_base($config->current['BASE']); - if($_SESSION['msgplug']->getacl("") == ""){ - $_SESSION['msgplug']->set_acl_base($ui->dn); - } - } - $msgplug= $_SESSION['msgplug']; - - /* save changes back to object */ - if (isset ($_POST['target'])){ - $msgplug->save_object (); - } - - /* Execute formular */ - $display= $msgplug->execute (); - $display.= "\n"; - - /* Page header*/ - $display= print_header(get_template_path('images/notifications.png'), _("Notifications")).$display; - - /* Store changes in session */ - $_SESSION['msgplug']= $msgplug; -} -?> diff --git a/plugins/admin/acl/acl_role.tpl b/plugins/admin/acl/acl_role.tpl deleted file mode 100644 index 17a2704b7..000000000 --- a/plugins/admin/acl/acl_role.tpl +++ /dev/null @@ -1,78 +0,0 @@ -{if $dialogState eq 'head'} - -

{t}Assigned ACLs for current entry{/t}

- - - - - - - - - - - - - -
- {t}Name{/t} - -{render acl=$cnACL} - -{/render} -
- {t}Description{/t} - -{render acl=$descriptionACL} - -{/render} -
- {t}Base{/t} - -{render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} - -
-{$aclList} - - -{/if} - -{if $dialogState eq 'create'} -

{t}ACL type{/t}  {if $javascript eq 'false'}{/if}

- -

 

- - -

{t}List of available ACL categories{/t}

-{$aclList} - -

 

-
- -   - -
-{/if} - -{if $dialogState eq 'edit'} - -

{$headline}

- -{$aclSelector} - -

 

-
- -   - -
-{/if} - diff --git a/plugins/admin/acl/class_aclManagement.inc b/plugins/admin/acl/class_aclManagement.inc deleted file mode 100644 index fd784ed0b..000000000 --- a/plugins/admin/acl/class_aclManagement.inc +++ /dev/null @@ -1,656 +0,0 @@ - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -class aclManagement extends plugin -{ - /* Plugin definitions */ - var $plHeadline = "ACLs"; - var $plDescription = "This does something"; - - /* Dialog attributes */ - var $acltabs = NULL; - var $ui = NULL; - var $acl = ""; - var $DivListACL = NULL; - - var $CopyPasteHandler; - var $start_pasting_copied_objects = FALSE; - - function aclManagement(&$config, &$ui) - { - /* Save configuration for internal use */ - $this->config = &$config; - $this->ui = &$ui; - - /* Copy & Paste enabled ?*/ - if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - - /* Creat dialog object */ - $this->DivListACL = new divListACL($this->config,$this); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - $_SESSION['LOCK_VARS_TO_USE'] = array("/^list/","/^id_/","/^list_acl_role_del/","/^list_acl_del/"); - - $smarty = get_smarty(); // Smarty instance - $s_action = ""; // Contains the action to be taken - $s_entry = ""; // The value for s_action - - /* Edit entry button pressed? */ - if( isset($_GET['act']) && $_GET['act'] == "list_edit_entry" ){ - $s_action= "edit"; - $s_entry= validate($_GET['id']); - } - - /* Edit entry button pressed? */ - if( isset($_GET['act']) && $_GET['act'] == "list_edit_role" ){ - $s_action= "edit_role"; - $s_entry= validate($_GET['id']); - } - - $types = array( - "del" =>"^list_acl_del", - "edit" =>"^list_acl_edit", - "del_role" =>"^list_acl_role_del", - "edit_role" =>"^list_acl_role_edit", - "copy" =>"^copy", - "cut" =>"^cut", - "copy_multiple"=> "^multiple_copy_objects", - "cut_multiple" => "^multiple_cut_objects", - "editPaste" =>"^editPaste", - "addrole" =>"^new_acl_role"); - - /* Test relevant POST values */ - foreach($_POST as $key => $val){ - - /* Get every possible POST combination and set s_action/s_entry accordingly */ - foreach($types as $act => $name){ - - if (preg_match("/".$name.".*/", $key)){ - $s_action= $act; - $s_entry= preg_replace("/".$name."_/i", "", $key); - } - } - } - - /* Remove coordinate prefix from POST, required by some browsers */ - $s_entry= preg_replace("/_.$/", "", $s_entry); - - /* Seperate possibly encoded tab and entry, default to tab "acl" */ - if(preg_match("/.*-.*/", $s_entry)){ - $s_tab= preg_replace("/^[^-]*-/i", "" ,$s_entry); - $s_entry= preg_replace("/-[^-]*$/i", "", $s_entry); - }else{ - $s_tab= "generic"; - } - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "new_acl_role"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - /******************** - Copy & Paste Handling ... - ********************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /******************** - * Add new Role entry - ********************/ - - if(($s_action == "addrole") && (!isset($this->acltabs->config))){ - - /* Get 'dn' from posted acl, must be unique */ - $this->dn= "new"; - - /* Check permissions */ - if(preg_match("/c/",$this->ui->get_permissions($this->DivListACL->selectedBase,"acl/acl"))){ - - /* Register acltabs to trigger edit dialog */ - $this->acltabs= new aclroletab($this->config, NULL,$this->dn); - $this->acltabs->set_acl_base($this->DivListACL->selectedBase); - }else{ - print_red(_("You are not allowed to create a new role.")); - } - } - - /******************** - Edit existing entry - ********************/ - - if (($s_action=="edit" || $s_action=="edit_role") && (!isset($this->acltabs->config))){ - - /* Get 'dn' from posted acl, must be unique */ - $this->dn= $this->list[trim($s_entry)]['dn']; - - /* Check permissions */ - if(preg_match("/r/",$this->ui->get_permissions($this->dn,"acl/acl"))){ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($acl= get_lock($this->dn)) != ""){ - return(gen_locked_message ($acl, $this->dn)); - } - - /* Lock the current entry, so everyone will get the above dialog */ - add_lock ($this->dn, $this->ui->dn); - - /* Register acltabs to trigger edit dialog */ - if($s_action=="edit_role"){ - $this->acltabs= new aclroletab($this->config, NULL,$this->dn); - $this->acltabs-> set_acl_base($this->dn); - }else{ - $this->acltabs= new acltab($this->config, NULL,$this->dn); - $this->acltabs-> set_acl_base($this->dn); - } - - /* Set ACL and move DN to the headline */ - $_SESSION['objectinfo']= $this->dn; - }else{ - print_red(_("You are not allowed to edit this acl.")); - } - } - - - /******************** - Edit canceled - ********************/ - if(isset($_POST['delete_lock'])){ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - /* Reset all relevant data, if we get a _cancel request */ - if (isset($_POST['edit_cancel'])){ - if (isset($this->acltabs)){ - del_lock ($this->dn); - unset ($this->acltabs); - } - $this->acltabs= NULL; - unset ($_SESSION['objectinfo']); - } - - - /******************** - Delete entry requested, display confirm dialog - ********************/ - - /* Remove acl was requested */ - if ($s_action=="del_role"){ - - /* Get 'dn' from posted acl */ - $this->dn= $this->list[trim($s_entry)]['dn']; - - /* Check permissions */ - if(preg_match("/d/",$this->ui->get_permissions($this->dn,"aclroles/aclrole"))){ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($acl= get_lock($this->dn)) != ""){ - return(gen_locked_message ($acl, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the acl %s."), @LDAP::fix($this->dn))); - $smarty->assign("is_role",true); - - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the acl isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this acl!")); - } - } - - - /******************** - Delete entry confirmed - ********************/ - - /* Confirmation for deletion has been passed. Acl should be deleted. */ - if (isset($_POST['delete_acl_role_confirmed'])){ - - /* Check permissions */ - if(preg_match("/d/",$this->ui->get_permissions($this->dn,"aclroles/aclrole"))){ - - /* Delete request is permitted, perform LDAP action */ - $this->acltabs= new aclroletab($this->config, NULL,$this->dn); - $this->acltabs->delete(); - unset ($this->acltabs); - $this->acltabs= NULL; - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this acl role!")); - - if(isset($this->ui->uid)){ - new log("security","aclroles/".get_class($this),$this->dn,array(),"Warning: '".$this->ui->uid."' tried to trick acl role deletion."); - } - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - /******************** - Delete entry requested, display confirm dialog - ********************/ - - /* Remove acl was requested */ - if ($s_action=="del"){ - - /* Get 'dn' from posted acl */ - $this->dn= $this->list[trim($s_entry)]['dn']; - - /* Check permissions */ - if(preg_match("/d/",$this->ui->get_permissions($this->dn,"acl/acl"))){ - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($acl= get_lock($this->dn)) != ""){ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^list_acl_edit/","/^list_acl_del/","/^id_/"); - return(gen_locked_message ($acl, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the acl %s."), @LDAP::fix($this->dn))); - $smarty->assign("is_role",false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the acl isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this acl!")); - } - } - - - /******************** - Delete entry confirmed - ********************/ - - /* Confirmation for deletion has been passed. Acl should be deleted. */ - if (isset($_POST['delete_acl_confirm'])){ - - /* Check permissions */ - if(preg_match("/d/",$this->ui->get_permissions($this->dn,"acl/acl"))){ - - /* Delete request is permitted, perform LDAP action */ - $this->acltabs= new acl($this->config, NULL,$this->dn); - $this->acltabs->remove_from_parent(); - unset ($this->acltabs); - $this->acltabs= NULL; - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this acl!")); - - if(isset($this->ui->uid)){ - new log("security","aclroles/".get_class($this),$this->dn,array(),"Warning: '".$this->ui->uid."' tried to trick acl role deletion."); - - } - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - - /******************** - Delete entry Canceled - ********************/ - - /* Delete acl canceled? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - } - - - /******************** - Edit entry finished (Save) - ********************/ - - /* Finish acl edit is triggered by the tabulator dialog, so - the acl wants to save edited data. Check and save at this - point. */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->acltabs->config))){ - - /* Check tabs, will feed message array */ - $this->acltabs->save_object(); - $message= $this->acltabs->check(); - - /* Save, or display error message? */ - if (count($message) == 0){ - - /* Save acl data to ldap */ - if($this->acltabs->save() == 1){ - return; - } - - if (!isset($_POST['edit_apply'])){ - - /* ACl has been saved successfully, remove lock from LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - - unset ($this->acltabs); - $this->acltabs= NULL; - unset ($_SESSION['objectinfo']); - } - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /******************** - Display subdialog - ********************/ - - - /* Show tab dialog if object is present */ - if(isset($this->acltabs->config)){ - - /* Save object */ - $this->acltabs->save_object(); - $display= $this->acltabs->execute(); - - /* Don't show buttons if tab dialog requests this */ - if(isset($this->acltabs)){ - - /* Skip displaying save/cancel if there is a sub dialog open */ - if (!isset($this->acltabs->dialog) || !$this->acltabs->dialog){ - $display.= "

\n"; -// $display.= "\n"; - $display.= " \n"; - - /* Skip Apply if it is a new entry */ - #if ($this->dn != "new"){ - # $display.= "\n"; - # $display.= " \n"; - #} - - // $display.= "\n"; - $display.= "

"; - } - } - return ($display); - } - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListACL->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Return rendered main page */ - /* Display dialog with system list */ - $this->DivListACL->parent = $this; - $this->DivListACL->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListACL->SubSearch){ - $this->DivListACL->AddDepartments($this->DivListACL->selectedBase,3,1); - } - $this->reload(); - $this->DivListACL->setEntries($this->list); - return($this->DivListACL->Draw()); - } - - - function reload() - { - /* Get divlist informations from filter part */ - $Regex = $this->DivListACL -> Regex; - $SubSearch = $this->DivListACL -> SubSearch; - $base = $this->DivListACL -> selectedBase; - $Attrs = array("ou","cn","description","gosaAclEntry","objectClass"); - $res = array(); - $tmp = array(); // Will contain temporary results - $ldap = $this->config->get_ldap_link(); - $Filter = "(&(objectClass=gosaACL)(gosaAclEntry=*)(|(cn=".$Regex.")(ou=".$Regex.")))"; - $FilterRoles= "(&(objectClass=gosaRole)(|(cn=".$Regex.")(ou=".$Regex.")))"; - - /* Fetch following structures, this will be used if !$SubSearch */ - $fetch_this = array( - "ME" => array("TYPE" => "cat" , "FLAGS" => GL_SIZELIMIT ,"BASE"=>""), - "SYSTEMS" => array("TYPE" => "search" , "FLAGS" => GL_SIZELIMIT | GL_SUBSEARCH ,"BASE"=>"ou=systems,"), - "APPS" => array("TYPE" => "search" , "FLAGS" => GL_SIZELIMIT | GL_SUBSEARCH ,"BASE"=>"ou=apps,"), - "PEOPLE" => array("TYPE" => "search" , "FLAGS" => GL_SIZELIMIT | GL_SUBSEARCH ,"BASE"=>get_people_ou()), - "GROUPS" => array("TYPE" => "search" , "FLAGS" => GL_SIZELIMIT | GL_SUBSEARCH ,"BASE"=>get_groups_ou())); - - /* Subsearch ? */ - if($SubSearch){ - - /* Get all object in this base */ - $Flags = GL_SIZELIMIT | GL_SUBSEARCH; - $fetch_base = $base; - $tmp = get_list($Filter, "acl", $fetch_base, $Attrs, $Flags); - $tmp2 = get_list($FilterRoles, "acl", $fetch_base, $Attrs, $Flags); - foreach($tmp as $entry){ - $res[] = $entry; - } - foreach($tmp2 as $entry){ - $res[] = $entry; - } - - }else{ - - $tmp_roles = get_list($FilterRoles, "acl", "ou=aclroles,".$base, $Attrs,GL_SIZELIMIT); - - foreach($tmp_roles as $entry){ - $res[] = $entry; - } - - /* Walk through all possible bases */ - foreach($fetch_this as $type => $data){ - - /* Get requried attributes */ - $Flags = $data['FLAGS']; - $fetch_base = $data['BASE'].$base; - $Type = $data['TYPE']; - - /* Check if method is cat or search */ - if($Type == "search"){ - $tmp = get_list($Filter, "acl", $fetch_base, $Attrs, $Flags); - foreach($tmp as $entry){ - $res[] = $entry; - } - }else{ - $ldap->cat($fetch_base,$Attrs); - $attrs = $ldap->fetch(); - if($attrs && isset($attrs['gosaAclEntry'])){ - $re2 = preg_replace("/\*/",".*",$Regex); - - if(!isset($attrs['ou']) && !isset($attrs['cn'])){ - $namingAttr= preg_replace("/^[^=]*+=([^,]*),.*$/","\\1",$fetch_base); - if(preg_match("/".$re2."/i",$namingAttr)){ - $res[] = $attrs; - } - }elseif( (isset($attrs['cn'][0]) && preg_match("/".$re2."/i",$attrs['cn'][0])) - ||(isset($attrs['ou'][0]) && preg_match("/".$re2."/i",$attrs['ou'][0]))){ - $res[] = $attrs; - } - } - } - } - } - $this->list = $res; - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->list[$s_entry]['dn']; - - if(isset($this->list[$s_entry]['objectClass']) && in_array("gosaRole",$this->list[$s_entry]['objectClass'])){ - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"aclroletab","ACLROLETAB","aclroles"); - } - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->list[$id]['dn']; - - if(isset($this->list[$id]['objectClass']) && in_array("gosaRole",$this->list[$id]['objectClass'])){ - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","aclroletab","ACLROLETAB","aclroles"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","aclroletab","ACLROLETAB","aclroles"); - } - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListACL->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function remove_lock() - { - /* Remove acl lock if a DN is marked as "currently edited" */ - if (isset($this->acltabs->dn)){ - del_lock ($this->acltabs->dn); - } - } - - - function save_object() - { - /* Handle divlist filter && department selection*/ - if(!is_object($this->acltabs)){ - $this->DivListACL->save_object(); - } - } - - /* A set of disabled and therefore overloaded functions. They are - not needed in this class. */ - function remove_from_parent() { } - function check() { } - - function save() { - echo "SAVE ACL"; - } - - function adapt_from_template($dn) { } - function password_change_needed() { } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array()); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/acl/class_aclRole.inc b/plugins/admin/acl/class_aclRole.inc deleted file mode 100644 index 18bf440dc..000000000 --- a/plugins/admin/acl/class_aclRole.inc +++ /dev/null @@ -1,686 +0,0 @@ -dn == "new"){ - $this->base = $_SESSION['CurrentMainBase']; - }else{ - $this->base = preg_replace("/^[^,]+,[^,]+,/","",$this->dn); - new log("view","aclroles/".get_class($this),$this->dn); - } - - /* Load ACL's */ - $this->gosaAclTemplate= array(); - if (isset($this->attrs["gosaAclTemplate"])){ - for ($i= 0; $i<$this->attrs["gosaAclTemplate"]['count']; $i++){ - $acl= $this->attrs["gosaAclTemplate"][$i]; - $this->gosaAclTemplate= array_merge($this->gosaAclTemplate, $this->explodeACL($acl)); - } - } - ksort($this->gosaAclTemplate); - - /* Extract available categories from plugin info list */ - $tmp= get_global('plist'); - $plist= $tmp->info; - $oc = array(); - foreach ($plist as $class => $acls){ - - /* Only feed categories */ - if (isset($acls['plCategory'])){ - - /* Walk through supplied list and feed only translated categories */ - foreach($acls['plCategory'] as $idx => $data){ - - /* Non numeric index means -> base object containing more informations */ - if (preg_match('/^[0-9]+$/', $idx)){ - if (!isset($this->ocMapping[$data])){ - $this->ocMapping[$data]= array(); - $this->ocMapping[$data][]= '0'; - } - $this->ocMapping[$data][]= $class; - } else { - if (!isset($this->ocMapping[$idx])){ - $this->ocMapping[$idx]= array(); - $this->ocMapping[$idx][]= '0'; - } - $this->ocMapping[$idx][]= $class; - $this->aclObjects[$idx]= $data['description']; - - /* Additionally filter the classes we're interested in in "self edit" mode */ - if (is_array($data['objectClass'])){ - foreach($data['objectClass'] as $objectClass){ - if (in_array_ics($objectClass, $oc)){ - $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription']; - break; - } - } - } else { - if (in_array_ics($data['objectClass'], $oc)){ - $this->myAclObjects[$idx.'/'.$class]= $acls['plDescription']; - } - } - } - - } - } - } - $this->aclObjects['all']= '* '._("All categories"); - $this->ocMapping['all']= array('0' => 'all'); - - /* Sort categories */ - asort($this->aclObjects); - - /* Fill acl types */ - $this->aclTypes= array( "reset" => _("Reset ACLs"), - "one" => _("One level"), - "base" => _("Current object"), - "sub" => _("Complete subtree"), - "psub" => _("Complete subtree (permanent)")); - asort($this->aclTypes); - - /* Finally - we want to get saved... */ - $this->is_account= TRUE; - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* Check if selected base is valid */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - $tmp= get_global('plist'); - $plist= $tmp->info; - - /* Handle posts */ - if (isset($_POST['new_acl'])){ - $this->dialogState= 'create'; - $this->dialog= TRUE; - $this->currentIndex= count($this->gosaAclTemplate); - $this->loadAclEntry(TRUE); - } - - $new_acl= array(); - $aclDialog= FALSE; - $firstedit= FALSE; - foreach($_POST as $name => $post){ - - /* Actions... */ - if (preg_match('/^acl_edit_.*_x/', $name)){ - $this->dialogState= 'create'; - $firstedit= TRUE; - $this->dialog= TRUE; - $this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name); - $this->loadAclEntry(); - continue; - } - if (preg_match('/^acl_del_.*_x/', $name)){ - unset($this->gosaAclTemplate[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]); - continue; - } - - if (preg_match('/^cat_edit_.*_x/', $name)){ - $this->aclObject= preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name); - $this->dialogState= 'edit'; - foreach ($this->ocMapping[$this->aclObject] as $oc){ - if (isset($this->aclContents[$oc])){ - $this->savedAclContents[$oc]= $this->aclContents[$oc]; - } - } - continue; - } - if (preg_match('/^cat_del_.*_x/', $name)){ - $idx= preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name); - foreach ($this->ocMapping[$idx] as $key){ - unset($this->aclContents["$idx/$key"]); - } - continue; - } - - /* Sorting... */ - if (preg_match('/^sortup_.*_x/', $name)){ - $index= preg_replace('/^sortup_([0-9]+).*$/', '\1', $name); - if ($index > 0){ - $tmp= $this->gosaAclTemplate[$index]; - $this->gosaAclTemplate[$index]= $this->gosaAclTemplate[$index-1]; - $this->gosaAclTemplate[$index-1]= $tmp; - } - continue; - } - if (preg_match('/^sortdown_.*_x/', $name)){ - $index= preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name); - if ($index < count($this->gosaAclTemplate)-1){ - $tmp= $this->gosaAclTemplate[$index]; - $this->gosaAclTemplate[$index]= $this->gosaAclTemplate[$index+1]; - $this->gosaAclTemplate[$index+1]= $tmp; - } - continue; - } - - /* ACL saving... */ - if (preg_match('/^acl_.*_[^xy]$/', $name)){ - $aclDialog= TRUE; - list($dummy, $object, $attribute, $value)= split('_', $name); - - /* Skip for detection entry */ - if ($object == 'dummy') { - continue; - } - - /* Ordinary ACLs */ - if (!isset($new_acl[$object])){ - $new_acl[$object]= array(); - } - if (isset($new_acl[$object][$attribute])){ - $new_acl[$object][$attribute].= $value; - } else { - $new_acl[$object][$attribute]= $value; - } - } - } - - /* Only be interested in new acl's, if we're in the right _POST place */ - if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){ - - foreach ($this->ocMapping[$this->aclObject] as $oc){ - unset($this->aclContents[$oc]); - unset($this->aclContents[$this->aclObject.'/'.$oc]); - if (isset($new_acl[$oc])){ - $this->aclContents[$oc]= $new_acl[$oc]; - } - if (isset($new_acl[$this->aclObject.'/'.$oc])){ - $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc]; - } - } - } - - /* Save new acl in case of base edit mode */ - if (1 == 0 && $this->aclType == 'base' && !$firstedit){ - $this->aclContents= $new_acl; - } - - /* Cancel new acl? */ - if (isset($_POST['cancel_new_acl'])){ - $this->dialogState= 'head'; - $this->dialog= FALSE; - if ($this->wasNewEntry){ - unset ($this->gosaAclTemplate[$this->currentIndex]); - } - } - - /* Store ACL in main object? */ - if (isset($_POST['submit_new_acl'])){ - $this->gosaAclTemplate[$this->currentIndex]['type']= $this->aclType; - $this->gosaAclTemplate[$this->currentIndex]['members']= $this->recipients; - $this->gosaAclTemplate[$this->currentIndex]['acl']= $this->aclContents; - $this->dialogState= 'head'; - $this->dialog= FALSE; - } - - /* Cancel edit acl? */ - if (isset($_POST['cancel_edit_acl'])){ - $this->dialogState= 'create'; - foreach ($this->ocMapping[$this->aclObject] as $oc){ - if (isset($this->savedAclContents[$oc])){ - $this->aclContents[$oc]= $this->savedAclContents[$oc]; - } - } - } - - /* Save edit acl? */ - if (isset($_POST['submit_edit_acl'])){ - $this->dialogState= 'create'; - } - - /* Add acl? */ - if (isset($_POST['add_acl']) && $_POST['aclObject'] != ""){ - $this->dialogState= 'edit'; - $this->savedAclContents= array(); - foreach ($this->ocMapping[$this->aclObject] as $oc){ - if (isset($this->aclContents[$oc])){ - $this->savedAclContents[$oc]= $this->aclContents[$oc]; - } - } - } - - /* Save common values */ - foreach (array("aclType", "aclObject", "target") as $key){ - if (isset($_POST[$key])){ - $this->$key= validate($_POST[$key]); - } - } - - /* Create templating instance */ - $smarty= get_smarty(); - - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("base_select", $this->base); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - if ($this->dialogState == 'head'){ - /* Draw list */ - $aclList= new divSelectBox("aclList"); - $aclList->SetHeight(350); - - /* Fill in entries */ - foreach ($this->gosaAclTemplate as $key => $entry){ - $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:100px'"); - $field2= array("string" => $this->assembleAclSummary($entry)); - $action= ""; - $action.= ""; - $action.= ""; - $action.= ""; - - $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'"); - $aclList->AddEntry(array($field1, $field2, $field3)); - } - - $smarty->assign("aclList", $aclList->DrawList()); - } - - if ($this->dialogState == 'create'){ - /* Draw list */ - $aclList= new divSelectBox("aclList"); - $aclList->SetHeight(450); - - /* Add settings for all categories to the (permanent) list */ - foreach ($this->aclObjects as $section => $dsc){ - $summary= ""; - foreach($this->ocMapping[$section] as $oc){ - if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) && - $this->aclContents[$oc][0] != ""){ - - $summary.= "$oc, "; - continue; - } - if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"]) && isset($this->aclContents["$section/$oc"][0]) && - $this->aclContents["$section/$oc"][0] != ""){ - - $summary.= "$oc, "; - continue; - } - if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){ - $summary.= "$oc, "; - } - } - - /* Set summary... */ - if ($summary == ""){ - $summary= ''._("No ACL settings for this category").''; - } else { - $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary)); - } - - $field1= array("string" => $dsc, "attach" => "style='width:140px'"); - $field2= array("string" => $summary); - $action= ""; - $action.= ""; - $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px'"); - $aclList->AddEntry(array($field1, $field2, $field3)); - } - - $smarty->assign("aclList", $aclList->DrawList()); - $smarty->assign("aclType", $this->aclType); - $smarty->assign("aclTypes", $this->aclTypes); - $smarty->assign("target", $this->target); - - if ($this->aclType == 'base'){ - $smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects)); - } - } - - if ($this->dialogState == 'edit'){ - $smarty->assign('headline', sprintf(_("Edit ACL for '%s', scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType])); - - /* Collect objects for selected category */ - foreach ($this->ocMapping[$this->aclObject] as $idx => $class){ - if ($idx == 0){ - continue; - } - $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription']; - } - if ($this->aclObject == 'all'){ - $aclObjects['all']= _("All objects in current subtree"); - } - $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects)); - } - - /* Show main page */ - $smarty->assign("dialogState", $this->dialogState); - - /* Assign cn and decription if this is a role */ - foreach(array("cn","description") as $name){ - $smarty->assign($name,$this->$name); - } - return ($smarty->fetch (get_template_path('acl_role.tpl',dirname(__FILE__)))); - } - - function sort_by_priority($list) - { - $tmp= get_global('plist'); - $plist= $tmp->info; - asort($plist); - $newSort = array(); - - foreach($list as $name => $translation){ - $na = preg_replace("/^.*\//","",$name); - if (!isset($plist[$na]['plPriority'])){ - $prio= 0; - } else { - $prio= $plist[$na]['plPriority'] ; - } - - $newSort[$name] = $prio; - } - - asort($newSort); - - $ret = array(); - foreach($newSort as $name => $prio){ - $ret[$name] = $list[$name]; - } - return($ret); - } - - function loadAclEntry($new= FALSE) - { - /* New entry gets presets... */ - if ($new){ - $this->aclType= 'sub'; - $this->recipients= array(); - $this->aclContents= array(); - } else { - $acl= $this->gosaAclTemplate[$this->currentIndex]; - $this->aclType= $acl['type']; - $this->recipients= $acl['members']; - $this->aclContents= $acl['acl']; - } - - $this->wasNewEntry= $new; - } - - - function aclPostHandler() - { - if (isset($_POST['save_acl'])){ - $this->save(); - return TRUE; - } - - return FALSE; - } - - - function save() - { - /* Assemble ACL's */ - $tmp_acl= array(); - foreach ($this->gosaAclTemplate as $prio => $entry){ - $final= ""; - $members= ""; - if (isset($entry['members'])){ - foreach ($entry['members'] as $key => $dummy){ - $members.= base64_encode(preg_replace('/^.:/', '', $key)).','; - } - } - $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members); - - /* ACL's if needed */ - if ($entry['type'] != "reset" && $entry['type'] != "role"){ - $acl= ":"; - if (isset($entry['acl'])){ - foreach ($entry['acl'] as $object => $contents){ - - /* Only save, if we've some contents in there... */ - if (count($contents)){ - $acl.= $object.";"; - - foreach($contents as $attr => $permission){ - - /* First entry? Its the one for global settings... */ - if ($attr == '0'){ - $acl.= $permission; - } else { - $acl.= '#'.$attr.';'.$permission; - } - - } - $acl.= ','; - } - - } - } - $final.= preg_replace('/,$/', '', $acl); - } - - $tmp_acl[]= $final; - } - - /* Call main method */ - plugin::save(); - - /* Finally (re-)assign it... */ - $this->attrs["gosaAclTemplate"]= $tmp_acl; - - /* Remove acl from this entry if it is empty... */ - if (!count($tmp_acl)){ - /* Remove attribute */ - if ($this->initially_was_account){ - $this->attrs["gosaAclTempalte"]= array(); - } else { - if (isset($this->attrs["gosaAclTemplate"])){ - unset($this->attrs["gosaAclTemplate"]); - } - } - } - - /* Do LDAP modifications */ - $ldap= $this->config->get_ldap_link(); - - /* Check if object already exists */ - $ldap->cat($this->dn); - if($ldap->count()){ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","aclroles/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","aclroles/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving ACLs with dn '%s' failed."),$this->dn)); - - /* Refresh users ACLs */ - $ui= get_userinfo(); - $ui->loadACL(); - $_SESSION['ui']= $ui; - } - - - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $serach_for = "*:role:".base64_encode($this->dn).":*"; - $ldap->search ("(&(objectClass=gosaACL)(gosaAclEntry=".$serach_for."))",array('dn','cn','sn','givenName','uid')); - $all_names = ""; - - - $cnt = 3; - while(($attrs = $ldap->fetch()) && $cnt){ - $name = $attrs['dn']; - $name = preg_replace("/[ ]/"," ",$name); - $name = "'".$name."'"; - $all_names .= $name.", "; - $cnt --; - } - - if(!empty($all_names)){ - $all_names = preg_replace("/, $/","",$all_names); - if(!$cnt){ - $all_names .= ", ..."; - } - $all_names = "".$all_names.""; - print_red(sprintf(_("This role can't be removed while it is in use. Follwing objects are using this role %s"),$all_names)); - return; - } - - $ldap->rmDir($this->dn); - new log("remove","aclroles/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of aclRole with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove"); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - show_ldap_error($ldap->get_error(), sprintf(_("Removing aclRole from objectgroup '%s' failed"), $og->dn)); - } - } - - - function save_object() - { - plugin::save_object(); - if(isset($_POST['acl_role_posted'])){ - - /* Get base selection */ - if(isset($_POST['base'])){ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$_POST['base']])){ - $this->base = $_POST['base']; - } - } - } - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - function getCopyDialog() - { - $smarty = get_smarty(); - $smarty->assign("cn",$this->cn); - $str = $smarty->fetch(get_template_path("paste_role.tpl",TRUE,dirname(__FILE__))); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - $source_o = new aclrole($this->config,$source['dn']); - $this->gosaAclTemplate = $source_o->gosaAclTemplate; - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Role"), - "plDescription" => _("ACL roles"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("admin"), - "plCategory" => array("aclroles" => array("objectClass" => "gosaRole", "description" => _("Acl roles"))), - - "plProvidedAcls" => array( - "cn" => _("Name"), - "base" => _("Base"), - "description" => _("Description")) - )); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/acl/class_divListACL.inc b/plugins/admin/acl/class_divListACL.inc deleted file mode 100644 index 7da993633..000000000 --- a/plugins/admin/acl/class_divListACL.inc +++ /dev/null @@ -1,306 +0,0 @@ -parent = &$parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of acl")); - $this->SetSummary(_("List of acls")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to edit and delete selected acls.")); - - $this->EnableAplhabet (true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col */ - $this->action_col_size = 120; - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>" ", "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>_("Summary"))); - $this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:".$this->action_col_size."px;border-right:0px;text-align:right;'")); - - /* Set dynamically filter checkboxes */ - $this->set_filter_objectclasses(); - - /* Add SubSearch checkbox */ - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false); - - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Display acls matching"),"*" , true); - } - - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - $Copy_Paste = ""; - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("acl"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Allow copy & paste for roles */ - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"acl"); - $acl = $ui->get_permissions($this->selectedBase,"acl/acl"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - $listhead .= - _("Base")." ". - "  "; - - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("Role")."|new_acl_role|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $str = $this->get_snapshot_header(TRUE) ; - if(!empty($str)){ - $s .= "..|---|\n"; - $s .= $str; - } - } - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - } - - /* so some basic settings */ - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - - foreach($list as $key => $acl_entry){ - - /* Get copy & paste icon */ - $acl = $this->ui->get_permissions($acl_entry['dn'],"acl/acl"); - $acl_all = $this->ui->has_complete_category_acls($acl_entry['dn'],"acl"); - $action = ""; - - if(in_array("gosaRole",$acl_entry['objectClass'])){ - - /* Role handling */ - $editlink = "%s"; - $list_left_icon = ""._("Role").""; - $cn = htmlentities(utf8_decode($acl_entry['cn'][0])) ; - - if(isset($acl_entry['description'][0])){ - $cn .= " [".$acl_entry['description'][0]."]"; - } - - /* Add copy & paste handler */ - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $action.= " "; - $action.= " "; - } - - /* Add actions depending on acls */ - if(preg_match("/r/", $acl)){ - $action.= ""; - } - - /* Add snapshot functionality */ - if(preg_match("/(c.*w|w.*c)/", $acl_all)){ - $action.= $this->GetSnapShotActions($acl_entry['dn']); - } - - if(preg_match("/d/", $acl)){ - $action.= ""; - } - }else{ - - /* Acl handling */ - $editlink = "%s"; - $list_left_icon = ""._("Acl").""; - $cn = htmlentities(utf8_decode($acl_entry['dn'])); - - /* Add actions depending on acls */ - if(preg_match("/r/", $acl)){ - $action.= ""; - } - if(preg_match("/d/", $acl)){ - $action.= ""; - } - } - - if(in_array("gosaRole",$acl_entry['objectClass'])){ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - }else{ - $field0 = array("string" => "", "attach" => "style='width:20px;'"); - } - - /* Cutted objects should be displayed in light grey */ - $display = $cn; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $acl_entry['dn']) { - $display = "".$display.""; - break; - } - } - } - - $field1 = array("string" => $list_left_icon, "attach"=> "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display)." ","attach" => ""); - $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:right;width:".$this->action_col_size."px;border-right:0px;'"); - $this->AddElement(array($field0,$field1,$field2,$field3)); - } - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - } - - - /* Add some additional checkboxes to the filter part, this should be generated dynamically. */ - function set_filter_objectclasses() - { - } - - /* Return objectClass names used in filter part */ - function get_filter_objectclasses() - { - return(array("gosaAccount","gosaDepartment")); - } - - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/acl/main.inc b/plugins/admin/acl/main.inc deleted file mode 100644 index bea89a962..000000000 --- a/plugins/admin/acl/main.inc +++ /dev/null @@ -1,57 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('macl'); - } -} else { - $display= "No headpage yet for this module"; - - /* Create usermanagement object on demand */ -if (!isset($_SESSION['macl']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['macl']= new aclManagement($config, $ui); - } - $macl= $_SESSION['macl']; - - /* Show and save dialog */ - $macl->save_object(); - $output= $macl->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/acl.png'), _("ACL management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/acl.png'), _("ACL management")); - } - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('macl'); - } - - $display.= $output; - $_SESSION['macl']= $macl; -} -?> diff --git a/plugins/admin/acl/paste_role.tpl b/plugins/admin/acl/paste_role.tpl deleted file mode 100644 index 41f45775f..000000000 --- a/plugins/admin/acl/paste_role.tpl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -
- {t}Name{/t} - - -
diff --git a/plugins/admin/acl/remove.tpl b/plugins/admin/acl/remove.tpl deleted file mode 100755 index 0b5323df4..000000000 --- a/plugins/admin/acl/remove.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
- {t}Warning{/t} -
-

- {$info} - {t}This includes all system and setup informations. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

-{if $is_role} - -   - -{else} - -   - -{/if} -

diff --git a/plugins/admin/acl/tabs_acl.inc b/plugins/admin/acl/tabs_acl.inc deleted file mode 100644 index db87979fa..000000000 --- a/plugins/admin/acl/tabs_acl.inc +++ /dev/null @@ -1,70 +0,0 @@ - "acl" , "NAME" => _("Acl"))); - - /* Save dn */ - $this->dn= $dn; - $this->config= $config; - - $baseobject= NULL; - - foreach ($data as $tab){ - $this->by_name[$tab['CLASS']]= $tab['NAME']; - - - if ($baseobject === NULL){ - if($tab['CLASS'] == "acl"){ - $baseobject= new $tab['CLASS']($this->config, $this, $this->dn); - }else{ - $baseobject= new $tab['CLASS']($this->config,$this->dn); - } - $this->by_object[$tab['CLASS']]= $baseobject; - } else { - if($tab['CLASS'] == "acl"){ - $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config,$this,$this->dn, $baseobject); - }else{ - $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject); - } - } - - $this->by_object[$tab['CLASS']]->parent= &$this; - $this->by_object[$tab['CLASS']]->set_acl_category("acl"); - - /* Initialize current */ - if ($this->current == ""){ - $this->current= $tab['CLASS']; - } - } - } - - function save($ignore_account= FALSE) - { - $ret= tabs::save(); - return $ret; - } - - function save_object($ignore_account= FALSE) - { - tabs::save_object(); - } - - function execute() - { - $display= tabs::execute(); - if(!$this->by_object['acl']->dialog){ - $display.= "

\n"; - $display.= " \n"; - $display.= "  \n"; - $display.= " \n"; - $display.= "

"; - } - return($display); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/acl/tabs_acl_role.inc b/plugins/admin/acl/tabs_acl_role.inc deleted file mode 100644 index b1132357d..000000000 --- a/plugins/admin/acl/tabs_acl_role.inc +++ /dev/null @@ -1,61 +0,0 @@ - "aclrole" , "NAME" => _("ACL Templates"))); - tabs::tabs($config, $data, $dn,"acl"); - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['aclrole']; - - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $new_dn= 'cn='.$baseobject->cn.",ou=aclroles,".$baseobject->base; - - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->move($this->dn, $new_dn); - $this->by_object['aclrole']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - $ret= tabs::save(); - - /* Fix tagging if needed */ - $baseobject->dn= $new_dn; - $baseobject->handle_object_tagging(); - - return $ret; - } - - function save_object($ignore_account= FALSE) - { - tabs::save_object(); - } - - function execute() - { - $display= tabs::execute(); - if(!$this->by_object['aclrole']->dialog){ - $display.= "

\n"; - $display.= " \n"; - $display.= "  \n"; - $display.= " \n"; - $display.= "

"; - } - return($display); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/applications/class_applicationGeneric.inc b/plugins/admin/applications/class_applicationGeneric.inc deleted file mode 100644 index 22fcf10be..000000000 --- a/plugins/admin/applications/class_applicationGeneric.inc +++ /dev/null @@ -1,569 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* application attributes */ - var $cn= ""; - var $description= ""; - var $base= ""; - var $gosaApplicationExecute= ""; - var $gosaApplicationName= ""; - var $gosaApplicationFlags= ""; - var $gosaApplicationIcon= ""; - var $gotoLogonScript =""; - var $iconData; - var $view_logged = FALSE; - - /* Headpage attributes */ - var $last_sorting= "invalid"; - var $applications= array(); - - /* attribute list for save action */ - var $attributes= array("cn", "description", "gosaApplicationExecute", "gosaApplicationName","gosaApplicationIcon", - "gosaApplicationFlags","gotoLogonScript"); - var $objectclasses= array("top", "gosaApplication"); - - var $isReleaseApplikation = false; - - function application (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)) { - if(!preg_match("/^ou=apps,/",$_SESSION['appfilter']['release'])){ - $this->isReleaseApplikation = true; - } - } - - /* Load icon */ - $ldap= $config->get_ldap_link(); - if ($dn != 'new'){ - $this->iconData= $ldap->get_attribute($dn, "gosaApplicationIcon"); - $this->saved_attributes['gosaApplicationIcon'] = $this->iconData; - } - if ($this->iconData == ""){ - $this->set_picture(""); - } - $_SESSION['binary']= $this->iconData; - $_SESSION['binarytype']= "image/jpeg"; - $this->gosaApplicationIcon= $this->iconData; - - /* This is always an account */ - $this->is_account= TRUE; - - if ($this->dn == "new"){ - if(isset($_SESSION['CurrentMainBase'])){ - $this->base= $_SESSION['CurrentMainBase']; - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - - if($this->isReleaseApplikation){ - $this->base = preg_replace("/^.*,ou=apps,/","",$this->dn); - }else{ - $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn); - } - } - } - - - function generateTemplate() - { - $str= "# This code is part of GOsa (https://gosa.gonicus.de)\n#\n"; - - $values = array(); - $names = array(); - if($this->parent->by_object['applicationParameters']->is_account){ - $names = $this->parent->by_object['applicationParameters']->option_name; - $values = $this->parent->by_object['applicationParameters']->option_value; - } - - if (count($names)){ - $str .="# This plugin handles these environment variables:\n"; - } else { - $str .="# This plugin handles no environment variables.\n"; - } - - foreach($names as $index => $name){ - - // Fix length - for($i = strlen($name) ; $i < 30 ; $i++){ - $name= $name." "; - } - if((isset($values[$index]))&&(!empty($values[$index]))){ - $str.= "# ".$name."\t(e.g. '".$values[$index]."')\n"; - }else{ - $str.= "# ".$name."\t("._("no example").")\n"; - } - } - $str .= "#\n". - "# Don't remove the following tag, it is used for header update.\n". - "### END HEADER ###"; - - return($str); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","application/".get_class($this),$this->dn); - } - - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Do we represent a valid group? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' is no application.").""; - return ($display); - } - - /* Download requested */ - foreach($_POST as $name => $value){ - if(preg_match("/^downloadScript/",$name)){ - $_SESSION['binary'] = $this->gotoLogonScript; - $_SESSION['binarytype'] = "octet-stream"; - $_SESSION['binaryfile'] = $this->cn.".gosaApplication"; - header("location: getbin.php "); - exit(); - } - } - - /* Reassign picture data, sometimes its corrupt cause we started a download of application scripts */ - $_SESSION['binary'] = $this->iconData; - $_SESSION['binarytype'] = "image/jpeg"; - - $smarty->assign("rand", rand(0, 10000)); - $head = $this->generateTemplate(); - $this->gotoLogonScript= $this->generateTemplate().preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript); - - if((isset($_POST['upLoad']))&&(isset($_FILES['ScriptFile']))){ - $str = file_get_contents($_FILES['ScriptFile']['tmp_name']); - $this->gotoLogonScript = $str; - } - - /* Fill templating stuff */ - $smarty->assign("cn", $this->cn); - $smarty->assign("bases", $this->get_allowed_bases()); - if ($this->dn == "new"){ - $smarty->assign("selectmode", ""); - $smarty->assign("namemode", ""); - } else { - $smarty->assign("namemode", "readonly"); - $smarty->assign("selectmode", "disabled"); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* Just allow selection valid bases */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Get random number for pictures */ - srand((double)microtime()*1000000); - $smarty->assign("rand", rand(0, 10000)); - - /* Variables */ - foreach(array("description", "gosaApplicationExecute", "gosaApplicationName","cn") as $val){ - $smarty->assign($val, $this->$val); - } - - /* Checkboxes */ - foreach (array("G" => "exec_for_groupmembers", "O" => "overwrite_config", - "L" => "place_on_kicker", - "D" => "place_on_desktop", "M" => "place_in_startmenu") as $key => $val){ - if (preg_match("/$key/", $this->gosaApplicationFlags)){ - $smarty->assign("$val", "checked"); - } else { - $smarty->assign("$val", ""); - } - } - - $smarty->assign("isReleaseApplikation" , $this->isReleaseApplikation); - $smarty->assign("gotoLogonScript",htmlentities($this->gotoLogonScript, ENT_COMPAT, 'UTF-8')); - $smarty->assign("base_select", $this->base); - /* Show main page */ - return($smarty->fetch (get_template_path('generic.tpl', TRUE))); - } - - - function remove_from_parent() - { - $ldap= $this->config->get_ldap_link(); - $ldap->rmDir($this->dn); - new log("remove","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of application with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove"); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - show_ldap_error($ldap->get_error(), sprintf(_("Removing application from objectgroup '%s' failed"), $og->dn)); - } - $ldap->search ("(&(objectClass=posixGroup)(gosaMemberApplication=".$this->cn."))", array("cn")); - while ($attrs= $ldap->fetch()){ - $ag= new appgroup($this->config, $ldap->getDN()); - $ag->removeApp($this->cn); - $ag->save (); - show_ldap_error($ldap->get_error(), sprintf(_("Removing application from group '%s' failed"), $ag->dn)); - } - - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['cn'])){ - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - /* Save attributes */ - parent::save_object(); - - /* Save application flags */ - $flag= ""; - if (isset($_POST['exec_for_groupmembers']) && $_POST['exec_for_groupmembers'] == 1){ - $flag.= "G"; - } - if (isset($_POST['place_on_desktop']) && $_POST['place_on_desktop'] == 1){ - $flag.= "D"; - } - if (isset($_POST['place_on_kicker']) && $_POST['place_on_kicker'] == 1){ - $flag.= "L"; - } - if (isset($_POST['place_in_startmenu']) && $_POST['place_in_startmenu'] == 1){ - $flag.= "M"; - } - if (isset($_POST['overwrite_config']) && $_POST['overwrite_config'] == 1){ - $flag.= "O"; - } - if ($this->acl_is_writeable("gosaApplicationFlags")){ - $this->gosaApplicationFlags= "[$flag]"; - } - - /* Remove current picture */ - if(isset($_POST['remove_picture'])){ - $this->set_picture(""); - } - - /* Check for picture upload */ - if (isset($_FILES['picture_file']['name']) && $_FILES['picture_file']['name'] != ""){ - - if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) { - print_red (_("The specified picture has not been uploaded correctly.")); - } - - if (!function_exists("imagick_blob2image")){ - /* Get temporary file name for conversation */ - $fname = tempnam ("/tmp", "GOsa"); - - /* Open file and write out photoData */ - $fp = fopen ($fname, "w"); - fwrite ($fp, $_FILES['picture_file']['tmp_name']); - fclose ($fp); - - /* Build conversation query. Filename is generated automatically, so - we do not need any special security checks. Exec command and save - output. For PHP safe mode, you'll need a configuration which respects - image magick as executable... */ - $query= "convert -size 48x48 $fname -resize 48x48 +profile \"*\" -"; - @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $query, "Execute"); - - /* Read data written by convert */ - $output= ""; - $sh= popen($query, 'r'); - while (!feof($sh)){ - $output.= fread($sh, 4096); - } - pclose($sh); - - unlink($fname); - } else { - - /* Load the new uploaded Photo */ - if(!$handle = imagick_ReadImage($_FILES['picture_file']['tmp_name'])){ - print_red(_("Can't access uploaded image.")); - } - - /* Resizing image to 147x200 and blur */ - if(!imagick_resize($handle,48,48,IMAGICK_FILTER_GAUSSIAN,0)){ - print_red(_("Uploaded image could not be resized, possilby the image magick extension is missing.")); - } - - /* Converting image to JPEG */ - if(!imagick_convert($handle,"PNG")) { - print_red(_("Could not convert image to png, possilby the image magick extension is missing.")); - } - - if(!imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){ - print_red(sprintf(_("Could not save uploaded image to %s."),$_FILES['picture_file']['tmp_name'])); - } - - imagick_free($handle); - } - - /* Activate new picture */ - $this->set_picture($_FILES['picture_file']['tmp_name']); - } - - if(!$this->isReleaseApplikation){ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - } - } - } - - - /* Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(!preg_match("#^/#",$this->gosaApplicationExecute)){ - $message[]=(_("Specified execute path must start with '/'.")); - } - - /* Permissions for that base? */ - if ($this->base != ""){ - $new_dn= "cn=".$this->cn.",ou=apps,".$this->base; - } else { - $new_dn= $this->dn; - } - - - if($this->dn == "new"){ - $this->set_acl_base($this->base); - } - - /* All required fields are set? */ - if ($this->cn == ""){ - $message[]= _("Required field 'Name' is not filled."); - } - - if(preg_match("/[^a-z0-9]/",$this->cn)) { - $message[]=_("Invalid character in application name. Only a-z 0-9 are allowed."); - } - - if ($this->gosaApplicationExecute == ""){ - $message[]= _("Required field 'Execute' is not filled."); - } - - /* Check for existing application */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current["BASE"]); - - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if((!empty($tmp)) && (isset($_SESSION['appfilter']['release']))){ - $baseDn = str_replace($this->config->current['BASE'],$this->base,$_SESSION['appfilter']['release']); - $baseDn = preg_replace("/ou=apps,.*/","ou=apps,".$this->base,$_SESSION['appfilter']['release']); - $ldap->ls("(&(objectClass=gosaApplication)(cn=".$this->cn."))",$baseDn,array("cn")); - if($ldap->count()){ - $attrs = $ldap->fetch(); - if($this->dn != $attrs['dn']) { - $message[]= _("There's already an application with this 'Name'."); - } - } - }else{ - $ldap->ls("(&(objectClass=gosaApplication)(cn=".$this->cn."))","ou=apps,".$this->base,array("cn")); - if ($ldap->count()){ - $attrs = $ldap->fetch(); - if($this->dn != $attrs['dn']) { - $message[]= _("There's already an application with this 'Name'."); - } - } - } - return $message; - } - - - /* Save to LDAP */ - function save() - { - /* Get application script without header part, to check if we must save the script itself */ - $script = preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript); - - plugin::save(); - $this->attrs["gosaApplicationIcon"]= $this->gosaApplicationIcon; - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('dn')); - - $a= $ldap->fetch(); - if (count($a)){ - - /* Remove gotoLogonScript if it is empty */ - if(empty($script)) { - $this->attrs['gotoLogonScript'] = array(); - } - - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - $this->handle_post_events("modify"); - new log("modify","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } else { - - /* Remove gotoLogonScript if it is empty */ - if(empty($script)) { - unset($this->attrs['gotoLogonScript']); - } - - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("add"); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of application with dn '%s' failed."),$this->dn)); - } - - function set_picture($filename) - { - if (!is_file($filename)){ - $filename= "./images/default_icon.png"; - $this->gosaApplicationIcon= "*removed*"; - } - - if (file_exists($filename)){ - $fd = fopen ($filename, "rb"); - $this->iconData= fread ($fd, filesize ($filename)); - $_SESSION['binary']= $this->iconData; - $_SESSION['binarytype']= "image/jpeg"; - $this->gosaApplicationIcon= $this->iconData; - - fclose ($fd); - } - } - - function getCopyDialog() - { - $vars = array("cn"); - - $str ="

"._("Application settings")."

- - - - - -
". - _("Application name"). - " - -
"; - $ret = array(); - $ret['status'] = ""; - $ret['string'] = $str; - return($ret); - } - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - $source_o = new application($this->config,$source['dn']); - $this->gosaApplicationIcon = $source_o->gosaApplicationIcon; - } - - - /* Return plugin informations for acl handling - #FIXME FAIscript seams to ununsed within this class... */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Application generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("application" => array("description" => _("Application"), - "objectClass" => "gosaApplication")), - "plProvidedAcls"=> array( - "cn" => _("Name"), - "base" => _("Base"), - "description" => _("Description"), - "gosaApplicationExecute" => _("Execute"), - "gosaApplicationName" => _("Name"), - "gosaApplicationIcon" => _("Icon"), - "gosaApplicationFlags" => _("Flag"), - "gotoLogonScript" => _("Script content"), - - "exec_for_groupmembers" => _("Only executable for members"), // G - "place_on_desktop" => _("Place icon on members desktop"), // D - "place_on_kicker" => _("Place entry in members launch bar"), // L - "place_in_startmenu" => _("Place entry in members startmenu"), // M - "overwrite_config" => _("Replace user configuration on startup")) // O - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/applications/class_applicationManagement.inc b/plugins/admin/applications/class_applicationManagement.inc deleted file mode 100644 index 69a4c0f48..000000000 --- a/plugins/admin/applications/class_applicationManagement.inc +++ /dev/null @@ -1,645 +0,0 @@ -config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - return(true); - } - return(false); - } - - function applicationManagement (&$config, &$ui) - { - /* Save configuration for internal use */ - $this->config = &$config; - $this->ui = &$ui; - - /* Check if copy & paste is activated */ - if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - - /* Creat dialog object */ - $this->DivListApplication = new divListApplication($this->config,$this); - - if($this->IsReleaseManagementActivated()){ - /* Check if we should enable the release selection */ - $this->enableReleaseManagement = true; - - /* Hide SubSearch checkbox */ - $this->DivListApplication->DisableCheckBox("SubSearch"); - } - } - - function getReleases($base) - { - $ldap = $this->config->get_ldap_link(); - $dn = "ou=apps,".$base; - $ret = array(); - $ret ["ou=apps,".$base] = "/"; - - $ldap->cd($dn); - $ldap->search("objectClass=organizationalUnit",array("ou")); - - while($attrs = $ldap->fetch()){ - $str = str_replace($dn,"",$attrs['dn']); - $tmp = array_reverse( split("ou=",$str)); - $str = ""; - foreach($tmp as $val){ - $val = trim(preg_replace("/,/","",$val)); - if(empty($val)) break; - $str .= "/".$val; - } - if(!empty($str)){ - $ret[$attrs['dn']]= preg_replace("/^\//","",$str); - } - } - asort($ret); - return($ret); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - - /**************** - Variable init - ****************/ - - /* These vars will be stored if you try to open a locked app, - to be able to perform your last requests after showing a warning message */ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^appl_edit_/","/^appl_del_/","/^item_selected/","/^remove_multiple_applications/"); - - $smarty = get_smarty(); // Smarty instance - $s_action = ""; // Contains the action to proceed - $s_entry = ""; // The value for s_action - $base_back = ""; // The Link for Backbutton - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/appl_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/appl_".$s_action."_/i","",$key); - // Post for edit - }elseif(preg_match("/appl_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/appl_".$s_action."_/i","",$key); - // Post for new - }elseif(preg_match("/^copy_.*/",$key)){ - $s_action="copy"; - $s_entry = preg_replace("/^copy_/i","",$key); - }elseif(preg_match("/^cut_.*/",$key)){ - $s_action="cut"; - $s_entry = preg_replace("/^cut_/i","",$key); - // Post for new - }elseif(preg_match("/^appl_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/^remove_multiple_applications/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^editPaste.*/i",$key)){ - $s_action="editPaste"; - }elseif(preg_match("/^multiple_copy_groups/",$key)){ - $s_action = "copy_multiple"; - }elseif(preg_match("/^multiple_cut_groups/",$key)){ - $s_action = "cut_multiple"; - } - } - - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; - } - - $s_entry = preg_replace("/_.$/","",$s_entry); - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "appl_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - /**************** - Copy & Paste handling - ****************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - /**************** - Create a new app - ****************/ - - /* New application? */ - if ($s_action=="new"){ - - /* By default we set 'dn' to 'new', all relevant plugins will - react on this. */ - $this->dn= "new"; - - /* Create new usertab object */ - $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application"); - $this->apptabs->set_acl_base($this->DivListApplication->selectedBase); - } - - - /**************** - Edit entry canceled - ****************/ - - /* Cancel dialogs */ - if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ - del_lock ($this->apptabs->dn); - unset ($this->apptabs); - $this->apptabs= NULL; - unset ($_SESSION['objectinfo']); - } - - - /**************** - Edit entry finished - ****************/ - - /* Finish apps edit is triggered by the tabulator dialog, so - the user wants to save edited data. Check and save at this - point. */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->apptabs->config))){ - - /* Check tabs, will feed message array */ - $this->apptabs->last= $this->apptabs->current; - $this->apptabs->save_object(); - $message= $this->apptabs->check(); - - /* Save, or display error message? */ - if (count($message) == 0){ - - /* Save data data to ldap */ - $this->apptabs->set_release($this->DivListApplication->selectedRelease); - $this->apptabs->save(); - - if (!isset($_POST['edit_apply'])){ - /* Application has been saved successfully, remove lock from - LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - unset ($this->apptabs); - $this->apptabs= NULL; - unset ($_SESSION['objectinfo']); - } - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /**************** - Edit entry - ****************/ - - /* User wants to edit data? */ - if (($s_action=="edit") && (!isset($this->apptabs->config))){ - - /* Get 'dn' from posted 'applist', must be unique */ - $this->dn= $this->applications[$s_entry]['dn']; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so everyone will get the - above dialog */ - add_lock ($this->dn, $this->ui->dn); - - /* Register apptabs to trigger edit dialog */ - $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application"); - $this->apptabs->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; - } - - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->applications[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("intro", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("intro", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); - } - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_application_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - $ui = get_userinfo(); - $acl = $ui->get_permissions($dn ,"application/application"); - if (preg_match('/d/', $acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn,"application"); - $this->apptabs->set_acl_base($dn); - $this->apptabs->delete (); - unset ($this->apptabs); - $this->apptabs= NULL; - - } else { - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this application!")); - new log("security","application/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_application_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - /**************** - Delete app - ****************/ - - /* Remove user was requested */ - if ($s_action == "del"){ - - /* Get 'dn' from posted 'uid' */ - $this->dn= $this->applications[$s_entry]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->dn ,"application/application"); - - if(preg_match("/d/",$acl)){ - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return (gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty= get_smarty(); - $smarty->assign("intro", sprintf(_("You're about to delete the application '%s'."), @LDAP::fix($this->dn))); - $smarty->assign("multiple", false); - return($smarty->fetch (get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this application!")); - } - } - - - /**************** - Delete app confirmed - ****************/ - - /* Confirmation for deletion has been passed. Group should be deleted. */ - if (isset($_POST['delete_app_confirm'])){ - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->dn ,"application/application"); - - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $this->dn,"application"); - $this->apptabs->set_acl_base($this->dn); - $this->apptabs->delete (); - unset ($this->apptabs); - $this->apptabs= NULL; - - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this application!")); - new log("security","application/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - - /**************** - Delete app canceled - ****************/ - - /* Delete application canceled? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - /* Show tab dialog if object is present */ - if (($this->apptabs) && (isset($this->apptabs->config))){ - $display= $this->apptabs->execute(); - - /* Don't show buttons if tab dialog requests this */ - if (!$this->apptabs->by_object[$this->apptabs->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - return ($display); - } - - - /**************** - Dialog display - ****************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListApplication->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases($base))){ - return($str); - } - - /* Display dialog with system list */ - $this->DivListApplication->parent = $this; - $this->DivListApplication->execute(); - $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase,3,1); - $this->reload(); - $this->DivListApplication->setEntries($this->applications); - return($this->DivListApplication->Draw()); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases(){ - if($this->DivListApplication->selectedRelease == "main"){ - return(array($this->DivListApplication->selectedBase)); - }else{ - return(array($this->DivListApplication->selectedRelease)); - } - } - - - function reload() - { - $this->applications= array(); - - /* Set base for all searches */ - $base = $this->DivListApplication->selectedBase; - $release = $this->DivListApplication->selectedRelease; - $Regex = $this->DivListApplication->Regex; - $SubSearch = $this->DivListApplication->SubSearch; - $Flags = GL_NONE | GL_SIZELIMIT; - $Filter = "(&(cn=".$Regex.")(objectClass=gosaApplication))"; - $tmp = array(); - $Releases = $this->getReleases($base); - - if(!$this->enableReleaseManagement){ - $use_base = "ou=apps,".$base; - }else{ - if(isset($Releases[$release])){ - $use_base = $release; - }else{ - $use_base = "ou=apps,".$base; - } - } - - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - } - - $res= get_list($Filter, "application", $use_base, array("cn","description","dn","objectClass"), $Flags); - foreach ($res as $val){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; - } - - ksort($tmp); - $this->applications=array(); - foreach($tmp as $val){ - $this->applications[]=$val; - } - reset ($this->applications); - } - - function remove_from_parent() - { - /* Optionally execute a command after we're done */ - $this->postremove(); - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->applications[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"apptabs","APPSTABS","application"); - } - - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->applications[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","apptabs","APPSTABS","application"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","apptabs","APPSTABS","application"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListApplication->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - /* Save to LDAP */ - function save() - { - /* Optionally execute a command after we're done */ - $this->postcreate(); - } - - function remove_lock() - { - if (isset($this->apptabs->dn)){ - del_lock ($this->apptabs->dn); - } - } - - function save_object() { - $this->DivListApplication->save_object(); - } - - function check() {} - function adapt_from_template($dn) {} - function password_change_needed() {} -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/applications/class_applicationParameters.inc b/plugins/admin/applications/class_applicationParameters.inc deleted file mode 100644 index 9f11eb6b9..000000000 --- a/plugins/admin/applications/class_applicationParameters.inc +++ /dev/null @@ -1,248 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Parameters */ - var $option_name= array(); - var $option_value= array(); - - /* attribute list for save action */ - var $attributes= array("gosaApplicationParameter"); - var $objectclasses= array(); - - var $CopyPasteVars = array("option_name","option_value"); - - function applicationParameters (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $this->gosaApplicationParameter = array(); - - if (isset($this->attrs['gosaApplicationParameter'])){ - $this->is_account= TRUE; - for ($i= 0; $i<$this->attrs['gosaApplicationParameter']['count']; $i++){ - $option= preg_replace('/^[^:]+:/', '', - $this->attrs['gosaApplicationParameter'][$i]); - $name= preg_replace('/:.*$/', '', - $this->attrs['gosaApplicationParameter'][$i]); - $this->option_name[$i]= $name; - $this->option_value[$i]= $option; - } - } else { - $this->is_account= FALSE; - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Show tab dialog headers */ - $display= ""; - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove options"), - _("This application has options. You can disable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Create options"), - _("This application has options disabled. You can enable them by clicking below.")); - $this->parent->by_object['application']->generateTemplate(); - return ($display); - } - } - - /* Add option to list */ - if (isset($_POST['add_option'])){ - $i= count($this->option_name); - $this->option_name[$i]= ""; - $this->option_value[$i]= ""; - } - - /* Remove value from list */ - for ($i= 0; $ioption_name); $i++){ - if (isset($_POST["remove$i"])){ - $k= 0; - $on= array(); - $ov= array(); - for ($j= 0; $joption_name); $j++){ - if ($j != $i){ - $on[$k]= $this->option_name[$j]; - $ov[$k]= $this->option_value[$j]; - $k++; - } - } - $this->option_name= $on; - $this->option_value= $ov; - break; - } - } - - /* Generate list of attributes */ - if (count($this->option_name) == 0){ - $this->option_name[]= ""; - $this->option_value[]= ""; - } - - - $acl = $this->getacl("gosaApplicationParameter") ; - $table= ""; - if (count ($this->option_name)){ - - for ($i= 0; $i < count($this->option_name); $i++){ - $name = $this->option_name[$i]; - $value= $this->option_value[$i]; - - $tag = ""; - if(!preg_match("/w/",$acl)){ - $tag = " disabled "; - } - - if(!preg_match("/r/",$acl)){ - $name = ""; - $value= ""; - } - - $table.="". - " ". - " ". - " ". - ""; - } - } - $table.= "
"._("Variable").""._("Default value")."
". - " ". - " ". - " ". - "
". - "
". - " ". - "
"; - $table.=""; - - /* Show main page */ - $smarty= get_smarty(); - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $smarty->assign("table", $table); - $display.= $smarty->fetch(get_template_path('parameters.tpl', TRUE)); - $this->parent->by_object['application']->generateTemplate(); - return ($display); - } - - function remove_from_parent() - { - $ldap= $this->config->get_ldap_link(); - - /* Zero attributes */ - $this->attrs= array(); - $this->attrs['gosaApplicationParameter']= array(); - - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of application parameters with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove'); - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['option0'])){ - for ($i= 0; $ioption_name); $i++){ - $this->option_name[$i]= $_POST["option$i"]; - $this->option_value[$i]= ""; - if ($_POST["value$i"] != ""){ - $this->option_value[$i]= $_POST["value$i"]; - } - } - } - } - - - /* Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Check for valid option names */ - for ($i= 0; $ioption_name); $i++){ - if (!preg_match ("/^[a-z0-9_]+$/i", $this->option_name[$i])){ - $message[]= sprintf(_("Value '%s' specified as option name is not valid."), - $this->option_name[$i]); - } - } - - return $message; - } - - - /* Save to LDAP */ - function save() - { - /* Generate values */ - $this->attrs= array(); - if (count($this->option_name) == 0){ - $this->attrs['gosaApplicationParameter']= array(); - } else { - for ($i= 0; $ioption_name); $i++){ - $this->attrs['gosaApplicationParameter'][]= $this->option_name[$i]. - ":".$this->option_value[$i]; - } - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of application parameters with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('modify'); - } - - /* Return plugin informations for acl handling -#FIXME FAIscript seams to ununsed within this class... */ - static function plInfo() - { - return (array( - "plShortName" => _("Parameter"), - "plDescription" => _("Parameter configuration"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("application"), - - "plProvidedAcls"=> array( - "gosaApplicationParameter" => _("Application parameter settings")) - )); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/applications/class_divListApplication.inc b/plugins/admin/applications/class_divListApplication.inc deleted file mode 100755 index 15b09c6d7..000000000 --- a/plugins/admin/applications/class_divListApplication.inc +++ /dev/null @@ -1,321 +0,0 @@ -selectedRelease = "ou=apps,".$_SESSION['CurrentMainBase']; - - $this->parent = &$parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of Applications")); - $this->SetSummary(_("This table displays all applications in the selected tree.")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to add, edit and remove selected applications. You may want to use the range selector on top of the application listbox, when working with a large number of applications.")); - - $this->EnableAplhabet(true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* set Page header */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Application name")." / "._("Department"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); - - /* Add SubSearch checkbox */ - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Display users matching"),"*" , true); - } - - function AddUserBoxToFilter($position){ - $str = ""; - if(($position == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){ - $smarty = get_smarty(); - $smarty->assign("selectedRelease",$this->selectedRelease); - $smarty->assign("branchimage","images/branch.png"); - $smarty->assign("releases",$this->AvailableReleases); - $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE)); - } - return($str); - } - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("application"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get acls */ - $ui = get_userinfo(); - $acl = $ui->get_permissions("cn=dummy,".$this->selectedBase,"application/application"); - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"application"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* And the rest, a base selection box */ - $listhead .= _("Base")." ". - "  "; - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("Application")."|appl_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - - $this->SetListHeader($listhead); - } - - /* so some basic settings */ - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - $this->AvailableReleases = $this->parent->getReleases($this->selectedBase); - } - - function setEntries($list) - { - /******************** - Variable init - ********************/ - - /* Create links */ - $linkopen = "%s"; - $editlink = "%s"; - $userimg = "User"; - $applimg = "A"; - $empty = ""; - - /* set Page header */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /******************** - Attach objects - ********************/ - - $ui = get_userinfo(); - foreach($list as $key => $val){ - - $acl = $ui->get_permissions($val['dn'],"application/application"); - $acl_all= $ui->has_complete_category_acls($val['dn'],"application"); - - /* Create action icons */ - $actions= ""; - - /* Add Copy & Paste icon */ - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - /* Only add cut icon, if we are allowed to move this user */ - if(preg_match("/m/",$acl)){ - $actions.= " "; - - $actions.= " "; - } - } - - /* Add edit icon */ - $actions.= ""; - - - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions.= $this->GetSnapShotActions($val['dn']); - } - - /* If we are allowed to remove the application account, display remove icon */ - if(preg_match("/d/",$acl)){ - $actions.= ""; - }else{ - $actions.= " "; - } - - $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; - - if(!isset($val['description'][0])){ - $desc = ""; - }else{ - $desc = " - [ ".$val['description'][0]." ]"; - } - - /* Cutted objects should be displayed in light grey */ - $display = $val['cn'][0].$desc; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => sprintf($applimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); - $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field0,$field1,$field2,$field3)); - } - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_apps = count($list); - - $num_app_str = _("Number of listed applications"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_app_str." ".$num_apps."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - } - - function Save() - { - MultiSelectWindow::Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - $_SESSION['appfilter']['release'] = $this->selectedRelease; - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/applications/generic.tpl b/plugins/admin/applications/generic.tpl deleted file mode 100644 index b50ed7eb8..000000000 --- a/plugins/admin/applications/generic.tpl +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
-{render acl=$cnACL} - -{/render} -
-{render acl=$gosaApplicationNameACL} - -{/render} -
-{render acl=$gosaApplicationExecuteACL} - -{/render} -
-{render acl=$descriptionACL} - -{/render} -
-{render acl=$baseACL} - -{/render} -{if !$isReleaseApplikation} -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -{/if} -
-
-   - - - - - - -
- -
- -
-  
- - -{render acl=$gosaApplicationIconACL} - -{/render} -{render acl=$gosaApplicationIconACL} - -{/render} -{render acl=$gosaApplicationIconACL} - -{/render} -
-
- -

 

- -

{t}Options{/t} {t}Options{/t}

- - - - - -
-{render acl=$gosaApplicationFlagsACL} - -{/render} - {t}Only executable for members{/t} -
-{render acl=$gosaApplicationFlagsACL} - -{/render} - {t}Replace user configuration on startup{/t} -
-{render acl=$gosaApplicationFlagsACL} - -{/render} - {t}Place icon on members desktop{/t} -
-{render acl=$gosaApplicationFlagsACL} - -{/render} - {t}Place entry in members startmenu{/t} -
-{render acl=$gosaApplicationFlagsACL} - -{/render} - {t}Place entry in members launch bar{/t} -
- -

 

- - - - - -
-

{t}Script{/t} {t}Script{/t}

-{render acl=$gotoLogonScriptACL} - -{/render} -{render acl=$gotoLogonScriptACL} - -{/render} -{render acl=$gotoLogonScriptACL} - -{/render} - -
- -
- - - diff --git a/plugins/admin/applications/main.inc b/plugins/admin/applications/main.inc deleted file mode 100644 index 2df737788..000000000 --- a/plugins/admin/applications/main.inc +++ /dev/null @@ -1,55 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('applicationManagement'); - } -} else { - /* Create applicationManagement object on demand */ - if (!isset($_SESSION['applicationManagement']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['applicationManagement']= new applicationManagement ($config, $_SESSION['ui']); - } - $applicationManagement= $_SESSION['applicationManagement']; - $applicationManagement->save_object(); - $output= $applicationManagement->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/application.png'), _("Application management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/application.png'), _("Application management")); - } - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('applicationManagement'); - } - - /* Show and save dialog */ - $display.= $output; - $_SESSION['applicationManagement']= $applicationManagement; -} - -?> diff --git a/plugins/admin/applications/parameters.tpl b/plugins/admin/applications/parameters.tpl deleted file mode 100644 index 57c221971..000000000 --- a/plugins/admin/applications/parameters.tpl +++ /dev/null @@ -1,2 +0,0 @@ -{$table} -
diff --git a/plugins/admin/applications/release_select.tpl b/plugins/admin/applications/release_select.tpl deleted file mode 100755 index d58738f05..000000000 --- a/plugins/admin/applications/release_select.tpl +++ /dev/null @@ -1,16 +0,0 @@ -
-
-

[F]{t}Branches{/t}

-
-
- - - - -
- {t}Current release{/t}  - -
-
diff --git a/plugins/admin/applications/remove.tpl b/plugins/admin/applications/remove.tpl deleted file mode 100644 index 8598ed857..000000000 --- a/plugins/admin/applications/remove.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$intro} - {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

-

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

- diff --git a/plugins/admin/applications/tabs_application.inc b/plugins/admin/applications/tabs_application.inc deleted file mode 100644 index 059e68335..000000000 --- a/plugins/admin/applications/tabs_application.inc +++ /dev/null @@ -1,62 +0,0 @@ -addSpecialTabs(); - } - - function set_release($newRelease) - { - $this->Release= preg_replace('/,ou=apps,.*$/', '', $newRelease); - if ($this->Release != ""){ - $this->Release= ",".$this->Release; - } - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['application']; - - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if((!empty($tmp)) && (isset($_SESSION['appfilter']['release']))){ - if(!$baseobject->isReleaseApplikation){ - $new_dn= "cn=".$baseobject->cn.",ou=apps,".$baseobject->base; - }else{ - $new_dn ="cn=".$baseobject->cn.",".$_SESSION['appfilter']['release']; - } - }else{ - $new_dn= "cn=".$baseobject->cn.",ou=apps,".$baseobject->base; - } - - /* Move group? */ - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->move($this->dn, $new_dn); - $this->by_object['application']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - tabs::save(); - - /* Fix tagging if needed */ - $baseobject->dn= $this->dn; - $baseobject->handle_object_tagging(); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc deleted file mode 100644 index 668da2f7a..000000000 --- a/plugins/admin/departments/class_departmentGeneric.inc +++ /dev/null @@ -1,610 +0,0 @@ -is_account= TRUE; - $this->ui= get_userinfo(); - $this->dn= $dn; - $this->orig_dn= $dn; - $this->orig_ou= $this->ou; - $this->config= $config; - - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - if(isset($_SESSION['CurrentMainBase'])){ - $this->base= $_SESSION['CurrentMainBase']; - }else{ - $this->base= dn2base($ui->dn); - } - } else { - $this->base= preg_replace ("/^[^,]+,/", "", $this->dn); - } - - $this->orig_base = $this->base; - - /* Is administrational Unit? */ - if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){ - $this->is_administrational_unit= true; - $this->initially_was_tagged = true; - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","department/".get_class($this),$this->dn); - } - - /* Reload departments */ - $this->config->get_departments($this->dn); - $this->config->make_idepartments(); - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Hide all departments, that are subtrees of this department */ - $bases = $this->get_allowed_bases(); - if(($this->dn == "new")||($this->dn == "")){ - $tmp = $bases; - }else{ - $tmp = array(); - foreach($bases as $dn=>$base){ - $fixed = str_replace("/","\\",$this->dn); - /* Only attach departments which are not a subtree of this one */ - if(!preg_match("/".$fixed."/",$dn)){ - $tmp[$dn]=$base; - } - } - } - $smarty->assign("bases", $tmp); - - foreach ($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - $smarty->assign("base_select", $this->base); - - /* Set admin unit flag */ - $smarty->assign("UnitTagDiabled",$this->UnitTagDiabled); - if(!$this->UnitTagDiabled){ - if ($this->is_administrational_unit) { - $smarty->assign("unitTag", "checked"); - } else { - $smarty->assign("unitTag", ""); - } - } - - return($smarty->fetch (get_template_path('generic.tpl', TRUE))); - } - - function clear_fields() - { - $this->dn = ""; - $this->base = ""; - - foreach ($this->attributes as $val){ - $this->$val= ""; - } - } - - function remove_from_parent() - { - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->recursive_remove(); - new log("remove","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of department with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove'); - } - - function must_be_tagged() - { - return $this->must_be_tagged; - } - - function am_i_moved() - { - return $this->rec_cpy; - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['dep_generic_posted'])){ - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - - /* Save tagging flag */ - if(!$this->UnitTagDiabled){ - if ($this->acl_is_writeable("unitTag")){ - if (isset($_POST['unitTag'])){ - $this->is_administrational_unit= true; - } else { - $this->is_administrational_unit= false; - } - } - } - } - } - - - /* Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Check for presence of this department */ - $ldap= $this->config->get_ldap_link(); - $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn')); - if ($this->orig_dn == "new" && $ldap->count()){ - $message[]= _("Department with that 'Name' already exists."); - } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){ - $message[]= _("Department with that 'Name' already exists."); - } - - /* All required fields are set? */ - if ($this->ou == ""){ - $message[]= _("Required field 'Name' is not set."); - } - if ($this->description == ""){ - $message[]= _("Required field 'Description' is not set."); - } - - if(is_department_name_reserved($this->ou,$this->base)){ - $message[]= sprintf(_("The field 'Name' contains the reserved word '%s'. Please choose another name."),$this->ou); - } - - if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){ - $message[]= _("The field 'Name' contains invalid characters."); - } - if (!is_phone_nr($this->telephoneNumber)){ - $message[]= _("The field 'Phone' contains an invalid phone number."); - } - if (!is_phone_nr($this->facsimileTelephoneNumber)){ - $message[]= _("The field 'Fax' contains an invalid phone number."); - } - - return $message; - } - - - /* Save to LDAP */ - function save() - { - $ldap= $this->config->get_ldap_link(); - - if(!$this->UnitTagDiabled){ - - /* Add tag objects if needed */ - if ($this->is_administrational_unit){ - - /* If this wasn't tagged before add oc an reset unit tag */ - if(!$this->initially_was_tagged){ - $this->objectclasses[]= "gosaAdministrativeUnit"; - $this->gosaUnitTag= ""; - - /* It seams that this method is called twice, - set this to true. to avoid adding this oc twice */ - $this->initially_was_tagged = true; - } - - if ($this->gosaUnitTag == ""){ - - /* It's unlikely, but check if already used... */ - $try= 5; - $ldap->cd($this->config->current['BASE']); - while ($try--){ - - /* Generate microtime stamp as tag */ - list($usec, $sec)= explode(" ", microtime()); - $time_stamp= preg_replace("/\./", "", $sec.$usec); - - $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag")); - if ($ldap->count() == 0){ - break; - } - } - if($try == 0) { - print_red(_("Fatal error: Can't find an unused tag to mark the administrative unit!")); - return; - } - $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec); - } - } - } - plugin::save(); - - if(!$this->UnitTagDiabled){ - - /* Remove tag information if needed */ - if (!$this->is_administrational_unit){ - $tmp= array(); - - /* Remove gosaAdministrativeUnit from this plugin */ - $has_unit_tag= false; - foreach($this->attrs['objectClass'] as $oc){ - if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){ - $tmp[]= $oc; - } - if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){ - $has_unit_tag= true; - } - } - $this->attrs['objectClass']= $tmp; - - if(!$has_unit_tag && isset($this->attrs['gosaUnitTag'])){ - $this->attrs['gosaUnitTag']= array(); - } - $this->gosaUnitTag = ""; - } - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('dn')); - $a= $ldap->fetch(); - $ldap->cd($this->dn); - - if (count($a)){ - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events('modify'); - } else { - $ldap->add($this->attrs); - $this->handle_post_events('add'); - new log("create","department/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of department with dn '%s' failed."),$this->dn)); - - - if(!$this->UnitTagDiabled){ - /* The parameter forces only to set must_be_tagged, and don't touch any objects - This will be done later */ - $this->tag_objects(true); - - /* Fix tagging if needed */ - if (!$this->is_administrational_unit){ - $this->handle_object_tagging(); - } - } - - /* Optionally execute a command after we're done */ - $this->postcreate(); - return(false); - } - - - function ShowMoveFrame() - { - $smarty = get_smarty(); - $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove"); - $smarty->assign("message","As soon as the move operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog."); - $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)); - return($display); - } - - function ShowTagFrame() - { - $smarty = get_smarty(); - $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment"); - $smarty->assign("message","As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog."); - $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)); - return($display); - } - - /* Tag objects to have the gosaAdministrativeUnitTag */ - function tag_objects($OnlySetTagFlag = false) - { - if(!$OnlySetTagFlag){ - $smarty= get_smarty(); - /* Print out html introduction */ - echo ' - - - - - - - - '; - echo "

".sprintf(_("Tagging '%s'."),"".@LDAP::fix($this->dn)."")."

"; - } - - $add= $this->is_administrational_unit; - $len= strlen($this->dn); - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - if ($add){ - $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='. - $this->gosaUnitTag.')))', array('dn')); - } else { - $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn')); - } - - while ($attrs= $ldap->fetch()){ - - /* Skip self */ - if ($attrs['dn'] == $this->dn){ - continue; - } - - /* Check for confilicting administrative units */ - $fix= true; - foreach ($this->config->adepartments as $key => $tag){ - /* This one is shorter than our dn, its not relevant... */ - if ($len >= strlen($key)){ - continue; - } - - /* This one matches with the latter part. Break and don't fix this entry */ - if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){ - $fix= false; - break; - } - } - - /* Fix entry if needed */ - if ($fix){ - if($OnlySetTagFlag){ - $this->must_be_tagged =true; - return; - } - $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE ); - } - } - if(!$OnlySetTagFlag){ - echo '

 

'; - echo "
-
-
"; - } - } - - - /* Move/Rename complete trees */ - function recursive_move($src_dn, $dst_dn,$force = false) - { - /* If force == false prepare to recursive move this object from src to dst - on the next call. */ - if(!$force){ - $this->rec_cpy = true; - $this->rec_src = $src_dn; - $this->rec_dst = $dst_dn; - }else{ - - /* If this is called, but not wanted, abort */ - if(!$this->rec_cpy){ - return; - } - - $src_dn = $this->rec_src; - $dst_dn = $this->rec_dst; - - /* Print header to have styles included */ - $smarty= get_smarty(); - - echo ' - - - - - - - - '; - echo "

".sprintf(_("Moving '%s' to '%s'"),"".@LDAP::fix($src_dn)."","".@LDAP::fix($dst_dn)."")."

"; - - - /* Check if the destination entry exists */ - $ldap= $this->config->get_ldap_link(); - - /* Check if destination exists - abort */ - $ldap->cat($dst_dn, array('dn')); - if ($ldap->fetch()){ - trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.", - E_USER_WARNING); - echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."
"; - return (FALSE); - } - - /* Perform a search for all objects to be moved */ - $objects= array(); - $ldap->cd($src_dn); - $ldap->search("(objectClass=*)", array("dn")); - while($attrs= $ldap->fetch()){ - $dn= $attrs['dn']; - $objects[$dn]= strlen($dn); - } - - /* Sort objects by indent level */ - asort($objects); - reset($objects); - - /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */ - foreach ($objects as $object => $len){ - - - $src= str_replace("\\","\\\\",$object); - $dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object); - $dst= str_replace($src_dn,$dst_dn,$object); - - echo ""._("Object").": ".@LDAP::fix($src)."
"; - - $this->update_acls($object, $dst,TRUE); - - if (!$this->copy($src, $dst)){ - echo "
".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."
"; - return (FALSE); - } - echo "" ; - flush(); - } - - /* Remove src_dn */ - $ldap->cd($src_dn); - $ldap->recursive_remove(); - $this->dn = $this->rec_dst; - $this->rec_src = $this->rec_dst = ""; - $this->rec_cpy =false; - - echo '

 

'; - - echo "
-
-
"; - - echo "" ; - echo ""; - - return (TRUE); - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array("plShortName" => _("Generic"), - "plDescription" => _("Departments"), - "plSelfModify" => FALSE, - "plPriority" => 0, - "plDepends" => array(), - "plSection" => array("admin"), - "plCategory" => array("department" => array("objectClass" => "gosaDepartment", "description" => _("Departments"))), - - "plProvidedAcls" => array( - "description" => _("Description"), - "c" => _("Country"), - "base" => _("Base"), - "l" => _("Location"), - "telephoneNumber" => _("Telephone"), - "ou" => _("Department name"), - "businessCategory" => _("Category"), - "st" => _("State"), - "postalAddress" => _("Address"), - "gosaUnitTag" => _("Administrative settings"), - "facsimileTelephoneNumber" => _("Fax")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/departments/class_departmentManagement.inc b/plugins/admin/departments/class_departmentManagement.inc deleted file mode 100644 index e2db188d1..000000000 --- a/plugins/admin/departments/class_departmentManagement.inc +++ /dev/null @@ -1,535 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Headpage attributes */ - var $last_dep_sorting= "invalid"; - var $departments= array(); - var $deptabs= NULL; - - /* attribute list for save action */ - var $attributes= array(); - var $objectclasses= array(); - - /* Vars to handle operations after saving the department - Recursive move && tagging */ - var $ObjectInSaveMode = false; // Is true, if current object wasn't saved right now - var $ObjectTaggingRequested = false; // Object must be tagged, an iframe will be shown. - var $RecursiveRemoveRequested = false; // Is true, if this object must be moved, an iframe will be displayed in this case - - function departmentManagement (&$config, &$ui) - { - $this->ui= &$ui; - $this->dn= ""; - $this->config= &$config; - $this->DivListDepartment = new divListDepartment($this->config,$this); - } - - function execute() - { - global $config; - - /* Call parent execute */ - plugin::execute(); - - /*************** - Var init - ***************/ - - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^dep_edit_.*/","/^dep_del_.*/","/^item_selected/","/^remove_multiple_departments/"); - - /* Reload departments */ - $smarty = get_smarty(); - $display = ""; - $s_action = ""; // Will contain an action, like del or edit - $s_entry = ""; // The entry name for edit delete -... - - - /*************** - Check posts - ***************/ - - // Check Post action - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/dep_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/dep_".$s_action."_/i","",$key); - $s_entry = preg_replace("/_.*$/","",$s_entry); - $s_entry = base64_decode($s_entry); - // Post for edit - }elseif(preg_match("/dep_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/dep_".$s_action."_/i","",$key); - $s_entry = preg_replace("/_.*$/","",$s_entry); - $s_entry = base64_decode($s_entry); - // Post for new - }elseif(preg_match("/^remove_multiple_departments/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/dep_new.*/",$key)){ - $s_action="new"; - } - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "dep_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - /*************** - Create a new department - ***************/ - - /* New Entry if Posted action (s_action) == new - */ - if ($s_action=="new"){ - $this->dn= "new"; - $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $this->dn,"department"); - $this->deptabs->set_acl_base($this->DivListDepartment->selectedBase); - } - - - /*************** - Edit entry - ***************/ - - /* Edit Entry if Posted action (s_action) == edit - * The entry which will be edited is defined in $s_entry - */ - if (( $s_action=="edit") && (!isset($this->deptabs->config))){ - $this->dn= $this->config->departments[trim($s_entry)]; - - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so everyone will get the above dialog */ - add_lock ($this->dn, $this->ui->dn); - - /* Register deptabs to trigger edit dialog */ - $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $this->dn,"department"); - $this->deptabs->set_acl_base($this->dn); - - $_SESSION['objectinfo']= $this->dn; - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - - - if(count($ids)){ - foreach($ids as $id){ - $id = base64_decode($id); - $dn = $this->config->departments[$id]; - - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("info", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("info", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); - } - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_department_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - $acl = $this->ui->get_permissions($dn,"department/department"); - if (preg_match('/d/', $acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $dn,"department"); - $this->deptabs->set_acl_base(); - $this->deptabs->delete (); - $this->deptabs = NULL; - } else { - print_red (_("You have no permission to remove this department.")); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_department_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /*************** - Delete entry - ***************/ - - /* Delete Entry if Posted action (s_action) == del - * The entry which will be deleted is defined in $s_entry - */ - if ($s_action =="del"){ - $this->dn= $this->config->departments[trim($s_entry)]; - - /* check acls */ - $acl = $this->ui->get_permissions($this->dn,"department/department"); - if(preg_match("/d/",$acl)){ - - /* Check locking */ - if (($user= get_lock($this->dn)) != ""){ - $_SESSION['dn']= $this->dn; - return(gen_locked_message($user, $this->dn)); - } else { - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), @LDAP::fix($this->dn))); - $smarty->assign("multiple", false); - $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE)); - return ($display); - } - }else{ - print_red (_("You have no permission to remove this department.")); - } - } - - - /*************** - Delete department confirmed - ***************/ - - /* If department deletion is accepted ... - * Finally delete department - */ - if (isset($_POST['delete_department_confirm'])){ - - /* check acls */ - $acl = $this->ui->get_permissions($this->dn,"department/department"); - if(preg_match("/d/",$acl)){ - $this->remove_from_parent(); - } else { - print_red (_("You have no permission to remove this department.")); - } - } - - - /*************** - Edit department finished - ***************/ - - if ((isset($_POST['edit_finish'])) && (isset($this->deptabs->config)) && !isset($_POST['dep_move_confirm'])){ - $this->deptabs->save_object(); - $obj = $this->deptabs->by_object['department']; - if($obj->orig_dn != "new"){ - if($obj->orig_ou != $obj->ou || $obj->base != $obj->orig_base){ - return($smarty->fetch(get_template_path("dep_move_confirm.tpl",TRUE))); - } - } - } - - /* Save changes */ - if ((isset($_POST['edit_finish'])|| isset($_POST['dep_move_confirm'])) && (isset($this->deptabs->config))){ - - /* Check tabs, will feed message array */ - $message= $this->deptabs->check(); - - /* Save, or display error message? */ - if (count($message) == 0){ - - $this->deptabs->save(true); - global $config; - $config->get_departments(); - $config->make_idepartments(); - $this->config = $config; - - /* This object must be tagged, so set ObjectTaggingRequested to true */ - if($this->deptabs->by_object['department']->must_be_tagged()){ - $this->ObjectTaggingRequested = true; - } - - /* Get recursive move is required, set RecursiveRemoveRequested to true */ - if($this->deptabs->by_object['department']->am_i_moved()){ - $this->RecursiveRemoveRequested = true; - } - - /* This var indicated that there is an object which isn't saved right now. */ - $this->ObjectInSaveMode = true; - - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /*************** - Handle Tagging (Return output for an iframe) - ***************/ - - /* This department must be tagged (Is called from iframe, generates output)*/ - if(isset($_GET['TagDepartment'])){ - $this->deptabs->by_object['department']->tag_objects(); - exit(); - } - - - /*************** - Handle recursive move (Return output for an iframe) - ***************/ - - /* initiate recursive remove (Is called from iframe, generates output)*/ - if(isset($_GET['PerformRecMove'])){ - $this->deptabs->by_object['department']->recursive_move("","",true); - $this->DivListDepartment->selectedBase = $this->deptabs->by_object['department']->dn; - exit(); - } - - - /*************** - Return iframes, which call tagging / recusrsive move - ***************/ - - /* While one of these vars below isset, we must return an iframe, - to perform requested operation */ - if($this->ObjectTaggingRequested){ - $this->ObjectTaggingRequested = false; - return($this->deptabs->by_object['department']->ShowTagFrame()); - } - if($this->RecursiveRemoveRequested){ - $this->RecursiveRemoveRequested = false; - return($this->deptabs->by_object['department']->ShowMoveFrame()); - } - - - /*************** - In case of tagging/moving the object wasn't deleted, do it know - ***************/ - - /* If there is an unsaved object and all operations are done - remove locks & save object tab & unset current object */ - if($this->ObjectInSaveMode && (!$this->RecursiveRemoveRequested) && (!$this->ObjectTaggingRequested)){ - $this->deptabs->save(); - $this->config->get_departments(); - $this->ObjectInSaveMode = false; - if ($this->dn != "new"){ - del_lock ($this->dn); - } - unset ($this->deptabs); - $this->deptabs= NULL; - unset ($_SESSION['objectinfo']); - } - - - /*************** - Dialog canceled - ***************/ - - /* User canceled edit oder delete - * Cancel dialog - */ - if (isset($_POST['edit_cancel']) || isset($_POST['delete_cancel']) || isset($_POST['delete_department_confirm'])){ - del_lock ($this->dn); - unset($this->depdabs); - $this->deptabs= NULL; - unset ($_SESSION['objectinfo']); - } - - /* Headpage or normal plugin screen? */ - if ($this->deptabs !== NULL){ - - /* Show main page (tabs) */ - $display= $this->deptabs->execute(); - if (!$this->deptabs->by_object[$this->deptabs->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - $display.= "\n"; - $display.= "

"; - } - return ($display); - }else{ - /* Display dialog with group list */ - $this->DivListDepartment->parent = $this; - $this->DivListDepartment->execute(); - $this->reload(); - $this->DivListDepartment->DepartmentsAdded = true; - $this->DivListDepartment->setEntries($this->departments); - return($this->DivListDepartment->Draw()); - } - } - - - function reload() - { - /* Vairaible init */ - $base = $this->DivListDepartment->selectedBase; - $base_back = preg_replace("/^[^,]+,/","",$base); - $Regex = $this->DivListDepartment->Regex; - - // Create Array to Test if we have a valid back button - $tmp = $_SESSION['config']->idepartments; - - // In case of a valid back button create entry - if(isset($tmp[$base_back])){ - $tmp2 ['dn'] = convert_department_dn($base_back); - - // If empty always go to top - if(empty($tmp2['dn'])){ - $tmp2['dn']="/"; - } - $tmp2 ['description'][0] = ".. "._("Back"); - $result[$tmp[$base_back]]=$tmp2; - } - - if($this->DivListDepartment->SubSearch){ - $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))", - "department", $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH); - }else{ - $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))", - "department", $base, array("ou", "description"), GL_SIZELIMIT ); - } - - $this->departments= array(); - - /* Add current base to the list of available departments, but only if its naming attribute is 'ou' */ - if(preg_match("/^ou=/",$base)){ - $this->departments [ convert_department_dn($base) ] = "."; - } - - foreach ($res as $key => $value){ - - /* Don't display base as entry on subsearch */ - if(($value['dn'] == $base) && ($this->DivListDepartment->SubSearch)){ - continue; - } - - $cdn= convert_department_dn($value['dn']); - - /* Append to dep list */ - if(isset($value["description"][0])){ - $this->departments[$cdn]= get_sub_department($cdn)." - [".$value["description"][0]."]"; - }else{ - $this->departments[$cdn]= get_sub_department($cdn);//$value["description"][0]; - } - } - natcasesort ($this->departments); - reset ($this->departments); - } - - function remove_from_parent() - { - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->recursive_remove(); - - /* Optionally execute a command after we're done */ - $this->postremove(); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[a-z0-9\\/\=]*$/i",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function remove_lock() - { - if (isset($this->dn)){ - del_lock ($this->dn); - } - } - - function save_object() - { - /* reload department */ - $this->config->get_departments(); - - $this->config->make_idepartments(); - $this->DivListDepartment->config= $this->config; - $this->DivListDepartment->save_object(); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/departments/class_divListDepartment.inc b/plugins/admin/departments/class_divListDepartment.inc deleted file mode 100755 index b1f642dbf..000000000 --- a/plugins/admin/departments/class_divListDepartment.inc +++ /dev/null @@ -1,228 +0,0 @@ -parent = &$parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of departments")); - $this->SetSummary(_("List of departments")); - $this->EnableAplhabet (true); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to create, delete and edit selected departments. Having a large number of departments, you might prefer the range selectors on top of the department list.")); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string"=>_("Department name"), "attach" => "style=''")); - $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")); - - - /* Add SubSearch checkbox */ - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching department names"), "*" , true); - } - - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("department"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Generate list head */ - $ui = get_userinfo(); - $acl = $ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/department"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - $listhead .= - " "._("Base")." ". - "  "; - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("Department")."|dep_new|\n"; - } - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - $linkopen = "%s"; - - $ui = get_userinfo(); - foreach($list as $key => $val) { - - $actions= ""; - - $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department"); - if(preg_match("/r/",$acl)){ - $actions.= ""; - } - - if(preg_match("/c/",$acl)){ - $actions.= ""; - } - - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - - /* check if this department contains sub-departments - Display different image in this case - */ - $non_empty=""; - $nkey= normalizePreg($key); - foreach($this->config->departments as $keyd=>$vald ){ - if(preg_match('/$nkey\/.*/',$keyd)){ - $non_empty="full"; - } - } - - $title = preg_replace('/ /', ' ', @LDAP::fix($this->config->departments[$key])); - - if($val == "."){ - $field01 = array("string" => " ", - "attach" => "style='width:20px;'"); - }else{ - $field01 = array("string" => "" , - "attach" => "style='width:20px;'"); - } - - $field0 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); - $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'"); - $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align: - right;'"); - - $this->AddElement( array($field01,$field0,$field1,$field2)); - } - - /* Create summary string for list footer */ - $num_deps=count($list); - $num_dep_str = _("Number of listed departments"); - $str = "".$num_dep_str." ".$num_deps."    "; - $this->set_List_Bottom_Info($str); - - } - function Save() - { - MultiSelectWindow::Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/departments/dep_iframe.tpl b/plugins/admin/departments/dep_iframe.tpl deleted file mode 100644 index 396cf2cf0..000000000 --- a/plugins/admin/departments/dep_iframe.tpl +++ /dev/null @@ -1,21 +0,0 @@ -

{t}Processing the requested operation{/t}

-{$message} -
-
-
- -
- - diff --git a/plugins/admin/departments/dep_move_confirm.tpl b/plugins/admin/departments/dep_move_confirm.tpl deleted file mode 100644 index 9338b7611..000000000 --- a/plugins/admin/departments/dep_move_confirm.tpl +++ /dev/null @@ -1,19 +0,0 @@ -
-  {t}Warning{/t} - {t}You are currently moving/renaming this department.{/t} -
-

-{t}Modifying a departments naming attribute 'ou' or base may corrupt acls and snapshot entries for all entire objects.{/t} -

-

-{t}GOsa can NOT fix this for you, yet.{/t} -

-

-{t}Before you confirm this action, ensure that everything will be as expected, possibly the best solution is a backup.{/t} -

- -

- -   - -

- diff --git a/plugins/admin/departments/generic.tpl b/plugins/admin/departments/generic.tpl deleted file mode 100644 index 7e353be8c..000000000 --- a/plugins/admin/departments/generic.tpl +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - -
-

{t}Properties{/t}

- - - - - - - - - - - - - - - - - - - - - - -
{$must} -{render acl=$ouACL} - -{/render} -
{$must} -{render acl=$descriptionACL} - -{/render} -
-{render acl=$businessCategoryACL} - -{/render} -

{$must} -{render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
- -
-   - -

{t}Location{/t}

- - - - - - - - - - - - - - - - - - - - - -
-{render acl=$stACL} - -{/render} -
-{render acl=$lACL} - -{/render} -
-{render acl=$postalAddressACL} - -{/render} -
-{render acl=$telephoneNumberACL} - -{/render} -
-{render acl=$facsimileTelephoneNumberACL} - -{/render} -
- -
- - -{if !$UnitTagDiabled} - - - -

 

- - - - - -
-

{t}Administrative settings{/t}

-{render acl=$gosaUnitTagACL} - -{/render} -
- -{/if} - - - diff --git a/plugins/admin/departments/main.inc b/plugins/admin/departments/main.inc deleted file mode 100644 index 5db627873..000000000 --- a/plugins/admin/departments/main.inc +++ /dev/null @@ -1,57 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('department'); - } -} else { - /* Create usermanagement object on demand */ - if (!isset($_SESSION['department']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['department']= new departmentManagement($config, $ui); - } - $department= $_SESSION['department']; - - /* Show and save dialog */ - $department->save_object(); - $output= $department->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/department.png'), _("Department management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/department.png'), _("Department management")); - } - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('department'); - } - - $display.= $output; - $_SESSION['department']= $department; - $config = $department->config; -} - -?> diff --git a/plugins/admin/departments/remove.tpl b/plugins/admin/departments/remove.tpl deleted file mode 100644 index e4e075aa3..000000000 --- a/plugins/admin/departments/remove.tpl +++ /dev/null @@ -1,24 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}This includes 'all' accounts, systems, etc. in this subtree. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

- diff --git a/plugins/admin/departments/tabs_department.inc b/plugins/admin/departments/tabs_department.inc deleted file mode 100644 index cf04bd29b..000000000 --- a/plugins/admin/departments/tabs_department.inc +++ /dev/null @@ -1,52 +0,0 @@ -base= $this->by_object['department']->base; - - /* Add references/acls/snapshots */ - $this->addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['department']; - $ou= preg_replace('/,/', '\,', $baseobject->ou); - $new_dn= @LDAP::convert('ou='.$ou.','.$baseobject->base); - - if($ignore_account){ - if ($this->dn != $new_dn && $this->dn != "new"){ - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ - /* Prepare to be moved */ - $baseobject->recursive_move($this->dn, $new_dn); - $this->by_object['department'] = $baseobject; - return; - } - } - } - $this->dn= $new_dn; - $baseobject->dn= $this->dn; - $this->by_object['department']= $baseobject; - return(tabs::save(TRUE)); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/devices/class_deviceGeneric.inc b/plugins/admin/devices/class_deviceGeneric.inc deleted file mode 100644 index 095adf7f3..000000000 --- a/plugins/admin/devices/class_deviceGeneric.inc +++ /dev/null @@ -1,241 +0,0 @@ -is_account = TRUE; - - /* Set class values */ - if(isset($this->attrs['gotoHotplugDevice'][0])){ - $tmp = preg_split("/\|/",$this->attrs['gotoHotplugDevice'][0]); - $this->cn = $this->attrs['cn'][0]; - $this->description= $tmp[0]; - $this->dev_id = $tmp[1]; - $this->serial = $tmp[2]; - $this->vendor = $tmp[3]; - } - - $this->orig_cn = $this->cn; - - /* Set Base */ - if ($this->dn == "new"){ - if(isset($_SESSION['CurrentMainBase'])){ - $this->base= $_SESSION['CurrentMainBase']; - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - $this->base =preg_replace ("/^[^,]+,ou=devices,/","",$this->dn); - } - } - - - public function execute() - { - $smarty = get_smarty(); - $smarty->assign("base",$this->base); - $smarty->assign("bases",$this->get_allowed_bases()); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - foreach($this->posts as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("deviceGeneric.tpl",TRUE,dirname(__FILE__)))); - } - - - public function check() - { - $message = plugin::check(); - - if(empty($this->cn)||(preg_match("/[^a-z0-9]/i",$this->cn))){ - $message[]=_("Please specify a valid name. Only 0-9 a-Z is allowed."); - } - if(preg_match("/[^a-z0-9!\"?.,;:-_\(\) ]/i",$this->description)){ - $message[]=_("Invalid character in description. Please specify a valid description."); - } - - /* Skip serial check if vendor and product id are given */ - if(preg_match("/^\s+$/i",$this->dev_id)){ - $message[]=_("Please specify a valid iSerial."); - } - if(empty($this->serial) || !$this->is_2byteHex($this->serial)){ - $message[]=_("Please specify a valid vendor ID. (2 byte hex like '0xFFFF')"); - } - if(empty($this->vendor) || !$this->is_2byteHex($this->vendor)){ - $message[]=_("Please specify a valid product ID. (2 byte hex like '0xFFFF')"); - } - - /* Check if entry already exists */ - if($this->cn != $this->orig_cn){ - $ldap = $this->config->get_ldap_link(); - $ldap->search("(&(objectClass=gotoDevice)(cn=".$this->cn."*))",array("cn")); - if($ldap->count()){ - $message[]=_("An Entry with this name already exists."); - } - } - - return($message); - } - - - public function save_object() - { - if(isset($_POST['deviceGeneric_posted'])){ - plugin::save_object(); - - if(isset($_POST['base'])){ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[get_post("base")])){ - $this->base = get_post("base"); - } - } - - foreach($this->posts as $post){ - if(isset($_POST[$post])){ - $this->$post = get_post($post); - } - } - } - } - - - public function remove_from_parent() - { - plugin::remove_from_parent(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDeviceDN=".$this->dn."))",array("cn","gotoHotplugDeviceDN")); - $skip = FALSE; - $str =""; - $cnt = 3; - while($cnt && $attrs = $ldap->fetch()){ - $skip =TRUE; - $str .= $attrs['cn'][0].", "; - $cnt --; - } - if($skip){ - $str = preg_replace("/, $/","",$str); - if($cnt == 0){ - $str .= "..."; - } - print_red(sprintf(_("Can't remove the device '%s' it is still in use be this user(s) : %s"),$this->cn,$str)); - }else{ - $ldap->rmdir_recursive($this->dn); - } - } - - - public function save() - { - plugin::save(); - - $this->attrs['gotoHotplugDevice'] = ""; - foreach($this->posts as $post){ - $this->attrs['gotoHotplugDevice'] .= $this->$post."|"; - } - $this->attrs['gotoHotplugDevice'] = preg_replace("/\|$/","",$this->attrs['gotoHotplugDevice']); - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error(),_("Device could not be saved.")); - } - - - /* check if given str in like this 0xffff*/ - function is_2byteHex($str) - { - return !strlen($str) || preg_match("/^(0x|x|)[a-f0-9][a-f0-9][a-f0-9][a-f0-9]/i",$str); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - $source_o = new deviceGeneric($this->config,$source['dn']); - foreach($this->CopyPasteVars as $post){ - $this->$post = $source_o->$post; - } - } - - - /* Return a dialog with all fields that must be changed, - if we want to copy this entry */ - function getCopyDialog() - { - $str = ""; - $smarty = get_smarty(); - $smarty->assign("cn", $this->cn); - $str = $smarty->fetch(get_template_path("paste_deviceGeneric.tpl",TRUE,dirname(__FILE__))); - - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - /* Save all */ - function saveCopyDialog() - { - $attrs = array("cn"); - foreach($attrs as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - } - - - - /* Return plugin informations for acl handling */ - public static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Device generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("devices" => array("description" => _("Devices"), - "objectClass" => "gotoHotplugDevice")), - "plProvidedAcls"=> array( - "cn" => _("Name")) - )); - - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/devices/class_deviceManagement.inc b/plugins/admin/devices/class_deviceManagement.inc deleted file mode 100644 index dbdfc0fb4..000000000 --- a/plugins/admin/devices/class_deviceManagement.inc +++ /dev/null @@ -1,554 +0,0 @@ -ui = get_userinfo(); - - /* Check if copy & paste is activated */ - if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - - /* Creat dialog object */ - $this->DivListDevices = new divListDevices($this->config,$this); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /**************** - Variable init - ****************/ - - /* These vars will be stored if you try to open a locked device, - to be able to perform your last requests after showing a warning message */ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^device_edit_/", - "/^device_del_/","/^item_selected/","/^remove_multiple_devices/"); - - $smarty = get_smarty(); // Smarty instance - $s_action = ""; // Contains the action to proceed - $s_entry = ""; // The value for s_action - $base_back = ""; // The Link for Backbutton - - /* Test Posts */ - foreach($_POST as $key => $val){ - - if(preg_match("/device_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/device_".$s_action."_/i","",$key); - }elseif(preg_match("/device_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/device_".$s_action."_/i","",$key); - }elseif(preg_match("/^copy_.*/",$key)){ - $s_action="copy"; - $s_entry = preg_replace("/^copy_/i","",$key); - }elseif(preg_match("/^cut_.*/",$key)){ - $s_action="cut"; - $s_entry = preg_replace("/^cut_/i","",$key); - }elseif(preg_match("/^device_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/^remove_multiple_devices/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^editPaste.*/i",$key)){ - $s_action="editPaste"; - }elseif(preg_match("/^multiple_copy_devices/",$key)){ - $s_action = "copy_multiple"; - }elseif(preg_match("/^multiple_cut_devices/",$key)){ - $s_action = "cut_multiple"; - } - } - - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; - } - - $s_entry = preg_replace("/_.$/","",$s_entry); - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "device_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - /**************** - Copy & Paste handling - ****************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - /**************** - Create a new device type - ****************/ - - /* New device type? */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->DivListDevices->selectedBase,"devices/deviceGeneric"); - if (($s_action=="new") && preg_match("/c/",$acl)){ - - /* By default we set 'dn' to 'new', all relevant plugins will - react on this. */ - $this->dn= "new"; - - /* Create new usertab object */ - $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $this->dn,"devices"); - $this->devicetabs->set_acl_base($this->DivListDevices->selectedBase); - } - - - /**************** - Edit entry canceled - ****************/ - - /* Cancel dialogs */ - if (isset($_POST['edit_cancel']) && is_object($this->devicetabs)){ - del_lock ($this->devicetabs->dn); - unset ($this->devicetabs); - $this->devicetabs= NULL; - unset ($_SESSION['objectinfo']); - } - - - /**************** - Edit entry finished - ****************/ - - /* Finish device edit is triggered by the tabulator dialog, so - the user wants to save edited data. Check and save at this point. */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->devicetabs->config))){ - - /* Check tabs, will feed message array */ - $this->devicetabs->save_object(); - $message= $this->devicetabs->check(); - - /* Save, or display error message? */ - if (count($message) == 0){ - - /* Save data data to ldap */ -# $this->devicetabs->set_release($this->DivListDevices->selectedRelease); - $this->devicetabs->save(); - - if (!isset($_POST['edit_apply'])){ - /* device type has been saved successfully, remove lock from LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - unset ($this->devicetabs); - $this->devicetabs= NULL; - unset ($_SESSION['objectinfo']); - } - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /**************** - Edit entry - ****************/ - - /* User wants to edit data? */ - if (($s_action=="edit") && (!isset($this->devicetabs->config))){ - - /* Get 'dn' from posted 'devicelist', must be unique */ - $this->dn= $this->devices[$s_entry]['dn']; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so everyone will get the - above dialog */ - add_lock ($this->dn, $this->ui->dn); - - - /* Register devicetabs to trigger edit dialog */ - $this->devicetabs= new devicetabs($this->config,$this->config->data['TABS']['DEVICETABS'], $this->dn,"devices"); - $this->devicetabs->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->devices[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("intro", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("intro", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); - } - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_device_confirm'])){ - - $ui = get_userinfo(); - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - $acl = $ui->get_permissions($dn,"devices/deviceGeneric"); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $dn,"devices"); - $this->devicetabs->set_acl_base($dn); - $this->devicetabs->delete (); - unset ($this->devicetabs); - $this->devicetabs= NULL; - - } else { - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this device type!")); - new log("security","devices/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_device_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /**************** - Delete device type - ****************/ - - /* Remove user was requested */ - if ($s_action == "del"){ - - /* Get 'dn' from posted 'uid' */ - $this->dn= $this->devices[$s_entry]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->dn,"devices/deviceGeneric"); - if (preg_match("/d/",$acl)){ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return (gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty= get_smarty(); - $smarty->assign("intro", sprintf(_("You're about to delete the device '%s'."), @LDAP::fix($this->dn))); - $smarty->assign("multiple", false); - return($smarty->fetch (get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this device!")); - } - } - - - /**************** - Delete device confirmed - ****************/ - - /* Confirmation for deletion has been passed. Group should be deleted. */ - if (isset($_POST['delete_device_confirm'])){ - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->dn,"devices/deviceGeneric"); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $this->dn,"devices"); - $this->devicetabs->set_acl_base($this->dn); - $this->devicetabs->delete (); - unset ($this->devicetabs); - $this->devicetabs= NULL; - - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this device!")); - new log("security","devices/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - - /**************** - Delete device canceled - ****************/ - - /* Delete device canceled? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - /* Show tab dialog if object is present */ - if (($this->devicetabs) && (isset($this->devicetabs->config))){ - $display= $this->devicetabs->execute(); - - /* Don't show buttons if tab dialog requests this */ - if (!$this->devicetabs->by_object[$this->devicetabs->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - return ($display); - } - - - /**************** - Dialog display - ****************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListDevices->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Display dialog with system list */ - $this->DivListDevices->parent = $this; - $this->DivListDevices->execute(); - $this->DivListDevices->AddDepartments($this->DivListDevices->selectedBase,3,1); - $this->reload(); - $this->DivListDevices->setEntries($this->devices); - return($this->DivListDevices->Draw()); - - } - - function save_object() { - $this->DivListDevices->save_object(); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array("ou=devices,".$this->DivListDevices->selectedBase)); - } - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->devices[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"devicetabs","DEVICETABS","devices"); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->devices[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","devicetabs","DEVICETABS","devices"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","devicetabs","DEVICETABS","devices"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListDevices->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - - function reload() - { - /* Set base for all searches */ - $base = $this->DivListDevices->selectedBase; - $Regex = $this->DivListDevices->Regex; - $SubSearch = $this->DivListDevices->SubSearch; - $Flags = GL_NONE | GL_SIZELIMIT; - $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=gotoDevice))"; - $tmp = array(); - - /* In case of subsearch, add the subsearch flag */ - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - }else{ - $base ="ou=devices,".$base; - } - - /* Get results and create index */ - $res= get_list($Filter, "devices", $base, array("cn","description","dn","objectClass"), $Flags); - foreach ($res as $val){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; - } - - /* sort entries */ - ksort($tmp); - $this->devices=array(); - foreach($tmp as $val){ - $this->devices[]=$val; - } - reset ($this->devices); - } - - function remove_lock() - { - if (isset($this->devicetabs->dn)){ - del_lock ($this->devicetabs->dn); - } - } - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function remove_from_parent() - { - /* This cannot be removed... */ - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/devices/class_divListDevices.inc b/plugins/admin/devices/class_divListDevices.inc deleted file mode 100755 index fb09fe8c8..000000000 --- a/plugins/admin/devices/class_divListDevices.inc +++ /dev/null @@ -1,303 +0,0 @@ -parent = &$parent; - $this->ui = get_userinfo(); - - /* set Page header */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /* Set list strings */ - $this->SetTitle (_("List of defined devices")); - $this->SetSummary (_("List of defined devices")); - $this->SetInformation (_("This menu allows you to add, edit and remove selected devices. You may want to use the range selector on top of the device listbox, when working with a large number of devices.")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->EnableAplhabet(true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Device name")." / "._("Department"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); - - /* Add SubSearch checkbox */ - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Display devices matching"),"*" , true); - } - - - /* Create list header, with create / copy & paste etc*/ - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments($this->module); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get acls */ - $ui = get_userinfo(); - $acl = $ui->get_permissions("cn=dummy,ou=devices,".$this->selectedBase,"devices/deviceGeneric"); - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"devices") ; - - - /* If this is true we add an additional seperator. Just look a few lines below */ - $listhead = MultiSelectWindow::get_default_header(); - - /* And at least add a department selection box */ - $listhead .= _("Base")." ". - "  "; - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("Device")."|device_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - - $this->SetListHeader($listhead); - } - - - /* Some basic settings */ - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - - function setEntries($list) - { - /******************** - Variable init - ********************/ - - /* Create links */ - $linkopen = "%s"; - $editlink = "%s"; - $userimg = "User"; - $deviceimg = "A"; - $empty = ""; - - /* set Page header */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /******************** - Attach objects - ********************/ - - foreach($list as $key => $val){ - - $ui = get_userinfo(); - $acl = $ui->get_permissions($val['dn'],"devices/deviceGeneric"); - $acl_all = $ui->has_complete_category_acls($val['dn'],"devices") ; - - /* Create action icons */ - $actions = ""; - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions .= $this->GetSnapShotActions($val['dn']); - } - - /* Get copy Paste icons */ - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions.= " "; - $actions.= " "; - } - - $actions.= ""; - - /* Add delete button */ - if(preg_match("/d/",$acl)){ - $actions.= ""; - }else{ - $actions.= " "; - } - - $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; - - if(!isset($val['description'][0])){ - $desc = ""; - }else{ - $desc = " - [ ".$val['description'][0]." ]"; - } - - /* Cutted objects should be displayed in light grey */ - $display = $val['cn'][0].$desc; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => sprintf($deviceimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); - $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field0,$field1,$field2,$field3)); - } - - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_objs = count($list); - - $num_obj_str = _("Number of listed devices"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_obj_str." ".$num_objs."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - } - - function Save() - { - MultiSelectWindow::Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/devices/deviceGeneric.tpl b/plugins/admin/devices/deviceGeneric.tpl deleted file mode 100644 index 59f7b9c18..000000000 --- a/plugins/admin/devices/deviceGeneric.tpl +++ /dev/null @@ -1,66 +0,0 @@ - -

{t}Devices{/t}

- - - - -
- - - - - - - - - - - - - -
- - -
{$must} - - -
- - -
-
- - - - - - - - - - - - - - -
{$must} - - -  
{$must} - - -
{$must} - - -
-
- - - - diff --git a/plugins/admin/devices/main.inc b/plugins/admin/devices/main.inc deleted file mode 100755 index 92f901dd3..000000000 --- a/plugins/admin/devices/main.inc +++ /dev/null @@ -1,57 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('DeviceManagement'); - } -} else { - - /* Create DeviceManagement object on demand */ - if (!isset($_SESSION['DeviceManagement']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['DeviceManagement']= new deviceManagement ($config); - } - - /* Get object */ - $DeviceManagement= $_SESSION['DeviceManagement']; - $DeviceManagement->save_object(); - $output= $DeviceManagement->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/devices.png'), _("Device management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/devices.png'), _("Device management")); - } - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('DeviceManagement'); - } - - /* Show and save dialog */ - $display.= $output; - $_SESSION['DeviceManagement']= $DeviceManagement; -} -?> diff --git a/plugins/admin/devices/paste_deviceGeneric.tpl b/plugins/admin/devices/paste_deviceGeneric.tpl deleted file mode 100644 index 44d688246..000000000 --- a/plugins/admin/devices/paste_deviceGeneric.tpl +++ /dev/null @@ -1,25 +0,0 @@ - -

{t}Devices{/t}

- - - - -
- - - - - -
{$must} - - -
-
- - - - diff --git a/plugins/admin/devices/remove.tpl b/plugins/admin/devices/remove.tpl deleted file mode 100755 index 643056cd3..000000000 --- a/plugins/admin/devices/remove.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$intro} - {t}This may be used by several users/groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

-

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

- diff --git a/plugins/admin/devices/tabs_devices.inc b/plugins/admin/devices/tabs_devices.inc deleted file mode 100755 index 9cb2e9017..000000000 --- a/plugins/admin/devices/tabs_devices.inc +++ /dev/null @@ -1,43 +0,0 @@ -addSpecialTabs(); - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['deviceGeneric']; - $new_dn= "cn=".$baseobject->cn.",ou=devices,".$baseobject->base; - - /* Move group? */ - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->move($this->dn, $new_dn); - $this->by_object['deviceGeneric']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - tabs::save(); - - /* Fix tagging if needed */ - $baseobject->dn= $this->dn; - $baseobject->handle_object_tagging(); - $this->by_object['deviceGeneric'] = $baseobject; - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/askClassName.tpl b/plugins/admin/fai/askClassName.tpl deleted file mode 100644 index 7975e1052..000000000 --- a/plugins/admin/fai/askClassName.tpl +++ /dev/null @@ -1,89 +0,0 @@ -
- {$headline} -
-
-

-{t}Adding a new class to the FAI management, requires a class name. You have to specify a unique class name for unique types of FAI classes, while you can use the same class name for different types of FAI classes. In the laste case, FAI will automatically enclose all these different class types to one unique class name.{/t} -
-
-

-

-
-{t}Please use one of the following methods to choose the name for the new FAI class.{/t} -
-
-

-
- - - - - - -
- - - - - - - - - -
- - -

{t}Enter FAI class name manually{/t}

-
  - {t}Class name{/t}  -
-
-
-
- - - - - - - - - - -
- - -

{t}Choose FAI class name from a list of existing classes{/t}

-
  - {t}Class name{/t}  -
-
-
-
- - -

 

- - - diff --git a/plugins/admin/fai/branch_selector.tpl b/plugins/admin/fai/branch_selector.tpl deleted file mode 100644 index addb5a7a2..000000000 --- a/plugins/admin/fai/branch_selector.tpl +++ /dev/null @@ -1,42 +0,0 @@ -
-
-

[F]{t}Branches{/t}

-
-
- - - - -
- {t}Current release{/t}  - -
- - - - -
- {if $allow_create} - - {t}Create new branch{/t} -
- - {t}Create new locked branch{/t} - {else} - {t}Branch{/t} - {t}Create new branch{/t} -
- {t}Freeze{/t} - {t}Create new locked branch{/t} - {/if} - - {if $selectedBranch != "main" && $allow_remove} -
- - {t}Delete current release{/t} - {/if} -
-
- diff --git a/plugins/admin/fai/class_askClassName.inc b/plugins/admin/fai/class_askClassName.inc deleted file mode 100644 index 4225869cc..000000000 --- a/plugins/admin/fai/class_askClassName.inc +++ /dev/null @@ -1,172 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array("whatever"); - - var $objectClass = false; - var $forbidden = array(); - var $ClassName = ""; - var $ClassAlreadyExists = false; - - function askClassName (&$config,$dn,$ui,$objectClass) - { - $this->ui = $ui; - $this->objectClass = $objectClass; - plugin::plugin ($config, $dn); - if(!isset($_SESSION['CurrentMainBase'])){ - $_SESSION['CurrentMainBase'] = $this->config->current['BASE']; - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $display= ""; - - /* The faifilter contais - * The base for all fai objects - */ - $faifilter = $_SESSION['faifilter']; - - /* First search for every ou, in given fai base - * With a second search detect all object that belong to the different ous. - */ - - $base = "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - if($faifilter['branch'] != "main"){ - $base = $faifilter['branch']; - } - $ldap = $this->config->get_ldap_link(); - - $res= get_list("(&(objectClass=organizationalUnit)(!(objectClass=FAIbranch)))", "fai", $base, - array("cn","description","objectClass"), GL_SIZELIMIT ); - - $delete = array(); - $used = array(); - foreach($res as $objecttypes){ - $res2= get_list("(objectClass=*)", "fai", $objecttypes['dn'], - array("cn","description","objectClass","FAIclass","FAIstate"), GL_SIZELIMIT | GL_CONVERT ); - foreach($res2 as $object){ - - /* skip class names with this name */ - if(in_array($this->objectClass,$object['objectClass']) || in_array("FAIprofile",$object['objectClass'])){ - if(isset($object['FAIstate'][0]) && preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - $delete[] = $object['cn'][0]; - } - - /* Skip profiles */ - if(!in_array("FAIprofile",$object['objectClass'])){ - if(isset($object['cn'])){ - $used[$object['cn'][0]]= $object['cn'][0]; - } - } - } - } - - /* Create headline - * Depending on the object type we want to create, a different headline will be shown - */ - switch($this->objectClass) { - case "FAIpartitionTable": $str =_("Create new FAI object - partition table.");break; - case "FAIpackageList" : $str =_("Create new FAI object - package bundle.");break; - case "FAIscript" : $str =_("Create new FAI object - script bundle.");break; - case "FAIvariable" : $str =_("Create new FAI object - variable bundle.");break; - case "FAIhook" : $str =_("Create new FAI object - hook bundle.");break; - case "FAIprofile" : $str =_("Create new FAI object - profile.");break; - case "FAItemplate" : $str =_("Create new FAI object - template.");break; - default : $str =_("Create new FAI object");break; - } - $smarty->assign("headline",$str); - - /* Save forbidden class names - */ - $this->forbidden = $delete; - - /* Delete all class names which already have this type of object - */ - foreach($delete as $del){ - unset($used[$del]); - } - - /* if there is no class name which is missing for this type - * of objectClass, we only can create a new one, disable selectBox - */ - if(count ($used)==0){ - $smarty->assign("ClassNamesAvailable", " disabled "); - $smarty->assign("grey", 'style="color:#C0C0C0"'); - }else{ - $smarty->assign("ClassNamesAvailable", ""); - $smarty->assign("grey", ""); - } - ksort($used); - $smarty->assign("ClassNames", $used); - $smarty->assign("ClassName", $this->ClassName); - $display.= $smarty->fetch(get_template_path('askClassName.tpl', TRUE)); - return($display); - } - - /* Get posts and set class name - */ - function save_object() - { - if(isset($_POST['classSelector']) && $_POST['classSelector'] == 1 - && isset($_POST['edit_continue'])){ - $this->ClassName = $_POST['UseTextInputName']; - $this->ClassAlreadyExists = true; - } - - if(isset($_POST['classSelector']) && $_POST['classSelector'] == 2 - && isset($_POST['edit_continue'])){ - $this->ClassAlreadyExists = false; - $this->ClassName = $_POST['SelectedClass']; - } - } - - /* Check given class name - */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if($this->ClassName != preg_replace("/ /","",trim($this->ClassName))){ - $message[] = _("Spaces are not allowed within class names."); - } - - if(empty($this->ClassName)){ - $message[]=_("The given class name is empty."); - } - - if(in_array($this->ClassName,$this->forbidden)){ - $message[]=_("The specified class name is already in use for this object type."); - } - - return ($message); - } - - - /* Return the class name */ - function save() - { - return($this->ClassName); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_divListFai.inc b/plugins/admin/fai/class_divListFai.inc deleted file mode 100644 index b15485c82..000000000 --- a/plugins/admin/fai/class_divListFai.inc +++ /dev/null @@ -1,419 +0,0 @@ -parent = $parent; - $this->ui = get_userinfo(); - - /* Set default base */ - if(!isset($_SESSION['CurrentMainBase'])){ - $_SESSION['CurrentMainBase'] = $this->config->current['BASE']; - } - $this->selectedBase = $_SESSION['CurrentMainBase']; - - /* Set list strings */ - $this->SetTitle(_("List of FAI classes")); - $this->SetSummary(_("This table displays all FAI classes in the selected tree.")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to create, delete and edit FAI classes.")); - - $this->EnableAplhabet (true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 80; -# if($this->parent->snapshotEnabled()){ -# $action_col_size += 32; -# } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Name of FAI class"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Class type"), "attach" => "style='width:200px;'")); - $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); - - $this->AddCheckBox("ShowProfiles" , _("Display FAI profile objects") ,_("Show profiles") ,true); - $this->AddCheckBox("ShowTemplates" , _("Display FAI template objects") ,_("Show templates") ,true); - $this->AddCheckBox("ShowScripts" , _("Display FAI scripts") ,_("Show scripts") ,true); - $this->AddCheckBox("ShowHooks" , _("Display FAI hooks") ,_("Show hooks") ,true); - $this->AddCheckBox("ShowVariables" , _("Display FAI variables") ,_("Show variables") ,true); - $this->AddCheckBox("ShowPackages" , _("Display FAI packages") ,_("Show packages") ,true); - $this->AddCheckBox("ShowPartitions" , _("Display FAI partitions") ,_("Show partitions") ,true); - - /* Add SubSearch checkbox */ - //$this->AddCheckBox(SEPERATOR); - //$this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Display users matching"),"*" , true); - } - - function AddUserBoxToFilter($position) - { - $str = ""; - if($position == 2){ - - /* Check if there are post commands available for fai management. - * If not, grey out freeze/branch and release remove buttons. - */ - $r = $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs')); - $c = $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs')); - - $smarty = get_smarty(); - $smarty->assign("allow_create", $c); - $smarty->assign("allow_remove", $r); - $smarty->assign("selectedBranch",$this->selectedBranch); - $smarty->assign("branchimage","images/branch.png"); - $smarty->assign("branches",$this->AvailableBranches); - $plug_id = 0; - if(isset($_GET['plug'])){ - $plug_id = $_GET['plug']; - } - $smarty->assign("plug_id",$plug_id); - $str = $smarty->fetch(get_template_path('branch_selector.tpl', TRUE)); - } - return($str); - } - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("fai"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Add seperator */ - $add_sep = false; - - /* Get complete fai acls, to be able to check if we must show or hide the snapshot abilities */ - $acl_all = $ui->has_complete_category_acls($this->selectedBase,$this->module); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* Add additional seperator */ - if($add_sep){ - $listhead .="  "; - } - - $listhead .= _("Base")." ". - "  "; - - - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - $acl = $ui->get_permissions($this->selectedBase,"fai/faiProfile"); - if(preg_match("/c/",$acl)){ - $s.= "...|". - " "._("Profile")."|Create_profile|\n"; - } - - /* Append create icons for each fai component */ - $arr = array( - array("images/fai_new_partitionTable.png" , _("Partition table") ,"Create_partition" , _("PT") , "faiPartitionTable"), - array("images/fai_new_script.png" , _("Scripts") ,"Create_script" , _("S") , "faiScript"), - array("images/fai_new_hook.png" , _("Hooks") ,"Create_hook" , _("H") , "faiHook"), - array("images/fai_new_variable.png" , _("Variables") ,"Create_variable" , _("V") , "faiVariable"), - array("images/fai_new_template.png" , _("Templates ") ,"Create_template" , _("I") , "faiTemplate"), - array("images/fai_new_packages.png" , _("Package list") ,"Create_package" , _("PK") , "faiPackage")); - - foreach($arr as $ar){ - $acl = $ui->get_permissions($this->selectedBase,"fai/".$ar[4]); - if(preg_match("/c/",$acl)){ - $s.= "...|". - " ".$ar[1]."|".$ar[2]."|\n"; - } - } - - /* Multiple options */ - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Add copy & paste icons, currently disabled, this ability is not implemeneted yet */ - if(preg_match("/(c.*w|w.*c)/",$acl_all) && isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler){ - $s .= "..|---|\n"; - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - -# /* Add snapshot icons, if we are allowed to write and create the complete fai module ($ui->has_complete_category_acls) */ -# if(preg_match("/(c.*w|w.*c)/",$acl_all)){ -# if($this->parent->snapshotEnabled()){ -# $s .= "..|---|\n"; -# $s .= $this->get_snapshot_header(TRUE); -# } -# } - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - } - - /* so some basic settings */ - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - $this->AvailableBranches = $this->parent->getBranches(); - } - - function setEntries($list) - { - /******************** - Variable init - ********************/ - - $objects = array( - "FAIpartitionTable" => array("IMG"=> "images/fai_partitionTable.png", "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"), - "FAIpackageList" => array("IMG"=> "images/fai_packages.png", "NAME"=>_("Package list") , "KZL"=> "PL", "VAR"=>"ShowPackages"), - "FAIscript" => array("IMG"=> "images/fai_script.png", "NAME"=>_("Scripts") , "KZL"=> "S", "VAR"=>"ShowScripts"), - "FAIvariable" => array("IMG"=> "images/fai_variable.png", "NAME"=>_("Variables") , "KZL"=> "V", "VAR"=>"ShowVariables"), - "FAIhook" => array("IMG"=> "images/fai_hook.png", "NAME"=>_("Hooks"), "KZL"=> "H", "VAR"=>"ShowHooks"), - "FAIprofile" => array("IMG"=> "images/fai_profile.png", "NAME"=>_("Profile") , "KZL"=> "P", "VAR"=>"ShowProfiles"), - "FAItemplate" => array("IMG"=> "images/fai_template.png", "NAME"=>_("Templates") , "KZL"=> "T", "VAR"=>"ShowTemplates")); - - $editlink ="%NAME%"; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 80; -# if($this->parent->snapshotEnabled()){ -# $action_col_size += 32; -# } - - /******************** - Attach objects - ********************/ - - $cnts = array(); - foreach($objects as $key => $data){ - $cnts[$key] = 0; - } - - foreach($list as $key => $value){ - $info = ""; - $img = ""; - $type = $value['type']; - $abort =false; - - $cnts[$type] ++; - - if(isset($objects[$type])){ - $img = "".$objects[$type]["; - $info = $objects[$type]['NAME']; - $var = $objects[$type]['VAR']; - }else{ - $img = ""; - $info = ""; - $var = ""; - } - - if((isset($value['description']))&&(!empty($value['description']))){ - $desc= " [".$value['description']."]"; - }else{ - $desc= ""; - } - - /* Add copy & cut icons */ - $ui = get_userinfo(); - $action =""; - $acl_all = $ui->has_complete_category_acls($this->selectedBase,$this->module); - if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){ - $action .= " "; - $action.= " "; - } - - if($value['FAIstate'] == "freeze"){ - $action.= "F"; - $action.= ""; - }else{ - $action.= ""; - -# if(preg_match("/(c)/",$value['acl']) && preg_match("/(w)/",$value['acl'])){ -# $action.= $this->GetSnapShotActions($value['dn']);; -# } - - if(preg_match("/d/",$value['acl'])){ - $action.= ""; - } - } - - /* Cutted objects should be displayed in light grey */ - $display = $value['cn'].$desc; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $value['dn']) { - $display = "".$display.""; - break; - } - } - } - $edi = $editlink; - $acti = $action; - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/","/%TITLE%/"),array($key,$display,preg_replace('/ /', ' ', @LDAP::fix($value['dn']))),$edi) , "attach" => "style=''"); - $field3 = array("string" => $info, "attach" => "style='width:200px;'"); - $field4 = array("string" => preg_replace("/%KEY%/",$key,$acti) , "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); - } - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - - $profile_str = _("Number of listed profiles"); - $partition_str = _("Number of listed partitions"); - $script_str = _("Number of listed scripts"); - $hook_str = _("Number of listed hooks"); - $variable_str = _("Number of listed variables"); - $template_str = _("Number of listed templates"); - $package_str = _("Number of listed packages"); - $dep_str = _("Number of listed departments"); - - $str = "".$profile_str." ".$cnts['FAIprofile']."    "; - $str.= "".$partition_str." ".$cnts['FAIpartitionTable']."    "; - $str.= "".$script_str." ".$cnts['FAIscript']."    "; - $str.= "".$hook_str." ".$cnts['FAIhook']."    "; - $str.= "".$variable_str." ".$cnts['FAIvariable']."    "; - $str.= "".$template_str." ".$cnts['FAItemplate']."    "; - $str.= "".$package_str." ".$cnts['FAIpackageList']."    "; - $str.= "".$dep_str." ".$num_deps."    "; - $this->set_List_Bottom_Info($str); - } - - function Save() - { - MultiSelectWindow::Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - $_SESSION['faifilter']['branch'] = $this->selectedBranch; - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiHook.inc b/plugins/admin/fai/class_faiHook.inc deleted file mode 100644 index ce60202a3..000000000 --- a/plugins/admin/fai/class_faiHook.inc +++ /dev/null @@ -1,608 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIhook"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAIhookEntry"; - var $subClasses = array("top","FAIclass","FAIhookEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = "faiHookEntry"; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAItask"); - var $sub_Load_Later = array("FAIscript"); - var $sub64coded = array(); - var $subBinary = array("FAIscript"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $SubObjects = array(); // All leafobjects of this object - var $view_logged = FALSE; - var $FAIstate = ""; - var $ui; - - function faiHook (&$config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - */ - if($dn != "new"){ - $this->dn =$dn; - - /* Get FAIstate - */ - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))", $attrs_to_search); - - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - $objects = array(); - $objects['status'] = "FreshLoaded"; - $objects['dn'] = $object['dn']; - $objects = $this->get_object_attributes($objects,$this->subAttributes); - $this->SubObjects[$objects['cn']] = $objects; - } - } - $this->ui = get_userinfo(); - } - - - /* Reload some attributes */ - function get_object_attributes($object,$attributes) - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($object['dn'],$attributes); - $tmp = $ldap->fetch(); - - foreach($attributes as $attrs){ - if(isset($tmp[$attrs][0])){ - $var = $tmp[$attrs][0]; - - /* Check if we must decode some attributes */ - if(in_array_ics($attrs,$this->sub64coded)){ - $var = base64_decode($var); - } - - /* check if this is a binary entry */ - if(in_array_ics($attrs,$this->subBinary)){ - $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0); - } - - /* Fix slashes */ - $var = addslashes($var); - $object[$attrs] = $var; - } - } - return($object); - } - - - function acl_base_for_current_object($dn) - { - if($dn == "new"){ - if($this->dn == "new"){ - $dn= $_SESSION['CurrentMainBase']; - }else{ - $dn = $this->dn; - } - } - return($dn); - } - - - function getUsedFAItask($cn) - { - $ret = array(); - foreach($this->SubObjects as $name => $class){ - if($class['cn'] == $cn){ - continue; - } - if($class['status'] != "delete"){ - $ret[$class['FAItask']] = $class['FAItask']; - } - } - return($ret); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","fai/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* New Listhandling - */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^editscript_/",$name)&&($once)){ - $once = false; - $entry = preg_replace("/^editscript_/","",$name); - $entry = base64_decode(preg_replace("/_.*/","",$entry)); - - $obj = $this->SubObjects[$entry]; - if($obj['status'] == "FreshLoaded"){ - $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); - } - - $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); - $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn'])); - $this->dialog->set_acl_category("fai"); - - $_SESSION['objectinfo'] = $obj['dn']; - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - if(preg_match("/^deletescript_/",$name)&&($once)){ - $entry = preg_replace("/^deletescript_/","",$name); - $entry = base64_decode(preg_replace("/_.*/","",$entry)); - - $dn = $this->acl_base_for_current_object($this->SubObjects[$entry]['dn']); - $acl = $this->ui -> get_permissions($dn,"fai/faiScriptEntry") ; - - if(preg_match("/d/",$acl)){ - $once = false; - - $status = $this->SubObjects[$entry]['status']; - if($status == "edited" || $status == "FreshLoaded"){ - $this->SubObjects[$entry]['status']= "delete"; - }else{ - unset($this->SubObjects[$entry]); - } - } - } - } - - /* Edit entries via GET */ - if(isset($_GET['act']) && isset($_GET['id'])){ - if($_GET['act'] == "edit" && isset($this->SubObjects[$_GET['id']])){ - $obj = $this->SubObjects[$_GET['id']]; - if($obj['status'] == "FreshLoaded"){ - $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); - } - $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); - $this->dialog->acl = $this->acl; - $_SESSION['objectinfo'] = $obj['dn']; - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - } - - ///// Ende new list handling - - /* Add new sub object */ - if(isset($_POST['AddSubObject'])){ - - $c_dn = $this->acl_base_for_current_object($this->dn); - $this->dialog= new $this->subClassName($this->config,"new"); - $this->dialog->set_acl_base($c_dn); - $this->dialog->set_acl_category("fai"); - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - - - /* Save Dialog */ - if(isset($_POST['SaveSubObject'])){ - - /* Perform post check*/ - $this->dialog->save_object(); - - /* Get messages */ - $msgs = $this->dialog->check(); - - /* print errors */ - if(count($msgs)>0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - - /* Get return object */ - $obj = $this->dialog->save(); - if(isset($obj['remove'])){ - - $old_stat = $this->SubObjects[$obj['remove']['from']]['status']; - - /* Depending on status, set new status */ - if($old_stat == "edited" || $old_stat == "FreshLoaded"){ - $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ - unset($this->SubObjects[$obj['remove']['from']]); - } - $obj['status'] = "new"; - $this->SubObjects[$obj['remove']['to']] = $obj; - unset($this->SubObjects[$obj['remove']['to']]['remove']); - }else{ - if($obj['status'] == "FreshLoaded"){ - $obj['status'] = "edited"; - } - $this->SubObjects[$obj['cn']]=$obj; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - } - - /* Sort entries */ - $tmp = $keys = array(); - foreach($this->SubObjects as $key => $entry){ - $keys[$key]=$key; - } - natcasesort($keys); - foreach($keys as $key){ - $tmp[$key]=$this->SubObjects[$key]; - } - $this->SubObjects = $tmp; - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - - /* Print dialog if $this->dialog is set */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return($display); - } - - - - /* Divlist added 28.02.2006 - Containing FAIscripts - */ - - $divlist = new divSelectBox("FAIhooks"); - $divlist->setHeight(400); - - foreach($this->getList(true) as $key => $name){ - - $dn= $this->acl_base_for_current_object($name['dn']); - $acl = $this->ui->get_permissions($dn,"fai/faiHookEntry") ; - $act = ""; - - /* Check if this object is freezed, in this case hide the delete icon */ - if($this->FAIstate == "freeze"){ - $act .= ""; - }else{ - $act .= ""; - if(preg_match("/d/",$acl)){ - $act .=""; - } - } - - /* Check if we are allowed to use the export button for this object */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiHookEntry","FAIscript") ; - if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){ - $down = ""; - }else{ - $down = " - "._("Download")." - "; - } - - /* Check if we are allowed to view the object */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiHookEntry","cn") ; - if(preg_match("/r/",$s_acl)){ - - $edit_link = "".$name['name'].""; - $divlist->AddEntry(array( array("string"=>$edit_link), - array("string"=>$down , "attach" => "style='width:20px;'"), - array("string"=>str_replace("%s",base64_encode($key),$act), - "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); - } - } - $smarty->assign("Entry_divlist",$divlist->DrawList()); - /* Divlist creation complete - */ - - $smarty->assign("SubObjects",$this->getList()); - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - }else{ - $smarty->assign($attrs,($this->$attrs)); - } - } - - $tmp = $this->plInfo(); - - $c_dn = $this->acl_base_for_current_object($this->dn); - $smarty->assign("sub_object_is_addable", preg_match("/c/",$this->ui->get_permissions($c_dn,"fai/faiHookEntry")) && $this->FAIstate!="freeze"); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $display.= $smarty->fetch(get_template_path('faiHook.tpl', TRUE)); - return($display); - } - - /* Generate listbox friendly SubObject list - */ - function getList($use_dns=false){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - if($use_dns){ - if((isset($obj['description']))&&(!empty($obj['description']))){ - $a_return[$obj['cn']]['name']= $obj['cn']." [".stripslashes($obj['description'])."]"; - }else{ - $a_return[$obj['cn']]['name']= $obj['cn']; - } - $a_return[$obj['cn']]['dn']= $obj['dn']; - }else{ - if((isset($obj['description']))&&(!empty($obj['description']))){ - $a_return[$obj['cn']]= $obj['cn']." [".stripslashes($obj['description'])."]"; - }else{ - $a_return[$obj['cn']]= $obj['cn']; - } - } - } - } - return($a_return); - } - - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $this->dn; - } - - prepare_to_save_FAI_object($use_dn,array(),true); - - new log("remove","fai/".get_class($this),$use_dn,$this->attributes); - - foreach($this->SubObjects as $name => $obj){ -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $obj['dn']; - } - prepare_to_save_FAI_object($use_dn,array(),true); - } - $this->handle_post_events("remove"); - } - - - /* Save data to object - */ - function save_object() - { - if((isset($_POST['FAIhook_posted'])) && ($this->FAIstate != "freeze")){ - plugin::save_object(); - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - } - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - prepare_to_save_FAI_object($this->dn,$this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/hook with dn '%s' failed."),$this->dn)); - - if($this->initially_was_account){ - new log("modify","fai/".get_class($this),$this->dn,$this->attributes); - }else{ - new log("create","fai/".get_class($this),$this->dn,$this->attributes); - } - - /* Do object tagging */ - $this->handle_object_tagging(); - - $ldap->cd($this->dn); - - /* Prepare FAIscriptEntry to write it to ldap - * First sort array. - * Because we must delete old entries first. - * After deletion, we perform add and modify - */ - $Objects = array(); - - /* We do not need to save untouched objects */ - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "FreshLoaded"){ - unset($this->SubObjects[$name]); - } - } - - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - - foreach($Objects as $name => $obj){ - - foreach($this->sub64coded as $codeIt){ - $obj[$codeIt]=base64_encode(stripslashes($obj[$codeIt])); - } - - $tmp = array(); - $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); - foreach($attributes as $attrs){ - if(empty($obj[$attrs])){ - $obj[$attrs] = array(); - } - if(!is_array($obj[$attrs])){ - $tmp[$attrs] = stripslashes($obj[$attrs]); - }else{ - $tmp[$attrs] = $obj[$attrs]; - } - } - - $tmp['objectClass'] = $this->subClasses; - - $sub_dn = "cn=".$obj['cn'].",".$this->dn; - - if($obj['status']=="new"){ - $ldap->cat($sub_dn,array("objectClass")); - if($ldap->count()){ - $obj['status']="edited"; - } - } - - /* Check if gosaAdministrativeUnitTag is required as object class */ - if($obj['status'] == "edited"){ - $ldap->cat($sub_dn,array("objectClass")); - $attrs = $ldap->fetch(); - if(isset($attrs['objectClass'])){ - if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ - $tmp['objectClass'][] = "gosaAdministrativeUnitTag"; - } - } - } - - if($obj['status'] == "delete"){ - prepare_to_save_FAI_object($sub_dn,array(),true); - $this->handle_post_events("remove"); - }elseif($obj['status'] == "edited"){ - prepare_to_save_FAI_object($sub_dn,$tmp); - $this->handle_post_events("modify"); - }elseif($obj['status']=="new"){ - prepare_to_save_FAI_object($sub_dn,$tmp); - $this->handle_post_events("add"); - } - $this->handle_object_tagging($sub_dn, $this->gosaUnitTag); - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - $objects = array(); - $objects['status'] = "edited"; - $objects['dn'] = $object['dn']; - $objects = $this->get_object_attributes($objects,$this->subAttributes); - $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); - - $this->SubObjects[$objects['cn']] = $objects; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Hook"), - "plDescription" => _("FAI hook"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 20, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name")." ("._("Read only").")", - "description" => _("Description")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiHookEntry.inc b/plugins/admin/fai/class_faiHookEntry.inc deleted file mode 100644 index 84b326e71..000000000 --- a/plugins/admin/fai/class_faiHookEntry.inc +++ /dev/null @@ -1,206 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("cn","description","FAIscript","FAItask"); - var $objectclasses= array(); - - var $orig_cn = ""; - var $tasks = array("chboot", "configure", "debconf", "extrbase", "faiend", "finish", - "install", "instsoft", "mirror", "mountdisks", "partition", "prepareapt", - "savelog", "softupdate", "sysinfo","updatebase"); - var $dn = ""; - var $cn = ""; - var $FAItask = "chboot"; - var $FAIscript = ""; - var $description = ""; - var $status = "new"; - var $parent = NULL; - var $FAIstate = ""; - - function faiHookEntry (&$config, $dn= NULL,$object=false) - { - plugin::plugin ($config, $dn); - if($dn != "new"){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = $name; - $this->$oname=$value; - } - - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - }elseif(is_array($object)){ - if(count($object)){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = $name; - $this->$oname=$value; - } - }else{ - - $this->status = "new"; - $this->orig_cn = false; - } - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - if(isset($_POST['ImportUpload'])){ - if(($_FILES['ImportFile']['error']!=0)){ - print_red(_("Please select a valid file.")); - }else - if(($_FILES['ImportFile']['size']==0)){ - print_red(_("Selected file is empty.")); - }else{ - $str = utf8_encode(file_get_contents($_FILES['ImportFile']['tmp_name'])); - $this->FAIscript = $str; - } - } - - /* Create download button*/ - if($this->dn != "new" && $this->acl_is_readable("FAIscript")){ - $smarty->assign("DownMe"," - "._("Download")." - "); - }else{ - $smarty->assign("DownMe",""); - } - - $used_tasks = $this->parent->getUsedFAItask($this->cn); - $tasks = $this->tasks; - foreach($this->tasks as $id => $task){ - if(in_array($task,$used_tasks)){ - unset($tasks[$id]); - } - } - $smarty->assign("tasks", $tasks); - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,(stripslashes($this->$attrs))); - }else{ - $smarty->assign($attrs,($this->$attrs)); - } - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $acl = $this->getacl($name); - if($this->FAIstate == "freezed"){ - $acl = preg_replace("/w/","",$acl); - } - $smarty->assign($name."ACL",$acl); - } - - if(get_magic_quotes_gpc()){ - $smarty->assign("FAIscript" , htmlentities(stripslashes($this->FAIscript))); - }else{ - $smarty->assign("FAIscript" , htmlentities($this->FAIscript)); - } - $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ - foreach($this->attributes as $attrs){ - if($this->acl_is_writeable($attrs)){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - }else{ - $this->$attrs = ""; - } - } - } - } - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ - $message[] =_("There is already a hook with the given name."); - } - - if(empty($this->FAIscript)) { - $message[]=_("Please enter a value for script."); - } - - if(empty($this->cn)){ - $message[] = _("Please enter a name."); - } - - return ($message); - } - - function save() - { - $tmp=array(); - foreach($this->attributes as $attrs){ - $tmp[$attrs] = $this->$attrs; - } - - /* Strip out dos newlines */ - $tmp['FAIscript']= strtr($this->FAIscript, array("\x0D" => "")); - - if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ - $tmp['remove']['from'] = $this->orig_cn; - $tmp['remove']['to'] = $tmp['cn']; - } - - $tmp['dn'] = $this->dn; - $tmp['status'] = $this->status; - return($tmp); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Hook entry"), - "plDescription" => _("FAI hook entry"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 21, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name"), - "description" => _("Description"), - "FAItask" => _("Task"), - "FAIscript" => _("FAI script")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc deleted file mode 100644 index b9c027110..000000000 --- a/plugins/admin/fai/class_faiManagement.inc +++ /dev/null @@ -1,1156 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Headpage attributes */ - var $lock_type = ""; // should be branch/freeze - var $lock_name = ""; - var $lock_dn = ""; - - /* attribute list for save action */ - var $attributes = array("lock_type","lock_name","lock_dn"); // Attributes Managed by this plugin - var $objectclasses= array(); // ObjectClasses which the attributes are related to - var $dialog = array(); // This object contains every dialog we have currently opened - - var $objects = array(); // This array contains all available objects shown in divlist - var $is_dialog = false; - - var $dispNewBranch= false; - var $dispNewFreeze= false; - - var $DivListFai; - var $start_pasting_copied_objects = FALSE; - var $CopyPasteHandler = FALSE; - var $base = ""; - - /* construction/reconstruction - */ - function faiManagement (&$config, $ui) - { - /* Set defaults */ - $this->dn = ""; - $this->config = $config; - $this->ui = $ui; - - /* Creat dialog object */ - $this->DivListFai = new divListFai($this->config,$this); - - /* Copy & Paste handler */ - if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){ - $this->CopyPasteHandler= new CopyPasteHandler($this->config); - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Initialise vars and smarty */ - $smarty = get_smarty(); - $smarty->assign("BranchName",""); - - $display = ""; - $s_action = ""; - $s_entry = ""; - - /* If an entry was locked, these vars will be stored in a session to allow direct edit */ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit_entry$/","/^id$/","/^entry_edit_/","/^entry_delete_/","/^item_selected/","/^remove_multiple_fai_objects/"); - - - /**************** - Handle posts - ****************/ - - /* Check ImageButton posts - * Create new tab ich new_xx is posted - */ - $posts = array( "/remove_branch/"=>"remove_branch", "/branch_branch/"=>"branch_branch", - "/freeze_branch/"=>"freeze_branch", "/create_partition/i"=>"new_partition", - "/create_script/i"=>"new_script", "/create_hook/i"=>"new_hook", - "/create_variable/i"=>"new_variable", "/create_template/i"=>"new_template", - "/create_package/i"=>"new_package", "/create_profile/i"=>"new_profile", - "/edit_continue/"=>"select_class_name_finished", - "/^multiple_copy_fai/" => "copy_multiple", - "/^multiple_cut_fai/" => "cut_multiple", - "/^copy/" => "copy", - "/^cut/" => "cut", - "/^remove_multiple_fai_objects/" => "del_multiple"); - - foreach($_POST as $name => $value){ - foreach($posts as $reg => $act ){ - if(preg_match($reg,$name)){ - $s_action = $act; - $s_entry = ltrim(preg_replace($reg,"",$name),"_"); - $s_entry = preg_replace("/_.*$/","",$s_entry); - } - } - if(preg_match("/^entry_edit_.*/",$name)){ - $s_entry = preg_replace("/^entry_edit_/","",$name); - $s_entry = preg_replace("/_.*$/","",$s_entry); - $s_action = "edit"; - }elseif(preg_match("/^entry_delete_.*/",$name)){ - $s_entry = preg_replace("/^entry_delete_/","",$name); - $s_entry = preg_replace("/_.*$/","",$s_entry); - $s_action = "delete"; - } - } - - if(isset($_GET['edit_entry'])){ - $s_entry = $_GET['edit_entry']; - $s_action = "edit"; - } - - if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){ - $s_action = "freeze_branch"; - } - if(isset($_GET['act']) && $_GET['act'] == "branch_branch"){ - $s_action = "branch_branch"; - } - if(isset($_GET['act']) && $_GET['act'] == "remove_branch"){ - $s_action = "remove_branch"; - } - - if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){ - $this->dispNewBranch = false; - $this->dispNewFreeze = false; - } - - - $type_acl_mapping = array( - "FAIpartitionTable" => "faiPartitionTable", - "FAIpackageList" => "faiPackage", - "FAIscript" => "faiScript", - "FAIvariable" => "faiVariable", - "FAIhook" => "faiHook", - "FAIprofile" => "faiProfile", - "FAItemplate" => "faiTemplate"); - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){ - $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);; - $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']); - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - /******************** - Copy & Paste - ********************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /**************** - Delete confirme dialog - ****************/ - - if ($s_action=="delete"){ - - /* Get 'dn' from posted termlinst */ - $this->dn= $this->objects[$s_entry]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $acl = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]); - if(preg_match("/d/",$acl)){ - - /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), @LDAP::fix($this->dn))); - $smarty->assign("multiple", false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this component!")); - } - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $this->dns = array(); - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->objects[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("warning", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("warning", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); - } - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_fai_object_confirm'])){ - - /* Find out more about the object type */ - $ldap = $this->config->get_ldap_link(); - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - $ldap->cat($dn, array('objectClass')); - $attrs = $ldap->fetch(); - $type = $this->get_type($attrs); - - $acl = $this->ui->get_permissions($dn,"fai/".$type[1]); - if(preg_match("/d/",$acl)){ - - $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai"); - $this->dialog->set_acl_base($dn); - $this->dialog->by_object[$type[1]]->remove_from_parent (); - unset ($this->dialog); - $this->dialog= FALSE; - $to_del = clean_up_releases($dn); - save_release_changes_now(); - - foreach($to_del as $dn){ - $ldap->rmdir_recursive($dn); - } - - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this component!")); - new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_fai_object_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /**************** - Delete aborted - ****************/ - - /* Delete canceled? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - } - - - /**************** - Delete confirmed - ****************/ - - /* Deltetion was confirmed, so delete this entry - */ - if (isset($_POST['delete_terminal_confirm'])){ - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - - /* Find out more about the object type */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('objectClass')); - if($ldap->count()){ - $attrs = $ldap->fetch(); - $type = $this->get_type($attrs); - - $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]); - if(preg_match("/d/",$acl)){ - - $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai"); - $this->dialog->set_acl_base($this->dn); - $this->dialog->by_object[$type[1]]->remove_from_parent (); - unset ($this->dialog); - $this->dialog= FALSE; - $to_del = clean_up_releases($this->dn); - save_release_changes_now(); - - foreach($to_del as $dn){ - $ldap->rmdir_recursive($dn); - } - - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this component!")); - new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - - }else{ - print_red(sprintf(_("Object could not be deleted '%s', object does not exist."),$this->dn)); - } - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - - /**************** - Edit entry - ****************/ - - if(($s_action == "edit") && (!isset($this->dialog->config))){ - $entry = $this->objects[$s_entry]; - $a_setup = $this->get_type($entry); - $this->dn = $entry['dn']; - - /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - add_lock ($this->dn, $this->ui->dn); - - $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai"); - $this->dialog->set_acl_base($this->dn); - $this->is_dialog = true; - - if($entry['FAIstate'] == "freeze"){ - #$this->dialog->set_acl(array("*none*")) ; - echo "Dawn it is freezed."; - } - $_SESSION['objectinfo'] = $this->dn; - } - - - /* Branch handling - 09.01.2006 - */ - - /**************** - Remove branch - ****************/ - - /* Remove branch - */ - if($s_action == "remove_branch"){ - $base= $this->DivListFai->selectedBranch; - - /* Check if we have a post remove method configured - * else skip this operation. (Skip:Button in the ui should be disabled in this case too) - */ - if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){ - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - if($this->acl_is_removeable()){ - - $smarty->assign("info", sprintf(_("You're about to delete a fai branch / freeze '%s'."), $this->DivListFai->selectedBranch)); - return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE))); - } else { - print_red (_("You are not allowed to delete this release!")); - } - } - } - - - /**************** - Remove branch confirmed - ****************/ - - if(isset($_POST['delete_branch_confirm'])){ - - /* Check if we have a post remove method configured - * else skip this operation. (Skip:Button in the ui should be disabled in this case too) - */ - if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){ - - $bb = $this->DivListFai->selectedBranch; - if(!isset($ldap)){ - $ldap = $this->config->get_ldap_link(); - } - - $br = $this->getBranches(); - - if(isset($br[$bb]) && $this->acl_is_removeable()){ - $name = $br[$bb]; - $ldap->cd($bb); - $ldap->recursive_remove(); - $ldap->cd(preg_replace('/,ou=fai,ou=configs,ou=systems,/', ',ou=apps,', $bb)); - $ldap->recursive_remove(); - $this->DivListFai->selectedBranch = "main"; - - /* Post remove */ - $this->lock_name = $name; - $this->lock_dn = $bb; - $this->postremove(); - - new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed"); - } - } - } - - - /**************** - Create a new branch "insert Name" - ****************/ - - if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){ - $_SESSION['LASTPOST'] = $_POST; - - if($this->dispNewBranch){ - $type = "branch"; - }else{ - $type = "freeze"; - } - - /* Check branch name */ - $name = $_POST['BranchName']; - $is_ok = true; - $smarty->assign("BranchName",$name); - $base= "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; - - /* Check used characters */ - if(preg_match("/[^0-9a-z \ö\ä\ü\.-_:,]/i",$name)){ - if($type == "branch"){ - print_red(_("Specified branch name is invalid.")); - }else{ - print_red(_("Specified freeze name is invalid.")); - } - $is_ok = false; - } - - /* Check if this name is already in use */ - if(!$this->CheckNewBranchName($_POST['BranchName'],$this->DivListFai->selectedBranch)){ - print_red(_("This name is already in use.")); - $is_ok = false; - } - - if($is_ok){ - $_SESSION['LASTPOST']['base'] = $base; - $_SESSION['LASTPOST']['type'] = $type; - $smarty->assign("iframe", true); - $smarty->assign("plugID", $_GET['plug']); - $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__))); - return($display); - } - } - - - /**************** - Create a new branch - ****************/ - - if(isset($_GET['PerformBranch'])){ - - if(!$this->acl_is_createable()){ - print_red(_("You are not allowed to create a new branch.")); - }else{ - - /* Create it know */ - $this->dispNewBranch = false; - $this->dispNewFreeze = false; - $base = $_SESSION['LASTPOST']['base']; - $_POST = $_SESSION['LASTPOST']; - $name = $_POST['BranchName']; - - $type = $_SESSION['LASTPOST']['type']; - $ldap = $this->config->get_ldap_link(); - - $baseToUse = $base; - if($this->DivListFai->selectedBranch != "main" ){ - $baseToUse = $this->DivListFai->selectedBranch; - } - - /* Create new Release name to be able to set faidebianRelease for FAIpackageList */ - - $CurrentReleases = $this->getBranches(); - $NewReleaseName = $name; - if(isset($CurrentReleases[$this->DivListFai->selectedBranch])) { - if($this->DivListFai->selectedBranch != "main"){ - $NewReleaseName = $CurrentReleases[$this->DivListFai->selectedBranch]."/".$name; - $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName); - }else{ - $NewReleaseName = $name; - } - } - - $appsrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,",$baseToUse); - $appdst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,","ou=".$name.",".$baseToUse) ; - - $mimesrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=mime,",$baseToUse); - $mimedst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=mime,","ou=".$name.",".$baseToUse) ; - - /* Check if source depeartments exist */ - foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){ - $ldap->cd($this->config->current['BASE']); - $ldap->cat($dep); - if(!$ldap->count()){ - $ldap->create_missing_trees($dep); - } - } - - /* Print header to have styles included */ - echo ' - - - - - - - - '; - - new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created"); - - /* Duplicate applications - */ - $ldap->cat($appsrc,array("dn")) ; - if($ldap->count()){ - $ldap->cd ($appdst); - $ldap->recursive_remove(); - $ldap->cd ($this->config->current['BASE']); - $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true); - } - - /* Duplicate mime types - */ - $ldap->cat($mimesrc,array("dn")) ; - if($ldap->count()){ - $ldap->cd ($mimedst); - $ldap->recursive_remove(); - $ldap->cd ($this->config->current['BASE']); - $ldap->copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true); - } - - $attr = array(); - $attr['objectClass'] = array("organizationalUnit","FAIbranch"); - $attr['ou'] = $name; - $attr['FAIstate'] = $type; - $ldap->cd($this->config->current['BASE']); - $ldap->cd("ou=".$name.",".$baseToUse); - $ldap->cat("ou=".$name.",".$baseToUse); - if($ldap->count()){ - $ldap->modify($attr); - }else{ - $ldap->add($attr); - } - - /* Duplicate fai objects - */ - // $ldap->cd ("ou=".$name.",".$baseToUse); - // $ldap->recursive_remove(); - // $ldap->cd ($this->config->current['BASE']); - // $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true); - - echo "
-
-
"; - - echo "" ; - - /* Print footer to have valid html */ - echo ""; - - $this->dispNewFreeze = false; - - /* Postcreate */ - - /* Assign possible attributes */ - $this->lock_type = $type; - $this->lock_name = $name; - $this->lock_dn = $baseToUse; - $this->postcreate(); - exit(); - } - } - - /**************** - Display dialog to enter new Branch name - ****************/ - - /* Check if we have a post create method configured - * else skip this operation. (Skip:Button in the ui should be disabled in this case too) - */ - if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){ - if(($s_action == "branch_branch")||($this->dispNewBranch)){ - if(!$this->acl_is_createable()){ - print_red(_("You are not allowed to create a new branch.")); - }else{ - $this->dispNewBranch=true; - $smarty->assign("iframe",false); - $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__))); - return($display); - } - } - } - - - /**************** - Display dialog to enter new Freeze name - ****************/ - - /* Check if we have a post create method configured - * else skip this operation. (Skip:Button in the ui should be disabled in this case too) - */ - if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){ - if(($s_action == "freeze_branch")||($this->dispNewFreeze)){ - if(!$this->acl_is_createable()){ - print_red(_("You are not allowed to create a new branch.")); - }else{ - $this->dispNewFreeze = true; - $smarty->assign("iframe",false); - $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__))); - return($display); - } - } - } - - - /**************** - Create a new object - ****************/ - - $types = array( "new_partition" => "FAIpartitionTable", - "new_script" => "FAIscript", - "new_hook" => "FAIhook", - "new_variable" => "FAIvariable", - "new_template" => "FAItemplate", - "new_package" => "FAIpackageList"); - - if(isset($types[$s_action])){ - $acl = $this->ui->get_permissions($this->DivListFai->selectedBase,"fai/".$type_acl_mapping[$types[$s_action]]); - if(preg_match("/c/",$acl)){ - $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]); - }else{ - print_red(sprintf(_("You are not allowed to create a new '%s' object."),$types[$s_action])); - } - } - - /* New Profile */ - if($s_action == "new_profile"){ - $this->dn = "new" ; - - $acl = $this->ui->get_permissions($this->DivListFai->selectedBase,"fai/faiProfile"); - if(preg_match("/c/",$acl)){ - $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile"))); - $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai"); - $this->dialog->set_acl_base($this->base); - - $this->is_dialog = false; - }else{ - print_red(sprintf(_("You are not allowed to create a new '%s' object."),"FAIprofile")); - } - } - - - /**************** - Get from ask class name dialog - ****************/ - - if($s_action == "select_class_name_finished"){ - $this->dialog->save_object(); - if(count($this->dialog->check())!=0){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } - }elseif(isset($this->dialog->objectClass)){ - $this->dn = "new" ; - $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass))); - $name = $this->dialog->save(); - - if(class_exists($a_setup[0])){ - $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai"); - $this->dialog->set_acl_base($this->base); - $this->dialog->by_object[$a_setup[1]]->cn = $name; - $this->is_dialog = true; - } - } - } - - - /**************** - Cancel dialogs - ****************/ - - if(isset($_POST['edit_cancel'])){ - unset($this->dialog); - $this->dialog=FALSE; - $this->is_dialog = false; - unset($_SESSION['objectinfo']); - del_lock ($this->dn); - } - - - /**************** - Save sub dialogs - ****************/ - - /* This check if the given tab could be saved - * If it was possible to save it, remove dialog object. - * If it wasn't possible, show errors and keep dialog. - */ - if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){ - $this->dialog->save_object(); - $msgs= $this->dialog->check(); - if(count($msgs)!=0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $this->dialog->save(); - save_release_changes_now(); - if (!isset($_POST['edit_apply'])){ - del_lock ($this->dn); - unset($this->dialog); - $this->dialog=FALSE; - $this->is_dialog=false; - unset($_SESSION['objectinfo']); - } - } - } - - - /**************** - Display currently open dialog - ****************/ - - /* If dialog is set, but $this->is_dialog==false, then - * only the "abort" button is shown, this are dialogs that must not be saved. - * If is_dialog == true, we are currently editing tab objects. - * Here we need both, save and cancel - */ - - if(is_object($this->dialog)){ - $display .= $this->dialog->execute(); - /* Don't show buttons if tab dialog requests this */ - - if(isset($this->dialog->current)){ - - $obj = $this->dialog->by_object[$this->dialog->current]; - - if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){ - - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - }elseif(!isset($this->dialog->current)){ - $display.= "

\n"; - $display.= " "; - $display.= "\n"; - $display.= "

"; - } - }else{ - $display.= "

\n"; - $display.= " "; - $display.= "\n"; - $display.= "

"; - - } - return($display); - } - - - /**************** - Dialog display - ****************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListFai->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Display dialog with system list */ - $this->DivListFai->parent = $this; - $this->DivListFai->execute(); - $this->DivListFai->AddDepartments($this->DivListFai->selectedBase,4,1); - $this->reload(); - $this->DivListFai->setEntries($this->objects); - return($this->DivListFai->Draw()); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - $tmp = array(); - $types = array("hooks","scripts","disk","packages","profiles","templates","variables"); - foreach($types as $type){ - if($this->DivListFai->selectedBranch == "main"){ - $tmp[] = "ou=".$type.",ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; - }else{ - $tmp[] = "ou=".$type.",".$this->DivListFai->selectedBranch; - } - } - return($tmp); - } - - - /* Get available branches for current base */ - function getBranches($base = false,$prefix = "") - { - $ret = array("/"=>"main"); - $ldap = $this->config->get_ldap_link(); - if(!$base){ - $base= $_SESSION['CurrentMainBase']; - } - $tmp = get_all_releases_from_base($base,true); - foreach($tmp as $dn => $name){ - $ret[$name]=$dn; - } - ksort($ret); - $ret = array_flip($ret); - - return ($ret); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - /* reload list of objects */ - function reload() - { - /* Variable initialisation */ - $str = ""; - $Regex = $this->DivListFai->Regex; - $this->objects = array(); - - /* Get base */ - $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; - if($this->DivListFai->selectedBranch != "main"){ - $br = $this->getBranches(); - if(isset($br[$this->DivListFai->selectedBranch])){ - $base = $this->DivListFai->selectedBranch; - }else{ - $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase; - } - } - $this->base = $base; - $this->set_acl_base($this->base); - - $this->lock_type = get_release_tag(get_release_dn($base)); - - /* Create a new list of FAI object - * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... - */ - $ObjectTypes = array( - "FAIpartitionTable" => array("OU"=>"ou=disk," , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"), - "FAIpackageList" => array("OU"=>"ou=packages," , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"), - "FAIscript" => array("OU"=>"ou=scripts," , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"), - "FAIvariable" => array("OU"=>"ou=variables," , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"), - "FAIhook" => array("OU"=>"ou=hooks," , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"), - "FAIprofile" => array("OU"=>"ou=profiles," , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"), - "FAItemplate" => array("OU"=>"ou=templates," , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate")); - - $filter = ""; - foreach($ObjectTypes as $key => $data){ - if($this->DivListFai->$data['CHKBOX']){ - $filter.= "(objectClass=".$key.")"; - } - } - $filter = "(&(|".$filter.")(cn=$Regex))"; - - /* Get resolved release dependencies */ - $tmp = get_all_objects_for_given_base($base,$filter); - - /* Ge listed ldap objects */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - foreach($tmp as $entry){ - - /* Get some more informations about the object */ - $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass")); - $object = $ldap->fetch(); - - /* Walk through possible types */ - foreach($ObjectTypes as $type => $rest){ - - $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']); - - if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){ - - /* Prepare object */ - unset($object['objectClass']['count']); - if(!isset($object['description'][0])){ - $object['description'][0]=""; - } - - /* Clean up object informations */ - $obj = array(); - $obj['cn'] = $object['cn'][0]; - $obj['dn'] = $object['dn']; - $obj['acl'] = $acl; - $obj['description'] = $object['description'][0]; - $obj['objectClass'] = $object['objectClass']; - - /* Append type to this string, to be able to check if the selected - * entry is of type 'freeze' or 'branch' - */ - if(!isset($object['FAIstate'])){ - $obj['FAIstate'] = $this->lock_type; - }else{ - $obj['FAIstate'] = $object['FAIstate'][0]; - } - - $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj; - $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type; - } - } - } - - ksort($this->objects); - reset ($this->objects); - - /* use numeric index, thats a bit more secure */ - $tmp0 = array(); - foreach($this->objects as $obj){ - $tmp0[]= $obj; - } - $this->objects = array(); - $this->objects = $tmp0; - } - - function remove_lock() - { - if (isset($this->dn)){ - del_lock ($this->dn); - } - } - - function get_type($array){ - if(in_array("FAIpartitionTable",$array['objectClass'])){ - return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS")); - } - if(in_array("FAIscript",$array['objectClass'])){ - return(array("tabsScript","faiScript","FAISCRIPTTABS")); - } - if(in_array("FAItemplate",$array['objectClass'])){ - return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS")); - } - if(in_array("FAIhook",$array['objectClass'])){ - return(array("tabsHook","faiHook","FAIHOOKTABS")); - } - if(in_array("FAIvariable",$array['objectClass'])){ - return(array("tabsVariable","faiVariable","FAIVARIABLETABS")); - } - if(in_array("FAIprofile",$array['objectClass'])){ - return(array("tabsProfile","faiProfile","FAIPROFILETABS")); - } - - if(in_array("FAIpackageList",$array['objectClass'])){ - return(array("tabsPackage","faiPackage","FAIPACKAGETABS")); - } - } - - function CheckNewBranchName($name,$base) - { - $f = $this->DivListFai->selectedBranch; - if($name == ""){ - return(false); - }elseif(in_array($name,$this->getBranches($f))) { - return(false); - }elseif(is_department_name_reserved($name,$base)){ - return(false); - } - return(true); - } - - function save_object() - { - $this->DivListFai->save_object(); - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - $base = $this->DivListFai->selectedBranch; - if($base == "main"){ - $base = $this->DivListFai->selectedBase; - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $entry = $this->objects[$s_entry]; - $a_setup = $this->get_type($entry); - $dn = $entry['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - - /* Cleanup object queue */ - $entry = $this->objects[$id]; - $a_setup = $this->get_type($entry); - $dn = $entry['dn']; - - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$base); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - save_release_changes_now(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("FAI releases"), - "plDescription" => _("FAI release management"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("fai"=> array("description" => _("FAI"), - "objectClass" => "FAIclass")), - "plProvidedAcls"=> array())); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc deleted file mode 100644 index bcd5eaaf6..000000000 --- a/plugins/admin/fai/class_faiPackage.inc +++ /dev/null @@ -1,670 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description","FAIpackage","FAIdebianRelease","FAIdebianSection", "FAIinstallMethod"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIpackageList","FAIrepository"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = ""; - var $subClasses = array("top","FAIclass","FAIscriptEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = ""; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description"); - var $sub64coded = array(); - - var $ConfiguredPackages = array(); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $SubObjects = array(); // All leafobjects of this object - - var $FAIdebianRelease = ""; // The selected release - var $FAIdebianSection = array(); // selected section - var $FAIinstallMethod = "aptitude"; // hard coded - var $mirror = ""; // selected mirror - - var $servers = array(); // All available servers - var $releases = array(); // All possible releases - var $sections = array(); // All section types - - var $list = NULL; - - var $mirrors = array(); // The combination of server/release/section - var $confDir = ""; - var $usedPackages = array(); - var $buffer = NULL; - var $strID =""; - var $newDialogShown =false; - - var $FAIstate = ""; - var $view_logged = FALSE; - var $base; - - var $FAIinstallMethods = array( "install", "ninstall", "remove", - "dselect-upgrade", "taskinst", "taskrm", - "hold", "clean", "aptitude", "aptitude-r", - "pending", "dpkgc" ); - - - function faiPackage (&$config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. - */ - if($dn != "new"){ - $this->dn =$dn; - - /* Get FAIstate - */ - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - } - - if(isset($this->attrs['FAIpackage'])){ - unset($this->attrs['FAIpackage']['count']); - foreach($this->attrs['FAIpackage'] as $pkg){ - $this->usedPackages[$pkg] = $pkg; - } - ksort($this->usedPackages); - }else{ - $this->usedPackages = array(); - } - - if($dn != "new"){ - - /* Create one filter with all package names, - instead of calling $ldap->search for every single package - */ - $PackageFilter = ""; - foreach($this->usedPackages as $name){ - $PackageFilter .= "(FAIpackage=".$name.")"; - } - $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))"; - - /* Search for configuration objects */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate")); - - /* Walk through configurations and append them to our list of ConfiguredPackages */ - while($attr = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$attr['FAIstate'][0])){ - continue; - } - } - - $tmp =array(); - $tmp['Name'] = $attr['FAIvariable'][0]; - $tmp['Type'] = $attr['FAIvariableType'][0]; - - if (isset($attr['FAIvariableContent'][0])){ - if(!in_array($attr['FAIvariableType'],array("multiselect"))){ - $tmp['Value'] = $attr['FAIvariableContent'][0]; - }else{ - $content = array(); - unset($attr['FAIvariableContent']['count']); - foreach($attr['FAIvariableContent'] as $attr){ - $tmp['Value'][] = $attr; - } - } - $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp; - } - } - } - - if (isset($this->attrs['FAIdebianSection']['count'])){ - unset($this->attrs['FAIdebianSection']['count']); - } - if((isset($this->attrs['FAIdebianSection']))&&(is_array($this->attrs['FAIdebianSection']))){ - $this->FAIdebianSection = array(); - foreach($this->attrs['FAIdebianSection'] as $sec){ - $this->FAIdebianSection[$sec]=$sec; - } - } - - if((isset($this->attrs['FAIdebianSection']))&&(is_string($this->attrs['FAIdebianSection']))){ - $this->FAIdebianSection=array($this->attrs['FAIdebianSection']=>$this->attrs['FAIdebianSection']) ; - } - $this->confDir = CONFIG_DIR."/fai/"; - $this->FAIpackage = array(); - - - $methods = array(); - foreach($this->FAIinstallMethods as $method){ - $methods[$method] = $method; - } - $this->FAIinstallMethods = $methods; - /* Check if we exist already - no need to ask for revisions, etc. then */ - if ($this->dn != "new"){ - $this->newDialogShown= true; - } - - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","fai/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - $smarty->assign( "FAIinstallMethods", $this->FAIinstallMethods ); - - if(!$this->is_account){ - - /* Assemble release name */ - $tmp= preg_replace('/,ou=fai,ou=configs,ou=systems,.*$/', '', $_SESSION['faifilter']['branch']); - $tmp= preg_replace('/ou=/', '', $tmp); - $rev= array_reverse(split(',', $tmp)); - $this->FAIdebianRelease= ""; - foreach ($rev as $part){ - $this->FAIdebianRelease.= "/$part"; - } - $this->FAIdebianRelease= preg_replace('#^/#', '', $this->FAIdebianRelease); - - /* Assemble sections */ - $repos= $this->getServerInfos(); - if(isset($repos[$this->FAIdebianRelease])){ - $this->FAIdebianSection= $repos[$this->FAIdebianRelease]; - $this->FAIdebianSection= array_unique($this->FAIdebianSection); - } - - /* Assign Repository settings*/ - $this->is_account = true; - } - - /* Assign variables */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - } - - /* Generate package list */ - $this->list= $this->genPkgs(); - - /* + was pressed to open the package dialog */ - if(isset($_POST['Addpkg']) && $this->acl_is_writeable("FAIpackage")){ - $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->list,$this->usedPackages); - $this->is_dialog =true; - } - - /* Delte selected package */ - if(isset($_POST['Delpkg']) && $this->acl_is_writeable("FAIpackage")){ - if($this->FAIstate != "freeze"){ - foreach($_POST['usedPackages'] as $del){ - if(isset($this->usedPackages[$del])){ - unset($this->usedPackages[$del]); - } - } - } - } - - /* Abort package selection dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->dialog = false; - $this->is_dialog=false; - } - - /* attach new packages */ - if(isset($_POST['SaveSubObject'])) { - if($this->FAIstate != "freeze"){ - $this->dialog->save_object(); - if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msgs){ - print_red($msgs); - } - }else{ - $use = $this->dialog->save(); - $this->usedPackages = $use; - $this->dialog = false; - $this->is_dialog=false; - ksort($this->usedPackages); - } - }else{ - $this->dialog = false; - $this->is_dialog=false; - } - } - - /* Configuration dialog open*/ - if((isset($_POST['Conpkg']))&&(isset($_POST['usedPackages']))&&(!empty($_POST['usedPackages'][0])) && $this->acl_is_writeable("FAIdebconfInfo")){ - $path = CONFIG_DIR."/fai/".$this->FAIdebianRelease."/debconf.d"; - $pkg_config = array(); - $pkg = $_POST['usedPackages'][0]; - - if(isset($this->ConfiguredPackages[$pkg])){ - $pkg_config = $this->ConfiguredPackages[$pkg]; - } - - $this->dialog = new faiPackageConfiguration($this->config, $this->dn,$pkg, $path, $pkg_config); - $this->is_dialog =true; - } - - /* Configuration dialog open*/ - if($this->FAIstate != "freeze" && $this->acl_is_writeable("FAIpackage")){ - if((isset($_POST['Markpkg']))&&(isset($_POST['usedPackages']))&&(!empty($_POST['usedPackages']))){ - foreach($_POST['usedPackages'] as $pkg){ - if (isset($this->usedPackages[$pkg])){ - unset($this->usedPackages[$pkg]); - if (preg_match('/^-/', $pkg)){ - $pkg= preg_replace('/^-/', '', $pkg); - } else { - $pkg= preg_replace('/^/', '-', $pkg); - } - $this->usedPackages[$pkg]= $pkg; - } - } - } - } - - /* Save Configuration */ - if(isset($_POST['SaveObjectConfig'])){ - if($this->FAIstate != "freeze"){ - $this->ConfiguredPackages= array_merge($this->ConfiguredPackages,$this->dialog->save()); - } - $this->dialog = false; - $this->is_dialog=false; - } - - /* cancel configuration */ - if(isset($_POST['CancelObjectConfig'])){ - $this->dialog = false; - $this->is_dialog=false; - } - - /* Display dialog */ - if($this->is_dialog){ - return $this->dialog->execute(); - } - - /* Assign section to smarty */ - $strsec = ""; - foreach($this->FAIdebianSection as $sec){ - $strsec .= $sec." "; - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/",$this->FAIstate))); - } - - $smarty->assign("releases",$this->releases); - $smarty->assign("release" ,$this->FAIdebianRelease); - $smarty->assign("sections",$this->sections); - $smarty->assign("section" ,$strsec); - $smarty->assign("usedPackages",$this->printUsedPackages()); - $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); - return($display); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $this->dn; - } - - prepare_to_save_FAI_object($use_dn,array(),true); - - new log("remove","fai/".get_class($this),$use_dn,$this->attributes); - - foreach($this->ConfiguredPackages as $pkgname => $attrs){ - foreach($attrs as $name => $attr){ - $pkgdn = "FAIvariable=".$name.",".$this->dn; -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $pkgdn); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $pkgdn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $obj['dn']; - } - prepare_to_save_FAI_object($use_dn,array(),true); - } - } - $this->handle_post_events("remove"); - } - - - /* Save data to object - */ - function save_object() - { - if($this->FAIstate == "freeze") return; - plugin::save_object(); - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(count($this->usedPackages)==0){ - $message[]=_("Please select a least one Package."); - } - - if((empty($this->FAIdebianRelease))||(empty($this->FAIdebianSection))){ - $message[]=_("Please choose a valid combination for your repository setup."); - } - - return ($message); - } - - function printUsedPackages(){ - $a_ret=array(); - if(is_array($this->usedPackages)) { - foreach($this->usedPackages as $usedName){ - - $config = 0; - - foreach($this->ConfiguredPackages as $name => $value){ - if($name == $usedName){ - $config ++; - } - } - - $c_str =""; - if($config){ - $c_str = " - "._("package is configured"); - } - - /* Adapt used name if we're marked for removal */ - $dsc= ""; - if (preg_match('/^-/', $usedName)){ - $dsc= " - "._("Package marked for removal"); - // Generally a bad idea here, because the toggel triggers on -, not on ! - //$usedName= preg_replace('/^-/', '! ', $usedName); - }else{ - $usedName2= $usedName; - } - - if(isset($this->list[$usedName][1])){ - $a_ret[$usedName] = $usedName2." [".$this->list[$usedName][1]."]".$c_str.$dsc; - }else{ - $a_ret[$usedName] = $usedName2.$c_str.$dsc; - } - } - } - return($a_ret); - } - - function genPkgs() - { - /* Generate a list off available packages for this mirror, section and release - */ - /* Only read this file if it wasn't read before */ - if($this->buffer === NULL){ - $this->buffer=array(); - $a_ret = array(); - foreach($this->FAIdebianSection as $sec){ - $strID= CONFIG_DIR."/fai/".$this->FAIdebianRelease."/".$sec; - - if(!is_file($strID)){ - print_red(sprintf(_("Package file '%s' does not exist."),$strID)); - unset($this->buffer); - return(array()); - } - $fp = fopen($strID,"r"); - - /* Parse every line and create an array */ - while(!feof($fp)){ - $str= fgets($fp,512); - $stra= split("\|",$str); - if(count($stra)==4){ - $a_ret[$stra[0]] = $stra; - } - } - fclose($fp); - /* Save our Data, to avoid reading it again */ - } - $this->buffer = $a_ret; - ksort($a_ret); - return($a_ret); - }else{ - return $this->buffer; - } - } - - - /* Save to LDAP */ - function save() - { - - /* Assemble release name */ - if($this->FAIdebianRelease == "ClearFromCopyPaste"){ - $tmp= preg_replace('/,ou=fai,ou=configs,ou=systems,.*$/', '', $_SESSION['faifilter']['branch']); - $tmp= preg_replace('/ou=/', '', $tmp); - $rev= array_reverse(split(',', $tmp)); - $this->FAIdebianRelease= ""; - foreach ($rev as $part){ - $this->FAIdebianRelease.= "/$part"; - } - $this->FAIdebianRelease= preg_replace('#^/#', '', $this->FAIdebianRelease); - } - - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - $this->attrs['FAIpackage'] = array(); - foreach($this->usedPackages as $pkg => $obj){ - $this->attrs['FAIpackage'][] = $pkg; - } - - $this->attrs['FAIdebianSection'] = array(); - foreach($this->FAIdebianSection as $sec){ - $this->attrs['FAIdebianSection'][] = $sec; - } - - prepare_to_save_FAI_object($this->dn,$this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/package list with dn '%s' failed."),$this->dn)); - - if($this->initially_was_account){ - new log("modify","fai/".get_class($this),$this->dn,$this->attributes); - }else{ - new log("create","fai/".get_class($this),$this->dn,$this->attributes); - } - - /* Do object tagging */ - $this->handle_object_tagging(); - $ldap->cd($this->dn); - - /* Save Package configurations */ - foreach($this->ConfiguredPackages as $pkgname => $attrs){ - foreach($attrs as $name => $attr){ - - $pkgattrs = array(); - - foreach($attr as $n=>$v){ - if(empty($v)) $v = array(); - } - - /* Set attributes */ - $pkgattrs['objectClass'][] = "FAIdebconfInfo"; - - $pkgattrs['FAIpackage'] = $pkgname; - $pkgattrs['FAIvariable'] = $name; - $pkgattrs['FAIvariableType'] = $attr['Type']; - $pkgattrs['FAIvariableContent'] = $attr['Value']; - $pkgdn = "FAIvariable=".$name.",".$this->dn; - - /* cehck if object already exists */ - $ldap->cat($pkgdn,array("objectClass")); - - /* Workaround for missing "gosaAdministrativeUnitTag" */ - $attrs = $ldap->fetch(); - if((isset($attrs['objectClass'])) && (in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass']))){ - $pkgattrs['objectClass'][] = "gosaAdministrativeUnitTag"; - } - - if(in_array($pkgattrs['FAIvariableType'],array("boolean","multiselect","password","select","string","text"))){ - prepare_to_save_FAI_object($pkgdn,$pkgattrs); - } - - /* Handle tagging */ - $this->handle_object_tagging($pkgdn, $this->gosaUnitTag); - } - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Package"), - "plDescription" => _("FAI Package list"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 28, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name"), - "description" => _("Description"), - "FAIpackage" => _("Packages"), - "FAIdebianSection" => _("Section")." ("._("Readonly").")", - "FAIinstallMethod" => _("Install Method"), - "FAIdebconfInfo" => _("Package configuration"), - "FAIdebianRelease" => _("Release")." ("._("Readonly").")") - )); - } - - - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - if(isset($source['FAIstate'][0])){ - $this->FAIstate = $source['FAIstate'][0]; - } - - $this->FAIdebianRelease = "ClearFromCopyPaste"; - - if(isset($source['FAIpackage'])){ - unset($source['FAIpackage']['count']); - foreach($source['FAIpackage'] as $pkg){ - $this->usedPackages[$pkg] = $pkg; - } - ksort($this->usedPackages); - }else{ - $this->usedPackages = array(); - } - - if((isset($source['FAIdebianSection']))&&(is_array($source['FAIdebianSection']))){ - $this->FAIdebianSection = array(); - for($i = 0 ; $i < $source['FAIdebianSection']['count'] ; $i ++){ - $this->FAIdebianSection[$source['FAIdebianSection'][$i]]=$source['FAIdebianSection'][$i]; - } - } - - /* Create one filter with all package names, - instead of calling $ldap->search for every single package - */ - $PackageFilter = ""; - foreach($this->usedPackages as $name){ - $PackageFilter .= "(FAIpackage=".$name.")"; - } - $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))"; - - /* Search for configuration objects */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($source['dn']); - $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate")); - - /* Walk through configurations and append them to our list of ConfiguredPackages */ - while($attr = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$attr['FAIstate'][0])){ - continue; - } - } - - $tmp =array(); - $tmp['Name'] = $attr['FAIvariable'][0]; - $tmp['Type'] = $attr['FAIvariableType'][0]; - - if (isset($attr['FAIvariableContent'][0])){ - if(!in_array($attr['FAIvariableType'],array("multiselect"))){ - $tmp['Value'] = $attr['FAIvariableContent'][0]; - }else{ - $content = array(); - unset($attr['FAIvariableContent']['count']); - foreach($attr['FAIvariableContent'] as $attr){ - $tmp['Value'][] = $attr; - } - } - $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp; - } - } - } - - - function getServerInfos() - { - $ret = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=FAIrepositoryServer)",array("*")); - while($attrs = $ldap->fetch()){ - if(isset($attrs['FAIrepository'])){ - for($i =0 ; $i < $attrs['FAIrepository']['count']; $i++){ - $obj = $attrs['FAIrepository'][$i]; - $tmp = split("\|",$obj); - if(count($tmp)==4){ - foreach(split(",",$tmp[3]) as $sec){ - if(!empty($sec)){ - $ret[$tmp[2]][] = $sec; - } - } - } - } - } - } - return($ret); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiPackageConfiguration.inc b/plugins/admin/fai/class_faiPackageConfiguration.inc deleted file mode 100644 index 18f3e2b6c..000000000 --- a/plugins/admin/fai/class_faiPackageConfiguration.inc +++ /dev/null @@ -1,84 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array(); - - var $Debconf_handle = NULL; - var $pkg_config ; - var $obj; - - function faiPackageConfiguration (&$config, $dn= NULL,$obj,$path,$pkg_config) - { - plugin::plugin ($config, $dn); - $this->obj = $obj; - $this->Debconf_handle = new debconf(); - $this->Debconf_handle->set_template_directory($path); - $this->Debconf_handle->set_package($this->obj); - $this->Debconf_handle->set_language(preg_replace('/_.*$/', '', get_browser_language())); - - if( $this->Debconf_handle->load() ) { - $this->pkg_config = $pkg_config; - - foreach($this->pkg_config as $var){ - $this->Debconf_handle->SetDefault($var['Name'],$var['Value']); - } - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - $smarty->assign("headline", sprintf(_("Debconf information for package '%s'"), $this->obj)); - - $this->Debconf_handle->PostCheck(); - - $smarty->assign("Config",$this->Debconf_handle->get_dialog()); - - $display.= $smarty->fetch(get_template_path('faiPackageConfiguration.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - function save() - { - $this->Debconf_handle->PostCheck(); - $pkgs = $this->Debconf_handle->template; - - $tmp = array(); - foreach($pkgs as $pkg){ - $tmp[$this->obj][$pkg['Name']]['Value']= $pkg['Default']; - $tmp[$this->obj][$pkg['Name']]['Name'] = $pkg['Name']; - $tmp[$this->obj][$pkg['Name']]['Type'] = $pkg['Type']; - } - return($tmp); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiPackageEntry.inc b/plugins/admin/fai/class_faiPackageEntry.inc deleted file mode 100644 index 1b22ba869..000000000 --- a/plugins/admin/fai/class_faiPackageEntry.inc +++ /dev/null @@ -1,200 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array(); - var $objectclasses= array(); - var $pkgs = array(); - - var $buffer = array(); - var $categories = array(); - var $searchStrPKG = ""; - var $selected = array(); - - /* Array with available class names */ - var $FAIAllclasses = array(); - - function faiPackageEntry (&$config, $dn= NULL,$pkgs,$selected=array()) - { - plugin::plugin ($config, $dn); - - $this->pkgs=$pkgs; - - if(isset($_SESSION['searchStrPKG'])){ - $this->searchStrPKG=$_SESSION['searchStrPKG']; - } - $this->selected=$selected; - - $this->searchStrPKG= _("Please enter your search string here"); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - $divlist = new divlist("PackageEntry"); - $divlist->SetPluginMode(); - $divlist->SetSummary(_("This list displays all assigned package names for this repository settings.")); - $divlist->SetEntriesPerPage(0); - $divlist->SetHeight("650px;"); - $divlist->SetHeader(array(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), - array("string" => "Name", "attach" => "style='width:180px;'"), - array("string" => "Version", "attach" ), - array("string" => "Description", "attach" => "style='width:240px;border-right:0px;text-align:left;'"))); - - if(isset($_GET['search'])){ - $this->searchStrPKG= $_GET['search']."*"; - } - - $pkgs= $this->pkgs; - - unset($this->categories); - foreach($pkgs as $name => $entry){ - $cat = $entry[2]; - if(!empty($cat)){ - if(!isset($this->categories[$cat])){ - $this->categories[$cat] = true; - } - if(isset($_POST['chkchange'])){ - $this->searchStrPKG = $_POST['searchStrPKG']; - if(isset($_POST['CAT'.$cat])){ - $this->categories[$cat]=true; - }else{ - $this->categories[$cat]=false; - } - } - } - } - - $this->searchStrPKG = preg_replace("/^\+/","",$this->searchStrPKG); - if(empty($this->searchStrPKG)){ - $this->searchStrPKG = "*"; - } - - @ksort($this->categories); - -$CHKS = ""; - $i = 0; - if(is_array($this->categories)) - foreach($this->categories as $cat => $selected){ - if($i == 3){ - $CHKS .=""; - $i = 0; - } - $i ++ ; - if($selected){ - $CHKS .=""; - }else{ - $CHKS .=""; - } - } - $CHKS .= "
 ".$cat."  ".$cat." 
"; - - - foreach($_POST as $name => $value){ - if(preg_match("/^wasonpage_/i",$name)){ - $name = preg_replace("/^wasonpage_/","",$name); - $n =base64_decode($name); - - if(isset($_POST['use_'.$name])){ - $this->selected[$n] = $n; - }else{ - if(isset($this->selected[$n])){ - unset($this->selected[$n]); - } - } - - } - } - - /* Prepare search filter */ - $search_str = preg_replace("/\\\\\*/",".*",normalizePreg($this->searchStrPKG)); - - $cnt = 0; - foreach($pkgs as $pkg){ - if($cnt > 200) { - print_red(sprintf(_("Your specified search string '%s' returned too many results. Only the first 200 entries are shown, to keep the memory usage low."),$this->searchStrPKG)); - break; - } - if((preg_match("/^".$search_str."/i",$pkg[0]))|| - (preg_match("/^".$search_str."/i",$pkg[3]))){ - if($this->categories[$pkg[2]]){ - if(in_array($pkg[0],$this->selected)){ - $check = " checked "; - }else{ - $check = ""; - } - $cnt ++ ; - $chkbox = " - "; - $divlist->AddEntry(array(array("string"=>$chkbox, "attach" => "style='text-align:center;width:20px;'"), - array("string"=>$pkg[0], "attach" => "style='width:180px;'"), - array("string"=>htmlentities($pkg[1])), - array("string"=>htmlentities($pkg[3]), "attach" => "style='width:221px;border-right:0px;text-align:left;'"))); - } - } - } - - $_SESSION['searchStrPKG'] = $this->searchStrPKG; - $smarty->assign("CHKS" , $CHKS); - $smarty->assign("searchStrPKG" , $this->searchStrPKG); - $smarty->assign("faihead" , ""); - $smarty->assign("failist" , $divlist->DrawList()); - $smarty->assign("infoimage" , get_template_path('images/info.png')); - $smarty->assign("launchimage" , get_template_path('images/launch.png')); - $smarty->assign("alphabet" , generate_alphabet()); - $smarty->assign("apply" , apply_filter(TRUE)); - $smarty->assign("search_image" , get_template_path('images/search.png')); - - $display.= $smarty->fetch(get_template_path('faiPackageEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - foreach($_POST as $name => $value){ - if(preg_match("/^wasonpage_/i",$name)){ - $name = preg_replace("/^wasonpage_/","",$name); - $n =base64_decode($name); - if(isset($_POST['use_'.$name])){ - $this->selected[$n] = $n; - }else{ - if(isset($this->selected[$n])){ - unset($this->selected[$n]); - } - } - - } - } - - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - function save() - { - return($this->selected); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc deleted file mode 100644 index 216d6c3ed..000000000 --- a/plugins/admin/fai/class_faiPartitionTable.inc +++ /dev/null @@ -1,621 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array("cn","description"); - var $objectclasses = array("top","FAIclass","FAIpartitionTable"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $disks = array(); // All defined Disks - var $is_dialog = false; // specifies which buttons will be shown to save or abort - - var $FAIstate = ""; - var $ui; - - var $view_logged = FALSE; - - function faiPartitionTable (&$config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - $this->acl ="#all#"; - - $this->ui = get_userinfo(); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - * First read disks from ldap ... and then the partition definitions for the disks. - */ - if($dn != "new"){ - $this->dn =$dn; - - /* Get FAIstate - */ - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - /* Read all disks from ldap taht are defined fot this partition table - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))",array("*")); - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - $this->disks[$object['cn'][0]]['status'] = "edited"; - $this->disks[$object['cn'][0]]['dn'] = $object['dn']; - $this->disks[$object['cn'][0]]['cn'] = $object['cn'][0]; - if(isset($object['description'][0])){ - $this->disks[$object['cn'][0]]['description'] = $object['description'][0]; - }else{ - $this->disks[$object['cn'][0]]['description'] = ""; - } - $this->disks[$object['cn'][0]]['partitions'] = array(); - } - - /* read all partitions for each disk - */ - foreach($this->disks as $name => $disk){ - $ldap->cd ($disk['dn']); - $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))",array("*")); - while($partition = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($partition['FAIstate'][0])){ - if(preg_match("/removed$/",$partition['FAIstate'][0])){ - continue; - } - } - - /* remove count ... from ldap result - */ - foreach($partition as $key=>$val){ - if((is_numeric($key))||($key=="count")||($key=="dn")){ - unset($partition[$key]); - }else{ - $partition[$key] = $val[0]; - } - } - - /* Append fetched partitions - */ - $partition['status']="edited"; - $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; - } - } - } - ksort($this->disks); - } - - - function acl_base_for_current_object($dn) - { - if($dn == "new"){ - if($this->dn == "new"){ - $dn= $_SESSION['CurrentMainBase']; - }else{ - $dn = $this->dn; - } - } - return($dn); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","fai/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Add Disk to this Partitionset - * This code adds a new HDD to the disks - * A new Dialog will be opened - */ - if(isset($_POST['AddDisk'])){ - $usedDiskNames =array(); - foreach($this->disks as $key=>$disk){ - $usedDiskNames[]= $key; - } - $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); - $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn)); - $this->dialog->set_acl_category("fai"); - $this->dialog->FAIstate = $this->FAIstate; - $this->is_dialog = true; - } - - /* Edit disk. - * Open dialog which allows us to edit the selected entry - */ - - if($this->dn != "new"){ - $_SESSION['objectinfo']= $this->dn; - } - - if((isset($_POST['EditDisk']))&&(isset($_POST['disks']))){ - $usedDiskNames =array(); - $Udisk = $_POST['disks'][0]; - if(isset($this->disks[$Udisk])){ - - foreach($this->disks as $key=>$disk){ - if($key != $Udisk){ - $usedDiskNames[]= $key; - } - } - - /* Set object info string, which will be displayed in plugin info line */ - if(isset($this->disks[$Udisk]['dn'])){ - $_SESSION['objectinfo'] = $this->disks[$Udisk]['dn']; - $dn = $this->disks[$Udisk]['dn']; - }else{ - $_SESSION['objectinfo'] = ""; - $dn = "new"; - } - - $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); - $this->dialog->set_acl_base($this->acl_base_for_current_object($dn)); - $this->dialog->set_acl_category("fai"); - $this->dialog->FAIstate = $this->FAIstate; - - $this->is_dialog = true; - } - } - - /* Edit aborted, close dialog, without saving anything - */ - if(isset($_POST['CancelDisk'])){ - unset($this->dialog); - $this->dialog = FALSE; - $this->is_dialog=false; - } - - /* Dialog saved - * Save given data from Dialog, if no error is occurred - */ - if(isset($_POST['SaveDisk'])){ - - if($this->FAIstate != "freeze"){ - $this->dialog->save_object(); - if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } - }else{ - $disk = $this->dialog->save(); - if(isset($disk['rename'])){ - if($this->disks[$disk['rename']['from']]['status']=="edited"){ - $this->disks[$disk['rename']['from']]['status']="delete"; - }else{ - unset($this->disks[$disk['rename']['from']]); - } - - foreach($disk['partitions'] as $key => $val){ - if($disk['partitions'][$key]['status']!="delete"){ - $disk['partitions'][$key]['status']= "new"; - } - } - - $disk['status']="new"; - $disk['cn']= $disk['rename']['to']; - } - - $this->disks[$disk['cn']]=$disk; - unset($this->dialog); - $this->dialog = FALSE; - $this->is_dialog=false; - ksort($this->disks); - } - }else{ - $this->dialog = FALSE; - $this->is_dialog=false; - } - } - - /* Delete selected disk drive from list - * Assign delete status for all its partitions - */ - if((isset($_POST['DelDisk']))&&(!empty($_POST['disks']))){ - if($this->FAIstate != "freeze"){ - foreach($_POST['disks'] as $disk) { - - if(isset($this->disks[$disk])){ - if($this->disks[$disk]['status']=="edited"){ - $this->disks[$disk."-delete"]=$this->disks[$disk]; - unset($this->disks[$disk]); - $disk = $disk."-delete"; - $this->disks[$disk]['status']="delete"; - foreach($this->disks[$disk]['partitions'] as $name => $value ){ - if($value['status']=="edited"){ - $this->disks[$disk]['partitions'][$name]['status']="delete"; - }else{ - unset($this->disks[$disk]['partitions'][$name]); - } - } - }else{ - unset($this->disks[$disk]); - } - } - } - } - } - - /* Display dialog if one is defined - */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - /* Assign all attributes to smarty engine - */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - if($this->$attrs){ - $smarty->assign($attrs."CHK"," "); - }else{ - $smarty->assign($attrs."CHK"," disabled "); - } - } - - $dn = $this->acl_base_for_current_object($this->dn); - $smarty->assign("sub_object_is_addable", - preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiPartitionTableEntry")) && - !preg_match("/freeze/",$this->FAIstate)); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - $disks = $this->getDisks(); - $smarty->assign("disks" ,$disks); - $display.= $smarty->fetch(get_template_path('faiPartitionTable.tpl', TRUE)); - return($display); - } - - function getDisks(){ - /* Return all available disks for this partition table - * Return in listBox friendly array - */ - $a_return = array(); - foreach($this->disks as $key => $disk){ - - $dn = "new"; - if(isset($obj['dn'])){ - $dn = $obj['dn']; - } - $dn = $this->acl_base_for_current_object($dn); - $acl = $this->ui->get_permissions($dn,"fai/faiPartitionTableEntry"); - if(preg_match("/(r|w)/",$acl)) { - - if($disk['status'] != "delete"){ - $cnt=0; - foreach($disk['partitions'] as $val){ - if($val['status']!="delete"){ - $cnt ++; - } - } - if(!empty($disk['description'])){ - if($cnt == 1){ - $a_return[$key]= $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition"), $cnt); - }else{ - $a_return[$key]= $disk['cn']." [".$disk['description']."], ".sprintf(_("%s partition(s)"), $cnt); - } - }else{ - if($cnt == 1){ - $a_return[$key]= $disk['cn'].", ".sprintf(_("%s partition"), $cnt); - }else{ - $a_return[$key]= $disk['cn'].", ".sprintf(_("%s partition(s)"), $cnt); - } - } - } - } - } - return($a_return); - } - - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $this->dn; - } - - prepare_to_save_FAI_object($use_dn,array(),true); - - new log("remove","fai/".get_class($this),$use_dn,$this->attributes); - - foreach($this->disks as $disk){ - - $disk_dn = "cn=".$disk['cn'].",".$this->dn; -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $disk_dn); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $disk_dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $disk_dn; - } - prepare_to_save_FAI_object($use_dn,array(),true); - - foreach($disk['partitions'] as $key => $partition){ - - $partition_dn= "FAIpartitionNr=".$partition['FAIpartitionNr'].",".$disk_dn; -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $partition_dn); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $partition_dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $disk_dn; - } - prepare_to_save_FAI_object($use_dn,array(),true); - } - } - } - - - /* Save data to object - */ - function save_object() - { - if($this->FAIstate == "freeze") return; - plugin::save_object(); - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - - plugin::save(); - /* Save current settings. - * 1 : We must save the partition table, with its description and cn - * 2 : Append Disk with cn and description. - * 3 : Save partitions for each disk - */ - - $ldap = $this->config->get_ldap_link(); - - prepare_to_save_FAI_object($this->dn,$this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/partition table with dn '%s' failed."),$this->dn)); - - if($this->initially_was_account){ - new log("modify","fai/".get_class($this),$this->dn,$this->attributes); - }else{ - new log("create","fai/".get_class($this),$this->dn,$this->attributes); - } - - /* Do object tagging */ - $this->handle_object_tagging(); - - /* Sort entries, because we must delete entries with status="delete" first */ - $order = array(); - foreach($this->disks as $key => $disk){ - if($disk['status'] == "delete"){ - $order[$key] = $disk; - } - } - foreach($this->disks as $key => $disk){ - if($disk['status'] != "delete"){ - $order[$key] = $disk; - } - } - - /* Append all disks to ldap */ - foreach($order as $cn=>$disk){ - $disk_dn = "cn=".$disk['cn'].",".$this->dn; - $disk_attrs['cn'] = $disk['cn']; - $disk_attrs['description'] = $disk['description']; - $disk_attrs['objectClass'] = array("top","FAIclass","FAIpartitionDisk"); - - if($disk['status']=="new"){ - $ldap->cat($disk_dn,array("objectClass")); - if($ldap->count()){ - $disk['status']="edited"; - } - } - - /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for disks */ - $ldap->cat($disk_dn,array("objectClass")); - $attrs = $ldap->fetch(); - if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ - $disk_attrs['objectClass'][] = "gosaAdministrativeUnitTag"; - } - - if($disk['status'] == "delete"){ - prepare_to_save_FAI_object($disk_dn,array(),true); - $this->handle_post_events("remove"); - }elseif($disk['status'] == "edited"){ - prepare_to_save_FAI_object($disk_dn,$disk_attrs); - $this->handle_post_events("modify"); - }elseif($disk['status']=="new"){ - prepare_to_save_FAI_object($disk_dn,$disk_attrs); - $this->handle_post_events("add"); - } - - $this->handle_object_tagging($disk_dn, $this->gosaUnitTag); - - if($disk['status']!="delete") - /* Add all partitions */ - foreach($disk['partitions'] as $key => $partition){ - $partition_attrs = array(); - - foreach($partition as $key => $value){ - if(!empty($value)){ - $partition_attrs[$key]=$value; - }else{ - unset($partition_attrs[$key]); - } - } - - $partition_dn= "FAIpartitionNr=".$partition_attrs['FAIpartitionNr'].",".$disk_dn; - $partition_attrs['objectClass']= array("top","FAIclass","FAIpartitionEntry"); - $partition_attrs['cn']= $partition_attrs['FAIpartitionNr']; - - unset($partition_attrs['status']); - unset($partition_attrs['old_cn']); - - if($partition['status']=="new"){ - $ldap->cat($partition_dn,array("objectClass")); - if($ldap->count()){ - $partition['status']="edited"; - } - } - - if((!isset($partition['FAImountPoint']))||(empty($partition['FAImountPoint']))){ - $partition_attrs['FAImountPoint']="swap"; - } - - /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for partitions */ - $ldap->cat($partition_dn,array("objectClass")); - $attrs = $ldap->fetch(); - if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ - $partition_attrs['objectClass'][] = "gosaAdministrativeUnitTag"; - } - - if($partition['status'] == "delete"){ - prepare_to_save_FAI_object($partition_dn,array(),true); - $this->handle_post_events("remove"); - }elseif($partition['status'] == "edited"){ - prepare_to_save_FAI_object($partition_dn,$partition_attrs); - $this->handle_post_events("modify"); - }elseif($partition['status']=="new"){ - prepare_to_save_FAI_object($partition_dn,$partition_attrs); - $this->handle_post_events("add"); - } - - $this->handle_object_tagging($partition_dn, $this->gosaUnitTag); - } - } - $this->handle_post_events("add"); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - /* Get FAIstate - */ - if(isset($source['FAIstate'][0])){ - $this->FAIstate = $source['FAIstate'][0]; - } - - /* Read all disks from ldap taht are defined fot this partition table - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))",array("*")); - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - $this->disks[$object['cn'][0]]['status'] = "edited"; - $this->disks[$object['cn'][0]]['dn'] = $object['dn']; - $this->disks[$object['cn'][0]]['cn'] = $object['cn'][0]; - if(isset($object['description'][0])){ - $this->disks[$object['cn'][0]]['description'] = $object['description'][0]; - }else{ - $this->disks[$object['cn'][0]]['description'] = ""; - } - $this->disks[$object['cn'][0]]['partitions'] = array(); - } - - /* read all partitions for each disk - */ - foreach($this->disks as $name => $disk){ - $ldap->cd ($disk['dn']); - $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))",array("*")); - while($partition = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($partition['FAIstate'][0])){ - if(preg_match("/removed$/",$partition['FAIstate'][0])){ - continue; - } - } - - /* remove count ... from ldap result - */ - foreach($partition as $key=>$val){ - if((is_numeric($key))||($key=="count")||($key=="dn")){ - unset($partition[$key]); - }else{ - $partition[$key] = $val[0]; - } - } - - /* Append fetched partitions - */ - $partition['status']="edited"; - $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; - } - } - ksort($this->disks); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Partition table"), - "plDescription" => _("FAI partition table"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 26, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name")." ("._("Read only").")", - "description" => _("Description")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiPartitionTableEntry.inc b/plugins/admin/fai/class_faiPartitionTableEntry.inc deleted file mode 100644 index 431157c26..000000000 --- a/plugins/admin/fai/class_faiPartitionTableEntry.inc +++ /dev/null @@ -1,516 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("DISKcn","DISKdescription"); - var $objectclasses= array(); - - var $DISKcn = ""; - var $DISKdescription = ""; - - var $partitions = array(); - var $UsedAttrs = array(); - var $is_edit = false; - var $old_cn = ""; - var $status = "new"; - var $deletePartitions = array(); - - var $FAIstate = ""; - - function faiPartitionTableEntry (&$config, $dn= NULL,$usedDiskNames=array(),$disk=false) - { - plugin::plugin ($config, $dn); - $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", - "FAImountOptions","FAIfsOptions","FAIpartitionFlags"); - - /* Default status is new */ - $this->status = "new"; - - /* We want to edit an entry */ - if($disk){ - - /* Set disk status */ - $this->status = $disk['status']; - - /* Walk through partitions */ - foreach($disk['partitions'] as $name => $values){ - - /* If a partition is already marked as delete, attach it to deletePartitions only. */ - if($values['status'] == "delete"){ - unset($disk['partitions'][$name]); - $this->deletePartitions[]=$values; - }else{ - - /* Set status, to know which partition must be deleted from ldap - new : Neu partition entry // save - edited : Update partition entry in ldap - deleted: Remove partition from ldap - */ - - /* If status is not new, set to edit mode. - * New means that this partition currently wasn't saved to ldap. - */ - if($disk['partitions'][$name]['status']!="new"){ - $disk['partitions'][$name]['status']="edited"; - } - - $disk['partitions'][$name]['old_cn']= $disk['partitions'][$name]['cn']; - - /* Assign empty attributes, if attribute is missing */ - foreach($this->UsedAttrs as $attr){ - if(!isset($values[$attr])){ - $disk['partitions'][$name][$attr]=""; - } - } - - if (preg_match('/^_/', $disk['partitions'][$name]['FAIfsType'])){ - $disk['partitions'][$name]['FAIfsType']= preg_replace('/^_/', '', $disk['partitions'][$name]['FAIfsType']); - $disk['partitions'][$name]['FAIencrypted']= true; - } else { - $disk['partitions'][$name]['FAIencrypted']= false; - } - } - } - - /* Set default attributes */ - $this->DISKcn = $disk['cn']; - $this->DISKdescription = $disk['description']; - $this->partitions = $disk['partitions']; - $this->is_edit = true; - $this->old_cn = $disk['cn']; - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $s_action = ""; - $s_entry = ""; - $display = ""; - - /* Assign values - * And Checkbox selection - */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - if($this->$attrs){ - $smarty->assign($attrs."CHK"," "); - }else{ - $smarty->assign($attrs."CHK"," disabled "); - } - } - - /* Check all Posts if there is something usefull for us, - * For example : Delete is posted as Delete_1 - * The number specifies the index we want to delete - */ - foreach($_POST as $name => $value){ - if((preg_match("/Delete_.*/",$name)) && $this->acl_is_removeable()){ - $tmp = split("_",$name); - $s_action = "remove"; - $s_entry = $tmp[1]; - } - } - - /* To remove a partition we unset the index posted. - * We must sort the index again, else we possibly got problems - * with partitions order. - */ - if($s_action == "remove" && $this->acl_is_removeable()){ - if($this->partitions[$s_entry]['status'] == "edited"){ - $this->deletePartitions[$s_entry]= $this->partitions[$s_entry]; - $this->deletePartitions[$s_entry]['FAIpartitionNr']=$s_entry; - unset($this->partitions[$s_entry]); - }else{ - unset($this->partitions[$s_entry]); - } - $tmp= array(); - foreach($this->partitions as $part){ - $tmp[count($tmp)+1]=$part; - } - $this->partitions = $tmp; - } - - /* To add a partitions we only append an empty - * array to the already defined partitions. - */ - if(isset($_POST['AddPartition']) && $this->acl_is_createable()){ - foreach($this->UsedAttrs as $attr){ - $tmp[$attr] = ""; - } - $tmp["old_cn"] = ""; - $tmp["FAIencrypted"] = FALSE; - $tmp['status']="new"; - $this->partitions[count($this->partitions)+1]=$tmp; - } - - /* $setup contains a table with the partitions. - */ - $smarty->assign("setup", $this->generateParts()); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - $tmp = $this->plInfo(); - $sacl = ""; - foreach($tmp['plProvidedAcls'] as $name => $translated){ - - $acl = $this->getacl($name); - $sacl .= $acl; - if($this->FAIstate == "freezed"){ - $acl = preg_replace("/w/","",$acl); - } - $smarty->assign($name."ACL",$acl); - } - $smarty->assign("allowSave",$sacl); - - $smarty->assign("sub_object_is_createable",$this->acl_is_createable()); - - /* Fetch template and show the result - */ - $display.= $smarty->fetch(get_template_path('faiPartitionTableEntry.tpl', TRUE)); - return($display); - } - - function generateParts() - { - /* Define Arrays with allowed syntax */ - $PartitionTypes = array("primary"=>_("primary"),"logical"=>_("logical")); - $FAIfsTypes = array("ext2","ext3","xfs","swap","reiser","dosfat16","winfat32"); - - /* Display Header */ - $str = ""; - if (count($this->partitions)){ - $str .= ""; - $str .= ""._("Type").""; - $str .= ""._("FS type").""; - $str .= ""._("Mount point").""; - $str .= ""._("Size in MB").""; - $str .= ""._("Mount options").""; - $str .= ""._("FS option").""; - $str .= ""._("Preserve").""; - $str .= ""._("Encrypted").""; - $str .= " "; - $str .= ""; - } - - /* Walk through all defined partitions. - * Create a new row for each partition and append it to - * the header defined above. - * To be able to check the posts later, we append a key to each single postfield. like cn_1 ... cn_2 - */ - foreach($this->partitions as $key => $part){ - - $dis = ""; - if($part['FAIpartitionFlags'] == "preserve"){ - $dis = " disabled "; - } - - $disableALL = ""; - if($this->FAIstate =="freeze"){ - $disableALL = " disabled "; - } - - if($part['status']!="delete"){ - - /* Generate Partition select box - */ - $PartitionType = ""; - if($this->acl_is_writeable("FAIpartitionType")){ - $PartitionType = ""; - }elseif($this->acl_is_readable("FAIpartitionType")){ - $PartitionType = $part['FAIpartitionType']; - } - - - /* Generate fsType select box - */ - $FAIfsType= ""; - if($this->acl_is_writeable("FAIfsType")){ - $FAIfsType= ""; - }elseif($this->acl_is_readable("FAIfsType")){ - $FAIfsType = $part['FAIfsType']; - } - - foreach(array("FAImountPoint","FAIpartitionSize","FAImountOptions","FAIfsOptions") as $attr){ - $$attr = ""; - if($this->acl_is_writeable($attr)){ - $$attr = ""; - - }elseif($this->acl_is_readable($attr)){ - $$attr = $part[$attr]; - } - } - - - $str .= "\n"; - $str .= "\n".$PartitionType.""; - $str .= "\n".$FAIfsType.""; - $str .= "\n".$FAImountPoint.""; - $str .= "\n".$FAIpartitionSize.""; - $str .= "\n".$FAImountOptions.""; - $str .= "\n".$FAIfsOptions.""; - - $changeState = "onClick=\"changeState('FAImountPoint_".$key."') ; ". - "changeState('FAIpartitionSize_".$key."') ; ". - "changeState('FAImountOptions_".$key."') ; ". - "changeState('FAIfsType_".$key."') ; ". - "changeState('FAIfsOptions_".$key."') ; \""; - - if($this->acl_is_writeable("FAIpartitionFlags")){ - if($part['FAIpartitionFlags']!=false){ - $str .= "\n"; - }else{ - $str .= "\n"; - } - if($part['FAIencrypted']!=false){ - $str .= "\n"; - }else{ - $str .= "\n"; - } - }else{ - if($part['FAIpartitionFlags']!=false){ - $str .= ""._("False").""; - }else{ - $str .= ""._("True").""; - } - if($part['FAIencrypted']!=false){ - $str .= ""._("False").""; - }else{ - $str .= ""._("True").""; - } - } - if($this->acl_is_removeable()){ - $str .= "\n"; - }else{ - $str .= "\n"; - } - $str .= "\n"; - } - } - - if(!empty($str)){ - $str = "".$str."
"; - } - return($str); - - } - - function save() - { - $tmp = array(); - $tmp['cn'] = $this->DISKcn; - - /* Attach partitions */ - foreach($this->partitions as $key=>$val) { - if (isset($this->partitions[$key]['FAIencrypted']) && $this->partitions[$key]['FAIencrypted']){ - unset ($this->partitions[$key]['FAIencrypted']); - $this->partitions[$key]['FAIfsType']= "_".$this->partitions[$key]['FAIfsType']; - } - $this->partitions[$key]['FAIpartitionNr']=$key; - } - - /* Attach deleted */ - foreach($this->deletePartitions as $key=>$val) { - $this->partitions[$key."-delete"]=$val; - $this->partitions[$key."-delete"]['status']="delete"; - } - - $tmp['description'] = $this->DISKdescription; - $tmp['partitions'] = $this->partitions; - $tmp['status'] = $this->status; - - /* If hdd name has changed, tell partitionTable to rename it */ - if(($this->is_edit)&&($this->old_cn != $this->DISKcn)){ - $tmp['rename']['from'] = $this->old_cn; - $tmp['rename']['to'] = $this->DISKcn; - } - return($tmp); - } - - - /* Save data to object */ - function save_object() - { - - - if((isset($_POST['TableEntryFrameSubmitted'])) && ($this->FAIstate != "freeze") ){ - plugin::save_object(); - - foreach($this->partitions as $key => $part){ - foreach($this->UsedAttrs as $attrs){ - - if($this->acl_is_writeable($attrs)){ - - if(isset($_POST[$attrs."_".$key])){ - $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key]; - }else{ - $this->partitions[$key][$attrs] = false; - } - } - } - - if($this->acl_is_writeable("FAIencrypted")){ - - if(isset($_POST["FAIencrypted_".$key])){ - $this->partitions[$key]["FAIencrypted"] = $_POST["FAIencrypted_".$key]; - }else{ - $this->partitions[$key]["FAIencrypted"] = false; - } - } - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Check for an empty disk name */ - if(empty($this->DISKcn)){ - $message[] = _("Please specify a valid disc name."); - } - - /* check every partition. - * if there is an invalid value defined, append an errorstr to message - */ - - /* Array that contain every partitionname mountpoint etc already assigned */ - $alreadyUsed = array(); - foreach($this->UsedAttrs as $attrs){ - $alreadyUsed[$attrs] = array(); - } - - foreach($this->partitions as $key => $part){ - - /* Skip all checks, if preserve is set */ - if($part['FAIpartitionFlags'] == "preserve"){ - $this->partitions[$key]['FAIfsType'] = "preserve"; - $this->partitions[$key]['FAIpartitionSize'] = "preserve"; - continue; - } - - if((in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint']))&&($part['FAIfsType']!="swap")){ - $message[]=sprintf(_("please enter a unique mount point for partition %s"),($key)); - } - - if($part['FAIfsType']!="swap" && $part['FAImountPoint'] != "-"){ - if((empty($part['FAImountPoint']))||(!((preg_match("/^\/.*/",$part['FAImountPoint']))||(preg_match("/^swap$/",$part['FAImountPoint']))))){ - $message[]=sprintf(_("Please enter a valid mount point for partition %s." ),($key)); - } - } - if($part['FAIfsType'] == "swap"){ - if(in_array($part['FAIfsType'],$alreadyUsed['FAIfsType'])){ - $message[]=sprintf(_("File system type 'swap' is already used, change file system type for partition %s."),$key); - } - } - if(($part['FAIfsType'] == "swap")&&(!empty($part['FAImountPoint']))&&($part['FAImountPoint']!="swap")){ - $message[]=_("Please use 'swap' as mount point, if 'swap' is used as fs-type."); - } - - $tmp = split("-",$part['FAIpartitionSize']); - switch (count($tmp)){ - case 0: - $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key)); - break; - case 1: - if (!is_id(is_id($tmp[0])) &&(!empty($tmp[1]))){ - $message[]= sprintf(_("Please enter a valid partition size for partition %s."),($key)); - } - break; - - case 2: - if((!is_id($tmp[0]))&&(!is_id($tmp[1])) &&(!empty($tmp[1]))){ - $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); - }elseif($tmp[0]>=$tmp[1]){ - $message[]=sprintf(_("Please enter a valid range for partition %s."),($key)); - } - break; - - default: - $message[]=sprintf(_("Please enter a range for partition size for partition %s."),($key)); - } - - foreach($this->UsedAttrs as $attrs){ - $alreadyUsed[$attrs][$key] = $part[$attrs]; - } - } - - $cnt = 0; - foreach($this->partitions as $key => $part){ - if($part['FAIpartitionType'] == "primary"){ - $cnt ++ ; - } - } - if($cnt > 3){ - $message[] = _("You have more than 3 primary partition table entries in your configuration, please check your configuration twice."); - } - - return ($message); - } - - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Partition table entry"), - "plDescription" => _("FAI partition table entry"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 27, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "DISKcn" => _("Name"), - "DISKdescription" => _("Description"), - "FAIpartitionType" => _("Partition type"), - "FAIpartitionNr" => _("Partition no."), - "FAIfsType" => _("File system type"), - "FAImountPoint" => _("Mount point"), - "FAIpartitionSize" => _("Partition size"), - "FAImountOptions" => _("Mount options"), - "FAIfsOptions" => _("File system options"), - "FAIencrypted" => _("File system encryption"), - "FAIpartitionFlags" => _("Partition flags")) - )); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiProfile.inc b/plugins/admin/fai/class_faiProfile.inc deleted file mode 100644 index 4b5daea9b..000000000 --- a/plugins/admin/fai/class_faiProfile.inc +++ /dev/null @@ -1,501 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description","FAIclass"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIprofile"); - - /* Specific attributes */ - var $old_cn = ""; - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $FAIclass = ""; // Classnames used for this profile - var $FAIclasses = array(); // Contains classname seperated in an array - var $FAIAllclasses = array(); // Contains all possible Classnames - var $ui ; - var $FAIstate = ""; - var $view_logged = FALSE; - - function faiProfile(&$config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - $ldap=$this->config->get_ldap_link(); - - $this->ui = get_userinfo(); - - /* Parse ldap attribute to get all assigned classes */ - $tmp = split(" ",$this->FAIclass); - $tmp2 = array(); - foreach($tmp as $class){ - if(!empty($class)){ - $tmp2[trim($class)] = trim($class); - } - } - - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - /* Sort assigned classes */ - if(is_array($tmp2)){ - foreach($tmp2 as $class){ - $this->FAIclasses[$class]=$class; - } - } - - $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTable","FAIpackageList"); - - /* Build filter */ - $filter= ""; - foreach ($categories as $cat){ - $filter.= "(objectClass=$cat)"; - } - - /* Get ldap connection */ - $base = $_SESSION['CurrentMainBase']; - $ldap->cd($base); - $sort = array(); - - /* search all FAI classes */ - $ldap->search("(|$filter)",array("*")); - while($attrs = $ldap->fetch()){ - - /* Sort by categorie */ - foreach($categories as $cat){ - if(in_array($cat,$attrs['objectClass'])){ - - /* Append entry */ - $this->FAIAllclasses[$attrs['cn'][0]][$cat]=$attrs; - - /* Create sort array, because the array above is a multidimensional array, and can't be sorted by php sorting functions*/ - $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; - } - } - } - - /* Sort the sort array */ - //ksort($sort); - - /* Reorder the FAIclasses array */ - foreach($sort as $name){ - $tmp[$name] =$this->FAIAllclasses[$name]; - } - - /* Assign sorted classes */ - $this->FAIAllclasses = array(); - $this->FAIAllclasses = $tmp; - - if($dn != "new"){ - $this->dn =$dn; - } - $this->old_cn = $this->cn; - } - - - /* Combine new array, used for up down buttons */ - function combineArrays($ar0,$ar1,$ar2) - { - $ret = array(); - if(is_array($ar0)) - foreach($ar0 as $ar => $a){ - $ret[$ar]=$a; - } - if(is_array($ar1)) - foreach($ar1 as $ar => $a){ - $ret[$ar]=$a; - } - if(is_array($ar2)) - foreach($ar2 as $ar => $a){ - $ret[$ar]=$a; - } - return($ret); - } - - - function acl_base_for_current_object($dn) - { - if($dn == "new"){ - if($this->dn == "new"){ - $dn= $_SESSION['CurrentMainBase']; - }else{ - $dn = $this->dn; - } - } - return($dn); - } - - - /* returns position in array */ - function getpos($atr,$attrs) - { - $i = 0; - foreach($attrs as $attr => $name) { - $i++; - if($attr == $atr){ - return($i); - } - } - return(-1); - } - - /* Transports the given Arraykey one position up*/ - function ArrayUp($atr,$attrs) - { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == 1))){ - $before = array_slice($attrs,0,($pos-2)); - $mitte = array_reverse(array_slice($attrs,($pos-2),2)); - $unten = array_slice($attrs,$pos); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - - /* Transports the given Arraykey one position down*/ - function ArrayDown($atr,$attrs) - { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == $cn))){ - $before = array_slice($attrs,0,($pos-1)); - $mitte = array_reverse(array_slice($attrs,($pos-1),2)); - $unten = array_slice($attrs,($pos+1)); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - /* class one position up */ - function catUp($id) - { - /* Get all cats depinding on current dir */ - $cats = $this->FAIclasses; - $this->FAIclasses =$this->ArrayUp($id,$cats); - } - - /* Class one position down */ - function catDown($id) - { - /* Get all cats depinding on current dir */ - $cats = $this->FAIclasses; - $this->FAIclasses =$this->ArrayDown($id,$cats); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","fai/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - $s_entry = ""; - $s_action = ""; - - /* Remove class name From list */ - $sort_once = false; - foreach($_POST as $name => $post){ - if(preg_match("/DEL_/i",$name) && $this->acl_is_writeable("FAIclass")){ - $s_action = "delete"; - $s_entry = preg_replace("/DEL_/","",$name); - $s_entry = base64_decode(preg_replace("/_.*$/","",$s_entry)); - }elseif(preg_match("/Add_class/i",$name)&& $this->acl_is_writeable("FAIclass")){ - $s_action = "add"; - }elseif(preg_match("/DelClass/i",$name) && $this->acl_is_writeable("FAIclass")){ - $s_action = "delete"; - $s_entry = $_POST['FAIclass']; - }elseif(preg_match("/AddClass/i",$name) && $this->acl_is_writeable("FAIclass")){ - $s_action = "add"; - } - - /* Check if a list element should be pushed one position up */ - if((preg_match("/sortup_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){ - $sort_once = true; - $val = preg_replace("/sortup_/","",$name); - $val = preg_replace("/_.*$/","",$val); - $val = base64_decode($val); - $this->catUp($val); - } - - /* Check if a list element should be pushed one position down */ - if((preg_match("/sortdown_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){ - $sort_once = true; - $val = preg_replace("/sortdown_/","",$name); - $val = preg_replace("/_.*$/","",$val); - $val = base64_decode($val); - $this->catDown($val); - } - - } - - if($s_action == "delete" && $this->acl_is_writeable("FAIclass")){ - unset($this->FAIclasses[$s_entry]); - } - - if($s_action == "add" && $this->acl_is_writeable("FAIclass")){ - $this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses); - $this->is_dialog =true; - } - - /* Save Dialog */ - if(isset($_POST['SaveSubObject'])){ - $this->dialog->save_object(); - $msgs= $this->dialog->check(); - if(count($msgs)){ - print_red($msgs); - }else{ - $ret = $this->dialog->save(); - foreach($ret as $class){ - $this->FAIclasses[$class] =$class; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - //ksort($this->FAIclasses); - } - } - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - $divlist =new divSelectBox("Profile"); - $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); - - /* item images */ - $objTypes['FAIhook'] = ""; - $objTypes['FAItemplate'] = ""; - $objTypes['FAIscript'] = ""; - $objTypes['FAIvariable'] = ""; - $objTypes['FAIpackageList'] = ""; - $objTypes['FAIpartitionTable'] = ""; - - /* Delete button */ - $actions = ""; - - /* Up down buttons */ - $linkupdown = " "; - $linkupdown.= ""; - - /* Append fai classes to divlist */ - if($this->acl_is_readable("FAIclass")){ - foreach($this->FAIclasses as $usedClass){ - $str = " "; - $act = ""; - - if(isset($this->FAIAllclasses[$usedClass])){ - foreach($this->FAIAllclasses[$usedClass] as $class => $obj){ - $str.= $objTypes[$class]; - } - } - - $field1 = array("string"=> $usedClass,"attach"=>""); - $field2 = array("string"=> $str,"attach"=>""); - if(($this->FAIstate != "freeze") && $this->acl_is_writeable("FAIclass")){ - $field3 = array("string"=> preg_replace("/%KEY%/",base64_encode($usedClass),$actions). - preg_replace("/%s/",base64_encode($usedClass),$linkupdown), - "attach"=>"style='border-right:none;'"); - }else{ - $field3 = array("string"=>" ", "attach"=>"style='border-right:none;'"); - } - $divlist->AddEntry(array($field1,$field2,$field3)); - } - } - - $smarty->assign("FAIclasses" ,$this->FAIclasses); - $smarty->assign("divlist" ,$divlist->DrawList()); - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - }else{ - $smarty->assign($attrs,($this->$attrs)); - } - } - - - $dn = $this->acl_base_for_current_object($this->dn); - $smarty->assign("sub_object_is_addable", - preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiScriptEntry")) && - !preg_match("/freeze/",$this->FAIstate)); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE)); - return($display); - } - - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $this->dn; - } - - new log("remove","fai/".get_class($this),$use_dn,$this->attributes); - prepare_to_save_FAI_object($use_dn,array(),true); - $this->handle_post_events("remove"); - } - - - /* Save data to object - */ - function save_object() - { - plugin::save_object(); - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(count($this->FAIclasses) == 0){ - $message[]=_("Please assign at least one class to this profile."); - } - - if(empty($this->cn)){ - $message[]=_("Please enter a valid name."); - } - - $ldap = $this->config->get_ldap_link(); - - $base = $_SESSION['faifilter']['branch']; - if($base == "main"){ - $base =$_SESSION['CurrentMainBase']; - } - $base = "ou=profiles,".$base; - - $ldap->cd($base); - if ($this->old_cn == ""){ - $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn."))",$base,array("*")); - } else { - $ldap->ls("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",$base,array("*")); - } - - if($ldap->count() || isset($this->FAIAllclasses[$this->cn])){ - $message[]=_("There is already a FAI object with this class name defined."); - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - $this->FAIclass = ""; - foreach($this->FAIclasses as $class){ - $this->FAIclass.=$class." "; - } - - $this->attrs['FAIclass']=trim($this->FAIclass); - - prepare_to_save_FAI_object($this->dn,$this->attrs); - - if($this->initially_was_account){ - new log("modify","fai/".get_class($this),$this->dn,$this->attributes); - }else{ - new log("create","fai/".get_class($this),$this->dn,$this->attributes); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/profile with dn '%s' failed."),$this->dn)); - - /* Do object tagging */ - $this->handle_object_tagging(); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/profile with dn '%s' failed."),$this->dn)); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Parse ldap attribute to get all assigned classes */ - $tmp = split(" ",$this->FAIclass); - $tmp2 = array(); - foreach($tmp as $class){ - if(!empty($class)){ - $tmp2[trim($class)] = trim($class); - } - } - - /* Sort assigned classes */ - if(is_array($tmp2)){ - foreach($tmp2 as $class){ - $this->FAIclasses[$class]=$class; - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Profile"), - "plDescription" => _("FAI profile"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 30, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name"), - "description" => _("Description"), - "FAIclass" => _("FAI classes")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiProfileEntry.inc b/plugins/admin/fai/class_faiProfileEntry.inc deleted file mode 100644 index 2d9b09764..000000000 --- a/plugins/admin/fai/class_faiProfileEntry.inc +++ /dev/null @@ -1,277 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array(); - var $objectclasses= array(); - - /* Array with available class names */ - var $FAIAllclasses = array(); - var $ui; - - function faiProfileEntry (&$config, $dn= NULL,$used=array(),$objects=false) - { - plugin::plugin ($config, $dn); - - /* Search only in fai tree */ - $base = "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - if($_SESSION['faifilter']['branch']!="main"){ - $base = $_SESSION['faifilter']['branch']; - } - - $this->ui = get_userinfo(); - - $filter = "(|(objectClass=FAIscript)(objectClass=FAItemplate)(objectClass=FAIhook)". - "(objectClass=FAIvariable)(objectClass=FAIpartitionTable)(objectClass=FAIpackageList))"; - - $FAI_objects = get_all_objects_for_given_base($base,$filter,true); - - /* Create array with categories to be able to sort different types of objects */ - $categories = array("FAIscript" => "faiScript", - "FAItemplate" => "faiTemplate", - "FAIhook" => "faiHook", - "FAIvariable" => "faiVariable", - "FAIpartitionTable" => "faiPartitionTable", - "FAIpackageList" => "faiPackageList"); - - /* Read out all objects from fai tree */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($base); - $sort=array(); - foreach($FAI_objects as $obj){ - - $ldap->cat($obj['dn']); - $attrs = $ldap->fetch(); - - /* Only use objects which have cn set */ - if((isset($attrs['cn'][0]))&&(!in_array($attrs['cn'][0],$used))){ - foreach($categories as $cat => $acl){ - if(in_array($cat,$attrs['objectClass'])){ - - $acl = $this->ui->get_permissions($attrs['dn'],"fai/".$acl); - - /* Append different types of objects */ - $this->FAIAllclasses[$attrs['cn'][0]]['objects'][$cat]=$cat; - - if(!isset($this->FAIAllclasses[$attrs['cn'][0]]['acl'])){ - $this->FAIAllclasses[$attrs['cn'][0]]['acl']=""; - } - $this->FAIAllclasses[$attrs['cn'][0]]['acl'].=$acl; - - /* Set selected status to false */ - $this->FAIAllclasses[$attrs['cn'][0]]['status']=false; - - $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; - } - } - } - } - - - $tmp = array(); - ksort($sort); - foreach($sort as $name){ - $tmp[$name] =$this->FAIAllclasses[$name]; - } - $this->FAIAllclasses = array(); - $this->FAIAllclasses = $tmp; - - /* If no search filter is set, create one */ - if (!is_global("SUBfaifilter")){ - $SUBfaifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'], "Sregex" => "*"); - $SUBfaifilter['SShowTemplates'] = true; - $SUBfaifilter['SShowScripts'] = true; - $SUBfaifilter['SShowHooks'] = true; - $SUBfaifilter['SShowVariables'] = true; - $SUBfaifilter['SShowPackages'] = true; - $SUBfaifilter['SShowPartitions']= true; - register_global("SUBfaifilter", $SUBfaifilter); - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - $SUBfaifilter = $_SESSION['SUBfaifilter']; - - /* If someone used the apply button, update searchfilter */ - if(isset($_POST['Sregex'])){ - foreach($SUBfaifilter as $key => $val){ - if(!isset($_POST[$key])){ - $SUBfaifilter[$key] = false; - }else{ - $SUBfaifilter[$key] =$_POST[$key]; - } - } - $SUBfaifilter['Sregex']= $_POST['Sregex']; - if(!strstr($SUBfaifilter['Sregex'],"*")){ - $SUBfaifilter['Sregex'] = $SUBfaifilter['Sregex']."*"; - } - } - - /* Save current searchfilter in session*/ - $_SESSION['SUBfaifilter']= $SUBfaifilter; - - /* Check if we used a checkboxe from the list, to select dselect an entry */ - foreach($_POST as $name => $value){ - foreach($this->FAIAllclasses as $class => $obj){ - $bclass = base64_encode($class); - if(isset($_POST["ON_PAGE_".$bclass])){ - if(isset($_POST['USE_'.$bclass])){ - $this->FAIAllclasses[$class]['status']=true; - }else{ - $this->FAIAllclasses[$class]['status']=false; - } - } - } - } - - /* Create different picture for each object type */ - $objTypes['FAIhook'] = " "; - $objTypes['FAItemplate'] = " "; - $objTypes['FAIscript'] = " "; - $objTypes['FAIvariable'] = " "; - $objTypes['FAIpackageList'] = " "; - $objTypes['FAIpartitionTable'] = " "; - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - }else{ - $smarty->assign($attrs,($this->$attrs)); - } - } - - /* Assign all filter attributes to smarty */ - foreach($SUBfaifilter as $key => $val){ - if(($key != "base")&&($key != "Sregex")){ - if($val){ - $smarty->assign($key."CHK", " checked "); - }else{ - $smarty->assign($key."CHK", ""); - } - }else{ - $smarty->assign($key,$val); - } - } - - /* Create a divlist to display all available class names with the depending object types */ - $divlist = new divlist("ProfileEntry"); - $divlist->SetPluginMode(); - $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); - $divlist->SetEntriesPerPage(0); - $divlist->SetHeader(array(array("string"=> _("Class name")), - array("string"=> _("Objects"),"attach"=>"style='border-right:0px;'"))); - - /* Action button allows us to delete an entry */ - $action = " - "; - - /* Check every single class name to match the current search filter */ - foreach($this->FAIAllclasses as $usedClass => $classes){ - - /* Skip those entries that we are not allowed to read. */ - if(!preg_match("/r/",$classes['acl'])){ - continue; - } - - $fi = str_replace("*",".*",$SUBfaifilter['Sregex']); - - $abort = true; - if(!preg_match("/".$fi."/",$usedClass)){ - $abort = false; - } - if((isset($classes['objects']['FAIscript']))&&($SUBfaifilter['SShowScripts'])){ - $abort = false; - } - if((isset($classes['objects']['FAItemplate']))&&($SUBfaifilter['SShowTemplates'])){ - $abort = false; - } - if((isset($classes['objects']['FAIhook']))&&($SUBfaifilter['SShowHooks'])){ - $abort = false; - } - if((isset($classes['objects']['FAIvariable']))&&($SUBfaifilter['SShowVariables'])){ - $abort = false; - } - if((isset($classes['objects']['FAIpartitionTable']))&&($SUBfaifilter['SShowPartitions'])){ - $abort = false; - } - if((isset($classes['objects']['FAIpackageList']))&&($SUBfaifilter['SShowPackages'])){ - $abort = false; - } - - if(!$abort){ - $str = ""; - foreach($classes['objects'] as $class => $obj){ - $str.= $objTypes[$obj]; - } - - /* Is this entry selected */ - if($classes['status']==true){ - $action_check = preg_replace("/%CHECK%/"," checked ",$action); - }else{ - $action_check = preg_replace("/%CHECK%/","",$action); - } - - /* Append to list */ - $field1 = array("string"=> str_replace("%KEY%",base64_encode($usedClass),$action_check).$usedClass,"attach"=>""); - $field2 = array("string"=> $str,"attach"=>"style='border-right:0px;'"); - $divlist->AddEntry(array($field1,$field2)); - } - } - - $smarty->assign("faihead" , ""); - $smarty->assign("failist" , $divlist->DrawList()); - $smarty->assign("infoimage" , get_template_path('images/info_small.png')); - $smarty->assign("launchimage" , get_template_path('images/small_filter.png')); - $smarty->assign("alphabet" , generate_alphabet()); - $smarty->assign("apply" , apply_filter(TRUE)); - $smarty->assign("search_image" , get_template_path('images/search.png')); - - $display.= $smarty->fetch(get_template_path('faiProfileEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - function save() - { - $tmp = array(); - foreach($this->FAIAllclasses as $class => $obj){ - if($obj['status']==true){ - $tmp[$class]=$class; - } - } - return($tmp); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc deleted file mode 100644 index 928aa0e94..000000000 --- a/plugins/admin/fai/class_faiScript.inc +++ /dev/null @@ -1,658 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIscript"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAIscriptEntry"; - var $subClasses = array("top","FAIclass","FAIscriptEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = "faiScriptEntry"; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAIpriority"); - var $sub_Load_Later = array("FAIscript"); - var $sub64coded = array(); - var $subBinary = array("FAIscript"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $SubObjects = array(); // All leafobjects of this object - - var $FAIstate = ""; - var $sort_by = "name"; - var $sort_order = "up"; - - var $view_logged = FALSE; - var $ui; - - function faiScript (&$config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. - */ - if($dn != "new"){ - - $this->dn =$dn; - - /* Get FAIstate - */ - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - $objects = array(); - $objects['status'] = "FreshLoaded"; - $objects['dn'] = $object['dn']; - $objects = $this->get_object_attributes($objects,$this->subAttributes); - $this->SubObjects[$objects['cn']] = $objects; - } - - } - $this->ui = get_userinfo(); - } - - - /* Reload some attributes */ - function get_object_attributes($object,$attributes) - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($object['dn'],$attributes); - $tmp = $ldap->fetch(); - - foreach($attributes as $attrs){ - if(isset($tmp[$attrs][0])){ - $var = $tmp[$attrs][0]; - - /* Check if we must decode some attributes */ - if(in_array_ics($attrs,$this->sub64coded)){ - $var = base64_decode($var); - } - - /* check if this is a binary entry */ - if(in_array_ics($attrs,$this->subBinary)){ - $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0); - } - - /* Fix slashes */ - $var = addslashes($var); - $object[$attrs] = $var; - } - } - return($object); - } - - - /* Return a valid dn to fetch acls. Because 'new' will not work. */ - function acl_base_for_current_object($dn) - { - if($dn == "new"){ - if($this->dn == "new"){ - $dn= "cn=dummy,".$_SESSION['CurrentMainBase']; - }else{ - $dn = $this->dn; - } - } - return($dn); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","fai/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Add new sub object */ - if(isset($_POST['AddSubObject'])){ - $this->dialog= new $this->subClassName($this->config,"new"); - $this->dialog->set_acl_base($this->acl_base); - $this->dialog->set_acl_category("fai"); - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - - if($this->dn != "new"){ - $_SESSION['objectinfo']= $this->dn; - } - - /* Handle posts */ - $s_action = $s_entry = ""; - foreach($_POST as $name => $value){ - - /* Edit script posted */ - if(preg_match("/^editscript_/",$name)){ - $s_action = "edit"; - $s_entry = preg_replace("/^editscript_/","",$name); - $s_entry = base64_decode(preg_replace("/_.*/","",$s_entry)); - break; - } - - /* Delete script requested */ - if(preg_match("/^deletescript_/",$name)){ - $s_action = "remove"; - $s_entry = preg_replace("/^deletescript_/","",$name); - $s_entry = base64_decode(preg_replace("/_.*/","",$s_entry)); - break; - } - } - - if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ - $s_entry = $_GET['id']; - if(isset($this->SubObjects[$s_entry])){ - $s_action = "edit"; - } - } - - if($s_action =="edit" && isset($this->SubObjects[$s_entry])){ - - /* Get object, and load missing entry values */ - $obj = $this->SubObjects[$s_entry]; - if($obj['status'] == "FreshLoaded"){ - $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); - } - - /* Create new dialog and set acl attributes */ - $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); - $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn'])); - $this->dialog->set_acl_category("fai"); - - /* Assign some additional dialog informations like headline and parent */ - $_SESSION['objectinfo'] = $obj['dn']; - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - - /* Check acls, are we allowed to delete an entry */ - if($s_action == "remove" && isset($this->SubObjects[$s_entry])){ - $entry = $this->SubObjects[$s_entry]; - $acl = $this->ui->get_permissions($this->acl_base_for_current_object($entry['dn']),"fai/faiScriptEntry") ; - if(preg_match("/d/",$acl)){ - $status = $entry['status']; - if($status == "edited" || $status == "FreshLoaded"){ - $this->SubObjects[$s_entry]['status']= "delete"; - }else{ - unset($this->SubObjects[$s_entry]); - } - } - } - - /* Save the edited entry */ - if(isset($_POST['SaveSubObject'])){ - - /* Check if there are still errors remaining that must be fixed before saving */ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)>0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - - /* Get return object */ - $obj = $this->dialog->save(); - - /* If we have renamed the script entry, we must remove the old entry */ - if(isset($obj['remove'])){ - - /* Get old entry values */ - $old_stat = $this->SubObjects[$obj['remove']['from']]['status']; - - /* Depending on status, set new status */ - if($old_stat == "edited" || $old_stat == "FreshLoaded"){ - $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ - unset($this->SubObjects[$obj['remove']['from']]); - } - - /* Append the new entry */ - $obj['status'] = "new"; - $this->SubObjects[$obj['remove']['to']] = $obj; - unset($this->SubObjects[$obj['remove']['to']]['remove']); - }else{ - - /* Set new status and append the entry */ - if($obj['status'] == "FreshLoaded"){ - $obj['status'] = "edited"; - } - $this->SubObjects[$obj['cn']]=$obj; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - - } - } - - /* Sort entries */ - $tmp = $keys = array(); - - if($this->sort_by == "name"){ - foreach($this->SubObjects as $key => $entry){ - $keys[$key]=$entry['cn']; - } - }elseif($this->sort_by == "priority"){ - foreach($this->SubObjects as $key => $entry){ - $keys[$key]=$entry['FAIpriority']; - } - } - - natcasesort($keys); - - if($this->sort_order == "down"){ - $keys =array_reverse($keys); - } - - foreach($keys as $key => $order_var){ - $tmp[$key]=$this->SubObjects[$key]; - } - $this->SubObjects = $tmp; - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - - /* Print dialog if $this->dialog is set */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return($display); - } - - /* Divlist added 23.02.2006 - Containing FAIscripts - */ - $divlist = new divlist("FAIscripts"); - $divlist->SetEntriesPerPage(0); - $plug = $_GET['plug']; - - if($this->sort_order == "up"){ - $dir = "\/"; - }else{ - $dir = "/\"; - } - - if($this->sort_by == "name"){ - $sort_name = $dir; - $sort_prio = ""; - }else{ - $sort_name = ""; - $sort_prio = $dir; - } - - $divlist->SetHeader(array( array("string"=>""._("Name").$sort_name.""), - array("string"=>"".$sort_prio._("Priority")."", - "attach"=>"style='width:100px;'"), - array("string"=>_("Download"), - "attach"=>"style='width:100px;'"), - array("string"=>_("Action"), - "attach"=>"style='border-right: 0px;width:100px;text-align:right;'"))); - $divlist->SetHeight(300); - $divlist->SetWidth("100%"); - foreach($this->getList(true) as $key => $name){ - - $dn= $this->acl_base_for_current_object($name['dn']); - $acl = $this->ui->get_permissions($dn,"fai/faiScriptEntry") ; - $act = ""; - - /* Hide delete icon if this object is freezed */ - if($this->FAIstate == "freeze"){ - $act .= ""; - }else{ - $act .= ""; - if(preg_match("/d/",$acl)){ - $act .=""; - } - } - - /* Check acls for download icon */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiScriptEntry","FAIscript") ; - if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){ - $down = ""; - }else{ - $down = " - "._("Download")." - "; - } - - /* Check if we are allowed to view this object */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiScriptEntry","cn") ; - if(preg_match("/r/",$s_acl)){ - $divlist->AddEntry(array( array("string"=>"".$name['name'].""), - array("string"=>$name['FAIpriority'] , "attach" => "style='width:100px;'"), - array("string"=>$down , "attach" => "style='width:100px;'"), - array("string"=>str_replace("%s",base64_encode($key),$act), - "attach"=>"style='border-right: 0px;width:100px;text-align:right;'"))); - } - } - $smarty->assign("Entry_divlist",$divlist->DrawList()); - - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - }else{ - $smarty->assign($attrs,($this->$attrs)); - } - } - - $dn = $this->acl_base_for_current_object($this->dn); - $smarty->assign("sub_object_is_addable", - preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiScriptEntry")) && - !preg_match("/freeze/",$this->FAIstate)); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $display.= $smarty->fetch(get_template_path('faiScript.tpl', TRUE)); - return($display); - } - - /* Generate listbox friendly SubObject list - */ - function getList($use_dns=false){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - if($use_dns){ - if((isset($obj['description']))&&(!empty($obj['description']))){ - $a_return[$obj['cn']]['name']= $obj['cn']." [".stripslashes($obj['description'])."]"; - }else{ - $a_return[$obj['cn']]['name']= $obj['cn']; - } - $a_return[$obj['cn']]['dn']= $obj['dn']; - $a_return[$obj['cn']]['FAIpriority']= $obj['FAIpriority']; - }else{ - if((isset($obj['description']))&&(!empty($obj['description']))){ - $a_return[$obj['cn']]= $obj['cn']." [".stripslashes($obj['description'])."]"; - }else{ - $a_return[$obj['cn']]= $obj['cn']; - } - } - } - } - return($a_return); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - if($this->acl_is_removeable()){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $this->dn; - } - - new log("remove","fai/".get_class($this),$use_dn,$this->attributes); - - prepare_to_save_FAI_object($use_dn,array(),true); - - foreach($this->SubObjects as $name => $obj){ - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $obj['dn']; - } - prepare_to_save_FAI_object($use_dn,array(),true); - } - $this->handle_post_events("remove"); - } - } - - - /* Save data to object - */ - function save_object() - { - if((isset($_POST['FAIscript_posted'])) && ($this->FAIstate != "freeze")){ - plugin::save_object(); - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - } - } - } - - /* Get sort order */ - if(isset($_GET['sort']) && in_array($_GET['sort'],array("name","priority"))){ - if($this->sort_by == $_GET['sort']){ - if($this->sort_order == "up"){ - $this->sort_order = "down"; - }elseif($this->sort_order == "down"){ - $this->sort_order = "up"; - } - } - $this->sort_by = $_GET['sort']; - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - prepare_to_save_FAI_object($this->dn,$this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Creating of FAI/script with dn '%s' failed."),$this->dn)); - - if($this->initially_was_account){ - new log("modify","fai/".get_class($this),$this->dn,$this->attributes); - }else{ - new log("create","fai/".get_class($this),$this->dn,$this->attributes); - } - - /* Do object tagging */ - $this->handle_object_tagging(); - - /* Prepare FAIscriptEntry to write it to ldap - * First sort array. - * Because we must delete old entries first. - * After deletion, we perform add and modify - */ - $Objects = array(); - - /* We do not need to save untouched objects */ - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "FreshLoaded"){ - unset($this->SubObjects[$name]); - } - } - - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - - foreach($Objects as $name => $obj){ - - foreach($this->sub64coded as $codeIt){ - $obj[$codeIt]=base64_encode(stripslashes($obj[$codeIt])); - } - - $tmp = array(); - $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); - foreach($attributes as $attrs){ - - if(empty($obj[$attrs])){ - $obj[$attrs] = array(); - } - if(!is_array($obj[$attrs])){ - $tmp[$attrs] = stripslashes($obj[$attrs]); - }else{ - $tmp[$attrs] = $obj[$attrs]; - } - } - - $tmp['objectClass'] = $this->subClasses; - - $sub_dn = "cn=".$obj['cn'].",".$this->dn; - - if($obj['status']=="new"){ - $ldap->cat($sub_dn,array("objectClass")); - if($ldap->count()){ - $obj['status']="edited"; - } - } - - if(empty($tmp['FAIpriority'])){ - $tmp['FAIpriority'] ="0"; - } - - /* Check if gosaAdministrativeUnitTag is required as object class */ - if($obj['status'] == "edited"){ - $ldap->cat($sub_dn,array("objectClass")); - $attrs = $ldap->fetch(); - if(isset($attrs['objectClass'])){ - if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ - $tmp['objectClass'][] = "gosaAdministrativeUnitTag"; - } - } - } - - if($obj['status'] == "delete"){ - prepare_to_save_FAI_object($sub_dn,array(),true); - $this->handle_post_events("remove"); - }elseif($obj['status'] == "edited"){ - prepare_to_save_FAI_object($sub_dn,$tmp); - $this->handle_post_events("modify"); - }elseif($obj['status']=="new"){ - prepare_to_save_FAI_object($sub_dn,$tmp); - $this->handle_post_events("add"); - } - - $this->handle_object_tagging($sub_dn, $this->gosaUnitTag); - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - $objects = array(); - $objects['status'] = "edited"; - $objects['dn'] = $object['dn']; - $objects = $this->get_object_attributes($objects,$this->subAttributes); - $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); - - $this->SubObjects[$objects['cn']] = $objects; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Script"), - "plDescription" => _("FAI script"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 18, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name")." ("._("Readonly").")", - "description" => _("Description")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiScriptEntry.inc b/plugins/admin/fai/class_faiScriptEntry.inc deleted file mode 100644 index 032132920..000000000 --- a/plugins/admin/fai/class_faiScriptEntry.inc +++ /dev/null @@ -1,198 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("cn","description","FAIpriority","FAIscript"); - var $objectclasses= array(); - - var $orig_cn = ""; - - var $dn = ""; - var $cn = ""; - var $FAIpriority = "0"; - var $FAIscript = ""; - var $description = ""; - var $status = "new"; - var $parent = NULL; - var $FAIstate = ""; - - function faiScriptEntry (&$config, $dn= NULL,$object=false) - { - plugin::plugin ($config, $dn); - if($dn != "new"){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = $name; - $this->$oname=$value; - } - - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - }else{ - if(is_array($object)&&count($object)){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = $name; - $this->$oname=$value; - } - }else{ - - $this->status = "new"; - $this->orig_cn = false; - } - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - if(isset($_POST['ImportUpload']) && $this->acl_is_writeable("FAIscript")){ - if(($_FILES['ImportFile']['error']!=0)){ - print_red(_("Please select a valid file.")); - }else - if(($_FILES['ImportFile']['size']==0)){ - print_red(_("Selected file is empty.")); - }else{ - $str = utf8_encode(addslashes(file_get_contents($_FILES['ImportFile']['tmp_name']))); - $this->FAIscript = $str; - } - } - - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - }else{ - $smarty->assign($attrs,($this->$attrs)); - } - } - - /* Create download button*/ - if($this->dn != "new" && $this->acl_is_readable("FAIscript")){ - $smarty->assign("DownMe"," - - "); - }else{ - $smarty->assign("DownMe",""); - } - - for($i =0 ; $i < 100 ; $i++){ - $FAIprioritys[$i]=$i; - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $acl = $this->getacl($name); - if($this->FAIstate == "freezed"){ - $acl = preg_replace("/w/","",$acl); - } - $smarty->assign($name."ACL",$acl); - } - - $smarty->assign("FAIprioritys",$FAIprioritys); - if(get_magic_quotes_gpc()){ - $smarty->assign("FAIscript" , htmlentities(stripslashes($this->FAIscript))); - }else{ - $smarty->assign("FAIscript" , htmlentities($this->FAIscript)); - } - $display.= $smarty->fetch(get_template_path('faiScriptEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ - foreach($this->attributes as $attrs){ - if($this->acl_is_writeable($attrs)){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - }else{ - $this->$attrs = ""; - } - } - } - } - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ - $message[] =_("There is already a script with the given name."); - } - - if(empty($this->cn)){ - $message[] = _("Please enter a name."); - } - - if(empty($this->FAIscript)){ - $message[]=_("Please enter a script."); - } - - return ($message); - } - - function save() - { - $tmp=array(); - foreach($this->attributes as $attrs){ - $tmp[$attrs] = $this->$attrs; - } - - /* Strip out dos newlines */ - $tmp['FAIscript']= strtr($this->FAIscript, array("\x0D" => "")); - - if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ - $tmp['remove']['from'] = $this->orig_cn; - $tmp['remove']['to'] = $tmp['cn']; - } - - $tmp['dn'] = $this->dn; - $tmp['status'] = $this->status; - return($tmp); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Script entry"), - "plDescription" => _("FAI script entry"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 19, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name"), - "description" => _("Description"), - "FAIscript" => _("Script entry"), - "FAIpriority" => _("Script Priority")) - )); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiSummaryTab.inc b/plugins/admin/fai/class_faiSummaryTab.inc deleted file mode 100644 index a9bfbb840..000000000 --- a/plugins/admin/fai/class_faiSummaryTab.inc +++ /dev/null @@ -1,583 +0,0 @@ -ui = get_userinfo(); - - /* Base object configuration */ - $this->objs = array( - "FAIscript" => array( "Image" =>"images/fai_script.png", "Name"=>_("Scripts") ,"Tree" =>"ou=scripts,") , - "FAIhook" => array( "Image" =>"images/fai_hook.png" , "Name"=>_("Hooks") ,"Tree" =>"ou=hooks,"), - "FAIvariable" => array( "Image" =>"images/fai_variable.png", "Name"=>_("Variables") ,"Tree" =>"ou=variables,") , - "FAItemplate" => array( "Image" =>"images/fai_template.png", "Name"=>_("Templates") ,"Tree" =>"ou=templates,") , - "FAIpartitionTable" => array( "Image" =>"images/fai_partitionTable.png","Name"=>_("Partition table") ,"Tree" =>"ou=disk,") , - "FAIpackageList" => array( "Image" =>"images/fai_packages.png", "Name"=>_("Package list") ,"Tree" =>"ou=packages,") , - "FAIprofile" => array( "Image" =>"images/fai_profile.png", "Name"=>_("Profiles") ,"Tree" =>"ou=profiles,")); - } - - - /* Init the fai tree with objects. - If this method is called, all assigned classes and the release name - will be read from parent object. */ - function init() - { - $this->InitCalled = true; - $this->Result = array(); - $_SESSION['faiSummaryTab']['UniqueID'] = 0; - - /* Get classes & release name - There are 2 different tabs which use the summary tab - faiProfile / Workstations */ - - /* Check if given parent object is fai profile tabs */ - if(isset($this->parent->by_name['faiProfile'])){ - - /* Get Classes and release */ - $this->Classes = $this->parent->by_object['faiProfile']->FAIclasses; - $this->base = $this->parent->by_object['faiProfile']->base; - $str = preg_replace("/^.*ou=profiles,/","",$this->dn); - - /* Check if parent tab is work tab */ - }elseif(isset($this->parent->by_name['workstartup'])){ - $this->Classes = $this->parent->by_object['workstartup']->FAIclass; - $this->Release = $this->parent->by_object['workstartup']->FAIrelease; - - /* Check if this is a workstation or an object group */ - if(isset($this->parent->by_object['workgeneric'])){ - $this->base = $this->parent->by_object['workgeneric']->base; - }elseif(isset($this->parent->by_object['ogroup'])){ - $this->base = $this->parent->by_object['ogroup']->base; - }elseif(isset($this->parent->by_object['servgeneric'])){ - $this->base = $this->parent->by_object['servgeneric']->base; - }else{ - print_red(_("Unknown type of FAI source information. This is not a profile, workstation nor a ogroup.")); - } - - /* Append workstation class && LAST */ - if(isset($this->parent->by_object['workgeneric']->cn)){ - $this->Classes[] = $this->parent->by_object['workgeneric']->cn; - } - } - - $tmp = array_flip($this->getBranches()); - - $this->Classes[] = "LAST"; - - /* You need full access to complete collection of fai acls to view this summary */ - $acl = $this->ui->has_complete_category_acls($this->base,"fai"); - if(!preg_match("/r/",$acl)){ - $this->Classes = array(); - } - - /* Set all available releases */ - $this->Releases = $tmp; - $this->usedClasses = array(); - - /* Check the configuration */ - if(count($this->Classes) && (!empty($this->Release))){ - foreach($this->Classes as $class){ - $this->resolveObject($class); - } - } - } - - - /* Capture posts, and call opnen close tag */ - function save_object() - { - $once = true; - - if(isset($_GET['expand']) && isset($_GET['id'])){ - if(isset($this->Result[$_GET['id']])){ - $this->Result[$_GET['id']]['Open'] =true ; - } - } - - if(isset($_GET['compress']) && isset($_GET['id'])){ - if(isset($this->Result[$_GET['id']])){ - unset($this->Result[$_GET['id']]['Open']); - } - } - - foreach($_POST as $name => $value ){ - - /* check for open tag request */ - if(preg_match("/^open_/",$name) && $once){ - $once = false; - $value = preg_replace("/^open_/","",$name); - $value = preg_replace("/_.*$/","",$value); - $this->Result[$value]['Open'] =true ; - } - /* Check for close tag request */ - if(preg_match("/^close_/",$name) && $once){ - $once = false; - $value = preg_replace("/^close_/","",$name); - $value = preg_replace("/_.*$/","",$value); - unset($this->Result[$value]['Open']); - } - if(preg_match("/^reloadList/",$name)){ - $this->InitCalled = false; - } - } - } - - - /* returns an array with all possibly release types */ - function getBranches($base = false,$prefix = "") - { - if(!$base){ - $base = $this->base; - } - return(get_all_releases_from_base($base,true)); - } - - - /* This function calls all nescessary functions to generate the fai class summary tree */ - function execute() - { - - /* Skip this if fai is deactivated */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(empty($tmp)){ - $str = "

"._("You can't use this plugin until FAI is activated.")."

"; - return $str; - } - - /* Check if we must (re)init the this tab */ - if(!$this->InitCalled){ - $this->init(); - } - - if(isset($_GET['show'])){ - $ldap = $this->config->get_ldap_link(); - $ldap->cat(base64_decode($_GET['id']), array('FAIscript', 'FAIhook', 'FAItemplateFile')); - $attrs = $ldap->fetch(); - if($_GET['type'] == "FAIscript"){ - $str = $attrs['FAIscript'][0]; - }elseif($_GET['type'] == "FAIhook"){ - $str = $attrs['FAIscript'][0]; - }elseif($_GET['type'] == "FAItemplate"){ - $str = $attrs['FAItemplateFile'][0]; - } - echo "
".$str."
"; - exit(); - } - - /* Get smarty class & assign created summary results */ - $smarty = get_smarty(); - $acl = $this->ui->has_complete_category_acls($this->base,"fai"); - $smarty->assign("readable", preg_match("/r/",$acl)); - - $this->ObjectList = $this->createSummary($this->Result); - $smarty->assign("objectList",$this->ObjectList); - return($smarty->fetch (get_template_path('faiSummary.tpl', TRUE, dirname(__FILE__)))); - } - - - /* Create output of from resolved fai objects */ - function createSummary($data) - { - /* Don't generate any output, if there is no result */ - $str =" "; - if(!count($this->Result)){ - $str.="
"; - $str.= (_("This object has no FAI classes assigned.")); - $str.= "
"; - return($str); - } - - /* walk through all classes */ - foreach($data as $key => $entry){ - - $image = "".$this->objs[$key]["; - if(!isset($entry['Open'])){ - $str .= " - - - "._("Open")." "; - $str .= $image." "; - $str .= " ".$this->objs[$key]['Name'].""; - }else{ - $str .= " - - "._("Close")." "; - $str .= $image." "; - $str .= "".$this->objs[$key]['Name'].""; - - /* Display FAItemplate FAIhook FAIscript entries */ - if(in_array($key,array("FAItemplate","FAIhook","FAIscript"))){ - - $nums = array(); - $tmp = array(); - if($key == "FAIscript"){ - if(is_array($entry['Entries'])){ - foreach($entry['Entries'] as $scripts){ - foreach($scripts as $script){ - - if(!isset($nums[$script['cn'][0]])){ - $nums[$script['cn'][0]]= 0; - } - $nums[$script['cn'][0]] ++; - - $tmp[$script['FAIpriority'][0].$script['cn'][0].$script['CLASS']] = $script; - } - } - } - krsort($tmp);; - - $entry['Entries'] = $tmp; - }else{ - $tmp = array(); - foreach($entry['Entries'] as $script){ - $tmp[$script['cn'][0].$script['CLASS']] = $script; - if(!isset($nums[$script['cn'][0]])){ - $nums[$script['cn'][0]]= 0; - } - $nums[$script['cn'][0]] ++; - } - ksort($tmp); - $entry['Entries'] = $tmp; - } - - foreach($entry['Entries'] as $cn => $data){ - - if(isset($nums[$data['cn'][0]]) && ($nums[$data['cn'][0]] > 1)){ - $str .=""; - }else{ - $str .=""; - } - - $str .= ""; - $str .= $image." "; - if(isset($data['FAIpriority'][0])){ - $str .= "(".$data['FAIpriority'][0].")"; - } - - $str .= " ".$data['cn'][0]; - if(isset($data['description'][0])){ - $str .= " [".$data['description'][0]."]"; - } - $str .= ""; - $str .= "".$data['CLASS'].""; - $str .= ""; - } - } - - /* Create variable entries */ - if(in_array($key,array("FAIvariable"))) { - foreach($entry['Entries'] as $cn => $data){ - $str .=""; - $str .= $image." ".$data['cn'][0]; - if(isset($data['description'][0])){ - $str .= " [".$data['description'][0]."] "; - } - /* Only display FAIvariableContent if description dosn't contain [*] */ - if(isset($data['description'][0]) && !preg_match("#\[\*\]#",$data['description'][0])){ - $str .=" = '".$data['FAIvariableContent'][0]."'"; - } - $str .= "".$data['CLASS'].""; - $str .=""; - } - } - - /* Create packagelist entries */ - if(in_array($key,array("FAIpackageList"))) { - ksort($entry['Entries']); - foreach($entry['Entries'] as $data){ - $str .=""; - $str .= $image." ".$data['cn'][0]; - $str .= "".$data['CLASS'].""; - $str .= "";; - } - } - - /* Create partition table entries */ - if(in_array($key,array("FAIpartitionTable"))) { - foreach($entry['Entries'] as $cn => $data){ - $str .= ""; - $str .= $image." ".$data['name']; - $str .= "".$data['CLASS'].""; - $str .= ""; - ksort($data['partitions']); - - $str .= ""; - $str .= " - - - - - - - - - "; - - $i = 0; - foreach($data['partitions'] as $key => $part){ - $i ++; - - if($i%2 == 1){ - $c = " class='rowxp1'"; - $d = " class='list1'"; - }else{ - $c = " class='rowxp0'"; - $d = " class='list0'"; - } - - $str.=" - - - - - - - - "; - } - $str .="
"._("No.").""._("Name").""._("FS options").""._("Mount options").""._("Size in MB").""._("Mount point").""._("Type")."
".$i."".$part['cn'][0]."".$part['FAIfsType'][0]."".$part['FAIfsOptions'][0]."".$part['FAIpartitionSize'][0]."".$part['FAImountPoint'][0]."".$part['FAIpartitionType'][0]."
"; - } - } - } - } - $str .=""; - return($str); - } - - - /* resolve specified object to append it to our object tree */ - function resolveObject($class) - { - $ldap = $this->config->get_ldap_link(); - $dn = $this->Releases [$this->Release]; - $resolvedClasses = get_all_objects_for_given_base($dn,"(&(objectClass=FAIclass)(cn=".$class."))"); - - /* Try to fetch all types of fai objects with the given cn */ - foreach($resolvedClasses as $obj){ - - $dn = $obj['dn']; - $ldap->cat($dn); - - while($attrs = $ldap->fetch()){ - - foreach($this-> objs as $key => $rest){ - if(in_array($key,$attrs['objectClass'])){ - - if(!isset($this->usedClasses[$key][$class])){ - $this->usedClasses[$key][$class] = true; - switch($key){ - case "FAIprofile": $this->prepare_FAIprofile($attrs);break; - case "FAIscript": $this->prepare_FAIscript($attrs);break; - case "FAIhook": $this->prepare_FAIhook($attrs);break; - case "FAIvariable": $this->prepare_FAIvariable($attrs);break; - case "FAItemplate": $this->prepare_FAItemplate($attrs);break; - case "FAIpackageList": $this->prepare_FAIpackageList($attrs);break; - case "FAIpartitionTable": $this->prepare_FAIpartitionTable($attrs);break; - } - } - - } - } - } - } - } - - /* Prepare fai script */ - function prepare_FAIscript($data) - { - if(isset($this->Result['FAIscript']['Entries'])){ - $current = $this->Result['FAIscript']['Entries']; - }else{ - $current = array(); - } - $ldap = $this->config->get_ldap_link(); - $ldap->cd($data['dn']); - $ldap->search("(objectClass=FAIscriptEntry)",array("cn","description","FAIpriority")); - while($attrs = $ldap->fetch()){ - $attrs['CLASS'] = $data['cn'][0]; - $current[$attrs['FAIpriority'][0]][] = $attrs; - } - $this->Result['FAIscript']['Entries'] = $current ; - } - - - /* Prepare fai script */ - function prepare_FAIpartitionTable($data) - { - if(isset($this->Result['FAIpartitionTable']['Entries'])){ - $current = $this->Result['FAIpartitionTable']['Entries']; - }else{ - $current = array(); - } - - /* get subentries */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($data['dn']); - $ldap->search("(objectClass=FAIpartitionDisk)",array("cn","description")); - $disks = array(); - - /* Create an array which is sortable by priority */ - while($attrs = $ldap->fetch()){ - $attrs['CLASS'] = $data['cn'][0]; - $disks[$attrs['cn'][0]]= $attrs; - if(isset($attrs['description'][0])){ - $disks[$attrs['cn'][0]]['name'] = $attrs['cn'][0]." [".$attrs['description'][0]."]"; - }else{ - $disks[$attrs['cn'][0]]['name'] = $attrs['cn'][0]; - } - $disks[$attrs['cn'][0]]['dn'] = $attrs['dn']; - $disks[$attrs['cn'][0]]['partitions'] = array(); - } - - /* Sort by priority */ - foreach($disks as $key => $disk){ - $ldap->cd($disk['dn']); - $ldap->search("(objectClass=FAIpartitionEntry)",array("*")); - while($attrs = $ldap->fetch()){ - if(!isset($attrs['FAIfsOptions'][0])){ - $attrs['FAIfsOptions'][0] = ""; - } - $attrs['CLASS'] = $data['cn'][0]; - $disks[$key]['partitions'][$attrs['cn'][0]] = $attrs; - } - } - $this->Result['FAIpartitionTable']['Entries'] = $disks; - } - - - /* Create template entry */ - function prepare_FAItemplate($data) - { - $current = array(); - if(isset($this->Result['FAItemplate']['Entries'])){ - $current = $this->Result['FAItemplate']['Entries']; - } - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($data['dn']); - $ldap->search("(objectClass=FAItemplateEntry)",array("cn","description")); - while($attrs = $ldap->fetch()){ - $attrs['CLASS'] = $data['cn'][0]; - $current[] = $attrs; - } - $this->Result['FAItemplate']['Entries'] = $current ; - } - - - /* Create a package list */ - function prepare_FAIpackageList($data) - { - $current = array(); - if(isset($this->Result['FAIpackageList']['Entries'])){ - $current = $this->Result['FAIpackageList']['Entries']; - } - if(isset($data['FAIpackage'])){ - unset($data['FAIpackage']['count']); - foreach($data['FAIpackage'] as $pkg){ - $attrs['CLASS'] = $data['cn'][0]; - $attrs['cn'][0] = $pkg; - $current[$pkg] = $attrs; - } - } - $this->Result['FAIpackageList']['Entries'] = $current ; - } - - - /* Create a variable entry */ - function prepare_FAIvariable($data) - { - $current = array(); - if(isset($this->Result['FAIvariable']['Entries'])){ - $current = $this->Result['FAIvariable']['Entries']; - } - $ldap = $this->config->get_ldap_link(); - $ldap->cd($data['dn']); - $ldap->search("(objectClass=FAIvariableEntry)",array("cn","description","FAIvariableContent")); - while($attrs = $ldap->fetch()){ - $attrs['CLASS'] = $data['cn'][0]; - $current[] = $attrs; - } - $this->Result['FAIvariable']['Entries'] = $current ; - } - - /* Create a hook entry */ - function prepare_FAIhook($data) - { - $current = array(); - if(isset($this->Result['FAIhook']['Entries'])){ - $current = $this->Result['FAIhook']['Entries']; - } - $ldap = $this->config->get_ldap_link(); - $ldap->cd($data['dn']); - $ldap->search("(objectClass=FAIhookEntry)",array("cn","description")); - while($attrs = $ldap->fetch()){ - $attrs['CLASS'] = $data['cn'][0]; - $current[$attrs['cn'][0]] = $attrs; - } - $this->Result['FAIhook']['Entries'] = $current ; - } - - - /* Create a new Profile entry */ - function prepare_FAIprofile($data) - { - $classes = split("\ ",$data['FAIclass'][0]); - foreach($classes as $class){ - $class = trim($class); - $this->resolveObject($class); - } - } - - /* Return plugin informations for acl handling * / - static function plInfo() - { - return (array( - "plShortName" => _("Summary"), - "plDescription" => _("FAI summary"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 15, - "plSection" => array("administration"), - "plCategory" => array("workstation","server","fai","ogroups") , - "plProvidedAcls"=> array( - "readable" => _("Viewable")), - )); - } - */ -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiTemplate.inc b/plugins/admin/fai/class_faiTemplate.inc deleted file mode 100644 index 5f4fcbf14..000000000 --- a/plugins/admin/fai/class_faiTemplate.inc +++ /dev/null @@ -1,579 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAItemplate"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAItemplateEntry"; - var $subClasses = array("top","FAIclass","FAItemplateEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = "faiTemplateEntry"; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAItemplatePath","FAIowner","FAImode"); - var $sub_Load_Later = array("FAItemplateFile"); - var $sub64coded = array(); - var $subBinary = array("FAItemplateFile"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $SubObjects = array(); // All leafobjects of this object - - var $FAIstate = ""; - var $ui; - var $view_logged = FALSE; - - function faiTemplate (&$config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. - */ - if($dn != "new"){ - $this->dn =$dn; - - /* Get FAIstate - */ - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - $objects = array(); - $objects['status'] = "FreshLoaded"; - $objects['dn'] = $object['dn']; - $objects = $this->get_object_attributes($objects,$this->subAttributes); - $this->SubObjects[$objects['cn']] = $objects; - } - } - $this->ui = get_userinfo(); - } - - - /* Reload some attributes */ - function get_object_attributes($object,$attributes) - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($object['dn'],$attributes); - $tmp = $ldap->fetch(); - - foreach($attributes as $attrs){ - if(isset($tmp[$attrs][0])){ - $var = $tmp[$attrs][0]; - - /* Check if we must decode some attributes */ - if(in_array_ics($attrs,$this->sub64coded)){ - $var = base64_decode($var); - } - - /* check if this is a binary entry */ - if(in_array_ics($attrs,$this->subBinary)){ - $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0); - } - - $var = stripslashes($var); - - $object[$attrs] = $var; - } - } - return($object); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","fai/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* New Listhandling - */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^editscript_/",$name)&&($once)){ - $once = false; - $entry = preg_replace("/^editscript_/","",$name); - $entry = base64_decode(preg_replace("/_.*/","",$entry)); - $obj = $this->SubObjects[$entry]; - - $acl_dn = $this->acl_base_for_current_object($obj['dn']); - $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); - if(preg_match("/r/",$acl)){ - if($obj['status'] == "FreshLoaded"){ - $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); - } - $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); - $this->dialog->set_acl_base($this->acl_base); - $this->dialog->set_acl_category("fai"); - - $_SESSION['objectinfo'] = $obj['dn']; - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - } - if(preg_match("/^deletescript_/",$name)&&($once)){ - $once = false; - $entry = preg_replace("/^deletescript_/","",$name); - $entry = base64_decode(preg_replace("/_.*/","",$entry)); - $obj = $this->SubObjects[$entry]; - - $acl_dn = $this->acl_base_for_current_object($obj['dn']); - $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); - if(preg_match("/d/",$acl)){ - $status = $this->SubObjects[$entry]['status']; - if($status == "edited" || $status == "FreshLoaded"){ - $this->SubObjects[$entry]['status']= "delete"; - }else{ - unset($this->SubObjects[$entry]); - } - } - } - } - - /* Edit entries via GET */ - if(isset($_GET['act']) && isset($_GET['id'])){ - if($_GET['act'] == "edit" && isset($this->SubObjects[$_GET['id']])){ - $obj = $this->SubObjects[$_GET['id']]; - if($obj['status'] == "FreshLoaded"){ - $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); - } - $this->dialog= new $this->subClassName($this->config,$this->dn,$obj); - $this->dialog->acl = $this->acl; - $_SESSION['objectinfo'] = $obj['dn']; - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - } - - /* Add new sub object */ - if(isset($_POST['AddSubObject'])){ - $acl_dn = "cn=dummy,".$this->acl_base_for_current_object($this->dn); - $acl = $this->ui->get_permissions($acl_dn,"fai/faiTemplateEntry"); - - if(preg_match("/c/",$acl)){ - $this->dialog= new $this->subClassName($this->config,"new"); - $this->dialog->set_acl_base($this->acl_base); - $this->dialog->set_acl_category("fai"); - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - } - - if($this->dn != "new"){ - $_SESSION['objectinfo']= $this->dn; - } - - /* Save Dialog */ - if(isset($_POST['SaveSubObject']) && is_object($this->dialog)){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)>0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - /* Get return object */ - $obj = $this->dialog->save(); - if(isset($obj['remove'])){ - - $old_stat = $this->SubObjects[$obj['remove']['from']]['status']; - - /* Depending on status, set new status */ - if($old_stat == "edited" || $old_stat == "FreshLoaded"){ - $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ - unset($this->SubObjects[$obj['remove']['from']]); - } - $obj['status'] = "new"; - $this->SubObjects[$obj['remove']['to']] = $obj; - unset($this->SubObjects[$obj['remove']['to']]['remove']); - }else{ - if($obj['status'] == "FreshLoaded"){ - $obj['status'] = "edited"; - } - $this->SubObjects[$obj['cn']]=$obj; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - } - - /* Sort entries */ - $tmp = $keys = array(); - foreach($this->SubObjects as $key => $entry){ - $keys[$key]=$key; - } - natcasesort($keys); - foreach($keys as $key){ - $tmp[$key]=$this->SubObjects[$key]; - } - $this->SubObjects = $tmp; - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - - /* Print dialog if $this->dialog is set */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return($display); - } - - /* Divlist Containing FAItemplates */ - $divlist = new divSelectBox("FAItemplates"); - $divlist->setHeight(400); - - $tmp = $this->getList(true); - - /* Create div list with all sub entries listed */ - foreach($this->SubObjects as $key => $name){ - - /* Skip removed entries */ - if($name['status'] == "delete") continue; - - /* Get permissions */ - $dn = $this->acl_base_for_current_object($name['dn']); - $acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry") ; - $act = ""; - - /* Hide delete icon if this object is freezed */ - if(preg_match("/freeze/",$this->FAIstate)){ - $act .= ""; - }else{ - $act .= ""; - if(preg_match("/d/",$acl)){ - $act .=""; - } - } - - /* Check acls for download icon */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry","FAItemplateFile") ; - if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){ - $down = ""; - }else{ - $down = " - "._("Download")." - "; - } - - /* Check if we are allowed to view this object */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry","cn") ; - if(preg_match("/r/",$s_acl)){ - - $edit_link = "".$tmp[$key].""; - $divlist->AddEntry(array( array("string"=> $edit_link), - array("string"=>$down , "attach" => "style='width:20px;'"), - array("string"=>str_replace("%s",base64_encode($key),$act), - "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); - } - } - $smarty->assign("Entry_divlist",$divlist->DrawList()); - /* Divlist creation complete - */ - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - }else{ - $smarty->assign($attrs,($this->$attrs)); - } - } - - $dn = $this->acl_base_for_current_object($this->dn); - $smarty->assign("sub_object_is_addable", - preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiTemplateEntry")) && - !preg_match("/freeze/",$this->FAIstate)); - - foreach($this->attributes as $attr){ - $smarty->assign($attr."ACL",$this->getacl($attr)); - } - - $display.= $smarty->fetch(get_template_path('faiTemplate.tpl', TRUE)); - return($display); - } - - - function acl_base_for_current_object($dn) - { - if($dn == "new"){ - if($this->dn == "new"){ - $dn= $_SESSION['CurrentMainBase']; - }else{ - $dn = $this->dn; - } - } - return($dn); - } - - - /* Generate listbox friendly SubObject list - */ - function getList(){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - - if((isset($obj['description']))&&(!empty($obj['description']))){ - if(strlen($obj['description']) > 40){ - $obj['description'] = substr($obj['description'],0,40)."..."; - } - $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; - }else{ - $a_return[$obj['cn']]= $obj['cn']; - } - } - } - return($a_return); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $this->dn); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $this->dn; - } - - prepare_to_save_FAI_object($use_dn,array(),true); - new log("remove","fai/".get_class($this),$use_dn,$this->attributes); - - foreach($this->SubObjects as $name => $obj){ -# $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']); - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $obj['dn']; - } - prepare_to_save_FAI_object($use_dn,array(),true); - } - $this->handle_post_events("remove"); - } - - - /* Save data to object - */ - function save_object() - { - if((isset($_POST['FAItemplate_posted'])) && (!preg_match("/freeze/",$this->FAIstate))){ - plugin::save_object(); - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - prepare_to_save_FAI_object($this->dn,$this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/template with dn '%s' failed."),$this->dn)); - - if($this->initially_was_account){ - new log("modify","fai/".get_class($this),$this->dn,$this->attributes); - }else{ - new log("create","fai/".get_class($this),$this->dn,$this->attributes); - } - - /* Do object tagging */ - $this->handle_object_tagging(); - - /* Prepare FAIscriptEntry to write it to ldap - * First sort array. - * Because we must delete old entries first. - * After deletion, we perform add and modify - */ - $Objects = array(); - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "FreshLoaded"){ - unset($this->SubObjects[$name]); - } - } - - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - - foreach($Objects as $name => $obj){ - - foreach($this->sub64coded as $codeIt){ - $obj[$codeIt]=base64_encode($obj[$codeIt]); - } - $tmp = array(); - $attributes = array_merge($this->sub_Load_Later,$this->subAttributes); - foreach($attributes as $attrs){ - if(empty($obj[$attrs])){ - $obj[$attrs] = array(); - } - $tmp[$attrs] =($obj[$attrs]); - } - - $tmp['objectClass'] = $this->subClasses; - - $sub_dn = "cn=".$obj['cn'].",".$this->dn; - - if($obj['status']=="new"){ - $ldap->cat($sub_dn,array("objectClass")); - if($ldap->count()){ - $obj['status']="edited"; - } - } - - /* Check if gosaAdministrativeUnitTag is required as object class */ - if($obj['status'] == "edited"){ - $ldap->cat($sub_dn,array("objectClass")); - $attrs = $ldap->fetch(); - if(isset($attrs['objectClass'])){ - if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ - $tmp['objectClass'][] = "gosaAdministrativeUnitTag"; - } - } - } - - if($obj['status'] == "delete"){ - prepare_to_save_FAI_object($sub_dn,array(),true); - $this->handle_post_events("remove"); - }elseif($obj['status'] == "edited"){ - prepare_to_save_FAI_object($sub_dn,$tmp); - $this->handle_post_events("modify"); - }elseif($obj['status']=="new"){ - prepare_to_save_FAI_object($sub_dn,$tmp); - $this->handle_post_events("add"); - } - - - $this->handle_object_tagging($sub_dn, $this->gosaUnitTag); - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - $objects = array(); - $objects['status'] = "edited"; - $objects['dn'] = $object['dn']; - $objects = $this->get_object_attributes($objects,$this->subAttributes); - $objects = $this->get_object_attributes($objects,$this->sub_Load_Later); - - $this->SubObjects[$objects['cn']] = $objects; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Template"), - "plDescription" => _("FAI template"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 24, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name")." ("._("Readonly").")", - "description" => _("Description")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiTemplateEntry.inc b/plugins/admin/fai/class_faiTemplateEntry.inc deleted file mode 100644 index 05c6b72ac..000000000 --- a/plugins/admin/fai/class_faiTemplateEntry.inc +++ /dev/null @@ -1,275 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("cn","description","FAItemplateFile","FAItemplatePath","FAImode","user","group","binary","FAIowner"); - var $objectclasses= array(); - - var $orig_cn = ""; - - var $dn = ""; - var $cn = ""; - var $FAItemplateFile = ""; - var $FAItemplatePath = ""; - var $description = ""; - var $status = "new"; - var $FAImode = "0640"; - var $FAIowner = "root.root"; - var $user = "root"; - var $group = "root"; - var $binary = false; - var $parent = NULL; - var $FAIstate = ""; - - function faiTemplateEntry (&$config, $dn= NULL,$object=false) - { - plugin::plugin ($config, $dn); - - if((isset($object['cn'])) && (!empty($object['cn']))){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = $name; - $this->$oname=$value; - } - - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - }else{ - $this->status = "new"; - $this->orig_cn= false; - } - - $this->user = explode( '.', $this->FAIowner ); - $this->group = $this->user[1]; - $this->user = $this->user[0]; - - $_SESSION['binary'] = $this->FAItemplateFile; - $_SESSION['binarytype'] = 'octet-stream'; - $_SESSION['binaryfile'] = basename( $this->FAItemplatePath ); - - if(!empty($this->dn) && $this->dn != "new"){ - $ldap = $this->config->get_ldap_link(); - $_SESSION['binary'] =$ldap->get_attribute($this->dn,"FAItemplateFile"); - $this->FAItemplateFile = $_SESSION['binary']; - } - - $this->FAImode= sprintf("%0.4s", $this->FAImode)." "; - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $smarty->assign("rand", rand(0, 10000)); - $display = ""; - - if(isset($_POST['TmpFileUpload']) && $this->acl_is_writeable("FAItemplateFile")){ - if($str=file_get_contents($_FILES['FAItemplateFile']['tmp_name'])){ - $this->FAItemplateFile = $str; - - /* If we don't have a filename set it from upload filename. */ - if( 0 == strlen( $this->FAItemplatePath )){ - $this->FAItemplatePath = $_FILES['FAItemplateFile']['name']; - } - - $_SESSION['binary'] = $this->FAItemplateFile; - $_SESSION['binarytype'] = 'octet-stream'; - $_SESSION['binaryfile'] = basename( $this->FAItemplatePath ); - } - } - - $status= _("no file uploaded yet"); - - $bStatus = false; // Hide download icon on default - - if(strlen($this->FAItemplateFile)){ - - $status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->FAItemplateFile)); - $bStatus = true; // Display download icon - } - $smarty->assign("status",$status); - $smarty->assign("bStatus",$bStatus); - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - }else{ - $smarty->assign($attrs,($this->$attrs)); - } - } - - /* Assign file modes */ - $tmode= "$this->FAImode "; - foreach (array("s", "u", "g", "o") as $type){ - $current= substr($tmode, 0, 1); - $tmode= preg_replace("/^./", "", $tmode); - $nr= 1; - while ($nr < 5){ - if ($current & $nr){ - $smarty->assign($type.$nr, "checked"); - } else { - $smarty->assign($type.$nr, ""); - } - $nr+= $nr; - } - } - - $smarty->assign("FAItemplateFile",""); - - foreach($this->attributes as $attr){ - $smarty->assign($attr."ACL",$this->getacl($attr,preg_match("/freeze/",$this->FAIstate))); - } - - /* We now split cn/FAItemplatePath to make things more clear... */ - $smarty->assign("cn", basename($this->FAItemplatePath)); - $smarty->assign("templatePath", dirname($this->FAItemplatePath)); - - $display.= $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - /* Check if form is posted and we are not freezed */ - if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ - - plugin::save_object(); - - /* Set user.group (FAIowner) attribute */ - if(isset($_POST['group']) && isset($_POST["user"]) && $this->acl_is_writeable("FAIowner")){ - $this->FAIowner = $_POST["user"].'.'.$_POST["group"]; - $this->user = $_POST['user']; - $this->group= $_POST['group']; - } - - /* Check if permissions have changed */ - if($this->acl_is_writeable("FAImode")){ - - /* Save mode */ - $tmode= ""; - foreach (array("s", "u", "g", "o") as $type){ - $nr= 1; - $dest= 0; - while ($nr < 5){ - if (isset($_POST["$type$nr"])){ - $dest+= $nr; - } - $nr+= $nr; - } - $tmode= $tmode.$dest; - } - $this->FAImode= $tmode; - - /* Assemble cn/FAItemplatePath */ - $this->cn= preg_replace('/\/+/', '/', $this->FAItemplatePath.'/'.$this->cn); - $this->FAItemplatePath= $this->cn; - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ - $message[] =_("There is already a template with the given name."); - } - - if(empty($this->FAItemplateFile)){ - $message[]=_("Please specify a value for attribute 'file'."); - } - - if(!preg_match('/^\//', $this->FAItemplatePath)){ - $message[]=_("Please specify a valid value for attribute 'Destination path'."); - } - - if(empty($this->cn)){ - $message[] = _("Please enter a file name."); - } - -# echo $this->cn; -# if(preg_match('/\//', $this->cn)){ -# $message[] = _("The file name should not contain / characters."); -# # } - - if(empty($this->user)){ - $message[] = _("Please enter a user."); - } - elseif(preg_match("/[^0-9a-z]/i",$this->user)){ - $message[] = _("Please enter a valid user. Only a-z/0-9 are allowed."); - } - - if(empty($this->group)){ - $message[] = _("Please enter a group."); - } - elseif(preg_match("/[^0-9a-z]/i",$this->group)){ - $message[] = _("Please enter a valid group. Only a-z/0-9 are allowed."); - } - - return ($message); - } - - function save() - { - $tmp=array(); - foreach($this->attributes as $attrs){ - $tmp[$attrs] = $this->$attrs; - } - - if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ - $tmp['remove']['from'] = $this->orig_cn; - $tmp['remove']['to'] = $tmp['cn']; - } - - $tmp['dn'] = $this->dn; - $tmp['status'] = $this->status; - - return($tmp); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Template entry"), - "plDescription" => _("FAI template entry"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 25, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name"), - "description" => _("Description"), - "FAItemplateFile" => _("Template file"), - "FAItemplatePath" => _("Template path"), - "FAIowner" => _("File owner"), - "FAImode" => _("File permissions")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiVariable.inc b/plugins/admin/fai/class_faiVariable.inc deleted file mode 100644 index ae6b79a99..000000000 --- a/plugins/admin/fai/class_faiVariable.inc +++ /dev/null @@ -1,475 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIvariable"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAIvariableEntry"; - var $subClasses = array("top","FAIclass","FAIvariableEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = "faiVariableEntry"; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAIvariableContent"); - var $sub64coded = array(); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $SubObjects = array(); // All leafobjects of this object - - var $FAIstate = ""; - var $ui ; - var $view_logged = FALSE; - - function faiVariable (&$config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - if($dn != "new"){ - $this->dn =$dn; - - /* Get FAIstate - */ - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - foreach($this->subAttributes as $attrs){ - if(!isset($object[$attrs][0])){ - $this->SubObjects[$object['cn'][0]][$attrs]=""; - }else{ - $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; - } - } - - foreach($this->sub64coded as $codeIt){ - $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); - } - - $this->SubObjects[$object['cn'][0]]['status'] = "edited"; - $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; - } - - } - $this->ui = get_userinfo(); - } - - - function acl_base_for_current_object($dn) - { - if($dn == "new"){ - if($this->dn == "new"){ - $dn= $_SESSION['CurrentMainBase']; - }else{ - $dn = $this->dn; - } - } - return($dn); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","fai/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Add new sub object */ - if(isset($_POST['AddSubObject'])){ - $this->dialog= new $this->subClassName($this->config,"new"); - $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn)); - $this->dialog->set_acl_category("fai"); - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - - if($this->dn != "new"){ - $_SESSION['objectinfo']= $this->dn; - } - - - /* Edit selected Sub Object */ - if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ - - $var = $_POST['SubObject'][0]; - $c_dn = $this->acl_base_for_current_object($this->SubObjects[$var]['dn']); - $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$var]); - $this->dialog->set_acl_category("fai"); - $this->dialog->set_acl_base($c_dn); - $this->dialog->parent = &$this; - $_SESSION['objectinfo'] = $this->SubObjects[$var]['dn']; - $this->is_dialog=true; - } - - /* Remove Sub object */ - if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ - foreach($_POST['SubObject'] as $var){ - - $c_dn = $this->acl_base_for_current_object($this->SubObjects[$var]['dn']); - $acl = $this->ui->get_permissions($c_dn,"fai/faiVariable"); - if(preg_match("/d/",$acl)){ - if($this->SubObjects[$var]['status'] == "edited"){ - $this->SubObjects[$var]['status']= "delete"; - }else{ - unset($this->SubObjects[$var]); - } - } - } - } - - /* Save Dialog */ - if(isset($_POST['SaveSubObject'])){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)>0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $obj = $this->dialog->save(); - if(isset($obj['remove'])){ - if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ - $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ - unset($this->SubObjects[$obj['remove']['from']]); - } - $obj['status'] = "new"; - $this->SubObjects[$obj['remove']['to']] = $obj; - unset($this->SubObjects[$obj['remove']['to']]['remove']); - }else{ - $this->SubObjects[$obj['cn']]=$obj; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - } - - /* Sort entries */ - $tmp = $keys = array(); - foreach($this->SubObjects as $key => $entry){ - $keys[$key]=$key; - } - natcasesort($keys); - foreach($keys as $key){ - $tmp[$key]=$this->SubObjects[$key]; - } - $this->SubObjects = $tmp; - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - - /* Print dialog if $this->dialog is set */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return($display); - } - - $ui = get_userinfo(); - $ret = $this->getList(); - $tmp = array(); - foreach($this->SubObjects as $key => $obj){ - $acl = $ui->get_permissions($obj['dn'],"fai/faiVariableEntry"); - if(preg_match("/r/",$acl) || $obj['dn'] == "new"){ - $tmp[$key] = $ret[$key]; - } - } - $smarty->assign("SubObjects",$tmp); - - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs)))); - }else{ - $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs))); - } - } - - $c_dn = $this->acl_base_for_current_object($this->dn); - $smarty->assign("is_createable", preg_match("/c/",$this->ui->get_permissions($c_dn,"fai/faiVariableEntry")) && $this->FAIstate!="freeze"); - $smarty->assign("is_removeable", preg_match("/d/",$this->ui->get_permissions($c_dn,"fai/faiVariableEntry")) && $this->FAIstate!="freeze"); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation) { - $smarty->assign($name."ACL",$this->getacl($name)); - } - - - $display.= $smarty->fetch(get_template_path('faiVariable.tpl', TRUE)); - return($display); - } - - /* Generate listbox friendly SubObject list - */ - function getList(){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - - if((isset($obj['description']))&&(!empty($obj['description']))&&(!preg_match("/\[\*\]/",$obj['description']))){ - if (preg_match("/\[\*\]/", $obj['description'])){ - $a_return[$obj['cn']]= $obj['cn']." [".preg_replace("/\s*\[\*\]\s*/", "", $obj['description'])."]"; - } else { - $a_return[$obj['cn']]= $obj['cn']."=".$obj['FAIvariableContent']." [".$obj['description']."]"; - } - }else{ - if (preg_match("/\[\*\]/", $obj['description'])){ - $a_return[$obj['cn']]= $obj['cn']; - } else { - $a_return[$obj['cn']]= $obj['cn']."=".$obj['FAIvariableContent']; - } - } - } - } - return($a_return); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - if($this->acl_is_removeable()){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $this->dn); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $this->dn; - } - - prepare_to_save_FAI_object($use_dn,array(),true); - new log("remove","fai/".get_class($this),$use_dn,$this->attributes); - - foreach($this->SubObjects as $name => $obj){ - $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']); - if($_SESSION['faifilter']['branch'] == "main"){ - $use_dn = $obj['dn']; - } - prepare_to_save_FAI_object($use_dn,array(),true); - } - $this->handle_post_events("remove"); - } - } - - - /* Save data to object - */ - function save_object() - { - if((isset($_POST['FAIvariable_posted'])) && ($this->FAIstate != "freeze") ){ - plugin::save_object(); - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - } - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - prepare_to_save_FAI_object($this->dn,$this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/variable with dn '%s' failed."),$this->dn)); - - if($this->initially_was_account){ - new log("modify","fai/".get_class($this),$this->dn,$this->attributes); - }else{ - new log("create","fai/".get_class($this),$this->dn,$this->attributes); - } - - /* Do object tagging */ - $this->handle_object_tagging(); - - /* Prepare FAIscriptEntry to write it to ldap - * First sort array. - * Because we must delete old entries first. - * After deletion, we perform add and modify - */ - $Objects = array(); - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - - foreach($Objects as $name => $obj){ - - foreach($this->sub64coded as $codeIt){ - $obj[$codeIt]=base64_encode($obj[$codeIt]); - } - - $tmp = array(); - foreach($this->subAttributes as $attrs){ - if(empty($obj[$attrs])){ - $obj[$attrs] = array(); - } - $tmp[$attrs] = $obj[$attrs]; - } - - $tmp['objectClass'] = $this->subClasses; - - $sub_dn = "cn=".$obj['cn'].",".$this->dn; - - if($obj['status']=="new"){ - $ldap->cat($sub_dn,array("objectClass")); - if($ldap->count()){ - $obj['status']="edited"; - } - } - - /* Check if gosaAdministrativeUnitTag is required as object class */ - if($obj['status'] == "edited"){ - $ldap->cat($sub_dn,array("objectClass")); - $attrs = $ldap->fetch(); - if(isset($attrs['objectClass'])){ - if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){ - $tmp['objectClass'][] = "gosaAdministrativeUnitTag"; - } - } - } - - if($obj['status'] == "delete"){ - prepare_to_save_FAI_object($sub_dn,array(),true); - $this->handle_post_events("remove"); - }elseif($obj['status'] == "edited"){ - prepare_to_save_FAI_object($sub_dn,$tmp); - $this->handle_post_events("modify"); - }elseif($obj['status']=="new"){ - prepare_to_save_FAI_object($sub_dn,$tmp); - $this->handle_post_events("add"); - } - - $this->handle_object_tagging($sub_dn, $this->gosaUnitTag); - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - foreach($this->subAttributes as $attrs){ - if(!isset($object[$attrs][0])){ - $this->SubObjects[$object['cn'][0]][$attrs]=""; - }else{ - $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; - } - } - foreach($this->sub64coded as $codeIt){ - $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); - } - $this->SubObjects[$object['cn'][0]]['status'] = "edited"; - $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Variable"), - "plDescription" => _("FAI variable"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 22, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name")." ("._("Read only").")", - "description" => _("Description")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/class_faiVariableEntry.inc b/plugins/admin/fai/class_faiVariableEntry.inc deleted file mode 100644 index 5fc6ef01e..000000000 --- a/plugins/admin/fai/class_faiVariableEntry.inc +++ /dev/null @@ -1,155 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("cn","description","FAIvariableContent"); - var $objectclasses= array(); - - var $orig_cn = ""; - var $dn = ""; - var $cn = ""; - var $FAIvariableContent = ""; - var $description = ""; - var $status = "new"; - var $parent = NULL; - var $FAIstate = ""; - - function faiVariableEntry (&$config, $dn= NULL,$object=false) - { - plugin::plugin ($config, $dn); - if((isset($object['cn'])) && (!empty($object['cn']))){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = $name; - $this->$oname=addslashes($value); - } - - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - - }else{ - $this->status = "new"; - $this->orig_cn = false; - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ - foreach($this->attributes as $attrs){ - if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs)))); - }else{ - $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs))); - } - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $acl = $this->getacl($name); - if($this->FAIstate == "freezed"){ - $acl = preg_replace("/w/","",$acl); - } - $smarty->assign($name."ACL",$acl); - } - - - - $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ - foreach($this->attributes as $attrs){ - if($this->acl_is_writeable($attrs)){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - }else{ - $this->$attrs = ""; - } - } - } - } - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ - $message[] =_("There is already a variable with the given name."); - } - - if(empty($this->FAIvariableContent)) { - $message[]=_("Please specify a value for the attribute 'content'."); - } - - if(empty($this->cn)){ - $message[] = _("Please enter a name."); - } - - return ($message); - } - - function save() - { - $tmp=array(); - foreach($this->attributes as $attrs){ - $tmp[$attrs] = stripslashes( $this->$attrs); - } - - if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ - $tmp['remove']['from'] = $this->orig_cn; - $tmp['remove']['to'] = $tmp['cn']; - } - - $tmp['dn'] = $this->dn; - $tmp['status'] = $this->status; - return($tmp); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Variable entry"), - "plDescription" => _("FAI variable entry "), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 23, - "plSection" => array("administration"), - "plCategory" => array("fai"), - "plProvidedAcls" => array( - "cn" => _("Name"), - "description" => _("Description"), - "FAIvariableContent"=> _("Variable content") ) - )); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/fai/faiHook.tpl b/plugins/admin/fai/faiHook.tpl deleted file mode 100644 index 6768ad92d..000000000 --- a/plugins/admin/fai/faiHook.tpl +++ /dev/null @@ -1,63 +0,0 @@ - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- - -{render acl=$cnACL} - -{/render} -
- - -{render acl=$descriptionACL} - -{/render} -
-
-

 

- - - - -
-

  - {t}List of hook scripts{/t} -

- - - - -
- {$Entry_divlist} -{if $sub_object_is_addable} - -{else} - -{/if} -
-
- - - - diff --git a/plugins/admin/fai/faiHookEntry.tpl b/plugins/admin/fai/faiHookEntry.tpl deleted file mode 100644 index 882da267d..000000000 --- a/plugins/admin/fai/faiHookEntry.tpl +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {t}Name{/t}{$must}  - -{render acl=$cnACL} - -{/render} -
- {t}Description{/t}  - -{render acl=$descriptionACL} - -{/render} -
-
-   - -

 {t}Hook attributes{/t}

- - - - -
- -{render acl=$FAItaskACL} - -{/render} -
-
- - -

 

-

  - -

- - - - -
-{render acl=$FAIscriptACL} - -{/render} -
-
-
-{render acl=$FAIscriptACL} -   -{/render} -{render acl=$FAIscriptACL} - -{/render} -{render acl=$FAIscriptACL} - {$DownMe} -{/render} -
- -

 

-
-
-   - -
- - - diff --git a/plugins/admin/fai/faiNewBranch.tpl b/plugins/admin/fai/faiNewBranch.tpl deleted file mode 100755 index 831e02898..000000000 --- a/plugins/admin/fai/faiNewBranch.tpl +++ /dev/null @@ -1,55 +0,0 @@ -{if $iframe == false} - -
-

-{t}You are now going to create a branch or locked branch. This action clones the existing release to another release name. Branches can be modified as usual. FAI classes of locked branches cannot be modified, just additional classes are possible. Branch names should be alphanumeric, excluding the reserved names 'scripts', 'hooks', 'partitions', 'variables', 'templates' and 'fai'.{/t} -
-{t}Branches are created as subreleases of the currently selected branch. Creating a new branch named 1.0.2 in SARGE for example, will result in a new release called SARGE/1.0.2.{/t} -
-
-

-

-
-{t}Please enter a name for the branch{/t}   - -
-
-

- -
-

- - -

-
- - - -{else} - -

{t}Processing the requested operation{/t}

-{t}As soon as the copy operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the fai management dialog.{/t} -
-
-
- -
- -{/if} diff --git a/plugins/admin/fai/faiPackage.tpl b/plugins/admin/fai/faiPackage.tpl deleted file mode 100644 index 87c83d98e..000000000 --- a/plugins/admin/fai/faiPackage.tpl +++ /dev/null @@ -1,100 +0,0 @@ - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- - -{render acl=$cnACL} - -{/render} -
- - -{render acl=$descriptionACL} - -{/render} -
-
-

 {t}Repository{/t}

- - - - - - - - - - - - - -
- {t}Release{/t} : - - {$release} -
- {t}Section{/t} : - - {$section} -
- {t}Install method{/t} : - -{render acl=$FAIinstallMethodACL} - -{/render} -
-
-

 

- - - - -
-

 {t}Used packages{/t}

-
- -
-{render acl=$FAIpackageACL} - -{/render} -{render acl=$FAIpackageACL} - -{/render} -{render acl=$FAIdebconfInfoACL} - -{/render} -{render acl=$FAIpackageACL} - -{/render} -
- - - - diff --git a/plugins/admin/fai/faiPackageConfiguration.tpl b/plugins/admin/fai/faiPackageConfiguration.tpl deleted file mode 100644 index db047590f..000000000 --- a/plugins/admin/fai/faiPackageConfiguration.tpl +++ /dev/null @@ -1,9 +0,0 @@ -

 {$headline}

-{$Config} -

 

-
-
- - -
- diff --git a/plugins/admin/fai/faiPackageEntry.tpl b/plugins/admin/fai/faiPackageEntry.tpl deleted file mode 100644 index 79f47c6c4..000000000 --- a/plugins/admin/fai/faiPackageEntry.tpl +++ /dev/null @@ -1,66 +0,0 @@ - - - - - -
-
-

- {t}List of available packages{/t} -

-
-
- {$faihead} -
-
-
-
- {$failist} - -
-
-
-

- [i]{t}Information{/t} -

-
-
- {t}This menu allows you to select multiple packages to add them to the currently edited package list.{/t} -
-
-
-

- [F] - {t}Filters{/t} -

-
-
- {$CHKS} -
-
- - - - - -
- {t}Display objects matching{/t} - - -
- {$apply} -
-
-
- - -
- - - - diff --git a/plugins/admin/fai/faiPartitionTable.tpl b/plugins/admin/fai/faiPartitionTable.tpl deleted file mode 100644 index f330fe67b..000000000 --- a/plugins/admin/fai/faiPartitionTable.tpl +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- - -{render acl=$cnACL} - -{/render} -
- - -{render acl=$descriptionACL} - -{/render} -
-
-   - -

  - -

- - - - -
-
-{if $sub_object_is_addable} - -{else} - -{/if} - - - -
-
- - - diff --git a/plugins/admin/fai/faiPartitionTableEntry.tpl b/plugins/admin/fai/faiPartitionTableEntry.tpl deleted file mode 100644 index 4379b663d..000000000 --- a/plugins/admin/fai/faiPartitionTableEntry.tpl +++ /dev/null @@ -1,48 +0,0 @@ - -

 {t}Device{/t}

- - - - - -
{$must}  -{render acl=$DISKcnACL} - -{/render} -   -{render acl=$DISKdescriptionACL} - -{/render} -
-
-

 

-
-

 {t}Partition entries{/t}

-{$setup} -
-{if $sub_object_is_createable} - -{else} - -{/if} -
-
-

 

-
-
-{render acl=$allowSave} - -{/render} - -
- - - diff --git a/plugins/admin/fai/faiProfile.tpl b/plugins/admin/fai/faiProfile.tpl deleted file mode 100644 index 090d968e7..000000000 --- a/plugins/admin/fai/faiProfile.tpl +++ /dev/null @@ -1,58 +0,0 @@ - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- - -{render acl=$cnACL} - -{/render} -
- - -{render acl=$descriptionACL} - -{/render} -
-
- - - - -
-

 {t}FAI classes{/t}

- - {$divlist} -
-{render acl=$FAIclassACL} - -{/render} - -
-
- - - diff --git a/plugins/admin/fai/faiProfileEntry.tpl b/plugins/admin/fai/faiProfileEntry.tpl deleted file mode 100644 index 72e865bea..000000000 --- a/plugins/admin/fai/faiProfileEntry.tpl +++ /dev/null @@ -1,73 +0,0 @@ - - - - - -
-
-

- {t}List of FAI objects (Fully Automatic Installation){/t} -

-
-
- {$faihead} -
-
-
- {$failist} - -
-
-
-

- [i]{t}Information{/t} -

-
-
-

- {t}This menu allows you to select FAI class names and to add them to the currently edited profile.{/t} -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - - - -
{t}Show only classes with templates{/t}
{t}Show only classes with scripts{/t}
{t}Show only classes with hooks{/t}
{t}Show only classes with variables{/t}
{t}Show only classes with packages{/t}
{t}Show only classes with partitions{/t}
- - - - - -
- {t}Display objects matching{/t} - - -
- {$apply} -
-
- -
- - -
- diff --git a/plugins/admin/fai/faiScript.tpl b/plugins/admin/fai/faiScript.tpl deleted file mode 100644 index c0ff247b5..000000000 --- a/plugins/admin/fai/faiScript.tpl +++ /dev/null @@ -1,63 +0,0 @@ - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- - -{render acl=$cnACL} - -{/render} -
- - -{render acl=$descriptionACL} - -{/render} -
-
-

 

- - - - -
-

  - {t}List of scripts{/t} -

- - - - -
- {$Entry_divlist} -{if $sub_object_is_addable} - -{else} - -{/if} -
-
- - - - diff --git a/plugins/admin/fai/faiScriptEntry.tpl b/plugins/admin/fai/faiScriptEntry.tpl deleted file mode 100644 index cddb2bbcd..000000000 --- a/plugins/admin/fai/faiScriptEntry.tpl +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {t}Name{/t}{$must}  - -{render acl=$cnACL} - -{/render} -
- {t}Description{/t}  - -{render acl=$descriptionACL} - -{/render} -
-
-   - -

 {t}Script attributes{/t}

- - - - - -
- - -{render acl=$FAIpriorityACL} - -{/render} -
-
-

 

-

  - -

- - - - -
-{render acl=$FAIscriptACL} - -{/render} -
-
-
-{render acl=$FAIscriptACL} -   -{/render} -{render acl=$FAIscriptACL} - -{/render} -{render acl=$FAIscriptACL} - {$DownMe} -{/render} -
-
-
-   - -
- - - diff --git a/plugins/admin/fai/faiSummary.tpl b/plugins/admin/fai/faiSummary.tpl deleted file mode 100644 index 196f7cab8..000000000 --- a/plugins/admin/fai/faiSummary.tpl +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -{if $readable} - - - - - - -{else} - - - -{/if} -
{t}FAI object tree{/t}
- - {t}Reload class and release configuration from parent object.{/t} -
- {$objectList} -
- {t}You are not allowed to view the fai summary.{/t} -
- diff --git a/plugins/admin/fai/faiTemplate.tpl b/plugins/admin/fai/faiTemplate.tpl deleted file mode 100644 index 627c5ddd5..000000000 --- a/plugins/admin/fai/faiTemplate.tpl +++ /dev/null @@ -1,52 +0,0 @@ - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- - -{render acl=$cnACL} - -{/render} -
- - -{render acl=$descriptionACL} - -{/render} -
-
-

  - {t}List of template files{/t} -

- {$Entry_divlist} -{if $sub_object_is_addable} - -{else} - -{/if} -
- - - - diff --git a/plugins/admin/fai/faiTemplateEntry.tpl b/plugins/admin/fai/faiTemplateEntry.tpl deleted file mode 100644 index b8ee41a61..000000000 --- a/plugins/admin/fai/faiTemplateEntry.tpl +++ /dev/null @@ -1,203 +0,0 @@ - - -

 {t}Generic{/t}

- - - - - -
- - - - - - - - - -
- {t}File name{/t}{$must}  - -{render acl=$cnACL} -    -{/render} -
- - -{render acl=$FAItemplatePathACL} - -{/render} -
-
- {t}Description{/t}  -{render acl=$descriptionACL} - -{/render} -
- -

 

- - - - - - - - - - - - -

 {t}Template attributes{/t}

- - - - - - - - -
- - - {$status} - {if $bStatus} - - {t}Save template{/t}... - - {/if} -
-
-{render acl=$FAItemplateFileACL} - -{/render} -{render acl=$FAItemplateFileACL} -   -{/render} -
-
-
- {t}Full path{/t}  - -{render acl=$FAItemplatePathACL} - {$FAItemplatePath} -{/render} -
-
- - - - - - - - - - -
- - -{render acl=$FAIownerACL} - -{/render} -
- - -{render acl=$FAIownerACL} - -{/render} -
-
-
{t}Access{/t}{$must}  - - - - - - - - - - - - - -{render acl=$FAImodeACL} - -{/render} -{render acl=$FAImodeACL} - -{/render} -{render acl=$FAImodeACL} - -{/render} - -{render acl=$FAImodeACL} - -{/render} - - - - -{render acl=$FAImodeACL} - -{/render} -{render acl=$FAImodeACL} - -{/render} -{render acl=$FAImodeACL} - -{/render} - -{render acl=$FAImodeACL} - -{/render} - - - - -{render acl=$FAImodeACL} - -{/render} -{render acl=$FAImodeACL} - -{/render} -{render acl=$FAImodeACL} - -{/render} - -{render acl=$FAImodeACL} - -{/render} - -
{t}Class{/t}{t}Read{/t}{t}Write{/t}{t}Execute{/t} {t}Special{/t} 
{t}User{/t} ({t}SUID{/t})
{t}Group{/t} ({t}SGID{/t})
{t}Others{/t} ({t}sticky{/t})
- -
-
-
-

 

-
-
-   - -
-
- - - - - - diff --git a/plugins/admin/fai/faiVariable.tpl b/plugins/admin/fai/faiVariable.tpl deleted file mode 100644 index cdbdab96b..000000000 --- a/plugins/admin/fai/faiVariable.tpl +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- - -{render acl=$cnACL} - -{/render} -
- - -{render acl=$descriptionACL} - -{/render} -
-
-   - -

  - -

- - - - -
-
-{if $is_createable} - -{else} - -{/if} - -{if $is_removeable} - -{else} - -{/if} -
-
- - - - diff --git a/plugins/admin/fai/faiVariableEntry.tpl b/plugins/admin/fai/faiVariableEntry.tpl deleted file mode 100644 index 0fd8a4afa..000000000 --- a/plugins/admin/fai/faiVariableEntry.tpl +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {t}Name{/t}{$must}  - -{render acl=$cnACL} - -{/render} -
- {t}Description{/t}  - -{render acl=$descriptionACL} - -{/render} -
-
-   - -

 {t}Variable attributes{/t}

- - - - - -
- - -{render acl=$FAIvariableContentACL} - -{/render} -
-
-

 

-
-
-   - -
- - - - diff --git a/plugins/admin/fai/main.inc b/plugins/admin/fai/main.inc deleted file mode 100644 index ab6749d44..000000000 --- a/plugins/admin/fai/main.inc +++ /dev/null @@ -1,55 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('FAI'); - } -} else { - /* Create usermanagement object on demand */ - if (!isset($_SESSION['FAI']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['FAI']= new faiManagement($config, $ui); - $_SESSION['FAI']->set_acl_category("fai"); - $_SESSION['FAI']->set_acl_base($_SESSION['CurrentMainBase']); - } - $FAI= $_SESSION['FAI']; - $FAI->save_object(); - $output= $FAI->execute(); - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('FAI'); - } - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/fai.png'), _("Fully Automatic Installation"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/fai.png'), _("Fully Automatic Installation")); - } - $display.= $output; - - $_SESSION['FAI']= $FAI; -} - -?> diff --git a/plugins/admin/fai/remove.tpl b/plugins/admin/fai/remove.tpl deleted file mode 100644 index 10bf93dc5..000000000 --- a/plugins/admin/fai/remove.tpl +++ /dev/null @@ -1,24 +0,0 @@ -
- {t}Warning{/t} -
- -

- {$warning} - {t}This includes 'all' object information. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

-{if $multiple} - -   - -{else} - -   - -{/if} -

diff --git a/plugins/admin/fai/remove_branch.tpl b/plugins/admin/fai/remove_branch.tpl deleted file mode 100755 index 3ed7f2329..000000000 --- a/plugins/admin/fai/remove_branch.tpl +++ /dev/null @@ -1,18 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}This includes all account data, system access, etc. for this branch. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- -   - -

- diff --git a/plugins/admin/fai/tabsHook.inc b/plugins/admin/fai/tabsHook.inc deleted file mode 100644 index 1857854b3..000000000 --- a/plugins/admin/fai/tabsHook.inc +++ /dev/null @@ -1,48 +0,0 @@ -addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['faiHook']; - - $new_dn= 'cn='.$baseobject->cn.",ou=hooks,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - - if($_SESSION['faifilter']['branch']!="main"){ - $new_dn ='cn='.$baseobject->cn.",ou=hooks,".$_SESSION['faifilter']['branch']; - } - - if ($this->dn != $new_dn && $this->dn != "new"){ - - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ -// $baseobject->recursive_move($this->dn, $new_dn); - } - } - $this->dn= $new_dn; - - tabs::save(TRUE); - } - -} - -?> diff --git a/plugins/admin/fai/tabsPackage.inc b/plugins/admin/fai/tabsPackage.inc deleted file mode 100644 index 8731835ef..000000000 --- a/plugins/admin/fai/tabsPackage.inc +++ /dev/null @@ -1,48 +0,0 @@ -addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['faiPackage']; - - $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - if($_SESSION['faifilter']['branch']!="main"){ - $new_dn ='cn='.$baseobject->cn.",ou=packages,".$_SESSION['faifilter']['branch']; - } - - if ($this->dn != $new_dn && $this->dn != "new"){ - - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ -// $baseobject->recursive_move($this->dn, $new_dn); - } - } - $this->dn= $new_dn; - - tabs::save(TRUE); - } - -} - -?> diff --git a/plugins/admin/fai/tabsPartition.inc b/plugins/admin/fai/tabsPartition.inc deleted file mode 100644 index 9d2312d57..000000000 --- a/plugins/admin/fai/tabsPartition.inc +++ /dev/null @@ -1,49 +0,0 @@ -addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['faiPartitionTable']; - - $new_dn= 'cn='.$baseobject->cn.",ou=disk,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - - if($_SESSION['faifilter']['branch']!="main"){ - $new_dn ='cn='.$baseobject->cn.",ou=disk,".$_SESSION['faifilter']['branch']; - } - - if ($this->dn != $new_dn && $this->dn != "new"){ - - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ -// $baseobject->recursive_move($this->dn, $new_dn); - } - } - $this->dn= $new_dn; - - tabs::save(TRUE); - } - -} - -?> diff --git a/plugins/admin/fai/tabsProfile.inc b/plugins/admin/fai/tabsProfile.inc deleted file mode 100644 index cbc3abd94..000000000 --- a/plugins/admin/fai/tabsProfile.inc +++ /dev/null @@ -1,49 +0,0 @@ -addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['faiProfile']; - - $new_dn= 'cn='.$baseobject->cn.",ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - - if($_SESSION['faifilter']['branch']!="main"){ - $new_dn ='cn='.$baseobject->cn.",ou=profiles,".$_SESSION['faifilter']['branch']; - } - - if ($this->dn != $new_dn && $this->dn != "new"){ - - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ -// $baseobject->recursive_move($this->dn, $new_dn); - } - } - $this->dn= $new_dn; - - tabs::save(TRUE); - } - -} - -?> diff --git a/plugins/admin/fai/tabsScript.inc b/plugins/admin/fai/tabsScript.inc deleted file mode 100644 index 28ebd224a..000000000 --- a/plugins/admin/fai/tabsScript.inc +++ /dev/null @@ -1,49 +0,0 @@ -addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['faiScript']; - - $new_dn= 'cn='.$baseobject->cn.",ou=scripts,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - - if($_SESSION['faifilter']['branch']!="main"){ - $new_dn ='cn='.$baseobject->cn.",ou=scripts,".$_SESSION['faifilter']['branch']; - } - - if ($this->dn != $new_dn && $this->dn != "new"){ - - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ -// $baseobject->recursive_move($this->dn, $new_dn); - } - } - $this->dn= $new_dn; - - tabs::save(TRUE); - } - -} - -?> diff --git a/plugins/admin/fai/tabsTemplate.inc b/plugins/admin/fai/tabsTemplate.inc deleted file mode 100644 index 2ff58199b..000000000 --- a/plugins/admin/fai/tabsTemplate.inc +++ /dev/null @@ -1,49 +0,0 @@ -addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['faiTemplate']; - - $new_dn= 'cn='.$baseobject->cn.",ou=templates,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - - if($_SESSION['faifilter']['branch']!="main"){ - $new_dn ='cn='.$baseobject->cn.",ou=templates,".$_SESSION['faifilter']['branch']; - } - - if ($this->dn != $new_dn && $this->dn != "new"){ - - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ -// $baseobject->recursive_move($this->dn, $new_dn); - } - } - $this->dn= $new_dn; - - tabs::save(TRUE); - } - -} - -?> diff --git a/plugins/admin/fai/tabsVariable.inc b/plugins/admin/fai/tabsVariable.inc deleted file mode 100644 index c872f2d9b..000000000 --- a/plugins/admin/fai/tabsVariable.inc +++ /dev/null @@ -1,49 +0,0 @@ -addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['faiVariable']; - - $new_dn= 'cn='.$baseobject->cn.",ou=variables,ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; - - if($_SESSION['faifilter']['branch']!="main"){ - $new_dn ='cn='.$baseobject->cn.",ou=variables,".$_SESSION['faifilter']['branch']; - } - - if ($this->dn != $new_dn && $this->dn != "new"){ - - /* if( new_dn is subtree of this->dn ) */ - $cnt1 = count(split(",",$this->dn)); - $cnt2 = count(split(",",$new_dn)); - if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ - print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); - }else{ -// $baseobject->recursive_move($this->dn, $new_dn); - } - } - $this->dn= $new_dn; - - tabs::save(TRUE); - } - -} - -?> diff --git a/plugins/admin/groups/application.tpl b/plugins/admin/groups/application.tpl deleted file mode 100644 index 87d8050aa..000000000 --- a/plugins/admin/groups/application.tpl +++ /dev/null @@ -1,44 +0,0 @@ -{if $enableReleaseManagement == true} -
- {t}Release focus{/t}  - {if $ReleaseSelectAble} -{render acl=$FAIreleaseACL} - -{/render} - {else} - {$Release} - {/if} -

 

-{ -/if} - - - - - - -
- - - - {$UsedApps} -{render acl=$gosaMemberApplicationACL} - -{/render} -{render acl=$gosaMemberApplicationACL} - -{/render} -   - - - - -
- {$List} -{render acl=$gosaMemberApplicationACL} - -{/render} -
- diff --git a/plugins/admin/groups/application_options.tpl b/plugins/admin/groups/application_options.tpl deleted file mode 100644 index aa5522180..000000000 --- a/plugins/admin/groups/application_options.tpl +++ /dev/null @@ -1,15 +0,0 @@ -
-{t}Application options{/t} -
-
- -{$table} - -
- -

- -   - -

- diff --git a/plugins/admin/groups/class_divListGroup.inc b/plugins/admin/groups/class_divListGroup.inc deleted file mode 100644 index fcf32f843..000000000 --- a/plugins/admin/groups/class_divListGroup.inc +++ /dev/null @@ -1,351 +0,0 @@ -AddCheckBox */ - var $ShowPrimaryGroups; - var $ShowSambaGroups; - var $ShowApplicationGroups; - var $ShowMailGroups; - var $ShowFunctionalGroups; - - /* Subsearch checkbox */ - var $SubSearch = false; - - var $parent ; - var $ui ; - - function divListGroup (&$config, &$parent) - { - MultiSelectWindow::MultiSelectWindow($config, "Groups", "groups"); - - $this->parent = &$parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of groups")); - $this->SetSummary(_("List of groups")); - $this->EnableAplhabet (true); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to add, edit and remove selected groups. You may want to use the range selector on top of the group listbox, when working with a large number of groups.")); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>_("Groupname / Department"))); - $this->AddHeader(array("string"=>_("Properties"),"attach"=>"style='width:136px;'")); - $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'")); - - /* Text ,Value ,Name ,Is selected */ - $this->AddCheckBox("ShowPrimaryGroups", _("Select to see groups that are primary groups of users"), _("Show primary groups"), true); - $this->AddCheckBox("ShowSambaGroups", _("Select to see groups that have samba groups mappings"), _("Show samba groups"), true); - $this->AddCheckBox("ShowApplicationGroups", _("Select to see groups that have applications configured"), _("Show application groups"),true); - $this->AddCheckBox("ShowMailGroups", _("Select to see groups that have mail settings"), _("Show mail groups"), true); - $this->AddCheckBox("ShowFunctionalGroups", _("Select to see normal groups that have only functional aspects"), _("Show functional groups"), true); - $this->AddCheckBox(SEPERATOR); - - /* Add SubSearch checkbox */ - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true); - $this->AddRegex ("UserRegex", _("User name of which groups are shown"), "*" , false, "images/search_user.png"); - } - - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("groups"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get acls */ - $acls = $ui->get_permissions($this->selectedBase,"groups/group"); - $acl_all= $ui->has_complete_category_acls($this->selectedBase,"groups"); - - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* Add department selection */ - $listhead .= _("Base")." ". - "  "; - - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - - /* Append create options */ - if(preg_match("/c/",$acl_all)) { - $s.= "...|". - " "._("Group")."|group_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($groups) - { - // Defining Links - $linkopen = "%s"; - - // image Buttons - $editlink = "%s"; - $userimg = "User"; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /* Assign extension images */ - $posiximg = ""; - $mailimg = ""; - $sambaimg = ""; - $applimg = ""; - $phoneimg = ""; - $envimg = ""; - - // Space - $empty = ""; - - // User and Template Images - $editlink = "%s"; - - $ui = get_userinfo(); - - // Test Every Entry and generate divlist Array - foreach($groups as $key => $val){ - - /* Create action icons - copy & paste icons */ - $acl = $ui->get_permissions($val['dn'],"groups/group"); - $acl_all= $ui->has_complete_category_acls($val['dn'],"groups"); - - $actions= ""; - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions.= " "; - $actions.= " "; - } - - /* Add edit icon */ - $actions.= ""; - - /* Add snapshot functionality */ - if(preg_match("/(c.*w|w.*c)/", $acl_all)){ - $actions.= $this->GetSnapShotActions($val['dn']); - } - - if(preg_match("/d/",$acl)){ - $actions.= ""; - } - - - $posix=$mail=$samba=$appl=$phone=$enviro=$empty; - - if(isset($val['objectClass'])){ - if(in_array("posixGroup", $val['objectClass'])) $posix = $posiximg; - if(in_array("gosaMailAccount", $val['objectClass'])) $mail = $mailimg; - if(in_array("sambaGroupMapping", $val['objectClass'])) $samba = $sambaimg; - if(in_array("gosaApplicationGroup", $val['objectClass'])) $appl = $applimg; - if(in_array("goFonPickupGroup", $val['objectClass'])) $phone = $phoneimg; - if(in_array("gotoEnvironment", $val['objectClass'])) $enviro= $envimg; - } - - $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; - - if(!isset($val['description'][0])){ - $desc = ""; - }else{ - $desc = " - [ ".$val['description'][0]." ]"; - } - - /* FAIrelease tag from groupApplications */ - if(isset($val['FAIrelease'][0])){ - $desc .= " (".$val['FAIrelease'][0].")"; - } - - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - - /* Cutted objects should be displayed in light grey */ - $display = $val['cn'][0].$desc; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); - $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix." ".$enviro." ".$mail." ".$samba." ".$appl." ".$phone), "attach" => "style='width:136px;'"); - $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - - $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); - } - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_grps = count($groups); - - $num_grp_str = _("Number of listed groups"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_grp_str." ".$num_grps."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/groups/class_groupApplication.inc b/plugins/admin/groups/class_groupApplication.inc deleted file mode 100644 index 12b80fab2..000000000 --- a/plugins/admin/groups/class_groupApplication.inc +++ /dev/null @@ -1,1230 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Appgroup attributes */ - var $gosaMemberApplication= array(); - - /* Helpers */ - var $departments = ""; // All departments within $this->curbase; - var $apps = array(); // All available applications - var $used_apps = array(); // Specifies which applications are currently assigned - - var $option_name = array(); - var $option_value = array(); - var $appoption = array(); - - var $table = ""; - var $curbase = ""; - var $curCatDir ; - var $curCatDepth =0; // - var $Categories; - - /* attribute list for save action */ - var $attributes = array("gosaMemberApplication","gosaApplicationParameter"); - var $objectclasses = array("gosaApplicationGroup"); - - var $FAIrelease = "/"; - var $InitialFAIrelease = "/"; - var $Releases = array(); - var $enableReleaseManagement = false; - - var $AllAppsForRelease = array(); - var $AllAppsForReleaseParameter = array(); - var $view_logged = FALSE; - var $CopyPasteVars = array("Categories"); - var $gosaApplicationParameter ; - var $ui = NULL; - var $no_release_acls = false; - - function appgroup (&$config, $dn= NULL, $parent= NULL) - { - - /* Check if we have relase mangement enabled and prepare group application for release management */ - $tmp = $config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - $this->enableReleaseManagement = true; - $this->objectclasses [] = "FAIreleaseTag"; - $this->attributes [] = "FAIrelease"; - } - - plugin::plugin ($config, $dn, $parent); - - /* set userinfo object */ - $this->ui = get_userinfo(); - - /* Compatibility check - In some case of old applikations with old release tag saving, - we must reassign is_account state. - (Or if release management wasn't activated before creating this app) */ - if($this->enableReleaseManagement){ - - /* Release management is activated && this is a valid group app account, - but no release class was found, so activate is_account flag */ - if(isset($this->attrs['objectClass'])){ - if($dn != "new" && ( in_array("gosaApplicationGroup",$this->attrs['objectClass'])) && - (!in_array("FAIreleaseTag",$this->attrs['objectClass']))){ - $this->is_account =true; - } - } - } - - /* Load member applications */ - if (isset ($this->attrs["gosaMemberApplication"][0])){ - $this->gosaMemberApplication = array(); - for ($i= 0; $i<$this->attrs["gosaMemberApplication"]["count"]; $i++){ - $this->gosaMemberApplication[]= - $this->attrs["gosaMemberApplication"][$i]; - } - } - - /* Load application options */ - if (isset($this->attrs['gosaApplicationParameter'])){ - for ($i= 0; $i<$this->attrs['gosaApplicationParameter']['count']; $i++){ - $option= preg_replace('/^[^:]+:/', '', - $this->attrs['gosaApplicationParameter'][$i]); - $name= preg_replace('/:.*$/', '', - $this->attrs['gosaApplicationParameter'][$i]); - $this->appoption[$name]= $option; - } - } - - /* Parse MemberApplication*/ - $tmp = array(); - $tmp2 = array(); - $prios = array(); - $cats = array(); - - foreach($this->gosaMemberApplication as $memberApp){ - if(preg_match("/\|/i",$memberApp)){ - - $tmp = split("\|",$memberApp); - - if(!empty($tmp[0])){ - $tmp2[$tmp[1]][$tmp[2]] = array("App"=>$tmp[0]); - } - if(!empty($tmp[1])){ - $n = split("/",$tmp[1]); - $c = count($n); - $cats [$tmp[1]] = $n[$c-1]; - } - $prios[$tmp[1]][$tmp[2]] = $tmp[2]; - }else{ - $tmp2[]['App'] = $memberApp; - } - } - - /* Assign collected category and application settings */ - $this->Categories = $cats; - $this->gosaMemberApplication = $tmp2; - - /* Sort application by category */ - $cats[""]=""; - foreach($cats as $cat ){ - if((isset($prios[$cat]))&&(count($prios[$cat]))){ - $max = max($prios[$cat]); - $min = 1;//min($prios[$cat]); - $last = false; - for($i = $min ; $i < $max ; $i++){ - if(!isset($prios[$cat][$i])){ - if($last == false){ - $this->gosaMemberApplication[$cat][$i]['App'] = "__SEPARATOR__".$i; - - $last = true; - } - }else{ - $last = false; - } - } - } - } - - /* Sort application by priority */ - $tmp = array(); - foreach($this->gosaMemberApplication as $key => $entries){ - ksort ($entries); - foreach($entries as $entry){ - $tmp[$key][]= $entry; - } - } - $this->gosaMemberApplication = $tmp; - $this->curbase = $this->config->current['BASE']; - - /* Get required release informations */ - if($this->enableReleaseManagement){ - $this->InitialFAIrelease = $this->FAIrelease; - $this->Releases = $this->getReleases(); - } - - } - - - /* Combine new array */ - function combineArrays($ar0,$ar1,$ar2) - { - $ret = array(); - if(is_array($ar0)) - foreach($ar0 as $ar => $a){ - $ret[$ar]=$a; - } - if(is_array($ar1)) - foreach($ar1 as $ar => $a){ - $ret[$ar]=$a; - } - if(is_array($ar2)) - foreach($ar2 as $ar => $a){ - $ret[$ar]=$a; - } - return($ret); - } - - /* Returns element position within given array */ - function getpos($atr,$attrs) - { - $i = 0; - foreach($attrs as $attr => $name) { - $i++; - if($attr == $atr){ - return($i); - } - } - return(-1); - } - - - /* Check current combination of application && release - Are all application available?, application parameter changed? ... */ - function diffAppsInReleases() - { - /* Only diff if it is required */ - $ret =array(); - - /* If current release has changed */ - if($this->FAIrelease != $this->InitialFAIrelease){ - - /* Walk through all apps which are currently displayed */ - if(isset($this->gosaMemberApplication[$this->curCatDir])){ - - foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){ - - /* If application is also available in new release, check if parameter differs */ - if(in_array($entry['App'],$this->AllAppsForRelease)){ - - $old = array(); // Old application parameter - $new = array(); // New parameters - - /* There are possibly no parameters specified */ - if(isset($this->AllAppsForReleaseParameter[$this->InitialFAIrelease][$entry['App']])){ - $old = $this->AllAppsForReleaseParameter[$this->InitialFAIrelease][$entry['App']]; - } - - if(isset($this->AllAppsForReleaseParameter[$this->FAIrelease][$entry['App']])){ - $new = $this->AllAppsForReleaseParameter[$this->FAIrelease][$entry['App']]; - } - - /* Both (old & new) have no gosaApplicationParameter - */ - if((!isset($old['gosaApplicationParameter'])) && (!isset($new['gosaApplicationParameter']))){ - $ret[$entry['App']] = false; - - /* Both got gosaApplicationParameter */ - }elseif((isset($old['gosaApplicationParameter'])) && (isset($new['gosaApplicationParameter']))){ - if(array_differs($old['gosaApplicationParameter'],$new['gosaApplicationParameter'])){ - $ret[$entry['App']] = true; - }else{ - $ret[$entry['App']] = false; - } - } - /* Initially had gosaApplicationParameter bot in new release not */ - }elseif((isset($old['gosaApplicationParameter'])) && (!isset($new['gosaApplicationParameter']))){ - $ret[$entry['App']] = true; - - /* Old release had no gosaApplicationParameter but new got some */ - }elseif((!isset($old['gosaApplicationParameter'])) && (isset($new['gosaApplicationParameter']))){ - $ret[$entry['App']] = true; - } - } - } - } - return($ret); - } - - /* TRansports the geiven Arraykey one position up*/ - function ArrayUp($atr,$attrs) - { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == 1))){ - $before = array_slice($attrs,0,($pos-2)); - $mitte = array_reverse(array_slice($attrs,($pos-2),2)); - $unten = array_slice($attrs,$pos); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - - /* TRansports the geiven Arraykey one position up*/ - function ArrayDown($atr,$attrs) - { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == $cn))){ - $before = array_slice($attrs,0,($pos-1)); - $mitte = array_reverse(array_slice($attrs,($pos-1),2)); - $unten = array_slice($attrs,($pos+1)); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - - /* Sort category on position up */ - function catUp($id) - { - /* Get all cats depinding on current dir */ - $cats = $this->GetSubdirs($this->curCatDir); - $newcats =$this->ArrayUp($id,$cats); - foreach($newcats as $cat => $name){ - unset($this->Categories[$cat]); - } - foreach($newcats as $cat => $name){ - $this->Categories[$cat]=$name; - } - } - - - /* Sort category on position down */ - function catDown($id) - { - /* Get all cats depinding on current dir */ - $cats = $this->GetSubdirs($this->curCatDir); - $newcats =$this->ArrayDown($id,$cats); - foreach($newcats as $cat => $name){ - unset($this->Categories[$cat]); - } - foreach($newcats as $cat => $name){ - $this->Categories[$cat]=$name; - } - } - - - /* Increase application priority */ - function getOneUp($appl) - { - $cat = $this->curCatDir; - $apps = $this->gosaMemberApplication[$cat]; - $appsA = array(); - foreach ($apps as $appkey => $name){ - $appsA[$name['App']] =$name['App']; - } - $result = $this->ArrayUp($appl,$appsA); - $ret = array(); - foreach($result as $app){ - $ret[]=array("App"=>$app); - } - $this->gosaMemberApplication[$cat] = $ret; - } - - - /* Decrease application priority */ - function getOneDown($appl) - { - $cat = $this->curCatDir; - $apps = $this->gosaMemberApplication[$cat]; - $appsA = array(); - foreach ($apps as $appkey => $name){ - $appsA[$name['App']] =$name['App']; - } - $result = $this->ArrayDown($appl,$appsA); - $ret = array(); - foreach($result as $app){ - $ret[]=array("App"=>$app); - } - $this->gosaMemberApplication[$cat] = $ret; - } - - - /* Add seperator to application list */ - function AddSeperator($id) - { - $found = false; - $cat = ""; - $tmp = array(); - foreach($this->gosaMemberApplication[$this->curCatDir] as $appID => $app){ - $tmp[] = $app; - if(($app['App'] == $id)&&(!$found)){ - $cnt = count($this->gosaMemberApplication[$this->curCatDir]); - $tmp[] = array("App" => "__SEPARATOR__".($cnt+1)); - $found = true; - } - } - if($found){ - $this->gosaMemberApplication[$this->curCatDir]=$tmp; - } - } - - - /* Check if application acls are readable */ - function check_acls() - { - return(count($this->ui->get_module_departments("application"))); - } - - - function execute() - { - /* Call parent 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); - } - - /* Check if department was selected */ - if((isset($_GET['act']))&&($_GET['act']=="depopen")){ - $dep = base64_decode($_GET['depid']); - $this->curbase =$dep; - } - - /* Check if category was selected */ - if((isset($_GET['act']))&&($_GET['act']=="open") && (empty($_GET['id']) || isset($this->Categories[base64_decode($_GET['id'])]))){ - $this->curCatDir = base64_decode($_GET['id']); - } - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Do we represent a valid group? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' is no appgroup.").""; - return ($display); - } - - /* Show tab dialog headers */ - $display= ""; - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove applications"), - _("This group has application features enabled. You can disable them by clicking below.")); - } else { - $display.= $this->show_enable_header(_("Create applications"), - _("This group has application features disabled. You can enable them by clicking below.")); - return ($display); - } - } - - /* Check acl, applications must be readable */ - if(!$this->check_acls()){ - $display .= ""._("ACL")." - "._("Insufficient permissions")." -

". - _("You do not have permission to query application entries. All your changes will not be saved."). - "

 

"; - $this->no_release_acls = true; - } - - - /* Add Categorie */ - if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){ - - /* Only allow adding a category, if it is allowed */ - if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ - - if(preg_match("/[\\\\\/]/i",$_POST['CatName'])){ - print_red(_("Invalid character in category name.")); - }elseif(!in_array($_POST['CatName'],$this->Categories)){ - if(empty($this->curCatDir)){ - $this->Categories[$_POST['CatName']]=$_POST['CatName']; - }else{ - $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName']; - } - }else{ - print_red(_("The specified category already exists.")); - } - } - } - - - $this->reload(); - $this->diffAppsInReleases(); - - /* Check POST variables for commands - to add/remove some applications */ - $only_once = false; - if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ - - /* Walk through posts */ - foreach($_POST as $name => $value){ - - /* Add a seperator to current category */ - if((preg_match("/AddSep_/",$name))&&(!$only_once)){ - $only_once = true; - $n = preg_replace("/AddSep_/","",$name); - $val= preg_replace("/_.*$/","",$n); - $this->AddSeperator($val); - } - - /* Delete application | seperator entry */ - if((preg_match("/DelApp_/",$name))&&(!$only_once)){ - $only_once = true; - - if(preg_match("/DelApp___SEPARATOR__/",$name)) { - $n= preg_replace("/DelApp___SEPARATOR__/","",$name); - $val= "__SEPARATOR__".preg_replace("/_.*$/","",$n); - }else{ - $n = preg_replace("/DelApp_/","",$name); - $val= preg_replace("/_.*$/","",$n); - } - - foreach($this->gosaMemberApplication as $key => $cat){ - foreach($cat as $key2 => $app){ - if($app['App'] == $val){ - unset($this->gosaMemberApplication[$key][$key2]); - if(isset($this->used_apps[$val])){ - foreach($this->getParameters($val) as $para){ - if(isset($this->appoption[$para])){ - unset($this->appoption[$para]); - } - } - unset($this->used_apps[$val]); - } - } - } - } - } - - if(preg_match("/DelCat_/",$name) && !$only_once){ - $only_once =TRUE; - $cat = preg_replace("/DelCat_/","",$name); - $cat = trim(base64_decode( preg_replace("/_.*$/","",$cat))); - - $free_apps = array(); - - if(isset($this->gosaMemberApplication[$cat]) && is_array($this->gosaMemberApplication[$cat])){ - foreach($this->gosaMemberApplication[$cat] as $app){ - $free_apps[] = $app['App']; - } - unset($this->gosaMemberApplication[$cat]); - unset($this->Categories[$cat]); - } - foreach($this->Categories as $key => $name){ - if(preg_match("/^".normalizePreg($cat)."\/.*/",$key)){ - foreach($this->gosaMemberApplication[$key] as $app){ - $free_apps[] = $app['App']; - } - unset($this->gosaMemberApplication[$key]); - unset($this->Categories[$key]); - } - } - foreach($free_apps as $app){ - if(isset($this->used_apps[$app])){ - unset($this->used_apps[$app]); - } - } - } - - /* Edit application parameter */ - if((preg_match("/EdiApp_/",$name))&&(!$only_once)){ - - $only_once = true; - $appname = $value; - $appname = preg_replace("/EdiApp_/","",$name); - $appname = preg_replace("/_.*$/","",$appname); - - /* We've got the appname, get parameters from ldap */ - $ldap= $this->config->get_ldap_link(); - - /* Check if we have release management enabled */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - - /* Get application parameter from ldap */ - $tmp = array_flip($this->Releases); - $base = $tmp[$this->FAIrelease]; - $ldap->cd($base); - $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter")); - $found = ""; - while($attrs = $ldap->fetch()) { - if(preg_match("/cn=".$appname.",".$base."/",$attrs['dn'])){ - $found = $attrs['dn']; - } - } - $ldap->cat($found, array("gosaApplicationParameter")); - }else{ - - /* Get application parameter from ldap */ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter")); - } - - /* Check if this application is unique */ - if ($ldap->count() != 1){ - print_red (_("The selected application name is not uniq. Please check your LDAP.")); - } else { - - /* Get parameter */ - $attrs= $ldap->fetch(); - if(isset($attrs['gosaApplicationParameter'])){ - $this->dialog= TRUE; - - /* Fill name and value arrays */ - for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){ - $option= preg_replace('/^[^:]+:/', '', - $attrs['gosaApplicationParameter'][$i]); - $name= preg_replace('/:.*$/', '', - $attrs['gosaApplicationParameter'][$i]); - $this->option_name[$i]= $name; - - /* Fill with values from application, default should be - loaded by the external scripts */ - if (isset($this->appoption[$name])){ - $this->option_value[$i]= $this->appoption[$name]; - } - } - - /* Create edit field */ - $table= ""; - for ($i= 0; $i < count($this->option_name); $i++){ - if (isset($this->option_value[$i])){ - $value= $this->option_value[$i]; - } else { - $value= ""; - } - $table.=""; - } - $table.= "
".$this->option_name[$i]."". - "
"; - $this->table= $table; - } else { - print_red (_("The selected application has no options.")); - } - } - } - } - } - - /* Add multiple */ - if(isset($_POST['AddApps'])){ - foreach($_POST as $name => $value){ - if(preg_match("/AddApp_/",$name)){ - $app = preg_replace("/AddApp_/","",$name); - $this->addApp($app); - } - } - } - - /* Add application with post */ - if((isset($_GET['act']))&&($_GET['act']=="add")){ - $this->used_apps[$_GET['id']]= $_GET['id']; - asort($this->used_apps); - $this->addApp($_GET['id']); - } - - /* Cancel edit options? */ - if (isset($_POST['edit_options_cancel'])){ - $this->dialog= FALSE; - } - - /* Finish edit options? */ - if (isset($_POST['edit_options_finish'])){ - $this->dialog= FALSE; - - /* Save informations passed by the user */ - $this->option_value= array(); - for ($i= 0; $ioption_name); $i++){ - $this->appoption[$this->option_name[$i]]= $_POST["value$i"]; - $this->is_modified= TRUE; - } - } - - /* Prepare templating stuff */ - $smarty= get_smarty(); - $smarty->assign("used_apps", $this->used_apps); - $apps= array(); - foreach ($this->apps as $key => $value){ - if (!array_key_exists($key, $this->used_apps)){ - $apps["$key"]= "$value"; - } - } - - - /* Create application list */ - $div = new divSelectBox("appgroup"); - $div->SetHeight(300); - $departments = array(); - $res = get_list("(objectClass=gosaDepartment)", "application", $this->curbase,array("description","cn","ou"),GL_SIZELIMIT); - foreach($res as $value){ - $fdn = $value['dn']; - $fdn = preg_replace("/".normalizePreg($this->curbase)."/","",$fdn); - $fdn= @LDAP::fix($fdn); - if($value["description"][0]!=".."){ - $departments[$value['dn']]= convert_department_dn($fdn)." - [".$value["description"][0]."]"; - }else{ - $departments[$value['dn']]=convert_department_dn($fdn)." ["._("Back")."]"; - } - } - - /* Create 'open' and 'add' links */ - if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ - $linkadd = "%s"; - }else{ - $linkadd = "%s"; - } - $linkopen = "%s"; - - /* Create base back entry */ - $base_back = preg_replace("/^[^,]+,/","",$this->curbase); - if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){ - $div->AddEntry(array( - array("string"=>sprintf($linkopen,base64_encode($base_back),".. ["._("back")."]"), - "attach"=>"style='border:0px;'") - )); - } - - /* Append departments for current base */ - foreach($departments as $key => $app){ - $div->AddEntry(array( - array("string"=>""._("department")." ".sprintf($linkopen,base64_encode($key),$app), - "attach"=>"style='border:0px;'") - )); - } - - /* Add applications found on this base */ - foreach($apps as $key => $app){ - $div->AddEntry(array( - array("string"=>sprintf("",$key). - ""._("application")." ".sprintf($linkadd,$key,$app), - "attach"=>"style='border:0px;'") - )); - } - - /* Create list of used/assigned applications */ - $div2 = new divSelectBox("appgroup"); - $div2->SetHeight(300); - - /* Check acls to create "edit/remove" category links */ - if(!$this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ - $linkopen = "\"\" %s"; - $catremove = "  "; - $catupdown = ""; - }else{ - $linkopen = "\"\" %s"; - $catremove = " "; - $catupdown = "". - "\"\"". - " ". - "". - "\"\"". - ""; - } - - /* Add back category for current category */ - if(empty($this->curCatDir)){ - $cnt =0; - }else{ - $cnt = count(split("/",$this->curCatDir)); - $tmp = split("/",$this->curCatDir); - $bbk = ""; - for($i = 0 ; $i < ($cnt -1 ) ; $i++){ - $bbk .= $tmp[$i]."/"; - } - $bbk = preg_replace("/\/$/","",$bbk); - $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,base64_encode($bbk),".. ["._("Back")."]")),array("string"=>" ","attach"=>"style='border-right:0px;'"))); - } - - /* Add sub categories */ - $this->GetSubdirs($this->curCatDir); - foreach($this->GetSubdirs($this->curCatDir) as $path => $name){ - $div2 ->AddEntry(array( - array("string"=>sprintf($linkopen,base64_encode($path),$name)), - array("string"=>preg_replace("/%s/",base64_encode($path),$catupdown.$catremove), - "attach"=>"align='right' style='width:80px;border-right:0px;'"))); - } - - /* Create priority & seperator links */ - $separator ="
"; - if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){ - $sep = ""; - $upudown = "". - " {t}sort{/t}". - " ". - "". - " {t}sort{/t}". - " ". - ""; - }else{ - $sep = ""; - $upudown = ""; - } - - /* Create edit link */ - if($this->acl_is_writeable("gosaApplicationParameter",$this->no_release_acls)){ - $edit= " "; - }else{ - $edit= ""; - } - - /* Get differences to mark those entries that have changed from last edit. */ - $Differences = $this->diffAppsInReleases(); - - /* Walk through entries an append them to list */ - if(isset($this->gosaMemberApplication[$this->curCatDir])){ - foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){ - - /* Add seperator */ - if(preg_match("/__SEPARATOR__/",$entry['App'])){ - $div2 ->AddEntry(array(array("string"=>$separator), - array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$upudown),"attach"=>"align='right' style='border-right:0px;'"))); - }else{ - - /* Add application */ - - $image = ""; - /* Check if application was available within selected release - * or application list if release management is not active - */ - if(!in_array($entry['App'],$this->AllAppsForRelease)){ - - /* release managent is active - */ - if(!$this->enableReleaseManagement){ - $image = "R "; - }else{ - $image = "FFAIrelease)."\"> "; - } - - }elseif(isset($Differences[$entry['App']]) && ($Differences[$entry['App']] == true)) { - $entry['App'].=" ["._("Check parameter")."]"; - $image = " "; - }else{ - $image = "\"\" "; - } - - $div2->AddEntry(array(array("string"=>sprintf($image."%s",$entry['App'])), - array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$sep.$edit.$upudown), - "attach"=>"align='right' style='width:100px;border-right:0px;'"))); - } - } - } - - /* Assign created div lists to template */ - $smarty->assign("UsedApps", $div2->DrawList()); - $smarty->assign("List", $div->DrawList()); - $smarty->assign("apps", $apps); - - $smarty->assign("enableReleaseManagement",$this->enableReleaseManagement); - - $smarty->assign("ReleaseSelectAble", false); - $smarty->assign("Release", $this->FAIrelease); - - if($this->enableReleaseManagement){ - $smarty->assign("FAIrelease", $this->FAIrelease); - $smarty->assign("Releases", $this->Releases); - - if(!$this->no_release_acls && count($this->Releases)){ - $smarty->assign("ReleaseSelectAble", true); - } - } - - /* Set acls to template */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $acl => $translation){ - $smarty->assign($acl."ACL",$this->getacl($acl,$this->no_release_acls)); - } - - /* Show main page */ - if (is_object($this->dialog)){ - $smarty->assign("table", $this->table); - $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE,dirname(__FILE__))); - } else { - $display.= $smarty->fetch (get_template_path('application.tpl', TRUE,dirname(__FILE__))); - } - - return ($display); - } - - - function getReleases() - { - /* Only display those releases that we are able to read */ - $dn = $this->config->current['BASE']; - $filter = "(&(objectClass=organizationalUnit)(objectClass=FAIbranch))"; - $res = get_list($filter,"application", $dn, array("ou"), GL_SUBSEARCH); - - $ret =array(); - foreach($res as $attrs){ - if(preg_match("/ou=apps,/",$attrs['dn'])){ - $bb = preg_replace("/ou=apps,.*/","",$attrs['dn']); - $parts = array_reverse(split("ou=",$bb)); - - $str =""; - foreach($parts as $part){ - if(empty($part)) { - continue; - } - $str .= str_replace(",","",$part)."/"; - } - $name = preg_replace("/\/$/","",$str); - if(empty($name)) { - $name ="/"; - } - $ret[$attrs['dn']] = $name; - } - } - return($ret); - } - - function save_object() - { - - /* Move category one position up or down */ - if((isset($_GET['act']))&&(($_GET['act'] == "cat_up")||($_GET['act']=="cat_down"))){ - if($_GET['act']=="cat_up"){ - $this->catUp(base64_decode($_GET['id'])); - } - if($_GET['act']=="cat_down"){ - $this->catDown(base64_decode($_GET['id'])); - } - } - - /* Move application one position up or down */ - if((isset($_GET['act']))&&(($_GET['act'] == "one_up")||($_GET['act']=="one_down"))){ - if(isset($_GET['id'])){ - $id = $_GET['id']; - $act = $_GET['act']; - - if($act == "one_up"){ - $this->getOneUp($id); - }elseif($act == "one_down") { - $this->getOneDown($id); - } - } - } - - - plugin::save_object(); - } - - - function remove_from_parent() - { - if(!$this->initially_was_account){ - return; - } - - plugin::remove_from_parent(); - - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - - $ldap->modify ($this->attrs); - new log("remove","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/applications with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove"); - } - - - /* Save to LDAP */ - function save() - { - /* Skip saving application settings, if we do not have release acls */ - if($this->no_release_acls){ - new log("security","groups/".get_class($this),$this->dn,array(),"Skip saving group application extension. Caused by insufficient acls"); - - return; - } - - plugin::save(); - - - - /* Copy members */ - $this->Categories[""]=""; - $this->attrs["gosaMemberApplication"]= array(); - $this->attrs["gosaApplicationParameter"]= array(); - $cat_id= 0 ; - foreach($this->Categories as $name => $cats){ - $i =0; - if(isset($this->gosaMemberApplication[$name])){ - foreach($this->gosaMemberApplication[$name] as $entry){ - if(!preg_match("/__SEPARATOR__/",$entry['App'])){ - $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$i; - $i ++; - } - } - } - if(($i==0)&&(!empty($name))){ - $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cat_id; - } - $cat_id++; - } - - - - /* Are there application parameters to be saved */ - $this->attrs['gosaApplicationParameter']= array(); - foreach($this->appoption as $name => $value){ - if ($value != ""){ - $this->attrs['gosaApplicationParameter'][]= "$name:$value"; - } - } - - /* Write back to LDAP */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - if($this->initially_was_account){ - new log("modify","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of groups/applications with dn '%s' failed."),$this->dn)); - - /* 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"); - } - } else { - $this->handle_post_events("add"); - } - - } - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - - function reload() - { - /* Generate applist */ - $this->apps= array(); - - /* Special handling for release managed apps */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp) && count($this->Releases)){ - $this->enableReleaseManagement = true; - - /* Check if release is available */ - $tmp = array_flip($this->Releases); - if(isset($tmp[$this->FAIrelease])){ - $base = $tmp[$this->FAIrelease]; - }else{ - - /* Release is not available, check if there is an alternative */ - $old_r = $this->FAIrelease; - $k = key($tmp); - - if(isset($tmp[$k])){ - - /* We have found an alternative release name */ - $r = $tmp[$k]; - $this->FAIrelease = $k; - $base = $r; - - /* Display msg */ - if(!(!$this->initially_was_account && $old_r =="/")){ - print_red(sprintf(_("Can't resolve the release name '%s', setting release name to '%s'. Possibly the objects base has changed."),$old_r,$k)); - } - }else{ - - /* There are no releases available ... */ - print_red(_("There are no releases available. You will not be able to select another release.")); - return; - } - } - - /* Get applications for this release */ - $base = preg_replace("/ou=apps,.*$/","ou=apps,".$this->curbase,$base); - $res = get_list("(objectClass=gosaApplication)","application",$base,array("*")); - }else{ - - /* Get applications for this base */ - $res = get_list("(objectClass=gosaApplication)","application","ou=apps,".$this->curbase,array("*")); - } - - /* Append applications */ - foreach($res as $attrs){ - if (isset($attrs["description"][0])){ - $this->apps[$attrs["cn"][0]]= - $attrs["cn"][0]." (". - $attrs["description"][0].")"; - } else { - $this->apps[$attrs["cn"][0]]= - $attrs["cn"][0]; - } - } - - /* Get all apps ... */ - $res = get_list("objectClass=gosaApplication","application",$this->config->current['BASE'],array("gosaApplicationParameter","cn"),GL_SUBSEARCH); - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - $this->AllAppsForRelease = array(); - if(!empty($tmp)){ - $tmp = array_flip($this->Releases); - foreach($res as $attrs){ - - $testdn = preg_replace("/ou=apps,.*$/","ou=apps",$attrs['dn']); - $testdn = preg_replace("/^[^,]+/","",$testdn); - $testdn = preg_replace("/^,/","",$testdn); - - if($testdn == preg_replace("/ou=apps,.*$/","ou=apps",$tmp[$this->FAIrelease])){ - $this->AllAppsForRelease[$attrs['dn']] = $attrs['cn'][0]; - $this->AllAppsForReleaseParameter[$this->FAIrelease][$attrs['cn'][0]] = $attrs; - } - } - }else{ - foreach($res as $attrs){ - $this->AllAppsForRelease[$attrs['dn']] = $attrs['cn'][0]; - } - } - - natcasesort ($this->apps); - reset ($this->apps); - - if(is_array($this->gosaMemberApplication)) - foreach ($this->gosaMemberApplication as $cat){ - if(is_array($cat)) - foreach($cat as $entry){ - $this->used_apps[$entry['App']]= $entry['App']; - } - } - } - - - function addApp($cn) - { - if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){ - foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){ - if($entry['App'] == $cn) return; - } - } - $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn); - $this->used_apps[$cn]=$cn; - $this->is_modified= TRUE; - } - - - function removeApp($cn) - { - $temp= array(); - foreach ($this->gosaMemberApplication as $value){ - if ($value != $cn){ - $temp[]= $value; - } - } - $this->gosaMemberApplication= $temp; - $this->is_modified= TRUE; - } - - function getParameters($app) - { - $tmp = $this->getReleases(); - $ret = array(); - if(in_array($this->FAIrelease,$tmp)){ - $tmp2 = array_flip($tmp); - $base = $tmp2[$this->FAIrelease]; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaApplication)(cn=".$app.")(gosaApplicationParameter=*))",array("gosaApplicationParameter")); - if($ldap->count()){ - $attrs = $ldap->fetch(); - for($i = 0 ; $i < $attrs['gosaApplicationParameter']['count'] ; $i ++ ){ - $name = preg_replace("/:.*$/","",$attrs['gosaApplicationParameter'][$i]); - $ret[$name] = $name; - } - } - } - return($ret); - } - - function GetSubdirs($dir) - { - $ret = array(); - $tmp1 = split("/",$this->curCatDir); - - foreach($this->Categories as $path=>$cat){ - $tmp2 = split("/",$path); - - if((empty($this->curCatDir))&&(!preg_match("/\//",$path))){ - $abort = false; - }elseif(((count($tmp1))+1) == (count($tmp2))){ - $abort = false; - for($i = 0 ; $i < count($tmp1) ; $i++){ - if($tmp1[$i] != $tmp2[$i]){ - $abort = true; - } - } - }else{ - $abort= true; - } - if(!$abort){ - $ret[$path]=$cat; - } - } - return($ret); - } - - - function PrepareForCopyPaste($source) - { - $s = new appgroup($this->config,$source['dn']); - $this->FAIrelease = $this->InitialFAIrelease = $s->FAIrelease; - $this->gosaMemberApplication = $s->gosaMemberApplication; - $this->appoption = $s->appoption; - $this->Categories = $s->Categories; - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Applications"), - "plDescription" => _("Group applications"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("admin"), - "plCategory" => array("groups"), - "plProvidedAcls"=> array( - "gosaMemberApplication" => _("Application"), - "FAIrelease" => _("Release"), - "gosaApplicationParameter" => _("Application parameter")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/groups/class_groupGeneric.inc b/plugins/admin/groups/class_groupGeneric.inc deleted file mode 100644 index 095d3be27..000000000 --- a/plugins/admin/groups/class_groupGeneric.inc +++ /dev/null @@ -1,978 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Group attributes */ - var $cn= ""; - var $description= ""; - var $gidNumber= ""; - var $memberUid= array(); - - /* Helpers */ - var $base= ""; - var $force_gid= FALSE; - var $fon_group= FALSE; - var $smbgroup= FALSE; - var $groupType= FALSE; - var $samba3= FALSE; - var $sambaSID= ""; - var $sambaDomainName= "DEFAULT"; - var $SID= ""; - var $ridBase= 0; - var $members= array(); - var $users= array(); - var $member= array(); - var $allusers= array(); - var $saved_gidNumber= ""; - var $oldgroupType= ""; - var $orig_dn= ""; - var $orig_cn= ""; - var $has_mailAccount= FALSE; - var $group_dialog= FALSE; - var $nagios_group =FALSE; - var $sambaGroupType; - var $dialog; - var $rfc2307bis= FALSE; - var $OnlyShowFirstEntries =200; - var $dnMapping= array(); - var $view_logged = FALSE; - var $allowGroupsWithSameNameInOtherSubtrees = true; - - /* attribute list for save action */ - var $attributes= array("cn", "description", "gidNumber","memberUid","sambaGroupType","sambaSID"); - var $objectclasses= array("top", "posixGroup"); - - var $CopyPasteVars = array("force_gid","fon_group","smbgroup","groupType","sambaSID","sambaDomainName","SID","nagios_group","sambaGroupType"); - - function group (&$config, $dn= NULL) - { - /* Set rfc2307bis flag */ - if (isset($config->current['RFC2307BIS']) && ($config->current['RFC2307BIS']== "true")){ - $this->rfc2307bis= TRUE; - $this->attributes[]= "member"; - $this->objectclasses[]= "groupOfNames"; - } - - plugin::plugin ($config, $dn); - - /* Load attributes depending on the samba version */ - $this->samba3= ($config->current['SAMBAVERSION'] == 3); - $this->orig_dn= $dn; - $this->orig_cn= $this->cn; - - /* Get member list */ - if (isset($this->attrs['memberUid'][0])){ - $tmp= array(); - for ($i= 0; $i<$this->attrs['memberUid']['count']; $i++){ - $tmp[]= $this->attrs['memberUid'][$i]; - } - $this->memberUid= $tmp; - sort ($this->memberUid); - } - - /* Save gidNumber for later use */ - if (isset($this->attrs['gidNumber'])){ - $this->saved_gidNumber= $this->attrs['gidNumber'][0]; - } - - /* Is a samba group? */ - if (isset($this->attrs['objectClass'])){ - if (array_search ('sambaGroupMapping', $this->attrs['objectClass']) == FALSE ){ - $this->smbgroup= FALSE; - } else { - $this->smbgroup= TRUE; - if (isset($this->attrs['sambaSID'])){ - $this->sambaSID= $this->attrs['sambaSID'][0]; - } - } - if (array_search ('goFonPickupGroup', $this->attrs['objectClass']) == FALSE ){ - $this->fon_group= FALSE; - } else { - $this->fon_group= TRUE; - } - if (array_search ('nagiosContactGroup', $this->attrs['objectClass']) == FALSE ){ - $this->nagios_group= FALSE; - } else { - $this->nagios_group= TRUE; - } - } - - /* Set mail flag */ - if (isset($this->attrs['objectClass']) && in_array('gosaMailAccount', $this->attrs['objectClass'])){ - $this->has_mailAccount= TRUE; - } - - /* Get samba Domain in case of samba 3 */ - if ($this->samba3 && $this->sambaSID != ""){ - $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID); - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase")); - if ($ldap->count() != 0){ - $attrs= $ldap->fetch(); - $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0]; - - /* Get domain name for SID */ - $this->sambaDomainName= "DEFAULT"; - foreach ($this->config->data['SERVERS']['SAMBA'] as $key => $val){ - if ($val['SID'] == $this->SID){ - $this->sambaDomainName= $key; - break; - } - } - } else { - if (isset($this->config->current['RIDBASE'])){ - $this->sambaDomainName= "DEFAULT"; - $this->ridBase= $this->config->current['RIDBASE']; - $this->SID= $this->config->current['SID']; - } else { - print_red(_("Can't find this groups SID in LDAP or in your configuration file!")); - } - } - - /* Get group type */ - $this->groupType= (int)substr(strrchr($this->sambaSID, "-"), 1); - if ($this->groupType < 500 || $this->groupType > 553){ - $this->groupType= 0; - } - $this->oldgroupType= $this->groupType; - } - - /* Get global filter config */ - if (!is_global("gufilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $gufilter= array( "dselect" => $base, - "regex" => "*"); - register_global("gufilter", $gufilter); - } - $gufilter= get_global('gufilter'); - - $gufilter['SubSearchGroup'] = false; - $gufilter['dselect'] = $_SESSION['gufilter']['dselect']; - - register_global('gufilter',$gufilter); - - if ($this->dn == "new"){ - if(isset($_SESSION['CurrentMainBase'])){ - $this->base= $_SESSION['CurrentMainBase']; - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - - /* Get object base */ - $this->base =preg_replace ("/^[^,]+,".normalizePreg(get_groups_ou())."/","",$this->dn); - } - - /* This is always an account */ - $this->is_account= TRUE; - $this->reload(); - } - - function execute() - { - /* Call parent 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); - } - - /* Do we represent a valid group? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' is no group.").""; - return ($display); - } - - /* Delete user from group */ - if (isset($_POST['del_users']) && isset($_POST['members'])){ - foreach ($_POST['members'] as $value){ - unset ($this->members["$value"]); - $this->removeUser($value); - } - $this->reload(); - } - - /* Add objects? */ - if (isset($_POST["edit_membership"])){ - $this->group_dialog= TRUE; - $this->dialog= TRUE; - } - - /* Add objects finished? */ - if (isset($_POST["add_users_finish"]) || isset($_POST["add_users_cancel"])){ - $this->group_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Add user to group */ - if (isset($_POST['add_users_finish']) && isset($_POST['users'])){ - foreach ($_POST['users'] as $value){ - $this->members["$value"]= $this->allusers[$value]; - asort($this->members); - $this->addUser($value); - } - $this->reload(); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){ - - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* Check if selected base is valid */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Assign templating stuff */ - $smarty= get_smarty(); - if ($this->samba3){ - $smarty->assign("samba3", "true"); - } else { - $smarty->assign("samba3", ""); - } - - if($this->config->search("nagiosaccount", "CLASS",array('menu'))){ - $smarty->assign("nagios",true); - }else{ - $smarty->assign("nagios",false); - } - - if($this->config->search("phoneAccount", "CLASS",array('menu'))){ - $smarty->assign("pickupGroup",true); - }else{ - $smarty->assign("pickupGroup",false); - } - - /* Manage object add dialog */ - if ($this->group_dialog){ - - /* Save data */ - $gufilter= get_global("gufilter"); - foreach( array("dselect", "regex") as $type){ - if (isset($_POST[$type])){ - $gufilter[$type]= $_POST[$type]; - } - } - if(isset($_POST['regex'])){ - if(isset($_POST['SubSearchGroup'])){ - $gufilter['SubSearchGroup'] = true; - }else{ - $gufilter['SubSearchGroup'] = false; - } - } - - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $gufilter['regex']= $s; - } - register_global("gufilter", $gufilter); - $this->reload(); - - /* Show dialog */ - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - - $smarty->assign("deplist", $this->get_allowed_bases("users/user")); - $smarty->assign("alphabet", generate_alphabet()); - foreach( array("dselect", "regex","SubSearchGroup") as $type){ - $smarty->assign("$type", $gufilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - $smarty->assign("users", $this->displayUsers); - $smarty->assign("apply", apply_filter()); - $display= $smarty->fetch (get_template_path('group_objects.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("base_select", $this->base); - - if ($this->samba3){ - $domains= array(); - foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){ - $domains[$name]= $name; - } - $smarty->assign("sambaDomains", $domains); - $smarty->assign("sambaDomainName", $this->sambaDomainName); - $groupTypes= array(0 => _("Samba group"), 512 => _("Domain admins"), 513 => _("Domain users"), - 514 => _("Domain guests")); - - /* Don't loose special groups! If not key'ed above, add it to - the combo box... */ - if ($this->groupType >= 500 && $this->groupType <= 553 && !isset($groupTypes[$this->groupType])){ - $groupTypes[$this->groupType]= sprintf(_("Special group (%d)"), $this->groupType); - } - - $smarty->assign("groupTypes", $groupTypes); - $smarty->assign("groupType", $this->groupType); - } - - /* Members and users */ - $smarty->assign("members", $this->members); - - /* Checkboxes */ - foreach (array("force_gid", "smbgroup") as $val){ - if ($this->$val == "1"){ - $smarty->assign("$val", "checked"); - } else { - $smarty->assign("$val", ""); - } - } - if ($this->force_gid != "1"){ - $smarty->assign("forceMode", "disabled"); - }else{ - $smarty->assign("forceMode", ""); - } - if ($this->fon_group){ - $smarty->assign("fon_group", "checked"); - } else { - $smarty->assign("fon_group", ""); - } - - if ($this->nagios_group){ - $smarty->assign("nagios_group", "checked"); - } else { - $smarty->assign("nagios_group", ""); - } - - /* Fields */ - foreach (array("cn", "description", "gidNumber") as $val){ - $smarty->assign("$val", $this->$val); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - if($this->acl_is_writeable("base")){ - $smarty->assign("baseSelect",true); - }else{ - $smarty->assign("baseSelect",false); - } - - /* Show main page */ - $smarty->assign("alphabet", generate_alphabet(10)); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("deplist", $this->config->idepartments); - return($smarty->fetch (get_template_path('generic.tpl', TRUE))); - } - - function addUser($uid) - { - $this->memberUid[]= $uid; - $this->memberUid= array_unique($this->memberUid); - } - - function removeUser($uid) - { - $temp= array(); - foreach ($this->memberUid as $value){ - if ($value != $uid){ - $temp[]= $value; - } - } - $this->memberUid= $temp; - } - - - /* Reload data */ - function reload() - { - /* Fix regex string */ - $gufilter = get_global("gufilter"); - $regex = normalizeLdap($gufilter['regex']); - $MaxUser = $this->OnlyShowFirstEntries; - - /* Prepare ldap link */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($gufilter['dselect']); - - - /* Resolve still unresolved memberuids to fill the list with sn/giveName attributes - (Store gathered sn/givenName informations in $this->allusers too, - to be prepared when adding/deleting users) - */ - $filter = ""; - foreach ($this->memberUid as $value){ - if(!isset($this->members[$value])){ - $filter .= "(uid=".normalizeLdap($value).")"; - } - } - if(!empty($filter)){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|".$filter."))",array("dn", "uid","sn","givenName")); - while($attrs = $ldap->fetch()){ - $this->dnMapping[$attrs['uid'][0]] = $attrs['dn']; - $this->members[$attrs['uid'][0]] = $this->createResultName($attrs); - $this->allusers[$attrs['uid'][0]]= $this->createResultName($attrs); - } - } - - /* check if all uids are resolved */ - foreach ($this->memberUid as $value){ - if(!isset($this->members[$value])){ - $this->members[$value] = _("! unknown id")." [".$value."]"; - } - } - - /* Create display list of users matching regex & filter - */ - $this->displayUsers = array(); - $filter = "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$))(|(uid=".$regex.")(sn=".$regex.")(givenName=".$regex.")))"; - - /* Search in current tree or within subtrees depending on the checkbox from filter section */ - if($gufilter['SubSearchGroup']){ - $flag = GL_SIZELIMIT | GL_SUBSEARCH; - $base = $gufilter['dselect']; - }else{ - $flag = GL_SIZELIMIT ; - $base = get_people_ou().$gufilter['dselect']; - } - $i = 0; - - - $res = get_list($filter,"users",$base,array("dn", "uid", "sn", "givenName"),$flag); - - /* Fetch all users and skip already used users */ - foreach($res as $attrs){ - if(in_array($attrs['uid'][0], $this->memberUid)) { - continue; - } - $i ++; - if($i > $MaxUser) { - break; - } - $this->dnMapping[$attrs['uid'][0]]= $attrs["dn"]; - $this->allusers[$attrs['uid'][0]] = $this->createResultName($attrs); - $this->displayUsers[$attrs['uid'][0]] = $this->createResultName($attrs); - } - - /* If more than max users are found, display a message to warn the user */ - if(($i == $MaxUser)){ - print_red(sprintf(_("Your search method returned more than '%s' users, only '%s' users are shown.") , $MaxUser,$MaxUser)); - } - - /* Sort lists */ - natcasesort($this->members); - reset($this->members); - natcasesort ($this->displayUsers); - reset ($this->displayUsers); - } - - - /* Create display name, this was used so often that it is excluded into a seperate function */ - function createResultName($attrs) - { - if (isset($attrs["givenName"][0]) && isset($attrs["sn"][0])){ - $ret = $attrs["sn"][0].", ".$attrs["givenName"][0]." [".$attrs["uid"][0]."]"; - } else { - $ret= $attrs['uid'][0]; - } - return($ret); - } - - - function remove_from_parent() - { - plugin::remove_from_parent(); - - $ldap= $this->config->get_ldap_link(); - $ldap->rmdir($this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/generic with dn '%s' failed."),$this->dn)); - - new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - - /* Remove ACL dependencies too, - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($this->dn)."*))",array("gosaAclEntry","dn")); - while($attrs = $ldap->fetch()){ - $acl = new acl($this->config,$this->parent,$attrs['dn']); - foreach($acl->gosaAclEntry as $id => $entry){ - foreach($entry['members'] as $m_id => $member){ - if($m_id == "G:".$this->dn || $m_id == "U:".$this->dn){ - unset($acl->gosaAclEntry[$id]['members'][$m_id]); - gosa_log("modify","groups/acl",$attrs['dn'],array(),sprintf("Removed acl for %s on object %s.",$this->dn,$attrs['dn'])); - } - } - } - $acl -> save(); - } - - /* Remove ACL dependencies too, - */ - $tmp = new acl($this->config,$this->parent,$this->dn); - $tmp->remove_acl(); - - /* Send signal to the world that we've done */ - $this->handle_post_events("remove"); - } - - - /* Save data to object */ - function save_object() - { - /* Save additional values for possible next step */ - if (isset($_POST['groupedit'])){ - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - $this->force_gid= 0; - - /* Only reset sambagroup flag if we are able to write this flag */ - if($this->acl_is_writeable("sambaGroupType")){ - $this->smbgroup = 0; - } - - /* Get base selection */ - if(isset($_POST['base'])){ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$_POST['base']])){ - $this->base = $_POST['base']; - } - } - - foreach (array( - "force_gid" => "gidNumber", - "smbgroup" => "sambaGroupType") as $val => $aclname) { - if ($this->acl_is_writeable($aclname) && isset($_POST["$val"])){ - $this->$val= $_POST["$val"]; - } - } - - /* Save sambaDomain attribute */ - if ($this->acl_is_writeable("sambaDomainName") && $this->samba3 && isset ($_POST['sambaDomainName'])){ - $this->sambaDomainName= $_POST['sambaDomainName']; - $this->groupType= $_POST['groupType']; - } - - /* Save fon attribute */ - if ($this->acl_is_writeable("fon_group")){ - if (isset ($_POST['fon_group'])){ - $this->fon_group= TRUE; - } else { - $this->fon_group= FALSE; - } - } - if ($this->acl_is_writeable("nagios_group")){ - if (isset ($_POST['nagios_group'])){ - $this->nagios_group= TRUE; - } else { - $this->nagios_group= FALSE; - } - } - } - } - - - /* Save to LDAP */ - function save() - { - - /* ID handling */ - if ($this->force_gid == 0){ - if ($this->saved_gidNumber != ""){ - $this->gidNumber= $this->saved_gidNumber; - } else { - /* Calculate new, lock uids */ - $wait= 10; - while (get_lock("uidnumber") != ""){ - sleep (1); - - /* timed out? */ - if ($wait-- == 0){ - break; - } - } - add_lock ("uidnumber", "gosa"); - $this->gidNumber= $this->get_next_id("gidNumber", $this->dn); - } - } - - plugin::save(); - - /* Remove objectClass for samba/phone support */ - $tmp= array(); - for ($i= 0; $iattrs["objectClass"]); $i++){ - if ($this->attrs['objectClass'][$i] != 'sambaGroupMapping' && - $this->attrs['objectClass'][$i] != 'sambaIdmapEntry' && - $this->attrs['objectClass'][$i] != 'goFonPickupGroup' && - $this->attrs['objectClass'][$i] != 'nagiosContactGroup'){ - $tmp[]= $this->attrs['objectClass'][$i]; - } - } - $this->attrs['objectClass']= $tmp; - $ldap= $this->config->get_ldap_link(); - - /* Add samba group functionality */ - if ($this->samba3 && $this->smbgroup){ - - /* Fixed undefined index ... - */ - $this->SID = $this->ridBase = ""; - if(isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){ - $this->SID = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID']; - }else{ - print_red(sprintf(_("No configured SID found for '%s'."),$this->sambaDomainName)); - } - if(isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'])){ - $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE']; - }else{ - print_red(sprintf(_("No configured RIDBASE found for '%s'."),$this->sambaDomainName)); - } - - $this->attrs['objectClass'][]= 'sambaGroupMapping'; - $this->attrs['sambaGroupType']= "2"; - - /* Check if we need to create a special entry */ - if ($this->groupType == 0){ - - if ($this->sambaSID == "" || $this->oldgroupType != $this->groupType){ - $gidNumber= $this->gidNumber; - while(TRUE){ - $sid= $this->SID."-".($gidNumber*2 + $this->ridBase+1); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(sambaSID=$sid)",array("sambaSID")); - if ($ldap->count() == 0){ - break; - } - $gidNumber++; - } - $this->attrs['sambaSID']= $sid; - $this->sambaSID= $sid; - } - - } else { - $this->attrs['sambaSID']=$this->SID."-".$this->groupType; - } - - /* User wants me to fake the idMappings? This is useful for - making winbind resolve the group names in a reasonable amount - of time in combination with larger databases. */ - if (isset($this->config->current['SAMBAIDMAPPING']) && - preg_match('/true/i', $this->config->current['SAMBAIDMAPPING'])){ - $this->attrs['objectClass'][]= "sambaIdmapEntry"; - } - - } - - /* Add phone functionality */ - if ($this->fon_group){ - $this->attrs['objectClass'][]= "goFonPickupGroup"; - } - - /* Add nagios functionality */ - if ($this->nagios_group){ - $this->attrs['objectClass'][]= "nagiosContactGroup"; - } - - /* Take members array */ - if (count ($this->memberUid)){ - $this->attrs['memberUid']= array_unique($this->memberUid); - } - - /* New accounts need proper 'dn', propagate it to remaining objects */ - if ($this->dn == 'new'){ - $this->dn= 'cn='.$this->cn.','.get_groups_ou().$this->base; - } - - /* Add member dn's for RFC2307bis Support */ - if ($this->rfc2307bis){ - if (count($this->memberUid)){ - $this->attrs['member'] = array(); - foreach($this->attrs['memberUid'] as $uid) { - $this->attrs['member'][]= $this->dnMapping[$uid]; - } - } else { - $this->attrs['member'][]= $this->dn; - } - } - - /* Save data. Using 'modify' implies that the entry is already present, use 'add' for - new entries. So do a check first... */ - $ldap->cat ($this->dn, array('dn')); - if ($ldap->fetch()){ - /* Modify needs array() to remove values :-( */ - if (!count ($this->memberUid)){ - $this->attrs['memberUid']= array(); - } - if ($this->samba3){ - if (!$this->smbgroup){ - $this->attrs['sambaGroupType']= array(); - $this->attrs['sambaSID']= array(); - } - } - $mode= "modify"; - } else { - $mode= "add"; - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - } - - /* Write back to ldap */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->$mode($this->attrs); - - /* Remove ACL dependencies too, - */ - if($this->dn != $this->orig_dn && $this->orig_dn != "new"){ - $tmp = new acl($this->config,$this->parent,$this->dn); - $tmp->update_acl_membership($this->orig_dn,$this->dn); - } - - 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()); - } - - $ret= 0; - if ( show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/generic with dn '%s' failed."),$this->dn))){ - $ret= 1; - } - - /* Remove uid lock */ - del_lock ("uidnumber"); - - /* Post that we've done*/ - $this->handle_post_events($mode); - - return ($ret); - } - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Permissions for that base? */ - if ($this->base != ""){ - $new_dn= 'cn='.$this->cn.','.get_groups_ou().$this->base; - } else { - $new_dn= $this->dn; - } - - /* must: cn */ - if ($this->cn == "" && $this->acl_is_writeable("cn")){ - $message[]= "The required field 'Name' is not set."; - } - - /* Check for valid input */ - if (!is_uid($this->cn)){ - $message[]= _("The field 'Name' contains invalid characters. Lowercase, numbers and dashes are allowed."); - } - - if($this->allowGroupsWithSameNameInOtherSubtrees == true){ - - /* Check for used 'cn' */ - $ldap= $this->config->get_ldap_link(); - if(($this->cn != $this->orig_cn) || ($this->orig_dn == "new")){ - $ldap->cd("ou=groups,".$this->base); - $ldap->ls("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",get_groups_ou().$this->base,array("cn")); - if ($ldap->count() != 0){ - $message[]= _("Value specified as 'Name' is already used."); - } - } - - }else{ - - /* Check for used 'cn' */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn")); - if ($ldap->count() != 0){ - - /* New entry? */ - if ($this->dn == 'new'){ - $message[]= _("Value specified as 'Name' is already used."); - } - - /* Moved? */ - elseif ($new_dn != $this->orig_dn){ - $ldap->fetch(); - if ($ldap->getDN() != $this->orig_dn){ - $message[]= _("Value specified as 'Name' is already used."); - } - } - } - } - - /* Check ID */ - if ($this->force_gid == "1"){ - if (!is_id($this->gidNumber)){ - $message[]= _("Value specified as 'GID' is not valid."); - } else { - if ($this->gidNumber < $this->config->current['MINID']){ - $message[]= _("Value specified as 'GID' is too small."); - } - - } - } - - return ($message); - } - - function get_next_id($attrib, $dn) - { - $ids= array(); - $ldap= $this->config->get_ldap_link(); - - $ldap->cd ($this->config->current['BASE']); - if (preg_match('/gidNumber/i', $attrib)){ - $oc= "posixGroup"; - } else { - $oc= "posixAccount"; - } - $ldap->search ("(&(objectClass=$oc)($attrib=*))", array("$attrib")); - - /* Get list of ids */ - while ($attrs= $ldap->fetch()){ - $ids[]= (int)$attrs["$attrib"][0]; - } - - /* Find out next free id near to UID_BASE */ - if (!isset($this->config->current['BASE_HOOK'])){ - $base= $this->config->current['UIDBASE']; - } else { - /* Call base hook */ - $base= get_base_from_hook($dn, $attrib); - } - for ($id= $base; $id++; $id < pow(2,32)){ - if (!in_array($id, $ids)){ - return ($id); - } - } - - /* Check if id reached maximum */ - if ($id >= pow(2,32)){ - print_red(_("Too many users, can't allocate a free ID!")); - exit; - } - } - - function getCopyDialog() - { - $vars = array("cn"); - - if($this ->force_gid){ - $used = " checked "; - $dis = ""; - }else{ - $used = ""; - $dis = " disabled "; - } - - $smarty = get_smarty(); - $smarty->assign("used",$used); - $smarty->assign("dis" ,$dis); - $smarty->assign("cn" ,$this->cn); - $smarty->assign("gidNumber",$this->gidNumber); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - if(isset($_POST['force_gid'])){ - $this->force_gid = 1; - $this->gidNumber= $_POST['gidNumber']; - }else{ - $this->force_gid = 0; - $this->gidNumber = false; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Generic group settings"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("admin"), - "plCategory" => array("groups" => array("objectClass" => "posixGroup", "description" => _("Groups"))), - - "plProvidedAcls" => array( - "cn" => _("Name"), - "base" => _("Base"), - "description" => _("Description"), - - "fonGroup" => _("Phone pickup group"), - "nagiosGroup" => _("Nagios group"), - - "gidNumber" => _("GID"), - "memberUid" => _("Group member"), - "sambaGroupType" => _("Samba group type"), - "sambaDomainName" => _("Samba domain name"), - "sambaSID" => _("Samba SID")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/groups/class_groupMail.inc b/plugins/admin/groups/class_groupMail.inc deleted file mode 100644 index be6f7b3fe..000000000 --- a/plugins/admin/groups/class_groupMail.inc +++ /dev/null @@ -1,1162 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - var $uid = ""; // User id - var $cn = ""; // cn - var $orig_cn = ""; // cn - - var $method = "mailMethod"; // Used Mail method - var $mmethod = ""; // Contains the gosa.conf MAILMETHOD - var $mail = ""; // Default mail address - - var $gosaMailAlternateAddress = array(); // Set default Alternate Mail Adresses to empty array - var $gosaMailForwardingAddress = array(); // Forwarding also empty - - var $gosaMailServer = ""; // Selected mailserver - var $gosaMailQuota = ""; // Defined Quota - var $quotaUsage = 0; // Currently used quota - - var $gosaVacationMessage = ""; // Vocation message - - var $imapacl = array('anyone' => 'p', // Set acls for everyone - '%members%' => 'lrswp', // %members% are all group-members - '' => 'p'); // Every user added gets this right - - var $kolabFolderType_SubType = ""; - var $kolabFolderType_Type = ""; - - var $gosaSpamSortLevel = ""; - var $gosaSpamMailbox = ""; - var $gosaSharedFolderTarget ; - - var $forward_dialog = FALSE; - - var $members = array(); // Group members - - var $mailusers = array(); - var $perms = array(); - var $gosaMailDeliveryMode = "[L ]"; // - var $gosaMailMaxSize = ""; // - - var $remove_folder_from_imap = true; - - /* Helper */ - var $indexed_acl= array(); - var $indexed_user= array(); - - var $view_logged = FALSE; - - /* attribute list for save action */ - var $attributes= array( "mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize", - "gosaMailAlternateAddress", "gosaMailForwardingAddress", - "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox", - "acl","gosaSharedFolderTarget", "gosaVacationMessage"); - - var $objectclasses= array("gosaMailAccount"); - var $CopyPasteVars = array("quotaUsage","imapacl"); - - function mailgroup (&$config, $dn= NULL, $ui= NULL) - { - /* Initialise all available attributes ... if possible - */ - plugin::plugin($config, $dn); - $this->orig_cn = $this->cn; - - /* Set mailMethod to the one defined in gosa.conf - */ - if (isset($this->config->current['MAILMETHOD'])){ - $this->mmethod= $this->config->current['MAILMETHOD']; - } - - /* Check if selected mail method exists - */ - $cls = get_correct_class_name("mailMethod$this->mmethod"); - if ($cls && class_exists($cls)){ - $this->method= $cls; - } else { - print_red(sprintf(_("There is no mail method '%s' specified in your gosa.conf available."), $this->mmethod)); - } - - /* Load Mailserver - */ - if(isset($this->attrs['gosaMailServer'][0])){ - $this->gosaMailServer = $this->attrs['gosaMailServer'][0]; - } - - /* Convert cn to uid in case of existing entry - */ - if (isset($this->attrs['cn'][0])){ - $this->uid= $this->attrs['cn'][0]; - } - - /* Get folder type */ - if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){ - if(isset($this->attrs['kolabFolderType'])){ - $tmp = split("\.",$this->attrs['kolabFolderType'][0]); - $this->kolabFolderType_Type = $tmp[0]; - $this->kolabFolderType_SubType = $tmp[1]; - } - } - - /* If this ins't new mailgroup, read all required data from ldap - */ - if (($dn != "new")&&($dn !== NULL)){ - - /* Load attributes which represent multiple entries - */ - 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]); - } - } - } - - /* Only do IMAP actions if gosaMailServer attribute is set - */ - if (isset ($this->attrs["gosaMailServer"][0])){ - - /* Create new instance of our defined mailclass - */ - $method= new $this->method($this->config); - - if ($method->connect($this->attrs["gosaMailServer"][0])){ - - - /* Maybe the entry is not saved in new style, get - permissions from IMAP and convert them to acl attributes */ - if (!isset($this->attrs['acl'])){ - $this->imapacl= $method->getSharedFolderPermissions($this->uid); - - /* Need to filter what a member acl could be... */ - $vote= array(); - $peak= 0; - $leader= ""; - foreach ($this->imapacl as $user => $acl){ - - if ($user != "anyone" ){ - if (!isset($vote[$acl])){ - $vote[$acl]= 1; - } else { - $vote[$acl]++; - } - if ($vote[$acl] > $peak){ - $leader= $acl; - $peek= $vote[$acl]; - } - } - - } - - /* Highest count wins as %members%, remove all members - with the same acl */ - if(!empty($leader)){ - $this->imapacl['%members%']= $leader; - } - foreach ($this->imapacl as $user => $acl){ - if ($this->acl == $leader && in_array($user, $this->attrs['memberUid'])){ - unset($this->imapacl[$user]); - } - } - - } // ENDE ! isset ($this->attrs['acl']) - - /* Adapt attributes if needed */ - $method->fixAttributesOnLoad($this); - - /* get Quota */ - $quota= $method->getQuota($this->uid); - - /* Update quota values */ - if(is_array($quota)){ - if ($quota['gosaMailQuota'] == 2147483647){ - $this->quotaUsage= ""; - $this->gosaMailQuota= ""; - } else { - $this->quotaUsage= $quota['quotaUsage']; - $this->gosaMailQuota= $quota['gosaMailQuota']; - } - }else{ - $this->quotaUsage = ""; - $this->gosaMailQuota = ""; -// print_red(sprintf(_("Can't get quota information for '%s'."),$this->uid)); - } - $method->disconnect(); - } // ENDE $method->connect($this->attrs["gosaMailServer"][0])){ - - } // ENDE gosaMailServer - - } // ENDE dn != "new" - - - /* Get global filter config */ - if (!is_global("gmailfilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $gmailfilter= array( "depselect" => $base, - "muser" => "", - "regex" => "*"); - register_global("gmailfilter", $gmailfilter); - } - - /* Load permissions */ - $tmp = array(); - if(preg_match("/olab/i",$this->mmethod)){ - $ldap = $this->config->get_ldap_link(); - - if (isset($this->attrs['acl'])){ - - for ($i= 0; $i<$this->attrs['acl']['count']; $i++){ - list($user, $permission)= split(' ', $this->attrs['acl'][$i]); - - /* Add to list */ - $this->imapacl[$user]= $permission; - - /* Get all user permissions sorted by acl, to detect the most used acl - This acl is then used for %members% - */ - if ($user != "anyone" && $user != "%members%"){ - $tmp[$permission][] = $user; - } - - /* There is an entry in $this->imapacl like this this ... - $this->attrs['imapacl']['anyone'] = "p"; - $this->attrs['imapacl']['%members%'] = "lprs"; - $this->attrs['imapacl'][''] = ""; <------ This is used to diplay an empty - Field for special acls in our template. - If there is at least one special acl in out imapacl, - we don't need this entry anymore, because it is already displayed. - */ - if ($user != "anyone" && $user != "%members%"){ - unset($this->imapacl['']); - } - } - } - - /* In this section we dectect which acl is tho most used - This will be used as %members% acl - */ - $tmp2 = array(); - foreach($tmp as $acl => $user){ - $tmp2[count($tmp[$acl])]=$acl; - } - /* Most used at last - */ - ksort($tmp2); - - /* Assign last (most used acl) to %members% acl - */ - $str = array_pop($tmp2); - if(!empty($str)) { - $this->imapacl['%members%']=$str; - } - - /* Open ldap connection - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* Remove those users, that use %members% acl && are member of this group. */ - foreach($this->imapacl as $mail => $permission){ - $ldap->search("(&(objectClass=person)(mail=".$mail."))",array("uid")); - $atr = $ldap->fetch(); - if((isset($this->attrs['memberUid'])) && (is_array($this->attrs['memberUid']))){ - if((isset($atr['uid'][0]))&&(in_array($atr['uid'][0],$this->attrs['memberUid']))&&($permission == $this->imapacl['%members%'])){ - unset($this->imapacl[$mail]); - } - } - } - /* Append an empty entry, for special acl handling */ - if(count($this->imapacl)==2){ - $this->imapacl[''] =""; - } - - }else{ // Not kolab - /* Load permissions */ - if (isset($this->attrs['acl'])){ - for ($i= 0; $i<$this->attrs['acl']['count']; $i++){ - list($user, $permission)= split(' ', $this->attrs['acl'][$i]); - $this->imapacl[$user]= $permission; - if ($user != "anyone" && $user != "%members%"){ - unset($this->imapacl['']); - } - } - } - } - - /* Load Mailserver - */ - if(isset($this->attrs['gosaMailServer'][0])){ - $this->gosaMailServer = $this->attrs['gosaMailServer'][0]; - } - /* Fill translations */ - $this->perms["lrsw"]= _("read"); - $this->perms["lrspw"]= _("post"); - $this->perms["p"]= _("external post"); - $this->perms["lrsipw"]= _("append"); - $this->perms["lrswipcd"]= _("write"); - $this->perms["lrswipcda"]= _("admin"); - $this->perms[""]= _("none"); - } - - function execute() - { - /* Call parent 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); - } - - /* Load templating engine */ - $smarty= get_smarty(); - - /* Assign acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation) { - $smarty->assign($name."ACL",$this->getacl($name)); - } - - if ($_SESSION['js']==FALSE){ - $smarty->assign("javascript", "false"); - } else { - $smarty->assign("javascript", "true"); - } - - /* Do we need to flip is_account state? */ - 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; - } - } - - $display = ""; - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - - $display.= "\"\" ". - _("This 'dn' has no valid mail extensions.").""; - return ($display); - } - - /* Show tab dialog headers */ - $display= ""; - if ($this->parent !== NULL){ - if ($this->is_account){ - $display.= $this->show_disable_header(_("Remove mail account"), - _("This account has mail features enabled. You can disable them by clicking below.")); - } else { - $display.= $this->show_enable_header(_("Create mail account"), - _("This account has mail features disabled. You can enable them by clicking below.")); - - /* Show checkbox that allows us to remove imap entry too*/ - if($this->initially_was_account){ - $c = ""; - if($this->remove_folder_from_imap){ - $c= " checked "; - } - $display .= "

Shared folder delete options

- "; - $display .= _("Remove the shared folder and all its contents after saving this account"); - } - return ($display); - } - } - - /* Add ACL? */ - if($this->acl_is_writeable("acl")){ - foreach ($this->indexed_user as $nr => $user){ - if (isset($_POST["add_$nr"])){ - $this->imapacl[""]= "l"; - } - if (isset($_POST["del_$nr"])){ - unset ($this->imapacl[$user]); - } - } - } - - /* Trigger forward add dialog? */ - if($this->acl_is_writeable("gosaMailForwardingAddress")){ - if (isset($_POST['add_local_forwarder'])){ - $this->forward_dialog= TRUE; - $this->dialog= TRUE; - } - } - - /* Cancel forward add dialog? */ - if($this->acl_is_writeable("gosaMailForwardingAddress")){ - if (isset($_POST['add_locals_cancel'])){ - $this->forward_dialog= FALSE; - $this->dialog= FALSE; - } - } - - /* Finished adding of locals? */ - if ((isset($_POST['add_locals_finish'])) && ($this->acl_is_writeable("gosaMailForwardingAddress"))) { - if (count ($_POST['local_list']) && $this->acl_is_writeable("gosaMailForwardingAddress")){ - - /* Walk through list of forwarders, ignore own addresses */ - foreach ($_POST['local_list'] as $val){ - if (!in_array ($val, $this->gosaMailAlternateAddress) && - $val != $this->mail){ - - $this->addForwarder($val); - } - } - } - $this->forward_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Add forward email addresses */ - if ((isset($_POST['add_forwarder'])) && ($this->acl_is_writeable("gosaMailForwardingAddress"))){ - if ($_POST['forward_address'] != ""){ - - /* Valid email address specified? */ - $address= $_POST['forward_address']; - if (!is_email($address)){ - - print_red (_("You're trying to add an invalid email address ". - "to the list of forwarders.")); - - } elseif ($address == $this->mail - || in_array($address, $this->gosaMailAlternateAddress)) { - - print_red (_("Adding your one of your own addresses to the forwarders makes no sense.")); - - } else { - - /* Add it */ - if ($this->acl_is_writeable("gosaMailForwardingAddress")){ - $this->addForwarder ($address); - } - - } - } - } - - /* Delete forward email addresses */ - if (isset($_POST['delete_forwarder']) && ($this->acl_is_writeable("gosaMailForwardingAddress"))){ - if (count($_POST['forwarder_list'])&& $this->acl_is_writeable("gosaMailForwardingAddress")){ - - $this->delForwarder ($_POST['forwarder_list']); - } - } - - /* Add alternate email addresses */ - if (isset($_POST['add_alternate'])){ - if ($_POST['alternate_address'] != "" && $this->acl_is_writeable("gosaMailAlternateAddress")){ - - if (!is_email($_POST['alternate_address'])){ - print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); - - } elseif (($user= $this->addAlternate ($_POST['alternate_address'])) != ""){ - $ui= get_userinfo(); - if ($user != $ui->username){ - print_red (_("The address you're trying to add is already used by user")." '$user'."); - } - } - } - } - - /* Delete alternate email addresses */ - if($this->acl_is_writeable("gosaMailAlternateAddress")){ - if (isset($_POST['delete_alternate']) && isset ($_POST['alternates_list'])){ - if (count($_POST['alternates_list']) && $this->acl_is_writeable("gosaMailAlternateAddress")){ - $this->delAlternate ($_POST['alternates_list']); - } - } - } - - /* Show forward add dialog */ - if ($this->forward_dialog){ - $ldap= $this->config->get_ldap_link(); - - /* Save data */ - $gmailfilter= get_global("gmailfilter"); - foreach( array("depselect", "muser", "regex") as $type){ - if (isset($_POST[$type])){ - $gmailfilter[$type]= $_POST[$type]; - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $gmailfilter['regex']= $s; - } - register_global("gmailfilter", $gmailfilter); - - /* Get actual list */ - $mailusers= array (); - if ($gmailfilter['regex'] != '*' && $gmailfilter['regex'] != ""){ - $regex= $gmailfilter['regex']; - $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))"; - } else { - $filter= ""; - } - if ($gmailfilter['muser'] != ""){ - $user= $gmailfilter['muser']; - $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))"; - } - - /* Add already present people to the filter */ - $exclude= ""; - foreach ($this->gosaMailForwardingAddress as $mail){ - $exclude.= "(mail=$mail)"; - } - if ($exclude != ""){ - $filter.= "(!(|$exclude))"; - } - - $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $gmailfilter['depselect'], - array("sn", "mail", "givenName"), GL_SUBSEARCH | GL_SIZELIMIT); - $ldap->cd($gmailfilter['depselect']); - $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName")); - error_reporting (0); - while ($attrs= $ldap->fetch()){ - if(preg_match('/%/', $attrs['mail'][0])){ - continue; - } - $name= $this->make_name($attrs); - $mailusers[$attrs['mail'][0]]= $name."<". - $attrs['mail'][0].">"; - } - error_reporting (E_ALL | E_STRICT); - natcasesort ($mailusers); - reset ($mailusers); - - /* Show dialog */ - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("usearch_image", get_template_path('images/search_user.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("mailusers", $mailusers); - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("hint", print_sizelimit_warning()); - foreach( array("depselect", "muser", "regex") as $type){ - $smarty->assign("$type", $gmailfilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE)); - return ($display); - } - - /* Assemble normal permissions */ - if (isset($this->imapacl['anyone'])){ - $smarty->assign("default_permissions", $this->imapacl['anyone']); - } - $smarty->assign("member_permissions", "lrsp"); - if (isset($this->imapacl['%members%'])){ - $smarty->assign("member_permissions", $this->imapacl['%members%']); - } - - /* Assemble extra attributes */ - $perm= $this->getacl( "permissions"); - $tmp= ""; - $nr= 0; - $count= count($this->imapacl); - $this->indexed_user= array(); - $this->indexed_acl= array(); - foreach($this->imapacl as $user => $acl){ - - /* Add additional acl settings */ - if ($user != "anyone" && $user != "%members%"){ - - $Dis = ""; - if(!preg_match("/w/",$perm)){ - $Dis = " disabled "; - } - - /* Reset given Acls to ensure that nobody can read username and acls if not allwoed */ - if(!preg_match("/r/",$perm)){ - $user = ""; - $nr = "none"; - $key = "none"; - } - - $tmp.= " - - - - -  "; - - - - if ($nr == $count - 1){ - if($this->acl_is_writeable("acl")){ - $tmp.= ""; - } - } - if ($count > 3){ - if($this->acl_is_writeable("acl")){ - $tmp.= ""; - } - } - } - $this->indexed_user[$nr]= $user; - $this->indexed_acl[$nr++]= $acl; - } - $smarty->assign("plusattributes", $tmp); - - /* Show main page */ - $mailserver= array(); - foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){ - $mailserver[]= $key; - } - $smarty->assign("mailServers", $mailserver); - foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail", - "gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){ - $smarty->assign("$val", $this->$val); - } - if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){ - if($this->acl_is_readable("gosaMailQuota")){ - $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true)); - $smarty->assign("quotadefined", "true"); - }else{ - $smarty->assign("quotadefined", "true"); - $smarty->assign("quotausage", "-"); - } - } else { - $smarty->assign("quotadefined", "false"); - } - - if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){ - - $smarty->assign("kolab", TRUE); - $smarty->assign("JS",$_SESSION['js']); - $smarty->assign("kolabFolderType_Types", array ( '' => _('Unspecified'), 'mail' => _('Mails'), - 'task' => _('Tasks') , 'journal' => _('Journals'), - 'calendar' => _('Calendar'), 'contact' => _('Contacts'), - 'note' => _('Notes'))); - if($this->kolabFolderType_Type == "mail"){ - $smarty->assign("kolabFolderType_SubTypes", array( - '' => _('Unspecified'), 'inbox' => _("Inbox") , - 'drafts' => _("Drafts"), 'sentitems' => _("Sent items"), - 'junkemail' => _("Junk mail"))); - }else{ - $smarty->assign("kolabFolderType_SubTypes", array( 'default' => _("Default"))); - } - $smarty->assign("kolabFolderType_Type", $this->kolabFolderType_Type); - $smarty->assign("kolabFolderType_SubType", $this->kolabFolderType_SubType); - }else{ - $smarty->assign("kolab", FALSE); - } - - - $display.= $smarty->fetch (get_template_path('mail.tpl', TRUE)); - return ($display); - } - - - /* remove object from parent */ - function remove_from_parent() - { - if(!$this->initially_was_account){ - return; - } - - /* Added these ObjectClass and Attributes, because they were not - removed correctly, only in case of kolab ... - */ - if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){ - $this->attributes[]="acl"; - $this->objectclasses[] = "kolabSharedFolder"; - } - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - /* Zero arrays */ - $this->attrs['gosaMailAlternateAddress']= array(); - $this->attrs['gosaMailForwardingAddress']= array(); - $this->attrs['gosaSharedFolderTarget']= array(); - - /* Connect to IMAP server for account deletion */ - if ($this->initially_was_account){ - - $method= new $this->method($this->config); - $method->fixAttributesOnRemove($this); - if ($method->connect($this->gosaMailServer) && $this->remove_folder_from_imap){ - - /* Remove account from IMAP server */ - $method->deleteMailbox($this->uid); - $method->disconnect(); - } - } - /* Keep uid */ - unset ($this->attrs['uid']); - - $ldap->cd($this->dn); - $ldap->modify ($this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/mail with dn '%s' failed."),$this->dn)); - - - 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"); - } - - - /* Save data to object */ - function save_object() - { - - /* Add special kolab attributes */ - if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){ - if(isset($_POST['kolabFolderType_Type'])){ - $this->kolabFolderType_Type = get_post("kolabFolderType_Type"); - $this->kolabFolderType_SubType = get_post("kolabFolderType_SubType"); - } - } - - /* Check if user wants to remove the shared folder from imap too */ - if($this->initially_was_account && !$this->is_account){ - if(isset($_POST['remove_folder_from_imap'])){ - $this->remove_folder_from_imap = true; - }else{ - $this->remove_folder_from_imap = false; - } - } - - /* Assemble mail delivery mode - The mode field in ldap consists of values between braces, this must - be called when 'mail' is set, because checkboxes may not be set when - we're in some other dialog. - - Example for gosaMailDeliveryMode [LR ] -L: Local delivery -R: Reject when exceeding mailsize limit -S: Use spam filter -V: Use vacation message -C: Use custom sieve script -I: Only insider delivery */ - if (isset($_POST['mailedit'])){ - - plugin::save_object(); - - $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode); - - /* Handle delivery flags */ - if($this->acl_is_writeable("gosaMailDeliveryModeL")){ - if(!preg_match("/L/",$tmp) && !isset($_POST['drop_own_mails'])){ - $tmp.="L"; - }elseif(preg_match("/L/",$tmp) && isset($_POST['drop_own_mails'])){ - $tmp = preg_replace("/L/","",$tmp); - } - } - - $opts = array( - "R" => "use_mailsize_limit", - "S" => "use_spam_filter", - "V" => "use_vacation", - "C" => "own_script", - "I" => "only_local"); - - foreach($opts as $flag => $post){ - if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){ - if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){ - $tmp.= $flag; - }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){ - $tmp = preg_replace("/".$flag."/","",$tmp); - } - } - } - - $tmp= "[$tmp]"; - if ($this->gosaMailDeliveryMode != $tmp){ - $this->is_modified= TRUE; - } - $this->gosaMailDeliveryMode= $tmp; - - /* Collect data and re-assign it to the imapacl array */ - if ($this->acl_is_writeable("acl")){ - $this->imapacl= array(); - $this->imapacl['%members%']= $_POST['member_permissions']; - $this->imapacl['anyone']= $_POST['default_permissions']; - foreach ($this->indexed_user as $nr => $user){ - if (!isset($_POST["user_$nr"])){ - continue; - } - if ($_POST["user_$nr"] != $user || - $_POST["perm_$nr"] != $this->indexed_acl[$nr]){ - $this->is_modified= TRUE; - } - $this->imapacl[$_POST["user_$nr"]]= $_POST["perm_$nr"]; - } - } - } - - } - - - - /* Save data to LDAP, depending on is_account we save or delete */ - function save() - { - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* Call parents save to prepare $this->attrs */ - plugin::save(); - - /* Save arrays */ - $this->attrs['gosaMailAlternateAddress'] = $this->gosaMailAlternateAddress; - $this->attrs['gosaMailForwardingAddress'] = $this->gosaMailForwardingAddress; - $this->attrs['gosaSharedFolderTarget'] = "share+".$this->uid; - - /* Only do IMAP actions if we are not a template */ - if(preg_match("/olab/i",$this->mmethod)){ - if (empty($this->gosaMailServer)||is_array($this->gosaMailServer)){ - if(isset($this->attrs['gosaMailServer'][0])){ - $this->gosaMailServer = $this->attrs['gosaMailServer'][0]; - } - } - } - - /* Exchange '%member%' pseudo entry */ - $memberacl= $this->imapacl['%members%']; - - foreach ($this->members as $user){ - if (!isset($this->imapacl[$user])){ - $this->imapacl[$user]= $memberacl; - } - } - - if(preg_match("/olab/i",$this->mmethod)){ - - /* Save acl's */ - $this->attrs['acl']= array(); - foreach ($this->imapacl as $user => $acl){ - if ($user == "" || preg_match("/%members%/",$user)){ - continue; - } - $ldap->search("(&(objectClass=person)(|(uid=".$user.")(mail=".$user.")))",array("mail")); - $mail = $ldap->fetch(); - if(isset($mail['mail'][0])){ - $sacl = $mail['mail'][0]." ".$acl; - }else{ - $sacl= "$user $acl"; - } - if(!in_array($sacl,$this->attrs['acl'])){ - $this->attrs['acl'][]= $sacl; - } - } - - if(!empty($this->kolabFolderType_Type)){ - $this->attrs['kolabFolderType'] = $this->kolabFolderType_Type.".".$this->kolabFolderType_SubType; - }else{ - $this->attrs['kolabFolderType'] = array(); - } - }else{ - - /* Save acl's */ - $this->attrs['acl']= array(); - foreach ($this->imapacl as $user => $acl){ - if ($user == "" || preg_match("/%members%/",$user)){ - continue; - } - $this->attrs['acl'][]= "$user $acl"; - } - } - - if ((!$this->is_template)&&(!empty($this->gosaMailServer))){ - $method= new $this->method($this->config); - $method->fixAttributesOnStore($this); - if (($method->connect($this->gosaMailServer))){ - $method->updateMailbox($this->uid); - $method->setQuota($this->uid, $this->gosaMailQuota); - $method->setSharedFolderPermissions($this->uid, $this->imapacl); - $method->disconnect(); - } - } - - /* Save data to LDAP */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of groups/mail with dn '%s' failed."),$this->dn)); - - 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"); - } - } else { - $this->handle_post_events("add"); - } - } - - /* Check formular input */ - function check() - { - $ldap= $this->config->get_ldap_link(); - - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(!$this->is_account) return array(); - - //$message[] = $str; - - /* must: mail */ - if ($this->mail == ""){ - $message[]= _("The required field 'Primary address' is not set."); - } - if (!is_email($this->mail)){ - $message[]= _("Please enter a valid email addres in 'Primary address' field."); - } - $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=". - $this->mail."))(!(uid=".$this->orig_cn."))(!(cn=".$this->orig_cn.")))"); - if ($ldap->count() != 0){ - $message[]= _("The primary address you've entered is already in use."); - } - - /* Check quota */ - if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){ - if (!is_numeric($this->gosaMailQuota)) { - $message[]= _("Value in 'Quota size' is not valid."); - } else { - $this->gosaMailQuota= (int) $this->gosaMailQuota; - } - } - - /* Check rejectsize for integer */ - if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailQuota")){ - if (!is_numeric($this->gosaMailMaxSize)){ - $message[]= _("Please specify a vaild mail size for mails to be rejected."); - } else { - $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize; - } - } - - /* Need gosaMailMaxSize if use_mailsize_limit is checked */ - if (is_integer(strpos($this->gosaMailDeliveryMode, "reject")) && $this->gosaMailMaxSize == ""){ - $message[]= _("You need to set the maximum mail size in order to reject anything."); - } - - if(ord($this->imapacl['anyone'][0])==194){ - $message[] = _("Please choose valid permission settings. Default permission can't be emtpy."); - } - - if(empty($this->gosaMailServer)){ - $message[] = _("Please select a valid mail server."); - } - - return ($message); - } - - /* Adapt from template, using 'dn' */ - function adapt_from_template($dn) - { - plugin::adapt_from_template($dn); - - foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){ - $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); - } - } - array_push($this->$val, $value); - } - } - } - } - - /* Add entry to forwarder list */ - function addForwarder($address) - { - $this->gosaMailForwardingAddress[]= $address; - $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress); - - sort ($this->gosaMailForwardingAddress); - reset ($this->gosaMailForwardingAddress); - $this->is_modified= TRUE; - } - - /* Remove list of addresses from forwarder list */ - function delForwarder($addresses) - { - $this->gosaMailForwardingAddress= array_remove_entries ($addresses, - $this->gosaMailForwardingAddress); - $this->is_modified= TRUE; - } - - - - function addAlternate($address) - { - $ldap= $this->config->get_ldap_link(); - - $address= strtolower($address); - - /* Is this address already assigned in LDAP? */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)". - "(gosaMailAlternateAddress=$address)))"); - - if ($ldap->count() > 0){ - $attrs= $ldap->fetch (); - return ($attrs["uid"][0]); - } - - /* Add to list of alternates */ - if (!in_array($address, $this->gosaMailAlternateAddress)){ - $this->gosaMailAlternateAddress[]= $address; - } - - sort ($this->gosaMailAlternateAddress); - reset ($this->gosaMailAlternateAddress); - $this->is_modified= TRUE; - - return (""); - } - - - function delAlternate($addresses) - { - $this->gosaMailAlternateAddress= array_remove_entries ($addresses, - $this->gosaMailAlternateAddress); - $this->is_modified= TRUE; - } - - - 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.= " "; - } - - return ($name); - } - - function getCopyDialog() - { - if(!$this->is_account) return(""); - - $smarty = get_smarty(); - $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress); - $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress); - $smarty->assign("mail",$this->mail); - $display= $smarty->fetch (get_template_path('paste_mail.tpl', TRUE)); - $ret = array(); - $ret['string'] = $display; - $ret['status'] = ""; - return($ret); - } - - function saveCopyDialog() - { - if(!$this->is_account) return; - - /* Perform ADD / REMOVE ... for mail alternate / mail forwarding addresses - */ - $this->execute(); - if(isset($_POST['mail'])){ - $this->mail = $_POST['mail']; - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Reset alternate mail addresses */ - $this->gosaMailAlternateAddress = array(); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Mail"), - "plDescription" => _("Group mail"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("groups"), - "plProvidedAcls"=> array( - "mail" => _("Mail address"), - "gosaMailAlternateAddress" => _("Alternate addresses"), - "gosaMailForwardingAddress" => _("Forwarding addresses"), - "gosaMailQuota" => _("Quota size"), - "gosaMailServer" => _("Mail server"), - "acl" => _("Permissions")) - )); - } - - - /* Remove given ACL for given member (uid,mail) .. - */ - function removeUserAcl($index ) - { - if(isset($this->imapacl[$index])){ - unset($this->imapacl[$index]); - } - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc deleted file mode 100644 index f146ad689..000000000 --- a/plugins/admin/groups/class_groupManagement.inc +++ /dev/null @@ -1,720 +0,0 @@ -config = &$config; - $this->ui = &$ui; - - /* Copy & Paste enabled ?*/ - if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - - /* Detect if we have to display the primary group checkbox */ - $tmp = ""; - if (isset($this->config->data['MAIN']['NOPRIMARYGROUP'])){ - $tmp = $this->config->data['MAIN']['NOPRIMARYGROUP']; - } - if(preg_match("/true/i",$tmp)|| (preg_match("/yes/",$tmp))){ - $this->ShowPrimaryCheckBox = false; - } else { - $this->ShowPrimaryCheckBox = true; - } - - /* Create dialog object */ - $this->DivListGroup = new divListGroup($this->config,$this); - $this->DivListGroup->DisableCheckBox("ShowPrimaryGroups",$this->ShowPrimaryCheckBox); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Store these posts if the current object is locked (used by somebody else)*/ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_groups/"); - - /* Save data */ - $s_action = ""; - $s_entry = ""; - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/^group_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/group_".$s_action."_/i","",$key); - // Post for edit - }elseif(preg_match("/^group_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/group_".$s_action."_/i","",$key); - // Post for new - }elseif(preg_match("/^group_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/^dep_home.*/i",$key)){ - $s_action="home"; - }elseif(preg_match("/^group_tplnew.*/i",$key)){ - $s_action="new_tpl"; - }elseif(preg_match("/^group_chgpw.*/i",$key)){ - $s_action="change_pw"; - $s_entry = preg_replace("/group_chgpw_/i","",$key); - }elseif(preg_match("/_group_edit_/",$key)){ - $type = preg_replace("/_group_edit_.*$/","",$key); - $s_action="edit"; - $s_entry = preg_replace("/".$type."_group_edit_/i","",$key); - $_POST['arg'] = $type; - }elseif(preg_match("/^editPaste.*/i",$key)){ - $s_action="editPaste"; - }elseif(preg_match("/^copy_.*/",$key)){ - $s_action="copy"; - $s_entry = preg_replace("/^copy_/i","",$key); - }elseif(preg_match("/^cut_.*/",$key)){ - $s_action="cut"; - $s_entry = preg_replace("/^cut_/i","",$key); - }elseif(preg_match("/^remove_multiple_groups/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^multiple_copy_groups/",$key)){ - $s_action = "copy_multiple"; - }elseif(preg_match("/^multiple_cut_groups/",$key)){ - $s_action = "cut_multiple"; - } - } - $s_entry = preg_replace("/_.$/","",$s_entry); - - /* Check for posted gets */ - if((isset($_GET['act'])) && ($_GET['act'] == "edit_entry")){ - $s_entry = $_GET['id']; - $s_action = "edit"; - } - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "group_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - - $smarty= get_smarty(); - - /******************** - Copy & Paste Handling ... - ********************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /******************** - Create a new group ... - ********************/ - - /* New group? */ - if ($s_action=="new"){ - - /* Check create permissions */ - $acl = $this->ui->get_permissions($this->DivListGroup->selectedBase,"groups/group"); - if(preg_match("/c/",$acl)){ - - /* By default we set 'dn' to 'new', all relevant plugins will - react on this. */ - $this->dn= "new"; - - /* Create new usertab object */ - $this->grouptab= new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $this->dn); - - /* Set up the group ACL's for this 'dn' */ - $this->grouptab->set_acl_base($this->DivListGroup->selectedBase); - } - } - - - /******************** - Save Group Tab/Object Changes - ********************/ - - /* Finish group edit is triggered by the tabulator dialog, so - the user wants to save edited data. Check and save at this - point. */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->grouptab->config)) ){ - - /* Check tabs, will feed message array - Save, or display error message? */ - $message= $this->grouptab->check(); - if (count($message) == 0){ - - /* Save user data to ldap */ - $this->grouptab->save(); - - if (!isset($_POST['edit_apply'])){ - /* Group has been saved successfully, remove lock from LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - - /* There's no page reload so we have to read new groups at this point. */ - //$this->reload (); - unset ($this->grouptab); - $this->grouptab= NULL; - unset ($_SESSION['objectinfo']); - } - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /******************** - Edit existing group - ********************/ - - /* User wants to edit data? */ - if (($s_action=="edit") && (!isset($this->grouptab-> config))){ - - /* Get 'dn' from posted 'uid', must be unique */ - $this->dn= $this->grouplist[trim($s_entry)]['dn']; - - /* Check locking & lock entry if required */ - $user = get_lock($this->dn); - if ($user != ""){ - return(gen_locked_message ($user, $this->dn)); - } - add_lock ($this->dn, $this->ui->dn); - - /* Register grouptab to trigger edit dialog */ - $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn); - $this->grouptab->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->grouplist[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("info", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("info", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); - } - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Groups should be deleted. */ - if (isset($_POST['delete_multiple_groups_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $acl = $this->ui->get_permissions($dn,"groups/group"); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn); - $this->grouptab->set_acl_base($dn); - $this->grouptab->delete (); - unset ($this->grouptab); - $this->grouptab= NULL; - - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this group!")); - new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_user_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete group - ********************/ - - /* Remove group was requested */ - if ($s_action=="del"){ - - /* Get 'dn' from posted 'uid' */ - $this->dn= $this->grouplist[trim($s_entry)]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $acl = $this->ui->get_permissions($this->dn,"groups/group"); - if(preg_match("/d/",$acl)){ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the group '%s'."), @LDAP::fix($this->dn))); - $smarty->assign("multiple", false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - - } else { - - /* Obviously the user isn't allowed to delete. Show message and clean session. */ - print_red (_("You are not allowed to delete this group!")); - } - } - - - /******************** - Delete group confirmed - ********************/ - - /* Confirmation for deletion has been passed. Group should be deleted. */ - if (isset($_POST['delete_group_confirm'])){ - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - $acl = $this->ui->get_permissions($this->dn,"groups/group"); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn); - $this->grouptab->set_acl_base($this->dn); - $this->grouptab->delete (); - unset ($this->grouptab); - $this->grouptab= NULL; - - /* Group list has changed, reload it. */ - //$this->reload (); - - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this group!")); - new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - - /******************** - Delete group canceled - ********************/ - - /* Delete group canceled? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - - /******************** - A dialog was canceled - ********************/ - - /* Cancel dialogs */ - if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ - if(isset($this->grouptab->dn)){ - del_lock ($this->grouptab->dn); - } - unset ($this->grouptab); - $this->grouptab= NULL; - unset($_SESSION['objectinfo']); - } - - - /******************** - If there is currently a dialog open, display it - ********************/ - - /* Show tab dialog if object is present */ - if (isset($this->grouptab->config)){ - $display= $this->grouptab->execute(); - - /* Don't show buttons if tab dialog requests this */ - if(isset($this->grouptab->by_object)){ - if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - } - return ($display); - } - - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListGroup->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Display dialog with group list */ - $this->DivListGroup->parent = $this; - $this->DivListGroup->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListGroup->SubSearch){ - $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4,1); - } - $this->reload (); - $this->DivListGroup->setEntries($this->grouplist); - return($this->DivListGroup->Draw()); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array(get_groups_ou().$this->DivListGroup->selectedBase)); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function reload($CreatePosixsList=false) - { - $this->grouplist = array(); - $primaries = array(); - $functional = array(); - $error= $error2 = ""; - $filter = "(objectclass=posixGroup)"; - - $base = $this->DivListGroup->selectedBase; - $Regex = $this->DivListGroup->Regex; - $UserRegex = $this->DivListGroup->UserRegex; - $SubSearch = $this->DivListGroup->SubSearch; - $ShowPrimaryGroups = $this->DivListGroup->ShowPrimaryGroups; - $ShowSambaGroups = $this->DivListGroup->ShowSambaGroups; - $ShowApplicationGroups = $this->DivListGroup->ShowApplicationGroups; - $ShowMailGroups = $this->DivListGroup->ShowMailGroups; - $ShowFunctionalGroups = $this->DivListGroup->ShowFunctionalGroups; - - /* Prepare ldap class */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($base); - $ldap->set_size_limit($_SESSION['size_limit']); - - - /******************** - Create filter depending on selected checkboxes - ********************/ - - /* Add application groups */ - if ($ShowApplicationGroups){ - $filter.= "(objectClass=gosaApplicationGroup)"; - } - - /* Add Mail Groups */ - if ($ShowMailGroups){ - $filter.= "(objectClass=gosaMailAccount)"; - } - - $sfilter= ""; - if ($this->config->current['SAMBAVERSION'] == 3){ - if (!$ShowPrimaryGroups){ - $sfilter= "(objectClass=sambaGroupMapping)"; - } elseif ($ShowSambaGroups){ - $filter.= "(objectClass=sambaGroupMapping)"; - } - } - - /* Prepare filter for given Regex && UserRegex */ - if ($filter != ""){ - $filter= "(&(cn=$Regex)(objectClass=posixGroup)(|$filter))"; - if ($UserRegex != ""){ - $filter= "(&(|(memberUID=".$UserRegex.")(cn=".$UserRegex."))$filter)"; - } - } - - - /******************** - Collect some groupids to be able to skip primary & functional groups - ********************/ - - /* Collect primary groupIDs to show primary groups - if this option is enabled in gosa conf && the checkbox is checked */ - if ($this->ShowPrimaryCheckBox){ - $res = get_list("(&(uid=$Regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))", - "groups", $base,array("gidNumber", "cn"), GL_SUBSEARCH); - foreach ($res as $attrs){ - $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0]; - } - } - - /* Collect all GroupIDs from those groups which are functional. - Only perfrom this search if ShowFunctionalGroups is unchecked, else leave arre empty */ - $ff = "(&(cn=$Regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))"; - if ($SubSearch){ - $res = get_list($ff, "groups", $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH); - } else { - $res = get_list($ff, "groups", $base,array("gidNumber", "cn", "description"), GL_NONE); - } - foreach($res as $attrs){ - if (!isset($primaries[$attrs['gidNumber'][0]])){ - $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0]; - } - } - - - /******************** - Search for the prepared filter - ********************/ - - /* Attributes to search for */ - $attrs = array("cn", "description", "gidNumber", "objectClass"); - - /* If subsearch is activated search for subobjects too */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - $attrs [] = "FAIrelease"; - } - - if ($SubSearch){ - $res= get_list($filter, "groups", $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH); - } else { - $res= get_list($filter, "groups", get_groups_ou().$base, $attrs, GL_SIZELIMIT); - } - - /* Sort values into grouplist*/ - $tmp = $tmp2 = array(); - foreach ($res as $value){ - /* Skip functional groups if checkbox isn't checked */ - if (!$ShowFunctionalGroups && isset($functional[$value['gidNumber'][0]])){ - continue; - } - - /* If gidNumber is in $primaries skip this entry */ - if (($ShowPrimaryGroups) || (!$ShowPrimaryGroups && !isset($primaries[$value['gidNumber'][0]]))){ - $tmp2[$value['cn'][0]] = $value; - $tmp [$value['cn'][0]] = $value['cn'][0]; - } - } - natcasesort($tmp); - foreach($tmp as $name){ - $this->grouplist[] = $tmp2[$name]; - } - reset ($this->grouplist); - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->grouplist[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups"); - } - - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->grouplist[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","grouptabs","GROUPTABS","groups"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","grouptabs","GROUPTABS","groups"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - /* Save data to object */ - function save_object() - { - $this->DivListGroup->save_object(); - } - - - function remove_lock() - { - if (isset($this->grouptab->dn)){ - del_lock ($this->grouptab->dn); - } - } - - - function remove_from_parent() - { - /* Optionally execute a command after we're done */ - $this->postremove(); - } - - - /* Save to LDAP */ - function save() - { - /* Optionally execute a command after we're done */ - $this->postcreate(); - } - - /* Unused functions */ - function check() { } - function adapt_from_template($dn) { } - function password_change_needed() { } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/groups/generic.tpl b/plugins/admin/groups/generic.tpl deleted file mode 100644 index 4d67c8665..000000000 --- a/plugins/admin/groups/generic.tpl +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - {if $samba3 ne ""} - - - - {/if} - {if $pickupGroup == "true"} - - - - - - - - - - {/if} - {if $nagios == "true"} - - - - - - - - - - {/if} -
{$must} -{render acl=$cnACL} - -{/render} -
- - -{render acl=$descriptionACL} - -{/render} -
-
-
- {$must} - -{render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-{render acl=$gidNumberACL} - -{/render} - -   -{render acl=$gidNumberACL} - -{/render} -
-{render acl=$sambaGroupTypeACL} - -{/render} -{render acl=$sambaGroupTypeACL} - -{/render} -   - -   -{render acl=$sambaDomainNameACL} - -{/render} -
-{render acl=$fonGroupACL} - {t}Members are in a phone pickup group{/t} -{/render} -
-{render acl=$nagiosGroupACL} - {t}Members are in a nagios group{/t} -{/render} -
- -
-   - - - - - - -
- -
-{render acl=$memberUidACL} - -{/render} -
- -   - -
-
- - - - - diff --git a/plugins/admin/groups/group_objects.tpl b/plugins/admin/groups/group_objects.tpl deleted file mode 100644 index 5fcdc73a2..000000000 --- a/plugins/admin/groups/group_objects.tpl +++ /dev/null @@ -1,59 +0,0 @@ - - - - - -
-
-

- {$hint} -

-
-
-

- - -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - -
- {t}Search within subtree{/t}
-
- - - - -
- -   - -
- -
- {$apply} -
-
- -

- -   - -

- diff --git a/plugins/admin/groups/mail.tpl b/plugins/admin/groups/mail.tpl deleted file mode 100644 index e7eb7083a..000000000 --- a/plugins/admin/groups/mail.tpl +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - -
-

{t}Generic{/t}

- - - - - - - - - - - - - - - - - - {if $kolab} - - - - - {/if} -
{$must} -{render acl=$mailACL} - -{/render} -
-{render acl=$gosaMailServerACL} - -{/render} -
-
- -
-
-{if $quotadefined eq "true"} - {$quotausage} -{else} - {t}not defined{/t} -{/if} -
{t}Quota size{/t} -{render acl=$gosaMailQuotaACL} - -{/render} - {t}MB{/t} -
- {t}Folder type{/t} - - - - {if !$JS} - - {/if} -
- -
-

{t}Alternative addresses{/t}

- -{render acl=$gosaMailAlternateAddressACL} - -{/render} - -
- -{render acl=$gosaMailAlternateAddressACL} - -{/render} - -{render acl=$gosaMailAlternateAddressACL} -   -{/render} - -{render acl=$gosaMailAlternateAddressACL} - -{/render} - -
- -

 

- - - - - - -
-

{t}IMAP shared folders{/t}

- - - - - - - - - - - {$plusattributes} -
-{render acl=$aclACL} - -{/render} -
-{render acl=$aclACL} - -{/render} -
- -
-

- - {t}Forward messages to non group members{/t} -

- -{render acl=$gosaMailForwardingAddressACL} - -{/render} - -
- -{render acl=$gosaMailForwardingAddressACL} - -{/render} -{render acl=$gosaMailForwardingAddressACL} -   -{/render} -{render acl=$gosaMailForwardingAddressACL} -   -{/render} -{render acl=$gosaMailForwardingAddressACL} - -{/render} -
- - - diff --git a/plugins/admin/groups/mail_admins.tpl b/plugins/admin/groups/mail_admins.tpl deleted file mode 100644 index 8c95cb0d0..000000000 --- a/plugins/admin/groups/mail_admins.tpl +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - -
- -
- -
- -
-
- -
-
- -
- : - - - {if $javascript ne "true"} - - {/if} -
- -

- -   - -

diff --git a/plugins/admin/groups/mail_locals.tpl b/plugins/admin/groups/mail_locals.tpl deleted file mode 100644 index 09d734a9b..000000000 --- a/plugins/admin/groups/mail_locals.tpl +++ /dev/null @@ -1,69 +0,0 @@ - - - - - -
-
-

-
-

-
-
-

- -

-
-
-
-

- [F] - {t}Filters{/t} -

-
-
- - {$alphabet} -
- - - - -
-   - -
- - - - - -
- - - -
- - - - - -
- - - -
- {$apply} -
-
- -

- -   - -

diff --git a/plugins/admin/groups/main.inc b/plugins/admin/groups/main.inc deleted file mode 100644 index 3a1210163..000000000 --- a/plugins/admin/groups/main.inc +++ /dev/null @@ -1,60 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('groupManagement'); - } -} else { - /* Create groupManagement object on demand */ - if (!isset($_SESSION['groupManagement']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['groupManagement']= new groupManagement ($config, $_SESSION['ui']); - } - $groupManagement= $_SESSION['groupManagement']; - $groupManagement->save_object(); - $output= $groupManagement->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/group.png'), - _("Group administration"), "\"\" ". - @LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/group.png'), _("Group administration")); - } - - $display.= $output; - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('groupManagement'); - } - - /* Show and save dialog */ - $_SESSION['groupManagement']= $groupManagement; -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/groups/paste_generic.tpl b/plugins/admin/groups/paste_generic.tpl deleted file mode 100644 index 26477def6..000000000 --- a/plugins/admin/groups/paste_generic.tpl +++ /dev/null @@ -1,25 +0,0 @@ -

{t}Group settings{/t}

- - - - - - - - - -
- {t}Group name{/t} - - -
- - - - -
- - diff --git a/plugins/admin/groups/paste_mail.tpl b/plugins/admin/groups/paste_mail.tpl deleted file mode 100644 index e30ba9af0..000000000 --- a/plugins/admin/groups/paste_mail.tpl +++ /dev/null @@ -1,56 +0,0 @@ -

{t}Mail settings{/t}

- - - - - - -
- - - - - -
- {$must} - - -
-
- - - - - -
- {t}Alternative addresses{/t} - -
- -   - -
- {t}Forward messages to non group members{/t} - -
- -   -   - -
-
-
- - - diff --git a/plugins/admin/groups/remove.tpl b/plugins/admin/groups/remove.tpl deleted file mode 100644 index 1c938342c..000000000 --- a/plugins/admin/groups/remove.tpl +++ /dev/null @@ -1,27 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}This may be a primary user group. Please double check if you really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- - {if $multiple} - -   - - {else} - -   - - {/if} - - -

- diff --git a/plugins/admin/groups/tabs_group.inc b/plugins/admin/groups/tabs_group.inc deleted file mode 100644 index 094551de9..000000000 --- a/plugins/admin/groups/tabs_group.inc +++ /dev/null @@ -1,101 +0,0 @@ -addSpecialTabs(); - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - - /* Update reference, transfer variables */ - $baseobject= $this->by_object['group']; - foreach ($this->by_object as $name => $obj){ - /* Don't touch base object */ - if ($name != 'group'){ - $obj->parent= &$this; - $obj->cn= $baseobject->cn; - $this->by_object[$name]= $obj; - } - } - } - - function delete() - { - /* Put baseobjects 'cn' to mailobjects 'uid' */ - $baseobject= $this->by_object['group']; - if (isset($this->by_object['mailgroup'])){ - $this->by_object['mailgroup']->uid= $baseobject->cn; - } - tabs::delete(); - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['group']; - - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base; - - /* Put baseobjects 'cn' to mailobjects 'uid' */ - if (isset($this->by_object['mailgroup'])){ - $this->by_object['mailgroup']->uid= $baseobject->cn; - } - - - /* Update reference, transfer variables */ - foreach ($this->by_object as $name => $obj){ - /* Transfer attributes for mailgroup account */ - if ($name == 'mailgroup'){ - $this->by_object['mailgroup']->members= $baseobject->memberUid;; - } - } - - /* Move group? */ - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->update_acls($this->dn,$new_dn); - $baseobject->move($this->dn, $new_dn); - $this->by_object['group']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - $ret= tabs::save(); - - /* Fix tagging if needed */ - $baseobject->dn= $new_dn; - $baseobject->handle_object_tagging(); - - return $ret; - } - - function saveCopyDialog() - { - tabs::saveCopyDialog(); - - /* Update reference, transfer variables */ - $baseobject= $this->by_object['group']; - foreach ($this->by_object as $name => $obj){ - /* Don't touch base object */ - if ($name != 'group'){ - $obj->parent= &$this; - $obj->cn= $baseobject->cn; - $this->by_object[$name]= $obj; - } - } - } - -} - -?> diff --git a/plugins/admin/mimetypes/class_divListMimeTypes.inc b/plugins/admin/mimetypes/class_divListMimeTypes.inc deleted file mode 100755 index 1c8677f46..000000000 --- a/plugins/admin/mimetypes/class_divListMimeTypes.inc +++ /dev/null @@ -1,343 +0,0 @@ -selectedRelease = "ou=mime,".$_SESSION['CurrentMainBase']; - $this->parent = &$parent; - $this->ui = get_userinfo(); - $this->AvailableReleases= $this->parent->getReleases($this->selectedBase); - - /* Set list strings */ - $this->SetTitle (_("List of defined mime types")); - $this->SetSummary (_("List of defined mime types")); - $this->SetInformation (_("This menu allows you to add, edit and remove selected mime types. You may want to use the range selector on top of the mime type listbox, when working with a large number of mime types.")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->EnableAplhabet(true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* set Page header */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Mime type name")." / "._("Department"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); - - /* Add SubSearch checkbox */ - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Display mime types matching"),"*" , true); - } - - - /* This function allows us to add a user defined filter part at position $position*/ - function AddUserBoxToFilter($position) - { - $str = ""; - if(($position == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){ - $smarty = get_smarty(); - $smarty->assign("selectedRelease",$this->selectedRelease); - $smarty->assign("branchimage","images/branch.png"); - $smarty->assign("releases",$this->AvailableReleases); - $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE,dirname(__FILE__))); - } - return($str); - } - - - /* Create list header, with create / copy & paste etc*/ - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments($this->module); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get acls */ - $ui = get_userinfo(); - $acl = $ui->get_permissions("cn=dummy,ou=mimetypes,".$this->selectedBase,"mimetypes/mimetype"); - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"mimetypes") ; - - - /* If this is true we add an additional seperator. Just look a few lines below */ - $add_sep = false; - - /* Get copy & paste icon */ - $Copy_Paste =""; - if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){ - $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon(); - $add_sep = true; - } - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* And at least add a department selection box */ - $listhead .= _("Base")." ". - "  "; - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("Mime type")."|mime_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - } - - - /* Some basic settings */ - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - - function setEntries($list) - { - /******************** - Variable init - ********************/ - - /* Create links */ - $linkopen = "%s"; - $editlink = "%s"; - $userimg = "User"; - $mimeimg = "A"; - $empty = ""; - - /* set Page header */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /******************** - Attach objects - ********************/ - - foreach($list as $key => $val){ - - $ui = get_userinfo(); - $acl = $ui->get_permissions($val['dn'],"mimetypes/mimetype"); - $acl_all = $ui->has_complete_category_acls($val['dn'],"mimetypes") ; - - /* Create action icons */ - $actions = ""; - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions .= $this->GetSnapShotActions($val['dn']); - } - - /* Get copy Paste icons */ - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions.= " "; - $actions.= " "; - } - - $actions.= ""; - - /* Add delete button */ - if(preg_match("/d/",$acl)){ - $actions.= ""; - }else{ - $actions.= " "; - } - - $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; - - if(!isset($val['description'][0])){ - $desc = ""; - }else{ - $desc = " - [ ".$val['description'][0]." ]"; - } - - /* Cutted objects should be displayed in light grey */ - $display = $val['cn'][0].$desc; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => sprintf($mimeimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); - $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field0,$field1,$field2,$field3)); - } - - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_objs = count($list); - - $num_obj_str = _("Number of listed mimetypes"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_obj_str." ".$num_objs."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - } - - function Save() - { - MultiSelectWindow::Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - - /* check if returned selectedRelease is a valid release. - If it isn't set to a valid release */ - $this->AvailableReleases = $this->parent->getReleases($this->selectedBase); - if(!isset($this->AvailableReleases[$this->selectedRelease])){ - $this->selectedRelease =key($this->AvailableReleases); - } - $_SESSION['mimefilter']['release'] = $this->selectedRelease; - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/mimetypes/class_mimetypeGeneric.inc b/plugins/admin/mimetypes/class_mimetypeGeneric.inc deleted file mode 100644 index 38b695e98..000000000 --- a/plugins/admin/mimetypes/class_mimetypeGeneric.inc +++ /dev/null @@ -1,755 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - var $objectclasses = array("top","gotoMimeType"); - var $attributes = array("cn","gotoMimeApplication","gotoMimeLeftClickAction","gotoMimeIcon", - "description","gotoMimeFilePattern","gotoMimeEmbeddedApplication", - "gotoMimeGroup"); - - /* Class vars */ - var $ui; - var $cn = ""; - var $gotoMimeLeftClickAction = "I"; - var $gotoMimeLeftClickAction_I = true; - var $gotoMimeLeftClickAction_E = false; - var $gotoMimeLeftClickAction_Q = false; - var $gotoMimeIcon = "*removed*"; - var $description = ""; - var $gotoMimeFilePattern = array(); - var $gotoMimeApplication = array(); - var $gotoMimeEmbeddedApplication = array(); - var $gotoMimeGroup = ""; - var $iconData = NULL; - var $base = ""; - var $ApplicationList = array(); - - - /* To prevent errors when using the 'apply' button, we use this variables - to manage array attributes */ - var $use_gotoMimeIcon = NULL; - var $use_gotoMimeFilePattern = array(); - var $use_gotoMimeApplication = array(); - var $use_gotoMimeEmbeddedApplication = array(); - - /* divLists */ - var $DivPatterns = NULL; - var $DivApps = NULL; - var $DivEApps = NULL; - - /* Mime type release mode */ - var $isReleaseMimeType = false; - - /* These vars will be copied too, if you use copy&paste mode */ - var $CopyPasteVars = array("use_gotoMimeFilePattern","use_gotoMimeApplication","use_gotoMimeEmbeddedApplication","iconData", - "gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q","use_gotoMimeIcon"); - - var $view_logged = FALSE; - - /* Select options */ - var $MimeGroups = array("application","audio","chemical","image","inode","message","model", - "multipart","text","video","x-conference","x-world"); - - /* Orig_Dn is used to verify if this object is new or only edited */ - var $orig_dn = ""; - - function mimetype(&$config,$dn= NULL) - { - plugin::plugin ($config, $dn); - - /* Save original dn */ - $this->orig_dn = $dn; - - /* get gotoMimeLeftClickActions I/E/Q */ - if(isset($this->gotoMimeLeftClickAction)){ - $str = $this->gotoMimeLeftClickAction; - for($i = 0 ; $i < strlen($str) ; $i ++ ){ - $varna = "gotoMimeLeftClickAction_". $str[$i]; - if(isset($this->$varna)){ - $this->$varna = true; - } - } - } - - /* Create list of defined applications in GOsa */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaApplication)(cn=*))",array('cn')); - $this->ApplicationList = array(); - while($attrs = $ldap->fetch()){ - $this->ApplicationList[$attrs['cn'][0]] = $attrs['cn'][0]; - } - - /* If both radio buttons arn't set, set option I */ - if(!$this->gotoMimeLeftClickAction_I && !$this->gotoMimeLeftClickAction_E){ - $this->gotoMimeLeftClickAction_I = true; - } - - /* Get list of array attributes */ - foreach(array("gotoMimeFilePattern") as $attr){ - $this->$attr = array(); - if(isset($this->attrs[$attr])){ - $tmp = array(); - for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){ - $str = $this->attrs[$attr][$i]; - $tmp[] = $str; - } - $use_attr = "use_".$attr; - $this->$use_attr = $tmp; - } - } - - /* Get list of array attributes with priority tag ( Test|32 )*/ - foreach(array("gotoMimeApplication","gotoMimeEmbeddedApplication") as $attr){ - $this->$attr = array(); - if(isset($this->attrs[$attr])){ - $tmp = array(); - for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){ - $str = $this->attrs[$attr][$i]; - $tmp2= split("\|",$str); - - if(count($tmp2) == 2){ - $name = $tmp2[0]; - $prio = $tmp2[1]; - $tmp[$prio] = $name; - } - } - ksort($tmp); - $use_attr = "use_".$attr; - $this->$use_attr = $tmp; - } - } - - /* Check if release Management is enabled */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)) { - $this->isReleaseMimeType= true; - } - - /* Set base */ - if ($this->dn == "new"){ - if(isset($_SESSION['CurrentMainBase'])){ - $this->base= $_SESSION['CurrentMainBase']; - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn); - } - - /* Get icon data */ - if(isset($this->attrs['gotoMimeIcon'])){ - $ldap = $this->config->get_ldap_link(); - $this->iconData = $ldap->get_attribute($this->dn,"gotoMimeIcon"); - $this->saved_attributes['gotoMimeIcon'] = $this->iconData; - } - if ($this->iconData == ""){ - $this->set_new_picture(""); - } - $_SESSION['binary'] = $this->iconData; - $_SESSION['binarytype'] = "image/jpeg"; - } - - - function execute() - { - $smarty = get_smarty(); - - if(!$this->view_logged){ - $this->view_logged =TRUE; - new log("view","mimetypes/".get_class($this),$this->dn); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Check Posts */ - $posts = array( - "/^Pattern_SortUp_/" => array("Action" => "Pattern_SortUp", "Func" => "ArrayUp", "Attr" => "use_gotoMimeFilePattern"), - "/^Pattern_SortDown_/" => array("Action" => "Pattern_SortDown","Func" => "ArrayDown", "Attr" => "use_gotoMimeFilePattern"), - "/^Pattern_Remove_/" => array("Action" => "Pattern_Remove", "Func" => "ArrayRemove","Attr" => "use_gotoMimeFilePattern"), - "/^Apps_SortUp_/" => array("Action" => "Apps_SortUp", "Func" => "ArrayUp", "Attr" => "use_gotoMimeApplication"), - "/^Apps_SortDown_/" => array("Action" => "Apps_SortDown", "Func" => "ArrayDown", "Attr" => "use_gotoMimeApplication"), - "/^Apps_Remove_/" => array("Action" => "Apps_Remove", "Func" => "ArrayRemove","Attr" => "use_gotoMimeApplication"), - "/^EApps_SortUp_/" => array("Action" => "EApps_SortUp", "Func" => "ArrayUp", "Attr" => "use_gotoMimeEmbeddedApplication"), - "/^EApps_SortDown_/" => array("Action" => "EApps_SortDown", "Func" => "ArrayDown", "Attr" => "use_gotoMimeEmbeddedApplication"), - "/^EApps_Remove_/" => array("Action" => "EApps_Remove", "Func" => "ArrayRemove","Attr" => "use_gotoMimeEmbeddedApplication")); - $once = true; - - /* Walk through posts and try to find some commands for us. */ - foreach($_POST as $name => $value){ - - /* Walk through possible commands */ - foreach($posts as $regex => $action){ - - /* Check if there is a command posted */ - if(preg_match($regex,$name) && $once){ - $once = false; - - /* Get action vars */ - $func = $action['Func']; // Get function name - $attr = $action['Attr']; // Get attribute name - - /* Get entry id */ - $s_entry = preg_replace($regex,"",$name); - $s_entry = preg_replace("/_[xy]$/","",$s_entry); - - /* Execute a command with the given attribute and entry - e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */ - if($this->acl_is_writeable($attr)){ - $this->$attr= $this->$func($s_entry,$this->$attr,true); - } - } - } - } - - /* Set a new icon was requested */ - if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){ - $this->set_new_picture($_FILES['picture_file']['tmp_name']); - } - - /* Add gotoMimeFilePattern */ - if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){ - if($this->acl_is_writeable("gotoMimeFilePattern")){ - $str = $_POST['NewFilePattern']; - if(!empty($str)){ - $this->use_gotoMimeFilePattern[] = $str; - } - } - } - - /* Add gotoMimeFilePattern */ - if(isset($_POST['AddNewApplication']) && - (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){ - if($this->acl_is_writeable("gotoMimeApplication")){ - $str = ""; - if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){ - $str = get_post("NewApplicationSelect"); - } - if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){ - $str = get_post("NewApplication"); - } - if(!empty($str) && !in_array($str,$this->use_gotoMimeApplication)){ - $this->use_gotoMimeApplication[] = $str; - } - } - } - - /* Add embedded application - * - From input or from select box - */ - if(isset($_POST['AddNewEmbeddedApplication']) && - (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){ - if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ - $str = ""; - if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){ - $str = get_post('NewEmbeddedApplicationSelect'); - } - if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){ - $str = get_post('NewEmbeddedApplication'); - } - if(!empty($str) && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){ - $this->use_gotoMimeEmbeddedApplication[] = $str; - } - } - } - - /* Create divlists */ - $DivPatterns = new divSelectBox("gotoMimePatterns"); - $DivApps = new divSelectBox("gotoMimeApplications"); - $DivEApps = new divSelectBox("gotoMimeEmbeddedApplications"); - $DivPatterns -> SetHeight(100); - $DivApps -> SetHeight(100); - $DivEApps -> SetHeight(100); - - - if($this->acl_is_writeable("gotoMimeFilePattern")){ - $Pattern_Actions= "   -   - "; - }else{ - $Pattern_Actions= ""; - } - - if($this->acl_is_writeable("gotoMimeApplication")){ - $Apps_Actions = "   -   - "; - }else{ - $Apps_Actions= ""; - } - - if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ - $EApps_Actions = "   -   - "; - }else{ - $EApps_Actions= ""; - } - - /* Before adding some entries check acls */ - if($this->acl_is_readable("gotoMimeFilePattern")){ - foreach($this->use_gotoMimeFilePattern as $key => $pattern){ - $field1 = array("string" => $pattern); - $field2 = array("string" => preg_replace("/%s/",$key,$Pattern_Actions),"attach"=>"style='border-right:0px;width:50px;'"); - $fields = array($field1,$field2); - $DivPatterns -> AddEntry($fields); - } - } - - if($this->acl_is_readable("gotoMimeApplication")){ - foreach($this->use_gotoMimeApplication as $key => $pattern){ - $field1 = array("string" => $pattern); - $field2 = array("string" => preg_replace("/%s/",$key,$Apps_Actions),"attach"=>"style='border-right:0px;width:50px;'"); - $fields = array($field1,$field2); - $DivApps -> AddEntry($fields); - } - } - if($this->acl_is_readable("gotoMimeEmbeddedApplication")){ - foreach($this->use_gotoMimeEmbeddedApplication as $key => $pattern){ - $field1 = array("string" => $pattern); - $field2 = array("string" => preg_replace("/%s/",$key,$EApps_Actions),"attach"=>"style='border-right:0px;width:50px;'"); - $fields = array($field1,$field2); - $DivEApps -> AddEntry($fields); - } - } - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("base_select", $this->base); - $smarty->assign("isReleaseMimeType", $this->isReleaseMimeType); - $smarty->assign("gotoMimeFilePatterns", $DivPatterns->DrawList()); - $smarty->assign("gotoMimeApplications", $DivApps->DrawList()); - $smarty->assign("gotoMimeEmbeddedApplications", $DivEApps->DrawList()); - - $smarty->assign("ApplicationList",$this->ApplicationList); - - /* Assign class vars to smarty */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign additional vars that are not included in attributes*/ - foreach(array("gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q") as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign select box options */ - $smarty->assign("gotoMimeGroups",$this->MimeGroups); - $smarty->assign("gotoMimeIcon" ,$this->get_picture()); - return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); - } - - - function save_object() - { - if(isset($_POST['MimeGeneric'])){ - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - /* Only save base if we are not in release mode */ - if(!$this->isReleaseMimeType){ - - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - - } - - /* Save radio buttons */ - if($this->acl_is_writeable("gotoMimeLeftClickAction")){ - if(isset($_POST['gotoMimeLeftClickAction_IE'])){ - $chr = $_POST['gotoMimeLeftClickAction_IE']; - if($chr == "E"){ - $this->gotoMimeLeftClickAction_E = true; - $this->gotoMimeLeftClickAction_I = false; - }else{ - $this->gotoMimeLeftClickAction_E = false; - $this->gotoMimeLeftClickAction_I = true; - } - } - if(isset($_POST['gotoMimeLeftClickAction_Q'])){ - $this->gotoMimeLeftClickAction_Q = true; - }else{ - $this->gotoMimeLeftClickAction_Q = false; - } - } - } - } - - - /* save current changes */ - function save() - { - /* Create gotoMimeLeftClickAction out of checkboxes and radio buttons */ - $arr = array ("E","I","Q"); - $str = ""; - foreach ($arr as $Chr){ - $var = "gotoMimeLeftClickAction_".$Chr; - if($this->$var){ - $str .= $Chr; - } - } - $this->gotoMimeLeftClickAction = $str; - - /* Create array entries with priority tag ( Test|3 )*/ - foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication") as $attr){ - $i = 0; - $use_attr = "use_".$attr; - $tmp = array(); - $this->$attr = array(); - foreach($this->$use_attr as $entry){ - $tmp[] = $entry."|".$i ++; - } - $this->$attr = $tmp; - } - - /* Create array entries */ - foreach(array("gotoMimeFilePattern") as $attr){ - $i = 0; - $use_attr = "use_".$attr; - $tmp = array(); - $this->$attr = array(); - foreach($this->$use_attr as $entry){ - $tmp[] = $entry; - } - $this->$attr = $tmp; - } - - /* Remove Icon if requested */ - if($this->use_gotoMimeIcon != "*removed*"){ - $this->gotoMimeIcon = $this->iconData; - }else{ - $this->gotoMimeIcon = ""; - } - - plugin::save(); - - /* If this is a newly created object, skip storing those - attributes that contain an empty array */ - if($this->orig_dn == "new"){ - foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern") as $attr){ - if(!count($this->$attr)){ - unset($this->attrs[$attr]); - } - } - } - - $ldap = $this->config->get_ldap_link(); - $ldap-> cd ( $this->config->current['BASE']); - $ldap->cat($this->dn); - if($ldap->count()){ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify($this->attrs); - new log("modify","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of mime type/generic with dn '%s' failed."),$this->dn)); - } - - - /* Remove current mime type */ - function remove_from_parent() - { - plugin::remove_from_parent(); - $ldap = $this->config->get_ldap_link(); - $ldap->rmDir($this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of mime type/generic with dn '%s' failed."),$this->dn)); - new log("remove","mimetypes/".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"); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - show_ldap_error($ldap->get_error(), sprintf(_("Removing mime type from objectgroup '%s' failed"), $og->dn)); - } - } - - - /* Check given values */ - function check() - { - $message = plugin::check(); - if(empty($this->cn)){ - $message[] = _("Please specify a valid name for this mime type."); - } - if(!count($this->use_gotoMimeFilePattern)){ - $message[] = _("Please specify at least one file pattern.") ; - } - - /* Check if there is already a mime type with this cn */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current["BASE"]); - if($this->isReleaseMimeType && (isset($_SESSION['mimefilter']['release']))){ - $baseDn = str_replace($this->config->current['BASE'],$this->base,$_SESSION['mimefilter']['release']); - $baseDn = preg_replace("/ou=mime,.*/","ou=mime,".$this->base,$_SESSION['mimefilter']['release']); - $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$baseDn,array("cn")); - if($ldap->count()){ - $attrs = $ldap->fetch(); - if($this->dn != $attrs['dn']) { - $message[]= _("There's already a mime type with this 'Name'."); - } - } - }else{ - $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))","ou=mime,".$this->base,array("cn")); - if ($ldap->count()){ - $attrs = $ldap->fetch(); - if($this->dn != $attrs['dn']) { - $message[]= _("There's already an mime with this 'Name'."); - } - } - } - - return($message); - } - - /** Helper functions **/ - - /* Set a new picture */ - function set_new_picture($filename) - { - if (empty($filename)){ - $filename= "./images/default_icon.png"; - $this->use_gotoMimeIcon= "*removed*"; - }else{ - $this->use_gotoMimeIcon= $filename; - } - - if (file_exists($filename)){ - $fd = fopen ($filename, "rb"); - $this->iconData= fread ($fd, filesize ($filename)); - $_SESSION['binary']= $this->iconData; - $_SESSION['binarytype']= "image/jpeg"; - fclose ($fd); - } - } - - /* Get picture link */ - function get_picture() - { - $_SESSION['binary']= $this->iconData; - $_SESSION['binarytype']= "image/jpeg"; - return("getbin.php"); - } - - /* Transports the given Arraykey one position up*/ - function ArrayUp($atr,$attrs) - { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == 1))){ - $before = array_slice($attrs,0,($pos-2)); - $mitte = array_reverse(array_slice($attrs,($pos-2),2)); - $unten = array_slice($attrs,$pos); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - - /* Transports the given Arraykey one position down*/ - function ArrayDown($atr,$attrs) - { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == $cn))){ - $before = array_slice($attrs,0,($pos-1)); - $mitte = array_reverse(array_slice($attrs,($pos-1),2)); - $unten = array_slice($attrs,($pos+1)); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - - /* return the position of the element in the array */ - function getpos($atr,$attrs) - { - $i = 0; - foreach($attrs as $attr => $name) { - $i++; - if($attr == $atr){ - return($i); - } - } - return(-1); - } - - - /* Remove this element from array */ - function ArrayRemove($key,$array,$reorder = false) - { - if(isset($array[$key])){ - unset($array[$key]); - if($reorder){ - $tmp = array(); - foreach($array as $entry){ - $tmp[] = $entry; - } - $array = $tmp; - } - } - return($array); - } - - - /* Combine new array */ - function combineArrays($ar0,$ar1,$ar2) - { - $ret = array(); - if(is_array($ar0)) - foreach($ar0 as $ar => $a){ - $ret[]=$a; - } - if(is_array($ar1)) - foreach($ar1 as $ar => $a){ - $ret[]=$a; - } - if(is_array($ar2)) - foreach($ar2 as $ar => $a){ - $ret[]=$a; - } - return($ret); - } - - - /* Return a dialog with all fields that must be changed, - if we want to copy this entry */ - function getCopyDialog() - { - $str = ""; - - $smarty = get_smarty(); - $smarty->assign("cn", $this->cn); - $smarty->assign("description", $this->description); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - /* Save all */ - function saveCopyDialog() - { - $attrs = array("cn","description"); - foreach($attrs as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Mime type generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("mimetypes" => array("description" => _("Mime types"), - "objectClass" => "gotoMimeType")), - "plProvidedAcls"=> array( - "cn" => _("Name"), - "gotoMimeGroup" => _("Mime group"), - "description" => _("Description"), - "base" => _("Base"), - "gotoMimeApplication" => _("Application"), - "gotoMimeLeftClickAction" => _("Left click action"), - "gotoMimeIcon" => _("Icon"), - "gotoMimeFilePattern" => _("File patterns"), - "gotoMimeEmbeddedApplication" => _("Embedded applications")) - )); - - } - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - $source_o = new mimetype($this->config,$source['dn'],$this->parent); - - foreach(array("gotoMimeLeftClickAction_Q","gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern","gotoMimeIcon","iconData") as $name){ - $use_attr = "use_".$name; - if(isset($this->$use_attr)){ - $this->$use_attr= $source_o->$use_attr; - } - $this->$name = $source_o->$name; - } - foreach($this->attributes as $name){ - $this->$name = $source_o->$name; - } - - if($this->iconData){ - $this->use_gotoMimeIcon ="Not emtpy, causes icon to be written."; - } - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/mimetypes/class_mimetypeManagement.inc b/plugins/admin/mimetypes/class_mimetypeManagement.inc deleted file mode 100755 index 5cd9c15b3..000000000 --- a/plugins/admin/mimetypes/class_mimetypeManagement.inc +++ /dev/null @@ -1,664 +0,0 @@ -config = &$config; - $this->ui = &$ui; - - /* Check if copy & paste is activated */ - if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - - /* Creat dialog object */ - $this->DivListMimeTypes = new divListMimeTypes($this->config,$this); - - if($this->IsReleaseManagementActivated()){ - - /* Check if we should enable the release selection */ - $this->enableReleaseManagement = true; - - /* Hide SubSearch checkbox */ - $this->DivListMimeTypes->DisableCheckBox("SubSearch"); - } - - } - - - /* Get all releases */ - function getReleases($base) - { - $ldap = $this->config->get_ldap_link(); - $dn = "ou=mime,".$base; - $ret = array(); - $ret ["ou=mime,".$base] = "/"; - - $ldap->cd($dn); - $ldap->search("objectClass=organizationalUnit",array("ou")); - - while($attrs = $ldap->fetch()){ - $str = str_replace($dn,"",$attrs['dn']); - $tmp = array_reverse( split("ou=",$str)); - $str = ""; - foreach($tmp as $val){ - $val = trim(preg_replace("/,/","",$val)); - if(empty($val)) break; - $str .= "/".$val; - } - if(!empty($str)){ - $ret[$attrs['dn']]= preg_replace("/^\//","",$str); - } - } - asort($ret); - return($ret); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - - /**************** - Variable init - ****************/ - - /* These vars will be stored if you try to open a locked mime, - to be able to perform your last requests after showing a warning message */ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^mime_edit_/","/^mime_del_/","/^item_selected/","/^remove_multiple_mimetypes/"); - - $smarty = get_smarty(); // Smarty instance - $s_action = ""; // Contains the action to proceed - $s_entry = ""; // The value for s_action - $base_back = ""; // The Link for Backbutton - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/mime_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/mime_".$s_action."_/i","",$key); - // Post for edit - }elseif(preg_match("/mime_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/mime_".$s_action."_/i","",$key); - // Post for new - }elseif(preg_match("/^copy_.*/",$key)){ - $s_action="copy"; - $s_entry = preg_replace("/^copy_/i","",$key); - }elseif(preg_match("/^cut_.*/",$key)){ - $s_action="cut"; - $s_entry = preg_replace("/^cut_/i","",$key); - // Post for new - }elseif(preg_match("/^mime_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/^remove_multiple_mimetypes/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^editPaste.*/i",$key)){ - $s_action="editPaste"; - }elseif(preg_match("/^multiple_copy_mimetypes/",$key)){ - $s_action = "copy_multiple"; - }elseif(preg_match("/^multiple_cut_mimetypes/",$key)){ - $s_action = "cut_multiple"; - } - } - - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; - } - - $s_entry = preg_replace("/_.$/","",$s_entry); - - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "mime_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - /**************** - Copy & Paste handling - ****************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /**************** - Create a new mime type - ****************/ - - /* New mime type? */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->DivListMimeTypes->selectedBase,"mimetypes/mimetype"); - if (($s_action=="new") && preg_match("/c/",$acl)){ - - /* By default we set 'dn' to 'new', all relevant plugins will - react on this. */ - $this->dn= "new"; - - /* Create new usertab object */ - $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); - $this->mimetabs->set_acl_base($this->DivListMimeTypes->selectedBase); - } - - - /**************** - Edit entry canceled - ****************/ - - /* Cancel dialogs */ - if (isset($_POST['edit_cancel'])){ - del_lock ($this->mimetabs->dn); - unset ($this->mimetabs); - $this->mimetabs= NULL; - unset ($_SESSION['objectinfo']); - } - - - /**************** - Edit entry finished - ****************/ - - /* Finish mime edit is triggered by the tabulator dialog, so - the user wants to save edited data. Check and save at this point. */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->mimetabs->config))){ - - /* Check tabs, will feed message array */ - $this->mimetabs->save_object(); - $message= $this->mimetabs->check(); - - /* Save, or display error message? */ - if (count($message) == 0){ - - /* Save data data to ldap */ - $this->mimetabs->set_release($this->DivListMimeTypes->selectedRelease); - $this->mimetabs->save(); - - if (!isset($_POST['edit_apply'])){ - /* Mime type has been saved successfully, remove lock from LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - unset ($this->mimetabs); - $this->mimetabs= NULL; - unset ($_SESSION['objectinfo']); - } - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /**************** - Edit entry - ****************/ - - /* User wants to edit data? */ - if (($s_action=="edit") && (!isset($this->mimetabs->config))){ - - /* Get 'dn' from posted 'mimelist', must be unique */ - $this->dn= $this->mimetypes[$s_entry]['dn']; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so everyone will get the - above dialog */ - add_lock ($this->dn, $this->ui->dn); - - - /* Register mimetabs to trigger edit dialog */ - $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); - $this->mimetabs->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - - $this->dns = array(); - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->mimetypes[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("intro", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("intro", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); - } - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_mimetype_confirm'])){ - - $ui = get_userinfo(); - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - $acl = $ui->get_permissions($dn,"mimetypes/mimetype"); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $dn,"mimetypes"); - $this->mimetabs->set_acl_base($dn); - $this->mimetabs->delete (); - unset ($this->mimetabs); - $this->mimetabs= NULL; - - } else { - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this mime type!")); - new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_mimetype_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /**************** - Delete mime type - ****************/ - - /* Remove user was requested */ - if ($s_action == "del"){ - - /* Get 'dn' from posted 'uid' */ - $this->dn= $this->mimetypes[$s_entry]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->dn,"mimetypes/mimetype"); - if (preg_match("/d/",$acl)){ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return (gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty= get_smarty(); - $smarty->assign("intro", sprintf(_("You're about to delete the mime type '%s'."), @LDAP::fix($this->dn))); - $smarty->assign("multiple", false); - return($smarty->fetch (get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this mime type!")); - } - } - - - /**************** - Delete mime confirmed - ****************/ - - /* Confirmation for deletion has been passed. Group should be deleted. */ - if (isset($_POST['delete_mime_confirm'])){ - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->dn,"mimetypes/mimetype"); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); - $this->mimetabs->set_acl_base($this->dn); - $this->mimetabs->delete (); - unset ($this->mimetabs); - $this->mimetabs= NULL; - - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this mime type!")); - new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - - /**************** - Delete mime canceled - ****************/ - - /* Delete mime type canceled? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - /* Show tab dialog if object is present */ - if (($this->mimetabs) && (isset($this->mimetabs->config))){ - $display= $this->mimetabs->execute(); - - /* Don't show buttons if tab dialog requests this */ - if (!$this->mimetabs->by_object[$this->mimetabs->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - return ($display); - } - - - /**************** - Dialog display - ****************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListMimeTypes->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Display dialog with system list */ - $this->DivListMimeTypes->parent = $this; - $this->DivListMimeTypes->execute(); - $this->DivListMimeTypes->AddDepartments($this->DivListMimeTypes->selectedBase,3,1); - $this->reload(); - $this->DivListMimeTypes->setEntries($this->mimetypes); - return($this->DivListMimeTypes->Draw()); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array($this->DivListMimeTypes->selectedRelease)); - } - - - - function reload() - { - $this->mimetypes= array(); - - /* Set base for all searches */ - $base = $this->DivListMimeTypes->selectedBase; - $release = $this->DivListMimeTypes->selectedRelease; - $Regex = $this->DivListMimeTypes->Regex; - $SubSearch = $this->DivListMimeTypes->SubSearch; - $Flags = GL_NONE | GL_SIZELIMIT; - $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=gotoMimeType))"; - $tmp = array(); - $Releases = $this->getReleases($base); - - - /* If release management is enabled, use release as base. */ - if(!$this->enableReleaseManagement){ - $use_base = $base; - }else{ - if(isset($Releases[$release])){ - $use_base = $release; - }else{ - $use_base = $base; - } - } - - /* In case of subsearch, add the subsearch flag */ - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - }else{ - if(!$this->enableReleaseManagement){ - $use_base ="ou=mime,".$use_base; - } - } - - /* Get results and create index */ - $res= get_list($Filter, "mimetypes", $use_base, array("cn","description","dn","objectClass"), $Flags); - foreach ($res as $val){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; - } - - /* sort entries */ - ksort($tmp); - $this->mimetypes=array(); - foreach($tmp as $val){ - $this->mimetypes[]=$val; - } - reset ($this->mimetypes); - } - - function remove_from_parent() - { - /* Optionally execute a command after we're done */ - $this->postremove(); - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $this->start_pasting_copied_objects = FALSE; - $dn = $this->mimetypes[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"mimetabs","MIMETABS","mimetypes"); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $this->start_pasting_copied_objects = FALSE; - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->mimetypes[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","mimetabs","MIMETABS","mimetypes"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","mimetabs","MIMETABS","mimetypes"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListMimeTypes->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - #if(!$this->CopyPasteHandler->entries_queued()){ - # $this->start_pasting_copied_objects = FALSE; - #} - return(""); - } - - - /* Check if the release management is activated. */ - function IsReleaseManagementActivated() - { - /* Check if we should enable the release selection */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - return(true); - } - return(false); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - /* Save to LDAP */ - function save() - { - /* Optionally execute a command after we're done */ - $this->postcreate(); - } - - function remove_lock() - { - if (isset($this->mimetabs->dn)){ - del_lock ($this->mimetabs->dn); - } - } - - function save_object() { - $this->DivListMimeTypes->save_object(); - } - - function check() {} - function adapt_from_template($dn) {} - function password_change_needed() {} -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/mimetypes/generic.tpl b/plugins/admin/mimetypes/generic.tpl deleted file mode 100644 index 1cb6d7549..000000000 --- a/plugins/admin/mimetypes/generic.tpl +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

[M] {t}Generic{/t}

-
- - - - - - - - - - - - - -{if !$isReleaseMimeType} - - - - - -{/if} -
- {t}Mime type{/t}{$must} - -{render acl=$gotoMimeGroupACL} - -{/render} -
- {t}Mime group{/t} - -{render acl=$gotoMimeGroupACL} - -{/render} -
- {t}Description{/t} - -{render acl=$descriptionACL} - -{/render} -
- {render acl=$baseACL} - - {/render} - {if !$isReleaseMimeType} - {render acl=$baseACL disable_picture='images/folder_gray.png'} - - {/render} - {/if} -
- -
- - - - - -
-
- {t}Mime icon{/t} -
-  
- -{render acl=$gotoMimeIconACL} - -{/render} -{render acl=$gotoMimeIconACL} - -{/render} -
-
-

 

-
-

{t}Left click{/t} {t}Left click{/t}

-
- {t}File patterns{/t}{$must} -{render acl=$gotoMimeFilePatternACL} - {$gotoMimeFilePatterns} -{/render} - -{render acl=$gotoMimeFilePatternACL} - -{/render} -{render acl=$gotoMimeFilePatternACL} - -{/render} - - {t}Applications{/t} -{render acl=$gotoMimeApplicationACL} - {$gotoMimeApplications} -{/render} - -{render acl=$gotoMimeApplicationACL} - -{/render} -{render acl=$gotoMimeApplicationACL} - -{/render} -{render acl=$gotoMimeApplicationACL} - -{/render} -
-

 

-
-

{t}Embedding{/t} {t}Embedding{/t}

-
- - - - - -
-{render acl=$gotoMimeLeftClickActionACL} - -{/render} - {t}Show file in embedded viewer{/t} -
- -{render acl=$gotoMimeLeftClickActionACL} - -{/render} - {t}Show file in external viewer{/t} -
- -{render acl=$gotoMimeLeftClickActionACL} - -{/render} - {t}Ask whether to save to local disk{/t} -
- -
- {t}Applications{/t} -{render acl=$gotoMimeEmbeddedApplicationACL} - {$gotoMimeEmbeddedApplications} -{/render} -{render acl=$gotoMimeEmbeddedApplicationACL} - -{/render} -{render acl=$gotoMimeEmbeddedApplicationACL} - -{/render} -{render acl=$gotoMimeEmbeddedApplicationACL} - -{/render} -
- - - diff --git a/plugins/admin/mimetypes/main.inc b/plugins/admin/mimetypes/main.inc deleted file mode 100755 index 1595f185e..000000000 --- a/plugins/admin/mimetypes/main.inc +++ /dev/null @@ -1,57 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('MimeTypeManagement'); - } -} else { - - /* Create MimeTypeManagement object on demand */ - if (!isset($_SESSION['MimeTypeManagement']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['MimeTypeManagement']= new mimetypeManagement ($config, $_SESSION['ui']); - } - - /* Get object */ - $MimeTypeManagement= $_SESSION['MimeTypeManagement']; - $MimeTypeManagement->save_object(); - $output= $MimeTypeManagement->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management")); - } - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('MimeTypeManagement'); - } - - /* Show and save dialog */ - $display.= $output; - $_SESSION['MimeTypeManagement']= $MimeTypeManagement; -} -?> diff --git a/plugins/admin/mimetypes/paste_generic.tpl b/plugins/admin/mimetypes/paste_generic.tpl deleted file mode 100644 index 34b5e0751..000000000 --- a/plugins/admin/mimetypes/paste_generic.tpl +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - -
-

 {t}Generic{/t}

-
- - - - - - - - - - -
- {t}Mime type{/t} - - -
- {t}Description{/t} - - -
- -
diff --git a/plugins/admin/mimetypes/release_select.tpl b/plugins/admin/mimetypes/release_select.tpl deleted file mode 100755 index d58738f05..000000000 --- a/plugins/admin/mimetypes/release_select.tpl +++ /dev/null @@ -1,16 +0,0 @@ -
-
-

[F]{t}Branches{/t}

-
-
- - - - -
- {t}Current release{/t}  - -
-
diff --git a/plugins/admin/mimetypes/remove.tpl b/plugins/admin/mimetypes/remove.tpl deleted file mode 100755 index 30c423318..000000000 --- a/plugins/admin/mimetypes/remove.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$intro} - {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

-

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

- diff --git a/plugins/admin/mimetypes/tabs_mimetypes.inc b/plugins/admin/mimetypes/tabs_mimetypes.inc deleted file mode 100755 index 6c1cd34c4..000000000 --- a/plugins/admin/mimetypes/tabs_mimetypes.inc +++ /dev/null @@ -1,64 +0,0 @@ -addSpecialTabs(); - } - - function set_release($newRelease) - { - $this->Release= preg_replace('/,ou=mime,.*$/', '', $newRelease); - if ($this->Release != ""){ - $this->Release= ",".$this->Release; - } - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['mimetype']; - - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - - if((!empty($tmp)) && (isset($_SESSION['mimefilter']['release']))){ - if(!$baseobject->isReleaseMimeType){ - $new_dn= "cn=".$baseobject->cn.",ou=mime,".$baseobject->base; - }else{ - $new_dn ="cn=".$baseobject->cn.",".$_SESSION['mimefilter']['release']; - } - }else{ - $new_dn= "cn=".$baseobject->cn.",ou=mime,".$baseobject->base; - } - - /* Move group? */ - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->move($this->dn, $new_dn); - $this->by_object['mimetype']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - tabs::save(); - - /* Fix tagging if needed */ - $baseobject->dn= $this->dn; - $baseobject->handle_object_tagging(); - $this->by_object['mimetype'] = $baseobject; - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/class_divListOGroup.inc b/plugins/admin/ogroups/class_divListOGroup.inc deleted file mode 100755 index c0e96a7c9..000000000 --- a/plugins/admin/ogroups/class_divListOGroup.inc +++ /dev/null @@ -1,331 +0,0 @@ -AddCheckBox */ - var $UserGroups ; - var $GroupGroups ; - var $ApplicationGroups ; - var $DepartmentGroups ; - var $ServerGroups ; - var $WorkstationGroups ; - var $TerminalGroups ; - var $PrinterGroups ; - var $PhoneGroups ; - - - /* Subsearch checkbox */ - var $SubSearch ; - var $parent ; - var $ui ; - - function divListOGroup (&$config,$parent) - { - MultiSelectWindow::MultiSelectWindow($config, "OGroups", "ogroups"); - - $this->parent = $parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of object groups")); - $this->SetSummary(_("List of object groups")); - $this->EnableAplhabet(true); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to add, edit or remove selected groups. You may want to use the range selector on top of the group listbox, when working with a large number of groups.")); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Properties"), "attach" => "style='width:136px;'")); - $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); - - /* Text ,Value ,Name ,Is selected */ - $this->AddCheckBox("UserGroups" , _("Select to see groups containing users") , _("Show groups containing users"), true); - $this->AddCheckBox("GroupGroups" , _("Select to see groups containing groups") , _("Show groups containing groups"), true); - $this->AddCheckBox("ApplicationGroups", _("Select to see groups containing applications"), _("Show groups containing applications"), true); - $this->AddCheckBox("DepartmentGroups" , _("Select to see groups containing departments") , _("Show groups containing departments"), true); - $this->AddCheckBox("ServerGroups" , _("Select to see groups containing servers") , _("Show groups containing servers"), true); - $this->AddCheckBox("WorkstationGroups", _("Select to see groups containing workstations"), _("Show groups containing workstations"), true); - $this->AddCheckBox("TerminalGroups" , _("Select to see groups containing terminals") , _("Show groups containing terminals"), true); - $this->AddCheckBox("PrinterGroups" , _("Select to see groups containing printer") , _("Show groups containing printer"), true); - $this->AddCheckBox("PhoneGroups" , _("Select to see groups containing phones") , _("Show groups containing phones"), true); - - /* Add SubSearch checkbox */ - $this->AddCheckBox(SEPERATOR); - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true); - } - - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("ogroups"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Add a seperator after displaying c&p and snapshot icons ? */ - $add_sep = false; - - /* Get copy & paste icon */ - $acls = $ui->get_permissions($this->selectedBase,"ogroups/ogroup"); - $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups"); - $Copy_Paste =""; - if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){ - $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon(); - $add_sep = true; - } - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - - /* Add department selector */ - $listhead .= _("Base")." ". - "  "; - - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acls)) { - $s.= "...|". - " "._("Object group")."|group_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; -# $s.= "..|". -# " "._("Edit")."|"."multiple_edit|\n"; - - $s.= "..|". - " "._("Remove")."|"."remove_multiple_ogroups/|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - /* Add Copy & Paste buttons if copy&paste is enabled - */ - // Defining Links - $linkopen = "%s"; - $editlink = "%s"; - $userimg = "User"; - $mailimg = "M"; - $empty = ""; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 80; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - $ui = get_userinfo(); - - // Assigning ogroups - foreach($list as $key => $val){ - - /* Create action icons */ - $actions= ""; - $acl_all= $ui->has_complete_category_acls($val['dn'],"ogroups"); - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions.= " "; - $actions.= " "; - } - - $actions.= ""; - - if(preg_match("/(c.*w|w.*c)/", $acl_all)){ - $actions.= $this->GetSnapShotActions($val['dn']); - } - - if(preg_match("/d/",$ui->get_permissions($val['dn'],"ogroups/ogroup"))) { - $actions.= ""; - }else{ - $actions.= " "; - } - - - if(isset($val['mail'])){ - $mail = $mailimg; - }else{ - $mail = $empty; - } - $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; - if(!isset($val['description'][0])){ - $desc = ""; - }else{ - $desc = " - [ ".$val['description'][0]." ]"; - } - - /* Cutted objects should be displayed in light grey */ - $display = $val['cn'][0].$desc; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => ""._("Object group")."", "attach" => "style='text-align:center;width: 20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); - $field3 = array("string" => preg_replace("/%KEY/", $key, $this->parent->convert_list($val))." ".$mail, "attach" => "style='width:136px;'"); - $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - - $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); - } - - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_objs = count($list); - - $num_obj_str = _("Number of listed object groups"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_obj_str." ".$num_objs."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/class_mailogroup.inc b/plugins/admin/ogroups/class_mailogroup.inc deleted file mode 100644 index ebf569729..000000000 --- a/plugins/admin/ogroups/class_mailogroup.inc +++ /dev/null @@ -1,199 +0,0 @@ -config= $config; - - /* Save initial account state */ - $this->initially_was_account= $this->is_account; - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","ogroups/".get_class($this),$this->dn); - } - - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Show tab dialog headers */ - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove mail account"), - _("This group has mail features enabled. You can disable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Create mail account"), _("This group has mail features disabled. You can enable them by clicking below.")); - return ($display); - } - } - - /* Initialize templating engine */ - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl("mail")); - } - - /* Assign mail attribute */ - $smarty->assign("mail", $this->mail); - - /* Show main page */ - return ($display.$smarty->fetch (get_template_path('mail.tpl', TRUE))); - } - - - /* Check formular input */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if ($this->is_account){ - $ldap= $this->config->get_ldap_link(); - - /* Check if mail address is valid */ - if (!is_email($this->mail) || $this->mail == ""){ - $message[]= _("Please enter a valid email address in 'Primary address' field."); - } - - /* Check if mail address is already in use */ - $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(!(objectClass=gosaUserTemplate))(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(cn=".$this->cn.")))", array("uid")); - if ($ldap->count() != 0){ - $message[]= _("The primary address you've entered is already in use."); - } - } - - return ($message); - } - - - function save() - { - $ldap= $this->config->get_ldap_link(); - - /* Call parents save to prepare $this->attrs */ - plugin::save(); - - /* Save data to LDAP */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - if($this->initially_was_account){ - new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/mail with dn '%s' failed."),$this->dn)); - - /* 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"); - } - } else { - $this->handle_post_events("add"); - } - } - - - /* remove object from parent */ - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/mail with dn '%s' failed."),$this->dn)); - } - - - function getCopyDialog() - { - $str = ""; - $smarty = get_smarty(); - $smarty->assign("mail", $this->mail); - $str = $smarty->fetch(get_template_path("paste_mail.tpl",TRUE,dirname(__FILE__))); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['mail'])){ - $this->mail = $_POST['mail']; - } - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Mail"), - "plDescription" => _("Mail group"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 4, - "plSection" => array("administration"), - "plCategory" => array("ogroups"), - "plProvidedAcls"=> array( - "mail" => _("Mail address")) - )); - } - - - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/class_ogroup.inc b/plugins/admin/ogroups/class_ogroup.inc deleted file mode 100644 index e74b3985a..000000000 --- a/plugins/admin/ogroups/class_ogroup.inc +++ /dev/null @@ -1,765 +0,0 @@ - $v2){ - return 1; - } - if ($v1 < $v2){ - return -1; - } - return 0; -} - - -class ogroup extends plugin -{ - /* Variables */ - var $cn= ""; - var $description= ""; - var $base= ""; - var $gosaGroupObjects= ""; - var $department= ""; - var $objects= array(); - var $objcache= array(); - var $memberList= array(); - var $member= array(); - var $orig_dn= ""; - var $group_dialog= FALSE; - var $view_logged = FALSE; - - /* attribute list for save action */ - var $attributes= array("cn", "description", "gosaGroupObjects","member"); - var $objectclasses= array("top", "gosaGroupOfNames"); - - function ogroup (&$config, $dn= NULL) - { - plugin::plugin ($config, $dn); - $this->orig_dn= $dn; - - $this->member = array(); - - /* Load member objects */ - if (isset($this->attrs['member'])){ - foreach ($this->attrs['member'] as $key => $value){ - if ("$key" != "count"){ - $value= @LDAP::convert($value); - $this->member["$value"]= "$value"; - } - } - } - $this->is_account= TRUE; - - /* Get global filter config */ - if (!is_global("ogfilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $ogfilter= array( "dselect" => $base, - "regex" => "*"); - register_global("ogfilter", $ogfilter); - } - $ogfilter= get_global('ogfilter'); - - /* Adjust flags */ - foreach( array( "U" => "accounts", - "G" => "groups", - "A" => "applications", - "D" => "departments", - "S" => "servers", - "W" => "workstations", - "T" => "terminals", - "F" => "phones", - "_" => "subtrees", - "P" => "printers") as $key => $val){ - - if (preg_match("/$key/", $this->gosaGroupObjects)){ - $ogfilter[$val]= "checked"; - } else { - $ogfilter[$val]= ""; - } - } - register_global("ogfilter", $ogfilter); - - if(isset($_SESSION['CurrentMainBase'])){ - $this->base = $_SESSION['CurrentMainBase']; - } - - /* Set base */ - if ($this->dn == "new"){ - $this->base= $_SESSION['CurrentMainBase']; - } else { - $this->base= preg_replace("/^[^,]+,".get_groups_ou()."/","",$this->dn); - } - - /* Load member data */ - $this->reload(); - } - - function AddDelMembership($NewMember = false){ - - if($NewMember){ - - /* Add member and force reload */ - $this->member[$NewMember]= $NewMember; - $this->reload(); - - $this->memberList[$NewMember]= $this->objcache[$NewMember]; - unset ($this->objects[$NewMember]); - uasort ($this->memberList, 'sort_list'); - reset ($this->memberList); - }else{ - /* Delete objects from group */ - if (isset($_POST['delete_membership']) && isset($_POST['members'])){ - foreach ($_POST['members'] as $value){ - $this->objects["$value"]= $this->memberList[$value]; - unset ($this->memberList["$value"]); - unset ($this->member["$value"]); - uasort ($this->objects, 'sort_list'); - reset ($this->objects); - } - $this->reload(); - } - - /* Add objects to group */ - if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){ - foreach ($_POST['objects'] as $value){ - $this->memberList["$value"]= $this->objects[$value]; - $this->member["$value"]= $value; - unset ($this->objects[$value]); - uasort ($this->memberList, 'sort_list'); - reset ($this->memberList); - } - $this->reload(); - } - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","ogroups/".get_class($this),$this->dn); - } - - - /* Do we represent a valid group? */ - if (!$this->is_account){ - $display= "\"\" ". - _("This 'dn' is no object group.").""; - return ($display); - } - - /* Delete objects from group */ - if (isset($_POST['delete_membership']) && isset($_POST['members'])){ - foreach ($_POST['members'] as $value){ - if(isset($this->memberList[$value])){ - $this->objects["$value"]= $this->memberList[$value]; - unset ($this->memberList["$value"]); - unset ($this->member["$value"]); - uasort ($this->objects, 'sort_list'); - reset ($this->objects); - } - } - $this->reload(); - } - - /* Add objects to group */ - if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){ - foreach ($_POST['objects'] as $value){ - if(isset($this->objects[$value])){ - $this->memberList["$value"]= $this->objects[$value]; - $this->member["$value"]= $value; - unset ($this->objects[$value]); - uasort ($this->memberList, 'sort_list'); - reset ($this->memberList); - } - } - $this->reload(); - } - - /* Load templating engine */ - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog) && $this->acl_is_moveable()){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Add objects? */ - if (isset($_POST["edit_membership"])){ - $this->group_dialog= TRUE; - $this->dialog= TRUE; - } - - /* Add objects finished? */ - if (isset($_POST["add_object_finish"]) || isset($_POST["add_object_cancel"])){ - $this->group_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Manage object add dialog */ - if ($this->group_dialog){ - - /* Save data */ - $ogfilter= get_global("ogfilter"); - foreach( array("dselect", "regex") as $type){ - if (isset($_POST[$type])){ - $ogfilter[$type]= $_POST[$type]; - } - } - if (isset($_POST['dselect'])){ - foreach( array("accounts", "groups", "applications", "departments", - "servers", "workstations", "terminals", "printers","subtrees", - "phones") as $type){ - - if (isset($_POST[$type])) { - $ogfilter[$type]= "checked"; - } else { - $ogfilter[$type]= ""; - } - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $ogfilter['regex']= $s; - } - register_global("ogfilter", $ogfilter); - $this->reload(); - - /* Calculate actual groups */ - $smarty->assign("objects", $this->convert_list($this->objects)); - - /* Show dialog */ - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("alphabet", generate_alphabet()); - foreach( array("dselect", "regex", "accounts", "groups", "applications", - "departments", "servers", "workstations", "terminals","subtrees", - "printers", "phones") as $type){ - $smarty->assign("$type", $ogfilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - $smarty->assign("apply", apply_filter()); - - $display= $smarty->fetch (get_template_path('ogroup_objects.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /* Bases / Departments */ - if ((isset($_POST['base'])) && ($this->acl_is_moveable())){ - $this->base= $_POST['base']; - } - - /* Assemble combine string */ - if ($this->gosaGroupObjects == "[]"){ - $smarty->assign("combinedObjects", _("none")); - } elseif (strlen($this->gosaGroupObjects) > 4){ - $smarty->assign("combinedObjects", ""._("too many different objects!").""); - } else { - $conv= array( "U" => _("users"), - "G" => _("groups"), - "A" => _("applications"), - "D" => _("departments"), - "S" => _("servers"), - "W" => _("workstations"), - "T" => _("terminals"), - "F" => _("phones"), - "P" => _("printers")); - - $type= preg_replace('/[\[\]]/', '', $this->gosaGroupObjects); - $p1= $conv[$type[0]]; - error_reporting(0); - if (isset($type[1]) && preg_match('/[UGADSFWTP]/', $type[1])){ - $p2= $conv[$type[1]]; - $smarty->assign("combinedObjects", "$p1 "._("and")." $p2"); - } else { - $smarty->assign("combinedObjects", "$p1"); - } - error_reporting(E_ALL | E_STRICT); - } - - /* Assign variables */ - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("base_select", $this->base); - $smarty->assign("department", $this->department); - $smarty->assign("members", $this->convert_list($this->memberList)); - - /* Objects have to be tuned... */ - $smarty->assign("objects", $this->convert_list($this->objects)); - - /* Fields */ - foreach ($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - - return ($smarty->fetch (get_template_path('generic.tpl', TRUE))); - } - - - /* Save data to object */ - function save_object() - { - /* Save additional values for possible next step */ - if (isset($_POST['ogroupedit'])){ - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - /* Save base, since this is no LDAP attribute */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - } - } - - - /* (Re-)Load objects */ - function reload() - { - /*########### - Variable initialisation - ###########*/ - - $this->objects = array(); - $this->ui = get_userinfo(); - $filter = ""; - $objectClasses = array(); - - $ogfilter = get_global("ogfilter"); - $regex = $ogfilter['regex']; - - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($ogfilter['dselect']); - - - /*########### - Generate Filter - ###########*/ - - $p_f= array("accounts" => array("CLASS"=>"gosaAccount" ,"DN"=> get_people_ou() ,"ACL" => "users"), - "groups" => array("CLASS"=>"posixGroup" ,"DN"=> get_groups_ou() ,"ACL" => "groups"), - "applications" => array("CLASS"=>"gosaApplication","DN"=> "ou=apps," ,"ACL" => "application"), - "departments" => array("CLASS"=>"gosaDepartment" ,"DN"=> "" ,"ACL" => "department"), - "servers" => array("CLASS"=>"goServer" ,"DN"=> "ou=servers,ou=systems," ,"ACL" => "server"), - "workstations" => array("CLASS"=>"gotoWorkstation","DN"=> "ou=workstations,ou=systems," ,"ACL" => "workstation"), - "terminals" => array("CLASS"=>"gotoTerminal" ,"DN"=> "ou=terminals,ou=systems," ,"ACL" => "terminal"), - "printers" => array("CLASS"=>"gotoPrinter" ,"DN"=> "ou=printers,ou=systems," ,"ACL" => "printer"), - "phones" => array("CLASS"=>"goFonHardware" ,"DN"=> "ou=phones,ou=systems," ,"ACL" => "phone")); - - - /*########### - Perform search for selected objectClasses & regex to fill list with objects - ###########*/ - - $Get_list_flags = 0; - if($ogfilter['subtrees'] == "checked"){ - $Get_list_flags |= GL_SUBSEARCH; - } - - foreach($p_f as $post_name => $data){ - - if($ogfilter[$post_name] == "checked"){ - - if($ogfilter['subtrees']){ - $base = $ogfilter['dselect']; - }else{ - $base = $data['DN'].$ogfilter['dselect']; - } - - $filter = "(&(objectClass=".$data['CLASS'].")(|(uid=$regex)(cn=$regex)(ou=$regex)))"; - $res = get_list($filter, $data['ACL'] , $base, - array("description", "objectClass", "sn", "givenName", "uid","ou","cn"),$Get_list_flags); - - /* fetch results and append them to the list */ - foreach($res as $attrs){ - - $type= $this->getObjectType($attrs); - $name= $this->getObjectName($attrs); - - /* Fill array */ - if (isset($attrs["description"][0])){ - $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); - } elseif (isset($attrs["uid"][0])) { - $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type"); - } else { - $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); - } - } - } - } - uasort ($this->objects, 'sort_list'); - reset ($this->objects); - - - /*########### - Build member list and try to detect obsolete entries - ###########*/ - - $this->memberList = array(); - - /* Walk through all single member entry */ - foreach($this->member as $dn){ - - /* The dn for the current member can't be resolved - it seams that this entry was removed - */ - /* Try to resolv the entry again, if it still fails, display error msg */ - $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass")); - - /* It has failed, add entry with type flag I (Invalid)*/ - if ($ldap->error != "Success"){ - $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I"); - - } else { - - /* Append this entry to our all object list */ - - /* Fetch object */ - $attrs= $ldap->fetch(); - - $type= $this->getObjectType($attrs); - $name= $this->getObjectName($attrs); - - if (isset($attrs["description"][0])){ - $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); - } elseif (isset($attrs["uid"][0])) { - $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type"); - } else { - $this->objcache[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); - } - $this->objcache[$attrs["dn"]]['objectClass'] = $attrs['objectClass']; - if(isset($attrs['uid'])){ - $this->objcache[$attrs["dn"]]['uid'] = $attrs['uid']; - } - - /* Fill array */ - if (isset($attrs["description"][0])){ - $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type"); - } else { - $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type"); - } - - $this->memberList[$dn]= $this->objects[$attrs["dn"]]; - } - } - uasort ($this->memberList, 'sort_list'); - reset ($this->memberList); - - /* Assemble types of currently combined objects */ - $objectTypes= ""; - foreach ($this->memberList as $dn => $desc){ - - /* Invalid object? */ - if ($desc['type'] == 'I'){ - continue; - } - - /* Fine. Add to list. */ - if (!preg_match('/'.$desc['type'].'/', $objectTypes)){ - $objectTypes.= $desc['type']; - } - } - $this->gosaGroupObjects= "[$objectTypes]"; - } - - - function convert_list($input) - { - $temp= ""; - $conv= array( "U" => "select_user.png", - "G" => "select_groups.png", - "A" => "select_application.png", - "D" => "select_department.png", - "S" => "select_server.png", - "W" => "select_workstation.png", - "T" => "select_terminal.png", - "F" => "select_phone.png", - "I" => "flag.png", - "P" => "select_printer.png"); - - foreach ($input as $key => $value){ - /* Generate output */ - $temp.= "\n"; - } - - return ($temp); - } - - - function getObjectType($attrs) - { - $type= "I"; - - foreach(array( "U" => "gosaAccount", - "G" => "posixGroup", - "A" => "gosaApplication", - "D" => "gosaDepartment", - "S" => "goServer", - "W" => "gotoWorkstation", - "T" => "gotoTerminal", - "F" => "goFonHardware", - "P" => "gotoPrinter") as $index => $class){ - if (in_array($class, $attrs['objectClass'])){ - $type= $index; - break; - } - } - - return ($type); - } - - - function getObjectName($attrs) - { - /* Person? */ - $name =""; - if (in_array('gosaAccount', $attrs['objectClass'])){ - if(isset($attrs['sn']) && isset($attrs['givenName'])){ - $name= $attrs['sn'][0].", ".$attrs['givenName'][0]; - } else { - $name= $attrs['uid'][0]; - } - } else { - if(isset($attrs["cn"][0])) { - $name= $attrs['cn'][0]; - } else { - $name= $attrs['ou'][0]; - } - } - - return ($name); - } - - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Permissions for that base? */ - if ($this->base != ""){ - $new_dn= 'cn='.$this->cn.','.get_groups_ou().$this->base; - } else { - $new_dn= $this->dn; - } - - - $ldap = $this->config->get_ldap_link(); - if($this->dn != $new_dn){ - $ldap->cat ($new_dn, array('dn')); - } - - if($ldap->count() !=0){ - $message[]= _("There is already an object with this cn."); - } - - /* Set new acl base */ - if($this->dn == "new") { - $this->set_acl_base($this->base); - } - - /* must: cn */ - if ($this->cn == ""){ - $message[]= "The required field 'Name' is not set."; - } - - /* To many different object types? */ - if (strlen($this->gosaGroupObjects) > 4){ - $message[]= _("You can combine two different object types at maximum only!"); - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Move members to target array */ - $this->attrs['member'] =array(); - foreach ($this->member as $key => $desc){ - $this->attrs['member'][]= @LDAP::fix($key); - } - - $ldap= $this->config->get_ldap_link(); - - /* New accounts need proper 'dn', propagate it to remaining objects */ - if ($this->dn == 'new'){ - $this->dn= 'cn='.$this->cn.','.get_groups_ou().$this->base; - } - - /* Save data. Using 'modify' implies that the entry is already present, use 'add' for - new entries. So do a check first... */ - $ldap->cat ($this->dn, array('dn')); - if ($ldap->fetch()){ - /* Modify needs array() to remove values :-( */ - if (!count ($this->member)){ - $this->attrs['member']= array(); - } - $mode= "modify"; - - } else { - $mode= "add"; - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - } - - /* Write back to ldap */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->$mode($this->attrs); - - if($mode == "add"){ - new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - /* Trigger post signal */ - $this->handle_post_events($mode); - - $ret= 0; - if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/generic with dn '%s' failed."),$this->dn))){ - $ret= 1; - } - - return ($ret); - } - - function remove_from_parent() - { - plugin::remove_from_parent(); - - $ldap= $this->config->get_ldap_link(); - $ldap->rmdir($this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/generic with dn '%s' failed."),$this->dn)); - - new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - /* Trigger remove signal */ - $this->handle_post_events("remove"); - } - - - function PrepareForCopyPaste($source) - { - /* Update available object types */ - if(isset($source['gosaGroupObjects'][0])){ - $this->gosaGroupObjects = $source['gosaGroupObjects'][0]; - } - - /* Reload tabs */ - $this->parent->reload($this->gosaGroupObjects ); - - /* Reload plugins */ - foreach($this->parent->by_object as $name => $class ){ - if(get_class($this) != $name) { - $this->parent->by_object[$name]->PrepareForCopyPaste($source); - } - } - - /* Load member objects */ - if (isset($source['member'])){ - foreach ($source['member'] as $key => $value){ - if ("$key" != "count"){ - $value= @LDAP::convert($value); - $this->member["$value"]= "$value"; - } - } - } - - } - - - function getCopyDialog() - { - $smarty = get_smarty(); - $smarty->assign("cn", $this->cn); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Object group generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => array("ogroups" => array("description" => _("Object groups"), - "objectClass" => "gosaGroupOfNames")), - "plProvidedAcls"=> array( - "cn" => _("Name"), - "base" => _("Base"), - "description" => _("Description"), - "member" => _("Member")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/class_ogroupManagement.inc b/plugins/admin/ogroups/class_ogroupManagement.inc deleted file mode 100644 index 574087740..000000000 --- a/plugins/admin/ogroups/class_ogroupManagement.inc +++ /dev/null @@ -1,632 +0,0 @@ -config= &$config; - $this->ui= get_userinfo(); - - /* Copy & Paste enabled ? - */ - if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE'] ))){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - - /* Div lsit management */ - $this->DivListOGroup = new divListOGroup($this->config,$this); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /**************** - Variable intialisation && Check posts for commands - ****************/ - - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_ogroups/"); - - $smarty = get_smarty(); - $s_action = ""; - $s_entry = ""; - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/^group_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/^group_".$s_action."_/i","",$key); - // Post for edit - }elseif(preg_match("/^group_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/^group_".$s_action."_/i","",$key); - // Post for new - }elseif(preg_match("/^group_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/^editPaste.*/i",$key)){ - $s_action="editPaste"; - }elseif(preg_match("/^copy_.*/",$key)){ - $s_action="copy"; - $s_entry = preg_replace("/^copy_/i","",$key); - }elseif(preg_match("/^cut_.*/",$key)){ - $s_action="cut"; - $s_entry = preg_replace("/^cut_/i","",$key); - }elseif(preg_match("/^remove_multiple_ogroups/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^multiple_cut_ogroups/",$key)){ - $s_action = "cut_multiple"; - }elseif(preg_match("/^multiple_copy_ogroups/",$key)){ - $s_action = "copy_multiple"; - }elseif(preg_match("/_group_edit_/",$key)){ - $type = preg_replace("/_group_edit_.*$/","",$key); - $s_action="edit"; - $s_entry = preg_replace("/".$type."_group_edit_/i","",$key); - $_POST['arg'] = $type; - } - } - $s_entry = preg_replace("/_.$/","",$s_entry); - - // Edit if - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; - } - - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "group_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - /**************** - Copy & Paste handling - ****************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /*************** - Create a new object group - ****************/ - - /* New group? */ - if ($s_action=="new"){ - - /* By default we set 'dn' to 'new', all relevant plugins will - react on this. */ - $this->dn= "new"; - - /* Create new usertab object */ - $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $this->dn,"ogroups"); - $this->ogroup->set_acl_base($this->DivListOGroup->selectedBase); - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - if(count($ids)){ - foreach($ids as $id){ - $dn = $this->ogrouplist[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("info", sprintf(_("You're about to delete the following object entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("info", sprintf(_("You're about to delete the following object entries %s"), @LDAP::fix($dns_names))); - } - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_ogroup_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - $acl = $this->ui->get_permissions($dn, "ogroups"); - if (preg_match('/d/', $acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $dn); - $this->ogroup->delete (); - unset ($this->ogroup); - $this->ogroup= NULL; - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this object group!")); - new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_ogroup_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /**************** - Delete object group - ****************/ - - if ($s_action=="del"){ - - /* Get 'dn' from posted 'uid' */ - $this->dn= $this->ogrouplist[$s_entry]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $acl = $this->ui->get_permissions($this->dn,"ogroups"); - if(preg_match("/d/",$acl)){ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the object group '%s'."), @LDAP::fix($this->dn))); - $smarty->assign("multiple", false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this object group!")); - } - } - - - /**************** - Delete confirmed - ****************/ - - /* Confirmation for deletion has been passed. Group should be deleted. */ - if (isset($_POST['delete_group_confirm'])){ - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - $acl = $this->ui->get_permissions($this->dn,"ogroups"); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->ogroup= new ogrouptabs($this->config, - $this->config->data['TABS']['OGROUPTABS'], $this->dn); - $this->ogroup->delete (); - unset ($this->ogroup); - $this->ogroup= NULL; - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this object group!")); - new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - - /**************** - Delete object group Canceled - ****************/ - - /* Delete group canceled? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - - /**************** - Edit group - ****************/ - - if (($s_action=="edit") && (! isset($this->ogroup->config)) ){ - - /* Get 'dn' from posted 'uid', must be unique */ - $this->dn= $this->ogrouplist[$s_entry]['dn']; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so everyone will get the - above dialog */ - add_lock ($this->dn, $this->ui->dn); - - /* Register grouptab to trigger edit dialog */ - $this->ogroup= new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $this->dn, "ogroups"); - $this->ogroup->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; - } - - - /**************** - Edit finished save - ****************/ - - /* Finish button has been pressed */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->ogroup->config)) ){ - - /* Check tabs, will feed message array */ - $message= $this->ogroup->check(); - - /* Save, or display error message? */ - if (count($message) == 0){ - - /* Save user data to ldap */ - $this->ogroup->save(); - - if (!isset($_POST['edit_apply'])){ - /* Group has been saved successfully, remove lock from - LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - - unset ($this->ogroup); - $this->ogroup= NULL; - unset ($_SESSION['objectinfo']); - } - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /**************** - Cancel edit object group - ****************/ - - /* Cancel dialogs */ - if ((isset($_POST['edit_cancel'])) && (isset($this->ogroup->dn))){ - del_lock ($this->ogroup->dn); - unset ($this->ogroup); - $this->ogroup= NULL; - unset($_SESSION['objectinfo']); - } - - - /**************** - Display open dialogs - ****************/ - - /* Show dialog if object is present */ - if (isset($this->ogroup->config)){ - $display= $this->ogroup->execute(); - - /* Don't show buttons if tab dialog requests this */ - if (!$this->ogroup->by_object[$this->ogroup->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - return ($display); - } - - - /**************** - Display list - ****************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListOGroup->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Display dialog with group list */ - $this->DivListOGroup->parent = $this; - $this->DivListOGroup->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListOGroup->SubSearch){ - $this->DivListOGroup->AddDepartments($this->DivListOGroup->selectedBase,4,1); - } - $this->reload (); - $this->DivListOGroup->setEntries($this->ogrouplist); - return($this->DivListOGroup->Draw()); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array(get_groups_ou().$this->DivListOGroup->selectedBase)); - } - - - - function convert_list($input) - { - $temp= ""; - - $conv= array( - "U" => array("select_user.png" ,_("User") , "ogroup"), - "G" => array("select_groups.png" ,_("Group") , "ogroup"), - "A" => array("select_application.png" ,_("Application") , "ogroup"), - "D" => array("select_department.png" ,_("Department") , "ogroup"), - "S" => array("select_server.png" ,_("Server") , "ogroup"), - "F" => array("select_phone.png" ,_("Phone") , "phonequeue"), - "W" => array("select_workstation.png" ,_("Workstation") , "workstartup"), - "T" => array("select_terminal.png" ,_("Terminal") , "termgroup"), - "P" => array("select_printer.png" ,_("Printer") , "ogroup")); - - /* Assemble picture */ - $type= $input['gosaGroupObjects'][0]; - $type= preg_replace("/[^A-Z]/i","",$type); - if (isset($type[0])){ - $p1['pic']= $conv[$type[0]][0]; - $p1['tit']= $conv[$type[0]][1]; - $p1['alt']= $type[0]; - $p1['lnk']= $conv[$type[0]][2]; - $html_object_1 = ""; - $temp.= $html_object_2." class='center' id='iconB".preg_replace("/_/","",$p2['lnk']."_group_edit_%KEY")."' - src='images/".$p2['pic']."' alt='".$p2['alt']."' title='".$p2['tit']."'>"; - return ($temp); - } - - - function reload() - { - /* Set base for all searches && initialise some vars */ - $this->ogrouplist= array(); - $base = $this->DivListOGroup->selectedBase; - $filter = "(gosaGroupObjects=[])"; - $Regex = $this->DivListOGroup->Regex; - - $chk = array( - "UserGroups" => "(gosaGroupObjects=*U*)" , - "GroupGroups" => "(gosaGroupObjects=*G*)" , - "ApplicationGroups" => "(gosaGroupObjects=*A*)" , - "DepartmentGroups" => "(gosaGroupObjects=*D*)" , - "ServerGroups" => "(gosaGroupObjects=*S*)" , - "WorkstationGroups" => "(gosaGroupObjects=*W*)" , - "TerminalGroups" => "(gosaGroupObjects=*T*)" , - "PrinterGroups" => "(gosaGroupObjects=*P*)" , - "PhoneGroups" => "(gosaGroupObjects=*F*)" ); - /* Create filter */ - foreach($chk as $chkBox => $FilterPart){ - if($this->DivListOGroup->$chkBox){ - $filter .= $FilterPart; - } - } - $filter= "(&(cn=$Regex)(objectClass=gosaGroupOfNames)(|$filter))"; - - if($this->DivListOGroup->SubSearch){ - $res= get_list($filter, "ogroups", $base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT | GL_SUBSEARCH); - }else{ - $res= get_list($filter, "ogroups", get_groups_ou().$base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT ); - } - - $this->ogrouplist= $res; - ksort ($this->ogrouplist); - reset ($this->ogrouplist); - $tmp=array(); - foreach($this->ogrouplist as $tkey => $val ){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - ksort($tmp); - $this->ogrouplist=array(); - foreach($tmp as $val){ - $this->ogrouplist[]=$val; - } - reset ($this->ogrouplist); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->ogrouplist[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups"); - } - - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->ogrouplist[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","ogrouptabs","OGROUPTABS","ogroups"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","ogrouptabs","OGROUPTABS","ogroups"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListOGroup->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - function save_object() - { - $this->DivListOGroup->save_object(); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/class_phonequeue.inc b/plugins/admin/ogroups/class_phonequeue.inc deleted file mode 100644 index f67ee78d8..000000000 --- a/plugins/admin/ogroups/class_phonequeue.inc +++ /dev/null @@ -1,961 +0,0 @@ -goFonHomeServers if available - * and use first server as default if necessary. - */ - if(array_key_exists('config',$_SESSION) && - array_key_exists('SERVERS',$_SESSION['config']->data) && - array_key_exists('FON',$_SESSION['config']->data['SERVERS']) && - count($_SESSION['config']->data['SERVERS']['FON']) && - is_callable("mysql_connect") - ) { - - /* Set available server */ - $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON']; - - /* Set default server */ - if($this->dn == "new"){ - $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; - } - - /* Remember inital home server, to be able to remove old entries */ - $this->init_HomeServer = $this->goFonHomeServer; - - /* get config */ - if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){ - print_red(sprintf(_("The specified home server '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry while ignoring old accounts."), preg_replace("/,/",", ",$this->goFonHomeServer), preg_replace("/,/",", ",$this->goFonHomeServers[0]['DN']))); - $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; - $this->init_HomeServer = $this->goFonHomeServers[0]['DN']; - } - $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer]; - } - - - /* Variable init - * Load phone nubmers and parse dial options - */ - if($this->is_account){ - if(isset($this->attrs['telephoneNumber'])){ - $this->telephoneNumber=$this->attrs['telephoneNumber']; - unset($this->telephoneNumber['count']); - } - for($i = 0; $i < strlen($this->goFonDialOption); $i++){ - $name = "goFonDialOption".$this->goFonDialOption[$i]; - $this->$name=$this->goFonDialOption[$i]; - } - } - - /* Set Queue announce hold time to true/false */ - if(preg_match("/no/i",$this->goFonQueueAnnounceHoldtime)){ - $this->goFonQueueAnnounceHoldtime=false; - }else{ - $this->goFonQueueAnnounceHoldtime=true; - } - - /* Define all available ringdown types */ - $types= array('ringall' =>_("ring all"), - 'roundrobin' =>_("round robin"), - 'leastrecent'=>_("least recently called"), - 'fewestcalls'=>_("fewest completed calls"), - 'random' =>_("random"), - 'rrmemory' =>_("round robin with memory")); - $i = 0; - foreach($types as $type => $name){ - $i++; - $this->goFonQueueStrategyOptions[$i] =$name; - $this->goFonQueueStrategyOptionsR[$i] =$type; - $tmp[$type] = $i; - } - $this->goFonQueueStrategy= $tmp[$this->goFonQueueStrategy]; - $this->old_cn = $this->cn; - $this->old_phone_numbers = $this->telephoneNumber; - } - - - /* This function ensures that the selected home server - * and the initially selected home server are reachable and accessible - */ - function check_database_accessibility() - { - /* Check if mysql extension is available */ - if(!is_callable("mysql_pconnect")){ - return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup.")); - } - - /******************** - * Check currently selected home server - ********************/ - - $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer]; - $r_current = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); - if(!$r_current){ - new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current)); - return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), - $cfg_Current['SERVER'],$cfg_Current['LOGIN'])); - } - $db_current = @mysql_select_db($cfg_Current['DB'],$r_current); - if(!$db_current){ - new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current)); - mysql_close($r_current); - return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER'])); - } - - /******************** - * Check init home server - ********************/ - - if($this->initially_was_account){ - $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ; - $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']); - if(!$r_init){ - new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_init)); - return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), - $cfg_Init['SERVER'],$cfg_Init['LOGIN'])); - } - $db_init = @mysql_select_db($cfg_Init['DB'],$r_init); - if(!$db_init){ - new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_init)); - mysql_close($r_init); - return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER'])); - } - } - } - - - /* Display plugin ui */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","ogroups/".get_class($this),$this->dn); - } - - 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; - } - } - - /* Show tab dialog headers */ - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove the phone queue from this Account"), - _("Phone queue is enabled for this group. You can disable it by clicking below.")); - } else { - $display= $this->show_enable_header(_("Create phone queue"), - _("For this group the phone queues are disabled. You can enable them by clicking below.")); - return ($display); - } - } - - if($this->acl_is_writeable("telephoneNumber")){ - - /* Add queue number */ - if(isset($_POST['add_phonenumber'])&&(isset($_POST['phonenumber']))&&(!empty($_POST['phonenumber']))){ - if((!in_array($_POST['phonenumber'],$this->telephoneNumber))&&(is_numeric($_POST['phonenumber']))){ - $this->telephoneNumber[]=$_POST['phonenumber']; - } - } - - /* Delete queue number */ - if(isset($_POST['delete_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){ - unset($this->telephoneNumber[$_POST['goFonQueueNumber_List']]); - } - - /* queue number up */ - if(isset($_POST['up_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){ - if($_POST['goFonQueueNumber_List']>0){ - $up = $this->telephoneNumber[$_POST['goFonQueueNumber_List']]; - $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1]; - $this->telephoneNumber[$_POST['goFonQueueNumber_List']] = $down; - $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1] = $up; - } - } - - /* Queuenumber down */ - if(isset($_POST['down_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){ - if(isset($this->telephoneNumber[($_POST['goFonQueueNumber_List']+1)])){ - $up = $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1]; - $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']]; - $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1] = $down; - $this->telephoneNumber[$_POST['goFonQueueNumber_List']] = $up; - } - $this->telephoneNumber[$_POST['goFonQueueNumber_List']] = $up; - } - } - - $tmp = array(); - foreach($this->telephoneNumber as $val){ - if(!empty($val)){ - $tmp[]= $val; - } - } - $this->telephoneNumber=$tmp; - - /* Assign samrty variables */ - $smarty= get_smarty(); - $smarty->assign("goFonQueueLanguageOptions",get_languages(FALSE,TRUE)); - $smarty->assign("goFonQueueStrategyOptions", $this->goFonQueueStrategyOptions); - - /* Set acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - foreach($this->attributes as $key => $val){ - $smarty->assign($val,$this->$val); - if($this->$val == false){ - $smarty->assign($val."CHK",""); - }else{ - $smarty->assign($val."CHK"," checked "); - } - } - - /* Create array with goFonHomeServer */ - $tmp = array(); - foreach($this->goFonHomeServers as $dn => $val){ - if(!is_numeric($dn)){ - $tmp[$dn] = $val['SERVER']; - } - } - $smarty->assign("goFonHomeServers",$tmp); - - return ($display.$smarty->fetch (get_template_path('phonequeue.tpl', TRUE))); - } - - - /* Check formular input */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - if(!count($this->goFonHomeServers)){ - $message[] = _("There must be at least one server with an asterisk database to create a phone queue."); - } - if(empty($this->goFonHomeServer)){ - $message[] = _("Please select a valid goFonHomeServer."); - } - if($this->is_number_used()){ - $message[] = $this->is_number_used(); - } - if(!((is_numeric($this->goFonTimeOut))||(empty($this->goFonTimeOut)))){ - $message[] = _("Timeout must be numeric"); - } - if(!((is_numeric($this->goFonQueueRetry))||(empty($this->goFonQueueRetry)))){ - $message[] = _("Retry must be numeric"); - } - if(!((is_numeric($this->goFonMaxLen))||(empty($this->goFonMaxLen)))){ - $message[] = _("Max queue length must be numeric"); - } - if(!((is_numeric($this->goFonAnnounceFrequency))||(empty($this->goFonAnnounceFrequency)))){ - $message[] = _("Announce frequency must be numeric"); - } - if(count($this->telephoneNumber)==0){ - $message[] = _("There must be least one queue number defined."); - } - - /* check if add to database could be successfull */ - $str = $this->add_to_database(); - if(!empty($str)){ - $message[] = $str; - } - return $message; - } - - - /* This function removes the old database entries. - * If this entry should be removed or the home server has changed - * this function is called to ensure that all old entries will be deleted. - */ - function remove_from_database($save = false) - { - /* Check if we must remove old entries */ - if($this->initially_was_account){ - - /* Check if there is at least on server configuration */ - if(!count($this->goFonHomeServers)){ - return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); - } - - /******************** - * Get configuration and check it - ********************/ - - /* Check if databases are reachable, returns an error string if anything fails */ - $error_str = $this->check_database_accessibility(); - if($error_str){ - return($error_str); - } - - /* Connect to current database to be able to add new entries */ - $cfg_Current = $this->goFonHomeServers[$this->init_HomeServer] ; - $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); - $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur); - - /* Create sql entries */ - $delete[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->old_cn."';\n"; - $delete[]= "DELETE FROM ".$cfg_Current['QUEUE_TABLE']." WHERE name='".$this->old_cn."'; \n"; - $delete[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->old_cn."';\n"; - foreach($this->old_phone_numbers as $number){ - $delete[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$number."';\n"; - } - - /* Execute the queries */ - if($save){ - foreach($delete as $sql){ - $res = @mysql_query($sql,$res_cur); - if(!$res){ - new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current)); - return(_("Error while removing old queue entries from database."). - " "._("Please have a look a the gosa logfiles.")); - } - } - } - } - } - - - /* This function handles the database entries for this - * queue. - * Existing entries will be updated if possible. - */ - function add_to_database($save = false) - { - /* Check if there is at least on server configuration */ - if(!count($this->goFonHomeServers)){ - return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); - } - - /******************** - * Get configuration and check it - ********************/ - - /* Check if databases are reachable, returns an error string if anything fails */ - $error_str = $this->check_database_accessibility(); - if($error_str){ - return($error_str); - } - - /* Connect to current database to be able to add new entries */ - $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer] ; - $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); - $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur); - - /* Connect to old home server and remove old entries if necessary */ - if(($this->initially_was_account) && ($this->init_HomeServer != $this->goFonHomeServer)){ - $str = $this->remove_from_database($save); - if(!empty($str)){ - return($str);; - } - } - - /* Ensure that we have the new cn in $this->cn and the old cn in $this->old_cn */ - $this->cn = $this->parent->by_object['ogroup']->cn; - - if($save){ - - /***************** - * Create queue table entry - *****************/ - - /* Check if QUEUE_TABLE entry exists. - * If this entry is missing - create it - * else update the entry with new values. - */ - $query = "SELECT * FROM ".$cfg_Current['QUEUE_TABLE']." WHERE name='".$this->old_cn."';"; - $res = mysql_query($query,$res_cur); - if(!$res){ - new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($res_cur)); - return(_("Could not detect old queue entry, query failed.")." "._("Please have a look a the gosa logfiles.")); - } - $cnt = mysql_affected_rows($res_cur); - - - /* Create queue table entry - * Leave unused options empty. - */ - $queue["announce"] = ""; - $queue["monitor_join"] = ""; - $queue["monitor_format"] = ""; - $queue["announce_round_seconds"]= ""; - $queue["wrapuptime"] = ""; - $queue["servicelevel"] = ""; - $queue["eventmemberstatus"] = ""; - $queue["eventwhencalled"] = ""; - $queue["memberdelay"] = ""; - $queue["weight"] = ""; - $queue["timeoutrestart"] = ""; - - $queue["queue_holdtime"] = $this->goFonQueueAnnounce; - $queue["queue_lessthan"] = $this->goFonQueueLessThan; - $queue["retry"] = $this->goFonQueueRetry; - $queue["reportholdtime"] = "1"; - $queue["joinempty"] = "no"; - $queue["leavewhenempty"] = "yes"; - - $queue["context"] = "default"; - $queue["name"] = $this->cn; - $queue["timeout"] = $this->goFonTimeOut; - $queue["maxlen"] = $this->goFonMaxLen; - $queue["strategy" ] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy]; - $queue["queue_thankyou"] = $this->goFonQueueThankYou; - $queue["queue_reporthold"] = $this->goFonQueueReportHold; - $queue["announce_frequency"] = $this->goFonAnnounceFrequency; - $queue["queue_youarenext"] = $this->goFonQueueYouAreNext; - $queue["queue_thereare"] = $this->goFonQueueThereAre; - $queue["queue_callswaiting"] = $this->goFonQueueCallsWaiting; - $queue["queue_minutes"] = $this->goFonQueueMinutes; - $queue["queue_seconds"] = $this->goFonQueueSeconds; - $queue["announce_holdtime"] = $this->goFonQueueAnnounceHoldtime; - $queue["musiconhold"] = $this->goFonMusiconHold; - - - /* Check if we must create a new queue entry - * or if we can update an existing entry - * $cnt contains the number of entries matching this cn - */ - - /* Create new queue table entry - */ - if($cnt == 0){ - - /* Parse and Add Queue */ - $entries = ""; - $values = ""; - foreach($queue as $attr=>$val){ - if($val == "") continue; - $entries.= "`".$attr."`,"; - $values .= "'".$val."',"; - } - $values = preg_replace("/,$/","",$values); - $entries = preg_replace("/,$/","",$entries ); - $SQL[]="INSERT INTO ".$cfg_Current['QUEUE_TABLE']." (".$entries.") VALUES (".$values.");"; - }elseif($cnt == 1){ - - /* Update queue table entry - */ - $queue_old = @mysql_fetch_assoc($res); - foreach($queue_old as $name => $value){ - if(isset($queue[$name]) && $queue[$name] == $value){ - unset($queue[$name]); - } - } - - /* Parse and Add Queue */ - if(count($queue)){ - $query = "UPDATE ".$cfg_Current['QUEUE_TABLE']." SET "; - foreach($queue as $key => $val){ - $query.= "".$key."='".$val."',"; - } - $query = preg_replace("/,$/","",$query); - $query.= " WHERE name='".$this->old_cn."';"; - $SQL[] = $query; - } - }else{ - return(sprintf(_("More than one entry in queue table found, that uses the name ('%s'). Please fix this issue manually first."),$this->cn)); - } - - - /***************** - * Create queue member entries - *****************/ - - /* Add the queue member entries - * First we must remove all old user entries. - * to be able to add a clean set of members. - */ - $SQL[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->cn."';"; - $SQL[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->old_cn."';"; - - /* Append new Member for this queue */ - $queueuser =array(); - $i = 0; - $parent = $this->parent->by_object['ogroup']; - - - $ldap = $this->config->get_ldap_link(); - foreach($parent->memberList as $member => $mem_data){ - $ldap->cat($member,array("goFonHomeServer","objectClass","dn","uid")); - if($ldap->count()){ - - $obj = $ldap->fetch(); - - /* Calculate server and account dependencies */ - $is_acc = in_array("goFonAccount",$obj['objectClass']); - $is_home= isset($obj['goFonHomeServer'][0]) && $obj['goFonHomeServer'][0] == $this->goFonHomeServer; - - /* Append user to list of queue member, - * only if user has phoneAccount extension && is on same home server */ - if($is_acc && $is_home){ - $i ++ ; - $queueuser[$i]['queue_name'] = $this->cn; - $queueuser[$i]['interface'] = "SIP/".$obj['uid'][0]; - $queueuser[$i]['penalty'] = 1; - } - } - } - - /* Parse and Add members to query Array */ - if(is_array($queueuser)){ - foreach($queueuser as $user){ - $entries = ""; - $values = ""; - foreach($user as $attr => $val){ - $entries.= "`".$attr."`,"; - $values .= "'".$val."',"; - } - $values = preg_replace("/,$/","",$values); - $entries = preg_replace("/,$/","",$entries ); - - $SQL[]="INSERT INTO ".$cfg_Current['QUEUE_MEMBER_TABLE']." (".$entries.") VALUES (".$values.")"; - } - } - - - /***************** - * Create extension entries - *****************/ - - /* Add the extension entries - * First we must remove all old entensions. - */ - $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->cn."';\n"; - $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->old_cn."';\n"; - - /* Delete old enxtension entries for the old telephone nubmer */ - if(is_array($this->old_phone_numbers)){ - foreach($this->old_phone_numbers as $phone){ - $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$phone."';\n"; - } - } - - /* Delete enxtension entries for telephone numbers */ - if(is_array($this->telephoneNumber)){ - foreach($this->telephoneNumber as $phone){ - $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$phone."';\n"; - } - } - - /* Create a extension entry fpr each telephoneNumber */ - $i_insert_only_once = false; - $prio = 11; // This represents the priority for each telephoneNumber - foreach($this->telephoneNumber as $num){ - - /* The naming refrences */ - if($i_insert_only_once == false){ - $i_insert_only_once = true; - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $this->cn; - $a_ext[$i]['priority'] = 1; - $a_ext[$i]['app'] = "Goto"; - $a_ext[$i]['appdata'] = $num."|1"; - $i ++ ; - } - - /* If there is currently no user for this queue - * Play no service sound file and return to default context. - */ - if(count($queueuser)==0){ - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 1; - $a_ext[$i]['app'] = "SetLanguage"; - $a_ext[$i]['appdata'] = "de"; - $i ++ ; - - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 2; - $a_ext[$i]['app'] = "Playback"; - $a_ext[$i]['appdata'] = "ss-noservice"; - $i ++ ; - - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 3; - $a_ext[$i]['app'] = "Goto"; - $a_ext[$i]['appdata'] = "default"; - $i ++ ; - }else{ - - /* Dcrement priority to avoid using same priority twice */ - $prio --; - - /* Wait for 2 seconds */ - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 1; - $a_ext[$i]['app'] = "Wait"; - $a_ext[$i]['appdata'] = "2"; - $i ++ ; - - /* Set language to queue language */ - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 2; - $a_ext[$i]['app'] = "SetLanguage"; - $a_ext[$i]['appdata'] = $this->goFonQueueLanguage; - $i ++ ; - - /* Play welcome sound file */ - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 3; - $a_ext[$i]['app'] = "Playback"; - $a_ext[$i]['appdata'] = $this->goFonWelcomeMusic; - $i ++ ; - - /* Set CID name */ - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 4; - $a_ext[$i]['app'] = "SetCIDName"; - if(!empty($this->parent->by_object['ogroup']->description)){ - $a_ext[$i]['appdata'] = $this->parent->by_object['ogroup']->description; - }else{ - $a_ext[$i]['appdata'] = $this->cn." - ".$num; - } - $i ++ ; - - /* Set queue priority */ - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 5; - $a_ext[$i]['app'] = "SetVar"; - $a_ext[$i]['appdata'] = "QUEUE_PRIO=".$prio; - $i ++ ; - - /* Open queue */ - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 6; - $a_ext[$i]['app'] = "Queue"; - $a_ext[$i]['appdata'] = $this->cn; - "|". - $this->goFonDialOptiont. - $this->goFonDialOptionT. - $this->goFonDialOptionh. - $this->goFonDialOptionH. - $this->goFonDialOptionr; - } - - $i++; - } - - /* Parse and Add Extension entries */ - foreach($a_ext as $ext){ - $entries = ""; - $values = ""; - foreach($ext as $attr => $val){ - $entries.= "`".$attr."`,"; - $values .= "'".$val."',"; - } - $values = preg_replace("/,$/","",$values); - $entries = preg_replace("/,$/","",$entries ); - $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$entries.") VALUES (".$values.")"; - } - - /* Do all collected mysql queries - */ - foreach($SQL as $query) - $res = mysql_query($query,$res_cur); - if(!$res){ - new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($res_cur)); - return(_("Mysql query failed.")." "._("Please have a look a the gosa logfiles.")); - } - } - @mysql_close($r_con); - return(false); - } - - - /* This function checks if the given phonenumbers - * are available or already in use - */ - function is_number_used() - { - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(& (!(uid=".$this->cn.")) - (!(cn=".$this->cn."))) - (| (objectClass=goFonAccount) - (objectClass=goFonQueue) - (objectClass=goFonConference)))", array("telephoneNumber","cn","uid")); - while($attrs = $ldap->fetch()) { - unset($attrs['telephoneNumber']['count']); - foreach($attrs['telephoneNumber'] as $tele){ - if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn']; - if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn']; - $numbers[$tele]=$attrs; - } - } - - foreach($this->telephoneNumber as $num){ - if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!= $this->attrs['cn'][0]))){ - if(isset($numbers[$num]['uid'][0])){ - return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]); - }else{ - return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]); - } - } - } - } - - - /* Get posted attributes */ - function save_object() - { - plugin::save_object(); - if(isset($_POST['phonenumber'])){ - foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionh","goFonDialOptionr","goFonDialOptionH","goFonMusiconHold") as $val){ - if(isset($_POST[$val])){ - $this->$val = $_POST[$val]; - }else{ - $this->$val = false; - } - } - if(isset($_POST['goFonQueueAnnounceHoldtime'])){ - $this->goFonQueueAnnounceHoldtime = "yes"; - }else{ - $this->goFonQueueAnnounceHoldtime = false; - } - } - } - - - function save() - { - $ldap= $this->config->get_ldap_link(); - - plugin::save(); - - /* Create dial option attribute */ - $this->attrs['goFonDialOption'] = ""; - foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){ - $this->attrs['goFonDialOption'].=$this->$val; - unset($this->attrs[$val]); - } - if(empty($this->attrs['goFonDialOption'])) { - $this->attrs['goFonDialOption']=array(); - } - - /* Set announce hold time to yes no .. */ - if($this->goFonQueueAnnounceHoldtime != "no" ){ - $this->attrs['goFonQueueAnnounceHoldtime'] = "yes"; - }else{ - $this->attrs['goFonQueueAnnounceHoldtime'] = "no"; - } - - /* Set strategy */ - $this->attrs['goFonQueueStrategy'] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy]; - - /* Add database entry, display error and abort if this fails */ - $str = $this->add_to_database(true); - if(!empty($str)){ - print_red($str); - } - - /* Save data to LDAP */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - if($this->initially_was_account){ - new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), _("Saving phone queue failed")); - - /* 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"); - } - } else { - $this->handle_post_events("add"); - } - } - - - /* remove object from parent */ - function remove_from_parent() - { - /* Cancel if nothing is to do here */ - if (!$this->initially_was_account){ - return; - } - - /* Remove database entries, - * if fails display errors and abort - */ - $str = $this->remove_from_database(true); - if(!empty($str)){ - print_red($str); - return false; - } - - /* Remove all temporary attributes */ - $tmp = array_flip($this->attributes); - foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){ - unset($this->$val); - unset($this->attrs[$val]); - unset($tmp[$val]); - } - foreach(array_flip($tmp) as $key => $val){ - $tmp2[]=$val; - } - $this->attributes = $tmp2; - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), _("Removing phone queue failed")); - } - - - function getCopyDialog() - { - $str = ""; - $str .= _("Phone number"); - $str .= " "; - return($str); - } - - - function saveCopyDialog() - { - if(isset($_POST['telephoneNumber'])){ - $this->telephoneNumber = $_POST['telephoneNumber']; - } - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Phone"), - "plDescription" => _("Phone group"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 3, - "plSection" => array("administration"), - "plCategory" => array("ogroups"), - "plProvidedAcls"=> array( - - "goFonTimeOut" => _("Timeout"), - "goFonMaxLen" => _("Max queue length"), - "goFonHomeServer" => _("Home server"), - "goFonAnnounceFrequency" => _("Announce frequency"), - "goFonDialOptiont" => _("Allow the called user to transfer his call"), - "goFonDialOptionT" => _("Allows calling user to transfer call"), - "goFonDialOptionh" => _("Allow the called to hangup by pressing *"), - "goFonDialOptionr" => _("Ring instead of playing background music"), - "goFonDialOptionH" => _("Allows calling to hangup by pressing *"), - - "goFonMusiconHold" => _("Music on hold"), - "goFonWelcomeMusic" => _("Welcome music"), - "goFonQueueReportHold" => _("Report hold time"), - "goFonQueueYouAreNext" => _("'You are next' sound"), - "goFonQueueThereAre" => _("'There are' sound"), - "goFonQueueCallsWaiting" => _("'Call waiting' sound"), - "goFonQueueThankYou" => _("'Thank you' sound"), - "goFonQueueMinutes" => _("'Minutes' sound"), - "goFonQueueSeconds" => _("'Seconds' sound"), - "goFonQueueLessThan" => _("'Less than' sound"), - "telephoneNumber" => _("Queue phone number"), - "goFonQueueLanguage" => _("Language"), - "goFonQueueStrategy" => _("Method"), - "goFonQueueAnnounceHoldtime"=> _("Announce holdtime"), - "goFonQueueAnnounce" => _("Announce"), - "goFonQueueRetry" => _("Retry")) - )); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/class_termgroup.inc b/plugins/admin/ogroups/class_termgroup.inc deleted file mode 100644 index 53c59ecc8..000000000 --- a/plugins/admin/ogroups/class_termgroup.inc +++ /dev/null @@ -1,432 +0,0 @@ - "localboot", - "instant_update" => "softupdate", - "update" => "sceduledupdate", - "reinstall" => "install", - "rescan" => "", - "memcheck" => "memcheck", - "sysinfo" => "sysinfo"); - - var $attributes = array("gotoMode","gotoSyslogServer", "gotoNtpServer"); - var $objectclasses = array("gotoWorkstationTemplate"); - var $CopyPasteVars = array("gotoNtpServers","modes","inheritTimeServer","members"); - var $view_logged = FALSE; - - - function termgroup (&$config, $dn= NULL, $parent= NULL) - { - /*************** - Some initialisations - ***************/ - - plugin::plugin($config, $dn, $parent); - - $ldap= $config->get_ldap_link(); - - $this->is_account = true; - $this->modes["active"]= _("Activated"); - $this->modes["locked"]= _("Locked"); -// $this->modes["memcheck"]= _("Memory test"); -// $this->modes["sysinfo"]= _("System analysis"); - - $this->orig_dn = $this->dn; - - /*************** - Get mac addresses from member objects - ***************/ - - /* We're only interested in the terminal members here, evaluate - these... */ - if(isset($this->attrs['member'])){ - for ($i= 0; $i<$this->attrs['member']['count']; $i++){ - $member= $this->attrs['member'][$i]; - $ldap->cat($member, array('objectClass', 'macAddress', 'cn')); - if (preg_match("/success/i", $ldap->error)){ - $attrs = $ldap->fetch(); - if (in_array("gotoTerminal", $attrs['objectClass']) || - in_array("gotoWorkstation", $attrs['objectClass'])){ - if (isset($attrs['macAddress'])){ - $this->members[$attrs['cn'][0]]= $attrs['macAddress'][0]; - } else { - $this->members[$attrs['cn'][0]]= ""; - } - } - } - } - } - - /*************** - Perpare NTP settings - ***************/ - - /* Create used ntp server array */ - $this->gotoNtpServer= array(); - if(isset($this->attrs['gotoNtpServer'])){ - $this->inheritTimeServer = false; - unset($this->attrs['gotoNtpServer']['count']); - foreach($this->attrs['gotoNtpServer'] as $server){ - $this->gotoNtpServer[$server] = $server; - } - } - - /* Set inherit checkbox state */ - if(in_array("default",$this->gotoNtpServer)){ - $this->inheritTimeServer = true; - $this->gotoNtpServer=array(); - } - - /* Create available ntp options */ - $this->gotoNtpServers = $this->config->data['SERVERS']['NTP']; - foreach($this->gotoNtpServers as $key => $server){ - if($server == "default"){ - unset($this->gotoNtpServers[$key]); - } - } - } - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if (!$this->acl_is_createable() && $this->dn == "new"){ - $message[]= _("You have no permissions to create a workstation on this 'Base'."); - } - - /* Check for valid ntpServer selection */ - if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){ - $message[]= _("There must be at least one NTP server selected."); - } - return($message); - } - - function remove_from_parent() - { - /* Workstation startup is using gotoWorkstationTemplate too, - if we remove this oc all other not manged attributes will cause errors */ - if(isset($this->attrs['gotoKernelParameters'])){ - $this->objectclasses = array(); - } - - /* Remove acc */ - plugin::remove_from_parent(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->orig_dn); - $ldap->modify($this->attrs); - $this->handle_post_events("remove"); - new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - - function update_term_member_FAIstate($act) - { - /* Get required informations */ - $og = $this->parent->by_object['ogroup']; - $allobs = $og->objcache; - - /* Get correct value for FAIstate */ - $action = $this->mapActions[$act]; - - /* Get ldap connection */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - - /* Foreach member of mthis ogroup ... */ - foreach($og->member as $key ){ - - /* check objectClasses and create attributes array */ - $attrs = array("FAIstate"=>$action); - for($i = 0; $i < $allobs[$key]['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $allobs[$key]['objectClass'][$i]; - } - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } - if($attrs['FAIstate'] == ""){ - $attrs['FAIstate'] = array(); - } - - /* If this objects is workstation,terminal or server upodate FAIstate */ - if(preg_match("/(w|t|s)/i",$allobs[$key]['type'])){ - $ldap->cd ($key); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(),sprintf(_("Setting action state (FAIstate) failed for object '%s', value was '%s'."),$key,$action)); - } - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","ogroups/".get_class($this),$this->dn); - } - - /*************** - Handle requested action - ***************/ - - /* Watch for events */ - if (isset($_POST['action'])){ - $macaddresses=""; - $names=""; - foreach ($this->members as $cn => $macAddress){ - $macaddresses.= "$macAddress "; - $names.= "$cn "; - } - - if (isset($_POST['action'])){ - - /* Update members fai state */ - $this->update_term_member_FAIstate(trim($_POST['saction'])); - - $cmd = $this->config->search("workgeneric", "ACTIONCMD",array('tabs')); - - if ($cmd == ""){ - print_red(_("No ACTIONCMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$macaddresses." ".escapeshellarg($_POST['saction']), $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } else { - $this->didAction= TRUE; - - /* Get dns from member objects. Create ldap object */ - $member = $this->parent->by_object['ogroup']->member; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* walk trough members and add FAIstate */ - foreach($member as $dn => $object){ - - /* Get object */ - $ldap->cat($dn,array("objectClass")); - $res = $ldap->fetch(); - $attrs = array(); - - /* Add FAI state */ - $attrs['FAIstate'] = ""; - if(isset($this->mapActions[$_POST['saction']])){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } - - /* Fix objectClass index */ - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } - - /* Check if we must add the objectClass */ - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } - - if($attrs['FAIstate'] == ""){ - $attrs['FAIstate'] = array(); - } - - $ldap->cd($dn); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic (FAIstate) with dn '%s' failed."),$dn)); - } - $this->didAction= TRUE; - } - } - } - } - - - /*************** - Add remove NTP server - ***************/ - - /* Add new ntp Server to our list */ - if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers']))){ - $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; - } - - /* Delete selected NtpServer for list of used servers */ - if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected']))){ - foreach($_POST['gotoNtpServerSelected'] as $name){ - unset($this->gotoNtpServer[$name]); - } - } - - - /*************** - Prepare smarty - ***************/ - - /* Set government mode */ - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated) { - $smarty->assign($name."ACL",$this->getacl($name)); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr, $this->$attr); - } - - /* Variables */ - foreach(array("gotoMode","gotoNtpServer") as $val){ - $smarty->assign($val."_select", $this->$val); - } - - $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), - "instant_update" => _("Instant update"), - "update" => _("Scheduled update"), - "reinstall" => _("Reinstall"), - "rescan" => _("Rescan hardware"), - "memcheck" => _("Memory test"), - "sysinfo" => _("System analysis"))); - - $smarty->assign("inheritTimeServer",$this->inheritTimeServer); - $smarty->assign("modes", $this->modes); - - $tmp = array(); - foreach($this->gotoNtpServers as $server){ - if(!in_array($server,$this->gotoNtpServer)){ - $tmp[$server] = $server; - } - } - - $smarty->assign("gotoNtpServers",$tmp); - $smarty->assign("syslogservers", $this->config->data['SERVERS']['SYSLOG']); - $smarty->assign("gotoSyslogServer_select", $this->gotoSyslogServer); - - /* Show main page */ - return ($smarty->fetch (get_template_path('termgroup.tpl', TRUE))); - } - - function save_object() - { - plugin::save_object(); - /* Set inherit mode */ - if(isset($_POST['workgeneric_posted'])){ - if(isset($_POST["inheritTimeServer"])){ - $this->inheritTimeServer = true; - }else{ - $this->inheritTimeServer = false; - } - } - } - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /*************** - Prepare special vars - ***************/ - - /* Unset some special vars ... */ - foreach (array("gotoSyslogServer") as $val){ - if ($this->attrs[$val] == "default"){ - $this->attrs[$val]= array(); - } - } - - /* Update ntp server settings */ - if($this->inheritTimeServer){ - $this->attrs['gotoNtpServer'] = "default"; - }else{ - /* Set ntpServers */ - $this->attrs['gotoNtpServer'] = array(); - foreach($this->gotoNtpServer as $server){ - $this->attrs['gotoNtpServer'][] = $server; - } - } - - - /*************** - Write to ldap - ***************/ - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - if($this->initially_was_account){ - new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - if(!$this->didAction){ - $this->handle_post_events("modify"); - } - show_ldap_error($ldap->get_error(), _("Saving workstation failed")); - - } - - static function plInfo() - { - return (array( - "plShortName" => _("System"), - "plDescription" => _("System group"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 5, - "plSection" => array("administration"), - "plCategory" => array("ogroups"), - "plProvidedAcls"=> array( - "gotoMode" => _("Mode"), - "gotoSyslogServer" => _("Syslog server"), - "FAIstate" => _("Action flag"), - "gotoNtpServer" => _("Ntp server")) - )); - } - - function PrepareForCopyPaste($source) - { - /* Create used ntp server array */ - $this->gotoNtpServer= array(); - - if(isset($source['gotoNtpServer'])){ - $this->inheritTimeServer = false; - unset($source['gotoNtpServer']['count']); - foreach($source['gotoNtpServer'] as $server){ - $this->gotoNtpServer[$server] = $server; - } - } - - /* Set inherit checkbox state */ - if(in_array("default",$this->gotoNtpServer)){ - $this->inheritTimeServer = true; - $this->gotoNtpServer=array(); - } - - /* Create available ntp options */ - $this->gotoNtpServers = $this->config->data['SERVERS']['NTP']; - foreach($this->gotoNtpServers as $key => $server){ - if($server == "default"){ - unset($this->gotoNtpServers[$key]); - } - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/generic.tpl b/plugins/admin/ogroups/generic.tpl deleted file mode 100644 index f6f75bcb4..000000000 --- a/plugins/admin/ogroups/generic.tpl +++ /dev/null @@ -1,65 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - -
{$must} -{render acl=$cnACL} - -{/render} -
-{render acl=$descriptionACL} - -{/render} -
 
{$must} -{render acl=$baseACL} - -{/render} -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
- -
-  ({$combinedObjects}) -
-{render acl=$memberACL} - -{/render} -
-{render acl=$memberACL} -   -{/render} -{render acl=$memberACL} - -{/render} -
- - - diff --git a/plugins/admin/ogroups/mail.tpl b/plugins/admin/ogroups/mail.tpl deleted file mode 100644 index a28d0ac04..000000000 --- a/plugins/admin/ogroups/mail.tpl +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - -
-

{t}Mail distribution list{/t}

- - - - - -
{$must} -{render acl=$mailACL} - -{/render} -
-
- - - diff --git a/plugins/admin/ogroups/main.inc b/plugins/admin/ogroups/main.inc deleted file mode 100644 index 79690779d..000000000 --- a/plugins/admin/ogroups/main.inc +++ /dev/null @@ -1,50 +0,0 @@ -save_object(); - $output= $ogroup->execute (); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/ogroup.png'), - _("Object groups"), - "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/ogroup.png'), _("Object groups")); - } - - $display.= $output; - - /* Store changes in session */ - $_SESSION['ogroup']= $ogroup; -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/ogroup_objects.tpl b/plugins/admin/ogroups/ogroup_objects.tpl deleted file mode 100644 index 663b60274..000000000 --- a/plugins/admin/ogroups/ogroup_objects.tpl +++ /dev/null @@ -1,58 +0,0 @@ - - - - - -
-
-

- {t}Select objects to add{/t} {$hint} -

-
-
-

- - -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
-

- {t}Show departments{/t}
- {t}Show people{/t}
- {t}Show groups{/t}
- {t}Show applications{/t}
- {t}Show servers{/t}
- {t}Show workstations{/t}
- {t}Show terminals{/t}
- {t}Show printers{/t}
- {t}Show phones{/t}
-

-

- {t}Search in subtrees{/t}
-

- -
  -
- -
- {$apply} -
-
- -

- -   - -

- diff --git a/plugins/admin/ogroups/paste_generic.tpl b/plugins/admin/ogroups/paste_generic.tpl deleted file mode 100644 index 91f84d8ae..000000000 --- a/plugins/admin/ogroups/paste_generic.tpl +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -
- {$must} - - -
- - diff --git a/plugins/admin/ogroups/paste_mail.tpl b/plugins/admin/ogroups/paste_mail.tpl deleted file mode 100644 index 737d707ef..000000000 --- a/plugins/admin/ogroups/paste_mail.tpl +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -
- {$must} - - -
- - diff --git a/plugins/admin/ogroups/phonequeue.tpl b/plugins/admin/ogroups/phonequeue.tpl deleted file mode 100644 index 643b4a326..000000000 --- a/plugins/admin/ogroups/phonequeue.tpl +++ /dev/null @@ -1,328 +0,0 @@ -

- ! {t}Only users with the same asterisk home server will be included to this queue.{/t} -

- - - - - - - - - - - - - - - - - -
-

 {t}Phone numbers{/t}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
-{render acl=$telephoneNumberACL} - -{/render} - -{render acl=$telephoneNumberACL} -
-{/render} -{render acl=$telephoneNumberACL} - -{/render} -
-{render acl=$telephoneNumberACL} - -{/render} -{render acl=$telephoneNumberACL} -   -{/render} -{render acl=$telephoneNumberACL} - -{/render} -
-

 {t}Options{/t}

{$must} -{render acl=$goFonHomeServerACL} - -{/render} -
- {t}Language{/t} - -{render acl=$goFonQueueLanguageACL} - -{/render} -
- {t}Timeout{/t} - -{render acl=$goFonTimeOutACL} - -{/render} -
- {t}Retry{/t} - -{render acl=$goFonQueueRetryACL} - -{/render} -
- {t}Strategy{/t} - -{render acl=$goFonQueueStrategyACL} - -{/render} - -
- {t}Max queue length{/t} - -{render acl=$goFonMaxLenACL} - -{/render} -
- {t}Announce frequency{/t} - -{render acl=$goFonAnnounceFrequencyACL} - -{/render} - {t}(in seconds){/t} -
-
-

- - {t}Queue sound setup{/t} -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {t}Music on hold{/t} - -{render acl=$goFonMusiconHoldACL} - -{/render} -
- {t}Welcome sound file{/t} - -{render acl=$goFonWelcomeMusicACL} - -{/render} -
- {t}Announce message{/t} - -{render acl=$goFonQueueAnnounceACL} - -{/render} -
- {t}Sound file for 'You are next ...'{/t} - -{render acl=$goFonQueueYouAreNextACL} - -{/render} -
- {t}'There are ...'{/t} - -{render acl=$goFonQueueThereAreACL} - -{/render} -
- {t}'... calls waiting'{/t} - -{render acl=$goFonQueueCallsWaitingACL} - -{/render} -
- {t}'Thank you' message{/t} - -{render acl=$goFonQueueThankYouACL} - -{/render} -
- {t}'minutes' sound file{/t} - -{render acl=$goFonQueueMinutesACL} - -{/render} -
- {t}'seconds' sound file{/t} - -{render acl=$goFonQueueSecondsACL} - -{/render} -
- {t}Hold sound file{/t} - -{render acl=$goFonQueueReportHoldACL} - -{/render} -
- {t}Less Than sound file{/t} - -{render acl=$goFonQueueLessThanACL} - -{/render} -
-
-

-

 {t}Phone attributes {/t}

- - - - - - - - - -
-{render acl=$goFonQueueAnnounceHoldtimeACL} - -{/render} - {t}Announce holdtime{/t} -
-{render acl=$goFonDialOptiontACL} - -{/render} - {t}Allow the called user to transfer his call{/t} -
-{render acl=$goFonDialOptionTACL} - -{/render} - {t}Allows calling user to transfer call{/t} -
- -
- - - - - - - - - - -
-{render acl=$goFonDialOptionhACL} - -{/render} - {t}Allow the called to hangup by pressing *{/t} -
-{render acl=$goFonDialOptionHACL} - -{/render} - {t}Allows calling to hangup by pressing *{/t} -
-{render acl=$goFonDialOptionrACL} - -{/render} - {t}Ring instead of playing background music{/t} -
-
diff --git a/plugins/admin/ogroups/remove.tpl b/plugins/admin/ogroups/remove.tpl deleted file mode 100644 index 720156b97..000000000 --- a/plugins/admin/ogroups/remove.tpl +++ /dev/null @@ -1,24 +0,0 @@ -
-  {t}Warning{/t} -
- -

- {$info} - {t}Please double check if you really want to do this since there is no way for GOsa to get your data back.{/t} -

-

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

- diff --git a/plugins/admin/ogroups/tabs_ogroups.inc b/plugins/admin/ogroups/tabs_ogroups.inc deleted file mode 100644 index 3485bb79f..000000000 --- a/plugins/admin/ogroups/tabs_ogroups.inc +++ /dev/null @@ -1,309 +0,0 @@ -by_object['ogroup']->memberList as $dn => $val){ - - if(isset($this->by_object['ogroup']->objcache[$dn])){ - $obj = $this->by_object['ogroup']->objcache[$dn]; - if(isset($obj['objectClass'])){ - if(in_array("goFonAccount",$obj['objectClass'])){ - $usePhoneTab = true; - } - } - } - } - if(((!$usePhoneTab)&&(isset($this->by_object['phonequeue'])))||((!preg_match("/U/",$objects))&&(isset($this->by_object['phonequeue'])))){ - $this->by_object['phonequeue']->remove_from_parent(); - unset($this->by_object['phonequeue']); - unset($this->by_name['phonequeue']); - } - /* Remove mail group if there is no user anymore */ - if((!preg_match("/U/",$objects))&&(isset($this->by_object['mailogroup']))){ - $this->by_object['mailogroup']->remove_from_parent(); - unset($this->by_object['mailogroup']); - unset($this->by_name['mailogroup']); - } - - /* Remove terminal group, if theres no terminal left in the object list */ - if(((!preg_match("/T/",$objects)) && (!preg_match("/W/",$objects)))&&(isset($this->by_object['termgroup']))){ - $this->by_object['termgroup']->remove_from_parent(); - unset($this->by_object['termgroup']); - unset($this->by_name['termgroup']); - } - - /* Remove ws tabs, if theres no ws left in the object list */ - if((!preg_match("/W/",$objects))&&(isset($this->by_object['workservice']))){ - $this->by_object['workservice']->remove_from_parent(); - unset($this->by_object['workservice']); - unset($this->by_name['workservice']); - } - if((!preg_match("/S/",$objects) && !preg_match("/W/",$objects))&&(isset($this->by_object['workstartup']))){ - $this->by_object['workstartup']->remove_from_parent(); - unset($this->by_object['workstartup']); - unset($this->by_name['workstartup']); - $this->by_object['faiSummary']->remove_from_parent(); - unset($this->by_object['faiSummary']); - unset($this->by_name['faiSummary']); - } - - /* Create goPhoneAccount if theres an user with goPhoneAccount - * but only if there is currently no queue enabled. - */ - if(!isset($this->by_object['phonequeue'])){ - foreach($this->by_object['ogroup']->memberList as $dn => $val){ - - if(isset($this->by_object['ogroup']->objcache[$dn])){ - $obj = $this->by_object['ogroup']->objcache[$dn]; - - if(isset($obj['objectClass'])){ - if(in_array("goFonAccount",$obj['objectClass'])){ - $this->by_name['phonequeue']= _("Phone queue"); - $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn); - $this->by_object['phonequeue']->parent= &$this; - break; - } - } - } - } - } - - /* Add mail group tab , if there is curerntly no mail tab defined */ - if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){ - if(isset($this->config->current['MAILMETHOD'])){ - if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){ - $this->by_name['mailogroup']= _("Mail"); - $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn); - $this->by_object['mailogroup']->parent= &$this; - } - } - } - - /* Add Terminal tab */ - if(((preg_match("/T/",$objects)) || (preg_match("/W/",$objects)))&&(!isset($this->by_object['termgroup']))){ - if(!isset($this->by_object['termgroup'])){ - $this->by_name['termgroup']= _("System"); - $this->by_object['termgroup']= new termgroup($this->config, $this->dn); - $this->by_object['termgroup']->inheritTimeServer = false; - $this->by_object['termgroup']->parent= &$this; - } - } - - /* Add Workstation tabs */ - if((preg_match("/W/",$objects))&&(!isset($this->by_object['workservice']))){ - $this->by_name['workservice']= _("Devices"); - $this->by_object['workservice']= new workservice($this->config, $this->dn); - $this->by_object['workservice']->inheritTimeServer = false; - $this->by_object['workservice']->parent= &$this; - $this->by_object['workservice']->acl = "#all#"; - } - if((preg_match("/S/",$objects) || preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){ - $this->by_name['workstartup']= _("Startup"); - $this->by_object['workstartup']= new workstartup($this->config, $this->dn); - $this->by_object['workstartup']->parent= &$this; - $this->by_object['workstartup']->acl = "#all#"; - $this->by_name['faiSummary']= _("Summary"); - $this->by_object['faiSummary']= new faiSummaryTab($this->config, $this->dn); - $this->by_object['faiSummary']->parent= &$this; - } - - /* Add application tab if user or group is member in this object group*/ - if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['appgroup'])){ - $this->by_name['appgroup']= _("Application"); - $this->by_object['appgroup']= new appgroup($this->config, $this->dn); - $this->by_object['appgroup']->acl = "#all#"; - $this->by_object['appgroup']->parent= &$this; - } - - /* Remove application tab if not required any longer */ - if(!preg_match("/G/",$objects) && !preg_match("/U/",$objects) && isset($this->by_name['appgroup'])){ - $this->by_object['appgroup']->remove_from_parent(); - unset($this->by_name['appgroup']); - unset($this->by_object['appgroup']); - } - - /* Add environment tab if user or group is member in this object group*/ - if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['environment'])){ - $this->by_name['environment']= _("Environment"); - $this->by_object['environment']= new environment($this->config, $this->dn); - $this->by_object['environment']->acl = "#all#"; - $this->by_object['environment']->parent= &$this; - } - - /* Remove environment tab if not required any longer */ - if(!preg_match("/G/",$objects) && !preg_match("/U/",$objects) && isset($this->by_name['environment'])){ - $this->by_object['environment']->remove_from_parent(); - unset($this->by_name['environment']); - unset($this->by_object['environment']); - } - /* Move reference tab to second position from right */ - if(isset($this->by_name['acl'])){ - $tmp = $this->by_name['acl']; - unset($this->by_name['acl']); - $this->by_name['acl'] = $tmp; - } - - /* Move reference tab to last position*/ - if(isset($this->by_name['reference'])){ - $tmp = $this->by_name['reference']; - unset($this->by_name['reference']); - $this->by_name['reference'] = $tmp; - } - - /* Reset acls */ - $this->set_acl_base($this->base); - foreach($this->by_object as $name => $obj){ - $this->by_object[$name]->set_acl_category($this->acl_category); - } - } - - function execute(){ - $str = ""; - $this->by_object['ogroup']->AddDelMembership(); - $this->reload($this->by_object['ogroup']->gosaGroupObjects); - $str .= tabs::execute(); - return ( $str); - } - - function ogrouptabs($config, $data, $dn,$category ="ogroups") - { - - tabs::tabs($config, $data, $dn, $category); - $this->base= $this->by_object['ogroup']->base; - $this->acl_category = $category; - - /* Insert extra tabs for several object types - if present */ - - $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects); - - for ($n= 0; $nby_name['termgroup']= _("Terminals"); - $this->by_object['termgroup']= new termgroup($this->config, $this->dn); - $this->by_object['termgroup']->parent= &$this; - - break; - - case "U": - /* Append a PhoneQueue, if objectClass = goFonAccount */ - $use = false; - foreach($this->by_object['ogroup']->memberList as $dn => $val){ - - $obj = $this->by_object['ogroup']->objcache[$dn]; - - if(isset($obj['objectClass'])){ - if(in_array("goFonAccount",$obj['objectClass'])){ - $use = true; - } - } - } - - /* We found goFonAccount in users objectClasses*/ - if($use){ - $this->by_name['phonequeue']= _("Phone queue"); - $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn); - $this->by_object['phonequeue']->parent= &$this; - } - - /* Add a user tab used for mail distribution lists */ - if(isset($this->config->current['MAILMETHOD'])){ - if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){ - $this->by_name['mailogroup']= _("Mail"); - $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn); - $this->by_object['mailogroup']->parent= &$this; - } - } - - break; - } - } - - /* Add references/acls/snapshots */ - $this->reload($this->by_object['ogroup']->gosaGroupObjects); - $this->addSpecialTabs(); - } - - - function check($ignore_account= FALSE) - { - return (tabs::check(FALSE)); - } - - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - - /* Update reference, transfer variables */ - $baseobject= $this->by_object['ogroup']; - foreach ($this->by_object as $name => $obj){ - - /* Don't touch base object */ - if ($name != 'ogroup'){ - $obj->parent = &$this; - $obj->uid = $baseobject->uid; - $obj->cn = $baseobject->cn; - $obj->sn = $baseobject->uid; - $obj->givenName = $baseobject->uid; - $this->by_object[$name]= $obj; - } - - /* Update parent in base object */ - $this->by_object['ogroup']->parent= &$this; - } - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['ogroup']; - - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base; - - /* Move group? */ - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->move($this->dn, $new_dn); - $this->by_object['ogroup']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - if ($this->dn == "new"){ - $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base; - } - - tabs::save(); - - /* Fix tagging if needed */ - $baseobject->dn= $new_dn; - $baseobject->handle_object_tagging(); - } - - function getCopyDialog() - { - $this->reload($this->by_object['ogroup']->gosaGroupObjects); - return(tabs::getCopyDialog()); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/ogroups/termgroup.tpl b/plugins/admin/ogroups/termgroup.tpl deleted file mode 100644 index b35458c99..000000000 --- a/plugins/admin/ogroups/termgroup.tpl +++ /dev/null @@ -1,110 +0,0 @@ -
-{t}Warning{/t}: {t}Actions you choose here influence all systems in this object group. Additionally, all values editable here can be inherited by the clients assigned to this object group.{/t} -
-
-

 

-

{t}Generic{/t}

- - - - - - - - - - - - - -
- - - - - -

-{render acl=$gotoNtpServerACL} - -{/render} -
-{render acl=$gotoNtpServerACL} - -{/render} -{render acl=$gotoNtpServerACL} - -{/render} - -{render acl=$gotoNtpServerACL} - -{/render} -
- - -
- - - - - - - - - - - - -
{t}Mode{/t} -{render acl=$gotoModeACL} - -{/render} -
 
-{render acl=$gotoSyslogServerACL} - -{/render} -
-
-

 

-
- - - - -
- - - -

{t}Action{/t}

- - - - - -
-{render acl=$FAIstateACL} - -{/render} - -{render acl=$FAIstateACL} - -{/render} -
- - - - - diff --git a/plugins/admin/systems/ArpNewDevice.tpl b/plugins/admin/systems/ArpNewDevice.tpl deleted file mode 100644 index 8e4bf44ac..000000000 --- a/plugins/admin/systems/ArpNewDevice.tpl +++ /dev/null @@ -1,31 +0,0 @@ -

{t}Integrating unknown devices{/t}

-

- {t}The current device has been detected by the ARP monitor used by GOsa. You can integrate this device into your running DHCP/DNS infrastructure by submitting this form. The device entry will disapear from the list of the systems and move to the DNS/DHCP configuration.{/t} -

- - - - - - - -
- - - - - - - -
-
-

-{$netconfig} - - - -

diff --git a/plugins/admin/systems/SelectDeviceType.tpl b/plugins/admin/systems/SelectDeviceType.tpl deleted file mode 100644 index d25acbf49..000000000 --- a/plugins/admin/systems/SelectDeviceType.tpl +++ /dev/null @@ -1,46 +0,0 @@ -
-

-{t}This is a new system which currently has no system type defined. Please choose a system type for this entry and press the 'continue' button. If this system should be added to a group of system settings, specify the preferred object group below.{/t} -
-
-

-

-
-{t}Please select a system type and an optional bundle of predefined settings to be inherited.{/t} -
-
-

-
- - - - - -
- - - - -
- {t}System type{/t}  - -
-
- - - - -
- {t}Choose an object group as template{/t}  - -
-
-

 

-

- - -

diff --git a/plugins/admin/systems/chooser.tpl b/plugins/admin/systems/chooser.tpl deleted file mode 100644 index 3e8bf95f9..000000000 --- a/plugins/admin/systems/chooser.tpl +++ /dev/null @@ -1,21 +0,0 @@ -

{t}Choose the kind of system component you want to create{/t}

- -

- {t}Linux terminals and workstations are autocreated on bootup. For this reason you're only be able to create templates for a specific tree. Servers are normally automatically added too, but in some special cases you may need to create a faked server entry to provide GOsa with some informations. Other network components may be used for Nagios setups to create component dependencies.{/t} -

- -{t}Linux thin client template{/t}
-{t}Linux workstation template{/t}
-{t}Linux Server{/t}
- -{t}Network printer{/t}
-{t}Phone{/t}
-{t}Other network component{/t}
- -

- -   - -

- - diff --git a/plugins/admin/systems/class_ArpNewDevice.inc b/plugins/admin/systems/class_ArpNewDevice.inc deleted file mode 100644 index 79009908e..000000000 --- a/plugins/admin/systems/class_ArpNewDevice.inc +++ /dev/null @@ -1,74 +0,0 @@ -cn =""; - $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); - $this->acl = "#all#"; - $this->netConfigDNS->acl = $this->acl; - $this->netConfigDNS->force_dns(); - } - - function execute() - { - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - $this->netConfigDNS->cn= $this->cn; - $smarty->assign("netconfig", $this->netConfigDNS->execute()); - - /* Display sub dialog from network settings */ - $this->netConfigDNS->acl = $this->acl; - if($this->netConfigDNS->dialog){ - $this->dialog = TRUE; - return($this->netConfigDNS->execute()); - }else{ - $this->dialog = FALSE; - } - - return($smarty->fetch (get_template_path('ArpNewDevice.tpl', TRUE))); - } - - function check() - { - $message= plugin::check(); - $message= array_merge($message, $this->netConfigDNS->check()); - if(empty($this->cn)){ - $message[] = _("Please specify a valid dns name."); - } - return($message); - } - - function save_object() - { - if(isset($_POST['ArpNewDevice_posted'])){ - plugin::save_object(); - $this->netConfigDNS->save_object(); - } - } - - function save() - { - $this->netConfigDNS->acl = $this->acl; - plugin::save(); - $this->netConfigDNS->cn = $this->cn; - $this->netConfigDNS->save($this->dn); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->rmdir_recursive($this->dn); - show_ldap_error($ldap->get_error(),_("Could not remove arp-alert device after writing dns and dhcp configuration.")); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_SelectDeviceType.inc b/plugins/admin/systems/class_SelectDeviceType.inc deleted file mode 100644 index c17b8ef5f..000000000 --- a/plugins/admin/systems/class_SelectDeviceType.inc +++ /dev/null @@ -1,85 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes= array("ObjectGroup","SystemType"); - var $objectclasses= array("whatever"); - - var $ObjectGroups = array(); - var $SystemTypes = array(); - - var $ObjectGroup = ""; - var $SystemType = ""; - - function SelectDeviceType (&$config, $dn= NULL) - { - plugin::plugin ($config, $dn); - - /* Get object groups */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn")); - $this->ObjectGroups['none']=_("none"); - while($attrs = $ldap->fetch()){ - $this->ObjectGroups[$attrs['dn']]= $attrs['cn'][0]; - } - - $this->SystemTypes =array("workstation"=>_("Workstation"), "terminal"=>_("Terminal"), "server"=>_("Server")); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - $smarty->assign("ObjectGroups" ,$this->ObjectGroups); - $smarty->assign("ObjectGroupKeys" ,array_flip($this->ObjectGroups)); - $smarty->assign("SystemTypes" ,$this->SystemTypes); - $smarty->assign("SystemTypeKeys" ,array_flip($this->SystemTypes)); - - $smarty->assign("ObjectGroup",$this->ObjectGroup); - $smarty->assign("SystemType",$this->SystemType); - - $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - /* Save to LDAP */ - function save() - { - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_baseSelectDialog.inc b/plugins/admin/systems/class_baseSelectDialog.inc deleted file mode 100644 index 04275e0de..000000000 --- a/plugins/admin/systems/class_baseSelectDialog.inc +++ /dev/null @@ -1,197 +0,0 @@ -parent = $parent; - - $this->selectedBase = $config->current['BASE']; - $this->allowedBases = $onlyAllowThisBases; - - $this->SetTitle("Base"); - $this->SetSummary(_("Choose a base")); - $this->SetListHeader("
". - "  ". - "  ". - "  ". - "  ". - "
"); - - $this->SetInformation(_("Step in the prefered tree and click save to use the current subtree as base. Or click the image at the end of each entry.")); - - $this->EnableAplhabet (true); - $this->EnableCloseButton(true); - $this->EnableSaveButton (true); - - $this->SetSaveButtonString(_("Use")); - $this->SetCloseButtonString(_("Cancel")); - - $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>_("Base"))); - $this->AddHeader(array("string"=>_("Action"),"attach"=>"style='width:50px;border-right:0px;'")); - - /* Text ,Value ,Name ,Is selected */ -// $this->AddCheckBox("Doesnothing","servers","Doesnothing",true); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("base_selection_regex",_("Filter entries with this syntax"),"*" , true); - } - - function execute() - { - $this->setEntries(); - return($this->Draw()); - } - - function setEntries() - { - $this->ClearElementsList(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->selectedBase); - $ldap->ls("(&(objectClass=gosaDepartment) - (|(ou=".$this->base_selection_regex.") - (cn=".$this->base_selection_regex.") - (description=".$this->base_selection_regex.")))", - $this->selectedBase,array("ou","description","cn")); - - $link = "%s"; - - $base_back = preg_replace("/^[^,]+,/","",$this->selectedBase); - $base_back = convert_department_dn($base_back); - - /* Add departments, to be able to switch into them - */ - while($attrs = $ldap->fetch()){ - - $key = $attrs['dn'] ; - $val = $attrs['ou'][0]; - - if(count($this->allowedBases) != 0){ - if(!isset($this->allowedBases[$key])){ - continue; - break; - } - } - - /* Append description */ - if(isset($attrs['description'][0])){ - $val.=" [".$attrs['description'][0]."]"; - } - - /* Add missing entries ... */ - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - - /* check if this department contains sub-departments - Display different image in this case - */ - $non_empty=""; - $keys= str_replace("/","\/",$key); - foreach($this->config->departments as $keyd ){ - if(preg_match("/,".$keys."/",$keyd)){ - $non_empty="full"; - } - } - - /* Add to divlist */ - $field1 = array("string" => "department", - "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($link,base64_encode($key),$val), "attach" => "style=''"); - $field3 = array("string" => sprintf(" ",base64_encode($key)), - "attach" => "style='width:50px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field1,$field2,$field3)); - } - } - - function Save() - { - MultiSelectWindow :: Save(); - $this->BaseToUse = $this->selectedBase; - } - - function isSelected() - { - return($this->BaseToUse); - } - - function setCurrentBase($base) - { - $this->selectedBase = $base; - } - - function save_object() - { - /* Save current base */ - $old_base = $this->selectedBase; - - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - - if(isset($_GET['open_dep'])){ - $this->selectedBase = base64_decode($_GET['open_dep']); - } - - $s_action =""; - foreach($_POST as $key => $value){ - if(preg_match("/^dep_back.*/i",$key)){ - $s_action="back"; - }elseif(preg_match("/^dep_root.*/",$key)){ - $s_action="root"; - }elseif(preg_match("/^dep_home.*/i",$key)){ - $s_action="home"; - }elseif(preg_match("/^usebase_/",$key)){ - $tmp = preg_replace("/^usebase_/","",$key); - $tmp = preg_replace("/_.*$/","",$tmp); - $tmp = base64_decode($tmp); - $this->BaseToUse = $tmp; - } - } - - $ui= get_userinfo(); - /* Homebutton is posted */ - if($s_action=="home"){ - $this->selectedBase=(preg_replace("/^[^,]+,/","",$ui->dn)); - $this->selectedBase=(preg_replace("/^[^,]+,/","",$this->selectedBase)); - } - - /* back to the roots ^^ */ - if($s_action=="root"){ - $this->selectedBase=($this->config->current['BASE']); - } - - /* If Backbutton is Posted */ - if($s_action=="back"){ - $base_back = preg_replace("/^[^,]+,/","",$this->selectedBase); - $base_back = convert_department_dn($base_back); - - if(isset($this->config->departments[trim($base_back)])){ - $this->selectedBase= $this->config->departments[trim($base_back)]; - }else{ - $this->selectedBase= $this->config->departments["/"]; - } - } - - /* Restore old base, if selected base is not allowed */ - if(count($this->allowedBases) && !isset($this->allowedBases[$this->selectedBase])){ - $this->selectedBase = $old_base; - } - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_componentGeneric.inc b/plugins/admin/systems/class_componentGeneric.inc deleted file mode 100644 index 8a65bdd8a..000000000 --- a/plugins/admin/systems/class_componentGeneric.inc +++ /dev/null @@ -1,331 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $interfaces= array(); - var $ignore_account= TRUE; - - /* Needed values and lists */ - var $base= ""; - var $cn= ""; - var $description= ""; - var $orig_dn= ""; - - /* attribute list for save action */ - var $attributes= array("cn", "description"); - var $objectclasses= array("top", "device", "ipHost", "ieee802Device"); - var $netConfigDNS; - var $view_logged = FALSE; - - function componentGeneric (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - $this->cn= ""; - } else { - $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); - } - $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, true); - /* Save dn for later references */ - $this->orig_dn= $this->dn; - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","component/".get_class($this),$this->dn); - } - - /* Do we represent a valid phone? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no network features.").""; - return($display); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $smarty->assign("bases", $this->config->idepartments); - - /* Set acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $smarty->assign("bases", $this->get_allowed_bases()); - - /* Assign attributes */ - foreach ($this->attributes as $attr){ - $smarty->assign("$attr", $this->$attr); - } - $smarty->assign("base_select", $this->base); - - /* Show main page */ - $str = $this->netConfigDNS->execute(); - if(is_object($this->netConfigDNS->dialog)){ - return($str); - } - $smarty->assign("netconfig", $str); - return($smarty->fetch (get_template_path('component.tpl', TRUE))); - } - - function set_acl_base($base) - { - plugin::set_acl_base($base); - $this->netConfigDNS->set_acl_base($base); - } - - function set_acl_category($cat) - { - plugin::set_acl_category($cat); - $this->netConfigDNS->set_acl_category($cat); - } - - function remove_from_parent() - { - $ldap= $this->config->get_ldap_link(); - $this->netConfigDNS->remove_from_parent(); - $ldap->rmdir($this->dn); - - new log("remove","component/".get_class($this),$this->dn,$this->attributes,$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system component/generic with dn '%s' failed."),$this->dn)); - $this->handle_post_events(array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - } - - - /* Save data to object */ - function save_object() - { - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - $this->netConfigDNS->save_object(); - - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - $message= array_merge($message,$this->netConfigDNS->check()); - - $this->dn= "cn=".$this->cn.",ou=netdevices,ou=systems,".$this->base; - - if ($this->cn == "" ){ - $message[]= _("The required field 'Component name' is not set."); - } - - /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn)){ - $message[] = _("Please specify a valid name for this object."); - } - - /* To check for valid ip*/ - if($this->netConfigDNS->ipHostNumber == ""){ - $message[]= _("The required field IP address is empty."); - } else { - if (!is_ip($this->netConfigDNS->ipHostNumber)){ - $message[]= _("The field IP address contains an invalid address."); - } - } - - if ($this->orig_dn != $this->dn){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); - $ldap->search ("(cn=".$this->cn.")", array("cn")); - if ($ldap->count() != 0){ - while ($attrs= $ldap->fetch()){ - if(preg_match("/cn=dhcp,/",$attrs['dn'])){ - continue; - } - if ($attrs['dn'] != $this->orig_dn){ - $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); - break; - } - } - } - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Remove all empty values */ - if ($this->orig_dn == 'new'){ - $attrs= array(); - foreach ($this->attrs as $key => $val){ - if (is_array($val) && count($val) == 0){ - continue; - } - $attrs[$key]= $val; - } - $this->attrs= $attrs; - } - - /* If this is a new Object IP & Mac aren't set. - IP & Mac are msut attributes, so we set this values by here. */ - if($this->orig_dn == 'new'){ - $this->attrs['ipHostNumber'] = $this->netConfigDNS->ipHostNumber; - $this->attrs['macAddress'] = $this->netConfigDNS->macAddress; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - if ($this->orig_dn == 'new'){ - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","component/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - - } else { - if ($this->orig_dn != $this->dn){ - $this->move($this->orig_dn, $this->dn); - } - - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","component/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } - - $this->netConfigDNS->cn = $this->cn; - $this->netConfigDNS->save(); - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system component/generic with dn '%s' failed."),$this->dn)); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Component generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => array("component" => array("description" => _("Network device"), - "objectClass" => array("device", "ipHost", "ieee802Device"))), - "plProvidedAcls"=> array( - "cn" => _("Name"), - "base" => _("Base"), - "description" => _("Description")) - )); - } - - /* Display generic part for server copy & paste */ - function getCopyDialog() - { - $vars = array("cn"); - $smarty = get_smarty(); - $smarty->assign("cn" ,$this->cn); - $smarty->assign("object","component"); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - if(isset($source['macAddress'][0])){ - $this->netConfigDNS->macAddress = $source['macAddress'][0]; - } - if(isset($source['ipHostNumber'][0])){ - $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_divListRepositories.inc b/plugins/admin/systems/class_divListRepositories.inc deleted file mode 100644 index 6e43dc18c..000000000 --- a/plugins/admin/systems/class_divListRepositories.inc +++ /dev/null @@ -1,84 +0,0 @@ -AddCheckBox */ - var $parent ; - var $ui ; - - var $regex ="*"; - - function divListRepository ($config,$parent) - { - MultiSelectWindow::MultiSelectWindow($config,"Repository", "server"); - - $this->parent = $parent; - $this->ui = get_userinfo(); - - $this->SetTitle("repositories"); - $this->SetSummary(_("List of configured repositories.")); - $this->SetInformation(_("This menu allows you to create, delete and edit repository settings.")); - $this->EnableCloseButton(FALSE); - $this->EnableSaveButton(FALSE); - $this->AddHeader(array("string"=>_("Release"),"attach"=>"style='width:80px;'")); - $this->AddHeader(array("string"=>_("Sections"))); - $this->AddHeader(array("string"=>_("Options"),"attach"=>"style='border-right:0px;width:55px;'")); - $this->AddRegex("regex",_("Regular expression for matching object names"),"*",TRUE); - $this->EnableAplhabet(TRUE); - } - - function GenHeader() - { - if($this->parent->acl_is_createable()){ - $this->SetListHeader(""); - } - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - $link = "%s"; - $edit = " "; - - /* Hide delete icon, if delete is not allowed */ - if($this->parent->acl_is_removeable()){ - $delete = ""; - }else{ - $delete = " "; - } - - foreach($list as $name => $reps){ - - $str = " "; - if(preg_match("/".str_replace("*",".*",$this->regex)."/",$reps['Release'])){ - foreach($reps['Sections'] as $sec){ - $str.=$sec." "; - } - $this->AddElement(array( - array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"), - array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)), - array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text- align:right;'") - )); - } - } - - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_divListSystem.inc b/plugins/admin/systems/class_divListSystem.inc deleted file mode 100644 index 61871b7a9..000000000 --- a/plugins/admin/systems/class_divListSystem.inc +++ /dev/null @@ -1,468 +0,0 @@ -AddCheckBox */ - var $ShowServers; - var $ShowTerminals; - var $ShowWorkstations; - var $ShowWinWorkstations; - var $ShowPrinters; - var $ShowDevices; - var $ShowPhones; - - /* Subsearch checkbox */ - var $SubSearch; - - var $parent ; - var $ui ; - - function divListSystem (&$config,$parent) - { - MultiSelectWindow::MultiSelectWindow($config, "System", array("server", - "workstation", - "terminal", - "phone", - "incoming", - "printer")); - - $this->parent = $parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of systems")); - $this->SetSummary(_("List of systems")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to add, remove and change the properties of specific systems. You can only add systems which have already been started once.")); - - $this->EnableAplhabet (true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 110; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>_("System / Department"))); - $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'")); - - /* Text ,Value ,Name ,Is selected */ - $this->AddCheckBox("ShowServers", _("Select to see servers"), _("Show servers"), true); - $this->AddCheckBox("ShowTerminals", _("Select to see Linux terminals"), _("Show terminals") , true); - $this->AddCheckBox("ShowWorkstations", _("Select to see Linux workstations"), _("Show workstations"), true); - $this->AddCheckBox("ShowWinWorkstations", _("Select to see MicroSoft Windows based workstations"), _("Show windows based workstations"),true); - $this->AddCheckBox("ShowPrinters", _("Select to see network printers"), _("Show network printers") ,true); - $this->AddCheckBox("ShowPhones", _("Select to see VOIP phones"), _("Show phones") , true); - $this->AddCheckBox("ShowDevices", _("Select to see network devices"), _("Show network devices"), true); - - /* Add SubSearch checkbox */ - $this->AddCheckBox(SEPERATOR); - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Display systems matching"),"*" , true); - $this->AddRegex ("UserRegex", _("Display systems of user"), "*" , false, "images/search_user.png"); - } - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $department = $departments = array(); - foreach($this->module as $module){ - $d = $ui->get_module_departments($module); - foreach($d as $department){ - $departments[$department] = $department; - } - } - - /* Load possible departments */ - $ui= get_userinfo(); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $departments)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* If there is at least one c (Create) and one w (Write) acl in this combination - display the snapshot paste icon. BUT check the correct acls in the management plugin */ - $all_module_acls = ""; - foreach($this->module as $module){ - $all_module_acls .= $ui->has_complete_category_acls($this->selectedBase,$module); - } - - /* Must we add an additional seperator */ - $add_sep = false; - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* Add base selection */ - $listhead .= _("Base")."  ". - "  "; - - /* Handle create icons */ - $s = ".|"._("Actions")."|\n"; - $s.= "..|". - " "._("Create")."|\n"; - if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"terminal/termgeneric"))){ - $s.= "...|". - " "._("Terminal")."|"."newsystem_terminal|\n"; - } - if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"workstation/workgeneric"))){ - $s.= "...|". - " "._("Workstation")."|"."newsystem_workstation|\n"; - } - if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"workstation/workgeneric"))){ - $s.= "...|". - " "._("Server")."|"."newsystem_server|\n"; - } - if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"phone/phoneGeneric"))){ - $s.= "...|". - " "._("Phone")."|"."newsystem_phone|\n"; - } - if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"printer/printgeneric"))){ - $s.= "...|". - " "._("Printer")."|"."newsystem_printer|\n"; - } - if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"component/componentGeneric"))){ - $s.= "...|". - " "._("Component")."|"."newsystem_component|\n"; - } - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Get copy & paste icon */ - $Copy_Paste =""; - if(preg_match("/(c.*w|w.*c)/",$all_module_acls) && $this->parent->CopyPasteHandler){ - $s .= "..|---|\n"; - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$all_module_acls)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($terminals) - { - $img1 = "C"; - $img2 = "L"; - $img3 = "L"; - $img4 = "M"; - $img5 = "I"; - $img6 = "F"; - $img7 = "K"; - $img8 = "A"; - $img9 = "F"; - $img10 = "L"; - - $empty =""; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 110; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - // User and Template Images - $editlink = "%s"; - - /* ACL mapping */ - $ui = get_userinfo(); - $tabs = array( - "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"), - "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"), - "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"), - "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"), - "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"), - "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"), - "incoming" => array("CLASS"=>"", "TABCLASS" =>"", "ACL"=> "incoming/systems"), - "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric")); - - - $cnts = array("component" => 0 , "terminal" => 0 , "workstation" => 0 , - "printer" => 0 , "phone" => 0 , "server" => 0, - "NewDevice" => 0, "winstation"=> 0); - - // Test Every Entry and generate divlist Array - foreach($terminals as $key => $val){ - - /* Get system type, it is used to fetch the acls for the current object. - "winstation" acls are stored as 2winworkstation", so we have to map this here */ - $type = $this->parent->get_system_type($val); - if($type == "winstation") { - $acl_type = "winworkstation"; - }else{ - $acl_type = $type; - } - - /* Map NewDevice acls to workstation acls */ - if($type == "NewDevice" || $type == "ArpNewDevice"){ - $type = "incoming"; - $acl_type = "incoming"; - } - - /* Get complete category acls */ - $acl_all = $ui->has_complete_category_acls($val['dn'],$acl_type) ; - - /* Get specific generic acls */ - $acl = $ui->get_permissions($val['dn'],$tabs[$type]['ACL']); - - $action =""; - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $action.= " "; - $action.= " "; - } - $action.= ""; - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $action.= $this->GetSnapShotActions($val['dn']); - }else{ - $action.= $empty." ".$empty." "; - } - - - if(preg_match("/d/",$acl)){ - $action.= ""; - }else{ - $action.= $empty; - } - - /* Generate picture list, which is currently disabled */ - if(in_array("goCupsServer" ,$val['objectClass'])) $cups = $img1; else $cups =$empty; - if(in_array("goLogDBServer" ,$val['objectClass'])) $logdb = $img2; else $logdb =$empty; - if(in_array("goSyslogServer" ,$val['objectClass'])) $syslog = $img3; else $syslog=$empty; - if(in_array("goImapServer" ,$val['objectClass'])) $imap = $img4; else $imap =$empty; - if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba = $img5; else $samba =$empty; - if(in_array("goShareServer" ,$val['objectClass'])) $nfs = $img6; else $nfs =$empty; - if(in_array("goKrbServer" ,$val['objectClass'])) $krb = $img7; else $krb =$empty; - if(in_array("goFonServer" ,$val['objectClass'])) $fon = $img8; else $fon =$empty; - if(in_array("goFaxServer" ,$val['objectClass'])) $fax = $img9; else $fax =$empty; - if(in_array("goLdapServer" ,$val['objectClass'])) $ldap = $img10; else $ldap =$empty; - - $pics = $cups.$logdb.$syslog.$imap.$samba.$nfs.$krb.$fon.$fax.$ldap; - $pics = ""; // Pictures currently hidden - - $val['cn'][0]= preg_replace('/\$$/', '', $val['cn'][0]); - - // Generate Array to Add - $dsc= ""; - if (isset($val['description'][0])){ - $dsc= " [".$val['description'][0]."]"; - } - if((isset($val['is_new']))&&(!empty($val['is_new']))){ - $display= $val["cn"][0]." ".$val['is_new'].$dsc; - }else{ - $display= $val["cn"][0].$dsc; - } - - - /* Check if this is a terminal/workstation && if we are allowed to change the gotoRootPasswd */ - $pwd_acl =""; - if(in_array("gotoWorkstation",$val['objectClass'])){ - $pwd_acl = $ui->get_permissions($val['dn'],"workstation/workgeneric","gotoRootPasswd"); - } - if(in_array("gotoTerminal",$val['objectClass'])){ - $pwd_acl = $ui->get_permissions($val['dn'],"terminal/termgeneric","gotoRootPasswd"); - } - if(preg_match("/w/",$pwd_acl)){ - $action2 = ""; - }else{ - $action2 = $empty; - } - - - if(in_array("gotoWorkstation",$val['objectClass'])){ - $action2= " ".$action2; - }else{ - $action2= $empty.$action2; - } - - if(isset($val['message'])){ - $display.= " (".$val['message'].")"; - } - - $img = $this->parent->convert_list($val); - - /* Cutted objects should be displayed in light grey */ - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - $type = $this->parent->get_system_type($val); - if($type == "ArpNewDevice"){ - $type = "NewDevice"; - } - $cnts[$type] ++; - - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - - $field1 = array("string" => sprintf($img['img'],$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); - $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action2.$action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement( array($field0,$field1,$field2,$field3)); - } - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - - $num_ser_str = _("Number of listed servers"); - $num_ws_str = _("Number of listed workstations"); - $num_ter_str = _("Number of listed terminals"); - $num_pho_str = _("Number of listed phones"); - $num_prt_str = _("Number of listed printers"); - $num_com_str = _("Number of listed network components"); - $num_new_str = _("Number of listed new devices"); - $num_wws_str = _("Number of listed windows workstations"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_ser_str." ".$cnts['server']."    "; - $str.= "".$num_ws_str." ".$cnts['workstation']."    "; - $str.= "".$num_ter_str." ".$cnts['terminal']."    "; - $str.= "".$num_pho_str." ".$cnts['phone']."    "; - $str.= "".$num_prt_str." ".$cnts['printer']."    "; - $str.= "".$num_com_str." ".$cnts['component']."    "; - $str.= "".$num_new_str." ".$cnts['NewDevice']."    "; - $str.= "".$num_wws_str." ".$cnts['winstation']."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - } - - - function Save() - { - MultiSelectWindow :: Save(); - } - - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); - - - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_divListSystemService.inc b/plugins/admin/systems/class_divListSystemService.inc deleted file mode 100644 index ca31601ba..000000000 --- a/plugins/admin/systems/class_divListSystemService.inc +++ /dev/null @@ -1,152 +0,0 @@ -AddCheckBox */ - var $parent ; - var $ui ; - - function divListSystemService ($config,$parent) - { - MultiSelectWindow::MultiSelectWindow($config,"SystemService", "server"); - - $this->parent = $parent; - $this->ui = get_userinfo(); - $this->EnableJSLeaveMsg(TRUE); - - /* Set list strings */ - $this->SetTitle(_("Installed services")); - $this->SetSummary(_("Installed services")); - - /* Result page will look like a headpage */ - $this->SetInformation(_("This menu allows you to add, remove and configure the properties of a specific service.")); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* set Page header */ - $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>_("Service name"))); - $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:100px;border-right:0px;'")); - $this->HideFilterPart(); - } - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $listhead = "
". - "  ". - "  ". - "  ". - "  ". - "  ". - "
"; - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - $tmp = array(); - foreach($list as $name => $entry){ - $tmp[$name] = $entry['Message']; - } - - natcasesort($tmp); - $tmp2 = array(); - foreach($tmp as $name => $value){ - $tmp2[$name] = $list[$name]; - } - - $ui = get_userinfo(); - - foreach($tmp2 as $name => $entry){ - - switch($entry['Status']){ - case '' : $str =" ";break; - case SERVICE_STOPPED : $str =""; break; - case SERVICE_STARTED : $str =""; break; - case SERVICE_RESTARTED : $str ="R"; break; - default: $str= "".$entry["; - } - - /* Get acls */ - $acl = $ui->get_permissions($this->parent->dn,"server/".$name); - if(preg_match("/w/i",$acl) && !preg_match("/r/i",$acl)){ - continue; - } - - $WasAccount = $this->parent->plugins[$name] -> initially_was_account; - - $plug = $_GET['plug']; - $link = "".$entry['Message'].""; - - $field1 = array("string" => $str ,"attach" => "style='width:20px;'"); - $field2 = array("string" => $link); - - $actions =""; - if($entry['AllowStart'] && $WasAccount){ - $actions .= " "; - }else{ - $actions .= " "; - } - if($entry['AllowStart'] && $WasAccount){ - $actions .= " "; - }else{ - $actions .= " "; - } - if($entry['AllowStart'] && $WasAccount){ - $actions .= " "; - }else{ - $actions .= " "; - } - - /* Check if edit is enabled and allowed for current service */ - if($entry['AllowEdit'] && preg_match("/(r|w)/i",$acl)){ - $actions .= " "; - }else{ - $actions .= " "; - } - - /* Check if remove is enabled and allowed for current service */ - if($entry['AllowRemove'] && preg_match("/d/i",$acl)){ - $actions .= " "; - }else{ - $actions .= " "; - } - - $field3 = array("string" => $actions ,"attach" => "style='width:100px;border-right:0px;'"); - $this->AddElement(array($field1,$field2,$field3)); - } - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_phoneGeneric.inc b/plugins/admin/systems/class_phoneGeneric.inc deleted file mode 100644 index f169c0ec7..000000000 --- a/plugins/admin/systems/class_phoneGeneric.inc +++ /dev/null @@ -1,521 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $interfaces= array(); - var $ignore_account= TRUE; - - /* Needed values and lists */ - var $base = ""; - var $cn = ""; - var $description = ""; - var $orig_dn = ""; - var $goFonType = ""; - var $goFonDmtfMode = ""; - var $goFonHost = ""; - var $goFonDefaultIP = "dynamic"; - var $goFonQualify = ""; - var $goFonAuth = ""; - var $goFonSecret = ""; - var $goFonInkeys = ""; - var $goFonPermit = array(); - var $goFonDeny = array(); - var $goFonOutkey = ""; - var $goFonTrunk = ""; - var $goFonAccountCode = ""; - var $goFonMSN = ""; - var $selected_categorie = 0; - var $netConfigDNS; - var $view_logged = FALSE; - - /* attribute list for save action */ - var $attributes= array("cn", "description", - "goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP", - "goFonQualify","goFonAuth","goFonSecret","goFonInkeys","goFonOutkey", - "goFonTrunk","goFonAccountCode","goFonMSN","selected_categorie","goFonPermit","goFonDeny" - ); - - /* this array defines which attributes are schown / saved for the different type of phones */ - var $usedattrs = array( "0"=>array("cn", "description", - "goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP", - "goFonQualify"), - "1"=>array("cn", "description", - "goFonType","goFonHost","goFonDefaultIP", - "goFonQualify","goFonAuth","goFonSecret","goFonInkeys","goFonOutkey", - "goFonTrunk","goFonAccountCode","selected_categorie","goFonPermit","goFonDeny"), - "2"=>array("cn", "description", "goFonMSN")); - - - var $objectclasses= array("top", "goFonHardware"); - - function phoneGeneric (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, true); - - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - $this->cn= ""; - } else { - $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); - } - - if($this->goFonMSN != ""){ - $this->selected_categorie = 2; - }elseif($this->goFonAccountCode != ""){ - $this->selected_categorie = 1 ; - - if(isset($this->attrs['goFonPermit']['count'])){ - unset ($this->attrs['goFonPermit']['count']); - $this->goFonPermit=$this->attrs['goFonPermit']; - } - - if(isset($this->attrs['goFonDeny']['count'])){ - unset ($this->attrs['goFonDeny']['count']) ; - $this->goFonDeny=$this->attrs['goFonDeny']; - } - - } else { - $this->selected_categorie = 0; - } - - if($this->goFonDefaultIP!="dynamic"){ - $this->goFonDefaultIP = "network"; - } - - /* Save dn for later references */ - $this->orig_dn= $this->dn; - } - - function set_acl_base($base) - { - plugin::set_acl_base($base); - $this->netConfigDNS->set_acl_base($base); - } - - function set_acl_category($cat) - { - plugin::set_acl_category($cat); - $this->netConfigDNS->set_acl_category($cat); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","phone/".get_class($this),$this->dn); - } - - /* Do we represent a valid phone? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no phone features.").""; - return($display); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* handle Permit Add*/ - if(isset($_POST['goFonPermitAdd']) && $this->acl_is_writeable("goFonPermit")){ - if(isset($_POST['goFonPermitNew'])){ - if(is_string($this->goFonPermit)){ - $this->goFonPermit=array(); - } - $new = $_POST['goFonPermitNew']; - if(strlen($new)> 1) { - $this->goFonPermit[]= $new; - } - } - } - - /* handle Deny Add*/ - if(isset($_POST['goFonDenyAdd']) && $this->acl_is_writeable("goFonDeny")){ - if(isset($_POST['goFonDenyNew'])){ - if(is_string($this->goFonDeny)){ - $this->goFonDeny=array(); - } - $new = $_POST['goFonDenyNew']; - if(strlen($new)> 1) { - $this->goFonDeny[]= $new; - } - } - } - - /* Handle Permit Deletion*/ - if(isset($_POST['goFonPermitDel']) && $this->acl_is_writeable("goFonPermit")){ - if(isset($_POST['goFonPermitS'])){ - if(is_string($this->goFonPermit)){ - $this->goFonPermit=array(); - } - $new = $_POST['goFonPermitS']; - $tmp = array_flip($this->goFonPermit); - unset($tmp[$new]); - $this->goFonPermit=array(); - foreach(array_flip($tmp) as $tm){ - $this->goFonPermit[]=$tm; - } - } - } - - - /* Handle Permit Deletion*/ - if(isset($_POST['goFonDenyDel']) && $this->acl_is_writeable("goFonDeny")){ - if(isset($_POST['goFonDenyS'])){ - if(is_string($this->goFonDeny)){ - $this->goFonDeny=array(); - } - $new = $_POST['goFonDenyS']; - $tmp = array_flip($this->goFonDeny); - unset($tmp[$new]); - $this->goFonDeny=array(); - foreach(array_flip($tmp) as $tm){ - $this->goFonDeny[]=$tm; - } - } - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - - $smarty->assign("bases", $this->get_allowed_bases()); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $smarty->assign("staticAddress","*");// $this->config->idepartments); - - /* Create Arrays for samrty select boxes */ - $smarty->assign("categories", array("SIP","IAX","CAPI")); - $smarty->assign("goFonTypes", array("peer" =>"peer" ,"user" =>"user" ,"friend" =>"friend")); - $smarty->assign("goFonDmtfModes", array("inband" =>"inband" ,"rfc2833"=>"rfc2833" ,"info" =>"info")); - $smarty->assign("goFonAuths", array("plaintext" =>"plaintext" ,"md5" =>"md5" /*,"rsa" =>"rsa"*/)); - $smarty->assign("goFonTrunks", array("yes" =>_("yes") ,"no" => _("no"))); - - /* deativate all fields that are not used by the specified type */ - foreach($this->attributes as $att){ - if((!in_array($att,$this->usedattrs[$this->selected_categorie]))){ - $smarty->assign($att."USED", "disabled" ); - $smarty->assign($att, ""); - }else{ - $smarty->assign($att."USED", "" ); - $smarty->assign($att, $this->$att); - } - } - - $smarty->assign("selected_categorie",$this->selected_categorie); - - /* Assign attributes */ - $smarty->assign("base_select", $this->base); - $smarty->assign("goFonDefaultIPs",array("dynamic"=>_("dynamic"),"network"=>_("Networksettings"))); - - /* Show main page */ - $str = $this->netConfigDNS->execute(); - if(is_object($this->netConfigDNS->dialog)){ - return($str); - } - $smarty->assign("netconfig", $str); - $smarty->assign("phonesettings", dirname(__FILE__)."/phonesettings.tpl"); - return($smarty->fetch (get_template_path('phone.tpl', TRUE))); - } - - function remove_from_parent() - { - if($this->acl_is_removeable()){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - $ldap->search ("(&(objectClass=goFonAccount)(goFonHardware=".$this->cn."))", array("uid","cn")); - while ($attr = $ldap->fetch()){ - print_red(sprintf(_("Can't delete because there are users which are depending on this phone. One of them is user '%s'."), - ($attr['uid'][0]." - ".$attr['cn'][0]))); - return; - } - - $this->netConfigDNS->remove_from_parent(); - $ldap->rmdir($this->dn); - - new log("remove","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system phone/generic with dn '%s' failed."),$this->dn)); - $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - } - } - - - /* Save data to object */ - function save_object() - { - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - $this->netConfigDNS->save_object(); - - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - $message= array_merge($message, $this->netConfigDNS->check()); - - $this->dn= "cn=".$this->cn.",ou=phones,ou=systems,".$this->base; - - /* To check for valid ip*/ - if($this->netConfigDNS->ipHostNumber == ""){ - $message[]= _("The required field IP address is empty."); - } else { - if (!is_ip($this->netConfigDNS->ipHostNumber)){ - $message[]= _("The field IP address contains an invalid address."); - } - } - - /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn) ){ - $message[] = _("Please specify a valid name for this object."); - } - - if ($this->cn == ""){ - $message[]= _("The required field 'Phone name' is not set."); - } - if ($this->cn == "0"){ - $message[]= _("The 'Phone name' '0' is reserved and cannot be used."); - } - - if ($this->orig_dn != $this->dn){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); - $ldap->search ("(cn=".$this->cn.")", array("cn")); - if ($ldap->count() != 0){ - while ($attrs= $ldap->fetch()){ - - if(preg_match("/cn=dhcp,/",$attrs['dn'])){ - continue; - } - - if ($attrs['dn'] != $this->orig_dn){ - $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); - break; - } - } - } - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - - /* only to define which attrs to save*/ - $mode = $this->selected_categorie; - - /* Remove all unwanted attrs */ - foreach($this->attributes as $att){ - - /* Check all attributes, if they are needed for this type of phone */ - if(!in_array($att,$this->usedattrs[$mode])){ - $this->attrs[$att] = array(); - } - } - - /* unset the categorie*/ - unset($this->attrs['selected_categorie']); - - /* Remove all empty values */ - if ($this->orig_dn == 'new'){ - $attrs= array(); - foreach ($this->attrs as $key => $val){ - if (is_array($val) && count($val) == 0){ - continue; - } - $attrs[$key]= $val; - } - $this->attrs= $attrs; - } - - if($this->goFonDefaultIP!="dynamic"){ - $this->attrs['goFonDefaultIP'] = $this->netConfigDNS->ipHostNumber; - } - - $this->attrs = $this->netConfigDNS->getVarsForSaving($this->attrs); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - if ($this->orig_dn == 'new'){ - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } else { - if ($this->orig_dn != $this->dn){ - $this->move($this->orig_dn, $this->dn); - } - - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","phone/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - // $user_phone_reload - $ldap->cd ($this->config->current['BASE']); - $user_phone_assignment = $ldap->fetch($ldap->search("(&(objectClass=goFonAccount)(goFonHardware=".$this->cn."))",array("uid"))); - if($user_phone_assignment){ - $usertab= new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $user_phone_assignment['dn']); - $usertab->by_object['phoneAccount']->is_modified = true; - $usertab->save(); - unset($usertab); - } - $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } - $this->netConfigDNS->cn = $this->cn; - $this->netConfigDNS->save(); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system phone/generic with dn '%s' failed."),$this->dn)); - } - - - /* Display generic part for server copy & paste */ - function getCopyDialog() - { - $vars = array("cn"); - $smarty = get_smarty(); - $smarty->assign("cn" ,$this->cn); - $smarty->assign("object","phone"); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - if(isset($source['macAddress'][0])){ - $this->netConfigDNS->macAddress = $source['macAddress'][0]; - } - if(isset($source['ipHostNumber'][0])){ - $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; - } - - $source_o = new phoneGeneric($this->config, $source['dn']); - $this->selected_categorie = $source_o->selected_categorie; - } - - - /* Return plugin informations for acl handling - #FIXME FAIscript seams to ununsed within this class... */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Phone generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("phone" => array("description" => _("Phone hardware"), - "objectClass" => "goFonHardware")), - "plProvidedAcls"=> array( - "cn" => _("Name"), - "base" => _("Base"), - "description" => _("Description"), - "goFonType" => _("SIP Mode"), - "goFonDmtfMode" => _("SIP DTMF mode"), - "goFonDefaultIP" => _("SIP Default ip"), - "goFonQualify" => _("SIP Qualify"), - "goFonAuth" => _("IAX authentication type"), - "goFonSecret" => _("IAX secret"), - "goFonAccountCode" => _("IAX account code"), - "goFonTrunk" => _("IAX trunk lines"), - "goFonPermit" => _("IAX permit settings"), - "goFonDeny" => _("IAX deny settings"), - "goFonMSN" => _("CAPI MSN"), - "categorie" => _("Hardware type")) - )); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc deleted file mode 100644 index 54092c670..000000000 --- a/plugins/admin/systems/class_printGeneric.inc +++ /dev/null @@ -1,1048 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $interfaces = array(); - var $ignore_account = FALSE; - - /* Needed values and lists */ - var $base = ""; - var $cn = ""; - var $l = ""; - var $description = ""; - var $labeledURI = ""; - var $gotoPrinterPPD = ""; - var $initial_PPD = ""; - var $orig_dn = ""; - - var $UserMember =""; - var $UserMembers =array(); - var $UserMemberKeys =array(); - - var $AdminMember =""; - var $AdminMembers =array(); - var $AdminMemberKeys =array(); - - var $PPDdialogToSave = NULL; - var $BelongsTo = "unknown"; // Specifies if this is a standalone printer, or belongs to a terminal / WS - - var $member =array(); - var $strings = ""; - var $netConfigDNS; - var $baseSelection = false; - var $macAddress = ""; - - var $gotoUserAdminPrinter; - var $gotoGroupAdminPrinter ; - var $gotoGroupPrinter; - var $gotoUserPrinter ; - - /* attribute list for save action */ - var $attributes = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress", - "gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter","gotoGroupPrinter"); - var $objectclasses = array("top", "gotoPrinter"); - var $view_logged = FALSE; - var $parent; - - function printgeneric (&$config, $dn,$parent_init,$parent) - { - $this->config = &$config; - $this->dn = $dn; - - /* If parent was posted(the tabs object) we can detect the printer type. */ - if($parent){ - $this->parent = $parent; - $this->getTypeOfPrinter(); - }else{ - $this->BelongsTo = "unknown"; - return; - } - - /* Update dn, to ensure storing as printer instead of WS / terminal */ - if(preg_match("/Terminal/i",$this->BelongsTo) || preg_match("/TerminalTemplate/i",$this->BelongsTo)){ - $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); - } - - if(preg_match("/Workstation/i",$this->BelongsTo) || preg_match("/WorkstationTemplate/i",$this->BelongsTo)){ - $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); - } - - $this->orig_dn = $this->dn; - - /* Get printer settings, possibly dn has changed */ - plugin::plugin ($config, $this->dn); - - /* Get is_account initially_was_account status */ - $this->getTypeOfPrinter(true); - - /* set orig dn to new if object is new */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('dn')); - if(!$ldap->count()){ - $this->orig_dn = "new"; - } - - /* create dns object */ - $this->netConfigDNS = new termDNS($this->config, $this,$this->objectclasses); - - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - $this->cn= ""; - } else { - - /* Set base and check if the extracted base exists */ - if(preg_match("/ou=incoming,/",$this->dn)){ - $this->base= preg_replace("/ou=incoming,/","",dn2base($this->dn)); - }else{ - $this->base= preg_replace("/ou=printers,ou=systems,/","",dn2base($this->dn)); - } - - if(!isset($this->config->idepartments[$this->base])){ - print_red(_("Can't extract a valid base out of object dn, setting base to '%s'."),$_SESSION['CurrentMainBase']); - $this->base = $_SESSION['CurrentMainBase']; - } - } - - /* Extract selected ppd */ - if(isset($this->gotoPrinterPPD)){ - $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD); - } - - $this->initial_PPD = $this->gotoPrinterPPD; - - /* Prepare different member types */ - foreach(array("AddUser" =>"gotoUserPrinter", - "AddGroup" =>"gotoGroupPrinter", - "AddAdminUser" =>"gotoUserAdminPrinter", - "AddAdminGroup" =>"gotoGroupAdminPrinter") as $type => $attr){ - - /* $this->members contains all members */ - $this->member[$type]=array(); - - if (isset($this->attrs[$attr]['count'])) { - unset($this->attrs[$attr]['count']); - } - - if(isset($this->attrs[$attr])){ - foreach($this->attrs[$attr] as $mem){ - if(preg_match("/Group/",$type)){ - $ldap->search("(&(objectClass=posixGroup)(cn=".$mem."))",array("cn","description")); - if($ldap->count()){ - $entry = $ldap->fetch(); - $this->member[$type][$entry['cn'][0]]=$entry; - } - }else{ - $ldap->search("(&(objectClass=person)(objectClass=inetOrgPerson)(uid=".$mem."))",array("cn","uid")); - if($ldap->count()){ - $entry = $ldap->fetch(); - $this->member[$type][$entry['uid'][0]]=$entry; - } - } - } - } - } - } - - function set_acl_base($base) - { - plugin::set_acl_base($base); - if(is_object($this->netConfigDNS)){ - $this->netConfigDNS->set_acl_base($base); - } - } - - function set_acl_category($cat) - { - plugin::set_acl_category($cat); - if(is_object($this->netConfigDNS)){ - $this->netConfigDNS->set_acl_category($cat); - } - } - - /* Detect type of printer. - * Printer can be stand alone, belong to a workstation or belong to a terminal. - * We can detect the type printer type when comparing the tabs objects - */ - function getTypeOfPrinter($UpdateAccountStatus = false) - { - /* Disable account as default - */ - $this->is_account = $this->initially_was_account = false; - - /* Detect type of printer via parent tabs. - */ - - $class = get_class($this->parent); - if(isset($this->parent->by_object['workgeneric'])){ - - /* Exclude templates - */ - $this->cn = $this->parent->by_object['workgeneric']->cn; - if($this->parent->by_object['workgeneric']->cn == "wdefault"){ - $this->BelongsTo = "WorkstationTemplate"; - }else{ - $this->BelongsTo = "Workstation"; - } - }elseif(isset($this->parent->by_object['termgeneric'])){ - - /* Exclude templates - */ - $this->cn = $this->parent->by_object['termgeneric']->cn; - if($this->parent->by_object['termgeneric']->cn == "default"){ - $this->BelongsTo = "TerminalTemplate"; - }else{ - $this->BelongsTo = "Terminal"; - } - }elseif(isset($this->parent->by_name['printgeneric'])){ - $this->BelongsTo = "Printer"; - } - - if($UpdateAccountStatus){ - - /* Set is_account / was account - */ - if($this->dn == "new"){ - $this->initially_was_account = false; - } - - /* If is printer it must be a true account. - */ - if(preg_match("/printer/i",$this->BelongsTo)){ - $this->is_account = true; - } - - /* Update dn, to ensure storing as printer instead of WS / terminal - */ - if(preg_match("/terminal/i",$this->BelongsTo)){ - $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); - } - - if(preg_match("/workstation/i",$this->BelongsTo)){ - $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); - } - - /* Detect if this is a valid printer account; - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('objectClass')); - - if($ldap->count()){ - $attrs = $ldap->fetch(); - if(in_array("gotoPrinter",$attrs['objectClass'])){ - $this->initially_was_account = true; - $this->is_account = true; - }else{ - $this->is_account = false; - } - } - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","printer/".get_class($this),$this->dn); - } - - - /* If type of printer couldn't be detected (because of missing parent object in construction) - * hide this tab. - */ - if(preg_match("/unknown/i",$this->BelongsTo)){ - $display= $this->show_enable_header(_("Add printer extension"), - _("Could not initialize printer tab, parameter parent was missing while construction."),TRUE,TRUE); - return($display); - } - - /* Templates can't have printer extensions - */ - if(preg_match("/WorkstationTemplate/i",$this->BelongsTo)){ - $display= $this->show_enable_header(_("Add printer extension"), - _("This is a workstation template, printer tab is disabled."),TRUE,TRUE); - return($display); - } - if(preg_match("/TerminalTemplate/i",$this->BelongsTo)){ - $display= $this->show_enable_header(_("Add printer extension"), - _("This is a terminal template, printer tab is disabled."),TRUE,TRUE); - return($display); - } - - /* Get cn from base object */ - if(preg_match("/^Workstation$/i",$this->BelongsTo)){ - $this->cn = $this->parent->by_object['workgeneric']->cn; - } - if(preg_match("/^Terminal$/i",$this->BelongsTo)){ - $this->cn = $this->parent->by_object['termgeneric']->cn; - } - - $smarty= get_smarty(); - - /* Assign acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL", $this->getacl($name)); - } - - $display=""; - - /* Tell smarty if this is a standalone object or a terminal / WS depending printer */ - if(preg_match("/^Printer$/i",$this->BelongsTo)){ - $smarty->assign("StandAlone",true); - }else{ - $smarty->assign("StandAlone",false); - } - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Do we represent a valid printer? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no printer features.").""; - return($display); - } - - /* If this is a WS / Terminal depending printer, display account state button */ - if(!preg_match("/^Printer$/i",$this->BelongsTo)){ - if((empty($this->cn)) && ($this->dn != "new")){ - $display= $this->show_enable_header(_("Add printer extension"), - _("This object has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE); - $this->is_account= false; - return $display; - } - - if (($this->is_account)){ - if(preg_match("/^Workstation$/i",$this->BelongsTo)){ - $display= $this->show_disable_header(_("Remove printer extension"), - _("This workstation has printer extension enabled.You can disable it by clicking below.")); - }elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){ - $display= $this->show_disable_header(_("Remove printer extension"), - _("This terminal has printer extension enabled. You can disable it by clicking below.")); - } - }else{ - if(preg_match("/^Workstation$/i",$this->BelongsTo)){ - $display= $this->show_disable_header(_("Add printer extension"), - _("This workstation has printer extension disabled. You can enable it by clicking below.")); - }elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){ - $display= $this->show_enable_header(_("Add printer extension"), - _("This terminal has printer extension disabled. You can enable it by clicking below.")); - } - return ($display); - } - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - $this->baseSelection = true; - } - } - - /* Dialog handling for base select dialog - * Check if base was selected, dialog aborted etc */ - if(is_object($this->dialog)){ - - $this->dialog->save_object(); - if($this->baseSelection){ - if($this->dialog->isClosed()){ - $this->dialog = false; - $this->baseSelection = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - $this->baseSelection = false; - }else{ - return($this->dialog->execute()); - } - } - } - - /* Fill templating stuff */ - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("base_select", $this->base); - - /* Assign attributes */ - foreach ($this->attributes as $attr){ - $smarty->assign("$attr", $this->$attr); - } - - if(isset($_POST['AddUser'])){ - $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddUser"); - } - if(isset($_POST['AddGroup'])){ - $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddGroup"); - } - if(isset($_POST['AddAdminUser'])){ - $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminUser"); - } - if(isset($_POST['AddAdminGroup'])){ - $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminGroup"); - } - - /* Display ppd configure/select dialog */ - if(isset($_POST['EditDriver'])){ - if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){ - $this->dialog = $this->PPDdialogToSave; - }else{ - $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); - $this->dialog->cn= $this->cn; - } - } - - /* remove ppd */ - if(isset($_POST['RemoveDriver'])){ - $this->gotoPrinterPPD = array(); - $this->PPDdialogToSave = NULL; - } - - /* Close ppd dialog */ - if(isset($_POST['ClosePPD'])){ - unset($this->dialog); - $this->dialog=FALSE; - } - - /* Save selected ppd */ - if(isset($_POST['SavePPD'])){ - $this->dialog->save_object(); - if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } - }else{ - $this->gotoPrinterPPD = array(); - $this->gotoPrinterPPD = $this->dialog->save(); - $this->PPDdialogToSave = $this->dialog; - unset($this->dialog); - $this->dialog=FALSE; - } - } - - /* Member management, delete user / group / admin ..*/ - if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){ - foreach($_POST['UserMember'] as $mem){ - $this->DelMember('AddUser',$mem); - } - } - - if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){ - foreach($_POST['UserMember'] as $mem){ - $this->DelMember('AddGroup',$mem); - } - } - - if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){ - foreach($_POST['AdminMember'] as $mem){ - $this->DelMember('AddAdminUser',$mem); - } - } - - if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){ - foreach($_POST['AdminMember'] as $mem){ - $this->DelMember('AddAdminGroup',$mem); - } - } - - /* Abort user / group adding dialog */ - if(isset($_POST['PrinterCancel'])){ - unset($this->dialog); - $this->dialog= FALSE; - } - - /* Save selected users / groups */ - if(isset($_POST['PrinterSave'])){ - $this->dialog->save_object(); - if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } - }else{ - $data= $new = $this->dialog->save(); - unset($data['type']); - foreach($data as $mem){ - $this->AddMember($new['type'], $mem['dn']); - } - unset($this->dialog); - $this->dialog=FALSE; - } - } - - /* Display dialog, if there is currently one open*/ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return $display; - } - - /* Parse selected ppd file */ - if((isset($_SESSION['config']->data['MAIN']['PPD_PATH']))&&(is_dir($_SESSION['config']->data['MAIN']['PPD_PATH']))){ - - $path = $_SESSION['config']->data['MAIN']['PPD_PATH']; - if(!preg_match("/\/$/",$path)){ - $path = $path."/"; - } - - $ppdManager= new ppdManager($path); - if(!empty($this->gotoPrinterPPD)){ - if((!file_exists($path.$this->gotoPrinterPPD))){ - $smarty->assign("driverInfo", "".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD).""); - }else{ - $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD)); - } - }else{ - $smarty->assign("driverInfo", _("Not defined")); - } - }else{ - $smarty->assign("driverInfo",_("Can't get ppd informations.")); - } - - /* Create user & admin user list */ - $list=$this->generateList(); - $userlist = array_merge($list['AddUser'],$list['AddGroup']); - $adminlist = array_merge($list['AddAdminUser'],$list['AddAdminGroup']); - - asort($userlist); - asort($adminlist); - - if(!preg_match("/Printer/i",$this->BelongsTo)){ - if(preg_match("/Terminal/i",$this->BelongsTo)){ - $smarty->assign("desc" ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"".$this->cn."")); - }else{ - $smarty->assign("desc" ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"".$this->cn."")); - } - $smarty->assign("cnACL" , $this->getacl("cn",true)); - }else{ - $smarty->assign("desc" ,""); - } - $smarty->assign("UserMember" ,$this->UserMember); - $smarty->assign("UserMembers" ,$userlist); - $smarty->assign("UserMemberKeys",array_flip($userlist)); - - $smarty->assign("AdminMember" ,$this->AdminMember); - $smarty->assign("AdminMembers" ,$adminlist); - $smarty->assign("AdminMemberKeys",array_flip($adminlist)); - if(preg_match("/Printer/i",$this->BelongsTo)){ - - /* Show main page */ - $str = $this->netConfigDNS->execute(); - if(is_object($this->netConfigDNS->dialog)){ - return($str); - } - $smarty->assign("netconfig", $str); - } else { - $smarty->assign("netconfig", ""); - } - - return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE))); - } - - function remove_from_parent() - { - /* Only remove if there was initially an account */ - if($this->initially_was_account){ - - /* Update dn, to ensure storing as printer instead of WS / terminal - */ - if(preg_match("/terminal/i",$this->BelongsTo)){ - $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); - } - - if(preg_match("/workstation/i",$this->BelongsTo)){ - $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); - } - - /* Check if this dn points to a printer, to avoid deleting something else */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('dn',"objectClass")); - if(!$ldap->count()){ - print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss."); - return; - } - - /* Check if obejct is a printer */ - $CheckPrinter = $ldap->fetch(); - if(!in_array("gotoPrinter",$CheckPrinter['objectClass'])){ - print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss."); - return; - } - - /* Remove account & dns extension */ - $this->netConfigDNS->remove_from_parent(); - $ldap->rmdir($this->dn); - - new log("remove","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system print/generic with dn '%s' failed."),$this->dn)); - $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - - /* Remove previously selected ppd file.*/ - if(!empty($this->initial_PPD)){ - $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD); - $tmp->removeModifiedPPD(); - } - } - } - - - /* Save data to object */ - function save_object() - { - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - if(is_object($this->netConfigDNS)){ - $this->netConfigDNS->save_object(); - } - - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - if (preg_match("/printer/i",$this->BelongsTo)){ - $message= array_merge($message, $this->netConfigDNS->check()); - } - - /* Don't display check messages if this is a template object */ - if(isset($this->parent->by_object['workgeneric'])){ - if($this->parent->by_object['workgeneric']->cn == "wdefault"){ - return $message; - } - }elseif(isset($this->parent->by_object['termgeneric'])){ - if($this->parent->by_object['termgeneric']->cn == "default"){ - return $message; - } - } - - $dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base; - - /* must: cn */ - if(($this->BelongsTo == "Printer") && (empty($this->cn))){ - $message[]= _("The required field 'Printer name' is not set."); - } - - /* must: cn */ - if(($this->BelongsTo == "Printer") && !is_dns_name($this->cn)){ - $message[]= _("Invalid character in printer name."); - } - - /* must: labeledURI */ - if(empty($this->labeledURI)){ - $message[]= "The required field 'Printer URL' is not set."; - } - - /* Check if there is already an entry with this cn*/ - if (($this->orig_dn != $dn)&&( preg_match("/printer/i",$this->BelongsTo))){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); - $ldap->ls("(cn=".$this->cn.")","ou=printers,ou=systems,".$this->base, array("cn")); - if ($ldap->count() != 0){ - while ($attrs= $ldap->fetch()){ - if(preg_match("/cn=dhcp,/",$attrs['dn'])){ - continue; - } - if ($attrs['dn'] != $this->orig_dn){ - $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); - break; - } - } - } - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - /* Update dn, to ensure storing as printer instead of WS / terminal - */ - if(preg_match("/terminal/i",$this->BelongsTo)){ - $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); - } - - if(preg_match("/workstation/i",$this->BelongsTo)){ - $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); - } - - if(!$this->is_account) return; - if(isset($this->parent->by_object['workgeneric'])){ - if($this->parent->by_object['workgeneric']->cn == "wdefault"){ - return; - } - }elseif(isset($this->parent->by_object['termgeneric'])){ - if($this->parent->by_object['termgeneric']->cn == "default"){ - return; - } - } - - /* If type is still unknown, the initialisation of this printer failed, abort. */ - if(preg_match("/unknown/i",$this->BelongsTo)){ - return; - } - - /* save ppd configuration */ - if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){ - $this->PPDdialogToSave->save_ppd(); - } - if($this->orig_dn != $this->dn){ - if(!empty($this->gotoPrinterPPD)) { - $this->PPDdialogToSave = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); - $this->PPDdialogToSave->cn = $this->cn; - $this->PPDdialogToSave->generateProperties(); - $this->PPDdialogToSave->update_ppd_url(); - } - } - - /* Remove previously selected ppd file.*/ - if($this->initial_PPD != $this->gotoPrinterPPD){ - if(!empty($this->initial_PPD)){ - $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD); - $tmp->removeModifiedPPD(); - } - } - - if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ - $method="https://"; - }else{ - $method="http://"; - } - - /* If no ppd is selected, remove this attribute */ - if(!empty($this->gotoPrinterPPD)) { - $this->gotoPrinterPPD = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD); - }else{ - $this->gotoPrinterPPD = array(); - } - - $dn= $this->dn; - plugin::save(); - $ldap= $this->config->get_ldap_link(); - - /* reduce objectClasses to minimun */ - $this->attrs['objectClass']= $this->objectclasses; - - /* Remove all empty values */ - if ($this->orig_dn == 'new'){ - $attrs= array(); - foreach ($this->attrs as $key => $val){ - if (is_array($val) && count($val) == 0){ - continue; - } - $attrs[$key]= $val; - } - $this->attrs= $attrs; - } - - /* Append printer user - */ - $this->attrs['gotoUserPrinter']=array(); - foreach($this->member['AddUser'] as $mem){ - $this->attrs['gotoUserPrinter'][]=$mem['uid'][0]; - } - - /* Append printer group - */ - $this->attrs['gotoGroupPrinter'] = array(); - foreach($this->member['AddGroup'] as $mem){ - $this->attrs['gotoGroupPrinter'][]=$mem['cn'][0]; - } - - /* Append printer admin user - */ - $this->attrs['gotoUserAdminPrinter'] = array(); - foreach($this->member['AddAdminUser'] as $mem){ - $this->attrs['gotoUserAdminPrinter'][]=$mem['uid'][0]; - } - - /* Append printer admin group - */ - $this->attrs['gotoGroupAdminPrinter']= array(); - foreach($this->member['AddAdminGroup'] as $mem){ - $this->attrs['gotoGroupAdminPrinter'][]=$mem['cn'][0]; - } - - if($this->orig_dn == 'new'){ - foreach(array("gotoGroupPrinter","gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter") as $checkVar){ - if(count($this->attrs[$checkVar]) == 0 || empty($this->attrs[$checkVar])){ - unset($this->attrs[$checkVar]); - } - } - }else{ - if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){ - $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; - } - } - - /* Ensure to create a new object */ - if(preg_match("/ou=incoming,/",$this->orig_dn)){ - $this->orig_dn = "new"; - } - - /* Move object in necessary*/ - if (($this->orig_dn != $this->dn) && ($this->orig_dn != 'new')){ - $this->move($this->orig_dn, $this->dn); - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn); - if(!$ldap->count()){ - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - - /* Remove empty values */ - foreach($this->attrs as $name => $value){ - if(empty($value)){ - unset($this->attrs[$name]); - } - } - - $ldap->add($this->attrs); - $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - new log("create","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } else { - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - new log("modify","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system print/generic with dn '%s' failed."),$this->dn)); - - if(preg_match("/printer/i",$this->BelongsTo)){ - $this->netConfigDNS->cn = $this->cn; - $this->netConfigDNS->dn = $this->dn; - $this->netConfigDNS->save(); - } - - /* This is a multi object. Handle tagging here... */ - $this->handle_object_tagging(); - } - - function generateList(){ - $a_return=array(); - - foreach($this->member as $type => $values){ - $a_return[$type]=array(); - foreach($values as $value){ - if((preg_match("/Group/i",$type))){ - if(!isset($value['description'])){ - $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0]; - }else{ - $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0]." [".$value['description'][0]."]"; - } - }else{ - $a_return[$type][$value['uid'][0]]=_("User")." : ".$value['cn'][0]; - } - } - } - return($a_return); - } - - /* Return plugin informations for acl handling - #FIXME FAIscript seams to ununsed within this class... */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Print generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 4, - "plSection" => array("administration"), - "plCategory" => array("printer" => array("description" => _("Printer"), - "objectClass" => "gotoPrinter"),"workstation","terminal"), - "plProvidedAcls"=> array( - "cn" => _("Name"), - "base" => _("Base") , - "description" => _("Description"), - "l" => _("Location"), - "labeledURI" => _("LabeledURL"), - "gotoPrinterPPD" => _("Printer PPD"), - "gotoUserPrinter" => _("Permissions")) - )); - } - - - /* Delete member */ - function DelMember($type,$id) - { - /* Check if there was a printer "dn" given, or the "cn" */ - foreach($this->member[$type] as $key => $printer){ - if($printer['dn'] == $id) { - $id = $key; - } - } - - if(!$this->acl_is_writeable("gotoUserPrinter")){ - print_red(sprintf(_("You are not allowed to remove the given object '%s' from the list of members of printer '%s'."),$id,$this->dn)); - return(FALSE); - } - - if(isset($this->member[$type][$id])){ - unset($this->member[$type][$id]); - return(TRUE); - } - return(FALSE); - } - - - /* Add given obejct to members */ - function AddMember($type,$dn) - { - $types = array("AddUser","AddGroup","AddAdminUser","AddAdminGroup"); - if(!in_array_ics($type, $types)){ - print_red(sprintf(_("Illegal printer type while adding '%s' to the list of '%s' printers,"),$dn,$type)); - return(FALSE); - } - - if(!$this->acl_is_writeable("gotoUserPrinter")){ - print_red(sprintf(_("You are not allowed to add the given object '%s' to the list of members of '%s'."),$dn,$this->dn)); - return(FALSE); - } - - /* Get name of index attributes */ - if(preg_match("/user/i",$type)){ - $var = "uid"; - }else{ - $var = "cn"; - } - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($dn); - $ldap->cat($dn,array($var,"cn")); - if($ldap->count()){ - - $attrs = $ldap->fetch(); - - if(isset($attrs[$var][0])){ - $name = $attrs[$var][0]; - - /* Check if this uid/cn is already assigned to any permission */ - foreach($types as $ctype){ - - /* If we want to add a user, only check user/userAdmin members */ - if((preg_match("/user/i",$type)) && (!preg_match("/user/i",$ctype))){ - continue; - } - - /* If we want to add a group, only check groups/adminGroups .. */ - if((preg_match("/group/i",$type)) && (!preg_match("/group/i",$ctype))){ - continue; - } - - if(isset( $this->member[$ctype][$name])){ - print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0])); - return(FALSE); - } - } - - /* Everything is fine. So add the given object to members */ - $this->member[$type][$attrs[$var][0]] = $attrs ; - }else{ - print_a($attrs); - } - }else{ - print_red(sprintf(_("Can't add '%s' to list of members, it is not reachable."),$dn)); - return(FALSE); - } - return(TRUE); - } - - - /* Display generic part for server copy & paste */ - function getCopyDialog() - { - $vars = array("cn"); - $smarty = get_smarty(); - $smarty->assign("cn" ,$this->cn); - $smarty->assign("object","printer"); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - if(isset($source['macAddress'][0])){ - $this->netConfigDNS->macAddress = $source['macAddress'][0]; - } - if(isset($source['ipHostNumber'][0])){ - $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; - } - - $source_o = new printgeneric($this->config,$source['dn'],NULL,$this->parent); - foreach($this->attributes as $attr){ - $this->$attr = $source_o->$attr; - } - $this->member = $source_o -> member; - - $this->gotoPrinterPPD = ""; - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_selectUserToPrinterDialog.inc b/plugins/admin/systems/class_selectUserToPrinterDialog.inc deleted file mode 100644 index 1f110e355..000000000 --- a/plugins/admin/systems/class_selectUserToPrinterDialog.inc +++ /dev/null @@ -1,198 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array("whatever"); - var $regex = "*"; - var $subtree = FALSE; - var $depselect = "/"; - var $deplist = "/"; - - var $searchObjects = ""; - var $searchAttrs = ""; - var $searchAppend = ""; - var $baseAddition = ""; - var $type = ""; - var $search_cat = ""; - - function selectUserToPrinterDialog (&$config, $dn= NULL,$type=false ) - { - plugin::plugin ($config, $dn); - $this->depselect = $this->config->current['BASE']; - - switch($type){ - case "AddUser" : - $this->searchObjects = "(objectClass=gosaAccount)(!(uid=*$))"; - $this->searchAttrs = array("cn","uid"); - $this->searchAppend = "uid"; - $this->baseAddition = get_people_ou(); - $this->search_cat = "users"; - ;break; - case "AddGroup" : - $this->searchObjects = "(objectClass=posixGroup)"; - $this->searchAttrs = array("cn","description"); - $this->searchAppend = "cn"; - $this->baseAddition = get_groups_ou(); - $this->search_cat = "groups"; - ;break; - case "AddAdminUser" : - $this->searchObjects = "(objectClass=gosaAccount)(!(uid=*$))"; - $this->searchAttrs = array("cn","uid"); - $this->searchAppend = "uid"; - $this->baseAddition = get_people_ou(); - $this->search_cat = "users"; - ;break; - case "AddAdminGroup" : - $this->searchObjects = "(objectClass=posixGroup)"; - $this->searchAttrs = array("cn","description"); - $this->searchAppend = "cn"; - $this->baseAddition = get_groups_ou(); - $this->search_cat = "groups"; - ;break; - } - $this->type = $type; - - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - if(isset($_POST['dialogissubmitted'])){ - $this->regex=$_POST['regexPrinter']; - $this->depselect = $_POST['depselectPrinter']; - } - $this->subtree= isset($_POST['SubSearch']); - - if((isset($_GET['search']))&&(!empty($_GET['search']))){ - $this->regex=$_GET['search']."*"; - $this->regex=preg_replace("/\*\*/","*",$this->regex); - } - - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - $deps_res[] = array("dn"=>$this->config->current['BASE']); - $deps_res= array_merge($deps_res,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", array("users","groups"), $this->config->current['BASE'], - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - /* Load possible departments */ - $ui = get_userinfo(); - - /* Allowed user departments */ - $udeps = $ui->get_module_departments("users"); - - /* Allowed groups department */ - $gdeps = $ui->get_module_departments("groups"); - - /* Combine both arrays */ - $tdeps = array_unique(array_merge($udeps,$gdeps)); - - /* Create usable departments array */ - $ids = $this->config->idepartments; - $deps = array(); - foreach($deps_res as $dep){ - if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){ - $value = $ids[$dep['dn']]; - $deps[$dep['dn']] = $value; - } - } - if(!isset($deps[$this->depselect])){ - $this->depselect = key($deps); - } - - - - $tmp_printers= $this->getPrinter(); - natcasesort($tmp_printers); - $smarty->assign("regexPrinter" , $this->regex); - $smarty->assign("deplistPrinter" , $deps);;//deplist); - $smarty->assign("depselectPrinter" , $this->depselect); - $smarty->assign("gotoPrinters" , $tmp_printers); - $smarty->assign("gotoPrinterKeys" , array_flip($tmp_printers)); - $smarty->assign("apply" , apply_filter()); - $smarty->assign("alphabet" , generate_alphabet()); - $smarty->assign("search_image" , get_template_path('images/search.png')); - $smarty->assign("tree_image" , get_template_path('images/tree.png')); - $smarty->assign("infoimage" , get_template_path('images/info.png')); - $smarty->assign("launchimage" , get_template_path('images/small_filter.png')); - $smarty->assign("deplist" , $deps); - $smarty->assign("subtree", $this->subtree?"checked":""); - - $display.= $smarty->fetch(get_template_path('selectUserToPrinterDialog.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - function check(){ - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(empty($_POST['gotoPrinter'])){ - $message[] = _("Please select a printer or press cancel."); - } - return $message; - } - - /* Save to LDAP */ - function save() - { - $a_return['type']=$this->type; - - foreach($_POST['gotoPrinter'] as $name){ - $data = $this->getPrinter(true); - $a_return[$name]= $data[$name]; - } - return($a_return); - } - - /* This function generates the Printerlist - * All printers are returned that match regex and and depselect - */ - function getPrinter($detailed = false) - { - $a_return=array(); - - $filter = "(&".$this->searchObjects."(cn=".$this->regex."))"; - $base = $this->baseAddition.$this->depselect; - $attrs = $this->searchAttrs; - $cat = $this->search_cat; - - if ($this->subtree){ - $res= get_list($filter,$cat,$this->depselect,$attrs, GL_SUBSEARCH); - } else { - $res= get_list($filter,$cat,$base,$attrs); - } - foreach($res as $printer){ - if(($detailed ==true)){ - if(isset($printer[$this->searchAppend])){ - $a_return[$printer[$this->searchAppend][0]] = $printer; - } - }else{ - if(isset($printer[$this->searchAppend])){ - if(isset($printer['description'][0])){ - $a_return[$printer[$this->searchAppend][0]] = $printer['cn'][0]." - ".$printer['description'][0]; - }else{ - $a_return[$printer[$this->searchAppend][0]] = $printer['cn'][0]; - } - } - } - } - return($a_return); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc deleted file mode 100644 index 9d29f5e59..000000000 --- a/plugins/admin/systems/class_servGeneric.inc +++ /dev/null @@ -1,444 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $ignore_account= TRUE; - var $interfaces= array(); - - /* Needed values and lists */ - var $base= ""; - var $cn= ""; - var $l= ""; - var $description= ""; - var $orig_dn= ""; - var $didAction= FALSE; - - /* attribute list for save action */ - var $attributes= array("cn", "description","gotoMode"); - var $objectclasses= array("top", "GOhard", "goServer"); - - var $gotoMode= "locked"; - - var $netConfigDNS; - var $modes = array(); - var $ui ; - var $mapActions = array("reboot" => "", - "instant_update" => "softupdate", - "localboot" => "localboot", - "update" => "sceduledupdate", - "reinstall" => "install", - "rescan" => "", - "memcheck" => "memcheck", - "sysinfo" => "sysinfo"); - - var $fai_activated =FALSE; - var $view_logged = FALSE; - - function servgeneric (&$config, $dn= NULL, $parent= NULL) - { - /* Check if FAI is activated */ - $tmp = $config->search("faiManagement", "CLASS",array('menu','tabs')); - - if(!empty($tmp)){ - $this->fai_activated = TRUE; - } - - plugin::plugin ($config, $dn, $parent); - - $this->ui = get_userinfo(); - $this->modes["active"]= _("Activated"); - $this->modes["locked"]= _("Locked"); - - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - $this->cn= ""; - } else { - $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); - } - $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); - $this->netConfigDNS->set_acl_category("server"); - $this->netConfigDNS->set_acl_base($this->base); - - /* Save dn for later references */ - $this->orig_dn= $this->dn; - } - - - function set_acl_base($base) - { - plugin::set_acl_base($base); - $this->netConfigDNS->set_acl_base($base); - } - - - function set_acl_category($cat) - { - plugin::set_acl_category($cat); - $this->netConfigDNS->set_acl_category($cat); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* Do we represent a valid server? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no server features.").""; - return($display); - } - - /* Check for action */ - if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){ - $cmd = $this->config->search("workgeneric", "ACTIONCMD",array('tabs')); - if ($cmd == ""){ - print_red(_("No ACTIONCMD definition found in your gosa.conf")); - } else { - - exec ($cmd." ".$this->netConfigDNS->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } else { - $this->didAction= TRUE; - - /* Set FAIstate */ - if($this->fai_activated && $this->dn != "new"){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn,array("objectClass")); - $res = $ldap->fetch(); - - $attrs = array(); - $attrs['FAIstate'] = ""; - if(isset($this->mapActions[$_POST['saction']])){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } - - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } - - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } - - if($attrs['FAIstate'] == ""){ -#FIXME we should check if FAIobject is used anymore - $attrs['FAIstate'] = array(); - } - - $ldap->cd($this->dn); - $ldap->modify($attrs); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic (FAIstate) with dn '%s' failed."),$this->dn)); - } - } - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once ){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* Only accept allowed bases */ - $tmp = $this->get_allowed_bases(); - if($tmp[$this->dialog->isSelected()]){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Assign base ACL */ - $smarty->assign("bases" , $this->get_allowed_bases()); - - /* Assign attributes */ - foreach ($this->attributes as $attr){ - $smarty->assign("$attr", $this->$attr); - } - - $smarty->assign("staticAddress", ""); - $smarty->assign("base_select", $this->base); - - /* Assign status */ - $query= "fping -q -r 1 -t 500 ".$this->cn; - exec ($query, $dummy, $retval); - - /* Offline */ - if ($retval == 0){ - $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), - "instant_update" => _("Instant update"), - "update" => _("Scheduled update"), - "reinstall" => _("Reinstall"), - "rescan" => _("Rescan hardware"), - "memcheck" => _("Memory test"), - "localboot" => _("Force localboot"), - "sysinfo" => _("System analysis"))); - } else { - $smarty->assign("actions", array("wake" => _("Wake up"), - "reinstall" => _("Reinstall"), - "update" => _("Scheduled update"), - "memcheck" => _("Memory test"), - "localboot" => _("Force localboot"), - "sysinfo" => _("System analysis"))); - } - - /* Show main page */ - $smarty->assign("fai_activated",$this->fai_activated); - - $str = $this->netConfigDNS->execute(); - if(is_object($this->netConfigDNS->dialog)){ - return($str); - } - $smarty->assign("netconfig", $str); - $smarty->assign("modes", $this->modes); - - return($smarty->fetch (get_template_path('server.tpl', TRUE))); - } - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){ - return; - } - - $this->netConfigDNS->remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - $ldap->rmdir($this->dn); - - new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/generic with dn '%s' failed."),$this->dn)); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } - - - /* Save data to object */ - function save_object() - { - /* Save current base, to be able to revert to last base, - if new base is invalid or not allowed to be selected */ - $base_tmp = $this->base; - plugin::save_object(); - $this->netConfigDNS->save_object(); - - /* Get base selection */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if($tmp[$_POST['base']]){ - $this->base = $_POST['base']; - }else{ - $this->base = $base_tmp; - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - $message= array_merge($message, $this->netConfigDNS->check()); - $this->dn= "cn=".$this->cn.",ou=servers,ou=systems,".$this->base; - - /* must: cn */ - if ($this->cn == ""){ - $message[]= _("The required field 'Server name' is not set."); - } - - /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn)){ - $message[] = _("Please specify a valid name for this object."); - } - - if ($this->orig_dn != $this->dn){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); - $ldap->search ("(cn=".$this->cn.")", array("cn")); - if ($ldap->count() != 0){ - while ($attrs= $ldap->fetch()){ - if ($attrs['dn'] != $this->orig_dn){ - if(!preg_match("/cn=dhcp,/",$attrs['dn']) && !preg_match("/,ou=incoming,/",$attrs['dn']) && preg_match("/,ou=servers,ou=systems,/",$attrs['dn'])){ - $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); - break; - } - } - } - } - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Remove all empty values */ - if ($this->orig_dn == 'new'){ - $attrs= array(); - foreach ($this->attrs as $key => $val){ - if (is_array($val) && count($val) == 0){ - continue; - } - $attrs[$key]= $val; - } - $this->attrs= $attrs; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - if ($this->orig_dn == 'new'){ - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $mode= "add"; - } else { - - /* cn is not case sensitive for ldap, but for php it is!! */ - if($this->config->current['DNMODE'] == "cn"){ - if (strtolower($this->orig_dn) != (strtolower($this->dn))){ - $this->recursive_move($this->orig_dn, $this->dn); - plugin::save(); - } - }else{ - if ($this->orig_dn != $this->dn){ - $this->recursive_move($this->orig_dn, $this->dn); - plugin::save(); - } - } - - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - $mode= "modify"; - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic with dn '%s' failed."),$this->dn)); - $this->netConfigDNS->cn = $this->cn; - $this->netConfigDNS->save(); - - /* Optionally execute a command after we're done */ - if(!$this->didAction){ - $this->handle_post_events($mode,array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } - } - - - /* Display generic part for server copy & paste */ - function getCopyDialog() - { - $vars = array("cn"); - - $smarty = get_smarty(); - $smarty->assign("cn" ,$this->cn); - $smarty->assign("object","server"); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - if(isset($source['macAddress'][0])){ - $this->netConfigDNS->macAddress = $source['macAddress'][0]; - } - if(isset($source['ipHostNumber'][0])){ - $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; - } - - } - - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Server generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => array("server" => array("description" => _("Server"), - "objectClass" => "goServer")), - "plProvidedAcls"=> array( - "cn" => _("Name"), - "description" => _("Description"), - "gotoMode" => _("Goto mode"), - "base" => _("Base"), - "FAIstate" => _("Action flag")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_serverService.inc b/plugins/admin/systems/class_serverService.inc deleted file mode 100644 index 338052b7e..000000000 --- a/plugins/admin/systems/class_serverService.inc +++ /dev/null @@ -1,442 +0,0 @@ -"Config object" , "dn"=>"Object dn"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array(); - - var $divList = NULL; - - var $plugins = array(); - var $pluign_names = array(); - - var $current = ""; - var $backup = NULL; - var $acl ; - var $cn; - - function ServerService (&$config, $dn) - { - plugin::plugin($config); - $this->dn= $dn; - foreach ($config->data['TABS']['SERVERSERVICE'] as $plug){ - $name= $plug['CLASS']; - $this->plugin_names[]= $name; - $this->plugins[$name]= new $name($config, $dn); - - /* Capture all service objectClases, necessary for acl handling */ - if(isset($this->plugins[$name]->objectclasses)){ - foreach($this->plugins[$name]->objectclasses as $oc){ - $this->objectclasses[] = $oc; - } - } - } - $this->divList = new divListSystemService($config,$this); - } - - function set_acl_base($base) - { - plugin::set_acl_base($base); - foreach($this->plugins as $name => $obj){ - $this->plugins[$name]->set_acl_base($base); - } - } - - function set_acl_category($category) - { - plugin::set_acl_category($category); - foreach($this->plugins as $name => $obj){ - $this->plugins[$name]->set_acl_category($category); - } - } - - function execute() - { - /* Variable initialisation */ - $s_action = ""; - $s_entry = ""; - - /* Walk through posts and check if there are some introductions for us */ - $PossiblePosts = array("addNewService" => "", - "startServices" => "", - "stopServices" => "", - "restartServices" => "", - "removeServices" => "", - - "StartSingleService" => "/^StartSingleService_(.*)_[xy]$/", - "StopSingleService" => "/^StopSingleService_(.*)_[xy]$/", - "RestartSingleService" => "/^RestartSingleService_(.*)_[xy]$/", - "RemoveSingleService" => "/^RemoveSingleService_(.*)_[xy]$/", - "EditSingleService" => "/^EditSingleService_(.*)_[xy]$/"); - - - $once = true; - foreach($_POST as $name => $value){ - foreach($PossiblePosts as $pregCheck => $idPreg) { - if(preg_match("/^".$pregCheck."/",$name) && $once){ - $once = false; - $s_action = $pregCheck; - - if(!empty($idPreg)){ - $s_entry = preg_replace($idPreg,"\\1",$name); - } - } - } - } - - - /* Handle state changes for services */ - $map = array( "startServices" => array("type" => START_SERVICE , "service" => ALL_SERVICES), - "stopServices" => array("type" => STOP_SERVICE , "service" => ALL_SERVICES), - "restartServices" => array("type" => RESTART_SERVICE , "service" => ALL_SERVICES), - "StartSingleService" => array("type" => START_SERVICE , "service" => $s_entry), - "StopSingleService" => array("type" => STOP_SERVICE , "service" => $s_entry), - "RestartSingleService" => array("type" => RESTART_SERVICE , "service" => $s_entry)); - if(isset($map[$s_action])){ - $type = $map[$s_action]['type']; - $service = $map[$s_action]['service']; - $this->ServiceStatusUpdate($type,$service); - } - - /* Handle actions linked via href */ - if(isset($_GET['act']) && $_GET['act'] == "open" && isset($_GET['id'])){ - $id = $_GET['id']; - if(isset($this->plugins[$id])){ - $s_entry = $id; - $s_action = "EditSingleService"; - } - } - - /* Open service add dialog */ - if($s_action == "addNewService"){ - $this->dialog = new ServiceAddDialog($this->config,$this->dn,$this); - } - - - /* Remove service */ - if($s_action == "RemoveSingleService"){ - - /* Create resetted obj */ - $new_obj = new $s_entry($this->config,$this->dn); - $new_obj -> set_acl_base($this->acl_base); - $new_obj -> set_acl_category(preg_replace("/\/$/","",$this->acl_category)); - $tmp = $new_obj->getListEntry(); - - if($tmp['AllowRemove']){ - - /* Check if we are allowed to remove this service - */ - $str = $this->plugins[$s_entry]->allow_remove(); - - if(empty($str)){ - $this->plugins[$s_entry] = $new_obj; - $this->plugins[$s_entry]->is_account = false; - }else{ - print_red($str); - } - } - } - - - /* Edit a service and make a backup from all attributes, - to be able to restore old values after aborting dialog */ - if($s_action == "EditSingleService"){ - $this->backup = get_object_vars($this->plugins[$s_entry]); - $this->dialog = $this->plugins[$s_entry]; - $this->current = $s_entry; - } - - - /* Abort service add */ - if(isset($_POST['CancelServiceAdd'])){ - $this->dialog = FALSE; - $this->backup = NULL; - $this->current = ""; - } - - - /* Abort dialog - Restore vars with values before editing */ - if(isset($_POST['CancelService']) && !empty($this->current)){ - if($this->backup == NULL){ - $this->plugins[$this->current] = new $this->current($this->config,$this->dn); - $this->plugins[$this->current]-> set_acl_base($this->acl_base); - $this->plugins[$this->current]-> set_acl_category(preg_replace("/\/$/","",$this->acl_category)); - - }else{ - foreach($this->backup as $name => $value){ - $this->plugins[$this->current]->$name = $value; - } - } - $this->dialog = FALSE; - $this->backup = NULL; - $this->current = ""; - } - - - /* Abort dialog */ - if(isset($_POST['SaveService']) && is_object($this->dialog)){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $this->plugins[$this->current] = $this->dialog; - $tmp = get_object_vars($this->dialog); - foreach($tmp as $name => $value){ - $this->plugins[$this->current]->$name = $value; - } - $this->current = ""; - $this->dialog = FALSE; - $this->backup = NULL; - } - } - - - /* Abort dialog */ - if((isset($_POST['SaveServiceAdd'])) && (!empty($_POST['ServiceName']))){ - $serv = $_POST['ServiceName']; - $this->plugins[$serv]->is_account = true; - $this->dialog = $this->plugins[$serv]; - $this->current = $serv; - } - - - /* There is currently a subdialog open, display this dialog */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - - /* Dispaly services overview */ - $this->divList->execute(); - $list = array(); - - foreach($this->plugins as $name => $obj){ - if($obj->is_account){ - $list[$name] = $this->plugins[$name]->getListEntry(); - } - } - $this->divList -> setEntries($list); - return("
".$this->divList->Draw()."
"); - } - - - /* Get all used services - CLASSNAME => _($this->plugins[*]->DisplayName); */ - function getAllUsedServices() - { - $ret = array(); - foreach($this->plugins as $name => $obj){ - if($obj->is_account){ - if(isset($obj->DisplayName)){ - $ret[$name] = $obj->DisplayName; - }else{ - $ret[$name] = $name; - } - } - } - return($ret); - } - - - /* Get all unused services - CLASSNAME => _($this->plugins[*]->DisplayName); */ - function getAllUnusedServices() - { - $tmp = $this->getAllUsedServices(); - $pool_of_ocs =array(); - foreach($tmp as $name => $value){ - if(isset($this->plugins[$name]->conflicts)){ - $pool_of_ocs[]= get_class($this->plugins[$name]); - } - } - - $ret = array(); - foreach($this->plugins as $name => $obj){ - - /* Skip all pluigns that will lead into conflicts */ - $skip = false; - if(isset($obj->conflicts)){ - foreach($obj->conflicts as $oc){ - if(in_array_ics($oc,$pool_of_ocs)){ - $skip = true; - } - } - } - - /* Only show createable services */ - if(!$obj->acl_is_createable()){ - $skip = true; - } - - if(!$skip){ - if(isset($obj->DisplayName)){ - $ret[$name] = $obj->DisplayName; - }else{ - $ret[$name] = $name; - } - } - } - return($ret); - } - - - /* This function sets the status var for each used - service && calls an external hook if specified in gosa.conf*/ - function ServiceStatusUpdate($method , $service) - { - /* Skip if this is a new server */ - if($this->dn == "new"){ - print_red(_("Can't set status while this server is not saved.")); - return; - } - - $action = ""; - if($method == START_SERVICE){ - $action = SERVICE_STARTED; - }elseif($method== STOP_SERVICE){ - $action = SERVICE_STOPPED; - }elseif($method == RESTART_SERVICE){ - $action = SERVICE_RESTARTED; - }else{ - print_red(sprintf(_("The specified method '%s' can't executed for services."),$action)); - return; - } - - $caseVars = array("cn","dn"); - if($service == ALL_SERVICES){ - foreach($this->plugins as $name => $obj){ - foreach($caseVars as $var){ - if(isset($this->$var)){ - $this->plugins[$name]->$var = $this->$var; - } - } - - /* check if services can be restarted */ - $map =array(SERVICE_STARTED=> "AllowStart" , - SERVICE_STOPPED => "AllowStop", - SERVICE_RESTARTED => "AllowRestart"); - - /* get plugins informations, restart/start/stop actions allowed ?*/ - $tmp = $this->plugins[$name]->getListEntry(); - - /* Check if given action is allowed for this service */ - if($tmp[$map[$action]]){ - if($this->plugins[$name]->initially_was_account && $this->plugins[$name]->is_account){ - $this->plugins[$name]->setStatus($action); - } - } - } - }else{ - foreach($caseVars as $var){ - if(isset($this->$var)){ - $this->plugins[$service]->$var = $this->$var; - } - } - if($this->plugins[$service]->is_account){ - $this->plugins[$service]->setStatus($action); - } - } - } - - - function check() - { - $message = plugin::check(); - return $message; - } - - - function save_object() - { - foreach($this->plugins as $name => $obj){ - if($obj->is_account){ - $this->plugins[$name]->save_object(); - } - } - } - - - function remove_from_parent() - { - $caseVars = array("cn","dn"); - foreach($this->plugins as $name => $obj){ - foreach($caseVars as $var){ - if(isset($this->$var)){ - $this->plugins[$name]->$var = $this->$var; - } - } - if($this->plugins[$name]->initially_was_account){ - $this->plugins[$name]->remove_from_parent(); - } - } - } - - - function save() - { - $caseVars = array("cn","dn"); - foreach($this->plugins as $name => $obj){ - - foreach($caseVars as $var){ - if(isset($this->$var)){ - $this->plugins[$name]->$var = $this->$var; - } - } - - if($this->plugins[$name]->is_account){ - $this->plugins[$name]->save(); - }else{ - if($this->plugins[$name]->initially_was_account){ - $this->plugins[$name]->remove_from_parent(); - } - } - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - foreach($this->plugins as $name => $plugin){ - $this->plugins[$name]->PrepareForCopyPaste($source); - } - } - - - /* Check if all plugins allow a remove .. */ - function allow_remove() - { - foreach($this->plugins as $name => $obj){ - $str = $obj->allow_remove(); - if(!empty($str)){ - return($str); - } - } - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_systemManagement.inc b/plugins/admin/systems/class_systemManagement.inc deleted file mode 100644 index 60a577e8b..000000000 --- a/plugins/admin/systems/class_systemManagement.inc +++ /dev/null @@ -1,1398 +0,0 @@ -config= $config; - $this->ui= $ui; - - /* Creat dialog object */ - $this->DivListSystem = new divListSystem($this->config,$this); - - /* Copy & Paste enabled ?*/ - if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - - /* Check whether the arp handling active or not */ - if($this->config->search("ArpNewDevice","CLASS",array('tabs')) != ""){ - $this->arp_handling_active = TRUE; - } - - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - $_SESSION['LOCK_VARS_TO_USE'] = array("/^system_edit_/i","/^system_del_/","/^act/","/^id/","/^item_selected/","/^remove_multiple_systems/"); - - /******************** - Check for functional posts, edit|delete|add|... system devices - ********************/ - $s_action = ""; // Contains the action to proceed - $s_entry = ""; // The value for s_action - $base_back = ""; // The Link for Backbutton - $smarty = get_smarty(); - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/system_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/system_del_/i","",$key); - // Post for edit - }elseif(preg_match("/system_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/system_edit_/i","",$key); - // Post for new - }elseif(preg_match("/system_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/system_tplnew.*/i",$key)){ - $s_action="new_tpl"; - }elseif(preg_match("/system_setpwd_.*/i",$key)){ - $s_action="change_pw"; - $s_entry = preg_replace("/system_setpwd_/i","",$key); - }elseif(preg_match("/gen_cd_.*/i",$key)){ - $s_action="gen_cd"; - $s_entry = preg_replace("/gen_cd_/i","",$key); - }elseif(preg_match("/^copy_.*/",$key)){ - $s_action="copy"; - $s_entry = preg_replace("/^copy_/i","",$key); - }elseif(preg_match("/^cut_.*/",$key)){ - $s_action="cut"; - $s_entry = preg_replace("/^cut_/i","",$key); - } - } - - /* Incoming handling - * If someone made a systemtype and ogroup selection - * Display the new requested entry type ... servtab in case of server and so on. - */ - if(isset($_POST['SystemTypeChoosen'])){ - $s_action = "SelectedSystemType"; - $s_entry = $_POST['SystemType']; - $_SESSION['SelectedSystemType']['ogroup'] = $_POST['ObjectGroup']; - $this->systab = NULL; - } - - /* remove image tags from posted entry (posts looks like this 'name_x')*/ - $s_entry = preg_replace("/_.$/","",$s_entry); - - /* Edit was requested by pressing the name(link) of an item */ - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; - } - /* Create options */ - if(isset($_POST['menu_action']) && preg_match("/^newsystem_/",$_POST['menu_action'])){ - $s_action = "newsystem"; - $s_entry = preg_replace("/^newsystem_/","",$_POST['menu_action']); - } - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - /* Check for exeeded sizelimit */ - if (($message= check_sizelimit()) != ""){ - return($message); - } - - /* Try to get informations about what kind of system to create */ - if ($s_action=="new") { - return ($smarty->fetch(get_template_path('chooser.tpl', TRUE))); - } - - - /******************** - Copy & Paste Handling ... - ********************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /******************** - Create FAI CD ... - ********************/ - if ($s_action=="gen_cd"){ - $this->dn= $this->terminals[$s_entry]['dn']; - $_SESSION['objectinfo']= $this->dn; - return ($smarty->fetch(get_template_path('gencd.tpl', TRUE))); - } - - - /* Start CD-Creation */ - if ((isset($_POST["cd_create"])) && !empty($this->dn)){ - $smarty->assign("src", "?plug=".$_GET['plug']."&PerformIsoCreation"); - return ($smarty->fetch(get_template_path('gencd_frame.tpl', TRUE))); - } - - - if ($this->dn != "" && isset($_GET['PerformIsoCreation'])){ - - $return_button = "
- - -
"; - - $dsc = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); - - /* Get and check command */ - $command= $this->config->search("workgeneric", "ISOCMD",array('tabs')); - - if (check_command($command)){ - @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute"); - - /* Print out html introduction */ - echo ' - - - - - - - -
';
-
-        /* Open process handle and check if it is a valid process */
-        $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
-        if (is_resource($process)) {
-          fclose($pipes[0]);
-
-          /* Print out returned lines && write JS to scroll down each line */
-          while (!feof($pipes[1])){
-            $cur_dat = fgets($pipes[1], 1024);
-            echo $cur_dat;
-            echo '' ;
-            flush();
-          }
-        }
-
-        /* Get error string && close streams */
-        $buffer= stream_get_contents($pipes[2]);
-
-        fclose($pipes[1]);
-        fclose($pipes[2]);
-        echo "
"; - - /* Check return code */ - $ret= proc_close($process); - if ($ret != 0){ - echo "

"._("Creating the image failed. Please see the report below.")."

"; - echo "
$buffer
"; - } - - - - echo $return_button."
"; - - } else { - $tmp= "

".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."

"; - echo $tmp; - } - - /* Scroll down completly */ - echo '' ; - echo ''; - flush(); - exit; - } - - - /******************** - Create new system ... - ********************/ - /* Create new default terminal - * Or create specified object of selected system type, from given incoming object - */ - - $save_object_directly = false; - if(($s_action == "SelectedSystemType") && (isset($_POST['ObjectGroup']) && ($_POST['ObjectGroup'] != "none"))){ - $save_object_directly = true; - } - - if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") { - - /* If the current entry is an incoming object - * $sw = System type as posted in new incoming handling dialog - */ - if($s_action == "SelectedSystemType") { - $sw = $s_entry; - }else{ - if(isset($_POST['system'])){ - $sw = $_POST['system']; - }else{ - $sw = $s_entry; - } - $this->dn= "new"; - } - - $tabs = array( - "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"), - "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"), - "server" => array("CLASS"=>"SERVTABS", "TABNAME"=>"servgeneric", "TABCLASS" =>"servtabs", "ACL"=> "server"), - "printer" => array("CLASS"=>"PRINTTABS", "TABNAME"=>"printgeneric", "TABCLASS" =>"printtabs", "ACL"=> "printer"), - "phone" => array("CLASS"=>"PHONETABS", "TABNAME"=>"phoneGeneric", "TABCLASS" =>"phonetabs", "ACL"=> "phone"), - "component" => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentGeneric","TABCLASS" =>"componenttabs", "ACL"=> "component")); - - if(isset($tabs[$sw])){ - $class = $tabs[$sw]["CLASS"]; - $tabname = $tabs[$sw]["TABNAME"]; - $tabclass = $tabs[$sw]["TABCLASS"]; - $acl_cat = $tabs[$sw]["ACL"]; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $ui = get_userinfo(); - $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname); - if(preg_match("/c/",$tabacl)){ - $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw); - $this->systab->set_acl_base($this->DivListSystem->selectedBase); - $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase; - $this->systab->base = $this->DivListSystem->selectedBase; - }else{ - print_red(_("You are not allowed to create a new object of this type.")); - } - } - } - - /******************** - Edit system ... - ********************/ - - /* User wants to edit data? */ - if (($s_action == "edit") && (!isset($this->systab->config))){ - - $this->dn= $this->terminals[$s_entry]['dn']; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Find out more about the object type */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('objectClass','gotoMode')); - $attrs= $ldap->fetch(); - $type= $this->get_system_type($attrs); - - /* Lock the current entry, so everyone will get the - above dialog */ - $tabs = array( - "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal"), - "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation"), - "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server"), - "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer"), - "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone"), - "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation"), - "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component")); - - - if($type == "ArpNewDevice"){ - $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn); - }elseif($type == "NewDevice"){ - $this->systab = new SelectDeviceType($this->config,$this->dn) ; - }elseif(isset($tabs[$type])){ - - $class = $tabs[$type]["CLASS"]; - $acl_cat = $tabs[$type]["ACL"]; - $tabclass = $tabs[$type]["TABCLASS"]; - - $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$acl_cat); - $this->systab->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; - add_lock ($this->dn, $this->ui->dn); - }else{ - print_red (_("You can't edit this object type yet!")); - del_lock($this->dn); - } - } - - - /******************** - Change password ... - ********************/ - - /* Set terminals root password */ - if ($s_action=="change_pw"){ - $tabs = array( - "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"), - "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation")); - - $type = $this->get_system_type($this->terminals[$s_entry]); - $class = $tabs[$type]["CLASS"]; - $tabname = $tabs[$type]["TABNAME"]; - $acl_cat = $tabs[$type]["ACL"]; - $tabclass = $tabs[$type]["TABCLASS"]; - $ui = get_userinfo(); - $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd"); - if(preg_match("/w/",$tabacl)){ - $this->dn= $this->terminals[$s_entry]['dn']; - $_SESSION['objectinfo']= $this->dn; - return ($smarty->fetch(get_template_path('password.tpl', TRUE))); - }else{ - print_red(_("You are not allowed to change the password for this object.")); - } - } - - - /******************** - Password change finish, but check if entered data is ok - ********************/ - - /* Correctly specified? */ - if (isset($_POST['password_finish'])){ - if ($_POST['new_password'] != $_POST['repeated_password']){ - print_red (_("Passwords entered as new and repeated do not match!")); - return($smarty->fetch(get_template_path('password.tpl', TRUE))); - } - } - - /******************** - Password change finish - ********************/ - - /* Change terminal password */ - if (isset($_POST['password_finish']) && - $_POST['new_password'] == $_POST['repeated_password']){ - - /* Check if user is allowed to set password */ - $tabs = array( - "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"), - "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation")); - - /* Detect object type */ - $type = ""; - foreach($this->terminals as $terminal){ - if($terminal['dn'] == $this->dn){ - $type = $this->get_system_type($terminal); - break; - } - } - - /* Type detected */ - if(!empty($type)){ - - /* Get infos */ - $class = $tabs[$type]["CLASS"]; - $tabname = $tabs[$type]["TABNAME"]; - $acl_cat = $tabs[$type]["ACL"]; - $tabclass = $tabs[$type]["TABCLASS"]; - - /* Get acls */ - $ui = get_userinfo(); - $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd"); - - /* Check acls */ - if(preg_match("/w/",$tabacl)){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dn); - - $attrs= array(); - if ($_POST['new_password'] == ""){ - $attrs['gotoRootPasswd']= array(); - } else { - $attrs['gotoRootPasswd']= crypt($_POST['new_password'],substr(session_id(),0,2)); - } - $ldap->modify($attrs); - new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error()); - }else{ - print_red(_("You are not allowed to change the password for this object.")); - } - }else{ - print_red(_("Can't detect object to change password.")); - } - unset($_SESSION['objectinfo']); - } - - - /******************** - Delete system cancel - ********************/ - - /* Delete terminal canceled? */ - if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){ - del_lock ($this->dn); - unset($_SESSION['objectinfo']); - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $this->dns = array(); - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->terminals[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("warning", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("warning", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); - } - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_system_confirm'])){ - - $ui = get_userinfo(); - $tabs = array( - "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"), - "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"), - "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"), - "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"), - "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"), - "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"), - "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric")); - - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - /* Get 'dn' from posted termlinst */ - $attrs = $this->terminals[$key]; - $type= $this->get_system_type($attrs); - - /* get object type */ - $tabtype = "termtabs"; - $tabobj = "TERMTABS"; - $tabacl = ""; - if(isset($tabs[$type])){ - $tabtype = $tabs[$type]['TABCLASS']; - $tabobj = $tabs[$type]['CLASS']; - $tabacl = $ui->get_permissions($dn,$tabs[$type]['ACL']); - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - if(preg_match("/d/",$tabacl)){ - - /* Delete request is permitted, perform LDAP action */ - if($tabtype=="phonetabs"){ - $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type); - $this->systab->set_acl_base($dn); - $this->systab->by_object['phoneGeneric']->remove_from_parent (); - }else{ - $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $dn,$type); - $this->systab->set_acl_base($dn); - $this->systab->delete(); - } - unset ($this->systab); - $this->systab= NULL; - - } else { - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this component!")); - new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - } - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_system_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete system, confirm dialog - ********************/ - - /* Remove terminal was requested */ - if ($s_action=="del"){ - - /* Get 'dn' from posted termlinst */ - $this->dn = $this->terminals[$s_entry]['dn']; - $attrs = $this->terminals[$s_entry]; - - $type= $this->get_system_type($attrs); - $ui = get_userinfo(); - $tabs = array( - "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"), - "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"), - "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"), - "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"), - "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"), - "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"), - "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric")); - - - /* get object type */ - $tabtype = "termtabs"; - $tabobj = "TERMTABS"; - $tabacl = ""; - if(isset($tabs[$type])){ - $tabtype = $tabs[$type]['TABCLASS']; - $tabobj = $tabs[$type]['CLASS']; - $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']); - } - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - if(preg_match("/d/",$tabacl)){ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), @LDAP::fix($this->dn))); - $smarty->assign("multiple", false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this component!")); - } - } - - - /******************** - Delete system, confirmed - ********************/ - /* Confirmation for deletion has been passed. Terminal should be deleted. */ - if (isset($_POST['delete_terminal_confirm'])){ - - /* Find out more about the object type */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('objectClass')); - $attrs= $ldap->fetch(); - $type= $this->get_system_type($attrs); - - $ui = get_userinfo(); - - $tabs = array( - "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"), - "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"), - "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"), - "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"), - "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"), - "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"), - "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric")); - - /* get object type */ - $tabtype = "termtabs"; - $tabobj = "TERMTABS"; - $tabacl = ""; - if(isset($tabs[$type])){ - $tabtype = $tabs[$type]['TABCLASS']; - $tabobj = $tabs[$type]['CLASS']; - $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']); - } - - /* Check if we are allowed to remove this object */ - if(preg_match("/d/",$tabacl)){ - - /* Delete request is permitted, perform LDAP action */ - if($tabtype=="phonetabs"){ - $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $this->dn,$type); - $this->systab->set_acl_base($this->dn); - $this->systab->by_object['phoneGeneric']->remove_from_parent (); - }else{ - $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $this->dn,$type); - $this->systab->set_acl_base($this->dn); - $this->systab->delete(); - } - unset ($this->systab); - $this->systab= NULL; - - /* Terminal list has changed, reload it. */ - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this component!")); - new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - - - - - - - - - /******************** - Edit system type finished, check if everything went ok - ********************/ - /* Finish user edit is triggered by the tabulator dialog, so - the user wants to save edited data. Check and save at this - point. */ - if ((isset($_POST['edit_finish'])) && (isset($this->systab->config)) || $save_object_directly){ - - /* Check tabs, will feed message array */ - $message = array(); - if(!$save_object_directly){ - $message = $this->systab->check(); - }else{ - $found = false; - - /* Set gotoMode to active if we there was an ogroup selected . (save_object_directly) */ - foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"graphic") as $tab => $value){ - if(isset($this->systab->by_object[$tab]->gotoMode)) { - $found = true; - $this->systab->by_object[$tab]->gotoMode = $value; - } - } - if(!$found){ - print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified."))); - } - - } - /* Save, or display error message? */ - if (count($message) == 0){ - - /* Incoming behavior; you can select a system type and an ogroup membership. - * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset. - * Check if we must add the new object to an object group. - * - * If this is done, delete the old incoming entry... it is still there, because this is a new - * entry and not an edited one, so we will delete it. - * - */ - - if(isset($_SESSION['SelectedSystemType'])){ - $SelectedSystemType= $_SESSION['SelectedSystemType']; - if($SelectedSystemType['ogroup'] != "none"){ - $og = new ogroup($this->config,$SelectedSystemType['ogroup']); - if($og){ - $og->AddDelMembership($this->systab->dn); - $og->save(); - } - } - } - - /* Save terminal data to ldap */ - if(isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){ - foreach (array("workservice", "termservice") as $cls){ - if (isset($this->systab->by_object[$cls])){ - $this->systab->by_object[$cls]->gotoXMouseport= ""; - $this->systab->by_object[$cls]->gotoXMouseType= ""; - $this->systab->by_object[$cls]->gotoXResolution= ""; - $this->systab->by_object[$cls]->gotoXColordepth= ""; - } - } - } - - $this->systab->save(); - - if(isset($_SESSION['SelectedSystemType'])){ - unset($_SESSION['SelectedSystemType']); - if(!isset($ldap)){ - $ldap = $this->config->get_ldap_link(); - } - $ldap->cd ($this->dn); - $ldap->cat($this->dn, array('dn')); - if(count($ldap->fetch())){ - $ldap->cd($this->dn); - $ldap->rmDir($this->dn); - } - $ldap->cd($this->config->current['BASE']); - } - - /* Terminal has been saved successfully, remove lock from - LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - - unset ($this->systab); - $this->systab= NULL; - unset($_SESSION['objectinfo']); - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /******************** - Edit system was canceled - ********************/ - /* Cancel dialogs */ - if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){ - if (isset($this->systab)){ - del_lock ($this->systab->dn); - unset ($this->systab); - } - $this->systab= NULL; - unset($_SESSION['objectinfo']); - - /* Remove ogroup selection, which was set while editing a new incoming entry */ - if(isset($_SESSION['SelectedSystemType'])){ - unset($_SESSION['SelectedSystemType']); - } - } - - /******************** - Display edit dialog, or some other - ********************/ - - /* Show tab dialog if object is present */ - if (isset($this->systab->config)){ - $display= $this->systab->execute(); - - /* Don't show buttons if tab dialog requests this */ - - $dialog = FALSE; - $hide_apply = $this->dn == "new"; - if(is_object($this->systab) && !isset($this->systab->by_object)){ - $dialog = TRUE; - $hide_apply = TRUE; - }elseif(isset($this->systab->by_object[$this->systab->current]->dialog)){ - $dia = $this->systab->by_object[$this->systab->current]->dialog; - if($dia === TRUE || is_object($dia)){ - $dialog = TRUE; - } - } - if(isset($this->systab->by_object[$this->systab->current]->netConfigDNS) && - $this->systab->by_object[$this->systab->current]->netConfigDNS->dialog){ - $dialog = TRUE; - } - - if (!$dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if (!$hide_apply){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - return ($display); - } - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListSystem->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Display dialog with system list */ - $this->DivListSystem->parent = $this; - $this->DivListSystem->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListSystem->SubSearch){ - $this->DivListSystem->AddDepartments($this->DivListSystem->selectedBase,3,1); - } - $this->reload(); - $this->DivListSystem->setEntries($this->terminals); - return($this->DivListSystem->Draw()); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - $tmp = array(); - - /* Check acls, if we are not allowed to create and write each plugin tab, skip this object */ - - $tabs = array( - "terminal" => "ou=terminals,ou=systems,", - "workstation" => "ou=workstations,ou=systems,", - "incoming" => "ou=incoming,", - "server" => "ou=servers,ou=systems,", - "printer" => "ou=printers,ou=systems,", - "phone" => "ou=phones,ou=systems,", - "winworkstation" => get_winstations_ou(), - "component" => "ou=netdevices,ou=systems," - ); - - foreach($tabs as $acl_cat => $dn){ - - $acl_all = $this->ui->has_complete_category_acls($dn.$this->DivListSystem->selectedBase,$acl_cat); - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $tmp[] = $dn.$this->DivListSystem->selectedBase; - } - } - return($tmp); - } - - - function remove_from_parent() - { - /* Optionally execute a command after we're done */ - $this->postremove(); - } - - - /* Save data to object */ - function save_object() - { - $this->DivListSystem->save_object(); - } - - - /* Check values */ - function check() - { - } - - - /* Save to LDAP */ - function save() - { - } - - function adapt_from_template($dn) - { - } - - function password_change_needed() - { - } - - function reload() - { - /* some var init */ - $ui = get_userinfo(); - $res = array(); - $this->terminals = array(); - $userregex = ""; - - /* Set base for all searches */ - $base= $this->DivListSystem->selectedBase; - - /* Prepare samba class name */ - $samba =""; - if ($this->DivListSystem->ShowWinWorkstations){ - if ($this->config->current['SAMBAVERSION'] == "3"){ - $samba= "sambaSamAccount"; - } else { - $samba= "sambaAccount"; - } - } - - /* This array represents the combination between checkboxes and search filters */ - $objs = array( "ShowServers" => array("CLASS" => "goServer" ,"TREE" => "ou=servers,ou=systems," ), - "ShowTerminals" => array("CLASS" => "gotoTerminal" ,"TREE" => "ou=terminals,ou=systems,"), - "ShowPrinters" => array("CLASS" => "gotoPrinter" ,"TREE" => "ou=printers,ou=systems," ), - "ShowDevices" => array("CLASS" => "ieee802Device" ,"TREE" => "ou=netdevices,ou=systems," ), - "ShowPhones" => array("CLASS" => "goFonHardware" ,"TREE" => "ou=phones,ou=systems," ), - "ShowWorkstations" => array("CLASS" => "gotoWorkstation" ,"TREE" => "ou=workstations,ou=systems," ), - "ShowWinWorkstations"=> array("CLASS" => $samba ,"TREE" => get_winstations_ou() )); - - /* Include the 'Display Systems of user' attribute */ - if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){ - $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")"; - } - - /* Attributes to fetch */ - $sys_attrs = array("cn", "description", "macAddress", "objectClass", "sambaDomainName","gotoMode"); - $sys_categories = array("terminal", "workstation", "server", "phone" ,"printer"); - - /* Add FAIstate to attributes if FAI is activated */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - $sys_attrs[] = "FAIstate"; - } - - /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled */ - foreach($objs as $checkBox => $oc){ - if($this->DivListSystem->$checkBox){ - if($this->DivListSystem->SubSearch){ - if($oc['CLASS'] != ""){ - $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))"; - $new_res = get_list($filter, $sys_categories , $base,$sys_attrs, GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT); - - /* Remove all objects that are not in the expected sub department */ - foreach($new_res as $key => $obj){ - if(preg_match("/^[^,]+,".normalizePreg($oc['TREE'])."/",$obj['dn'])){ - $res[$obj['dn']] = $obj; - } - } - } - }else{ - /* User filter? */ - if($oc['CLASS'] != ""){ - $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))"; - $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs, GL_NONE | GL_SIZELIMIT)); - } - } - } - } - - /* Search for incoming objects */ - $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))"; - $res = array_merge($res,get_list($filter,$sys_categories,"ou=incoming,".$base,$sys_attrs, GL_NONE | GL_SIZELIMIT)); - - /* Get all gotoTerminal's */ - foreach ($res as $value){ - - $tmp= $value['dn']; - $add= ""; - - /* Extract base */ - foreach($objs as $obj){ - if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){ - $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn'])); - } - } - - /* Create a string containing the last part of the department. */ - $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp))); - if(empty($dn_name)){ - $dn_name = "/"; - } - - /* check if current object is a new one */ - if (preg_match ("/,ou=incoming,/i", $tmp)){ - if (in_array_ics('gotoTerminal', $value['objectClass'])){ - $add= "- "._("New terminal"); - }elseif (in_array_ics('gotoWorkstation', $value['objectClass'])){ - $add= "- "._("New workstation"); - }elseif (in_array_ics('GOhard', $value['objectClass']) && !isset($value['gotoMode'])){ - $add= "- "._("Unknown device"); - }elseif (in_array_ics('GOhard', $value['objectClass'])){ - $add= "- "._("New Device"); - } - } - - /* Detect type of object and create an entry for $this->terminals */ - $terminal = array(); - - if (in_array_ics('gotoTerminal', $value["objectClass"])){ - - /* check acl */ - $acl = $ui->get_permissions($value['dn'],"terminal/termgeneric"); - if($add != "" || preg_match("/r/",$acl)) { - if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){ - $terminal = $value; - $terminal['type'] = "T"; - $terminal['is_new'] = $add; - } else { - $terminal = $value; - $terminal['type'] = "D"; - $terminal['message'] = _("Terminal template for")." '".$dn_name."' "; - $terminal['location'] = array_search($tmp, $this->config->departments); - } - } - } elseif (in_array_ics('gotoWorkstation', $value["objectClass"])){ - - $acl = $ui->get_permissions($value['dn'],"workstation/workgeneric"); - if($add != "" || preg_match("/r/",$acl)) { - if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){ - $terminal = $value; - $terminal['type'] = "L"; - $terminal['is_new'] = $add; - } else { - $terminal = $value; - $terminal['type'] = "D"; - $terminal['location'] = array_search($tmp, $this->config->departments); - $terminal['message'] = _("Workstation template for")." '".$dn_name."' "; - } - if (isset($value["FAIstate"][0])){ - $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]); - } - } - } elseif (in_array_ics('gotoPrinter', $value["objectClass"])){ - - - $acl = $ui->get_permissions($value['dn'],"printer/printgeneric"); - if($add != "" || preg_match("/r/",$acl)) { - - $terminal = $value; - $terminal['type'] = "P"; - } - } elseif (in_array_ics('goServer', $value["objectClass"])){ - - $acl = $ui->get_permissions($value['dn'],"server/servgeneric"); - if($add != "" || preg_match("/r/",$acl)) { - - $terminal = $value; - $terminal['type'] = "S"; - if (isset($value["FAIstate"][0])){ - $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]); - } - } - } elseif (in_array_ics('goFonHardware', $value["objectClass"])){ - - $acl = $ui->get_permissions($value['dn'],"phone/phoneGeneric"); - if($add != "" || preg_match("/r/",$acl)) { - - $terminal = $value; - $terminal['type'] = "F"; - } - }elseif (in_array_ics("GOhard",$value['objectClass'])){ - - $acl = $ui->get_permissions($value['dn'],"server/servgeneric"). - $ui->get_permissions($value['dn'],"terminal/termgeneric"). - $ui->get_permissions($value['dn'],"workstation/workgeneric"); - if($add != "" || preg_match("/r/",$acl)) { - - $terminal = $value; - $terminal['type'] = "Q"; - $terminal['is_new'] = $add; - } - } elseif (in_array_ics('ieee802Device', $value["objectClass"])){ - - $acl = $ui->get_permissions($value['dn'],"component/componentGeneric"); - if($add != "" || preg_match("/r/",$acl)) { - - $terminal = $value; - $terminal['type'] = "C"; - } - } else{ - - $name= preg_replace('/\$$/', '', $value['cn'][0]); - if (isset($value['sambaDomainName'])){ - $domain= " [".$value['sambaDomainName'][0]."]"; - } else { - $domain= ""; - } - $terminal=$value; - $terminal['type'] ="W"; - $terminal['domain'] = $name.$domain; - } - - if(count($terminal)){ - $this->terminals[]=$terminal; - } - } - - $tmp=array(); - foreach($this->terminals as $tkey => $val ){ - $tmp[strtolower($val['cn'][0]).$val['dn']]=$val; - } - ksort($tmp); - $this->terminals=array(); - foreach($tmp as $val){ - $this->terminals[]=$val; - } - reset ($this->terminals); - } - - function remove_lock() - { - if (isset($this->systab->dn)){ - del_lock ($this->systab->dn); - } - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - - $tabs = array( - "terminal" => array( "CLASS" =>"TERMTABS", "TABNAME" =>"termgeneric", - "TABCLASS" =>"termtabs", "ACL" =>"terminal"), - "workstation" => array( "CLASS" =>"WORKTABS", "TABNAME" =>"workgeneric", - "TABCLASS" =>"worktabs", "ACL" =>"workstation"), - "server" => array( "CLASS" =>"SERVTABS", "TABNAME" =>"servgeneric", - "TABCLASS" =>"servtabs", "ACL" =>"server"), - "printer" => array( "CLASS" =>"PRINTTABS", "TABNAME" =>"printgeneric", - "TABCLASS" =>"printtabs", "ACL" =>"printer"), - "phone" => array( "CLASS" =>"PHONETABS", "TABNAME" =>"phoneGeneric", - "TABCLASS" =>"phonetabs", "ACL" =>"phone"), - "component" => array( "CLASS" =>"COMPONENTTABS","TABNAME" =>"componentGeneric", - "TABCLASS" =>"componenttabs","ACL" =>"component")); - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->terminals[$s_entry]['dn']; - $oc = $this->terminals[$s_entry]['objectClass']; - $type = $this->get_system_type($this->terminals[$s_entry]); - - $tab_o = $tabs[$type]['CLASS']; - $tab_c = $tabs[$type]['TABCLASS']; - $acl = $tabs[$type]['ACL']; - - $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->terminals[$id]['dn']; - $oc = $this->terminals[$id]['objectClass']; - $type = $this->get_system_type($this->terminals[$id]); - - if(isset($tabs[$type])){ - $tab_o = $tabs[$type]['CLASS']; - $tab_c = $tabs[$type]['TABCLASS']; - $acl = $tabs[$type]['ACL']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl); - } - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - function get_system_type($attrs) - { - $classes = $attrs['objectClass']; - - $type= ""; - if (in_array_ics('ieee802Device', $classes)){ - $type= "component"; - }elseif (in_array_ics('gotoTerminal', $classes)){ - $type= "terminal"; - }elseif (in_array_ics('gotoWorkstation', $classes)){ - $type= "workstation"; - }elseif (in_array_ics('gotoPrinter', $classes)){ - $type= "printer"; - }elseif (in_array_ics('goFonHardware', $classes)){ - $type= "phone"; - }elseif (in_array_ics('goServer', $classes)){ - $type= "server"; - }elseif (in_array_ics('GOhard', $classes) && !isset($attrs['gotoMode']) && $this->arp_handling_active){ - $type= "ArpNewDevice"; - }elseif (in_array_ics('GOhard', $classes)){ - $type= "NewDevice"; - }elseif (in_array_ics('sambaAccount', $classes) || - in_array_ics('sambaSamAccount', $classes)){ - $type= "winstation"; - } - return ($type); - } - - - function convert_list($input) - { - $temp= ""; - $conv= array( - "NQ" => array("select_newsystem.png",_("New System from incoming")), - "D" => array("select_default.png",_("Template")), - "T" => array("select_terminal.png",_("Terminal")), - "L" => array("select_workstation.png",_("Workstation")), - "GL" => array("select_workstation_green.png",_("Workstation is installing")), - "YL" => array("select_workstation_yellow.png",_("Workstation is waiting for action")), - "RL" => array("select_workstation_red.png",_("Workstation installation failed")), - "F" => array("select_phone.png",_("Phone")), - "S" => array("select_server.png",_("Server")), - "GS" => array("select_server_green.png",_("Server is installing")), - "YS" => array("select_server_yellow.png",_("Server is waiting for action")), - "RS" => array("select_server_red.png",_("Server installation failed")), - "W" => array("select_winstation.png",_("Winstation")), - "C" => array("select_component.png",_("Network Device")), - "NT"=> array("select_new_terminal.png",_("New Terminal")), - "NL"=> array("select_new_workstation.png",_("New Workstation")), - "P" => array("select_printer.png",_("Printer"))); - - if((isset($input['is_new']))&&(!empty($input['is_new']))){ - $input['type']="N".$input['type']; - } - foreach ($conv as $key => $value){ - if($input['type']==$key){ - $tmp['img'] ="".$key.""; - $tmp['class']=$key; - return $tmp; - } - } - } - - - function getState($type, $state) - { - switch (preg_replace('/:.*$/', '', $state)) { - case 'installing': - $type= 'G'.$type; - break; - case 'error': - $type= 'R'.$type; - break; - case 'install': - case 'sysinfo': - case 'softupdate': - case 'scheduledupdate': - $type= 'Y'.$type; - break; - } - - - return ($type); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - /* !! Incoming dummy acls, required to defined acls for incoming objects - */ - static function plInfo() - { - return (array( - "plShortName" => _("Incoming objects"), - "plDescription" => _("Incoming objects"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 99, - "plSection" => array("administration"), - "plCategory" => array("incoming" => array( "description" => _("Incoming"), - "objectClass" => "")), - "plProvidedAcls"=> array() - - )); - } - - - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc deleted file mode 100644 index be12d590e..000000000 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ /dev/null @@ -1,682 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $gotoMode= "disabled"; - var $gotoTerminalPath= ""; - var $gotoSwapServer= ""; - var $gotoSyslogServer= ""; - var $gotoSyslogServers = array(); - var $gotoNtpServer= array(); - var $gotoNtpServers= array(); - var $gotoSndModule= ""; - var $gotoFloppyEnable= ""; - var $gotoCdromEnable= ""; - var $ghCpuType= "-"; - var $ghMemSize= "-"; - var $ghUsbSupport= "-"; - var $ghNetNic= array(); - var $ghIdeDev= array(); - var $ghScsiDev= array(); - var $ghGfxAdapter= "-"; - var $ghSoundAdapter= "-"; - var $gotoLastUser= "-"; - var $netConfigDNS; - /* Needed values and lists */ - var $base= ""; - var $cn= ""; - var $orig_dn= ""; - - var $inheritTimeServer = true; - - /* Plugin side filled */ - var $modes= array(); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes= array("gotoMode", "gotoTerminalPath", - "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer", - "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule", - "ghCpuType", "ghMemSize","ghUsbSupport", - "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser"); - var $objectclasses= array("top", "gotoTerminal", "GOhard"); - - var $mapActions = array("reboot" => "", - "instant_update" => "softupdate", - "update" => "sceduledupdate", - "reinstall" => "install", - "rescan" => "", - "memcheck" => "memcheck", - "sysinfo" => "sysinfo"); - - var $fai_activated = FALSE; - var $view_logged = FALSE; - - var $member_of_ogroup = FALSE; - - function termgeneric (&$config, $dn= NULL, $parent= NULL) - { - /* Check if FAI is activated */ - $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - $this->fai_activated = TRUE; - } - - plugin::plugin ($config, $dn, $parent); - - if(!isset($this->parent->by_object['ogroup'])){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn")); - $this->member_of_ogroup = $ldap->count() >= 1; - } - - $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); - /* Read arrays */ - foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ - if (!isset($this->attrs[$val])){ - continue; - } - for ($i= 0; $i<$this->attrs[$val]['count']; $i++){ - array_push($this->$val, $this->attrs[$val][$i]); - } - } - - /* Create used ntp server array */ - $this->gotoNtpServer= array(); - if(isset($this->attrs['gotoNtpServer'])){ - $this->inheritTimeServer = false; - unset($this->attrs['gotoNtpServer']['count']); - foreach($this->attrs['gotoNtpServer'] as $server){ - $this->gotoNtpServer[$server] = $server; - } - } - - /* Set inherit checkbox state */ - if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){ - $this->inheritTimeServer = true; - $this->gotoNtpServer=array(); - } - - /* You can't inherit the NTP service, if we are not member in an object group */ - if(!$this->member_of_ogroup){ - $this->inheritTimeServer = FALSE; - } - - /* Create available ntp options */ - $this->gotoNtpServers = $this->config->data['SERVERS']['NTP']; - foreach($this->gotoNtpServers as $key => $server){ - if($server == "default"){ - unset($this->gotoNtpServers[$key]); - } - } - - $this->modes["disabled"]= _("disabled"); - $this->modes["text"]= _("text"); - $this->modes["graphic"]= _("graphic"); - - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } else { - $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); - } - - /* Create an array of all Syslog servers */ - $tmp = $this->config->data['SERVERS']['SYSLOG']; - foreach($tmp as $server){ - $visible = $server; - if($server == "default" && $this->member_of_ogroup) { - $visible = "["._("inherited")."]"; - } - $this->gotoSyslogServers[$server] = $visible; - } - - $this->orig_dn= $this->dn; - } - - function set_acl_base($base) - { - plugin::set_acl_base($base); - $this->netConfigDNS->set_acl_base($base); - } - - function set_acl_category($cat) - { - plugin::set_acl_category($cat); - $this->netConfigDNS->set_acl_category($cat); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","terminal/".get_class($this),$this->dn); - } - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){ - - /* Set FAIstate */ - if($this->fai_activated && $this->dn != "new"){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn,array("objectClass")); - $res = $ldap->fetch(); - - $attrs = array(); - $attrs['FAIstate'] = ""; - if(isset($this->mapActions[$_POST['saction']])){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } - - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } - - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } - - if($attrs['FAIstate'] == ""){ -#FIXME we should check if FAIobject is used anymore - $attrs['FAIstate'] = array(); - } - - $ldap->cd($this->dn); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/generic (FAIstate) with dn '%s' failed."),$this->dn)); - } - - switch($_POST['saction']){ - case 'wake': - $cmd= $this->config->search("termgeneric", "WAKECMD",array('tabs')); - - if ($cmd == ""){ - print_red(_("No WAKECMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$this->netConfigDNS->macAddress, $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } - } - break; - - case 'reboot': - $cmd= $this->config->search("termgeneric", "REBOOTCMD",array('tabs')); - if ($cmd == ""){ - print_red(_("No REBOOTCMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$this->cn, $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } - } - break; - - case 'halt': - $cmd= $this->config->search("termgeneric", "HALTCMD",array('tabs')); - if ($cmd == ""){ - print_red(_("No HALTCMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$this->cn, $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } - } - break; - } - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Do we represent a valid terminal? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no terminal features.").""; - return($display); - } - - /* Add new ntp Server to our list */ - if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){ - $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; - } - - /* Delete selected NtpServer for list of used servers */ - if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){ - foreach($_POST['gotoNtpServerSelected'] as $name){ - unset($this->gotoNtpServer[$name]); - } - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $smarty->assign("cn", $this->cn); - $smarty->assign("staticAddress", ""); - - $smarty->assign("bases", $this->get_allowed_bases()); - - /* tell smarty the inherit checkbox state */ - $smarty->assign("inheritTimeServer",$this->inheritTimeServer); - - /* Check if terminal is online */ - $query= "fping -q -r 1 -t 500 ".$this->cn; - exec ($query, $dummy, $retval); - - /* Offline */ - if ($retval == 0){ - $smarty->assign("actions", array( "halt" => _("Switch off"), - "reboot" => _("Reboot"), - "memcheck" => _("Memory test"), - "sysinfo" => _("System analysis"))); - } else { - $smarty->assign("actions", array("wake" => _("Wake up"), - "memcheck" => _("Memory test"), - "sysinfo" => _("System analysis"))); - } - - /* Arrays */ - $smarty->assign("modes", $this->modes); - - $tmp2 = array(); - foreach($this->config->data['SERVERS']['NFS'] as $server){ - if($server != "default"){ - $tmp2[$server]= $server; - }else{ - if($this->member_of_ogroup){ - $tmp2[$server]="["._("inherited")."]"; - } - } - } - - $smarty->assign("nfsservers", $tmp2); - $smarty->assign("syslogservers", $this->gotoSyslogServers); - - $tmp = array(); - foreach($this->gotoNtpServers as $server){ - if(!in_array($server,$this->gotoNtpServer)){ - $tmp[$server] = $server; - } - } - - $smarty->assign("ntpservers", $tmp); - $smarty->assign("fai_activated",$this->fai_activated); - - /* Variables */ - foreach(array("base", "gotoMode", "gotoTerminalPath", "gotoSwapServer","gotoSyslogServer", "gotoNtpServer") as $val){ - $smarty->assign($val."_select", $this->$val); - } - - $smarty->assign("member_of_ogroup",$this->member_of_ogroup); - - /* Show main page */ - $str = $this->netConfigDNS->execute(); - if(is_object($this->netConfigDNS->dialog)){ - return($str); - } - $smarty->assign("netconfig", $str); - return($smarty->fetch (get_template_path('terminal.tpl', TRUE))); - } - - function remove_from_parent() - { - if($this->acl_is_removeable()){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $ldap->cat($this->dn, array('dn')); - if($ldap->count()){ - $this->netConfigDNS->remove_from_parent(); - $ldap->rmDir($this->dn); - - new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of object system terminal/generic with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - } - } - } - - - /* Save data to object */ - function save_object() - { - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - - $this->netConfigDNS->save_object(); - - /* Save terminal path to parent since it is used by termstartup, too */ - if(isset($this->parent->by_object['termstartup'])){ - $this->parent->by_object['termstartup']->gotoTerminalPath= $this->gotoTerminalPath; - } - - if(isset($_POST['termgeneric_posted'])){ - if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){ - $this->inheritTimeServer = true; - }else{ - $this->inheritTimeServer = false; - } - } - - if(isset($_POST["inheritAll"])){ - $this->set_everything_to_inherited(); - } - - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Skip IP & Mac checks if this is a template */ - if($this->cn != "default"){ - $message= array_merge($message, $this->netConfigDNS->check()); - } - - /* Permissions for that base? */ - $this->dn= "cn=".$this->cn.",ou=terminals,ou=systems,".$this->base; - - if ($this->cn == ""){ - $message[]= _("The required field 'Terminal name' is not set."); - } - - /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn) ){ - $message[] = _("Please specify a valid name for this object."); - } - - if ($this->orig_dn == 'new'){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); - - /* It is possible to have a 'default' terminal on every base */ - if($this->cn == "default"){ - $ldap->cat($this->dn); - }else{ - $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn")); - } - if ($ldap->count() != 0){ - while ($attrs= $ldap->fetch()){ - if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,ou=incoming,/", $ldap->getDN())){ - continue; - } else { - if ($attrs['dn'] != $this->orig_dn){ - $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); - break; - } - } - } - } - } - - /* Check for valid ntpServer selection */ - if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){ - $message[]= _("There must be at least one NTP server selected, or the inherit mode activated."); - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - - /* Move object if requested */ - if( $this->orig_dn != 'new' && $this->dn != $this->orig_dn){ - $this->move($this->orig_dn, $this->dn); - } - - plugin::save(); - - /* Strip out 'default' values */ - foreach (array("gotoTerminalPath", "gotoSwapServer", "gotoSyslogServer") as $val){ - if(isset($this->attrs[$val])){ - if ($this->attrs[$val] == "default"){ - $this->attrs[$val]= array(); - } - } - } - - /* Add missing arrays */ - foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){ - if (isset ($this->$val) && count ($this->$val) != 0){ - $this->attrs["$val"]= $this->$val; - } - } - - /* Remove all empty values */ - if ($this->orig_dn == 'new'){ - $attrs= array(); - foreach ($this->attrs as $key => $val){ - if (is_array($val) && count($val) == 0){ - continue; - } - $attrs[$key]= $val; - } - $this->attrs= $attrs; - } - - /* Set ntpServers */ - $this->attrs['gotoNtpServer'] = array(); - if(!$this->inheritTimeServer){ - foreach($this->gotoNtpServer as $server){ - $this->attrs['gotoNtpServer'][] = $server; - } - } - - /* Append gosaAdministrativeUnitTag to objectClass if gosaUnitTag isset */ - if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){ - $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - if ($this->orig_dn == 'new'){ - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - if (!count($this->attrs['gotoNtpServer'])){ - unset($this->attrs['gotoNtpServer']); - } - $ldap->add($this->attrs); - new log("create","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } else { - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } - - /* cn=default and macAddress=- indicates that this is a template */ - if($this->cn == "default"){ - $this->netConfigDNS->macAddress = "-"; - } - - $this->netConfigDNS->cn = $this->cn; - $this->netConfigDNS->save(); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/generic with dn '%s' failed."),$this->dn)); - } - - - - - - /* Display generic part for server copy & paste */ - function getCopyDialog() - { - $vars = array("cn"); - $smarty = get_smarty(); - $smarty->assign("cn" ,$this->cn); - $smarty->assign("object","terminal"); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - if(isset($source['macAddress'][0])){ - $this->netConfigDNS->macAddress = $source['macAddress'][0]; - } - if(isset($source['ipHostNumber'][0])){ - $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; - } - - /* Create used ntp server array */ - $this->gotoNtpServer= array(); - if(isset($source['gotoNtpServer'])){ - $this->inheritTimeServer = false; - unset($source['gotoNtpServer']['count']); - foreach($source['gotoNtpServer'] as $server){ - $this->gotoNtpServer[$server] = $server; - } - } - - /* Set inherit checkbox state */ - if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){ - $this->inheritTimeServer = true; - $this->gotoNtpServer=array(); - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Terminal"), - "plDescription" => _("Terminal generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => array("terminal" => array( "description" => _("Terminal"), - "objectClass" => "gotoTerminal")), - "plProvidedAcls"=> array( - "gotoMode" => _("Mode"), - "gotoTerminalPath" => _("Root server"), - "gotoSwapServer" => _("Swap server"), - "gotoSyslogServer" => _("Syslog server enabled"), - "gotoNtpServer" => _("Ntp server settings"), - "base" => _("Base"), - "cn" => _("Name"), - "gotoRootPasswd" => _("Root password"), - "FAIstate" => _("Action flag")) - )); - } - - - function set_everything_to_inherited() - { - $this->gotoTerminalPath = "default"; - $this->gotoSwapServer = "default" ; - $this->gotoSyslogServer = "default"; - $this->inheritTimeServer = TRUE; - - /* Set workstation service attributes to inherited */ - if($this->member_of_ogroup && isset($this->parent->by_object['termservice'])){ - foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant", - "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){ - $this->parent->by_object['termservice']->$name = "default"; - } - } - - /* Set workstation startup attributes to inherited */ - if($this->member_of_ogroup && isset($this->parent->by_object['termstartup'])){ - $this->parent->by_object['termstartup']->gotoBootKernel = "default-inherited"; - $this->parent->by_object['termstartup']->gotoLdapServer = "default-inherited"; - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_terminalInfo.inc b/plugins/admin/systems/class_terminalInfo.inc deleted file mode 100644 index 0a21884d2..000000000 --- a/plugins/admin/systems/class_terminalInfo.inc +++ /dev/null @@ -1,255 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $ghCpuType= "-"; - var $ghMemSize= "-"; - var $macAddress= "-"; - var $ghUsbSupport= "-"; - var $ghNetNic= array(); - var $ghIdeDev= array(); - var $ghScsiDev= array(); - var $ghGfxAdapter= "-"; - var $ghSoundAdapter= "-"; - var $ghInventoryNumber= "-"; - var $gotoLastUser= "-"; - var $gotoFloppyEnable= ""; - var $gotoCdromEnable= ""; - - /* Needed values and lists */ - var $base= ""; - var $cn= ""; - var $view_logged = FALSE; - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes= array("cn", "gotoMode", "gotoTerminalPath", "gotoFloppyEnable", - "gotoCdromEnable", "ghInventoryNumber", - "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer", - "ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport", - "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser"); - var $objectclasses= array("GOhard"); - - function terminfo (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config,$dn); - - /* Read arrays */ - foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ - if (!isset($this->attrs[$val])){ - continue; - } - for ($i= 0; $i<$this->attrs[$val]['count']; $i++){ - array_push($this->$val, $this->attrs[$val][$i]); - } - } - - /* Fix USB entry */ - if ($this->ghUsbSupport == "true"){ - $this->ghUsbSupport= _("present"); - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","terminal/".get_class($this),$this->dn); - } - - /* Do we represent a valid terminal? */ - if (!$this->is_account && $this->parent === NULL){ - echo "\"\" ". - _("This 'dn' has no terminal features.").""; - return; - } - - $smarty= get_smarty(); - $display= ""; - if(!is_callable("snmpget")){ - print_red(_("There is no php snmp module installed, can't gather any informations.")); - - $smarty->assign("load", progressbar(0,100,15,true)); - $smarty->assign("mem", progressbar(0,100,15,true)); - $smarty->assign("swap", progressbar(0,100,15,true)); - foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd","status","ghNetNic", "ghIdeDev", "ghScsiDev","FloppyDevice", "CdromDevice","active") as $val){ - $smarty->assign("$val", ""._("unknown status").""); - } - - - $display =""; - }else - /* Default entry? */ - if ($this->cn == "default"){ - $display= "

"; - $display.= _("This is a virtual terminal which has no properties to show here."); - $display.= "
"; - } else { - - /* Get template object */ - $smarty->assign("staticAddress", ""); - - /* Prevent undefined variable .... */ - $smarty->assign("load", progressbar(0,100,15,true)); - $smarty->assign("mem", progressbar(0,100,15,true)); - $smarty->assign("swap", progressbar(0,100,15,true)); - - /* Check if terminal is online */ - $query= "fping -q -r 1 -t 500 ".$this->cn; - exec ($query, $dummy, $retval); - - if ($retval == 0){ - $smarty->assign("status", _("online")); - $smarty->assign("active", "true"); - - /* Fill data if we have snmp */ - $host= $this->cn; - - /* Use 'goto' as snmp community or the configured value from the config */ - $community= 'goto'; - $str = search_config($this->config->data['TABS'],"terminfo","SNMPCOMMUNITY"); - if(!empty($str)){ - $community = $str; - } - - /* Get memory informations */ - if(!is_callable("snmpget")){ - $MemFree = false; - }else{ - $MemFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailReal.0"); - } - if ($MemFree != FALSE){ - $MemFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemFree); - $MemTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalReal.0"); - $MemTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemTotal); - if ($MemTotal != 0){ - $smarty->assign("mem",progressbar( (int)(($MemTotal - $MemFree)*100/$MemTotal),100,15,true)); - ; - } - $SwapFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailSwap.0"); - $SwapFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapFree); - $SwapTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalSwap.0"); - $SwapTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapTotal); - if ($SwapTotal != 0){ -#$smarty->assign("swap", (int)(($SwapTotal - $SwapFree)*100/$SwapTotal)); - $smarty->assign("swap", progressbar(0,100,15,true)); - } - - /* Get system uptime */ - $sysup= @snmpget($host, $community, "SNMPv2-MIB::sysUpTime.0"); - $smarty->assign("uptime", preg_replace('/^.* ([0-9:]+)\..*$/', '\\1', $sysup)); - - /* Get system load */ - $sysload= @snmpget($host, $community, "UCD-SNMP-MIB::laLoad.2"); - $sysload= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $sysload); - - $smarty->assign("load", progressbar($sysload*100,100,15,true)); - - /* Get status for key processes */ - $processes= @snmpwalk($host, $community, "UCD-SNMP-MIB::prNames"); - $check4= array("sshd", "cupsd", "artsd", "X", "saned"); - foreach ($check4 as $pname){ - $eflag= -1; - foreach ($processes as $key => $val){ - $process= preg_replace('/^.*[:=] (.*)$/', '\\1', $val); - if ($process == $pname){ - $index= preg_replace('/^.*\.([0-9]+) [:=] .*$/', '\\1', $val); - $res= @snmpget($host, $community, "UCD-SNMP-MIB::prErrorFlag.$index"); - $eflag= preg_replace('/^.*[:=] /', '', $res); - break; - } - } - switch ($eflag){ - case 0: - $smarty->assign("$pname", "\""._("running")."\""); - break; - case 1: - $smarty->assign("$pname", "\""._("not"); - break; - default: - $smarty->assign("$pname", _("not defined")); - } - } - } else { - foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd") as $val){ - $smarty->assign("$val", ""._("unknown status").""); - } - } - /* Check for mounted partitions (show max 8 partitions) */ - $partitions= ""; - for ($n= 1; $n<9; $n++){ - $device= @snmpget($host, $community, "UCD-SNMP-MIB::dskDevice.$n"); - if ($device == ""){ - break; - } - $device= preg_replace('/^STRING: */', '', $device); - $usage= @snmpget($host, $community, "UCD-SNMP-MIB::dskPercent.$n"); - $usage= preg_replace('/^INTEGER: */', '', $usage); - $partitions.= "$device".progressbar($usage,100,16,true)."\n"; - } - $smarty->assign("partitions", $partitions); - } else { - $smarty->assign("status", _("offline")); - $smarty->assign("active", "false"); - } - - /* Set floppy and cdrom status */ - foreach(array("Floppy", "Cdrom") as $val){ - $name= "goto".$val."Enable"; - if ($this->$name == "YES"){ - $status= _("present"); - } else { - $status= "-"; - } - $smarty->assign($val."Device", $status); - } - - /* Show main page */ - foreach(array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ - if (!count($this->$val)){ - $this->$val= "-"; - } - $smarty->assign($val, $this->$val); - } - } - foreach(array("ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport", - "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "ghInventoryNumber") as $val){ - - $smarty->assign($val, $this->$val); - } - $display= $smarty->fetch (get_template_path('info.tpl', TRUE)); - - return ($display); - } - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - } - - - /* Save to LDAP */ - function save() - { - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_terminalService.inc b/plugins/admin/systems/class_terminalService.inc deleted file mode 100644 index 49f804692..000000000 --- a/plugins/admin/systems/class_terminalService.inc +++ /dev/null @@ -1,527 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $gotoLpdEnable= FALSE; - var $gotoXMonitor= ""; - var $gotoXMethod= ""; - var $gotoXdmcpServer= ""; - var $gotoFontPath= ""; - var $gotoXDriver= ""; - var $gotoXResolution= ""; - var $gotoXColordepth= ""; - var $gotoXHsync= ""; - var $gotoXVsync= ""; - var $gotoXKbModel= ""; - var $gotoXKbLayout= ""; - var $gotoXKbVariant= ""; - var $gotoXMouseType= ""; - var $gotoXMouseport= ""; - var $gotoLpdServer= ""; - var $gotoScannerEnable= ""; - var $gotoScannerModel= ""; - var $gotoScannerClients= ""; - var $gotoScannerBackend= ""; - var $goFonHardware= "automatic"; - - var $AutoSync = false; - var $view_logged = FALSE; - - /* Needed values and lists */ - var $ignore_account= TRUE; - var $base= ""; - var $cn= ""; - var $orig_dn= ""; - var $XMethods= array(); - var $XDrivers= array(); - var $XResolutions= array(); - var $XColordepths= array(); - var $XKbModels= array (); - var $XKbLayouts= array (); - var $XKbVariants= array (); - var $MouseTypes= array(); - var $MousePorts= array(); - var $gotoScannerModels= array(); - var $hardware_list= array(); - var $used_hardware= array(); - - - /* attribute list for save action */ - var $attributes= array("cn", "gotoLpdEnable", "gotoXMonitor", "gotoXMethod", "gotoXdmcpServer", - "gotoFontPath", "gotoXDriver", "gotoXResolution", "gotoXColordepth", - "gotoXHsync", "gotoXVsync", "gotoLpdEnable", "gotoLpdServer", - "gotoScannerEnable", "gotoScannerModel", "gotoScannerClients", - "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant", - "gotoXMouseType", "gotoXMouseport", "goFonHardware"); - var $objectclasses= array("GOhard"); - - - function termservice (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - /* Get list of available xdrivers */ - $this->XDrivers = $this->getListOfXDrivers(); - array_unshift($this->XDrivers, "["._("unknown")."]"); - - $this->XResolutions= array( - "default" => "["._("inherited")."]" , - "640x480" => "640x480", - "800x600" => "800x600", - "1024x768" => "1024x768", - "1152x864" => "1152x864", - "1280x1024" => "1280x1024", - "1400x1050" => "1400x1050", - "1600x1200" => "1600x1200"); - - if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){ - $file = $this->config->data['MAIN']['RESOLUTION_HOOK']; - - if(is_readable($file)){ - $str = file_get_contents($file); - $lines = split("\n",$str); - foreach($lines as $line){ - $line = trim($line); - if(!empty($line)){ - $this->XResolutions[$line]=$line; - } - } - //natcasesort($this->gotoXResolutions); - }else{ - print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file)); - } - } - - $this->XColordepths= array( - "default" => "["._("inherited")."]", - "8" => "8 " ._("bit"), - "15" => "15 "._("bit"), - "16" => "16 "._("bit"), - "24" => "24 "._("bit")); - - $this->XKbModels['default']= "["._("inherited")."]"; - foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex", - "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless", - "logiinetnav", "logiinternet", "macintosh", "microsoft", - "microsoftpro", "omnikey101", "pc101", "pc102", "pc104", - "pc105", "rapidaccess", "rapidaccess2", "winbook") as $type){ - $this->XKbModels[$type] = $type; - } - - /* Additional values will be extracted from CONFIG_DIR.keyboardLayouts */ - $this->XKbLayouts= array ("default"=>"["._("inherited")."]","de"=> "de","intl" =>"intl","us" =>"us"); - $this->XKbVariants= array ("default"=>"["._("inherited")."]", "nodeadkeys"=>"nodeadkeys", "basic"=>"basic"); - - $this->MouseTypes= array( "AUTO" => "["._("inherited")."]" , "ImPS/2" => "ImPS/2", - "PS/2" => "PS/2" , "Microsoft" => "Microsoft", - "Logitech" => "Logitech"); - - $this->MousePorts= array("AUTO" =>"["._("inherited")."]" , "/dev/ttyS0" => "/dev/ttyS0", - "/dev/ttyS1" => "/dev/ttyS1" , "/dev/psaux" => "/dev/psaux", - "/dev/input/mice" =>"/dev/input/mice"); - - - /* try to read additional keyboard layouts - */ - if(file_exists(CONFIG_DIR."/keyboardLayouts")){ - if(is_readable(CONFIG_DIR."/keyboardLayouts")){ - $str = file_get_contents(CONFIG_DIR."/keyboardLayouts"); - $tmp = split("\n",$str); - foreach($tmp as $entry){ - if((!empty($entry)) && (!preg_match("/^#/",$entry))){ - $entry = trim($entry); - $tmp2 = split ("\:",$entry); - $la = trim($tmp2[0]); // What would be saved to ldap - $da = trim($tmp2[1]); // This wis displayed in the listbox - $this->XKbLayouts [ $la] = $da; - } - } - } - } - - /* Load scanner models */ - $fcontents = file ($this->config->basedir."/include/scanner.inc"); - while (list ($line_num, $line) = each ($fcontents)) { - preg_match('/^(\w+) "([^"]+)" "([^"]+)" "([^"]+)"/', "$line", $matches); - $this->gotoScannerModels[$matches[2]." - ".$matches[3]]= $matches[1]."|".$matches[4]; - } - ksort ($this->gotoScannerModels); - - /* Initialize methods */ - $this->XMethods["default"]= _("default"); - $this->XMethods["indirect"]= _("show chooser"); - $this->XMethods["query"]= _("direct"); -#$this->XMethods["squery"]= _("direct via ssh"); -#$this->XMethods["nquery"]= _("direct via nx"); - $this->XMethods["load"]= _("load balanced"); -#$this->XMethods["sload"]= _("load balanced via ssh"); -#$this->XMethods["nload"]= _("load balanced via nx"); - $this->XMethods["rdp"]= _("Windows RDP"); - $this->XMethods["citrix"]= _("ICA client"); - - $this->orig_dn= $this->dn; - - /* Load hardware list */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); - while ($attrs= $ldap->fetch()){ - $cn= $attrs['cn'][0]; - if (isset($attrs['description'])){ - $description= " - ".$attrs['description'][0]; - } else { - $description= ""; - } - $this->hardware_list[$cn]= "$cn$description"; - } - - /* Eventually colorize phones */ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware')); - while($attrs = $ldap->fetch()){ - $cn = $attrs['goFonHardware'][0]; - if(isset($this->hardware_list[$cn])){ - $this->used_hardware[$cn]= $cn; - } - } - - $this->hardware_list["automatic"]= _("automatic"); - ksort($this->hardware_list); - - /* Convert gotoLpdEnable */ - $this->gotoLpdEnable= preg_match("/yes/i",$this->gotoLpdEnable); - - /* Load hardware list */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))"); - if ($ldap->count() == 1){ - $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout", - "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport"); - $attrs= $ldap->fetch(); - - foreach ($map as $name){ - if (!isset($attrs[$name][0])){ - continue; - } - - switch ($name){ - case 'gotoXResolution': - $this->XResolutions['default'] = _("inherited").' ['.$attrs[$name][0].']' ; - break; - case 'gotoXColordepth': - $this->XColordepths['default'] = _("inherited").' ['.$attrs[$name][0].' '._('Bit').']'; - break; - case 'gotoXKbModel': - $this->XKbModels['default'] = _("inherited").' ['.$attrs[$name][0].']'; - break; - case 'gotoXKbLayout': - $this->XKbLayouts['default'] = _("inherited").' ['.$attrs[$name][0].']'; - break; - case 'gotoXKbVariant': - $this->XKbVariants['default'] = _("inherited").' ['.$attrs[$name][0].']' ; - break; - case 'gotoXMouseType': - $this->MouseTypes['AUTO'] = _("inherited").' ['.$attrs[$name][0].']' ; - break; - case 'gotoXMouseport': - $this->MousePorts['AUTO'] = _("inherited").' ['.$attrs[$name][0].']' ; - break; - } - } - } - if(preg_match("/\+/",$this->gotoXHsync)){ - $this->AutoSync = true; - $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync); - $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync); - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","terminal/".get_class($this),$this->dn); - } - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Do we represent a valid terminal? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no terminal features.").""; - return ($display); - } - - /* Show main page */ - $smarty= get_smarty(); - - /* Assign acls */ - $tmp= $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - - /* Arrays */ - foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths", - "gotoScannerModels", "XKbModels","XKbVariants", - "MouseTypes", "MousePorts") as $val){ - $smarty->assign("$val", $this->$val); - } - $smarty->assign("XKbLayouts", $this->XKbLayouts); - $smarty->assign("XKbLayoutKeys",array_flip($this->XKbLayouts)); - - $smarty->assign("xdmcpservers", $this->config->data['SERVERS']['TERMINAL']); - $smarty->assign("fontservers", $this->config->data['SERVERS']['FONT']); - $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); - $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); - - /* Variables - select */ - foreach(array("gotoXMethod", "gotoXdmcpServer", "gotoFontPath", - "gotoXDriver", "gotoXResolution", "gotoXColordepth", - "gotoLpdServer", "gotoScannerModel", "gotoXKbModel", "gotoXKbLayout", - "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ - - $smarty->assign($val."_select", $this->$val); - } - - /* Variables */ - foreach(array("gotoXHsync", "gotoXVsync") as $val){ - $smarty->assign($val, $this->$val); - } - $smarty->assign("staticAddress", ""); - - /* Checkboxes */ - foreach(array("gotoLpdEnable", "gotoScannerEnable") as $val){ - if ($this->$val == TRUE) { - $smarty->assign("$val", "checked"); - } else { - $smarty->assign("$val", ""); - } - } - - /* Phone stuff */ - $smarty->assign ("goFonHardware", $this->goFonHardware); - $hl= "\n"; - $smarty->assign ("hardware_list", $hl); - $smarty->assign ("gotoXMonitor", $this->gotoXMonitor); - - $smarty->assign("AutoSyncACL",$this->getacl("AutoSync")); - - $smarty->assign("AutoSyncCHK"," "); - if($this->AutoSync){ - $smarty->assign("AutoSyncCHK"," checked "); - $smarty->assign("gotoXVsyncACL", preg_replace("/w/","",$this->getacl("gotoXVsync"))); - $smarty->assign("gotoXHsyncACL", preg_replace("/w/","",$this->getacl("gotoXHsync"))); - } - - /* Show main page */ - return($smarty->fetch (get_template_path('terminalService.tpl', TRUE))); - } - - function remove_from_parent() - { - new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs)); - $this->handle_post_events("remove"); - } - - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - - /* Save checkbox state */ - if (isset ($_POST['gotoXMethod'])){ - foreach (array("gotoLpdEnable", "gotoScannerEnable") as $val){ - - if($this->acl_is_writeable($val)){ - if (!isset ($_POST["$val"])){ - $this->$val= FALSE; - } else { - $this->$val= TRUE; - } - } - } - } - - if(isset($_POST['gotoXDriver'])){ - if(isset($_POST['AutoSync'])){ - $this->AutoSync = true; - }else{ - $this->AutoSync = false; - } - } - - /* Default entries can use blank hsync/vsync entries */ - if ($this->dn != "" && $this->cn != "default" && $this->cn != "default"){ - - /* But only if no auto sync is enabled... */ - if (!$this->AutoSync){ - - /* Check vsync for correct usage */ - $val= preg_replace ("/\s/", "", $this->gotoXVsync); - if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXVsync")){ - - $message[]= _("Please specify a valid VSync range."); - } elseif ($this->acl_is_writeable("gotoXVsync")){ - list($v1,$v2)= preg_split ("/[-+]/", $val); - if ($v2 != ""){ - if ($v1 > $v2){ - $message[]= _("Please specify a valid VSync range."); - } - } - } - - /* Check hsync for correct usage */ - $val= preg_replace ("/\s/", "", $this->gotoXHsync); - if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXHsync")){ - - $message[]= _("Please specify a valid HSync range."); - } elseif ($this->acl_is_writeable("gotoXHsync")){ - list($v1,$v2)= preg_split ("/[-+]/", $val); - if ($v2 != ""){ - if ($v1 > $v2){ - $message[]= _("Please specify a valid HSync range."); - } - } - } - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - return ($message); - } - - - /* Save to LDAP */ - function save() - { - /* Convert to string */ - $this->gotoLpdEnable= $this->gotoLpdEnable?"Yes":"No"; - - plugin::save(); - - /* Strip out 'default' values */ - foreach(array("gotoXMethod", "gotoXdmcpServer", "gotoFontPath", - "gotoXDriver", "gotoXResolution", "gotoXColordepth", - "gotoLpdServer", "gotoScannerModel", "gotoXKbModel", "gotoXKbLayout", - "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ - - if ($this->attrs[$val] == "default"){ - $this->attrs[$val]= array(); - } - } - - if($this->AutoSync){ - $this->attrs['gotoXHsync'] = "30+55"; - $this->attrs['gotoXVsync'] = "50+70"; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/service with dn '%s' failed."),$this->dn)); - $this->handle_post_events("modify"); - } - - - function getListOfXDrivers() - { - $drivers = array(); - - /* Generate a list of xdrivers from CONFIG_DIR/xdrivers */ - if (file_exists(CONFIG_DIR.'/xdrivers')){ - $xdrivers = file (CONFIG_DIR.'/xdrivers'); - foreach ($xdrivers as $line){ - if (!preg_match ("/^#/", $line)){ - $drivers[]= trim($line); - } - } - } else { - $drivers = array("ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", "fglrx", - "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc", "nv", "nvidia", - "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion", - "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware"); - } - return($drivers); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Service"), - "plDescription" => _("Terminal service"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 3, - "plSection" => array("administration"), - "plCategory" => array("terminal"), - - "plProvidedAcls"=> array( - "gotoXMonitor" => _("Monitor"), - "gotoXMethod" => _("Method"), - "gotoXdmcpServer" => _("Remote desktop"), - "gotoFontPath" => _("Font path"), - "gotoXDriver" => _("Gfx driver"), - "gotoXResolution" => _("Gfx resolution"), - "gotoXColordepth" => _("Gfx color depth"), - "gotoXHsync" => _("Hsync"), - "gotoXVsync" => _("Vsync"), - "AutoSync" => _("Auto-Sync"), - "gotoLpdEnable" => _("Printer service enabled"), - "gotoLpdServer" => _("Spool server"), - "gotoScannerEnable" => _("Scanner enabled"), - "gotoScannerModel" => _("Scanner model"), - "gotoXKbModel" => _("Keyboard model"), - "gotoXKbLayout" => _("Keyboard layout"), - "gotoXKbVariant" => _("Keyboard variant"), - "gotoXMouseType" => _("Mouse type"), - "gotoXMouseport" => _("Mouse port"), - "goFonHardware" => _("Telephone hardware")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_terminalStartup.inc b/plugins/admin/systems/class_terminalStartup.inc deleted file mode 100644 index 0174459e3..000000000 --- a/plugins/admin/systems/class_terminalStartup.inc +++ /dev/null @@ -1,582 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $bootmode= "G"; - var $goLdapServerList= array(); - var $gotoBootKernel= "default-inherit"; - var $gotoKernelParameters= ""; - var $gotoLdapServer= ""; - var $gotoModules= array(); - var $gotoTerminalPath= ""; - var $gotoBootKernels= array(); - - /* Ldap server list */ - var $gotoLdapServers = array(); - var $gotoLdapServerList = array(); - var $gotoLdap_inherit = FALSE; - - /* Share */ - var $gotoShares = array();// Currently Share Option - var $gotoShare = ""; // currently selected Share Option - var $gotoShareSelections= array();// Available Shares for this account in Listbox format - var $gotoAvailableShares= array();// Available Shares for this account - - - /* attribute list for save action */ - var $attributes= array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters","gotoModules"); - var $objectclasses= array("GOhard"); - var $view_logged = FALSE; - - /* Helper */ - var $customParameters= ""; - var $orig_dn= ""; - var $ignore_account= TRUE; - - function termstartup (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $this->gotoBootKernels = array("default-inherit"=>"["._("inherited")."]"); - - /* Get arrays */ - foreach (array("gotoModules") as $val){ - $this->$val = array(); - if (isset($this->attrs["$val"]["count"])){ - for ($i= 0; $i<$this->attrs["count"]; $i++){ - if (isset($this->attrs["$val"][$i])){ - array_push($this->$val, $this->attrs["$val"][$i]); - } - } - } - sort ($this->$val); - $this->$val= array_unique($this->$val); - } - - /* Parse Kernel Parameters to decide what boot mode is enabled */ - if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){ - $this->bootmode= "G"; - } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){ - $this->bootmode= "D"; - } elseif ($this->gotoKernelParameters == "") { - $this->bootmode= "G"; - } else { - $this->bootmode= "T"; - } - if (preg_match("/ o /", $this->gotoKernelParameters)){ - $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters); - } else { - $this->customParameters= ""; - } - - /* Prepare Shares */ - if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){ - unset($this->attrs['gotoShare']['count']); - foreach($this->attrs['gotoShare'] as $share){ - $tmp = $tmp2 = array(); - $tmp = split("\|",$share); - $tmp2['server'] =$tmp[0]; - $tmp2['name'] =$tmp[1]; - $tmp2['mountPoint'] =$tmp[2]; - $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; - } - } - - $this->gotoShareSelections= $config->getShareList(true); - $this->gotoAvailableShares= $config->getShareList(false); - - $this->orig_dn= $this->dn; - - /* Get list of boot kernels */ - if (isset($this->config->data['TABS'])){ - $command= $this->config->search(get_class($this), "KERNELS",array('tabs')); - - if (!check_command($command)){ - $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command, - get_class($this)); - } else { - $fh= popen($command, "r"); - while (!feof($fh)) { - $buffer= trim(fgets($fh, 256)); - - if(!empty($buffer)){ - - $name=$value = $buffer; - - if(preg_match("/:/",$buffer)){ - $name = preg_replace("/:.*$/","",$buffer); - $value= preg_replace("/^.*:/","",$buffer); - $this->gotoBootKernels[$name]= $name.":".$value; - }else{ - $this->gotoBootKernels[$name]= $value; - } - } - } - pclose($fh); - } - - } - - foreach($this->config->data['SERVERS']['LDAP'] as $server) { - $this->gotoLdapServerList[]= $server; - } - if(isset($this->attrs['gotoLdapServer'])){ - unset($this->attrs['gotoLdapServer']['count']); - sort($this->attrs['gotoLdapServer']); - foreach($this->attrs['gotoLdapServer'] as $value){ - $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value); - } - } - if(!count($this->gotoLdapServers)){ - $this->gotoLdap_inherit = TRUE; - } - - /* Load hardware list */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))"); - if ($ldap->count() == 1){ - $map= array("gotoLdapServer"); - $attrs= $ldap->fetch(); - - foreach ($map as $name){ - if (!isset($attrs[$name][0])){ - continue; - } - - switch ($name){ - case 'gotoLdapServer': - $this->goLdapServerList= array_merge(array('default-inherit' => _("inherited").' ['.$attrs[$name][0].']' ), $this->goLdapServerList); - break; - } - } - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","terminal/".get_class($this),$this->dn); - } - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Do we represent a valid terminal? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no terminal features.").""; - return ($display); - } - - /* Add module */ - if (isset ($_POST['add_module'])){ - if ($_POST['module'] != "" && $this->acl_is_writeable("gotoMode")){ - $this->add_list ($this->gotoModules, $_POST['module']); - } - } - - /* Delete module */ - if (isset ($_POST['delete_module'])){ - if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoMode")){ - $this->del_list ($this->gotoModules, $_POST['modules_list']); - } - } - - /* Show main page */ - $smarty= get_smarty(); - - /* Assign acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - - /* In this section server shares will be defined - * A user can select one of the given shares and a mount point - * and attach this combination to his setup. - */ - $smarty->assign("gotoShareSelections", $this->gotoShareSelections); - $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections)); - $smarty->assign("gotoBootKernels",$this->gotoBootKernels); - - /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry - * This entry will be, a combination of mountPoint and sharedefinitions - */ - if(isset($_POST['gotoShareAdd']) && $this->acl_is_writeable("gotoShare")){ - /* We assign a share to this user, if we don't know where to mount the share */ - if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){ - print_red(_("You must specify a valid mount point.")); - }else{ - $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']]; - $s_mount = $_POST['gotoShareMountPoint']; - /* Preparing the new assignment */ - $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share; - $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount; - } - } - - /* if the Post gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected) - * If there is no defined share selected, we will abort the deletion without any message - */ - if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare'])) && $this->acl_is_writeable("gotoShare")){ - unset($this->gotoShares[$_POST['gotoShare']]); - } - - $smarty->assign("gotoShares",$this->printOutAssignedShares()); - $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares())); - - /* Create divSelectBox for ldap server selection - */ - $SelectBoxLdapServer = new divSelectBox("LdapServer"); - $SelectBoxLdapServer->SetHeight(80); - - /* Add new ldap server to the list */ - if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){ - if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){ - $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']]; - if(!in_array($to_add,$this->gotoLdapServers)){ - $this->gotoLdapServers[] = $to_add; - } - } - } - - /* Move ldap servers up and down */ - if(!$this->gotoLdap_inherit){ - foreach($_POST as $name => $value){ - if(preg_match("/sort_ldap_up_/",$name)){ - $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name); - $from = $id; - $to = $id -1; - $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); - if($tmp){ - $this->gotoLdapServers = $tmp; - } - break; - } - if(preg_match("/sort_ldap_down_/",$name)){ - $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name); - $from = $id; - $to = $id +1; - $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); - if($tmp){ - $this->gotoLdapServers = $tmp; - } - break; - } - if(preg_match("/gotoLdapRemove_/",$name)){ - $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name); - $value = $this->gotoLdapServers[$id]; - $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers); - break; - } - } - } - /* Add Entries - */ - foreach($this->gotoLdapServers as $key => $server){ - if(!in_array($server,$this->gotoLdapServerList)){ - $server = $server." (missing)"; - } - - $SelectBoxLdapServer->AddEntry( - array(array("string" => $server), - array("string" => - " ". - " ". - "", - "attach" => "style='text-align:right;width:40px;border-right:0px;'"))); - } - - if($this->gotoLdap_inherit){ - $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));; - }else{ - $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer")); - } - - $list = array(); - foreach($this->gotoLdapServerList as $key => $entry){ - if(!in_array($entry,$this->gotoLdapServers)){ - $list[$key] = $entry; - } - } - $smarty->assign("gotoLdapServers", $SelectBoxLdapServer->DrawList()); - $smarty->assign("gotoLdapServerList", $list); - $smarty->assign("gotoLdap_inherit", $this->gotoLdap_inherit); - $smarty->assign("JS", $_SESSION['js']); - - foreach (array("gotoModules" ) as $val){ - $smarty->assign("$val", $this->$val); - } - - /* Values */ - foreach(array("gotoBootKernel", "customParameters") as $val){ - $smarty->assign($val, $this->$val); - } - - /* Radio button group */ - if (preg_match("/G/", $this->bootmode)) { - $smarty->assign("graphicalbootup", "checked"); - } else { - $smarty->assign("graphicalbootup", ""); - } - if (preg_match("/T/", $this->bootmode)) { - $smarty->assign("textbootup", "checked"); - } else { - $smarty->assign("textbootup", ""); - } - if (preg_match("/D/", $this->bootmode)) { - $smarty->assign("debugbootup", "checked"); - } else { - $smarty->assign("debugbootup", ""); - } - - /* Show main page */ - return($smarty->fetch (get_template_path('terminalStartup.tpl', TRUE))); - } - - function remove_from_parent() - { - if($this->acl_is_removeable()){ - $this->handle_post_events("remove"); - new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs)); - } - } - - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - - if(isset($_POST['TerminalStarttabPosted'])){ - if(isset($_POST['gotoLdap_inherit'])){ - $this->gotoLdap_inherit = TRUE; - }else{ - $this->gotoLdap_inherit = FALSE; - } - - /* Save group radio buttons */ - if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){ - $this->bootmode= $_POST["bootmode"]; - } - - /* Save kernel parameters */ - if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){ - $this->customParameters= $_POST["customParameters"]; - } - } - } - - - /* Save to LDAP */ - function save() - { - /* Find proper terminal path for tftp configuration - FIXME: This is suboptimal when the default has changed to - another location! */ - if ($this->gotoTerminalPath == "default-inherit"){ - $ldap= $this->config->get_ldap_link(); - - /* Strip relevant part from dn, keep trailing ',' */ - $tmp= preg_replace("/^cn=[^,]+,ou=terminals,ou=systems,/i", "", $this->dn); - $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp); - - /* Walk from top to base and try to load default values for - 'gotoTerminalPath'. Abort when an entry is found. */ - while (TRUE){ - $tmp= preg_replace ("/^[^,]+,/", "", $tmp); - - $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp". - $this->config->current['BASE'], array('gotoTerminalPath')); - $attrs= $ldap->fetch(); - if (isset($attrs['gotoTerminalPath'])){ - $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0]; - break; - } - - /* Nothing left? */ - if ($tmp == ""){ - break; - } - } - } - - /* Add semi automatic values */ - // FIXME: LDAP Server may not be set here... - $this->gotoKernelParameters= "root=/dev/nfs nfsroot=". - $this->gotoTerminalPath. - ",ro,hard,nolock,fg,rsize=8192 ". - "ip=::::::dhcp ldap=".base64_encode($this->gotoLdapServer); - - switch ($this->bootmode){ - case "D": - $this->gotoKernelParameters.= " debug"; - break; - case "G": - $this->gotoKernelParameters.= " splash=silent"; - break; - } - if ($this->customParameters != ""){ - $this->gotoKernelParameters.= " o ".$this->customParameters; - } - - plugin::save(); - - /* Add missing arrays */ - foreach (array("gotoModules") as $val){ - if (isset ($this->$val) && count ($this->$val) != 0){ - - $this->attrs["$val"]= array_unique($this->$val); - } - if(!isset($this->attrs["$val"])){ - $this->attrs["$val"]=array(); - } - } - - /* Prepare list of ldap servers */ - $this->attrs['gotoLdapServer'] = array(); - if(!$this->gotoLdap_inherit){ - $i = 0; - foreach($this->gotoLdapServers as $server){ - $i ++; - $this->attrs['gotoLdapServer'][] = $i.":".$server; - } - } - - /* Strip out 'default' values */ - foreach(array("gotoBootKernel") as $value){ - if (!isset($this->attrs[$value]) || $this->attrs[$value] == "default-inherit"){ - $this->attrs[$value] = array(); - } - } - - /* prepare share settings */ - $tmp = array(); - foreach($this->gotoShares as $name => $settings){ - $tmp2 = split("\|",$name); - $name = $tmp2[0]; - $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint']; - } - $this->attrs['gotoShare']=$tmp; - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - - $this->cleanup(); - $ldap->modify ($this->attrs); - - new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/startup with dn '%s' failed."),$this->dn)); - $this->handle_post_events("modify"); - } - - /* Add value to array, check if unique */ - function add_list (&$array, $value) - { - if ($value != ""){ - $array[]= $value; - sort($array); - array_unique ($array); - } - } - - - /* Delete value to array, check if unique */ - function del_list (&$array, $list) - { - $tmp= array(); - foreach ($array as $mod){ - if (!in_array($mod, $list)){ - $tmp[]= $mod; - } - } - $array= $tmp; - } - - /* Generate ListBox frindly output for the defined shares - * Possibly Add or remove an attribute here, - */ - function printOutAssignedShares() - { - $a_return = array(); - if(is_array($this->gotoShares)){ - foreach($this->gotoShares as $share){ - $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]"; - } - } - return($a_return); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - $source_o = new termstartup ($this->config, $source['dn']); - - foreach(array("gotoModules", "gotoKernelParameters","gotoShares","customParameters","bootmode","gotoTerminalPath","gotoShares","goLdapServerList","gotoBootKernel","gotoLdapServer","gotoBootKernels") as $attr){ - $this->$attr = $source_o->$attr; - } - } - - - function array_switch_item($ar,$from,$to) - { - if(!is_array($ar)){ - return(false); - } - if(!isset($ar[$from])){ - return(false); - } - if(!isset($ar[$to])){ - return(false); - } - - $tmp = $ar[$from]; - $ar[$from] = $ar[$to]; - $ar[$to] = $tmp; - return($ar); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Startup"), - "plDescription" => _("Terminal startup"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 5, - "plSection" => array("administration"), - "plCategory" => array("terminal"), - - "plProvidedAcls"=> array( - "gotoLdapServer" => _("Ldap server"), - "gotoShare" => _("Shares"), - "gotoModules" => _("Kernel modules"), - "gotoBootKernel" => _("Boot kernel"), - "gotoKernelParameters"=> _("Kernel parameter")) - )); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_winGeneric.inc b/plugins/admin/systems/class_winGeneric.inc deleted file mode 100644 index 8a15e930c..000000000 --- a/plugins/admin/systems/class_winGeneric.inc +++ /dev/null @@ -1,306 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $interfaces= array(); - - /* Needed values and lists */ - var $base= ""; - var $cn= ""; - var $description= ""; - var $orig_dn= ""; - var $shadowLastChange=""; - var $uidNumber=""; - var $gidNumber=""; - var $loginShell=""; - var $gecos=""; - var $shadowMin=""; - var $shadowWarning=""; - var $shadowInactive=""; - var $uid=""; - var $sn=""; - var $givenName=""; - var $homeDirectory=""; - var $sambaSID=""; - var $sambaPrimaryGroupSID=""; - var $displayName=""; - var $sambaPwdMustChange=""; - var $sambaNTPassword=""; - var $sambaPwdLastSet=""; - var $sambaAcctFlags=""; - var $netConfigDNS; - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("cn", "description","shadowLastChange", - "uidNumber","gidNumber","loginShell","gecos","shadowMin","shadowWarning", - "shadowInactive","uid","cn","sn","givenName","homeDirectory","sambaSID", - "sambaPrimaryGroupSID","displayName", "sambaPwdMustChange", - "sambaNTPassword","sambaPwdLastSet","sambaAcctFlags"); - var $objectclasses= array("posixAccount","person","organizationalPerson","inetOrgPerson","gosaAccount","shadowAccount","sambaSamAccount","top"); - - var $view_logged = FALSE; - - function wingeneric (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - $this->cn= ""; - } else { - $this->base= preg_replace ("/^[^,]+,".normalizePreg(get_winstations_ou())."/", "", $this->dn); - } - - /* Save dn for later references */ - $this->orig_dn= $this->dn; - - $this->cn= preg_replace("/\\\$\$/","",$this->cn); - } - - - function set_acl_base($base) - { - plugin::set_acl_base($base); - $this->netConfigDNS->set_acl_base($base); - } - - function set_acl_category($cat) - { - plugin::set_acl_category($cat); - $this->netConfigDNS->set_acl_category($cat); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","winworkstation/".get_class($this),$this->dn); - } - - - /* Do we represent a valid phone? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no network features.").""; - return($display); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - - // Undefined index in wingeneric.tpl ... - $smarty->assign("bases", $this->config->idepartments); - - /* Assign attributes */ - foreach ($this->attributes as $attr){ - $smarty->assign("$attr", $this->$attr); - } - - $smarty->assign("base_select", $this->base); - - /* Show main page */ - $str = $this->netConfigDNS->execute(); - if(is_object($this->netConfigDNS->dialog)){ - return($str); - } - $smarty->assign("netconfig", $str); - return($smarty->fetch (get_template_path('wingeneric.tpl', TRUE))); - } - - function remove_from_parent() - { - $this->netConfigDNS->remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - $ldap->rmdir($this->dn); - new log("remove","winworkstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system wingeneric/generic with dn '%s' failed."),$this->dn)); - $this->handle_post_events("remove"); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - } - - - /* Save data to object */ - function save_object() - { - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - $this->netConfigDNS->save_object(); - - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - $message= array_merge($message, $this->netConfigDNS->check()); - $this->dn= "cn=".$this->cn.",ou=netdevices,ou=systems,".$this->base; - - /* Set new acl base */ - if($this->dn == "new") { - $this->set_acl_base($this->base); - } - - if(!$this->acl_is_createable() && $this->dn == "new"){ - $message[]= _("You have no permissions to create a component on this 'Base'."); - } - - if ($this->orig_dn != $this->dn){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); - $ldap->search ("(cn=".$this->cn.")", array("cn")); - if ($ldap->count() != 0){ - while ($attrs= $ldap->fetch()){ - if(preg_match("/cn=dhcp,/",$attrs['dn'])){ - continue; - } - if ($attrs['dn'] != $this->orig_dn){ - $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); - break; - } - } - } - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Remove all empty values */ - if ($this->orig_dn == 'new'){ - $attrs= array(); - foreach ($this->attrs as $key => $val){ - if (is_array($val) && count($val) == 0){ - continue; - } - $attrs[$key]= $val; - } - $this->attrs= $attrs; - } - - if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){ - $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - if ($this->orig_dn == 'new'){ - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","winworkstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("add"); - } else { - if ($this->orig_dn != $this->dn){ - $this->move($this->orig_dn, $this->dn); - } - - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","winworkstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("modify"); - } - - $this->netConfigDNS->cn = preg_replace("/\\\$\$/","",$this->cn); - $this->netConfigDNS->save(); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system wingeneric/generic with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->postcreate(); - } - - /* Return plugin informations for acl handling - #FIXME FAIscript seams to ununsed within this class... */ - static function plInfo() - { - return (array( - "plShortName" => _("Win generic"), - "plDescription" => _("Windows workstation generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("winworkstation" => array("description" => _("Win workstation"), - "objectClass" => "gotoWorkstation")), - "plProvidedAcls"=> array( - "cn" => _("Workstation name"), - "description" => _("Description")) - )); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc deleted file mode 100644 index 14641c0b7..000000000 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ /dev/null @@ -1,663 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Generic terminal attributes */ - var $gotoMode= "locked"; - var $gotoSyslogServer= ""; - var $gotoSyslogServers= array(); - var $gotoNtpServer= array(); - var $gotoNtpServers= array(); - var $gotoSndModule= ""; - var $gotoFloppyEnable= ""; - var $gotoCdromEnable= ""; - var $ghCpuType= "-"; - var $ghMemSize= "-"; - var $ghUsbSupport= "-"; - var $ghNetNic= array(); - var $ghIdeDev= array(); - var $ghScsiDev= array(); - var $ghGfxAdapter= "-"; - var $ghSoundAdapter= "-"; - var $gotoLastUser= "-"; - var $FAIscript= ""; - var $didAction= FALSE; - var $FAIstate= ""; - var $view_logged = FALSE; - - /* Needed values and lists */ - var $base= ""; - var $cn= ""; - var $l= ""; - var $orig_dn= ""; - - /* Plugin side filled */ - var $modes= array(); - - var $netConfigDNS; - - var $inheritTimeServer = true; - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes= array("gotoMode", "gotoSyslogServer", "gotoNtpServer", - "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule", - "ghCpuType", "ghMemSize", "ghUsbSupport", - "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript"); - var $objectclasses= array("top", "gotoWorkstation", "GOhard"); - - var $mapActions = array("reboot" => "", - "localboot" => "localboot", - "halt" => "", - "instant_update" => "softupdate", - "update" => "scheduledupdate", - "reinstall" => "install", - "rescan" => "", - "memcheck" => "memcheck", - "sysinfo" => "sysinfo"); - - - var $fai_activated = FALSE; - - var $member_of_ogroup = FALSE; - - function workgeneric (&$config, $dn= NULL, $parent= NULL) - { - $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - $this->fai_activated = TRUE; - } - - plugin::plugin ($config, $dn, $parent); - - if(!isset($this->parent->by_object['ogroup'])){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn")); - $this->member_of_ogroup = $ldap->count() >= 1; - } - - $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses); - - /* Read arrays */ - foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ - if (!isset($this->attrs[$val])){ - continue; - } - for ($i= 0; $i<$this->attrs[$val]['count']; $i++){ - array_push($this->$val, $this->attrs[$val][$i]); - } - } - - /* Create used ntp server array */ - $this->gotoNtpServer= array(); - if(isset($this->attrs['gotoNtpServer'])){ - $this->inheritTimeServer = false; - unset($this->attrs['gotoNtpServer']['count']); - foreach($this->attrs['gotoNtpServer'] as $server){ - $this->gotoNtpServer[$server] = $server; - } - } - - /* Set inherit checkbox state */ - if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer) == 0)){ - $this->inheritTimeServer = true; - $this->gotoNtpServer=array(); - } - - /* You can't inherit the NTP service, if we are not member in an object group */ - if(!$this->member_of_ogroup){ - $this->inheritTimeServer = FALSE; - } - - /* Create available ntp options */ - $tmp = $this->config->data['SERVERS']['NTP']; - $this->gotoNtpServers = array(); - foreach($tmp as $key => $server){ - if($server == "default") continue; - $this->gotoNtpServers[$server] = $server; - } - - $this->modes["active"]= _("Activated"); - $this->modes["locked"]= _("Locked"); - - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } else { - $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); - } - - /* Create an array of all Syslog servers */ - $tmp = $this->config->data['SERVERS']['SYSLOG']; - foreach($tmp as $server){ - $visible = $server; - if($server == "default" && $this->member_of_ogroup) { - $visible = "["._("inherited")."]"; - } - $this->gotoSyslogServers[$server] = $visible; - } - - /* Save 'dn' for later referal */ - $this->orig_dn= $this->dn; - } - - - function set_acl_base($base) - { - plugin::set_acl_base($base); - $this->netConfigDNS->set_acl_base($base); - } - - function set_acl_category($cat) - { - plugin::set_acl_category($cat); - $this->netConfigDNS->set_acl_category($cat); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","workstation/".get_class($this),$this->dn); - } - - /* Do we need to flip is_account state? */ - 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['action'])) && ($this->acl_is_writeable("FAIstate"))){ - $cmd= $this->config->search("workgeneric", "ACTIONCMD",array('tabs')); - if ($cmd == ""){ - print_red(_("No ACTIONCMD definition found in your gosa.conf")); - } else { - exec ($cmd." ".$this->netConfigDNS->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval); - if ($retval != 0){ - print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); - } elseif ($_POST['saction'] != "wake") { - - /* Set FAIstate */ - if($this->fai_activated && $this->dn != "new"){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn,array("objectClass")); - $res = $ldap->fetch(); - - $attrs = array(); - $attrs['FAIstate'] = $this->FAIstate; - if(isset($this->mapActions[$_POST['saction']]) && $this->mapActions[$_POST['saction']] != ""){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } - - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } - - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } - - if($attrs['FAIstate'] == ""){ -#FIXME we should check if FAIobject is not used anymore - $attrs['FAIstate'] = array(); - } - - $ldap->cd($this->dn); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic (FAIstate) with dn '%s' failed."),$this->dn)); - - } - $this->didAction= TRUE; - } - } - } - - /* Do we represent a valid terminal? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no workstation features.").""; - return($display); - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Add new ntp Server to our list */ - if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){ - $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; - } - - /* Delete selected NtpServer for list of used servers */ - if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){ - foreach($_POST['gotoNtpServerSelected'] as $name){ - unset($this->gotoNtpServer[$name]); - } - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - - /* Set acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $smarty->assign("cn", $this->cn); - $smarty->assign("l", $this->l); - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("staticAddress", ""); - - $tmp = array(); - foreach($this->gotoNtpServers as $server){ - if(!in_array($server,$this->gotoNtpServer)){ - $tmp[$server] = $server; - } - } - $smarty->assign("gotoNtpServers",$tmp); - - /* Check if workstation is online */ - $query= "fping -q -r 1 -t 500 ".$this->cn; - exec ($query, $dummy, $retval); - - /* Offline */ - if ($retval == 0){ - $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), - "instant_update" => _("Instant update"), - "update" => _("Scheduled update"), - "reinstall" => _("Reinstall"), - "rescan" => _("Rescan hardware"), - "memcheck" => _("Memory test"), - "localboot" => _("Force localboot"), - "sysinfo" => _("System analysis"))); - } else { - $smarty->assign("actions", array("wake" => _("Wake up"), - "reinstall" => _("Reinstall"), - "update" => _("Scheduled update"), - "memcheck" => _("Memory test"), - "localboot" => _("Force localboot"), - "sysinfo" => _("System analysis"))); - } - /* Arrays */ - $smarty->assign("modes", $this->modes); - $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); - $smarty->assign("syslogservers", $this->gotoSyslogServers); - $smarty->assign("fai_activated",$this->fai_activated); - - $ntpser = array(); - foreach($this->gotoNtpServers as $server){ - if(!in_array($server,$this->gotoNtpServer)){ - $ntpser[$server] = $server; - } - } - $smarty->assign("gotoNtpServers", $ntpser); - - /* Variables */ - foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){ - $smarty->assign($val."_select", $this->$val); - } - - /* tell smarty the inherit checkbox state */ - $smarty->assign("inheritTimeServer",$this->inheritTimeServer); - $smarty->assign("member_of_ogroup",$this->member_of_ogroup); - - $str = $this->netConfigDNS->execute(); - if(is_object($this->netConfigDNS->dialog)){ - return($str); - } - $smarty->assign("netconfig", $str); - - /* Show main page */ - return($smarty->fetch (get_template_path('workstation.tpl', TRUE))); - } - - function remove_from_parent() - { - if($this->acl_is_removeable()){ - - $this->netConfigDNS->remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - $ldap->rmdir($this->dn); - new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system workstation/generic with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - } - - if(isset($_POST["inheritAll"])){ - $this->set_everything_to_inherited(); - } - } - - - /* Save data to object */ - function save_object() - { - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - /* Save base, since this is no LDAP attribute */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - - $this->netConfigDNS->save_object(); - - /* Set inherit mode */ - if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){ - if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){ - $this->inheritTimeServer = true; - }else{ - $this->inheritTimeServer = false; - } - } - - if(isset($_POST["inheritAll"])){ - $this->set_everything_to_inherited(); - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Skip IP & Mac checks if this is a template */ - if($this->cn != "wdefault"){ - $message= array_merge($message, $this->netConfigDNS->check()); - } - - $this->dn= "cn=".$this->cn.",ou=workstations,ou=systems,".$this->base; - - if ($this->cn == ""){ - $message[]= _("The required field 'Workstation name' is not set."); - } - - /* Check if given name is a valid host/dns name */ - if(!is_dns_name($this->cn)){ - $message[] = _("Please specify a valid name for this object."); - } - - if ($this->orig_dn != $this->dn){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->base); - - if($this->cn == "wdefault"){ - $ldap->cat($this->dn); - }else{ - $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn")); - } - if ($ldap->count() != 0){ - while ($attrs= $ldap->fetch()){ - if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,ou=incoming,/", $ldap->getDN())){ - continue; - } else { - if ($attrs['dn'] != $this->orig_dn){ - $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); - break; - } - } - } - } - } - - /* Check for valid ntpServer selection */ - if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){ - $message[]= _("There must be at least one NTP server selected, or the inherit mode activated."); - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Strip out 'default' values */ - foreach (array("gotoSyslogServer") as $val){ - - if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){ - $this->attrs[$val]= array(); - } - } - - /* Add missing arrays */ - foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){ - if (isset ($this->$val) && count ($this->$val) != 0){ - $this->attrs["$val"]= $this->$val; - } - } - - /* Remove all empty values */ - if ($this->orig_dn == 'new'){ - $attrs= array(); - foreach ($this->attrs as $key => $val){ - if (is_array($val) && count($val) == 0){ - continue; - } - $attrs[$key]= $val; - } - $this->attrs= $attrs; - } - - /* Update ntp server settings */ - if($this->inheritTimeServer){ - if($this->is_new){ - if(isset($this->attrs['gotoNtpServer'])){ - unset($this->attrs['gotoNtpServer']); - } - }else{ - $this->attrs['gotoNtpServer'] = array(); - } - }else{ - /* Set ntpServers */ - $this->attrs['gotoNtpServer'] = array(); - foreach($this->gotoNtpServer as $server){ - $this->attrs['gotoNtpServer'][] = $server; - } - } - - if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){ - $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - if ($this->orig_dn == 'new'){ - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn)); - if(!$this->didAction){ - $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } - } else { - if ($this->orig_dn != $this->dn){ - $this->move($this->orig_dn, $this->dn); - } - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - if(!$this->didAction){ - $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber)); - } - } - - /* cn=default and macAddress=- indicates that this is a template */ - if($this->cn == "wdefault"){ - $this->netConfigDNS->macAddress = "-"; - } - - $this->netConfigDNS->cn = $this->cn; - $this->netConfigDNS->save(); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn)); - } - - - /* Display generic part for server copy & paste */ - function getCopyDialog() - { - $vars = array("cn"); - $smarty = get_smarty(); - $smarty->assign("cn" ,$this->cn); - $smarty->assign("object","workstation"); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - if(isset($source['macAddress'][0])){ - $this->netConfigDNS->macAddress = $source['macAddress'][0]; - } - if(isset($source['ipHostNumber'][0])){ - $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0]; - } - - /* Create used ntp server array */ - $this->gotoNtpServer= array(); - if(isset($source['gotoNtpServer'])){ - $this->inheritTimeServer = false; - unset($source['gotoNtpServer']['count']); - foreach($source['gotoNtpServer'] as $server){ - $this->gotoNtpServer[$server] = $server; - } - } - - /* Set inherit checkbox state */ - if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){ - $this->inheritTimeServer = true; - $this->gotoNtpServer=array(); - } - } - - - /* Return plugin informations for acl handling - #FIXME FAIscript seams to ununsed within this class... */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Workstation generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("workstation" => array("description" => _("Workstation"), - "objectClass" => "gotoWorkstation")), - "plProvidedAcls"=> array( - "cn" => _("Workstation name"), - "l" => _("Location") , - "base" => _("Base") , - "gotoMode" => _("Goto mode"), - "gotoSyslogServer" => _("Syslog server"), - "gotoNtpServer" => _("Ntp server"), - "gotoRootPasswd" => _("Root password"), - "FAIstate" => _("Action flag")) - )); - } - - function set_everything_to_inherited() - { - $this->gotoSyslogServer = "default"; - $this->inheritTimeServer = TRUE; - - /* Set workstation service attributes to inherited */ - if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){ - foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant", - "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){ - $this->parent->by_object['workservice']->$name = "default"; - } - } - - /* Set workstation startup attributes to inherited */ - if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){ - $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited"; - $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited"; - $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited"; - } - } -} - // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_workstationService.inc b/plugins/admin/systems/class_workstationService.inc deleted file mode 100644 index 23698cf61..000000000 --- a/plugins/admin/systems/class_workstationService.inc +++ /dev/null @@ -1,505 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - var $gotoScannerEnable; - /* Generic terminal attributes */ - var $gotoXMonitor= ""; - var $gotoXDriver= ""; - var $gotoXResolution= ""; - var $gotoXColordepth= ""; - var $gotoXHsync= ""; - var $gotoXVsync= ""; - var $AutoSync = false; - var $gotoXKbModel= ""; - var $gotoXKbLayout= ""; - var $gotoXKbVariant= ""; - var $gotoXMouseType= ""; - var $gotoXMouseport= ""; - var $gotoScannerClients= ""; - var $gotoScannerBackend= ""; - var $goFonHardware= "automatic"; - var $view_logged = FALSE; - - /* Needed values and lists */ - var $ignore_account= TRUE; - var $base= ""; - var $cn= ""; - var $orig_dn= ""; - var $XMethods= array(); - var $XDrivers= array(); - var $XResolutions = array(); - var $MouseTypes= array(); - var $MousePorts= array(); - var $hardware_list= array(); - var $used_hardware= array(); - - - /* attribute list for save action */ - var $attributes= array("gotoXMonitor", - "gotoXDriver", "gotoXResolution", "gotoXColordepth", - "gotoXHsync", "gotoXVsync", - "gotoScannerEnable", "gotoScannerClients", - "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant", - "gotoXMouseType", "gotoXMouseport", "goFonHardware"); - var $objectclasses= array("GOhard"); - - var $XColordepths =array(); - var $XKbModels =array(); - var $XKbLayouts =array(); - var $XKbVariants =array(); - - function workservice (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $this->XResolutions= array( - "640x480" => "640x480", - "800x600" => "800x600", - "1024x768" => "1024x768", - "1152x864" => "1152x864", - "1280x1024" => "1280x1024", - "1400x1050" => "1400x1050", - "1600x1200" => "1600x1200"); - - if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){ - $file = $this->config->data['MAIN']['RESOLUTION_HOOK']; - - if(is_readable($file)){ - $str = file_get_contents($file); - $lines = split("\n",$str); - foreach($lines as $line){ - $line = trim($line); - if(!empty($line)){ - $this->XResolutions[$line]=$line; - } - } - //natcasesort($this->gotoXResolutions); - }else{ - print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file)); - } - } - - /* Get list of available xdrivers */ - $this->XDrivers = $this->getListOfXDrivers(); - - array_unshift($this->XDrivers, "["._("unknown")."]"); - - $this->XColordepths= array( - "8" => "8 " ._("bit"), - "15" => "15 "._("bit"), - "16" => "16 "._("bit"), - "24" => "24 "._("bit")); - - foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex", - "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless", - "logiinetnav", "logiinternet", "macintosh", "microsoft", - "microsoftpro", "omnikey101", "pc101", "pc102", "pc104", - "pc105", "rapidaccess", "rapidaccess2", "winbook") as $type){ - $this->XKbModels[$type] = $type; - } - - $this->MouseTypes= array("ImPS/2" => "ImPS/2", "PS/2" => "PS/2", "Microsoft" => "Microsoft", - "Logitech" => "Logitech"); - - $this->MousePorts= array("/dev/ttyS0" =>"/dev/ttyS0", - "/dev/ttyS1" => "/dev/ttyS1", "/dev/psaux" =>"/dev/psaux", - "/dev/input/mice" => "/dev/input/mice"); - - /* Additional values will be extracted from CONFIG_DIR./keyboardLayouts */ - $this->XKbLayouts= array ("de"=> "de","intl" =>"intl","us" =>"us"); - $this->XKbVariants= array ("nodeadkeys"=>"nodeadkeys", "basic"=>"basic"); - - /* try to read additional keyboard layouts - */ - if(file_exists(CONFIG_DIR."/keyboardLayouts")){ - if(is_readable(CONFIG_DIR."/keyboardLayouts")){ - $str = file_get_contents(CONFIG_DIR."/keyboardLayouts"); - $tmp = split("\n",$str); - foreach($tmp as $entry){ - if((!empty($entry)) && (!preg_match("/^#/",$entry))){ - $entry = trim($entry); - $tmp2 = split ("\:",$entry); - $la = trim($tmp2[0]); // What would be saved to ldap - $da = trim($tmp2[1]); // This wis displayed in the listbox - $this->XKbLayouts [ $la] = $da; - } - } - } - } - - /* Initialize methods */ - $this->XMethods["indirect"]= _("show chooser"); - $this->XMethods["query"]= _("direct"); - #$this->XMethods["squery"]= _("direct via ssh"); - #$this->XMethods["nquery"]= _("direct via nx"); - $this->XMethods["load"]= _("load balanced"); - #$this->XMethods["sload"]= _("load balanced via ssh"); - #$this->XMethods["nload"]= _("load balanced via nx"); - $this->XMethods["rdp"]= _("Windows RDP"); - $this->XMethods["citrix"]= _("ICA client"); - - $this->orig_dn= $this->dn; - - /* Load hardware list */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); - while ($attrs= $ldap->fetch()){ - $cn= $attrs['cn'][0]; - if (isset($attrs['description'])){ - $description= " - ".$attrs['description'][0]; - } else { - $description= ""; - } - $this->hardware_list[$cn]= "$cn$description"; - } - - /* Eventually colorize phones */ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware')); - while($attrs = $ldap->fetch()){ - $cn = $attrs['goFonHardware'][0]; - if(isset($this->hardware_list[$cn])){ - $this->used_hardware[$cn]= $cn; - } - } - - if(preg_match("/\+/",$this->gotoXHsync)){ - $this->AutoSync = true; - $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync); - $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync); - } - - $this->hardware_list["automatic"]= _("automatic"); - ksort($this->hardware_list); - - /* Load hardware list */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))"); - if ($ldap->count() == 1){ - $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout", - "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport"); - $attrs= $ldap->fetch(); - - foreach ($map as $name){ - if (!isset($attrs[$name][0])){ - continue; - } - - switch ($name){ - case 'gotoXResolution': - $this->XResolutions= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions; - break; - case 'gotoXColordepth': - $this->XColordepths= array('default' => _("inherited").' ['.$attrs[$name][0].' '._('Bit').']') + $this->XColordepths; - break; - case 'gotoXKbModel': - $this->XKbModels= array('default' => _("inherited").' ['.$attrs[$name][0].']') + $this->XKbModels; - break; - case 'gotoXKbLayout': - $this->XKbLayouts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbLayouts; - break; - case 'gotoXKbVariant': - $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants; - break; - case 'gotoXMouseType': - $this->MouseTypes= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes; - break; - case 'gotoXMouseport': - $this->MousePorts= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts; - break; - } - - } - - } - - /* Workaround to fill in inherited values if we've specified an objectclass */ - if (isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){ - $this->XResolutions= array('default' => _("inherited")); - $this->XColordepths= array('default' => _("inherited")); - $this->XKbModels= array('default' => _("inherited")); - $this->XKbLayouts= array('default' => _("inherited")); - $this->XKbVariants= array('default' => _("inherited")); - $this->MouseTypes= array('AUTO' => _("inherited")); - $this->MousePorts= array('AUTO' => _("inherited")); - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","workstation/".get_class($this),$this->dn); - } - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Show main page */ - $smarty= get_smarty(); - - /* Assign ACLs */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Arrays */ - foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths", - "XKbModels", "XKbVariants", - "MouseTypes", "MousePorts") as $val){ - $smarty->assign("$val", $this->$val); - } - $smarty->assign("XKbLayouts" ,$this->XKbLayouts); - $smarty->assign("XKbLayoutKeys" ,array_flip($this->XKbLayouts)); - - $smarty->assign("xdmcpservers", $this->config->data['SERVERS']['TERMINAL']); - $smarty->assign("fontservers", $this->config->data['SERVERS']['FONT']); - $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); - $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']); - - /* Variables - select */ - foreach(array( - "gotoXDriver", "gotoXResolution", "gotoXColordepth", - "gotoXKbModel", "gotoXKbLayout","gotoScannerEnable", - "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ - - $smarty->assign($val."_select", $this->$val); - } - - /* Variables */ - foreach(array("gotoXHsync", "gotoXVsync") as $val){ - $smarty->assign($val, $this->$val); - } - $smarty->assign("staticAddress", ""); - - /* Checkboxes */ - foreach(array("gotoScannerEnable") as $val){ - if ($this->$val == TRUE) { - $smarty->assign("$val", "checked"); - } else { - $smarty->assign("$val", ""); - } - } - - /* Phone stuff */ - $smarty->assign ("goFonHardware", $this->goFonHardware); - - $perms = ""; - if($this->acl_is_writeable("goFonHardware")){ - $perms = " disabled "; - } - - $hl= "\n"; - $smarty->assign ("hardware_list", $hl); - $smarty->assign ("gotoXMonitor", $this->gotoXMonitor); - - if($this->AutoSync){ - $smarty->assign("AutoSyncCHK"," checked "); - $smarty->assign("hiddenState"," disabled "); - }else{ - $smarty->assign("AutoSyncCHK"," "); - $smarty->assign("hiddenState",""); - } - - /* Show main page */ - return($smarty->fetch (get_template_path('workstationService.tpl',TRUE,dirname(__FILE__)))); - } - - function remove_from_parent() - { - $this->handle_post_events("remove"); - new log("remove","workstation/".get_class($this),$this->dn); - } - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - - if((isset($_POST['gotoXDriver'])) && $this->acl_is_writeable("AutoSync")) { - if(isset($_POST['AutoSync'])){ - $this->AutoSync = true; - }else{ - $this->AutoSync = false; - } - } - } - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Default entries can use blank hsync/vsync entries */ - if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){ - - /* But only if no auto sync is enabled... */ - if (!$this->AutoSync){ - - /* Check vsync for correct usage */ - $val= preg_replace ("/\s/", "", $this->gotoXVsync); - - if($this->acl_is_writeable("gotoXVsync")){ - if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){ - $message[]= _("Please specify a valid VSync range."); - } else{ - list($v1,$v2)= preg_split ("/[-+]/", $val); - if ($v2 != ""){ - if ($v1 > $v2){ - $message[]= _("Please specify a valid VSync range."); - } - } - } - } - - /* Check hsync for correct usage */ - $val= preg_replace ("/\s/", "", $this->gotoXHsync); - if($this->acl_is_writeable("gotoXHsync")){ - if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){ - $message[]= _("Please specify a valid HSync range."); - } else{ - list($v1,$v2)= preg_split ("/[-+]/", $val); - if ($v2 != ""){ - if ($v1 > $v2){ - $message[]= _("Please specify a valid HSync range."); - } - } - } - } - } - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - /* remove objectclass GOhard if this is an ogroup tab */ - if(isset($this->parent->by_object['ogroup'])){ - $this->objectclasses = array(); - } - - plugin::save(); - - /* Strip out 'default' values */ - foreach(array( - "gotoXDriver", "gotoXResolution", "gotoXColordepth", - "gotoXKbModel", "gotoXKbLayout", - "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){ - - if ($this->attrs[$val] == "default"){ - $this->attrs[$val]= array(); - } - } - - if($this->AutoSync){ - $this->attrs['gotoXHsync'] = "30+55"; - $this->attrs['gotoXVsync'] = "50+70"; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/service with dn '%s' failed."),$this->dn)); - $this->handle_post_events("modify"); - } - - - function getListOfXDrivers() - { - /* Generate a list of xdrivers from CONFIG_DIR./xdrivers */ - $drivers = array(); - if (file_exists(CONFIG_DIR.'/xdrivers')){ - $xdrivers = file (CONFIG_DIR.'/xdrivers'); - foreach ($xdrivers as $line){ - if (!preg_match ("/^#/", $line)){ - $drivers[]= trim($line); - } - } - } else { - $drivers = array("ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", "fglrx", - "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc", "nv", "nvidia", - "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion", - "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware"); - } - return($drivers); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Service"), - "plDescription" => _("Workstation service"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 10, - "plSection" => array("administration"), - "plCategory" => array("workstation","ogroups"), - - "plProvidedAcls"=> array( - "gotoXMonitor" => _("Monitor"), - "gotoXDriver" => _("Gfx driver"), - "gotoXResolution" => _("Gfx resolution"), - "gotoXColordepth" => _("Gfx color depth"), - "gotoXHsync" => _("Hsync"), - "gotoXVsync" => _("Vsync"), - "AutoSync" => _("Use DDC"), - "gotoScannerEnable" => _("Scanner enabled"), - "gotoXKbModel" => _("Keyboard model"), - "gotoXKbLayout" => _("Keyboard layout"), - "gotoXKbVariant" => _("Keyboard variant"), - "gotoXMouseType" => _("Mouse type"), - "gotoXMouseport" => _("Mouse port"), - "goFonHardware" => _("Telephone hardware")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/class_workstationStartup.inc b/plugins/admin/systems/class_workstationStartup.inc deleted file mode 100644 index 8e9ed5240..000000000 --- a/plugins/admin/systems/class_workstationStartup.inc +++ /dev/null @@ -1,1360 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Ldap server list */ - var $gotoLdapServers = array(); - var $gotoLdapServerList = array(); - var $gotoLdap_inherit = FALSE; - - /* Generic terminal attributes */ - var $bootmode = "G"; - var $gotoBootKernel = "default-inherited"; - var $gotoKernelParameters = ""; - var $gotoLdapServer = "default-inherited"; - var $gotoModules = array(); - var $gotoAutoFs = array(); - var $gotoFilesystem = array(); - var $gotoTerminalPath = ""; - var $FAIstatus = ""; - var $gotoBootKernels = array(); - - /* attribute list for save action */ - var $attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "FAIclass", "FAIstatus", "gotoShare","FAIdebianMirror", "FAIrelease"); - var $objectclasses = array("GOhard", "FAIobject"); - - /* Share */ - var $gotoShares = array();// Currently Share Option - var $gotoShare = ""; // currently selected Share Option - var $gotoShareSelections= array();// Available Shares for this account in Listbox format - var $gotoAvailableShares= array();// Available Shares for this account - - /* Helper */ - var $customParameters = ""; - var $orig_dn = ""; - var $ignore_account = TRUE; - - /* FAI class selection */ - var $FAIclass = array(); - var $FAIclasses = array(); - var $FAIclassInfo = array(); - var $FAIrelease = ""; - var $FAIdebianMirror = "auto"; - - var $unresolved_classes = array(); - var $view_logged = FALSE; - - /* FAI class selection */ - var $InheritedFAIclass = array(); - var $InheritedFAIrelease = ""; - var $InheritedFAIdebianMirror = "auto"; - - /* Contains all possible server/release/class settings */ - var $FAIServRepConfig = array(); - - var $CopyPasteVars = array("gotoModules","gotoShares"); - - var $fai_activated = FALSE; - var $o_group_dn =""; - var $member_of_ogroup = FALSE; - - function workstartup (&$config, $dn= NULL, $parent= NULL) - { - /* Check if FAI is active */ - $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - $this->fai_activated = TRUE; - }else{ - $this->attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "gotoShare"); - $this->objectclasses = array("GOhard"); - } - - plugin::plugin ($config, $dn, $parent); - - if(!isset($this->parent->by_object['ogroup'])){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn","dn")); - if($ldap->count()){ - $this->member_of_ogroup = TRUE; - $attrs = $ldap->fetch(); - $this->o_group_dn = $attrs['dn']; - } - } - - /* Creating a list of valid Mirrors - * none will not be saved to ldap. - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - foreach($this->config->data['SERVERS']['LDAP'] as $server) { - $this->gotoLdapServerList[]= $server; - } - - if(isset($this->attrs['gotoLdapServer'])){ - unset($this->attrs['gotoLdapServer']['count']); - sort($this->attrs['gotoLdapServer']); - foreach($this->attrs['gotoLdapServer'] as $value){ - $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value); - } - } - if(!count($this->gotoLdapServers) && $this->member_of_ogroup){ - $this->gotoLdap_inherit = TRUE; - } - - /* FAI Initialization - Skip this if FAI is not activated - */ - if($this->fai_activated) { - - $_SESSION['getAvailableClassesForThisRelease_CACHE'] = array(); - $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'] = array(); - - /* Search all FAI objects */ - $ldap->search("(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAIpartitionTable))",array("cn","objectClass","FAIdebianSection",'description')); - /* Sort all entries, and attach elementtype. - * To be able to show the types in the listbox. - */ - while($attr = $ldap->fetch()){ - $cn = $attr['cn'][0]; - - if(!isset($attr['description'])){ - $attr['description'][0] =""; - } - - $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'][] = $attr; - - if(in_array('FAIpackageList',$attr['objectClass'])){ - $tmp2[$cn]['FAIpackageList']['obj'] = 'FAIpackageList'; - $tmp2[$cn]['FAIpackageList']['kzl'] = 'Pl'; - $tmp2[$cn]['FAIpackageList']['sec'] = $attr['FAIdebianSection']; - $tmp2[$cn]['FAIpackageList']['desc'] = $attr['description']; - $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; - } - if(in_array('FAItemplate',$attr['objectClass'])){ - $tmp2[$cn]['FAItemplate']['obj'] = 'FAItemplate'; - $tmp2[$cn]['FAItemplate']['kzl'] = 'T'; - $tmp2[$cn]['FAItemplate']['desc'] = $attr['description']; - $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; - } - if(in_array('FAIvariable',$attr['objectClass'])){ - $tmp2[$cn]['FAIvariable']['obj'] = 'FAIvariable'; - $tmp2[$cn]['FAIvariable']['kzl'] = 'V'; - $tmp2[$cn]['FAIvariable']['desc'] = $attr['description']; - $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; - } - if(in_array('FAIscript',$attr['objectClass'])){ - $tmp2[$cn]['FAIscript']['obj'] = 'FAIscript'; - $tmp2[$cn]['FAIscript']['kzl'] = 'S'; - $tmp2[$cn]['FAIscript']['desc'] = $attr['description']; - $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; - } - if(in_array('FAIhook',$attr['objectClass'])){ - $tmp2[$cn]['FAIhook']['obj'] = 'FAIhook'; - $tmp2[$cn]['FAIhook']['kzl'] = 'H'; - $tmp2[$cn]['FAIhook']['desc'] = $attr['description']; - $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; - } - if(in_array('FAIpartitionTable',$attr['objectClass'])){ - $tmp2[$cn]['FAIpartitionTable']['obj']= 'FAIpartitionTable'; - $tmp2[$cn]['FAIpartitionTable']['kzl']= 'Pt'; - $tmp2[$cn]['FAIpartitionTable']['desc'] = $attr['description']; - $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; - } - if(in_array('FAIprofile',$attr['objectClass'])){ - $tmp2[$cn]['FAIprofile']['obj']= 'FAIprofile'; - $tmp2[$cn]['FAIprofile']['kzl']= 'P'; - $tmp2[$cn]['FAIprofile']['desc'] = $attr['description']; - $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0]; - } - } - if(is_array($this->FAIclasses)){ - natcasesort($this->FAIclasses); - } - - if(isset($tmp2)){ - $this->FAIclassInfo = $tmp2; - } else { - $this->FAIclassInfo = array(); - } - - /* Build up an array like this one : - [$url]['SERVER'] = 'srv1-002'; - [$url]['RELEASE']['siga/rc9.0.2'] - ['SECTIONS'][0] "main"; - ['SECTIONS'][1] "non-free"; - [$url]['RELEASE']['siga/rc9.0.2'] - ['PACKAGES'][0] "pkg1"; - ['PACKAGES'][1] "postfix"; - */ - - $ldap->search("(&(FAIrepository=*)(objectClass=FAIrepositoryServer))",array("FAIrepository")); - $test = array(); - while($attr = $ldap->fetch()){ - if(isset($attr['FAIrepository'])){ - - unset($attr['FAIrepository']['count']); - - foreach($attr['FAIrepository'] as $rep){ - $tmp = split("\|",$rep); - - if(count($tmp)==4){ - $sections = split(",",$tmp[3]); - $release = $tmp[2]; - $server = $tmp[1]; - $url = $tmp[0]; - - $test[$url]['RELEASE'][$release]['SECTIONS'] = $sections; - - /* Result will be cached - */ - $rel_classes = $this->getAvailableClassesForThisRelease($release); - $test[$url]['RELEASE'][$release]['PACKAGES'] = $rel_classes; - $test[$url]['SERVER'] = $server; - - /* auto gets all releases/classes - */ - $test['auto']['RELEASE'][$release]['SECTION'] = $sections; - $test['auto']['RELEASE'][$release]['PACKAGES'] = $rel_classes; - } - } - } - } - - /* Add possible elements from hook */ - $lines= $this->GetHookElements(); - foreach ($lines as $hline){ - $entries= split(";", $hline); - if (isset($entries[1]) && !isset($test[$entries[1]])){ - $test[$entries[1]]['RELEASE']= array(); - - /* Split releases */ - if (isset($entries[2])){ - $releases= split(",", $entries[2]); - - foreach ($releases as $release){ - $rname= preg_replace('/:.*$/', '', $release); - $sections= split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release)); - $classes= split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release)); - $test[$entries[1]]['RELEASE'][$rname]= array(); - $test[$entries[1]]['RELEASE'][$rname]['SECTION']= $sections; - foreach ($classes as $class){ - if ($class != ""){ - $test[$entries[1]]['RELEASE'][$rname]['PACKAGES'][$class]= $class; - } - } - } - } - } - } - - $this->FAIServRepConfig= $test; - - if((isset($this->FAIclass))&&(!is_array($this->FAIclass))){ - $tmp = array(); - $tmp = split(" ",$this->FAIclass); - $tmp2 =array(); - - foreach($tmp as $class){ - if( ":" == $class[0] ) { - $this->FAIrelease = substr( $class, 1 ); - } - else - { - $tmp2[$class] = $class; - } - } - $this->FAIclass = $tmp2; - } - - if(!is_array($this->FAIclass)){ - $this->FAIclass =array(); - } - }// END of FAI initialization stuff - - - /* Get arrays */ - foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){ - if (isset($this->attrs["$val"]["count"])){ - for ($i= 0; $i<$this->attrs["count"]; $i++){ - if (isset($this->attrs["$val"][$i])){ - array_push($this->$val, $this->attrs["$val"][$i]); - } - } - } - sort ($this->$val); - $this->$val= array_unique($this->$val); - } - - /* Parse Kernel Parameters to decide what boot mode is enabled */ - if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){ - $this->bootmode= "G"; - } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){ - $this->bootmode= "D"; - } elseif ($this->gotoKernelParameters == "") { - $this->bootmode= "G"; - } else { - $this->bootmode= "T"; - } - if (preg_match("/ o /", $this->gotoKernelParameters)){ - $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters); - } else { - $this->customParameters= ""; - } - - /* Prepare Shares */ - if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){ - unset($this->attrs['gotoShare']['count']); - foreach($this->attrs['gotoShare'] as $share){ - $tmp = $tmp2 = array(); - $tmp = split("\|",$share); - $tmp2['server'] =$tmp[0]; - $tmp2['name'] =$tmp[1]; - $tmp2['mountPoint'] =$tmp[2]; - $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; - } - } - - $this->gotoShareSelections= $config->getShareList(true); - $this->gotoAvailableShares= $config->getShareList(false); - $tmp2 = array(); - - - $this->orig_dn= $this->dn; - - /* Handle inheritance value "default" */ - if ($this->member_of_ogroup){ - $this->gotoBootKernels= array("default-inherited" => '['._("inherited").']'); - } - - /* Load hardware list */ - if ($this->member_of_ogroup){ - - if(count($this->FAIclass)==0 && $this->FAIrelease == ""){ - $this->FAIdebianMirror = "inherited"; - } - - if($this->fai_activated){ - $map= array("gotoBootKernel","FAIclass","FAIdebianMirror"); - }else{ - $map= array("gotoBootKernel"); - } - - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->o_group_dn); - $attrs= $ldap->fetch(); - - foreach ($map as $name){ - if (!isset($attrs[$name][0])){ - continue; - } - - switch ($name){ - case 'gotoBootKernel': - $this->gotoBootKernels['default-inherited']= _("inherited").' ['.$attrs[$name][0].']' ; - break; - - case 'FAIclass': - $str = split(":",$attrs[$name][0]); - $this->InheritedFAIclass = split("\ ",trim($str[0])); - $this->InheritedFAIrelease = trim($str[1]); - break; - - case 'FAIdebianMirror': - $this->InheritedFAIdebianMirror = $attrs[$name][0]; - break; - } - } - } - - /* Get list of boot kernels */ - if (isset($this->config->data['TABS'])){ - $command= $this->config->search(get_class($this), "KERNELS",array('tabs')); - - if (!check_command($command)){ - $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command, - get_class($this)); - } else { - $fh= popen($command, "r"); - while (!feof($fh)) { - $buffer= trim(fgets($fh, 256)); - - if(!empty($buffer)){ - - $name=$value = $buffer; - - if(preg_match("/:/",$buffer)){ - $name = preg_replace("/:.*$/","",$buffer); - $value= preg_replace("/^.*:/","",$buffer); - $this->gotoBootKernels[$name]= $name.":".$value; - }else{ - $this->gotoBootKernels[$name]= $value; - } - } - - } - pclose($fh); - } - } - - /* Turn to default, if we've nothing to inherit */ - if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){ - $this->gotoBootKernel= "default"; - } - - /* Preselect release if none was selected yet */ - if(empty($this->FAIrelease) && $this->FAIdebianMirror == "auto"){ - if(isset($this->FAIServRepConfig['auto']['RELEASE']) && is_array($this->FAIServRepConfig['auto']['RELEASE'])){ - $this->FAIrelease = key($this->FAIServRepConfig['auto']['RELEASE']); - } - } - } - - - /* This class is called by the contrucktor ONLY. - * It return the available classes for each - * Server / Release combination ... - * (Release specifies which classes are available) - */ - function getAvailableClassesForThisRelease($release) - { - /* There could be more than one server providing this release, - so use cached result if available - */ - if(isset($_SESSION['getAvailableClassesForThisRelease_CACHE'][$release])) { - return($_SESSION['getAvailableClassesForThisRelease_CACHE'][$release]); - } - - $test2 = array(); - $bb = $this->generateDNSyn($release); - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* Get classes fpr given release */ - $p_classes = get_all_objects_for_given_base($bb, - "(|(objectClass=FAIpackageList)(objectClass=FAItemplate)". - "(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)". - "(objectClass=FAIprofile)(objectClass=FAIpartitionTable))"); - - /* Create list of classes */ - foreach($p_classes as $class){ - $ldap->cat($class['dn'],array("cn")); - $attr = $ldap->fetch(); - $test2[$attr['cn'][0]] = $attr['cn'][0]; - } - $_SESSION['getAvailableClassesForThisRelease_CACHE'][$release] = $test2; - return($test2); - } - - - /* Create array to display available classes/profiles in a selectbox - * This function only displays the available classes. - * If a class is available is defined by these facts : - * 1. Is this class available for the selected release ? - * - if it is available, check if the release is available for the selected server - * (done by $this->getFAIreleases()) - * 2. Is this class currently not assigned to $this->FAIclass - */ - function selectFriendlyClasses(){ - $tmp=array(); - - if($this->FAIdebianMirror == "inherited" || $this->FAIrelease == ""){ - return($tmp); - } - - /* check if the current release exists, - else select the first one .. - */ - $tmp2 = $this->getFAIreleases(); - if(!isset($tmp2[$this->FAIrelease]) || !$tmp2[$this->FAIrelease]['USE']){ - foreach($tmp2 as $key => $data){ - if($data['USE']){ - $this->FAIrelease = $key; - } - } - } - if(!in_array($this->FAIrelease, $tmp2)){ -# $this->FAIrelease = key($tmp2); - } - - /* Get all Packages for this server/release combination - */ - if(!isset($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'][$this->FAIrelease]['PACKAGES'])){ - $pkgs = array(); - print_red(_("There are packages in your configuration, which can't be resolved with current server/release settings.")); - }else{ - $pkgs = $this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'][$this->FAIrelease]['PACKAGES']; - } - - /* Check each and every single class name - */ - foreach($pkgs as $pkg){ - - /* Class already assigned to the classes list ? - * If not ... go on - */ - if(!in_array($pkg,$this->FAIclass)){ - - /* Create the displayed list entry value - HKLMOP [-Pl P V T-] or something like that - */ - $str = ""; - foreach($this->FAIclassInfo[$pkg] as $entry){ - if(isset($entry['kzl'])){ - $str .= $entry['kzl']." "; - } - } - - /* Append class if everyting was fine - */ - $tmp[$pkg] = $pkg." [-".trim($str)."-]"; - } - } - /* Just sort and return new classes list ... - ( possibly we should cache the result ... ) - */ - natcasesort ($tmp); - return($tmp); - } - - function check() - { - $messages = array(); - - /* Call common method to give check the hook */ - $messages= plugin::check(); - - /* If there are packages selected, but no mirror show error */ - if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){ - $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'."); - } - - return($messages); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","workstation/".get_class($this),$this->dn); - } - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Do we represent a valid terminal? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' has no terminal features.").""; - return ($display); - } - - /* Add module */ - if (isset ($_POST['add_module'])){ - if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModule")){ - $this->add_list ($this->gotoModules, $_POST['module']); - } - } - - /* Delete module */ - if (isset ($_POST['delete_module'])){ - if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModule")){ - $this->del_list ($this->gotoModules, $_POST['modules_list']); - } - } - - /* FAI class management */ - if($this->fai_activated){ - if(((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))) && ($this->acl_is_writeable("FAIclass"))){ - $found = 0 ; - - /* If this new class/profile will attach a second partition table - * to our list of classes, abort and show a message. - */ - foreach($this->FAIclass as $name){ - if(isset($this->FAIclassInfo[$name])){ - foreach($this->FAIclassInfo[$name] as $atr){ - if(isset($atr['obj'])){ - if($atr['obj'] == "FAIpartitionTable"){ - $found ++ ; - } - } - } - } - } - - if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){ - print_red(_("There is already a profile in your selection that contain partition table configurations.")); - }else{ - $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel']; - } - } - - $sort = false; - - /* Move one used class class one position up or down */ - if($this->acl_is_writeable("FAIclass")){ - foreach($_POST as $name => $val){ - - $sort_type = false; - if((preg_match("/sort_up/",$name))&&(!$sort)){ - $sort_type = "sort_up_"; - } - if((preg_match("/sort_down/",$name))&&(!$sort)){ - $sort_type = "sort_down_"; - } - - if(($sort_type)&&(!$sort)){ - $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name))); - $sort = true; - - $last = -1; - $change_down = -1; - - /* Create array with numeric index */ - $tmp = array(); - foreach($this->FAIclass as $class){ - $tmp [] = $class; - } - - /* Walk trough array */ - foreach($tmp as $key => $faiName){ - if($faiName == $value){ - if($sort_type == "sort_up_"){ - if($last != -1){ - $change_down= $last; - } - }else{ - if(isset($tmp[$key+1])){ - $change_down = $key; - } - } - } - $last = $key; - } - - $tmp2 = array(); - $skip = false; - - foreach($tmp as $ky => $vl){ - - if($ky == $change_down){ - $skip = $vl; - }else{ - $tmp2[$vl] = $vl; - } - if(($skip != false)&&($ky != $change_down)){ - $tmp2[$skip] = $skip; - $skip =false; - } - } - $this->FAIclass = $tmp2; - } - - if(preg_match("/fai_remove/i",$name)){ - $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name))); - unset($this->FAIclass[$value]); - } - } - } - - /* Delete selected class from our list */ - if($this->acl_is_writeable("FAIclass")){ - if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){ - if(isset($this->FAIclass[$_POST['FAIclassSel']])){ - unset($this->FAIclass[$_POST['FAIclassSel']]); - } - } - } - }// END fai handling - - /* Show main page */ - $smarty= get_smarty(); - - /* Assign ACLs to smarty */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $smarty->assign("member_of_ogroup",$this->member_of_ogroup); - - /* In this section server shares will be defined - * A user can select one of the given shares and a mount point - * and attach this combination to his setup. - */ - $smarty->assign("gotoShareSelections", $this->gotoShareSelections); - $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections)); - - /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry - * This entry will be, a combination of mountPoint and sharedefinitions - */ - if((isset($_POST['gotoShareAdd'])) && ($this->acl_is_writeable("gotoShare"))) { - /* We assign a share to this user, if we don't know where to mount the share */ - if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){ - print_red(_("You must specify a valid mount point.")); - }else{ - if(count($this->gotoAvailableShares)){ - $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']]; - $s_mount = $_POST['gotoShareMountPoint']; - /* Preparing the new assignment */ - $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share; - $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount; - } - } - } - - /* if the Post gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected) - * If there is no defined share selected, we will abort the deletion without any message - */ - if(($this->acl_is_writeable("gotoShare"))&& (isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){ - unset($this->gotoShares[$_POST['gotoShare']]); - } - - $smarty->assign("gotoShares",$this->printOutAssignedShares()); - $smarty->assign("gotoSharesCount",count($this->printOutAssignedShares())); - $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares())); - $smarty->assign("gotoBootKernels",$this->gotoBootKernels); - - /* Create divSelectBox for ldap server selection - */ - $SelectBoxLdapServer = new divSelectBox("LdapServer"); - $SelectBoxLdapServer->SetHeight(130); - - /* Add new ldap server to the list */ - if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){ - if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){ - $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']]; - if(!in_array($to_add,$this->gotoLdapServers)){ - $this->gotoLdapServers[] = $to_add; - } - } - } - - /* Move ldap servers up and down */ - if(!$this->gotoLdap_inherit){ - foreach($_POST as $name => $value){ - if(preg_match("/sort_ldap_up_/",$name)){ - $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name); - $from = $id; - $to = $id -1; - $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); - if($tmp){ - $this->gotoLdapServers = $tmp; - } - break; - } - if(preg_match("/sort_ldap_down_/",$name)){ - $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name); - $from = $id; - $to = $id +1; - $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to); - if($tmp){ - $this->gotoLdapServers = $tmp; - } - break; - } - if(preg_match("/gotoLdapRemove_/",$name)){ - $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name); - $value = $this->gotoLdapServers[$id]; - $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers); - break; - } - } - } - - /* Add Entries - */ - foreach($this->gotoLdapServers as $key => $server){ - if(!in_array($server,$this->gotoLdapServerList)){ - $server = $server." (missing)"; - } - - $SelectBoxLdapServer->AddEntry( - array(array("string" => $server), - array("string" => - " ". - " ". - "", - "attach" => "style='text-align:right;width:40px;border-right:0px;'"))); - } - - if($this->gotoLdap_inherit){ - $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));; - }else{ - $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer")); - } - - $list = array(); - foreach($this->gotoLdapServerList as $key => $entry){ - if(!in_array($entry,$this->gotoLdapServers)){ - $list[$key] = $entry; - } - } - $smarty->assign("gotoLdapServers", $SelectBoxLdapServer->DrawList()); - $smarty->assign("gotoLdapServerList", $list); - $smarty->assign("gotoLdap_inherit", $this->gotoLdap_inherit); - $smarty->assign("JS", $_SESSION['js']); - - foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){ - $smarty->assign("$val", $this->$val); - } - - /* Values */ - foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){ - $smarty->assign($val, $this->$val); - } - - $smarty->assign("fai_activated",$this->fai_activated); - - /* Create FAI output */ - if($this->fai_activated){ - $smarty->assign("FAIdebianMirrors",$this->getFAIdebianMirrors()); - $smarty->assign("FAIdebianMirror",$this->FAIdebianMirror); - $smarty->assign("FAIreleases",$this->getFAIreleases()); - $smarty->assign("FAIrelease",$this->FAIrelease); - $smarty->assign("FAIclasses",$this->selectFriendlyClasses()); - $smarty->assign("FAIclassesKeys",array_flip($this->selectFriendlyClasses())); - $smarty->assign("FAIclassKeys",$this->FAIclass); - - $inheritedRelease = array(); - if(!empty($this->InheritedFAIrelease)){ - $inheritedRelease[$this->InheritedFAIrelease]= $this->InheritedFAIrelease; - } - $smarty->assign("InheritedFAIrelease",$inheritedRelease); - - $div = new divSelectBox("WSFAIscriptClasses"); - $div -> SetHeight("110"); - $str_up = "  "; - $str_down = "  "; - $str_remove = "  "; - $str_empty = "  \"\""; - - $i = 1; - - if($this->FAIdebianMirror == "inherited"){ - $tmp = $this->InheritedFAIclass; - }else{ - $tmp = $this->FAIclass; - } - - foreach($tmp as $class){ - - $marker = ""; - if(in_array_ics($class,$this->unresolved_classes)){ - $marker = " ("._("Not available in current setup").")"; - } - - if($this->FAIdebianMirror == "inherited"){ - $str = ""; - }else{ - if($i==1){ - $str = $str_empty.$str_down.$str_remove; - }elseif($i == count($this->FAIclass)){ - $str = $str_up.$str_empty.$str_remove; - }else{ - $str = $str_up.$str_down.$str_remove; - } - } - $i ++ ; - - $desc = ""; - if(isset($this->FAIclassInfo[$class])){ - foreach($this->FAIclassInfo[$class] as $types ){ - if(isset($types['desc'][0])){ - $desc.= $types['desc'][0]." "; - } - } - } - if(!empty($desc)){ - $desc = " [".trim($desc)."]"; - } - - $div->AddEntry(array( - array("string"=>$class.$desc.$marker), - array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'") - )); - } - $smarty->assign("FAIScriptlist",$div->DrawList()); - }// END FAI output generation - - /* Radio button group */ - if (preg_match("/G/", $this->bootmode)) { - $smarty->assign("graphicalbootup", "checked"); - } else { - $smarty->assign("graphicalbootup", ""); - } - if (preg_match("/T/", $this->bootmode)) { - $smarty->assign("textbootup", "checked"); - } else { - $smarty->assign("textbootup", ""); - } - if (preg_match("/D/", $this->bootmode)) { - $smarty->assign("debugbootup", "checked"); - } else { - $smarty->assign("debugbootup", ""); - } - - /* Show main page */ - return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__)))); - } - - function remove_from_parent() - { - $this->handle_post_events("remove"); - new log("remove","workstation/".get_class($this),$this->dn); - } - - function generateDNSyn($release) - { - $str = ""; - $tmp = split("\/",$release); - $tmp = array_reverse($tmp); - $base = "ou=fai,ou=configs,ou=systems,"; - foreach($tmp as $departmentname){ - $str .= ",ou=".$departmentname; - } - $str = preg_replace("/^,/","",($str.",".$base)); - - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=FAIbranch))",array("ou")); - while($attrs = $ldap->fetch()){ - if(preg_match("/".normalizePreg($str)."/",$attrs['dn'])){ - return($attrs['dn']); - } - } - - return($str.$this->config->current['BASE']); - } - - function getFAIdebianMirrors() - { - $ret = array(); - - /* Only add inherit option, if we are part in an object group - */ - if($this->member_of_ogroup) { - $ret['inherited']['NAME']="["._("inherited")."]"; - $ret['inherited']['USE'] = TRUE; - } - - $ret['auto']['NAME']=_("automatic"); - $ret['auto']['USE'] = TRUE; - $secs = array(); - - /* Walk through all available servers - and check if they support the currently selected classes - if not, dont't add them to our list - */ - foreach($this->FAIServRepConfig as $mirror => $rest){ - - /* Automatically selection is available everytime */ - if($mirror == "auto"){ - continue; - } - - $use = false; - if(count($this->FAIclass) == 0){ - $use = true; - }else{ - $tmp = $this->getFAIreleases(); - foreach($tmp as $release => $data){ - if(isset($rest['RELEASE'][$release]) && $release == $this->FAIrelease){ - $use = $data['USE']; - } - } - } - - /* If current server, doesn't support this class - remove it from list - */ - $ret[$mirror]['NAME'] = $mirror; - $ret[$mirror]['USE'] = $use; - } - return($ret); - } - - function getFAIreleases() - { - $ret = array(); - - if($this->FAIdebianMirror == "inherited") { - return(array()); - } - - if(!isset($this->FAIServRepConfig[$this->FAIdebianMirror])){ - $this->FAIdebianMirror = "auto"; - } - - $errorClasses = array(); - if(isset($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'])) { - foreach($this->FAIServRepConfig[$this->FAIdebianMirror]['RELEASE'] as $release => $sections){ - $use = true; - - if(!count($this->FAIclass) == 0){ - foreach($this->FAIclass as $class){ - if(!in_array($class, $sections['PACKAGES'])){ - $use = false; - $errorClasses[$class] = $class; - }else{ - if(isset($errorClasses[$class])){ - unset($errorClasses[$class]); - } - } - } - } - $ret[$release]['NAME']=$release; - $ret[$release]['USE']=$use; - } - } - - if((count($ret) == 0 ) && ($this->FAIdebianMirror != "auto")){ - $eClasses = " "; - foreach($errorClasses as $class){ - $eClasses .= $class." "; - } - - print_red(sprintf(_("Can't resolve one or more of the given FAIclass(es) [%s] in FAI server '%s'. Server was reset to 'auto'."),$eClasses, $this->FAIdebianMirror)); - $this->FAIdebianMirror = "auto"; - return($this->getFAIreleases()); - }elseif((count($ret) == 0 ) && ($this->FAIdebianMirror == "auto")){ - - $eClasses = " "; - foreach($errorClasses as $class){ - $eClasses .= $class." "; - } - - $eClasses = preg_replace("/ */","",$eClasses); - - if(!empty($eClasses)) { - - $this->unresolved_classes = $errorClasses; - $this->FAIdebianMirror = "auto"; - print_red(sprintf(_("Can't resolve the given FAIclass(es) [%s] anyway, please check your FAI configurations, possibly some classes where deleted or renamed. Server was reset to 'auto'."),$eClasses)); - } - } - return($ret); - } - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - - if(isset($_POST['WorkstationStarttabPosted'])){ - if(isset($_POST['gotoLdap_inherit'])){ - $this->gotoLdap_inherit = TRUE; - }else{ - $this->gotoLdap_inherit = FALSE; - } - - /* Save group radio buttons */ - if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){ - $this->bootmode= $_POST["bootmode"]; - } - - /* Save kernel parameters */ - if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){ - $this->customParameters= $_POST["customParameters"]; - } - } - } - - - /* Save to LDAP */ - function save() - { - - /* Depending on the baseobject (Ogroup / WS) we - * use another set of objectClasses - * In case of WS itself, we use "array("GOhard", "FAIobject");" - * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject")) - */ - if(isset($this->parent->by_object['ogroup'])){ - $this->objectclasses = array("gotoWorkstationTemplate"); - }elseif(isset($this->parent->by_object['workgeneric'])){ - $this->objectclasses = array("GOhard"); - }elseif(isset($this->parent->by_object['servgeneric'])){ - $this->objectclasses = array("GOhard","gotoWorkstationTemplate"); - }else{ - print "Object Type Configuration : unknown"; - exit(); - } - - /* Append FAI class */ - if($this->fai_activated){ - $this->objectclasses[] = "FAIobject"; - } - - /* Find proper terminal path for tftp configuration - FIXME: This is suboptimal when the default has changed to - another location! */ - if (($this->gotoTerminalPath == "default")){ - $ldap= $this->config->get_ldap_link(); - - /* Strip relevant part from dn, keep trailing ',' */ - $tmp= preg_replace("/^cn=[^,]+,ou=terminals,ou=systems,/i", "", $this->dn); - $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp); - - /* Walk from top to base and try to load default values for - 'gotoTerminalPath'. Abort when an entry is found. */ - while (TRUE){ - $tmp= preg_replace ("/^[^,]+,/", "", $tmp); - - $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp". - $this->config->current['BASE'], array('gotoTerminalPath')); - $attrs= $ldap->fetch(); - if (isset($attrs['gotoTerminalPath'])){ - $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0]; - break; - } - - /* Nothing left? */ - if ($tmp == ""){ - break; - } - } - } - - /* Add semi automatic values */ - // FIXME: LDAP Server may not be set here... - $this->gotoKernelParameters= "ldap=".base64_encode($this->gotoLdapServer); - - switch ($this->bootmode){ - case "D": - $this->gotoKernelParameters.= " debug"; - break; - case "G": - $this->gotoKernelParameters.= " splash=silent"; - break; - } - if ($this->customParameters != ""){ - $this->gotoKernelParameters.= " o ".$this->customParameters; - } - - plugin::save(); - - unset( $this->attrs['FAIrelease'] ); - - $str = ""; - - /* Skip FAI attribute handling if not necessary */ - if($this->fai_activated){ - if($this->FAIdebianMirror == "inherited"){ - $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] = $this->attrs['FAIdebianMirror'] = array(); - }else{ - foreach($this->FAIclass as $class){ - $str .= $class." "; - } - $str .= ":" . $this->FAIrelease; - $this->attrs['FAIclass']= ""; - $this->attrs['FAIclass']= trim($str); - - if(empty($this->attrs['FAIclass'])){ - $this->attrs['FAIclass'] = array(); - } - } - } - - /* Add missing arrays */ - foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){ - if (isset ($this->$val) && count ($this->$val) != 0){ - - $this->attrs["$val"]= array_unique($this->$val); - } - if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array(); - } - - /* Prepare list of ldap servers */ - $this->attrs['gotoLdapServer'] = array(); - if(!$this->gotoLdap_inherit){ - $i = 0; - foreach($this->gotoLdapServers as $server){ - $i ++; - $this->attrs['gotoLdapServer'][] = $i.":".$server; - } - } - - if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){ - $this->attrs['gotoBootKernel']= array(); - } - - /* if mirror == none stop saving this attribute */ - if($this->FAIdebianMirror == "none"){ - $this->FAIdebianMirror = ""; - } - - /* Get FAIstate from object, the generic tab could have changed it during execute */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - - - /* Skip FAI attribute handling if not necessary */ - if($this->fai_activated){ - $ldap->cat($this->dn,array("FAIstate")); - $checkFAIstate = $ldap->fetch(); - - /* Remove FAI objects if no FAI class is selected */ - if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){ - $this->attrs['FAIclass'] = array(); - $this->attrs['FAIdebianMirror'] = array(); - } - } - - - /* prepare share settings */ - $tmp = array(); - foreach($this->gotoShares as $name => $settings){ - $tmp2= split("\|",$name); - $name = $tmp2[0]; - $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint']; - } - $this->attrs['gotoShare']=$tmp; - - $this->cleanup(); - $ldap->modify ($this->attrs); - new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/startup with dn '%s' failed."),$this->dn)); - $this->handle_post_events("modify"); - } - - /* Add value to array, check if unique */ - function add_list (&$array, $value) - { - if ($value != ""){ - $array[]= $value; - sort($array); - array_unique ($array); - } - } - - - /* Delete value to array, check if unique */ - function del_list (&$array, $list) - { - $tmp= array(); - foreach ($array as $mod){ - if (!in_array($mod, $list)){ - $tmp[]= $mod; - } - } - $array= $tmp; - } - - /* Generate ListBox frindly output for the defined shares - * Possibly Add or remove an attribute here, - */ - function printOutAssignedShares() - { - $a_return = array(); - if(is_array($this->gotoShares)){ - foreach($this->gotoShares as $share){ - $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]"; - } - } - return($a_return); - } - - - function GetHookElements() - { - $ret = array(); - $cmd= $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs')); - if(!empty($cmd)){ - $res = shell_exec($cmd); - $res2 = trim($res); - if((!$res)){ - print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s' please check your gosa.conf."),$cmd)); - }elseif(empty($res2)){ - print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd)); - }else{ - $tmp = split("\n",$res); - foreach($tmp as $line){ - if(empty($line)) continue; - $ret[]= $line; - } - } - } - return($ret); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - $source_o = new workstartup ($this->config, $source['dn']); - - foreach(array("FAIclass","gotoModules", "gotoAutoFs", "gotoFilesystem","gotoKernelParameters","gotoShares","customParameters") as $attr){ - $this->$attr = $source_o->$attr; - } - } - - - function array_switch_item($ar,$from,$to) - { - if(!is_array($ar)){ - return(false); - } - if(!isset($ar[$from])){ - return(false); - } - if(!isset($ar[$to])){ - return(false); - } - - $tmp = $ar[$from]; - $ar[$from] = $ar[$to]; - $ar[$to] = $tmp; - return($ar); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Startup"), - "plDescription" => _("System startup"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 9, - "plSection" => array("administration"), - "plCategory" => array("workstation","server","ogroups"), - - "plProvidedAcls"=> array( - "gotoLdapServer" => _("Ldap server"), - "gotoBootKernel" => _("Boot kernel"), - "gotoKernelParameters" => _("Kernel parameter"), - - "gotoModules" => _("Kernel modules"), - "gotoShare" => _("Shares"), - - "FAIclass" => _("FAI classes"), - "FAIdebianMirror" => _("Debian mirror"), - "FAIrelease" => _("Debian release"), - - "FAIstatus" => _("FAI status flag")) // #FIXME is this acl realy necessary ? - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/component.tpl b/plugins/admin/systems/component.tpl deleted file mode 100644 index 3ddd5068c..000000000 --- a/plugins/admin/systems/component.tpl +++ /dev/null @@ -1,56 +0,0 @@ - - - - - -
- - - - - - - - - - - - -
{$must} -{render acl=$cnACL} - -{/render} -
 
{$must} -{render acl=$baseACL} - -{/render} -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} - -
-
- - - - - -
-{render acl=$descriptionACL} - -{/render} -
-
- -

 

- -{$netconfig} - - - diff --git a/plugins/admin/systems/contents.tpl b/plugins/admin/systems/contents.tpl deleted file mode 100644 index 001d50d43..000000000 --- a/plugins/admin/systems/contents.tpl +++ /dev/null @@ -1 +0,0 @@ -{$Kekse} sind gesund diff --git a/plugins/admin/systems/gencd.tpl b/plugins/admin/systems/gencd.tpl deleted file mode 100644 index f0c449677..000000000 --- a/plugins/admin/systems/gencd.tpl +++ /dev/null @@ -1,20 +0,0 @@ -

- {t}CD-Install-Image generation{/t} -

-

- {t}This option enables you to generate FAI install CD images for the selected workstation. The procedure may take about 10 minutes to complete, so please be patient after pressing the 'Create ISO-Image' button.{/t} -

- -

- -   - -

- - - diff --git a/plugins/admin/systems/gencd_frame.tpl b/plugins/admin/systems/gencd_frame.tpl deleted file mode 100644 index 4c53bdab5..000000000 --- a/plugins/admin/systems/gencd_frame.tpl +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/plugins/admin/systems/info.tpl b/plugins/admin/systems/info.tpl deleted file mode 100644 index e088c595a..000000000 --- a/plugins/admin/systems/info.tpl +++ /dev/null @@ -1,135 +0,0 @@ -

{t}System information{/t}

- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
{t}CPU{/t}{$ghCpuType}
{t}Memory{/t}{$ghMemSize}
{t}Boot MAC{/t}{$macAddress}
{t}USB support{/t}{$ghUsbSupport}
{t}System status{/t}{$status}
{t}Inventory number{/t}{$ghInventoryNumber}
{t}Last login{/t}{$gotoLastUser}
-
-   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{t}Network devices{/t} - {foreach item=netcard from=$ghNetNic} - {$netcard}
- {/foreach} -
{t}IDE devices{/t} - {foreach item=idedev from=$ghIdeDev} - {$idedev}
- {/foreach} -
{t}SCSI devices{/t} - {foreach item=scsidev from=$ghScsiDev} - {$scsidev}
- {/foreach} -
{t}Floppy device{/t}{$FloppyDevice}
{t}CDROM device{/t}{$CdromDevice}
{t}Graphic device{/t}{$ghGfxAdapter}
{t}Audio device{/t}{$ghSoundAdapter}
-
- -{if $active eq "true"} -
-

{t}System status{/t}

- - - - - - -
- - - - - - - - - - - - - - - - - {$partitions} -
{t}Up since{/t}{$uptime}
{t}CPU load{/t}{$load}
{t}Memory usage{/t}{$mem}
{t}Swap usage{/t}{$swap}
 
-
-   - - - - - - - - - - - - - - - - - -
{t}SSH service{/t}{$sshd}
{t}Print service{/t}{$cupsd}
{t}Scan service{/t}{$saned}
{t}Sound service{/t}{$artsd}
{t}GUI{/t}{$X}
-
-{/if} - diff --git a/plugins/admin/systems/main.inc b/plugins/admin/systems/main.inc deleted file mode 100644 index f9bd8fb9c..000000000 --- a/plugins/admin/systems/main.inc +++ /dev/null @@ -1,55 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('systems'); - } -} else { - /* Create usermanagement object on demand */ - if (!isset($_SESSION['systems']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['systems']= new systems($config, $ui); - } - $systems= $_SESSION['systems']; - $systems->save_object(); - $output= $systems->execute(); - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('systems'); - } - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/system.png'), _("System management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/system.png'), _("System management")); - } - - /* Show and save dialog */ - $display.= $output; - $_SESSION['systems']= $systems; -} - -?> diff --git a/plugins/admin/systems/network.tpl b/plugins/admin/systems/network.tpl deleted file mode 100644 index 7cb6b3ff9..000000000 --- a/plugins/admin/systems/network.tpl +++ /dev/null @@ -1,152 +0,0 @@ -

{t}Network settings{/t}

- - - - - - {if $DNS_is_account==true} - - {/if} - - -
- - - - - - - - - - {if $dhcpEnabled} - - - - {/if} -
-{render acl=$ipHostNumberACL} - -{/render} -{render acl=$ipHostNumberACL} -{if $DNSAccount == true} - - {else} - - {/if} -{/render} -
{$staticAddress} -{render acl=$macAddressACL} - -{/render} - {if $autonet==true} - - {/if} -
- - {if $dhcpParentNodeCnt} - - - - - {else} - - - - {/if} - {if $dhcp_is_Account} - - - - - {/if} -
- - - {t}Enable DHCP for this device{/t} - -
- - {t}Enable DHCP for this device{/t} ({t}not configured{/t}) - -
  - {t}Parent node{/t} - -   - -
-
-
- - {if $ZoneCnt} - {if $DNSAccount == true} - - {else} - - {/if} - - {t}Enable DNS for this device{/t} - - {if $DNSAccount == true} -
- {else} - - {else} - - {t}Enable DNS for this device{/t} ({t}not configured{/t}) - - {/if} - -
- - - diff --git a/plugins/admin/systems/password.tpl b/plugins/admin/systems/password.tpl deleted file mode 100644 index 734a4ae0c..000000000 --- a/plugins/admin/systems/password.tpl +++ /dev/null @@ -1,39 +0,0 @@ -

- {t}To change the terminal root password use the fields below. The changes take effect during the next reboot. Please memorize the new password, because you wouldn't be able to log in.{/t} -

-

- {t}Leave fields blank for password inheritance from default entries.{/t} -

- -

- {t}Changing the password impinges on authentification only.{/t} -

- - - - - - - - - - -
- -
- -

- -   - -

- - - diff --git a/plugins/admin/systems/paste_generic.tpl b/plugins/admin/systems/paste_generic.tpl deleted file mode 100644 index b15920aee..000000000 --- a/plugins/admin/systems/paste_generic.tpl +++ /dev/null @@ -1,60 +0,0 @@ -{if $object == "server"} - - - - - -
{$must} - -
-{/if} -{if $object == "workstation"} - - - - - -
{$must} - -
-{/if} -{if $object == "terminal"} - - - - - -
{$must} - -
-{/if} -{if $object == "printer"} - - - - - -
{$must} - -
-{/if} -{if $object == "phone"} - - - - - -
{$must} - -
-{/if} -{if $object == "component"} - - - - - -
{$must} - -
-{/if} diff --git a/plugins/admin/systems/phone.tpl b/plugins/admin/systems/phone.tpl deleted file mode 100644 index 58fdd6084..000000000 --- a/plugins/admin/systems/phone.tpl +++ /dev/null @@ -1,57 +0,0 @@ - - - - - -
- - - - - - - - - - - - -
{$must} -{render acl=$cnACL} - -{/render} -
 
{$must} -{render acl=$baseACL} - -{/render} -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-
- - - - - -
-{render acl=$descriptionACL} - -{/render} -
-
- -

 

-{include file="$phonesettings"} - -

 

-{$netconfig} - - - diff --git a/plugins/admin/systems/phonesettings.tpl b/plugins/admin/systems/phonesettings.tpl deleted file mode 100644 index 19385ac86..000000000 --- a/plugins/admin/systems/phonesettings.tpl +++ /dev/null @@ -1,260 +0,0 @@ -

{t}Advanced phone settings{/t}

- - - - - -{if $selected_categorie eq '0'} - - - - -
- {$staticAddress} -{render acl=$categorieACL} - -{/render} - {if $javascript eq 'false'} - - {/if} -
-
-
- - - - - - - - - -
- {$staticAddress} - - -{render acl=$goFonTypeACL} - -{/render} -
- - -{render acl=$goFonDmtfModeACL} - -{/render} -
-
- - - - - - - - - -
- - -{render acl=$goFonDefaultIPACL} - -{/render} -
- - -{render acl=$goFonQualifyACL} - -{/render} -
-
-{/if} - -{if $selected_categorie eq '1'} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -{render acl=$goFonTypeACL} - -{/render} -
- - -{render acl=$goFonDefaultIPACL} - -{/render} -
- - -{render acl=$goFonQualifyACL} - -{/render} -
-   -
- - -{render acl=$goFonAuthACL} - -{/render} -
- - -{render acl=$goFonSecretACL} - -{/render} -
-   -
- - -{render acl=$goFonAccountCodeACL} - -{/render} -
- - -{render acl=$goFonTrunkACL} - -{/render} -
- - - - - - - - -
-
-{render acl=$goFonPermitACL} - -{/render} -
-{render acl=$goFonPermitACL} - -{/render} -{render acl=$goFonPermitACL} - -{/render} -{render acl=$goFonPermitACL} - -{/render} -

-
-
-{render acl=$goFonDenyACL} - -{/render} -
-{render acl=$goFonDenyACL} - -{/render} -{render acl=$goFonDenyACL} - -{/render} -{render acl=$goFonDenyACL} - -{/render} -
- - -{/if} - -{if $selected_categorie eq '2'} - - - - - - -
-   -{render acl=$goFonMSNACL} - -{/render} -
- - -   - - - -{/if} diff --git a/plugins/admin/systems/ppd/class_printerPPDDialog.inc b/plugins/admin/systems/ppd/class_printerPPDDialog.inc deleted file mode 100644 index a93e91bb4..000000000 --- a/plugins/admin/systems/ppd/class_printerPPDDialog.inc +++ /dev/null @@ -1,546 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array("cn"); - var $objectclasses = array("whatever"); - - /* PPD Handling */ - var $selectedPPD = false; // e.g. /vendor/device.ppd - var $ppdManager = false; // new ppdManager; - var $ppdConfig = false; // $this->ppdManager->loadProperties($this->selectedPPD['link']); - var $ppdList = array(); // Contains all Printer models - var $ppdListHeader = array(); // Contains all printer vendors - - /* Paths */ - var $pathToPPD = ""; // Base path, defined in gosa.conf e.g. "/var/spool/ppd/" - var $pathToModified = "modified/"; // used to store the modified ppds - - /* Object Info */ - var $cn = "" ; // Used to tag the ppds modified by the printer object, - - /* If there is already a ppd file for the same type of printer, - * remember the path to ppd file and display a dialog which allows - * to overwrite the current ppd file. - */ - var $add_ppd_later = ""; - var $add_later_msg_dialog = NULL; - - function printerPPDDialog (&$config, $dn= NULL, $ppdfile=NULL ) - { - plugin::plugin ($config, $dn); - $this->depselect = $this->config->current['BASE']; - - /* Get PPD path and remove double //, and add trailing / */ - if(isset($_SESSION['config']->data['MAIN']['PPD_PATH'])){ - $this->pathToPPD = $_SESSION['config']->data['MAIN']['PPD_PATH']; - $this->pathToPPD= preg_replace("/\/\//", "/", $this->pathToPPD); - if(!preg_match("/\/$/",$this->pathToPPD)){ - $this->pathToPPD = $this->pathToPPD."/"; - } - }else{ - $this->pathToPPD = ""; - } - - /* It seams that we have an existing PPD path, so go on */ - if(!((!is_dir($this->pathToPPD))||(empty($this->pathToPPD)))){ - - /* Load all available PPD files and sort them into an array */ - $this->ppdManager= new ppdManager($this->pathToPPD); - $this->getPrinterReload (); - - /* The user has already a valid PPD assigned - * Get some informations about this PPD - * and set it as selected. - * The ppdpath ['link'] should be relative from .../ppd/modified/ - * e.g. "/Compaq/Compaq-J1200.ppd" */ - if(($ppdfile!== NULL)&&(strlen($ppdfile)>0)){ - $ppdfile = preg_replace("#".$this->pathToModified."#","",$ppdfile); - if(!file_exists($this->pathToPPD.$this->pathToModified.$ppdfile)){ - print_red(sprintf(_("Can't open '%s', ppd settings resetted."),$ppdfile)); - }else{ - $res = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$ppdfile); - if($res){ - $tmp = split("\n",$res); - $tmp3 = array(); - $tmp3['name'] = trim(preg_replace("/^\-/","",trim($tmp[1]))); - $tmp3['link'] = $ppdfile; - $tmp3['ppd'] = $res; - } - $this->selectedPPD = $tmp3; - } - } - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $display= ""; - $smarty= get_smarty(); - $smarty->assign("ppdString", _("Can't get ppd informations.")); - $smarty->assign("showOptions", ""); - - /* Check these paths */ - $paths = array($this->pathToPPD, $this->pathToPPD.$this->pathToModified); - - /* If one of our required paths is not available, stop here and display some info */ - foreach($paths as $path){ - - /* Check if path is write/readable*/ - $is_r = @is_readable($path); - if(((!is_dir($path))||(empty($path)) || (!$is_r)) && (!@mkdir($path))){ - print_red(sprintf(_("The specified path '%s' which results from PPD_PATH in your gosa.conf is invalid, can't read/write any ppd informations."),$path)); - /* Print out template */ - $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__))); - return($display); - } - } - - // PPD selection / upload / dialog handling - - /* Is there a new PPD file uploaded ? */ - if((isset($_FILES['NewPPDFile']))&&(isset($_POST['SubmitNewPPDFile']))){ - $file = ($_FILES['NewPPDFile']); - if($file['size'] != 0 ){ - if($name = $this->AddPPD($file['tmp_name'])){ - $this->SelectPPD($name); - } - }else{ - print_red(_("Please specify a valid ppd file.")); - } - } - - /* Overwrite existing PPD file and select it as currently used for this object */ - if(is_object($this->add_later_msg_dialog) && ($this->add_later_msg_dialog->is_confirmed()) && $this->add_ppd_later != ""){ - if($name = $this->AddPPD($this->add_ppd_later,TRUE)){ - $this->SelectPPD($name); - } - $this->add_ppd_later = ""; - $this->add_later_msg_dialog = NULL; - } - - /* Open a dialog that allow us to select different PPDs */ - if(isset($_POST['SelectPPD'])){ - $this->dialog= new printerPPDSelectionDialog($this->config,$this->dn,$this->ppdList,$this->ppdListHeader,$this->selectedPPD); - } - - /* The selection dialog fpr PPDs is canceled */ - if(isset($_POST['ClosePPDSelection'])){ - unset($this->dialog); - $this->dialog=FALSE; - } - - /* Div Selection */ - if((isset($_GET['act']))&&($_GET['act']=="use")){ - $this->SelectPPD(base64_decode($_GET['id'])); - unset($this->dialog); - $this->dialog=FALSE; - - } - - /* if a dialog is open, print the dialog instead of this class */ - if(is_object($this->dialog)){ - $display = $this->dialog->execute(); - return($display); - } - - // ENDE PPD selection / upload / dialog handling - - /* Give smarty the information it needs */ - $smarty->assign("ppdString" ,$this->getPPDInformation()); - $tmp= $this->generateProperties(); - if ($tmp == ""){ - $smarty->assign("showOptions", 0); - } else { - $smarty->assign("showOptions", 1); - $smarty->assign("properties",$this->generateProperties()); - } - - /* Print out template */ - $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - - /* Select PPD */ - function SelectPPD($name) - { - /* Replace base path we don't need it here - The path we need looks like this : "/Vendor/ModellName.ppd"; - thats all */ - $name = preg_replace("#".$this->pathToPPD."#","",$name); - - /* Intialise some base vars */ - $AbsoluteSourceName = $this->pathToPPD.$name; - $AbsoluteDestinationPath = $this->pathToPPD.$this->pathToModified; - $Vendor = ""; // Vendor - $Name = ""; // Name - $Modell = ""; // Modell - $PrinterName = ""; // The new name of the printer - $PPDName = ""; - - /* Force reload of config dialog */ - $this->ppdConfig = false; - $this->selectedPPD['link'] = false; - - /* Get PPD informations and set vendor / modell / name */ - if((!file_exists($AbsoluteSourceName)) || (!is_readable($AbsoluteSourceName))){ - print_red(sprintf(_("Can't select PPD file '%s', the file is not readable"),$AbsoluteSourceName)); - return; - } - $res = $this->ppdManager->loadDescription($AbsoluteSourceName); - if($res){ - $tmp = split("\n",$res); - $Name = trim(preg_replace("/^\-/","",trim($tmp[1]))); - $Vendor = trim($tmp[0]); - $Model = trim(preg_replace("/".$Vendor."/","",$Name)); - } - - $PrinterName = $this->cn."-".preg_replace("/[^a-z0-9-_\.]/i","_",$Name); - $PPDName = $Vendor."/".$PrinterName.".ppd"; - - /* Create the vendors path, if it doesn't exists already */ - if(!is_dir($AbsoluteDestinationPath.$Vendor)){ - if(!(@mkdir($AbsoluteDestinationPath.$Vendor))){ - print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$AbsoluteDestinationPath.$Vendor)); - return(false); - } - } - - /* Create destination file handle */ - $fp = @fopen($AbsoluteDestinationPath.$PPDName,"w+"); - if(!$fp){ - print_red(sprintf(_("Can't create file '%s' to store modifed ppd informations."),$AbsoluteDestinationPath.$PPDName)); - return(false); - } - - $str = file_get_contents($AbsoluteSourceName); - fputs($fp,$str); - @fclose($fp); - - //$this->ppdManager->updateAttribute($filename,"NO_SECTION","ModelName",$printerName); - - $tmp3['link'] =$PPDName; - $this->selectedPPD = $tmp3; - $this->getPrinterReload(); - return($PPDName); - } - - - /* This function adds a new ppd file to the list of available ppds. - All required paths and files will be created - $_PathOnHdd e.g. = /tmp/PHP_tmpfile213452 */ - function AddPPD($_PathOnHdd,$overwrite = FALSE) - { - /* Check if file exists && is readable */ - if((!is_file($_PathOnHdd)) || (!is_readable($_PathOnHdd))){ - print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd)); - return(false); - } - - /* Reload list to detect changes e.g. a file has been deleted */ - $this->getPrinterReload(); - - /* Get Description from ppd, & parse out some informations */ - $res = @$this->ppdManager->loadDescription($_PathOnHdd); - if($res){ - $tmp = split("\n",$res); - $name = trim(preg_replace("/^\-/","",trim($tmp[1]))); - $vendor = trim($tmp[0]); - $model = trim(preg_replace("/".$vendor."/","",$name)); - } - - /* Check if parse was successfull */ - if(empty($name) || empty($vendor)){ - print_red(sprintf(_("The given ppd file '%s' seams to be invalid, can't get any model or vendor informations."),$_PathOnHdd)); - return(false); - } - - /* Prepare list of ppds */ - if(!isset($this->ppdList[$vendor])){ - $this->ppdList[$vendor] = array(); - } - - /* Create ppd file and fill in the source contents */ - $ppdname = $vendor."/".$name.".ppd"; - $filename = $this->pathToPPD.preg_replace("/[^a-z0-9-_\.\/]/i","_",$ppdname); - $filename = $this->pathToPPD.$ppdname; - $contents = file_get_contents($_PathOnHdd); - - - /* Check if this ppd already exists */ - $found = false; - foreach($this->ppdList[$vendor] as $key => $val){ - if(preg_match("/".$model.".*/i",$key)){ - $found = true; - if(!$overwrite){ - if(!copy($_PathOnHdd,$_PathOnHdd."_back")){ - print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd)); - }else{ - $this->add_ppd_later = $_PathOnHdd."_back"; - $this->add_later_msg_dialog = new msg_dialog(_("Overwrite existing PPD"), - _("There is already a ppd file for this kind of printer. Do you want to overwrite it?"),CONFIRM_DIALOG); - } - return; - } - } - } - - /* Create the vendors path, if it doesn't exists already */ - if(!is_dir($this->pathToPPD.$vendor)){ - if(!(@mkdir($this->pathToPPD.$vendor))){ - print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$this->pathToPPD.$vendor)); - return(false); - } - } - - /* Open file handle */ - $fp = fopen($filename,"w+"); - - /* Check file handle & contents */ - if(!$fp){ - print_red(sprintf(_("Can't save file '%s'."),$filename)); - return; - } - if(empty($contents)){ - print_red(_("Uploaded ppd file is empty, can't create new ppd file.")); - return; - } - - /* Fille file with data */ - fputs($fp,$contents); - @fclose($fp); - - /* Our job is done here */ - return($ppdname); - } - - - /* This function reloads the list of available printers/vendors - $this->ppdListHeader - Compaq => 1 - $this->ppdList - Compaq => Compaq IJ1200 => name => Compaq IJ1200 - link => /var/spool/ppd/Compaq/Compaq-J1200.ppd - ppd => Compaq - Co - */ - function getPrinterReload() - { - if(is_readable($this->pathToPPD)){ - $tmp = @$this->ppdManager->getPrinterList(true); - - $this->ppdListHeader = $this->ppdList = array(); - - /* Sort all available files, and create header (Vendor index) */ - foreach($tmp as $file=>$ppd){ - - if(preg_match("#".$this->pathToModified."#",$file)) continue; - - $tmp2 = split("\n",$ppd); - if(!isset($this->ppdListHeader[$tmp2[0]])){ - $this->ppdListHeader[$tmp2[0]]=0; - } - $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2]); - $tmp3['link'] =$file; - $tmp3['ppd'] =$ppd; - $this->ppdListHeader[$tmp2[0]]++; - $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2])]=$tmp3; - } - } - } - - - /* Save all options posted from ppd dialog */ - function save_object() - { - if(!((isset($_POST['PPDDisSubmitted'])) && (is_array($this->ppdConfig)))){ - return; - } - - foreach($this->ppdConfig as $cat => $obj){ - foreach($obj as $attr => $attributes){ - if(isset($_POST[base64_encode($attributes['_name'])])){ - $this->ppdConfig[$cat][$attr]['_default'] = $_POST[base64_encode($attributes['_name'])]; - } - } - } - } - - - /* Save modified ppd */ - function save_ppd() - { - if($this->ppdManager){ - $this->ppdManager->saveProperties($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'],$this->ppdConfig); - } - } - - - /* Return selected ppd path, if none is selected then false */ - function save() - { - /* return the selected PPD, and in future the selected options too */ - return($this->pathToModified.$this->selectedPPD['link']); - } - - - /* Get Information for a single PPD entry - * This will be shown on top of template - */ - function getPPDInformation() - { - $str = "none"; - if(!empty($this->selectedPPD)){ - $str = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']); - } - return($str) ; - } - - - /* Display all options from the selected ppd file */ - function generateProperties() - { - /* Set Headline */ - $str = ""; - $feed= ""; - - $s_ppd = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']; - - /* If ppd exists and is readable */ - if((!empty($this->selectedPPD['link']))&&(file_exists($s_ppd))){ - - /* If there is no initial Configuration, load it */ - if($this->ppdConfig == false){ - $this->ppdConfig = $this->ppdManager->loadProperties($s_ppd); - } - - /* Create a table */ - $str .= "
"; - - /* Input all data to the table */ - foreach($this->ppdConfig as $cat => $obj){ - - /* Add new category */ - $str .= ""; - - /* Add attributes of the current category */ - foreach($obj as $attr => $settings){ - - /* Skip all entries beginning with _ */ - if($attr[0] == "_") continue; - - /* Prepare data */ - $values = array(); - $name = $settings['_name']; - - if (!isset($settings['_default'])){ - $default = ""; - } else { - $default = $settings['_default']; - } - - $type = $settings['_type']; - - /* Add name to table */ - $str .= "\n"; - } - } - $str .= "
$feed"; - if ($feed == ""){ - $feed= "
"; - } - $str .= ""._("Section")." '".$cat."' 
"; - $str .= "
\n"; - $str .= $name."
\n"; - $str .= "
\n"; - - /* Get all values */ - foreach( $settings as $vname => $value){ - if($vname[0] != "_"){ - $values[$vname]= $value; - } - } - - /* preparing Html output - * Supported types are PickOne/Boolean - */ - - /* If type is PickOne, create a select box */ - if(($type == "PickOne")||(($type=="Boolean")&&(count($values)>1))){ - - $str .= "\n"; - - }elseif($type == "Boolean"){ - - /* If type is Boolean & no values are given */ - $str .= "\n"; - - }else{ - print_red(sprintf(_("Unsupported ppd type '%s' used for '%s' "),$type,$name)); - } - $str .= "
\n"; - } - return($str); - } - - function removeModifiedPPD() - { - $path = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']; - - if(file_exists($path)){ - if(is_writeable($path)){ - if(!@unlink($path)){ - print_red(sprintf(_("Removing old ppd file '%s' failed."),$path)); - } - }else{ - print_red(sprintf(_("Removing old ppd file '%s' failed. File is not accessible."),$path)); - } - }else{ - print_red(sprintf(_("Removing old ppd file '%s' failed. File does not exists or is not accessible."),$path)); - } - } - - function update_ppd_url() - { - $this->SelectPPD("modified/".$this->selectedPPD['link']); - } - - function check() - { - $message = plugin::check(); - if(empty($this->selectedPPD['link'])){ - $message[] = _("Please select a valid ppd file or use 'Cancel' to go back to printer configuration."); - } - return($message); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc b/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc deleted file mode 100644 index d4f5d16b8..000000000 --- a/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc +++ /dev/null @@ -1,197 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = FALSE; - var $attributes = array(); - var $objectclasses = array("whatever"); - - var $list =array(); - var $header =array(); - var $current_del_id = ""; - var $Vendor = ""; - - function printerPPDSelectionDialog (&$config, $dn= NULL,$list=false,$headers=false,$ppd=false) - { - plugin::plugin ($config, $dn); - $this->list = $list; - $this->header = $headers; - $this->depselect = $this->config->current['BASE']; - - if(!isset($_SESSION['printerPPDSelectionDialog'])){ - $_SESSION['printerPPDSelectionDialog']['regex'] = "*"; - } - - /* Order the manufacturers index */ - ksort($this->header); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - $s_action = "none"; - - $regex = $_SESSION['printerPPDSelectionDialog']['regex']; - - if(isset($_GET['search'])){ - $regex = $_GET['search']."*"; - } - - if(isset($_POST['regex'])){ - $regex= $_POST['regex']; - } - - $regex = str_replace("**","*",$regex); - $_SESSION['printerPPDSelectionDialog']['regex'] = $regex; - - - /* Delete requested, check if everything is ok and display confirmation dialog */ - if(isset($_GET['act']) && $_GET['act'] == "del"){ - - /* Get id and check if id is valid */ - $id_to_del = base64_decode($_GET['id']); - $found = ""; - foreach($this->list[$this->Vendor] as $key => $data){ - if($data['link'] == $id_to_del){ - $found = $key; - break; - } - } - if(!empty($found)){ - $this->current_del_id = $id_to_del; - - $smarty->assign("warning", sprintf(_("You're about to delete the ppd file '%s' at '%s'."), $found,$id_to_del)); - return($smarty->fetch(get_template_path('remove_ppd.tpl', TRUE))); - - }else{ - print_red(sprintf(_("Could not found specified ppd file '%s'."),$id_to_del)); - } - } - - /* Deletion confirmed */ - if(isset($_POST['delete_ppd_confirm']) && !empty($this->current_del_id)){ - - /* check if file is removeable */ - if(is_writeable($this->current_del_id)){ - $is_ok = @unlink($this->current_del_id); - - /* Update ppd list */ - if($is_ok){ - foreach($this->list as $vendor => $ppds){ - foreach($ppds as $ppd => $data){ - if($data['link'] == $this->current_del_id){ - unset($this->list[$vendor][$ppd]); - } - } - } - } - }else{ - $is_ok = false; - } - - if(!$is_ok){ - print_red(_("Something went wrong while trying to remove the ppd file from server, possibly we have no write access.")); - } - } - - - /** Added **/ - $list = array(); - foreach($this->list as $cat => $ppds){ - foreach($ppds as $ppd){ - if(preg_match("/^".str_replace("*",".*",$regex)."/i",$ppd['ppd'])){ - if(is_readable($ppd['link'])){ - $list[$ppd['link']] = $ppd; - } - } - } - } - - if((isset($_GET['act']))&&($_GET['act']=="open")) { - - if((!empty($_GET['id'])) && (!isset( $this->header[base64_decode($_GET['id'])]))){ - print_red(sprintf(_("Selected vendor '%s' does not exists in our list of ppds."),base64_decode($_GET['id']))); - $this->Vendor = ""; - }else{ - $this->Vendor = base64_decode($_GET['id']); - } - } - - $div = new divSelectBox("printerPPDSelectionDialog"); - $div ->SetHeight(450); - $div ->SetSummary(_("Printer ppd selection.")); - - $linkopen = " -  %s - "; - $uselink = "%s"; - $dellink = " - "._("delete")." - "; - - if(empty($this->Vendor)){ - foreach($this-> header as $key => $entry){ - $div ->AddEntry (array( - array("string"=>sprintf($linkopen,base64_encode($key),$key),"attach"=>"style='border-right:0px;'") - )); - } - }else{ - $div ->AddEntry (array( - array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'") - )); - foreach($list as $key => $ppd){ - if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){ - - if(is_writeable($ppd['link'])){ - $del_str = sprintf($dellink,base64_encode($key)); - }else{ - $del_str = ""; - } - - $div ->AddEntry (array( - array("string"=>sprintf($uselink,base64_encode($key),$ppd['ppd'])), - array("string"=>$del_str,"attach"=>"style='border-right:0px;'") - - )); - } - } - } - - $smarty->assign("List", $div -> DrawList()); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("apply", apply_filter()); - $smarty->assign("regex", $regex); - - $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - function save_object() - { - } - - function check(){ - } - - /* Save to LDAP */ - function save() - { - return $this->selectedPPD; - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/ppd/printerPPDDialog.tpl b/plugins/admin/systems/ppd/printerPPDDialog.tpl deleted file mode 100644 index 761d00516..000000000 --- a/plugins/admin/systems/ppd/printerPPDDialog.tpl +++ /dev/null @@ -1,24 +0,0 @@ -

P {t}Printer driver{/t}

- - - - - -
- {t}Model{/t}: {$ppdString}  - - - {t}New driver{/t}  - - -
-{if $showOptions eq 1} -

 

-

L {t}Options{/t}

-{$properties} -{/if} -

- - - -

diff --git a/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl b/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl deleted file mode 100644 index b6cad00b8..000000000 --- a/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl +++ /dev/null @@ -1,48 +0,0 @@ - - - - - -
-
-

- {t}Select objects to add{/t} -

-
-
- {$List} - -
-
-
-

- [F] - {t}Filters{/t} -

-
-
- - {$alphabet} -
- - - - - -
- - - -
- {$apply} - -
-
- -

- -

- diff --git a/plugins/admin/systems/ppd/remove_ppd.tpl b/plugins/admin/systems/ppd/remove_ppd.tpl deleted file mode 100644 index 6d28ba9ec..000000000 --- a/plugins/admin/systems/ppd/remove_ppd.tpl +++ /dev/null @@ -1,15 +0,0 @@ -
- {t}Warning{/t} -
-

- {$warning} -

- -

- {t}The ppd file will be removed from the server and can not be restored.{/t} -

-

- -   - -

diff --git a/plugins/admin/systems/printer.tpl b/plugins/admin/systems/printer.tpl deleted file mode 100644 index e4ba965b9..000000000 --- a/plugins/admin/systems/printer.tpl +++ /dev/null @@ -1,150 +0,0 @@ - - - - - -
-{if $StandAlone } -

{t}General{/t}

- - - - - - - - - - - - - - - - -
{$must} -{render acl=$cnACL} - -{/render} -
-{render acl=$descriptionACL} - -{/render} -
 
{$must} -{render acl=$baseACL} - -{/render} -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-
-{/if} -

{t}Details{/t}

- - - - - - - - - -
-{render acl=$lACL} - -{/render} -
{$must} -{render acl=$labeledURIACL} - -{/render} -
- - - - -
-
- {t}Driver{/t}: {$driverInfo}  -{render acl=$gotoPrinterPPDACL mode=read_active} - -{/render} -{render acl=$gotoPrinterPPDACL} - -{/render} -
-
- -

 

- -

{t}Permissions{/t}

- - - - - -
- - - - -
- {t}Users which are allowed to use this printer{/t}
-{render acl=$gotoUserPrinterACL} -
-{/render} -{render acl=$gotoUserPrinterACL} - -{/render} -{render acl=$gotoUserPrinterACL} - -{/render} -{render acl=$gotoUserPrinterACL} - -{/render} -
- -
- - - - -
- {t}Users which are allowed to administrate this printer{/t}
-{render acl=$gotoUserPrinterACL} -
-{/render} -{render acl=$gotoUserPrinterACL} - -{/render} -{render acl=$gotoUserPrinterACL} - -{/render} -{render acl=$gotoUserPrinterACL} - -{/render} - -
- -
- - -{if $netconfig ne ''} -

 

-{$netconfig} -{/if} - - - diff --git a/plugins/admin/systems/remove.tpl b/plugins/admin/systems/remove.tpl deleted file mode 100644 index dc5dbb2bd..000000000 --- a/plugins/admin/systems/remove.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
- {t}Warning{/t} -
-

- {$warning} - {t}This includes all system and setup informations. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

diff --git a/plugins/admin/systems/selectUserToPrinterDialog.tpl b/plugins/admin/systems/selectUserToPrinterDialog.tpl deleted file mode 100644 index c60be2297..000000000 --- a/plugins/admin/systems/selectUserToPrinterDialog.tpl +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - -
-
-

- -

-
-
-

-
-

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - -
-  {t}Search in subtrees{/t} -
- - - - - -
- - - -
- - - - - -
- - - -
- {$apply} -
-
- -

 

-

- - -

- diff --git a/plugins/admin/systems/server.tpl b/plugins/admin/systems/server.tpl deleted file mode 100644 index 4e2d9b6a4..000000000 --- a/plugins/admin/systems/server.tpl +++ /dev/null @@ -1,85 +0,0 @@ - - - - - -
- - - - - - - - - - - - - -
{$must} -{render acl=$cnACL} - -{/render} -
-{render acl=$descriptionACL} - -{/render} -

{$must}
-
-{render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-
- - - - - -
{t}Mode{/t} -{render acl=$gotoModeACL} - -{/render} -
-
- -

 

- -{$netconfig} - -{if $fai_activated} -

 

- -

{t}Action{/t}

- - - - - -
-{render acl=$FAIstateACL} - -{/render} - - -
-{/if} - - - diff --git a/plugins/admin/systems/services/ServiceAddDialog.tpl b/plugins/admin/systems/services/ServiceAddDialog.tpl deleted file mode 100644 index f055f33c1..000000000 --- a/plugins/admin/systems/services/ServiceAddDialog.tpl +++ /dev/null @@ -1,32 +0,0 @@ -
 
-
- {t}Adding a new service to the current server{/t} -
-
-

-{t}This dialog allows you to add new services to the currenty edited server object. The box below shows all available but not already used services.{/t} -
-
-

-{if $Services} -
-
{t}Service to add{/t}   - -{else} -
- {t}All available services are already in use.{/t} -
-{/if} -
-
-
-

-

- -   - -
- diff --git a/plugins/admin/systems/services/class_ServiceAddDialog.inc b/plugins/admin/systems/services/class_ServiceAddDialog.inc deleted file mode 100644 index 47e97012d..000000000 --- a/plugins/admin/systems/services/class_ServiceAddDialog.inc +++ /dev/null @@ -1,34 +0,0 @@ -"Config object" , "dn"=>"Object dn"); - - /* This plugin does not have any ocs */ - var $objectclasses = array(); - var $parent = NULL; - - function ServiceAddDialog(&$config,$dn,$parent) - { - plugin::plugin($config); - $this->parent = $parent; - } - - function execute() - { - $smarty = get_smarty(); - $services = $this->parent->getAllUnusedServices(); - natcasesort($services); - $smarty->assign("Services",$services); - return($smarty->fetch(get_template_path("ServiceAddDialog.tpl", TRUE,dirname(__FILE__)))); - } - - function check(){ return array();} - function save_object(){;} - function save(){} - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/class_goService.inc b/plugins/admin/systems/services/class_goService.inc deleted file mode 100644 index edfd3d7d5..000000000 --- a/plugins/admin/systems/services/class_goService.inc +++ /dev/null @@ -1,238 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array(); - var $attributes = array(); - var $StatusFlag = ""; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array(); - var $dn = NULL; - var $cn = ""; - var $DisplayName = ""; - var $view_logged =FALSE; - - - /* Construcktion */ - function goService(&$config,$dn) - { - plugin::plugin($config,$dn); - $this->DisplayName = _("Empty service"); - } - - - /* Create content */ - function execute() - { - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $str ="
". - "  ". - " ". - "
"; - return($str); - } - - - /* Get service information for serverService plugin */ - function getListEntry() - { - - $this->updateStatusState(); - - /* Assign status flag */ - if(!empty($this->StatusFlag)){ - $flag = $this->StatusFlag; - $fields['Status'] = $this->$flag; - }else{ - $fields['Status'] = ""; - } - - /* Name displayed in service overview */ - $fields['Message'] = _("Empty service"); - - /* Allow/disallow some functions */ - $fields['AllowStart'] = $this->acl_is_writeable("start"); - $fields['AllowStop'] = $this->acl_is_writeable("stop"); - $fields['AllowRestart'] = $this->acl_is_writeable("restart"); - $fields['AllowRemove'] = $this->acl_is_removeable(); - $fields['AllowEdit'] = true; - return($fields); - } - - - /* Remove service */ - function remove_from_parent() - { - if(!$this->initially_was_account || !$this->acl_is_removeable()){ - return; - } - - plugin::remove_from_parent(); - - /* Remove status flag, it is not a memeber of - this->attributes, so ensure that it is deleted too */ - if(!empty($this->StatusFlag)){ - $this->attrs[$this->StatusFlag] = array(); - } - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - - } - - new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn)); - $this->handle_post_events("remove"); - } - - - /* Save service */ - function save() - { - plugin::save(); - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - if($this->initially_was_account){ - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("modify"); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn)); - } - - - /* Directly save new status flag */ - function setStatus($value) - { - if($value == "none") return; - - /* Can't set status flag for new services (Object doesn't exists in ldap tree) */ - if(!$this->initially_was_account) return; - - /* Can't set status flag, if no flag is specified */ - if(empty($this->StatusFlag)){ - return; - } - - /* Get object (server), update status flag and save changes */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - - $tmp = $ldap->fetch(); - for($i = 0; $i < $tmp['objectClass']['count']; $i ++){ - $attrs['objectClass'][] = $tmp['objectClass'][$i]; - } - $flag = $this->StatusFlag; - $attrs[$flag] = $value; - $this->$flag = $value; - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn)); - $this->action_hook(); - } - } - - - function check() - { - $message = plugin::check(); - return($message); - } - - - function save_object() - { - plugin::save_object(); - } - - - function action_hook($add_attrs= array()) - { - /* Find postcreate entries for this class */ - $command= $this->config->search(get_class($this), "ACTION_HOOK",array('menu','tabs')); - if ($command != ""){ - - /* Walk through attribute list */ - foreach ($this->attributes as $attr){ - if (!is_array($this->$attr)){ - $command= preg_replace("/%$attr/", $this->$attr, $command); - } - } - $command= preg_replace("/%dn/", $this->dn, $command); - - /* Additional attributes */ - foreach ($add_attrs as $name => $value){ - $command= preg_replace("/%$name/", $value, $command); - } - - /* If there are still some %.. in our command, try to fill these with some other class vars */ - if(preg_match("/%/",$command)){ - $attrs = get_object_vars($this); - foreach($attrs as $name => $value){ - if(!is_string($value)) continue; - $command= preg_replace("/%$name/", $value, $command); - } - } - - if (check_command($command)){ - @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, - $command, "Execute"); - - exec($command); - } else { - $message= sprintf(_("Command '%s', specified as ACTION_HOOK for plugin '%s' doesn't seem to exist."), $command, get_class($this)); - print_red ($message); - } - } - } - - - /* Get updates for status flag */ - function updateStatusState() - { - if(empty($this->StatusFlag)) return; - - $attrs = array(); - $flag = $this->StatusFlag; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->cn); - $ldap->cat($this->dn,array($flag)); - if($ldap->count()){ - $attrs = $ldap->fetch(); - } - if(isset($attrs[$flag][0])){ - $this->$flag = $attrs[$flag][0]; - } - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/cups/class_goCupsServer.inc b/plugins/admin/systems/services/cups/class_goCupsServer.inc deleted file mode 100644 index 6fa572b9d..000000000 --- a/plugins/admin/systems/services/cups/class_goCupsServer.inc +++ /dev/null @@ -1,85 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goCupsServer"); - var $attributes = array(); - var $StatusFlag = "goCupsServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goCupsServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $acl; - var $cn = ""; - var $goCupsServerStatus = ""; - var $view_logged =FALSE; - - function goCupsServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("Print service"); - } - - - function execute() - { - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("goCupsServer.tpl",TRUE,dirname(__FILE__)))); - } - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Print service"); - $fields['AllowEdit'] = false; - return($fields); - } - - function check() - { - $message = plugin::check(); - return($message); - } - - function save_object() - { - plugin::save_object(); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Cups"), - "plDescription" => _("Print service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 100, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - - "plProvidedAcls"=> array() - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/cups/goCupsServer.tpl b/plugins/admin/systems/services/cups/goCupsServer.tpl deleted file mode 100644 index e10bd2f67..000000000 --- a/plugins/admin/systems/services/cups/goCupsServer.tpl +++ /dev/null @@ -1,9 +0,0 @@ -

{t}Print Service{/t} {t}enabled{/t}

- -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc b/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc deleted file mode 100644 index 43f583152..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc +++ /dev/null @@ -1,146 +0,0 @@ -is_account= TRUE; - $this->setAutoStatements(); - $this->setAutoOptions(); - } - - function execute() - { - /* Check for interaction */ - if (isset($_POST['add_statement']) && $_POST['addstatement'] != ""){ - $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addstatement')); - $val= preg_replace("/^$key\s*/", '', get_post('addstatement')); - $this->statements[$key]= $val; - } - if (isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){ - $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpstatements')); - if (in_array($key, $this->autoStatements)){ - print_red(_("Can't delete automatic statements. Please use the fields above.")); - } else { - unset($this->statements[$key]); - } - } - if (isset($_POST['add_option']) && $_POST['addoption'] != ""){ - $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addoption')); - $val= preg_replace("/^$key\s*/", '', get_post('addoption')); - $this->options[$key]= $val; - } - if (isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){ - $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpoptions')); - if (in_array($key, $this->autoOptions)){ - print_red(_("Can't delete automatic options. Please use the fields above.")); - } else { - unset($this->options[$key]); - } - } - - $smarty= get_smarty(); - - /* Assign arrays */ - $statements= array(); - foreach ($this->statements as $key => $val){ - if (in_array($key, $this->autoStatements)){ - $statements[$key]= "$key $val ["._("automatic")."]"; - } else { - $statements[$key]= "$key $val"; - } - } - $smarty->assign("dhcpstatements", $statements); - $options= array(); - foreach ($this->options as $key => $val){ - if (in_array($key, $this->autoOptions)){ - $options[$key]= "$key $val ["._("automatic")."]"; - } else { - $options[$key]= "$key $val"; - } - } - $smarty->assign("dhcpoptions", $options); - - /* Show main page */ - $smarty->assign("show_advanced", $this->show_advanced); - return ($smarty->fetch (get_template_path('dhcp_advanced.tpl', TRUE,dirname(__FILE__)))); - } - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['show_advanced'])){ - $this->show_advanced= TRUE; - } - if (isset($_POST['hide_advanced'])){ - $this->show_advanced= FALSE; - } - } - - - /* Check values */ - function check() - { - /* Nothing to check here */ - $message= array(); - return $message; - } - - - /* Save to LDAP */ - function save() - { - } - - - function setAutoOptions($addopt= array()) - { - $options= array("routers", "domain-name", "domain-name-servers", "subnet-mask", "broadcast-address"); - $this->autoOptions= array_merge($options, $addopt); - } - - - function setAutoStatements($addstat= array()) - { - $statements= array("filename", "next-server", "get-lease-hostnames", "use-host-decl-names"); - $this->autoStatements= array_merge($statements, $addstat); - } - -} - -?> diff --git a/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc b/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc deleted file mode 100644 index cbe987da8..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc +++ /dev/null @@ -1,126 +0,0 @@ -assign("cn", $this->cn); - - /* Show main page */ - $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE)).$this->network->execute(); - - /* Merge arrays for advanced view */ - $this->fix_options(); - foreach (array("options", "statements") as $type){ - $this->advanced->$type= $this->$type + $this->network->$type; - } - - $display.= $this->advanced->execute(); - - /* Merge back for removals */ - foreach (array("options", "statements") as $type){ - $this->$type= $this->advanced->$type; - $this->network->$type= $this->advanced->$type; - } - - /* Add footer */ - $display.= "
". - " 
"; - - - return ($display); - } - - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - /* Save cn */ - if (isset($_POST['cn'])){ - $this->cn= validate(get_post('cn')); - } - - /* Handle global saving */ - dhcpPlugin::save_object(); - } - - - /* Check values */ - function check() - { - $message= array(); - - $cache = $this->parent->dhcpObjectCache; - - /* All required fields are set? */ - if ($this->cn == ""){ - $message[]= _("Required field 'Name' is not filled."); - } - if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){ - $message[]= _("Field 'Name' contains illegal characters."); - } - - /* cn already used? */ - if ($this->orig_cn != $this->cn || $this->new){ - - foreach($cache as $dn => $dummy){ - if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ - $message[]= _("The name for this host section is already used!"); - break; - } - } - } - - /* Check external plugins */ - $net= $this->network->check(); - $adv= $this->advanced->check(); - $message= array_merge($message, $net, $adv); - - return $message; - } - - - /* Save to LDAP */ - function save() - { - dhcpPlugin::save(); - return ($this->attrs); - } - - -} - -?> diff --git a/plugins/admin/systems/services/dhcp/class_dhcpHost.inc b/plugins/admin/systems/services/dhcp/class_dhcpHost.inc deleted file mode 100644 index e8aab5c95..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpHost.inc +++ /dev/null @@ -1,181 +0,0 @@ -new){ - $this->dhcpHWAddress= $attrs['dhcpHWAddress'][0]; - } - - $this->advanced->setAutoOptions(array("host-name")); - $this->advanced->setAutoStatements(array("fixed-address")); - - $this->realGosaHost = $host_exists_in_gosa; - } - - function execute() - { - $smarty= get_smarty(); - $smarty->assign("cn", $this->cn); - $smarty->assign("dhcpHWAddress", preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress)); - $smarty->assign("realGosaHost",$this->realGosaHost); - - /* Create fixed address */ - if (isset($this->statements['fixed-address'])){ - $smarty->assign("fixedaddr", $this->statements['fixed-address']); - } else { - $smarty->assign("fixedaddr", ""); - } - - /* Prepare hw type selector */ - $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress); - $smarty->assign("hwtype", $hwtype); - $smarty->assign("hwtypes", array("ethernet" => _("Ethernet"), - "fddi" => _("FDDI"), - "token-ring" => _("Token Ring"))); - /* Show main page */ - $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute(); - - /* Merge arrays for advanced view */ - $this->fix_options(); - foreach (array("options", "statements") as $type){ - $this->advanced->$type= $this->$type + $this->network->$type; - } - $display.= $this->advanced->execute(); - - /* Merge back for removals */ - foreach (array("options", "statements") as $type){ - $this->$type= $this->advanced->$type; - $this->network->$type= $this->advanced->$type; - } - - /* Add footer */ - $display.= "
". - " 
"; - - - return ($display); - } - - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - /* Save remaining attributes */ - if (isset($_POST['dhcp_host_posted'])){ - - /* Assemble hwAddress */ - if (isset($_POST['dhcpHWAddress'])){ - $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress'); - } - - if(!$this->realGosaHost){ - $this->cn= validate(get_post('cn')); - } - - /* Save fixed address */ - if(!$this->realGosaHost){ - if ($_POST['fixedaddr'] != ""){ - $this->statements['fixed-address']= get_post('fixedaddr'); - } else { - unset ($this->statements['fixed-address']); - } - } - $this->options['host-name']= $this->cn; - } - - dhcpPlugin::save_object(); - } - - - /* Check values */ - function check() - { - $message= array(); - - $cache = array(); - if(isset($this->parent)){ - $cache = $this->parent->dhcpObjectCache; - } - - /* All required fields are set? */ - if ($this->cn == ""){ - $message[]= _("Required field 'Name' is not filled."); - } - - /* cn already used? */ - if ($this->orig_cn != $this->cn || $this->new){ - - foreach($cache as $dn => $dummy){ - if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ - $message[]= _("The name for this host section is already used!"); - break; - } - } - } - - /* Check syntax of MAC address */ - $check= preg_replace('/^[^\s]*\s/', '', $this->dhcpHWAddress); - if (!preg_match('/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/', $check)){ - $message[]= _("The hardware address specified by you is not valid!"); - } - - /* Check external plugins */ - $net= $this->network->check(); - $adv= $this->advanced->check(); - $message= array_merge($message, $net, $adv); - - return $message; - } - - - /* Save to LDAP */ - function save() - { - dhcpPlugin::save(); - if ($this->dhcpHWAddress != ""){ - $this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress); - } else { - $this->attrs['dhcpHWAddress']= array(); - } - - return ($this->attrs); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc b/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc deleted file mode 100644 index 1c3ced065..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc +++ /dev/null @@ -1,226 +0,0 @@ -is_account= TRUE; - } - - function execute() - { - /* Check for iteraction */ - if (isset($_POST['add_dns']) && $_POST['addserver'] != ""){ - if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){ - print_red(_("The name of the DNS server your're going to add is not valid!")); - } else { - $servers= array(); - if (isset($this->options['domain-name-servers'])){ - foreach(split(",", $this->options['domain-name-servers']) as $val){ - $servers[$val]= $val; - } - } - $servers[get_post('addserver')]= get_post('addserver'); - - $tmp= ""; - foreach($servers as $val){ - $tmp.= $val.","; - } - $this->options['domain-name-servers']= preg_replace('/,$/', '', $tmp); - } - } - if (isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){ - $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '', - $this->options['domain-name-servers']); - $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp); - if ($tmp != ""){ - $this->options['domain-name-servers']= $tmp; - } else { - unset($this->options['domain-name-servers']); - } - } - - /* Show main page */ - $smarty= get_smarty(); - - /* - * Assemble options - */ - - /* Router */ - if (isset($this->options['routers'])){ - $smarty->assign("routers", $this->options['routers']); - } else { - $smarty->assign("routers", ""); - } - - /* DNS */ - if (isset($this->options['domain-name'])){ - $smarty->assign("domain", trim($this->options['domain-name'], '"')); - } else { - $smarty->assign("domain", ""); - } - if (isset($this->options['domain-name-servers'])){ - $servers= array(); - foreach(split(",", $this->options['domain-name-servers']) as $val){ - $servers[$val]= $val; - } - $smarty->assign("dnsservers", $servers); - } else { - $smarty->assign("dnsservers", ""); - } - - /* Netmask / Broadcast */ - if (isset($this->options['subnet-mask'])){ - $this->options['subnet-mask']= normalize_netmask($this->options['subnet-mask']); - $smarty->assign("subnet_mask", $this->options['subnet-mask']); - } else { - $smarty->assign("subnet_mask", ""); - } - if (isset($this->options['broadcast-address'])){ - $smarty->assign("broadcast_address", $this->options['broadcast-address']); - } else { - $smarty->assign("broadcast_address", ""); - } - - /* Boot stuff */ - if (isset($this->statements['filename'])){ - $smarty->assign("filename", trim($this->statements['filename'], '"')); - } else { - $smarty->assign("filename", ""); - } - if (isset($this->statements['next-server'])){ - $smarty->assign("nextserver", $this->statements['next-server']); - } else { - $smarty->assign("nextserver", ""); - } - - /* Set flags */ - $smarty->assign("autohost", ""); - if (isset($this->statements['get-lease-hostnames'])){ - if (preg_match('/^(true|on|yes)$/', $this->statements['get-lease-hostnames'])){ - $smarty->assign("autohost", "checked"); - } - } - $smarty->assign("autohostdecl", ""); - if (isset($this->statements['use-host-decl-names'])){ - if (preg_match('/^(true|on|yes)$/', $this->statements['use-host-decl-names'])){ - $smarty->assign("autohostdecl", "checked"); - } - } - - return $smarty->fetch(get_template_path('dhcp_network.tpl', TRUE,dirname(__FILE__))); - } - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - /* Only save, if we are "active" */ - if (isset($_POST['routers'])){ - - /* - * Assemble options - */ - - /* Options */ - foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask", - "broadcast-address" => "broadcast_address") as $key => $val){ - - if ($_POST["$val"] == ''){ - unset($this->options["$key"]); - } else { - $this->options["$key"]= get_post("$val"); - } - } - - /* Statements */ - foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){ - if ($_POST["$val"] == ''){ - unset($this->statements["$key"]); - } else { - - /* Only quote filename values */ - if(in_array($key,array("filename"))){ - $this->statements["$key"]= '"'.get_post("$val").'"'; - }else{ - $this->statements["$key"]= get_post("$val"); - } - } - } - - /* Flags */ - if (isset ($_POST['autohost'])){ - $this->statements['get-lease-hostnames']= "true"; - } else { - unset($this->statements['get-lease-hostnames']); - } - if (isset ($_POST['autohostdecl'])){ - $this->statements['use-host-decl-names']= "on"; - } else { - unset($this->statements['use-host-decl-names']); - } - } - } - - - /* Check values */ - function check() - { - $message= array(); - - /* Check netmask and broadcast */ - foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){ - if (!isset($this->options["$key"])){ - continue; - } - $tmp= preg_replace('/^[^\s]+\s/', '', $this->options["$key"]); - - if (!is_ip($tmp)){ - $message[]= sprintf(_("Error in definition of '%s'!"), $typ); - } - } - - return $message; - } - - - /* Save to LDAP */ - function save() - { - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc b/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc deleted file mode 100644 index 756a97893..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc +++ /dev/null @@ -1,80 +0,0 @@ - array("dhcpSharedNetwork", "dhcpSubnet", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/), - #"dhcpClass" => array("dhcpSubClass"), - "dhcpSubClass" => array(), - "dhcpHost" => array(), - "dhcpGroup" => array("dhcpHost"), - "dhcpPool" => array(), - "dhcpSubnet" => array("dhcpPool", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/), - "dhcpSharedNetwork" => array("dhcpSubnet", "dhcpPool")); - - - - function dhcpNewSectionDialog($type) - { - $this->types= array( "dhcpService" => _("Global options"), - /*"dhcpClass" => _("Class"),*/ - "dhcpSubClass" => _("Subclass"), - "dhcpHost" => _("Host"), - "dhcpGroup" => _("Group"), - "dhcpPool" => _("Pool"), - "dhcpSubnet" => _("Subnet"), - "dhcpSharedNetwork" => _("Shared network")); - - $this->classtype= $type; - } - - function execute() - { - /* Fill templating stuff */ - $smarty = get_smarty(); - $display= ""; - - $sections= $this->sectionMap[$this->classtype]; - $t_sections= array(); - foreach ($sections as $section){ - $t_sections[$section]= $this->types[$section]; - } - asort($t_sections); - $ui = get_userinfo(); - $smarty->assign("sections", $t_sections); - $display.= $smarty->fetch(get_template_path('dhcpNewSection.tpl', TRUE)); - return($display); - } - - /* Get posts and set class name - */ - function save_object() - { - } - - /* Check given class name */ - function check() - { - /* Call common method to give check the hook */ - $message= ""; - - return ($message); - } - - - /* Return the class name */ - function save() - { - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dhcp/class_dhcpPool.inc b/plugins/admin/systems/services/dhcp/class_dhcpPool.inc deleted file mode 100644 index 9e9821e8a..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpPool.inc +++ /dev/null @@ -1,191 +0,0 @@ -new){ - $this->dhcpRange= $attrs['dhcpRange'][0]; - list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange); - } - - $this->advanced->setAutoOptions(array("host-name")); - $this->advanced->setAutoStatements(array("fixed-address")); - } - - function execute() - { - $smarty= get_smarty(); - $smarty->assign("cn", $this->cn); - $smarty->assign("range_start", $this->range_start); - $smarty->assign("range_stop", $this->range_stop); - - /* Show main page */ - $display= $smarty->fetch(get_template_path('dhcp_pool.tpl', TRUE)).$this->network->execute(); - - /* Merge arrays for advanced view */ - $this->fix_options(); - foreach (array("options", "statements") as $type){ - $this->advanced->$type= $this->$type + $this->network->$type;; - } - - $display.= $this->advanced->execute(); - - /* Merge back for removals */ - foreach (array("options", "statements") as $type){ - $this->$type= $this->advanced->$type; - $this->network->$type= $this->advanced->$type; - } - - /* Add footer */ - $display.= "
". - " 
"; - - return ($display); - } - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['cn'])){ - $this->cn= validate(get_post('cn')); - $this->range_start= validate(get_post('range_start')); - $this->range_stop= validate(get_post('range_stop')); - } - - dhcpPlugin::save_object(); - - /* Move range to internal variable */ - $this->dhcpRange= $this->range_start." ".$this->range_stop; - } - - - /* Check values */ - function check() - { - $message= array(); - - $cache = $this->parent->dhcpObjectCache; - - /* All required fields are set? */ - if ($this->cn == ""){ - $message[]= _("Required field 'Name' is not filled."); - } - - /* cn already used? */ - if ($this->orig_cn != $this->cn || $this->new){ - - foreach($cache as $dn => $dummy){ - if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ - $message[]= _("The name for this section is already used!"); - break; - } - } - } - - if ($this->dhcpRange == ""){ - $message[]= _("Required field 'Range' is not filled."); - } - - if (!is_ip($this->range_start) || !is_ip($this->range_stop)){ - $message[]= _("Field 'Range' contains invalid IP addresses."); - } - - if(!is_ip_range($this->range_start,$this->range_stop)){ - $message[] = _("Field 'Range' contains invalid IP range."); - } - - /* Check if range is in the network */ - $dn= $this->dn; - while (preg_match('/,/', $dn)){ - $type= $this->objectType($cache, $dn); - - /* Check for subnet */ - if ($type == 'dhcpSubnet'){ - $network= $cache[$dn]['cn'][0]; - $netmask= normalize_netmask($cache[$dn]['dhcpNetMask'][0]); - if (!is_in_network($network, $netmask, $this->range_start) || - !is_in_network($network, $netmask, $this->range_stop)){ - $message[] = _("'Range' is not inside the configured network."); - } - } - - /* Stop if we've examined the service base object */ - if ($type == 'dhcpService'){ - break; - } - $dn= preg_replace('/^[^,]+,/', '', $dn); - } - - /* Check external plugins */ - $net= $this->network->check(); - $adv= $this->advanced->check(); - $message= array_merge($message, $net, $adv); - - return $message; - } - - /* Save to LDAP */ - function save() - { - dhcpPlugin::save(); - $this->attrs['dhcpRange']= array($this->dhcpRange); - - return ($this->attrs); - } - - - function objectType($cache, $dn) - { - $type= ""; - $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost", - "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork"); - - foreach ($cache[$dn]['objectClass'] as $oc){ - if (in_array($oc, $types)){ - $type= $oc; - break; - } - } - - return ($type); - } - - -} - -?> diff --git a/plugins/admin/systems/services/dhcp/class_dhcpService.inc b/plugins/admin/systems/services/dhcp/class_dhcpService.inc deleted file mode 100644 index 57f76cc9e..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpService.inc +++ /dev/null @@ -1,181 +0,0 @@ -new){ - /* Load attributes */ - $this->dhcpPrimaryDN= $attrs['dhcpPrimaryDN'][0]; - } else { - /* We keep the parent dn here if it's new */ - $this->statements['default-lease-time']= 600; - $this->statements['max-lease-time']= 1700; - $this->statements['authoritative']= TRUE; - $this->statements['ddns-update-style']= 'none'; - } - - $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-identifier", "ddns-update-style")); - $this->advanced->setAutoOptions(array("server-name")); - - /* Save for later action */ - $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN; - } - - - function execute() - { - /* Show main page */ - $smarty= get_smarty(); - - $smarty->assign('ddns_styles', $this->ddns_styles); - foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $value){ - if (isset($this->statements[preg_replace('/_/', '-', $value)])){ - $smarty->assign("$value", $this->statements[preg_replace('/_/', '-', $value)]); - } else { - $smarty->assign("$value", ""); - } - } - - if (isset($this->statements['authoritative'])){ - $smarty->assign("authoritative", "checked"); - } else { - $smarty->assign("authoritative", ""); - } - - /* Show main page */ - $display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE)).$this->network->execute(); - - /* Merge arrays for advanced view */ - $this->fix_options(); - foreach (array("options", "statements") as $type){ - $this->advanced->$type= $this->$type + $this->network->$type;; - } - - $display.= $this->advanced->execute(); - - /* Merge back for removals */ - foreach (array("options", "statements") as $type){ - $this->$type= $this->advanced->$type; - $this->network->$type= $this->advanced->$type; - } - - /* Add footer */ - $display.= "
". - " 
"; - - - return ($display); - - } - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - /* No need to save in the first time */ - if (!isset($_POST['ddns_update_style'])){ - return; - } - - /* Save remaining attributes */ - foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){ - $tval= preg_replace('/_/', '-', $val); - if ($_POST[$val] != ""){ - $this->statements[$tval]= validate(get_post($val)); - } else { - unset ($this->statements[$tval]); - } - } - if (isset($_POST['authoritative'])){ - $this->statements['authoritative']= ""; - } else { - unset($this->statements['authoritative']); - } - - dhcpPlugin::save_object(); - } - - - /* Check values */ - function check() - { - $message= array(); - - if (!is_id($this->statements['default-lease-time'])){ - $message[]= _('Default lease time needs to be numeric.'); - } - if (!is_id($this->statements['max-lease-time'])){ - $message[]= _('Maximum lease time needs to be numeric.'); - } - if ($this->statements['default-lease-time'] > $this->statements['max-lease-time']){ - $message[]= _('Default lease time needs to smaller than the maximum lease time.'); - } - - /* Check external plugins */ - $net= $this->network->check(); - $adv= $this->advanced->check(); - $message= array_merge($message, $net, $adv); - - return $message; - } - - - /* Save to LDAP */ - function save() - { - global $config; - $this->attrs= array(); - - /* Get and set server name */ - $ldap= $config->get_ldap_link(); - $ldap->cat($this->dhcpPrimaryDN, array('cn')); - $res= $ldap->fetch(); - $server_name= $res['cn'][0]; - - dhcpPlugin::save(); - - $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN); - $this->removeOption('server-name'); -# $this->attrs['dhcpOption'][]= "server-name $server_name"; - - return ($this->attrs); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc b/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc deleted file mode 100644 index 6e55b75d6..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc +++ /dev/null @@ -1,188 +0,0 @@ -advanced->setAutoStatements(array("server-identifier", "default-lease-time", - "max-lease-time", "min-lease-time", "authoritative", "deny-unknown-clients", - "deny-bootp", "deny-booting")); - } - - - function execute() - { - $smarty= get_smarty(); - - /* Fill template */ - $smarty->assign ("cn", $this->cn); - foreach (array("server-identifier", "default-lease-time", "max-lease-time", "min-lease-time") as $attr){ - if (isset($this->statements[$attr])){ - $smarty->assign(preg_replace('/-/', '_', $attr), $this->statements[$attr]); - } else { - $smarty->assign(preg_replace('/-/', '_', $attr), ""); - } - } - if (isset($this->statements["authoritative"])){ - $smarty->assign("authoritative", "checked"); - } else { - $smarty->assign("authoritative", ""); - } - if (!isset($this->statements["deny unknown-clients"])){ - $smarty->assign("allow_unknown_state", "checked"); - } else { - $smarty->assign("allow_unknown_state", ""); - } - if (!isset($this->statements["deny bootp"])){ - $smarty->assign("allow_bootp_state", "checked"); - } else { - $smarty->assign("allow_bootp_state", ""); - } - if (!isset($this->statements["deny booting"])){ - $smarty->assign("allow_booting_state", "checked"); - } else { - $smarty->assign("allow_booting_state", ""); - } - - /* Show main page */ - $display= $smarty->fetch(get_template_path('dhcp_sharedNetwork.tpl', TRUE)).$this->network->execute(); - - /* Merge arrays for advanced view */ - $this->fix_options(); - foreach (array("options", "statements") as $type){ - $this->advanced->$type= $this->$type + $this->network->$type; - } - - $display.= $this->advanced->execute(); - - /* Merge back for removals */ - foreach (array("options", "statements") as $type){ - $this->$type= $this->advanced->$type; - $this->network->$type= $this->advanced->$type; - } - - /* Add footer */ - $display.= "
". - " 
"; - - - return ($display); - } - - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['cn'])){ - $this->cn= validate(get_post('cn')); - dhcpPlugin::save_object(); - - foreach (array("server-identifier", "default-lease-time", - "max-lease-time", "min-lease-time") as $attr){ - if (isset($_POST[$attr]) && $_POST[$attr] != ""){ - $this->statements[$attr]= get_post($attr); - } else { - unset($this->statements[$attr]); - } - } - - if (isset($_POST["authoritative"])){ - $this->statements["authoritative"]= ""; - } else { - unset ($this->statements["authoritative"]); - } - - foreach(array("unknown-clients", "bootp", "booting") as $name){ - if (isset($_POST[$name])){ - $this->statements["allow $name"]= ""; - unset($this->statements["deny $name"]); - } else { - $this->statements["deny $name"]= ""; - unset($this->statements["allow $name"]); - } - } - } - } - - - /* Check values */ - function check() - { - $message= array(); - - $cache = $this->parent->dhcpObjectCache; - - /* All required fields are set? */ - if ($this->cn == ""){ - $message[]= _("Required field 'Name' is not filled."); - } - - /* Check lease times */ - foreach (array("default-lease-time" => _("Default lease time"), - "max-lease-time" => _("Max. lease time"), - "min-lease-time" => _("Min. lease time")) as $key => $val){ - if (isset($this->statements[$key]) && $this->statements[$key] != "" && - !is_id($this->statements[$key])){ - $message[]= sprintf(_("The value specified as '%s' is not numeric!"), $val); - } - } - - /* cn already used? */ - if ($this->orig_cn != $this->cn || $this->new){ - - foreach($cache as $dn => $dummy){ - if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ - $message[]= _("The name for this host section is already used!"); - break; - } - } - } - - /* Check external plugins */ - $net= $this->network->check(); - $adv= $this->advanced->check(); - $message= array_merge($message, $net, $adv); - - return $message; - } - - - /* Save to LDAP */ - function save() - { - dhcpPlugin::save(); - - return ($this->attrs); - } - -} - -?> diff --git a/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc b/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc deleted file mode 100644 index 8c2da41de..000000000 --- a/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc +++ /dev/null @@ -1,200 +0,0 @@ -new){ - /* Load attributes */ - foreach (array("dhcpNetMask", "dhcpRange") as $attr){ - if (isset($attrs[$attr][0])){ - $this->$attr= $attrs[$attr][0]; - } - } - if (isset($attrs['dhcpRange']) && count($attrs['dhcpRange'])){ - $this->use_range= TRUE; - list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange); - } - } - - $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask); - } - - - function execute() - { - $smarty= get_smarty(); - $smarty->assign("cn", $this->cn); - $smarty->assign("dhcp_netmask", $this->dhcpNetMask); - - /* Prepare range */ - if ($this->use_range){ - $smarty->assign("use_range", "checked"); - $smarty->assign("range_disabled", ""); - } else { - $smarty->assign("use_range", ""); - $smarty->assign("range_disabled", "disabled"); - } - $smarty->assign("range_start", $this->range_start); - $smarty->assign("range_stop", $this->range_stop); - - /* Show main page */ - $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE)).$this->network->execute(); - - /* Merge arrays for advanced view */ - $this->fix_options(); - foreach (array("options", "statements") as $type){ - $this->advanced->$type= $this->$type + $this->network->$type; - } - - $display.= $this->advanced->execute(); - - /* Merge back for removals */ - foreach (array("options", "statements") as $type){ - $this->$type= $this->advanced->$type; - $this->network->$type= $this->advanced->$type; - } - - /* Add footer */ - $display.= "
". - " 
"; - - /* Show main page */ - return $display; - } - - - function remove_from_parent() - { - } - - - /* Save data to object */ - function save_object() - { - if(isset($_POST['dhcp_subnet_posted'])){ - if (isset($_POST['cn'])){ - $this->cn= validate(get_post('cn')); - } - if (isset($_POST['dhcp_netmask'])){ - $this->dhcpNetMask= validate(get_post('dhcp_netmask')); - } - if (isset($_POST['use_range'])){ - $this->use_range= TRUE; - $this->range_start= validate(get_post('range_start')); - $this->range_stop= validate(get_post('range_stop')); - } else { - $this->use_range= FALSE; - } - - /* Move range to internal variable */ - $this->dhcpRange= $this->range_start." ".$this->range_stop; - dhcpPlugin::save_object(); - } - } - - - /* Check values */ - function check() - { - $message= array(); - - $cache = $this->parent->dhcpObjectCache; - - /* All required fields are set? */ - if ($this->cn == ""){ - $message[]= _("Required field 'Network address' is not filled."); - } - if ($this->dhcpNetMask == ""){ - $message[]= _("Required field 'Netmask' is not filled."); - } - - /* cn already used? */ - if ($this->orig_cn != $this->cn || $this->new){ - - foreach($cache as $dn => $dummy){ - if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ - $message[]= _("The name for this section is already used!"); - break; - } - } - } - - /* IP's? */ - foreach(array('dhcpNetMask' => _("Netmask"), 'cn' => _("Network address"), 'range_start' => _("Range"), 'range_stop' => _("Range")) as $attr => $str){ - if ($this->$attr != "" && !is_ip($this->$attr)){ - $message[]= sprintf(_("The field '%s' contains an invalid IP address"), $str); - } - } - - /* Check ip range */ - if ($this->use_range){ - if(!is_ip_range($this->range_start,$this->range_stop)){ - $message[] = _("Field 'Range' contains invalid IP range."); - } - - /* Check if range is in the network */ - if (!is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) || - !is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){ - $message[] = _("'Range' is not inside the configured network."); - } - } - - /* Check external plugins */ - $net= $this->network->check(); - $adv= $this->advanced->check(); - $message= array_merge($message, $net, $adv); - - return $message; - } - - - /* Save to LDAP */ - function save() - { - dhcpPlugin::save(); - - /* Move dn to the result */ - $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask)); - if ($this->use_range && !empty($this->dhcpRange)){ - $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop); - } else { - $this->attrs['dhcpRange']= array(); - } - - return ($this->attrs); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dhcp/class_servDHCP.inc b/plugins/admin/systems/services/dhcp/class_servDHCP.inc deleted file mode 100644 index c804ec2bc..000000000 --- a/plugins/admin/systems/services/dhcp/class_servDHCP.inc +++ /dev/null @@ -1,739 +0,0 @@ - array(),"FOR_LIST"=> array()); - var $take_over_id = -1; - var $display_warning = TRUE; - - function servdhcp (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $this->serviceDN = "cn=dhcp,".$dn; - $this->orig_dn = $dn; - - $this->DisplayName = _("DHCP service"); - - $this->types= array( "dhcpLog" => _("Logging"), - "dhcpService" => _("Global options"), - "dhcpClass" => _("Class"), - "dhcpSubClass" => _("Subclass"), - "dhcpHost" => _("Host"), - "dhcpGroup" => _("Group"), - "dhcpPool" => _("Pool"), - "dhcpSubnet" => _("Subnet"), - "dhcpFailOverPeer" => _("Failover peer"), - "dhcpSharedNetwork" => _("Shared network")); - - - /* Backport: PHP4 compatibility */ - foreach($this->types as $type => $translation){ - $this->types[strtolower($type)] = $translation; - } - - /* Load information about available services */ - $this->reload(); - if (!count($this->dhcpSections)){ - $this->is_account= FALSE; - $this->dhcp_server_list = $this->get_list_of_dhcp_servers(); - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $smarty->assign("dns_take_over",FALSE); - $display= ""; - - - /*****************/ - /* Handle Take Over Actions - /*****************/ - - /* Give smarty the required informations */ - $smarty->assign("dhcp_server_list", $this->dhcp_server_list['FOR_LIST']); - $smarty->assign("dhcp_server_list_cnt", count($this->dhcp_server_list['FOR_LIST'])); - - /* Take over requested, save id */ - if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){ - $id = $_POST['take_over_src']; - if(isset($this->dhcp_server_list['ENTRIES'][$id])){ - $this->take_over_id = $id; - } - } - - /* Abort take over action */ - if(isset($_POST['cancel_take_over'])){ - $this->dialog =false; - $this->take_over_id = -1; - $this->dhcp_server_list = $this->get_list_of_dhcp_servers(); - } - - /* Display informartion about take over that will be started when saving this server - * and hide default dhcp output - */ - if($this->take_over_id != -1){ - - $this->dialog = FALSE; - $id = $this->take_over_id; - $smarty->assign("dns_take_over",TRUE); - $warning = sprintf(_("You are going to migrate the DHCP setup from server '%s'."), - $this->dhcp_server_list['ENTRIES'][$id]['cn'][0]); - $warning.= " "._("The migration will be started when you save this system. To cancel this action, use the cancel button below."); - - if($this->display_warning){ - print_red($warning); - $this->display_warning = FALSE; - } - return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE))); - } - - - /*****************/ - /* List handling - /*****************/ - - /* Section Creation? */ - if (isset($_POST['create_section']) && isset($_POST['section'])){ - $section= $_POST['section']; - $tmp = new dhcpNewSectionDialog(NULL); - if (isset($tmp->sectionMap[$section])){ - $this->dialog= new $section($this->current_object); - $this->current_object= ""; - } else { - $this->dialog= FALSE; - } - } - - /* Cancel section creation? */ - if (isset($_POST['cancel_section']) || isset($_POST['cancel_dhcp'])){ - $this->dialog= FALSE; - } - - /* Save changes */ - if (isset($_POST['save_dhcp'])){ - $this->dialog->save_object(); - $messages= $this->dialog->check(); - if (count($messages)){ - show_errors($messages); - } else { - $dn= $this->dialog->dn; - $class= get_class($this->dialog); - $type= $this->types[$class]; - if(empty($this->serviceDN)){ - $indent= substr_count(preg_replace("/".$this->dn."/", '', $dn), ",") -1; - }else{ - $indent= substr_count(preg_replace("/".$this->serviceDN."/", '', $dn), ","); - } - $spaces= ""; - for ($i= 0; $i<$indent; $i++){ - $spaces.= "    "; - } - $data= $this->dialog->save(); - if ($this->current_object == ""){ - /* New object */ - $newsects= array(); - foreach ($this->dhcpSections as $key => $dsc){ - $newsects[$key]= $dsc; - if ($key == $dn){ - $spaces.= "    "; - $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'"; - } - } - $this->dhcpObjectCache[$data['dn']]= $data; - $this->dhcpSections= $newsects; - } else { - if ($dn != $data['dn']){ - /* Old object, new name */ - $this->dhcpObjectCache[$dn]= array(); - $this->dhcpObjectCache[$data['dn']]= $data; - - /* If we renamed a section, we've to rename a couple of objects, too */ - foreach ($this->dhcpObjectCache as $key => $dsc){ - if (preg_match("/,$dn$/", $key)){ - $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key); - $dsc['MODIFIED']= TRUE; - $this->dhcpObjectCache[$new_dn]= $dsc; - unset($this->dhcpObjectCache[$key]); - } - } - $newsects= array(); - foreach ($this->dhcpSections as $key => $dsc){ - if ($key == $dn){ - $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'"; - continue; - } - if (preg_match("/,$dn$/", $key)){ - $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key); - $newsects[$new_dn]= $dsc; - } else { - $newsects[$key]= $dsc; - } - } - $this->dhcpSections= $newsects; - - } else { - /* Old object, old name */ - $this->dhcpObjectCache[$data['dn']]= $data; - } - } - $this->dialog= FALSE; - } - } - - /* Remove section? */ - if (isset($_POST['delete_dhcp_confirm'])){ - if ($this->acl_is_removeable()){ - unset($this->dhcpSections[$this->current_object]); - unset($this->dhcpObjectCache[$this->current_object]); - $this->dhcpObjectCache[$this->current_object]= array(); - foreach ($this->dhcpSections as $key => $value){ - if (preg_match("/".$this->current_object."$/", $key)){ - unset($this->dhcpSections[$key]); - unset($this->dhcpObjectCache[$key]); - $this->dhcpObjectCache[$key]= array(); - } - } - } else { - print_red(_("You're not allowed to remove DHCP sections!")); - } - $this->dialog= FALSE; - } - - /* Look for post entries */ - foreach($_POST as $name => $value){ - - /* Insert new section? */ - if (preg_match('/^insertDhcp_.*_x$/', $name)){ - $dn= base64_decode(preg_replace('/^insertDhcp_([^_]+)_x$/', '\1', $name)); - if (isset($this->dhcpObjectCache[$dn])){ - $this->dialog= new dhcpNewSectionDialog($this->objectType($dn)); - $this->current_object= $dn; - $this->dialog->acl= $this->acl; - } - } - - /* Edit section? */ - if (preg_match('/^editDhcp_.*_x$/', $name)){ - $dn= base64_decode(preg_replace('/^editDhcp_([^_]+)_x$/', '\1', $name)); - if (isset($this->dhcpObjectCache[$dn])){ - $section= $this->objectType($dn); - $this->current_object= $dn; - $this->dialog= new $section($this->dhcpObjectCache[$dn]); - } - } - - /* Remove section? */ - if (preg_match('/^delDhcp_.*_x$/', $name)){ - $dn= base64_decode(preg_replace('/^delDhcp_([^_]+)_x$/', '\1', $name)); - if (isset($this->dhcpObjectCache[$dn])){ - $this->current_object= $dn; - $this->dialog= 1; - $smarty->assign("warning", sprintf(_("You're about to delete the DHCP section '%s'."), $dn)); - return($smarty->fetch(get_template_path('remove_dhcp.tpl', TRUE))); - } - } - - } - - if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){ - $dn = base64_decode($_GET['id']); - if (isset($this->dhcpObjectCache[$dn])){ - $section= $this->objectType($dn); - $this->current_object= $dn; - $this->dialog= new $section($this->dhcpObjectCache[$dn]); - } - } - - - if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){ - $dn = base64_decode($_GET['id']); - if (isset($this->dhcpObjectCache[$dn])){ - $section= $this->objectType($dn); - $this->current_object= $dn; - $this->dialog= new $section($this->dhcpObjectCache[$dn]); - } - } - - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Show tab dialog headers */ - if ($this->is_account){ -# $display= $this->show_header(_("Remove DHCP service"), -# _("This server has DHCP features enabled. You can disable them by clicking below.")); - - if (!count($this->dhcpObjectCache)){ - $attrs= array(); - $attrs['dn']= 'cn=dhcp,'.$this->dn; - $attrs['cn']= array('dhcp'); - $attrs['objectClass']= array('top', 'dhcpService'); - $attrs['dhcpPrimaryDN']= array($this->dn); - $attrs['dhcpStatements']= array("default-lease-time 600", - "max-lease-time 1200", - "authoritative", - "ddns-update-style none"); - $attrs['MODIFIED']= TRUE; - $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options"); - $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs; - } - - } else { -# $display= $this->show_header(_("Add DHCP service"), - -# _("This server has DHCP features disabled. You can enable them by clicking below.")); - return ($display); - } - - - /* Show dialog - */ - if(isset($this->dialog) && is_object($this->dialog)){ - $this->dialog->save_object(); - $this->dialog->parent = $this; - return($this->dialog->execute()); - } - - /* Create Listbox with existing Zones - */ - $DhcpList = new divSelectBox("dhcpSections"); - $DhcpList->SetHeight(400); - - /* Add entries to divlist - */ - $editImgIns = "". - "". - ""; - $editImgInsNoDel = "". - ""; - $editImg = "". - ""; - - $tmp = new dhcpNewSectionDialog(NULL); - foreach($this->dhcpSections as $section => $values ){ - - $values = "".$values.""; - - if (count($tmp->sectionMap[$this->objectType($section)])){ - if ($this->objectType($section) == "dhcpService"){ - $DhcpList->AddEntry(array( - array("string" => $values), - array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'") - )); - } else { - $DhcpList->AddEntry(array( - array("string" => $values), - array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'") - )); - } - } else { - $DhcpList->AddEntry(array( - array("string" => $values), - array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'") - )); - } - } - - /* Display tempalte */ - $smarty->assign("DhcpList",$DhcpList->DrawList()); - $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE)); - return($display); - } - - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - /* Remove subtrees */ - $ldap= $this->config->get_ldap_link(); - foreach ($this->dhcpObjectCache as $dn => $content){ - if ($this->objectType($dn) == 'dhcpService'){ - $ldap->rmdir_recursive($dn); - show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed")); - } - } - - /* Remove from self */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed")); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove"); - } - - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - /* Take over handling - * - Load servdhcp class and dhcpObjectCache for the source dhcp setup. - * - Assign dhcpObjectCache to this configuration. - * - Save this setup and remove source setup from ldap. - */ - if($this->take_over_id != -1){ - $id = $this->take_over_id; - $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']); - $tmp = new servdhcp ($this->config, $src); - $this->orig_dn = $src; - $this->dhcpObjectCache = $tmp->dhcpObjectCache; - } - - /* Save dhcp setttings */ - $ldap= $this->config->get_ldap_link(); - foreach ($this->dhcpObjectCache as $dn => $data){ - - if($this->dn != $this->orig_dn){ - $dn = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$dn); - } - - /* Remove entry? */ - if (count($data) == 0){ - /* Check if exists, then remove... */ - if($ldap->cat($dn)){ - $ldap->rmdir_recursive($dn); - show_ldap_error($ldap->get_error(), _("Can't remove DHCP object!")); - } - continue; - } - - /* Opdate dhcp option 'server-name' to actual server name */ - if($this->dn != $this->orig_dn){ - $fixed = FALSE; - foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){ - if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){ - foreach($data['dhcpOption'] as $key => $option){ - if(preg_match("/^server-name /",$option)){ - $data['dhcpOption'][$key] = "server-name ".$this->cn; - $data['MODIFIED'] = TRUE; - break; - } - } - } - - /* Skip next loops if entry is updated */ - if($fixed){ - break; - } - } - } - - /* Modify existing entry? */ - if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){ - - if($ldap->cat($dn)){ - $modify= TRUE; - } else { - $modify= FALSE; - } - - /* Build new entry */ - $attrs= array(); - foreach ($data as $attribute => $values){ - if ($attribute == "MODIFIED" || $attribute == "dn"){ - continue; - } - - if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){ - foreach($values as $v_key => $value){ - $values[$v_key] = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$value); - } - } - - if (count($values)){ - - if($attribute == "dhcpOption"){ - foreach($values as $key => $value){ - $option_name = trim(preg_replace("/[^ ]*$/","",$value)); - $option_value= trim(preg_replace("/^[^ ]*/","",$value)); - if(in_array($option_name,$this->quote_option)){ - $values[$key] = $option_name." \"".$option_value."\""; - } - } - } - if (count($values) == 1){ - $attrs[$attribute]= $values[0]; - } else { - $attrs[$attribute]= $values; - } - } else { - if ($modify){ - $attrs[$attribute]= array(); - } - } - } - - $ldap->cd($dn); - if ($modify){ - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), _("Can't save DHCP object!")); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("modify"); - } else { - $ldap->add($attrs); - show_ldap_error($ldap->get_error(), _("Can't save DHCP object!")); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("create"); - } - } - } - - $this->dhcpServiceDN= $this->serviceDN; - if($this->dn != $this->orig_dn){ - $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN); - } - - /* Replace 'new' dn */ - if(preg_match("/new$/",$this->dhcpServiceDN)){ - $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN); - } - - plugin::save(); - - /* Save data to LDAP */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - show_ldap_error($ldap->get_error(), _("Saving DHCP service failed")); - - /* 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"); - } - } else { - $this->handle_post_events("add"); - } - - /* Take over handling - * - Remove old dhcp config from source server - */ - if($this->take_over_id != -1){ - $id = $this->take_over_id; - $src = $this->dhcp_server_list['ENTRIES'][$id]['dn']; - $tmp = new servdhcp ($this->config, $src); - $tmp->remove_from_parent(); - } - } - - - function reload() - { - /* Init LDAP and load list */ - $ldap= $this->config->get_ldap_link(); - $ui= get_userinfo(); - $me= $this->dn; - - $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))"; - - $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH); - $final= array(); - - foreach ($list as $value){ - - /* Set header */ - $sortpart= split(",", $value['dn']); - $sortpart= array_reverse($sortpart); - $tmp= implode(",", $sortpart); - - $final[$value['dn']]= $tmp."!"._("Global options"); - - /* Read all sub entries to place here */ - $ldap->cd($value['dn']); - $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array()); - $this->serviceDN= $value['dn']; - - while ($attrs= $ldap->fetch()){ - $sattrs= array(); - for ($i= 0; $i<$attrs['count']; $i++){ - $sattrs[$attrs[$i]]= $attrs[$attrs[$i]]; - unset($sattrs[$attrs[$i]]['count']); - } - $sattrs['dn']= $ldap->getDN(); - - foreach($sattrs as $name => $values){ - if($name == "dhcpOption"){ - foreach($values as $key => $value){ - $value_name = trim(preg_replace("/[^ ]*$/","",$value)); - $value_value= trim(preg_replace("/^[^ ]*/","",$value)); - if(in_array($value_name,$this->quote_option)){ - $value_value = preg_replace("/^\"/","",$value_value); - $value_value = preg_replace("/\"$/","",$value_value); - $sattrs[$name][$key] = $value_name." ".$value_value; - } - } - } - } - - $this->dhcpObjectCache[$ldap->getDN()]= $sattrs; - $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN()); - $indent= substr_count($tmp, ","); - $spaces= ""; - for ($i= 0; $i<$indent; $i++){ - $spaces.= "    "; - } - - foreach ($this->types as $key => $val){ - if (in_array("$key", $attrs['objectClass'])){ - $type= $val; - break; - } - } - - /* Prepare for sorting... */ - $sortpart= split(",", $ldap->getDN()); - $sortpart= array_reverse($sortpart); - $tmp= implode(",", $sortpart); - $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'"; - } - } - - /* Sort it... */ - natsort($final); - $this->dhcpSections= array(); - foreach ($final as $key => $val){ - $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val); - } - - } - - - function objectType($dn) - { - $type= ""; - $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost", - "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork"); - - foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){ - if (in_array($oc, $types)){ - $type= $oc; - break; - } - } - - /* That should not happen... */ - if ($type == ""){ - print_red(_("DHCP configuration set is unknown. Please contact your system administrator.")); - } - - return ($type); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("DHCP service"), - "plDescription" => _("DHCP service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 84, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - - ) - )); - } - - - function take_over_service() - { - - } - - - function get_list_of_dhcp_servers() - { - $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array()); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN")); - while($attrs = $ldap->fetch()){ - - /* Skip own config */ - if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){ - continue; - } - - $ret['ENTRIES'][] = $attrs; - } - foreach($ret['ENTRIES'] as $key => $data){ - $ret['FOR_LIST'][$key] = $data['cn'][0]; - } - return($ret); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("DHCP service"); - $fields['AllowEdit'] = true; - return($fields); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl b/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl deleted file mode 100644 index 517c3b403..000000000 --- a/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl +++ /dev/null @@ -1,25 +0,0 @@ -
- {t}Create new DHCP section{/t} -
-
-

-{t}Please choose one of the following DHCP section types.{/t} -

-
-{t}Section{/t}  - - -

- -   - -

- - - diff --git a/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl b/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl deleted file mode 100644 index 5ce0e4600..000000000 --- a/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{* GOsa dhcp sharedNetwork - smarty template *} - -

-
- -{if $show_advanced} - - - - - - - - - - -
-
- {t}DHCP statements{/t} -
- -
-   -   - -
-
- {t}DHCP options{/t} -
- -
-   -   - -
- -{else} - - - -{/if} -

 

diff --git a/plugins/admin/systems/services/dhcp/dhcp_group.tpl b/plugins/admin/systems/services/dhcp/dhcp_group.tpl deleted file mode 100644 index 930fc05ee..000000000 --- a/plugins/admin/systems/services/dhcp/dhcp_group.tpl +++ /dev/null @@ -1,22 +0,0 @@ -{* GOsa dhcp sharedNetwork - smarty template *} -

{t}Generic{/t}

- - - - - -
- {t}Name{/t}{$must} - - -
- -

 

- - - diff --git a/plugins/admin/systems/services/dhcp/dhcp_host.tpl b/plugins/admin/systems/services/dhcp/dhcp_host.tpl deleted file mode 100644 index 602c51255..000000000 --- a/plugins/admin/systems/services/dhcp/dhcp_host.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{* GOsa dhcp host - smarty template *} -

{t}Generic{/t}

- - - - - -
- - - - - - - - - -
{t}Name{/t}{$must} - -
{t}Fixed address{/t} - -
-
- - - - - - - - - -
{t}Hardware type{/t} - -
{t}Hardware address{/t}{$must} - -
-
- -

- - - diff --git a/plugins/admin/systems/services/dhcp/dhcp_network.tpl b/plugins/admin/systems/services/dhcp/dhcp_network.tpl deleted file mode 100644 index 5645a63ac..000000000 --- a/plugins/admin/systems/services/dhcp/dhcp_network.tpl +++ /dev/null @@ -1,90 +0,0 @@ -{* GOsa dhcp sharedNetwork - smarty template *} - - - - - -
-

{t}Network configuration{/t}

- - - - - - - - - - - - - -
{t}Router{/t} - -
{t}Netmask{/t} - -
{t}Broadcast{/t} - -
-
-
-

{t}Bootup{/t}

- - - - - - - - - -
{t}Filename{/t} - -
{t}Next server{/t} - -
- -
-

{t}Domain Name Service{/t}

- - - - - - - - - - - -
{t}Domain{/t} - -
-
- {t}DNS server{/t}
- -
-   - - -
-

{t}Domain Name Service options{/t}

- {t}Assign hostnames found via reverse mapping{/t} -
- {t}Assign hostnames from host declarations{/t} -
- -
- - - diff --git a/plugins/admin/systems/services/dhcp/dhcp_pool.tpl b/plugins/admin/systems/services/dhcp/dhcp_pool.tpl deleted file mode 100644 index dcbd05c3d..000000000 --- a/plugins/admin/systems/services/dhcp/dhcp_pool.tpl +++ /dev/null @@ -1,26 +0,0 @@ -{* GOsa dhcp sharedNetwork - smarty template *} -

{t}Generic{/t}

- - - - - -
- {t}Name{/t}{$must}  - - - {t}Range{/t}{$must}  - -  -  - -
- -

 

- - - diff --git a/plugins/admin/systems/services/dhcp/dhcp_service.tpl b/plugins/admin/systems/services/dhcp/dhcp_service.tpl deleted file mode 100644 index 6ca515e67..000000000 --- a/plugins/admin/systems/services/dhcp/dhcp_service.tpl +++ /dev/null @@ -1,43 +0,0 @@ -

{t}Generic{/t}

- - - - - - - - -
- {t}Authoritative service{/t}
-
- {t}Dynamic DNS update{/t} - -
- - - - - - - - - - -
{t}Default lease time (s){/t} - -
{t}Maximum lease time (s){/t} - -
- -
- -

- - - diff --git a/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl b/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl deleted file mode 100644 index 374da3500..000000000 --- a/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl +++ /dev/null @@ -1,107 +0,0 @@ -{* GOsa dhcp sharedNetwork - smarty template *} -

{t}Generic{/t}

- - - - - - - - -
- - - - - - - - - - -
{t}Name{/t}{$must} - -
{t}Server identifier{/t} - -
- -
- - - - -
- {t}Authoritative server{/t} -
-
- -

 

- - - - - - - - -
- -

{t}Leases{/t}

- - - - - - - - - - - - - -
{t}Default lease time{/t} -  {t}seconds{/t} -
{t}Max. lease time{/t} -  {t}seconds{/t} -
{t}Min. lease time{/t} -  {t}seconds{/t} -
- -
-

{t}Access control{/t}

- - - - - - - - - - -
- {t}Allow unknown clients{/t} -
- {t}Allow bootp clients{/t} -
- {t}Allow booting{/t} -
-
- -

 

- - - diff --git a/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl b/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl deleted file mode 100644 index 05425fbdc..000000000 --- a/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl +++ /dev/null @@ -1,41 +0,0 @@ -{* GOsa dhcp subnet - smarty template *} -

{t}Generic{/t}

- - - - - -
- - - - - - - - -
{t}Network address{/t}{$must}
{t}Netmask{/t}{$must}
-
- - - - - - - - - -
{t}Range for dynamic address assignment{/t}
  -  -  - -
-
- -

- - - diff --git a/plugins/admin/systems/services/dhcp/remove_dhcp.tpl b/plugins/admin/systems/services/dhcp/remove_dhcp.tpl deleted file mode 100644 index 39fb19bb6..000000000 --- a/plugins/admin/systems/services/dhcp/remove_dhcp.tpl +++ /dev/null @@ -1,17 +0,0 @@ -
- {t}Warning{/t} -
-

- {$warning} - {t}This includes 'all' DHCP subsections that are located within this section. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- -   - -

diff --git a/plugins/admin/systems/services/dhcp/servdhcp.tpl b/plugins/admin/systems/services/dhcp/servdhcp.tpl deleted file mode 100644 index 846af22ff..000000000 --- a/plugins/admin/systems/services/dhcp/servdhcp.tpl +++ /dev/null @@ -1,35 +0,0 @@ -{if $dns_take_over} - - - - -
-

{t}DHCP take over will take place when saving this entry. Choose 'Cancel' to abort.{/t}

-
-{else} - -{if $dhcp_server_list_cnt} - - - -{/if} - - - -
- {t}Take over dhcp configuration from following server{/t}  - - -
-

{t}DHCP sections{/t}

- {$DhcpList} -
-{/if} -

 

-
- -   - -
"Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = FALSE; - var $attributes = array(); - var $objectclasses = array("whatever"); - - var $RecordTypes = array(); - var $Zones = array(); - - var $orig_dn = ""; - - var $initially_was_account; - - /* ServerService tab vars */ - var $conflicts = array("servdns"); - var $DisplayName = ""; - var $StatusFlag = ""; - var $view_logged = FALSE; - - var $dns_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array()); - var $take_over_id = -1; - - - function servdns (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $this->DisplayName = _("DNS service"); - - $this->orig_dn = $dn; - - /* Get record types for zones - */ - $this->RecordTypes = getDnsRecordTypes(true); - - /* Get all zone Informations - */ - $this->Zones = getDNSZoneEntries($config,$dn); - - /* If there is at least one entry in this -> types, we have DNS enabled - */ - if(count($this->Zones) == 0){ - $this->is_account = false; - $this->dns_server_list = $this->get_list_of_dns_servers(); - }else{ - $this->is_account = true; - } - $this->initially_was_account = $this->is_account; - } - - - function get_list_of_dns_servers() - { - $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array()); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=dNSZone)(zoneName=*))",array("dn","zoneName")); - $dns = array(); - while($attrs = $ldap->fetch()){ - /* Skip own config */ - if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){ - continue; - } - $dn = preg_replace("/^zoneName=[^,]+,/","",$attrs['dn']); - if(preg_match("/^cn=/",$dn) && !in_array($dn,$dns)){ - $dns[] = $dn; - } - } - $i = 0; - foreach($dns as $dn){ - $ldap->cat($dn,array('*')); - if($ldap->count()){ - $i ++; - $attrs = $ldap->fetch(); - $ret['ENTRIES'][$i] = $attrs; - $ret['FOR_LIST'][$i] = $attrs['cn'][0]; - } - } - return($ret); - } - - - function get_dns_info_string($id) - { - $ret=""; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dns_server_list['ENTRIES'][$id]['dn']); - $ldap->search("(|(zoneName=*)(relativeDomainName=*))",array("dn")); - while($attrs = $ldap->fetch()){ - $ret .= $attrs['dn']."\n"; - } - return($ret); - } - - - function execute() - { - /* Call parent execute - */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* Fill templating stuff - */ - $smarty= get_smarty(); - $smarty->assign("dns_take_over",FALSE); - $smarty->assign("is_createable",$this->acl_is_createable()); - $display= ""; - - - $this->initially_was_account= $this->is_account; - /*****************/ - /* Handle Take Over Actions - /*****************/ - - /* Give smarty the required informations */ - $smarty->assign("dns_server_list", $this->dns_server_list['FOR_LIST']); - $smarty->assign("dns_server_list_cnt", count($this->dns_server_list['FOR_LIST'])); - - /* Take over requested, save id */ - if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){ - $id = $_POST['take_over_src']; - if(isset($this->dns_server_list['ENTRIES'][$id])){ - $this->take_over_id = $id; - } - } - - /* Abort take over action */ - if(isset($_POST['cancel_take_over'])){ - $this->dialog =false; - $this->take_over_id = -1; - $this->dns_server_list = $this->get_list_of_dns_servers(); - } - - /* Display informartion about take over that will be started when saving this server - * and hide default dns output - */ - if($this->take_over_id != -1){ - $this->dialog = FALSE; - $id = $this->take_over_id; - $info = $this->get_dns_info_string($id); - $smarty->assign("dns_take_over",TRUE); - $smarty->assign("info",$info); - $warning = sprintf(_("You are going to migrate the DNS setup from server '%s'."),$this->dns_server_list['ENTRIES'][$id]['cn'][0]); - $warning2 = _("The migration will be startet when you save this system. To cancel this action, use the cancel button below."); - $smarty->assign("warning",$warning); - $smarty->assign("warning2",$warning2); - return($smarty->fetch(get_template_path('servdns.tpl', TRUE))); - } - - - /* Do we need to flip is_account state? - */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove DNS service"), - _("This server has DNS features enabled. You can disable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Add DNS service"), - _("This server has DNS features disabled. You can enable them by clicking below.")); - return ($display); - } - - - /* Edited or Added zone - */ - if(isset($_POST['SaveZoneChanges'])){ - $this->dialog->save_object(); - - /* Check for errors - */ - if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msgs){ - print_red($msgs); - } - }else{ - /* add new/edited zone - */ - $ret = $this->dialog->save(); - if(!$this->dialog->isNew){ - unset($this->Zones[$this->dialog->OldZoneName]); - } - $this->Zones[$ret['zoneName']] = $ret; - $this->dialog = FALSE; - } - } - - /* Cancel zone edit / new - */ - if(isset($_POST['CancelZoneChanges'])){ - $this->dialog = FALSE; - } - - /* Add empty new zone - */ - if(isset($_POST['AddZone'])){ - $this->dialog = new servdnseditZone($this->config,$this->dn); - } - - /* Check for edit zone request - */ - $once = false; - foreach( $_POST as $name => $value){ - - /* check all post for edit request - */ - if(preg_match("/^editZone_/",$name)&&!$once){ - $once =true; - $tmp = preg_replace("/^editZone_/","",$name); - $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); - $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$tmp]); - } - - /* check posts for delete zone - */ - if(preg_match("/^delZone_/",$name)&&!$once){ - - $once =true; - $tmp = preg_replace("/^delZone_/","",$name); - $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); - - /* Initiate deletion - */ - $this->RemoveZone($tmp); - } - } - - if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ - $id = base64_decode($_GET['id']); - if(isset($this->Zones[$id])){ - $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]); - } - } - - if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){ - $id = base64_decode($_GET['id']); - if(isset($this->Zones[$id])){ - $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]); - } - } - - /* Show dialog - */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $this->dialog->parent = $this; - return($this->dialog->execute()); - } - - /* Create Listbox with existing Zones - */ - $ZoneList = new divSelectBox("dNSZones"); - $ZoneList -> SetHeight(254); - - /* Add entries to divlist - */ - $editImg = ""; - if($this->acl_is_removeable()){ - $editImg.= ""; - } - - $link = "%s"; - foreach($this->Zones as $zone => $values ){ - $ZoneList->AddEntry(array( - array("string" => sprintf($link,base64_encode($zone),($zone))), - array("string" => sprintf($link,base64_encode($zone),_("Reverse zone")." : ".($values['ReverseZone']))), - array("string" => _("TTL")." : ".$values['sOAttl']), - array("string" => _("Class")." : ".$values['dNSClass']), - array("string" =>str_replace("%s",base64_encode($zone),$editImg)) - )); - } - - /* Display tempalte - */ - $smarty->assign("ZoneList",$ZoneList->DrawList()); - $display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE)); - return($display); - } - - - /* Delete specified zone - */ - function RemoveZone($id) - { - $zones = $this->getUsedZoneNames(); - - if(isset($this->Zones[$id]['InitialReverseZone'])){ - $rev = FlipIp($this->Zones[$id]['InitialReverseZone']); - }else{ - $rev = FlipIp($this->Zones[$id]['ReverseZone']); - } - - $zonename = ""; - if(isset($this->Zones[$id]['InitialzoneName'])){ - $zonename= $this->Zones[$id]['InitialzoneName']; - } - - $used = array(); - - /* Add Records which use this zoneName - */ - if(isset($zones[$zonename])){ - $used = array_merge($used,$zones[$zonename]); - } - - /* Add Records which uses this reverse zone - */ - if(isset($zones[$rev.".in-addr.arpa"])){ - $used = array_merge($used,$zones[$rev.".in-addr.arpa"]); - } - - /* There are still entries using this configuration - * Abort deletion - */ - if(count($used)){ - $i = 2; - $str =""; - foreach($used as $dn){ - if($i > 0 && !preg_match("/,relativeDomainName=/",$dn)){ - $i --; - $name = preg_replace("/^[^=]+=([^,]*),.*$/","\\1",$dn); - $zone = preg_replace("/^.*zoneName=([^,]*),.*$/","\\1",$dn); - $str.= $name.".".$zone." "; - } - } - - /* Only show 2 dns in the error message - */ - if(count($used)> 2) { - $str .=" ... "; - } - print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str))); - return(false); - }else{ - unset($this->Zones[$id]); - return(true); - } - } - - - /* This funtion returns all used Zonenames - */ - function getUsedZoneNames() - { - $ret = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=dNSZone)(!(relativeDomainName=@))(zoneName=*))",array("zoneName","relativeDomainName")); - while($attr = $ldap->fetch()){ - $ret[$attr['zoneName'][0]][] = $attr['dn']; - } - return($ret); - } - - - /* Remove dns service - */ - function remove_from_parent() - { - if($this->initially_was_account){ - $bool = true; - $this->is_account = FALSE; - foreach($this->Zones as $key => $zone){ - $bool= $bool & $this->RemoveZone($key); - } - - if($bool){ - $this->save(); - } - return($bool); - } - } - - - /* Save to LDAP */ - function save() - { - - /* Take over handling - * - Create list of zones managed by source server - * - Copy ldap entries to destination server - * - Remove old zone entries from source - */ - if($this->take_over_id != -1){ - $del = array(); - $id = $this->take_over_id; - $src = $this->dns_server_list['ENTRIES'][$id]['dn']; - $ldap = $this->config->get_ldap_link(); - $ldap->ls("(objectClass=dnsZone)",$src,array('cn')); - while($attrs = $ldap->fetch()){ - $src_zone = $attrs['dn']; - $dst_zone = preg_replace("/".normalizePreg($src)."$/",$this->dn,$src_zone); - $res = plugin::recursive_move($src_zone, $dst_zone); - - if($res){ - $del [] = $src_zone; - } - } - foreach($del as $src_zone){ - $ldap->rmdir_recursive($src_zone); - } - return; - } - - /* Save zone editor changes now */ - foreach($this->Zones as $name => $zone){ - if(isset($zone['zoneEditor'] ) && $zone['zoneEditor'] != NULL && is_object($zone['zoneEditor'])){ - $zone['zoneEditor']->save(); - unset($this->Zones[$name]['zoneEditor']);; - } - } - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* Get differences - */ - $old_dn = $this->orig_dn; - if($old_dn == "new"){ - $old_dn = $this->dn; - } - - $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); - - /* Update dns to current object dn */ - $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn); - $tmp2 = array(); - foreach($tmp as $key1 => $data1){ - $tmp2[$key1] = array(); - foreach($data1 as $key2 => $data2){ - $tmp2[$key1][preg_replace("/".normalizePreg($old_dn)."$/",$this->dn,$key2)] = $data2; - } - } - $tmp = $tmp2; - - /* Updated zone entries if reverser or forward name has changed - * Must be done before moving entries, else the given dn is invalid - */ - if(isset($tmp['zoneUpdates'])){ - foreach($tmp['zoneUpdates'] as $dn => $attrs){ - $ldap->cd($dn); - $ldap->modify($attrs); - new log("modfiy","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Updating of system server/dns with dn '%s' failed."),$this->dn)); - } - } - - /* Delete dns - */ - foreach($tmp['del'] as $dn => $del){ - - $for = $del['InitialzoneName']; - $rev = FlipIp($del['InitialReverseZone']).".in-addr.arpa"; - - $ldap->cd($dn); - $ldap->rmdir_recursive($dn); - new log("remove","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/dns with dn '%s' failed."),$this->dn)); - - /* Handle Post events */ - if(preg_match("/^zoneName=/",$dn)){ -# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $for)); -# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $rev)); - } - } - - /* move follwoing entries - */ - foreach($tmp['move'] as $src => $dst){ - $this->recursive_move($src,$dst); - } - - /* Add || Update new DNS entries - */ - foreach($tmp['add'] as $dn => $attrs){ - $ldap->cd($dn); - $ldap->cat($dn, array('dn')); - if($ldap->fetch()){ - $ldap->cd($dn); - $ldap->modify ($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); - - /* Handle Post events */ - if(preg_match("/^zoneName=/",$dn)){ -# $this->handle_post_events("modify",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); - } - }else{ - $ldap->cd($dn); - $ldap->add($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn)); - - /* Handle Post events */ - if(preg_match("/^zoneName=/",$dn)){ -# $this->handle_post_events("add",array("dn" => $dn,"zoneName" => $attrs['zoneName'])); - } - } - } - $this->handle_post_events("modify"); - } - - - /* Directly save new status flag */ - function setStatus($value) - { - if($value == "none") return; - if(!$this->initially_was_account) return; - if(empty($this->StatusFlag)) return; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - - $tmp = $ldap->fetch(); - for($i = 0; $i < $tmp['objectClass']['count']; $i ++){ - $attrs['objectClass'][] = $tmp['objectClass'][$i]; - } - $flag = $this->StatusFlag; - $attrs[$flag] = $value; - $this->$flag = $value; - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/dns with dn '%s' failed."),$this->dn)); - $this->action_hook(); - } - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("DNS service"); - $fields['AllowEdit'] = true; - return($fields); - } - - - /* Get updates for status flag */ - function updateStatusState() - { - if(empty($this->StatusFlag)) return; - - $attrs = array(); - $flag = $this->StatusFlag; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->cn); - $ldap->cat($this->dn,array($flag)); - if($ldap->count()){ - $attrs = $ldap->fetch(); - } - if(isset($attrs[$flag][0])){ - $this->$flag = $attrs[$flag][0]; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("DNS service"), - "plDescription" => _("DNS service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 83, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "zoneName" =>_("Zone name"), - "ReverseZone" =>_("Reverse zone"), - "sOAprimary" =>_("Primary dns server"), - "sOAmail" =>_("Mail address"), - "sOAserial" =>_("Serial"), - "sOArefresh" =>_("Refresh"), - "sOAretry" =>_("Retry"), - "sOAexpire" =>_("Expire"), - "sOAttl" =>_("TTL"), - "zoneRecords" =>_("Zone records")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dns/class_servDNSeditZone.inc b/plugins/admin/systems/services/dns/class_servDNSeditZone.inc deleted file mode 100644 index d5df0871d..000000000 --- a/plugins/admin/systems/services/dns/class_servDNSeditZone.inc +++ /dev/null @@ -1,603 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("zoneName","ReverseZone","dNSClass", - "sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl"); - var $objectclasses = array("whatever"); - - var $RecordTypes = array(); - - var $ReverseZone = ""; - var $zoneName = ""; - var $dNSClass = "IN"; - - var $sOAprimary = ""; - var $sOAmail = ""; - var $sOAserial = ""; - var $sOArefresh = "3600"; - var $sOAretry = "1800"; - var $sOAexpire = "720000"; - var $sOAttl = "6400"; - - var $Records = array(); - var $mXRecords = array(); - - var $OldZoneName = ""; // To detect changes made with this edit - var $OldReverseZone = ""; - - var $InitialReverseZone = ""; - var $InitialzoneName = ""; - var $NetworkClass = "A" ; // One out of A,B,C - - var $dialog = false; - - var $zoneEditor = NULL; - - var $isNew = true; - - var $ZoneObject = array(); - - function servdnseditZone (&$config, $dn= NULL,$attrs = array()) - { - plugin::plugin ($config, $dn); - - /* All types with required attrs */ - $this->RecordTypes = getDnsRecordTypes(true); - - if(!count($attrs)){ - $this->OldZoneName = ""; - $this->OldReverseZone = ""; - $this->isNew = true; - $this->sOAserial = date("Ymd")."1"; - - $this->InitialzoneName = "";//$attrs['InitialzoneName']; - $this->InitialReverseZone = "";//$attrs['InitialReverseZone']; - }else{ - $this->ZoneObject = $attrs; - - if(isset($attrs['zoneEditor'])){ - $this->zoneEditor = $attrs['zoneEditor']; - } - $this->OldZoneName = $attrs['zoneName']; - $this->OldReverseZone = $attrs['ReverseZone']; - - $this->InitialzoneName = $attrs['InitialzoneName']; - $this->InitialReverseZone = $attrs['InitialReverseZone']; - - $this->isNew = false; - - foreach($this->attributes as $value){ - $this->$value = $attrs[$value]; - } - - $this->sOAmail = preg_replace("/\./","@",$this->sOAmail,1); - $this->sOAmail = preg_replace("/\.$/","",$this->sOAmail); - $this->sOAprimary = preg_replace("/\.$/","",$this->sOAprimary); - $this->zoneName = preg_replace("/\.$/","",$this->zoneName); - - if(isset($attrs['RECORDS'])){ - $this->Records = $attrs['RECORDS']; - - $tmp2 = array(); - $usedPrio = array(); - foreach($this->Records as $key => $rec){ - if($rec['type'] == "mXRecord"){ - $tmp = split(" ",$rec['value']); - $rec['value'] = $tmp[1]; - $tmp2[$tmp[0]] = $rec; - unset($this->Records[$key]); - } - if($rec['type'] == "nSRecord"){ - unset($this->Records[$key]); - } - } - if(count($tmp2) != 0){ - reset($tmp2); - ksort($tmp2); - } - $this->mXRecords = $tmp2; - }else{ - $this->mXRecords = array(); - $this->Records = array(); - } - - $str = date("Ymd"); - if(preg_match("/^".$str."/",$this->sOAserial)){ - $this->sOAserial = $this->sOAserial + 1; - }else{ - $this->sOAserial = date("Ymd")."01"; - } - } - - /* Detect Network class */ - if(!empty($this->ReverseZone)){ - - $dots = count(split("\.",$this->ReverseZone)); - if($dots == 1){ - $this->NetworkClass = "A"; - $this->ReverseZone .= ".0.0.0"; - }elseif($dots == 2){ - $this->NetworkClass = "B"; - $this->ReverseZone .= ".0.0"; - }else{ - $this->NetworkClass = "C"; - $this->ReverseZone .= ".0"; - } - } - } - - /* TRansports the geiven Arraykey one position up*/ - function ArrayUp($atr,$attrs) - { - $ret = $attrs; - $pos = $atr ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == 1)||($pos >$cn))){ - $before = array_slice($attrs,0,($pos-2)); - $mitte = array_reverse(array_slice($attrs,($pos-2),2)); - $unten = array_slice($attrs,$pos); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - - /* TRansports the geiven Arraykey one position up*/ - function ArrayDown($atr,$attrs) - { - $ret = $attrs; - $pos = $atr ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == $cn))){ - $before = array_slice($attrs,0,($pos-1)); - $mitte = array_reverse(array_slice($attrs,($pos-1),2)); - $unten = array_slice($attrs,($pos+1)); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - /* Combine new array */ - function combineArrays($ar0,$ar1,$ar2) - { - $ret = array(); - if(is_array($ar0)) - foreach($ar0 as $ar => $a){ - $ret[]=$a; - } - if(is_array($ar1)) - foreach($ar1 as $ar => $a){ - $ret[]=$a; - } - if(is_array($ar2)) - foreach($ar2 as $ar => $a){ - $ret[]=$a; - } - return($ret); - } - - function getpos($atr,$attrs) - { - $i = 0; - foreach($attrs as $attr => $name) { - $i++; - if($attr == $atr){ - return($i); - } - } - return(-1); - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - - - /* Fill templating stuff */ - $smarty= get_smarty(); - $ui = get_userinfo(); - - $smarty->assign("ACLs",$this->parent->getacl("")); - $display= ""; - - /* Open Zone Entry Edit Dialog - */ - if(!count($this->ZoneObject)){ - $smarty->assign("AllowZoneEdit" , false); - }else{ - $smarty->assign("AllowZoneEdit" , true); - if(isset($_POST['EditZoneEntries'])){ - if($this->zoneEditor == NULL){ - $this->zoneEditor= new servDNSeditZoneEntries($this->config,$this->dn,$this->ZoneObject); - $this->zoneEditor->parent = $this; - } - $this->dialog = $this->zoneEditor; - } - } - - /* Save Zone Entry Edit Dialog - */ - if(isset($_POST['SaveZoneEntryChanges'])){ - $this->dialog->save_object(); - if(count($this->dialog->check())){ - $msgs = $this->dialog->check(); - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $this->zoneEditor = clone $this->dialog; - $this->dialog = FALSE; -# $rev = FlipIp(getNameFromMix($this->InitialReverseZone)).".in-addr.arpa"; -# $for = getNameFromMix($this->InitialzoneName); -# -# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $rev)); -# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $for)); -# $this->dialog = false; - } - } - - /* Cancel Zone Entrie Edit Dialog - */ - if(isset($_POST['CancelZoneEntryChanges'])){ - $this->dialog = false; - } - - /* Display any type of open dialogs - */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - $once =true; - foreach($_POST as $name => $value){ - if((preg_match("/^MXup_/",$name)) && ($once)){ - $once = false; - - $id = preg_replace("/^MXup_/","",$name); - $id = preg_replace("/_.*$/","",$id); - $id = base64_decode($id); - - $this->mXRecords = $this->ArrayUp(($id+1),$this->mXRecords); - } - if((preg_match("/^MXdown_/",$name)) && ($once)){ - $once = false; - - $id = preg_replace("/^MXdown_/","",$name); - $id = preg_replace("/_.*$/","",$id); - $id = base64_decode($id); - - $this->mXRecords = $this->ArrayDown(($id+1),$this->mXRecords); - } - if((preg_match("/^MXdel_/",$name)) && ($once)){ - $once = false; - - $id = preg_replace("/^MXdel_/","",$name); - $id = preg_replace("/_.*$/","",$id); - $id = base64_decode($id); - - unset($this->mXRecords[$id]); - - $tmp =array(); - foreach($this->mXRecords as $entry){ - $tmp[] = $entry; - } - - $this->mXRecords = $tmp; - } - } - - if((isset($_POST['AddMXRecord'])) && (!empty($_POST['StrMXRecord']))){ - $this->mXRecords[] = array("type"=>"mXRecord","value"=>trim($_POST['StrMXRecord'])); - } - - /* Handle Post events */ - $once = true; - foreach($_POST as $name => $value){ - - /* Delete record if requested */ - if((preg_match("/RemoveRecord_/",$name))&&($once)){ - $once = false; - $id= preg_replace("/RemoveRecord_/","",$name); - unset($this->Records[$id]); - } - } - - /* Add new Zonerecord */ - if(isset($_POST['AddNewRecord'])){ - $this->Records[] = array("type"=>"aRecord","value"=>""); - } - - /* Fill in values */ - foreach($this->attributes as $name){ - $smarty->assign($name,$this->$name); - } - - - $div = new divSelectBox("MxRecords"); - $div->setHeight(120); - $recs = $this->mXRecords; - - $oneup = " "; - $onedown = " "; - $onedel = " - "; - - foreach($recs as $key => $rec){ - $div ->AddEntry(array( - array("string"=>$rec['value']), -/* array("string"=>$key, - "attach"=>"style='width:20px;'"),*/ - array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel), - "attach"=>"style='width:70px;border-right:0px;'") - )); - } - - /* Assign records list */ - $smarty->assign("NotNew", false); - $smarty->assign("Mxrecords", $div->DrawList()); - $smarty->assign("records" , $this->generateRecordsList()); - $smarty->assign("NetworkClass", $this->NetworkClass); - $smarty->assign("NetworkClasses", array("A"=>"255.0.0.0 (Class A)","B"=>"255.255.0.0 (Class B)","C"=>"255.255.255.0 (Class C)")); - - /* Display tempalte */ - $display.= $smarty->fetch(get_template_path('servdnseditzone.tpl', TRUE)); - return($display); - } - - function remove_from_parent() - { - } - - /* Save data to object */ - function save_object() - { - //plugin::save_object(); - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - - foreach($this->Records as $id => $value){ - if(isset($_POST['RecordTypeSelectedFor_'.$id])){ - $this->Records[$id]['type'] = $_POST['RecordTypeSelectedFor_'.$id]; - } - if(isset($_POST['RecordValue_'.$id])){ - $this->Records[$id]['value'] = $_POST['RecordValue_'.$id]; - } - } - - if(isset($_POST['NetworkClass'])){ - $this->NetworkClass = $_POST['NetworkClass']; - } - - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Check if zoneName is already in use */ - $usedZones = $this->getUsedZoneNames(); - if(($this->isNew == true)||($this->zoneName != $this->InitialzoneName)||($this->ReverseZone != $this->InitialReverseZone)){ - /* if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){ - $message[] =_("This zoneName is already in use"); - } - if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitialReverseZone)){ - $message[] =_("This reverse zone is already in use"); - }*/ - } - - if(empty($this->zoneName)){ - $message[] =sprintf(_("Please choose a valid zone name.")); - } - - if(empty($this->ReverseZone)){ - $message[] =sprintf(_("Please choose a valid reverse zone name.")); - } - - if($this->zoneName != strtolower($this->zoneName)){ - $message[] = _("Only lowercase strings are allowed as zone name."); - } - - if(!is_numeric($this->sOAserial)){ - $message[] = _("Please specify a numeric value for serial number."); - } - - if(!is_numeric($this->sOArefresh)){ - $message[] = _("Please specify a numeric value for refresh."); - } - - if(!is_numeric($this->sOAttl)){ - $message[] = _("Please specify a numeric value for ttl."); - } - - if(!is_numeric($this->sOAexpire)){ - $message[] = _("Please specify a numeric value for expire."); - } - - if(!is_numeric($this->sOAretry)){ - $message[] = _("Please specify a numeric value for retry."); - } - - foreach($this->Records as $name => $values){ - /* only lower-case is allowed in record entries ... */ - if($values['value'] != strtolower($values['value'])){ - $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']); - } - } - - /* Check class for given Zone Address */ - $addr = preg_replace("/^[^\/]*+\//","",$this->ReverseZone); - - /* Check for valid&complete IP address */ - if(!is_ip($addr)){ - $message[] = _("The given network address is not a valid, please specify a valid IP address."); - } - - /* Check if given address matches selected network class */ - switch($this->NetworkClass){ - case 'A': { - if(!preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){ - $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.0.0.0")); - } - } - break; - case 'B': { - if(!preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){ - $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.0.0")); - } - } - break; - case 'C': { - if(!preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){ - $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.x.0")); - } - } - break; - default : $message[] =sprintf(_("The given network class '%s' is not valid."),$this->NetworkClass); - } - - return ($message); - } - - /* This funtion returns all used Zonenames */ - function getUsedZoneNames() - { - $ret = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(zoneName=*))",array("zoneName","tXTRecord")); - while($attr = $ldap->fetch()){ - if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){ - if(isset($attr['tXTRecord'][0])){ - $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]); - $ret[$zn] =FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0])); - } - }else{ - $ret[$attr['zoneName'][0]]=""; - } - } - return($ret); - } - - /* Save to LDAP */ - function save() - { - $ret =array(); - foreach($this->attributes as $name){ - $ret[$name] = $this->$name; - } - - /* Create mx records - */ - foreach($this->mXRecords as $key => $rec){ - $rec['value']= $key." ".$rec['value']; - $this->Records [] = $rec; - } - - - $ret['RECORDS'] = $this->Records; - - switch($this->NetworkClass){ - case 'C' : $ret['ReverseZone']= preg_replace("/\.[0-9]*$/","",$this->ReverseZone);break; - case 'B' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break; - case 'A' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break; - default : trigger_error("Invalid network class given '".$this->NetworkClass."'"); - } - - $ret['InitialReverseZone']= $this->InitialReverseZone; - $ret['InitialzoneName'] = $this->InitialzoneName; - - $ret['sOAmail'] = preg_replace("/\@/",".",$this->sOAmail); - - foreach(array("sOAprimary","zoneName","sOAmail") as $attr){ - if(!preg_match("/\.$/",$ret[$attr])){ - if(!is_ip($ret[$attr])){ - $ret[$attr] = $ret[$attr]."."; - } - } - } - - $ret['RECORDS'][] = array("type" => "nSRecord","value" => $ret['sOAprimary']) ; - - $ret['zoneEditor'] = $this->zoneEditor; - return($ret); - } - - - /* This function generate a table row for each used record. - This table row displays the recordtype in a select box - and the specified value for the record, and a remove button. - The last element of the table also got an 'add' button. - */ - function generateRecordsList($changeStateForRecords="") - { - $changeStateForRecords = ""; - - $str = ""; - foreach($this->Records as $key => $entry){ - - if($entry['type'] == "mXRecord") continue; - - $changeStateForRecords.= "changeState('RecordTypeSelectedFor_".$key."');\n"; - $changeStateForRecords.= "changeState('RecordValue_".$key."');\n"; - $changeStateForRecords.= "changeState('RemoveRecord_".$key."');\n"; - - $str.=" ". - " ". - " ". - " ". - ""; - } - - $str.= " ". - " ". - " ". - "
".$this->generateRecordListBox($entry['type'],"RecordTypeSelectedFor_".$key)."
". - " ". - "
"; - return($str); - } - - /* This function generates a select box out of $this->RecordTypes options. - The Parameter $selected is used to predefine an attribute. - $name is used to specify a post name - */ - function generateRecordListBox($selected,$name) - { - $str = ""; - return($str); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc deleted file mode 100644 index 8453ae794..000000000 --- a/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc +++ /dev/null @@ -1,498 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array("whatever"); - - var $Devices = array(); - - var $zoneName = ""; // ZoneName of currently edited Zone - var $reverseName = ""; // ReverseZone of the currently edited Zone - - var $RecordTypes = array(); // Possible record type. - - var $disableDialog = false; // Dialog will be disabled, if this zone is new - - function servDNSeditZoneEntries (&$config,$dn, &$zoneObject) - { - plugin::plugin ($config, $dn); - - /* Initialise class - */ - $this->RecordTypes = getDnsRecordTypes(); - $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn; - $this->zoneName = $zoneObject['InitialzoneName']; - $this->reverseName = $zoneObject['InitialReverseZone']; - - /* Remove nSRecord from listed types */ - if(isset($this->RecordTypes['nSRecord'])){ - unset($this->RecordTypes['nSRecord']); - } - /* Remove nSRecord from listed types */ - if(isset($this->RecordTypes['pTRRecord'])){ - unset($this->RecordTypes['pTRRecord']); - } - - /* Get ldap connection - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - /* Get zone content - */ - $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName")); - - while($attrs = $ldap->fetch()){ - $this->Devices[$attrs['relativeDomainName'][0]] = getDNSHostEntries($config,$attrs['relativeDomainName'][0],true); - $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0]; - } - - $ldap->cat($this->dn,array("objectClass")); - - $this->disableDialog = true; - if(count($this->Devices)|| $ldap->count()){ - $this->disableDialog = false; - } - } - - function execute() - { - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - $table = ""; - foreach($this->Devices as $key => $dev){ - $table .= $this->generateRecordConfigurationRow($key); - } - - $smarty->assign("disableDialog",$this->disableDialog); - $smarty->assign("table",$table);; - $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE)); - return($display); - } - - - function save_object() - { - /* Check posts for operations ... - */ - $once = true; - $ptr_updates = array(); - foreach($_POST as $name => $value){ - - /* Add a new Record in given object - */ - - $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name); - $tmp2 = split("\|",$tmp); - - /* Add new host entry - */ - if((preg_match("/^UserRecord_?/",$name)) && ($once)){ - $once = false; - $entry = getDNSHostEntries($this->config,"",true); - $entry['exists'] = true; - $entry['zoneName'] = strtoupper($this->attrs['cn'][0])."/".$this->zoneName; - $entry['RECORDS'][] = array("type" => "aRecord" , "value"=>""); - $this->Devices[_("New entry")] = $entry; - } - - if(count($tmp2) != 2) continue; - - $Name = base64_decode($tmp2[0]); - $RecordID = $tmp2[1]; - - /* Add new REcord - */ - if((preg_match("/^AddRecord_/",$name)) && ($once)){ - $once = false; - $this->Devices[$Name]['RECORDS'][] = $this->Devices[$Name]['RECORDS'][$RecordID]; - } - - /* Remove record from given dn - */ - if((preg_match("/^RemoveRecord_/",$name)) && ($once)){ - $once = false; - if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ - unset($this->Devices[$Name]['RECORDS'][$RecordID]); - } - - /* Check if there is at least one visible record. Else remove complete entry */ - $visible = false; - foreach($this->Devices[$Name]['RECORDS'] as $rec){ - if(in_array($rec['type'],$this->RecordTypes)){ - $visible = true; - break; - } - } - if(!$visible && isset($this->Devices[$Name]['RECORDS'])){ - $this->Devices[$Name]['RECORDS'] = array(); - } - } - } - - /* Possible attributes posted - */ - foreach($_POST as $name => $value){ - - /* Extract informations out of post name - */ - $tmp = preg_replace("/^.*_/","\\1",$name); - $tmp2 = split("\|",$tmp); - - if(count($tmp2) != 2) continue; - - $Name = base64_decode($tmp2[0]); - $RecordID = $tmp2[1]; - - /* Check for value change - */ - if(preg_match("/ValueSelection_/",$name)){ - if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ - - /* Update value */ - $old = $this->Devices[$Name]['RECORDS'][$RecordID]['value']; - $this->Devices[$Name]['RECORDS'][$RecordID]['value'] = $value; - - /* Handle pTRRecord */ - if(!isset($ptr_updates[$Name]) && $this->Devices[$Name]['RECORDS'][$RecordID]['type'] == "aRecord"){ - - $found = false; - $ip = $value; - $match = preg_replace("/^[^\/]*+\//","",$this->reverseName); - $ip = preg_replace("/^".normalizePreg($match)."/","",$ip); - $ip = preg_replace("/^\./","",$ip); - - foreach($this->Devices[$Name]['RECORDS'] as $key => $dev){ - if($dev['type'] == "pTRRecord"){ - $ptr_updates[$Name] = $Name; - $this->Devices[$Name]['RECORDS'][$key]['value'] = $ip; - $found = true; - break; - } - } - if(!$found){ - $dev = array('type'=> 'pTRRecord', 'value' => $ip); - $this->Devices[$Name]['RECORDS'][] = $dev; - } - } - } - } - - /* record type changed - */ - if(preg_match("/^RecordTypeSelection_/",$name)){ - if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){ - $this->Devices[$Name]['RECORDS'][$RecordID]['type'] = $value; - } - } - } - - /* check for renamed entries - */ - foreach($_POST as $name => $value){ - - /* Extract informations out of post name - */ - $tmp = preg_replace("/^.*_/","\\1",$name); - $tmp2 = split("\|",$tmp); - - if(count($tmp2) != 2) continue; - - $Name = base64_decode($tmp2[0]); - $RecordID = $tmp2[1]; - - /* Host renamed - */ - if(preg_match("/RenameHost_/",$name)){ - if((isset($this->Devices[$Name])) && ($Name != $value)){ - - if(isset($this->Devices[$value])){ - print_red(sprintf(_("Can't rename '%s' to '%s' there is already an entry with the same name in our zone editing dialog."),$Name,$value)); - }else{ - $this->Devices[$value] = $this->Devices[$Name]; - unset($this->Devices[$Name]); - } - } - } - } - } - - - /* check something - */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - - $names = array(); - foreach($this->Devices as $DevName => $device){ - - /* Don't need to check empty values ... */ - if(!count($device['RECORDS'])) continue; - - /* Checking entry name - */ - if(!preg_match("/^[a-z0-9_\.-]+$/i", $DevName) || (empty($DevName))){ - $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $DevName); - } - - /* Renaming check for existing devices - */ - if(isset($device['OrigCn']) && ($DevName != $device['OrigCn'] )){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); - if($ldap->count()){ - $message[] = sprintf(_("Can not rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$DevName); - } - }elseif(!isset($device['OrigCn'])){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName")); - if($ldap->count()){ - $message[] = sprintf(_("Can not create '%s',the destination name already exists."),$DevName); - } - } - - /* Check names - */ - if(!isset($names[$DevName])){ - $names[$DevName] = ""; - }else{ - $message[] = sprintf(_("The name '%s' is used more than once."),$DevName); - } - - /* Names should be written in lowercase - */ -# if(strtolower($DevName) != $DevName){ -# $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $DevName); -# } - - /* Check records - */ - $singleEntries = array("cNAMERecord","pTRRecord"); - - $tmp = array(); - $tmp2 = array(); - foreach($device['RECORDS'] as $Num => $Rec){ - - /* Check for multiple use of unique record types - */ - if(in_array($Rec['type'],$singleEntries)){ - if(!isset($tmp[$Rec['type']])){ - $tmp[$Rec['type']] = ""; - }else{ - $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$Rec['type']); - } - } - - /* Check for empty / duplicate entries in record array - */ - if(empty($Rec['value'])){ - $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$Rec['type'],$DevName); - } - - /* Check for duplicate record entries - */ - if(!isset($tmp[$Rec['type']][$Rec['value']])){ - $tmp[$Rec['type']][$Rec['value']] = ""; - }else{ - $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$Rec['type'],$DevName); - } - } - } - return ($message); - } - - function save() - { - if($this->disableDialog) return; - - $todo = array(); - - - - /* Create todolist - */ - foreach($this->Devices as $name => $dev){ - if(isset($dev['OrigCn'])){ - if(count($dev['RECORDS'])){ - $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); - }else{ - $dev['exists'] = false; - $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name); - } - }else{ - if(count($dev['RECORDS'])){ - $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name); - }else{ - $dev['exists'] = false; - $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name); - } - } - } - - $tmp = array(); - $tmp['del'] = array(); - $tmp['add'] = array(); - $tmp['move'] = array(); - foreach($todo as $to){ - foreach($to as $type => $entries){ - $tmp[$type] = array_merge($tmp[$type],$entries); - } - } - - /* Get ldap link - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - - /* move follwoing entries - */ - foreach($tmp['move'] as $src => $dst){ - $this->recursive_move($src,$dst); - } - - /* Delete dns */ - foreach($tmp['del'] as $dn => $del){ - $ldap->cd($dn); - $ldap->rmdir_recursive($dn); - if(is_object($this->parent->parent)){ - $this->parent->parent->handle_post_events("remove",array("dn" => $dn)); - } - } - - /* Add || Update new DNS entries - */ - foreach($tmp['add'] as $dn => $attrs){ - $ldap->cd($dn); - $ldap->cat($dn, array('dn')); - if(count($ldap->fetch())){ - $ldap->cd($dn); - $ldap->modify ($attrs); - if(is_object($this->parent->parent)){ - $this->parent->parent->handle_post_events("modify",array("dn" => $dn)); - } - }else{ - $ldap->cd($dn); - $ldap->add($attrs); - if(is_object($this->parent->parent)){ - $this->parent->parent->handle_post_events("create",array("dn" => $dn)); - } - } - } - } - - - /* Create html table out of given entry - */ - function generateRecordConfigurationRow($objKey){ - - /* Get some basic informations - */ - $obj = $this->Devices[$objKey]; - $objectName = $objKey; - - /* Abort if emtpy - */ - if(count($obj['RECORDS']) == 0) return ""; - - /* Set title - */ - $str= "
"; - - $hostNameOnce = true; - - /* Walk through all defined records - */ - $str.= ""; - foreach($obj['RECORDS'] as $id => $record){ - - /* Skip not selectable entries */ - if(!isset($this->RecordTypes [$record['type']])) { - continue; - } - - /* Create unique post name - */ - $name = base64_encode($objKey)."|".$id; - - $str .= " - - - - "; - } - $str .="
\n"; - - /* Only first host entry name should be editable - */ - if($hostNameOnce){ - $hostNameOnce = false; - $str .="\n"; - } - - /* Create rest. Selectbox, icons ... - */ - $str .=" - - ".$this->createRecordTypeSelection($record['type'],$name)." - - - - - - "; - -# if($record['type'] == "aRecord"){ -# $str .=""; -# }else{ -# $str .= ""; -# } - - $str.= - "
"; - return($str); - } - - - /* Create selectbox with all available option types - */ - function createRecordTypeSelection($id,$refID){ - - $str = "\n"; - return($str); - } - - - function remove_from_parent() - { - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dns/class_termDNS.inc b/plugins/admin/systems/services/dns/class_termDNS.inc deleted file mode 100644 index 025933291..000000000 --- a/plugins/admin/systems/services/dns/class_termDNS.inc +++ /dev/null @@ -1,1012 +0,0 @@ -parent = $parent; - $this->objectclasses = $objectClasses; - $this->IPisMust = $IPisMust; - - plugin::plugin ($config, $parent->dn); - - if(isset($this->attrs['cn'][0])){ - $this->OrigCn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]); - $this->cn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]); - } - - - /************ - * DHCP - ************/ - - /* Hide all dhcp specific code, if dhcp plugin is not present in config */ - $dhcpEnabled = FALSE; - if($this->config->search("servdhcp","class",array("tabs"))){ - $this->dhcpEnabled = TRUE; - } - if($this->dhcpEnabled){ - $this->dhcpParentNodes = $this->get_dhcp_parent_nodes(); - $this->dhcpParentNode = $this->get_dhcp_parent_node(); - if($this->dhcpParentNode){ - $this->dhcp_is_Account = TRUE; - $this->initial_dhcp_is_Account = TRUE; - $this->dhcpHostEntry = $this->get_dhcp_host_entry(); - } - $this->initial_dhcpHostEntry = $this->dhcpHostEntry; - $this->initial_dhcpParentNode= $this->dhcpParentNode; - } - - - /************ - * Autonetwork hook - ************/ - - /* Do we have autonet support? */ - if (isset($this->config->data['MAIN']['AUTO_NETWORK_HOOK'])){ - $this->autonet= true; - } - - - /************ - * DNS - ************/ - - /* Hide all dns specific code, if dns is not available - */ - $DNSenabled = false; - foreach($this->config->data['TABS']['SERVERSERVICE'] as $tab){ - if(preg_match("/^servdns$/",$tab['CLASS'])){ - $this->DNSenabled = true; - } - } - if(!$this->DNSenabled){ - $this->DNS_is_account = false; - return; - } - - if($this->DNSenabled){ - - /* Get Zones - */ - $this->Zones = getAvailableZones($config); - - /* Get Entry - */ - $this->dnsEntry = getDNSHostEntries($config,$this->OrigCn); - - /* Remove A record which equals $this->ipHostNumber - */ - $ptr = $this->get_pTRRecord(); - foreach($this->dnsEntry['RECORDS'] as $key => $rec){ - if(($rec['type'] == "aRecord") && ($rec['value'] == $this->ipHostNumber)){ - unset($this->dnsEntry['RECORDS'][$key]); - } - if(($rec['type'] == "pTRRecord") && ($rec['value'] == $ptr)){ - unset($this->dnsEntry['RECORDS'][$key]); - } - } - - /* Get Record types - */ - $this->RecordTypes = getDnsRecordTypes(); - - /* If there is at least one entry in this -> types, we have DNS enabled - */ - if($this->dnsEntry['exists']){ - $this->DNS_is_account = true; - }else{ - $this->DNS_is_account = false; - } - } - - /* Create a list of used mac and ip addresses */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(|(macAddress=*)(ipHostNumber=*))",array("macAddress","ipHostNumber")); - while($attrs = $ldap->fetch()){ - if(isset($attrs['ipHostNumber'][0])){ - $this->used_ip_mac["ip:".$attrs['ipHostNumber'][0]] = "ip:".$attrs['ipHostNumber'][0]; - } - if(isset($attrs['macAddress'][0])){ - $this->used_ip_mac["mac:".$attrs['macAddress'][0]] = "mac:".$attrs['macAddress'][0]; - } - } - - /* Save initial ip and mac values, to be able - check if the used values are already in use */ - $this->orig_ipHostNumber = $this->ipHostNumber; - $this->orig_macAddress = $this->macAddress; - - /* Store initally account settings - */ - $this->initially_was_account = $this->DNS_is_account; - - if($this->DNS_is_account){ - new log("view","unknown/".get_class($this),$this->dn); - } - } - - - function netmaskIsCoherent($idZone) - { - $netmask = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($idZone))); - if(!strstr($this->ipHostNumber, $netmask)){ - return false; - }else{ - return true; - } - } - - - function getVarsForSaving($attrs) - { - foreach($this->attributes as $attr){ - if(!empty($this->$attr)){ - $attrs[$attr] = $this->$attr; - } - } - return($attrs); - } - - function execute() - { - /* Call parent execute */ - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $display= ""; - - $smarty->assign("staticAddress", ""); - $smarty->assign("autonet", $this->autonet); - - /* Check for autonet button */ - if ($this->autonet && isset($_POST['autonet'])){ - $cmd= $this->config->data['MAIN']['AUTO_NETWORK_HOOK']; - if(!empty($cmd) && $this->cn != ""){ - $res = shell_exec($cmd." ".$this->cn); - if(!$res){ - print_red(sprintf(_("Can't execute specified AUTO_NETWORK_HOOK '%s'. Please check your gosa.conf."),$cmd)); - } else { - $res= split(';', trim($res)); - if (isset($res[0]) && $res[0] != ""){ - $this->ipHostNumber= $res[0]; - } - if (isset($res[1]) && $res[1] != ""){ - $this->macAddress= $res[1]; - } - } - } - } - - - /********** - * DHCP Handling - **********/ - - if(isset($_POST['dhcpEditOptions'])){ - - if(count($this->dhcpHostEntry) == 0){ - $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE); - }else{ - $this->dialog = new dhcpHost($this->dhcpHostEntry,TRUE); - } - $this->dialog->cn = $this->cn; - $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress; - if(!empty($this->ipHostNumber)){ - $this->dialog->statements['fixed-address'] = $this->ipHostNumber; - } - } - - if(isset($_POST['cancel_dhcp'])){ - $this->dialog = FALSE; - } - - if(isset($_POST['save_dhcp'])){ - $this->dialog->save_object(); - - $msgs = $this->dialog->check(array()); - if(count($msgs)){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $this->dhcpHostEntry = $this->dialog->save(); - $this->dialog = FALSE; - } - } - - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - $smarty->assign("dhcpEnabled", $this->dhcpEnabled); - $smarty->assign("dhcp_is_Account",$this->dhcp_is_Account); - $smarty->assign("dhcpParentNode", $this->dhcpParentNode); - $smarty->assign("dhcpParentNodes",$this->dhcpParentNodes); - $smarty->assign("dhcpParentNodeCnt",count($this->dhcpParentNodes)); - - - /********** - * DNS Handling - **********/ - - /* There is no dns available - */ - if($this->DNSenabled == false){ - - /* Is IP address must ? */ - $smarty->assign("DNS_is_account",false); - $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account))); - - /* Assign smarty all non DNs attributes */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - $smarty->assign("staticAddress","*"); - - $display.= $smarty->fetch(get_template_path('network.tpl', TRUE)); - }else{ - $smarty->assign("DNS_is_account",true); - - /* Add new empty array to our record list */ - if(isset($_POST['AddNewRecord'])){ - $this->dnsEntry['RECORDS'][] =array("type"=>"aRecord","value"=>""); - } - - /* propose_ip */ - if(isset($_POST['propose_ip'])){ - foreach($this->Zones as $key => $name){ - if($name == $this->dnsEntry['zoneName']){ - $net = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($key))); - $this->ipHostNumber = $this->generateRandomIp($net); - } - } - } - - /* Handle all posts */ - $only_once =true; - foreach($_POST as $name => $value){ - - /* Check if we have to delete a record entry */ - if((preg_match("/RemoveRecord_/",$name))&&($only_once)) { - - /* Avoid performing this once again */ - $only_once = false; - - /* Extract id for specified entry */ - $id = preg_replace("/RemoveRecord_/","",$name); - $id = preg_replace("/_.*$/","",$id); - - /* Delete this record, mark edited entries to be able to delete them */ - if(isset($this->dnsEntry['RECORDS'][$id])){ - unset($this->dnsEntry['RECORDS'][$id]); - } - } - } - /* Assign smarty all non DNs attributes */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign smarty all DNS attributes */ - foreach($this->DNSattributes as $attr){ - $smarty->assign($attr,$this->dnsEntry[$attr]); - } - - /* Assign all needed vars */ - $smarty->assign("DNSAccount",$this->DNS_is_account); - $smarty->assign("hide_dns_check_box",$this->hide_dns_check_box); - - $smarty->assign("Zones",$this->Zones); - $smarty->assign("ZoneCnt",count($this->Zones)); - $smarty->assign("ZoneKeys",($this->Zones)); - $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account))); - - /* Create zone array */ - $idZones = array(); - foreach($this->Zones as $id => $zone){ - if($this->netmaskIsCoherent($id)) { - $idZones[$id] = $zone; - }else{ - $idZones[$id] = $zone." ("._("Not matching").")"; - } - } - $smarty->assign("Zones",$idZones); - $smarty->assign("ZoneKeys", $this->Zones); - - $tmp = $this->generateRecordsList(); - - $changeStateForRecords = $tmp['changeStateForRecords']; - - $smarty->assign("records",$tmp['str']); - $smarty->assign("changeStateForRecords",$changeStateForRecords); - $smarty->assign("staticAddress","*"); - - $display.= $smarty->fetch(get_template_path('network.tpl', TRUE)); - } - return($display); - } - - - function remove_from_parent() - { - if($this->initially_was_account){ - - $ldap = $this->config->get_ldap_link(); - - $tmp = array(); - $this->dnsEntry['exists'] = false; - $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn); - - /* Delete dns */ - foreach($tmp['del'] as $dn => $del){ - $ldap->cd($dn); - $ldap->rmdir_recursive($dn); - new log("remove","unknown/".get_class($this),$dn); - } - } - } - - - /* Save data to object */ - function save_object() - { - - if(isset($_POST['network_tpl_posted'])){ - - /* Save all posted vars */ - plugin::save_object(); - - /* Handle DHCP Posts*/ - if($this->dhcpEnabled && isset($_POST['network_tpl_posted'])){ - foreach($this->dhcpAttributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - if(isset($_POST['dhcp_is_Account'])){ - $this->dhcp_is_Account = TRUE; - }else{ - $this->dhcp_is_Account = FALSE; - } - } - - /* Ge all non dns attributes (IP/MAC)*/ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){ - $this->$attr = $_POST[$attr]; - } - } - - /* Check if DNS should be enabled / disabled */ - if($this->DNS_is_account && $this->acl_is_removeable() && !isset($_POST['DNS_is_account'])){ - $this->DNS_is_account = false; - }elseif(!$this->DNS_is_account && $this->acl_is_createable() && isset($_POST['DNS_is_account'])){ - $this->DNS_is_account = true; - } - - /* Get dns attributes */ - if(($this->DNSenabled) && (isset($_POST['network_tpl_posted']))){ - - /* Check for posted record changes */ - if(is_array($this->dnsEntry['RECORDS']) && $this->acl_is_writeable("Records")){ - foreach($this->dnsEntry['RECORDS'] as $key => $value){ - - /* Check if type has changed */ - if(isset($_POST['RecordTypeSelectedFor_'.$key])){ - $this->dnsEntry['RECORDS'][$key]['type'] = $_POST['RecordTypeSelectedFor_'.$key]; - } - /* Check if value has changed */ - if(isset($_POST['RecordValue_'.$key])){ - $this->dnsEntry['RECORDS'][$key]['value'] = $_POST['RecordValue_'.$key]; - } - } - } - /* Get all basic DNS attributes (TTL, Clas ..)*/ - foreach($this->DNSattributes as $attr){ - if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){ - $this->dnsEntry[$attr] = $_POST[$attr]; - } - } - - - } - if($this->hide_dns_check_box){ - $this->DNS_is_account = true; - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if($this->dhcpEnabled && $this->dhcp_is_Account && $this->dhcpParentNode != "" && count($this->dhcpHostEntry) == 0){ -# $message[] =_("You have not configured your dhcp settings yet."); - } - - /* Check if mac and ip are already used */ - if(!empty($this->ipHostNumber) && $this->DNS_is_account && - $this->ipHostNumber != $this->orig_ipHostNumber && - in_array("ip:".$this->ipHostNumber,$this->used_ip_mac)){ - $message[] =_("The specified IP address is already in use."); - } - if(!empty($this->macAddress) && $this->dhcp_is_Account && - $this->macAddress != $this->orig_macAddress && - in_array("mac:".$this->macAddress,$this->used_ip_mac)){ - print_red(sprintf(_("The specified MAC address '%s' for this system '%s' is already in use."),$this->macAddress,$this->cn)); - } - - /* Check if ip must be given - */ - if(($this->IPisMust)||($this->DNS_is_account)){ - if (empty($this->ipHostNumber)){ - $message[]= _("The required field 'IP-address' is not set."); - } - - if (!is_ip($this->ipHostNumber)){ - $message[]= _("Wrong IP format in field IP-address."); - } - } - - /* Check if mac is empty - */ - if ($this->macAddress == "" ){ - $message[]= _("The required field 'MAC-address' is not set."); - } - if(!is_mac($this->macAddress)){ - $message[]=(_("The given macaddress is invalid. There must be 6 2byte segments seperated by ':'.")); - } - - /* only perfrom this checks if this is a valid DNS account */ - if($this->DNS_is_account){ - - $checkArray = array(); - $onlyOnce = array(); - - // $onlyOnce['cNAMERecord'] = 0; - $tmp = array_flip($this->Zones); - $tmp2 = $tmp[$this->dnsEntry['zoneName']]; - if(!$this->netmaskIsCoherent($tmp2)){ //this->dnsEntry['zoneName'])){ - $tmp2 = preg_replace("/^.*\//","",$tmp2); - $message[] =sprintf(_("The specified IP address '%s' is not matching the selected reverse zone entry '%s'."),$this->ipHostNumber,$tmp2); - } - - /* Walk through all entries and detect duplicates or mismatches - */ - foreach($this->dnsEntry['RECORDS'] as $name => $values){ - - /* Count record values, to detect duplicate entries for a specific record - */ - if(!isset($checkArray[$values['type']][$values['value']])){ - $checkArray[$values['type']][$values['value']] = 0; - }else{ - $message[] = sprintf(_("Found duplicate value for record type '%s'."),$values['type']); - } - - /* Check if given entries in $onlyOnce are used more than once - */ - if(isset($onlyOnce[$values['type']])){ - $onlyOnce[$values['type']] ++; - if($onlyOnce[$values['type']] > 1){ - $message[] = sprintf(_("Found more than one entry for the uniqe record type '%s'."),$values['type']); - } - } - - /* Skip txt record ... - */ - if($values['type'] == "tXTRecord") continue; - - /* Check if there is an aRecord defined which uses the same IP as used in IPhostAddress - */ - if(($values['type'] == "aRecord")&&($values['value'] == $this->ipHostNumber)){ - $message[]=sprintf(_("The device IP '%s' is added as 'A Record', this will be done automatically, please remove the record."), - $this->ipHostNumber); - } - - /* only lower-case is allowed in record entries ... - */ - if($values['value'] != strtolower($values['value'])){ - $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']); - } - } - } - return ($message); - } - - - /* Save to LDAP */ - function save() - { - $ldap= $this->config->get_ldap_link(); - - $dn = $this->parent->dn; - - /*******************/ - /* IP-MAC HANDLING */ - /*******************/ - - /* $dn was posted as parameter */ - $this->dn = $dn; - - /* Save DNS setting & ip/Mac*/ - plugin::save(); - - /* Write back to ldap */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /****************/ - /* DHCP HANDLING */ - /****************/ - - /* New entry */ - if($this->dhcpEnabled){ - - if(count($this->dhcpHostEntry) == 0){ - $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE); - $this->dialog->cn = $this->cn; - $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress; - if(!empty($this->ipHostNumber)){ - $this->dialog->statements['fixed-address'] = $this->ipHostNumber; - } - $this->dialog->execute(); - $this->dialog->save_object(); - $this->dhcpHostEntry = $this->dialog->save(); - if(count($this->dhcpHostEntry['dhcpOption']) == 0){ - $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn); - } - } - - if(count($this->dhcpHostEntry) == 0){ - $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE); - $this->dialog->cn = $this->cn; - $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress; - if(!empty($this->ipHostNumber)){ - $this->dialog->statements['fixed-address'] = $this->ipHostNumber; - } - $this->dialog->execute(); - $this->dialog->save_object(); - $this->dhcpHostEntry = $this->dialog->save(); - if(count($this->dhcpHostEntry['dhcpOption']) == 0){ - $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn); - } - } - - /* Write mac address to dhcp settings */ - if($this->dhcp_is_Account){ - if(!isset($this->dhcpHostEntry['dhcpHWAddress'][0]) || - !preg_match("/ethernet ".$this->macAddress."/",$this->dhcpHostEntry['dhcpHWAddress'][0])){ - $this->dhcpHostEntry['dhcpHWAddress'] = array("ethernet ".$this->macAddress); - $this->dhcpHostEntry['MODIFIED'] = TRUE; - } - } - - - /* Unset dhcpStatements if this attribute is empty */ - if(isset($this->dhcpHostEntry['dhcpStatements']) && - ($this->dhcpHostEntry['dhcpStatements'] == "" || count($this->dhcpHostEntry['dhcpStatements']) == 0) ){ - unset($this->dhcpHostEntry['dhcpStatements']); - } - - /* DHCP removed */ - if($this->initial_dhcp_is_Account && !$this->dhcp_is_Account){ - $ldap->rmdir_recursive($this->dhcpHostEntry['dn']); - show_ldap_error($ldap->get_error(),_("Removing dhcp entry for this object failed.")); - - $tmp = new servdhcp($this->config,$this->dhcpParentNode); - $tmp->handle_post_events("remove"); - } - - /* DHCP Added */ - if(!$this->initial_dhcp_is_Account && $this->dhcp_is_Account){ - $attrs = $this->dhcpHostEntry; - unset($attrs['MODIFIED']); - unset($attrs['dn']); - $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode); - $res = $ldap->add($attrs); - - $tmp = new servdhcp($this->config,$this->dhcpParentNode); - $tmp->handle_post_events("add"); - - show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed.")); - } - - /* DHCP still activated */ - if($this->initial_dhcp_is_Account && $this->dhcp_is_Account){ - - /* DHCP node changed */ - if(($this->initial_dhcpParentNode != $this->dhcpParentNode) || - ($this->cn != $this->OrigCn)){ - $attrs = $this->dhcpHostEntry; - $attrs['cn'] = $this->cn; - unset($attrs['dn']); - unset($attrs['MODIFIED']); - $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode); - $res = $ldap->add($attrs); - - $tmp = new servdhcp($this->config,$this->dhcpParentNode); - $tmp->handle_post_events("modify"); - - show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed.")); - if($res){ - $ldap->rmdir_recursive($this->dhcpHostEntry['dn']); - show_ldap_error($ldap->get_error(),_("Removing old dhcp entry failed.")); - } - } - - /* SAME node but modified */ - if(isset($this->dhcpHostEntry['MODIFIED']) && $this->dhcpHostEntry['MODIFIED'] == 1 && - $this->initial_dhcpParentNode == $this->dhcpParentNode){ - $attrs = $this->dhcpHostEntry; - unset($attrs['dn']); - unset($attrs['MODIFIED']); - $ldap->cd($this->dhcpHostEntry['dn']); - $ldap->modify($attrs); - - $tmp = new servdhcp($this->config,$this->dhcpParentNode); - $tmp->handle_post_events("modify"); - - show_ldap_error($ldap->get_error(),_("Modifying dhcp entry failed.")); - } - } - } - - - /****************/ - /* DNS HANDLING */ - /****************/ - - /* If isn't DNS account but initially was DNS account - remove all DNS entries - */ - if((!$this->DNSenabled) || ((!$this->DNS_is_account)&&(!$this->initially_was_account))){ - return; - }else{ - - /* Add ipHostNumber to aRecords - */ - $backup_dnsEntry = $this->dnsEntry; - if(!empty($this->ipHostNumber)){ - $this->dnsEntry['RECORDS'][] = array("type"=>"aRecord","value"=>$this->ipHostNumber); - $ptr = $this->get_pTRRecord(); - if(!empty($ptr)){ - $this->dnsEntry['RECORDS'][] = array("type"=>"pTRRecord","value"=>$ptr); - } - } - - /* Create diff and follow instructions - * If Account was disabled, remove account by setting exists to false - */ - if((!$this->DNS_is_account)&&($this->initially_was_account)){ - $this->dnsEntry['exists'] = false; - $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn); - }else{ - $this->dnsEntry['exists'] = $this->DNS_is_account; - $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn); - } - - /* move follwoing entries - */ - foreach($tmp['move'] as $src => $dst){ - $this->recursive_move($src,$dst); - } - - /* Delete dns */ - foreach($tmp['del'] as $dn => $del){ - $ldap->cd($dn); - $ldap->rmdir_recursive($dn); - new log("modify","unknown/".get_class($this),$dn,array("*"),$ldap->get_error()); - } - - /* Add || Update new DNS entries - */ - foreach($tmp['add'] as $dn => $attrs){ - $ldap->cd($dn); - $ldap->cat($dn, array('dn')); - if(count($ldap->fetch())){ - $ldap->cd($dn); - $ldap->modify ($attrs); - }else{ - $ldap->cd($dn); - $ldap->add($attrs); - } - new log("modify","unknown/".get_class($this),$dn,array_keys($attrs),$ldap->get_error()); - } - - - /* Display errors - */ - if($ldap->get_error() != "Success"){ - show_ldap_error($ldap->get_error(), sprintf(_("Saving of terminal/dns account with dn '%s' failed."),$this->dn)); - } - - $tmp2 = new servdns($this->config,$this->dn); - $tmp2->handle_post_events("modify"); - - $this->dnsEntry = $backup_dnsEntry; - } - } - - /* Create html table with all used record types - */ - function generateRecordsList() - { - $changeStateForRecords = ""; - - if(!$this->DNS_is_account) { - $str = ""; - return(array("str" => $str, "changeStateForRecords"=> "")); - } - - $str = ""; - foreach($this->dnsEntry['RECORDS'] as $key => $entry){ - - $changeStateForRecords.= "changeState('RecordTypeSelectedFor_".$key."');\n"; - $changeStateForRecords.= "changeState('RecordValue_".$key."');\n"; - $changeStateForRecords.= "changeState('RemoveRecord_".$key."');\n"; - - $str.=" ". - " ". - " ". - " ". - ""; - } - - $str.= " ". - " ". - " ". - "
".$this->generateRecordListBox($entry['type'],"RecordTypeSelectedFor_".$key)."
". - " ". - "
"; - $ret = array("str" => $str, "changeStateForRecords" => $changeStateForRecords); - return($ret); - } - - - /* Create a html select box which allows us to select different types of records - */ - function generateRecordListBox($selected,$name) - { - $str = ""; - return($str); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - $tmp = array( - "plShortName" => _("DNS"), - "plDescription" => _("DNS settings"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 5, - "plSection" => array("administration"), - "plCategory" => array("workstation","terminal","phone","server","component","printer","winworkstation"), - - "plProvidedAcls"=> array( - "ipHostNumber" => _("IP address"), - "macAddress" => _("MAC address")) - ); - - /* Hide all dns specific code, if dns is not available - */ - foreach($_SESSION['config']->data['TABS']['SERVERSERVICE'] as $tab){ - if(preg_match("/^servdns$/",$tab['CLASS'])){ - $tmp['plProvidedAcls']["Records"] = _("DNS records"); - $tmp['plProvidedAcls']["zoneName"] = _("Zone name"); - $tmp['plProvidedAcls']["dNSTTL"] = _("TTL"); - break; - } - } - return($tmp); - } - - - function get_dhcp_host_entry() - { - $attrs = array(); - $dn = $this->get_dhcp_host_entry_dn(); - if($dn){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($dn,array("*")); - if($ldap->count()){ - $attrs = $ldap->fetch(); - foreach($attrs as $key => $value){ - if(is_numeric($key) || ($key == "count")){ - unset($attrs[$key]); - } - if(is_array($value) && isset($value['count'])){ - unset($attrs[$key]['count']); - } - } - } - } - return($attrs); - } - - - function get_dhcp_host_entry_dn() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(objectClass=dhcpHost)(cn=".$this->cn."))",array("cn","dn")); - - if($ldap->count()){ - $attr = $ldap->fetch(); - return($attr['dn']); - }else{ - return(""); - } - } - - - function get_dhcp_parent_node() - { - return(preg_replace("/^cn=".normalizePreg($this->cn).",/","",$this->get_dhcp_host_entry_dn())); - } - - - function get_dhcp_parent_nodes() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=dhcpService)",array("dhcpPrimaryDN")); - - $dhcp_dns = array(); - while($attr = $ldap->fetch()){ - $dhcp_dns[$attr['dn']] = $attr['dhcpPrimaryDN'][0]; - } - - foreach($dhcp_dns as $key => $pri_dns){ - $ldap->cat($pri_dns,array("cn")); - $tmp = $ldap->fetch(); - if(isset($tmp['cn'][0])){ - $dhcp_dns[$key] = $tmp['cn'][0]; - }else{ - unset($dhcp_dns[$key]); - } - } - - $tmp = $tmp2 = array(); - foreach($dhcp_dns as $dn => $cn){ - $ldap->cd($dn); - $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpGroup)". - "(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork))",array("cn")); - while($attr = $ldap->fetch()){ - $tmp[$attr['dn']] = $attr['cn'][0]; - } - $tmp2 = array_merge($tmp2,$this->create_tree($tmp,preg_replace("/^[^,]+,/i","",$dn),"(".$cn.") ")); - } - return($tmp2); - } - - - /* this function returns the default ptr record entry */ - function get_pTRRecord() - { - if(!empty($this->ipHostNumber) && isset($this->dnsEntry['zoneName']) && !empty($this->dnsEntry['zoneName'])){ - $ldap = $this->config->get_ldap_link(); - $ldap->cat(getDNSZoneDN($this->config,$this->dnsEntry['zoneName'])); - $attrs = $ldap->fetch(); - $tmp = array_flip($this->Zones); - $tmp = preg_replace("/^[^\/]*+\//","",$tmp[$this->dnsEntry['zoneName']]); - $tmp = trim(preg_replace("/\.in-addr.arpa$/","",$tmp)); - $ptr = preg_replace("/^".normalizePreg(FlipIp($tmp))."\./","",$this->ipHostNumber); - return($ptr); - }else{ - return(FALSE); - } - } - - - function generateRandomIP($net = "") - { - $str = $net; - $cnt = 4; - while(substr_count($str,".") < 3 && $cnt > 0){ - $str .= ".".rand(0,255); - $str = preg_replace("/\.\.*/",".",$str); - $str = trim($str,". "); - $cnt --; - } - return($str); - } - - - function create_tree($arr,$base,$current = "") - { - $ret = array(); - foreach($arr as $r => $name){ - $base_part = str_replace($base,"",$r); - if(preg_match("/^[a-z]*=".normalizePreg($name)."(|,)$/i",$base_part)){ - $ret[$r] = $current.$name; - $tmp = $this->create_tree($arr,$r,$current.". "); - foreach($tmp as $sub_key => $sub_name){ - $ret[$sub_key] = $sub_name; - } - } - } - return($ret); - } - - function force_dns() - { - if($this->DNSenabled){ - $this->DNS_is_account = TRUE; - $this->hide_dns_check_box = TRUE; - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl b/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl deleted file mode 100644 index 9c0428c29..000000000 --- a/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl +++ /dev/null @@ -1,27 +0,0 @@ -

{t}This dialog allows you to configure all components of this DNS zone on a single list.{/t}

-

 

-{if $disableDialog} -
- {t}This dialog can't be used until the currently edited zone was saved or the zone entry exists in the ldap database.{/t} - -{else} -
- {$table} -
- -{/if} - -

 

-
-

- - -

-
- - - diff --git a/plugins/admin/systems/services/dns/servdns.tpl b/plugins/admin/systems/services/dns/servdns.tpl deleted file mode 100644 index 6cfa50f09..000000000 --- a/plugins/admin/systems/services/dns/servdns.tpl +++ /dev/null @@ -1,63 +0,0 @@ -{if $dns_take_over} - - - - -
-

{t}DNS take over initiated{/t}

- {$warning} - {t}This includes 'all' DNS zones that are located within this server. Please double check if your really want to do this.{/t} -

- {$warning2} -
- -

-

- {t}Following objects will be taken over{/t} : -

-

-

{$info}
-

-
-{else} - -{if $dns_server_list_cnt} - - - -{/if} - - - -
- {t}Take over DNS configuration from{/t}  - - -
-

{t}Zones{/t}

- {$ZoneList} - {if $is_createable} - - {else} - - {/if} -
- - - - -{/if} -

 

-

-

- -   - -
-

diff --git a/plugins/admin/systems/services/dns/servdnseditzone.tpl b/plugins/admin/systems/services/dns/servdnseditzone.tpl deleted file mode 100644 index 1136dba53..000000000 --- a/plugins/admin/systems/services/dns/servdnseditzone.tpl +++ /dev/null @@ -1,177 +0,0 @@ -

{t}Generic{/t}

- - - - - -
- - - - - - - - - - - - - -
{t}Zone name{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Network address{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Netmask{/t} - -{render acl=$ACLs} - -{/render} -
-
- - - - - -
- {t}Zone records{/t} -
- {if $AllowZoneEdit == false} - {t}Can't be edited because the zone wasn't saved right now.{/t} - {/if} -
-{render acl=$ACLs} - -{/render} -
-
-

 

-

{t}SOA record{/t}

- - - - - -
- - - - - - - - - - - - - -
{t}Primary dns server for this zone{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Mail address{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Serial number (automatically incremented){/t}{$must} - -{render acl=$ACLs} - -{/render} -
-
- - - - - - - - - - - - - - - - - -
{t}Refresh{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Retry{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}Expire{/t}{$must} - -{render acl=$ACLs} - -{/render} -
{t}TTL{/t}{$must} - -{render acl=$ACLs} - -{/render} -
-
- -

 

-
- - - - - -
-

{t}MxRecords{/t}

- - - - -
-{render acl=$ACLs} - {$Mxrecords} -{/render} -{render acl=$ACLs} - -{/render} -{render acl=$ACLs} - -{/render} -
-
-

{t}Global zone records{/t}

-{render acl=$ACLs} - {$records} -{/render} -
-
-

-{render acl=$ACLs} - -{/render} - -

-
- diff --git a/plugins/admin/systems/services/glpi/class_glpiAccount.inc b/plugins/admin/systems/services/glpi/class_glpiAccount.inc deleted file mode 100644 index e6411087a..000000000 --- a/plugins/admin/systems/services/glpi/class_glpiAccount.inc +++ /dev/null @@ -1,806 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= FALSE; - var $attributes= array("ID","name","contact", - "tech_num","comments","date_mod","os","location","domain","network","contact_num", - "model","type","is_template","FK_glpi_enterprise","deleted"); - - var $ID ; // Is set if this entry is edited - var $name = ""; // This should be the dn of this entry - var $contact = ""; // Empty - - var $comments = ""; // Comment - - var $contact_num = ""; // Contact person - var $tech_num = ""; // Technical responsible person - - var $addUser = ""; // This is used to remember if a dialog was opened for tech_num or contact_num - - var $date_mod = ""; // Modification timestamp - var $os = 0; // Operating system - var $location = 0; // Not used yet - var $domain = 0; // ? Set to 0 - var $network = 0; // ? Set to 0 - - var $model = 0; // ? Can't remember this, it isn't used in GOsa - var $type = 0; // System type id - var $is_template = 0; // Used as template ? - var $FK_glpi_enterprise = 0; // Manufacturer id - var $deleted = "N"; // Deleted entries should have this set to Y - - var $renameTypeDialog = false; - var $renameOSDialog = false; - var $select_type ; - var $view_logged = FALSE; - - /* Not necessary, cause we use mysql databse */ - var $objectclasses= array("whatever"); - - /* Used to remember if this was an account (simply: is this an edited entry) */ - var $initially_was_account = false; - - /* Remember current dialog */ - var $edit_type = false; - var $edit_os = false; - - var $data; - var $handle = NULL; // Glpi class handle used to query database - - var $cur_dialog = NULL; // This contains the sub dialog handle - - var $orig_dn; // To check if dn, has changed - var $ui; // Some GOsa specific user informations - - var $usedDevices = array(); // Which devices are currently selected - var $usedAttachments = array(); // Used Attachments - - /* Contructor - Sets default values and checks if we already have an existing glpi account - */ - function glpiAccount (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - $this->ui= get_userinfo(); - - /* Abort class construction, if no db is defined */ - if(!isset($this->config->data['SERVERS']['GLPI'])){ - return; - } - - // Get informations about databse connection - $this->data = $this->config->data['SERVERS']['GLPI']; - - // Abort if mysql extension is missing - if(!is_callable("mysql_connect")){ - return; - } - - // Create handle of glpi class, and check if database connection is established - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - - if(!$this->handle->is_connected){ - return; - } - - // If this dn is already used in database, then get all informations for this entry - if($this->handle->is_account($this->dn)){ - $this->is_account = true; - $tmp = ($this->handle->getComputerInformations($this->dn)); - - foreach(array("tech_num","os","FK_glpi_enterprise","type","comments","contact_num") as $attr){ - $this->$attr = $tmp[0][$attr]; - } - $this->usedDevices = $this->handle->getUsedDevices($tmp[0]['ID']); - $atts = $this->handle->getAssignAttachments($tmp[0]['ID']); - foreach($atts as $attachment){ - - $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc']; - } - }else{ - $this->is_account = false; - } - - /* set defaults */ - $this->name = $this->dn; - $this->orig_dn = $this->dn; - $this->initially_was_account = $this->is_account; - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","all/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Assign smarty defaults - To avoid undefined indexes, if there is an error with the glpi db - */ - foreach(array("SystemTypes","SystemTypeKeys","Manufacturers", - "OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys", - "OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){ - $smarty->assign($attr,array()); - } - foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){ - $smarty->assign($attr,""); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation) { - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Check if there is a glpi database server defined - */ - if(!isset($this->config->data['SERVERS']['GLPI'])){ - print_red(_("There is no server with valid glpi database service.")); - return($smarty->fetch(get_template_path('glpi.tpl', TRUE))); - } - - $this->data = $this->config->data['SERVERS']['GLPI']; - - /* Check if we can call mysql_connect - If we can't, there is no the mysql-php extension - */ - if(!is_callable("mysql_connect")){ - print_red(_("Can't connect to glpi database, the php-mysql extension is missing.")); - return($smarty->fetch(get_template_path('glpi.tpl', TRUE))); - } - - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - - /* If handle == false, abort - Seems that the server, username and or password is wrong - */ - if(!$this->handle->is_connected){ - print_red(_("Can't connect to glpi database, check configuration twice.")); - return($smarty->fetch(get_template_path('glpi.tpl', TRUE))); - } - - /* All checks are ok - Lets handle Posts, templates etc below ... - */ - - $users = $this->handle->getUsers(); - $ldap= $this->config->get_ldap_link(); - - /* Check for Trading button Post - */ - if(isset($_POST['Trading'])){ - print_red(_("This feature is not implemented yet.")); - } - - /* Check for Software button Post - */ - if(isset($_POST['Software'])){ - print_red(_("This feature is not implemented yet.")); - } - - /* Check for Contract button Post - */ - if(isset($_POST['Contracts'])){ - print_red(_("This feature is not implemented yet.")); - } - - /* Add Device was requested, open new dialog - */ - if((isset($_POST['AddDevice'])) && ($this->acl_is_writeable("Devices"))){ - $this->dialog =true; - $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices); - } - - /* Attachment pool was closed with use - */ - if(isset($_POST['UseAttachment']) && ($this->acl_is_writeable("Attachments"))){ - if(count($this->cur_dialog->check())){ - foreach($this->cur_dialog->check() as $msg){ - print_red($msg); - } - }else{ - $this->cur_dialog->save_object(); - $this->usedAttachments = $this->cur_dialog->save(); - $this->cur_dialog = false; - $this->edit_type = false; - } - } - - /* Attachment pool was closed with abort - */ - if(isset($_POST['AbortAttachment'])){ - $this->cur_dialog = false; - $this->edit_type = false; - } - - /* Open Attachment pool to add/edit Attachments - */ - if(isset($_POST['AddAttachment']) && ($this->acl_is_writeable("Attachments"))){ - $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments); - $this->dialog = true; - } - - /* Remove Attachment fro this tab - */ - $once = true; - foreach($_POST as $name => $value){ - if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){ - $once= false; - $name = preg_replace("/^delAttachment_/","",$name); - $entry = preg_replace("/_.*$/","",$name); - if(isset($this->usedAttachments[$entry])){ - unset($this->usedAttachments[$entry]); - } - } - } - if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && ($this->acl_is_writeable("Attachments"))){ - foreach($_POST['Attachments'] as $entry){ - if(isset($this->usedAttachments[$entry])){ - unset($this->usedAttachments[$entry]); - } - } - } - - /* We have selected some devices and pressed use button - */ - if(isset($_POST['SelectDeviceSave']) && $this->acl_is_writeable("Devices")){ - $this->cur_dialog->save_object(); - $this->usedDevices= ($this->cur_dialog->getSelected()); - $this->cur_dialog = false; - $this->dialog = false; - $this->edit_type=false; - } - - /* Aborted Device selction - */ - if(isset($_POST['SelectDeviceCancel']) && ($this->acl_is_writeable("Devices"))){ - $this->dialog = false; - $this->cur_dialog = false; - $this->edit_type=false; - } - - /* System type management - */ - if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){ - $this->dialog = true; - $this->edit_type=true; - } - - /* This closes the system type editing dialog - */ - if(isset($_POST['close_edit_type']) && ($this->acl_is_writeable("type"))){ - $this->edit_type=false; - $this->dialog = false; - } - - if(isset($_POST['Rename_Cancel'])){ - $this->renameTypeDialog = false; - $this->renameOSDialog = false; - } - - /* This appends a new system to our sytem types - */ - if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){ - $attr = $this->handle->getSystemTypes(); - if(in_array(trim($_POST['type_string']),$attr)){ - print_red(_("Adding new sytem type failed, this system type name is already used.")) ; - }else{ - $this->handle->addSystemType(trim($_POST['type_string'])); - } - } - - /* Remove selected type from our system types list - */ - if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){ - $tmp = $this->handle->is_systemTypeUsed($_POST['select_type']); - if(count($tmp)){ - $names = ""; - foreach($tmp as $name){ - $names .= ", ".$name; - } - $names = preg_replace("/^, /","",$names); - $names = trim($names); - if(count($tmp) == 3){ - $names .= " ..."; - } - print_red(sprintf(_("You can't delete this system type, it is still in use by these system(s) '%s'"),$names)); - }else{ - $this->handle->removeSystemType($_POST['select_type']); - } - } - - /* Rename selected system type to given string - */ - if(isset($_POST['Rename_type_OK'])){ - $attr = $this->handle->getSystemTypes(); - if(in_array(trim($_POST['string']),$attr)){ - print_red(_("Rename failed, this system type name is already used.")) ; - }else{ - $this->renameTypeDialog = false; - $this->handle->updateSystemType($_POST['string'],trim($this->select_type)); - } - } - - - if((isset($_POST['rename_type'])&&(!empty($_POST['select_type'])))||($this->renameTypeDialog)){ - if(isset($_POST['select_type'])){ - $this->select_type = $_POST['select_type']; - } - $this->renameTypeDialog = true; - $tmp = $this->handle->getSystemTypes(); - - $smarty->assign("string",$tmp[$this->select_type]); - if(isset($_POST['string'])){ - $smarty->assign("string",$_POST['string']); - } - $smarty->assign("Method","rename"); - $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE)); - return($display); - } - - - - /* Someone wants to edit the system types ... - So, lets open a new dialog which provides some buttons to edit the types - */ - if($this->edit_type){ - $smarty->assign("Method","edit"); - $smarty->assign("SystemTypes", $this->handle->getSystemTypes()); - $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes())); - $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE)); - return($display); - } - - /* System os management - */ - if(isset($_POST['edit_os']) && $this->acl_is_writeable("os")){ - $this->dialog = true; - $this->edit_os=true; - } - - /* Close Operating system dialog - */ - if(isset($_POST['close_edit_os'])){ - $this->edit_os=false; - $this->dialog = false; - } - - /* Add new os to the db - */ - if((isset($_POST['add_os']))&&(!empty($_POST['is_string'])) && $this->acl_is_writeable("os")){ - $attr = $this->handle->getOSTypes(); - if(in_array(trim($_POST['is_string']),$attr)){ - print_red(_("Adding new operating system failed, specifed name is already used.")) ; - }else{ - $this->handle->addOS(trim($_POST['is_string'])); - } - } - - /* Delete selected os from list and db - */ - if((isset($_POST['del_os']))&&(!empty($_POST['select_os'])) && $this->acl_is_writeable("os")){ - $tmp = $this->handle->is_osUsed($_POST['select_os']); - - if(count($tmp)){ - - $names = ""; - foreach($tmp as $name){ - $names .= ", ".$name; - } - $names = preg_replace("/^, /","",$names); - $names = trim($names); - if(count($tmp) == 3){ - $names .= " ..."; - } - print_red(sprintf(_("You can't delete this operating system, it is still in use by these system(s) '%s'"),$names)); - - }else{ - $this->handle->removeOS_byID($_POST['select_os']); - } - } - - /* Rename selected os to given string - */ - if(isset($_POST['Rename_os_OK']) && $this->acl_is_writeable("os")){ - $attr = $this->handle->getOSTypes(); - if(in_array(trim($_POST['string']),$attr)){ - print_red(_("Updating operating system failed, specifed name is already used.")) ; - }else{ - $this->handle->updateOS($_POST['string'],$this->select_type); - $this->renameOSDialog = false; - } - } - if((isset($_POST['rename_os'])&&(!empty($_POST['select_os'])))||($this->renameOSDialog)){ - if(isset($_POST['select_os'])){ - $this->select_type = $_POST['select_os']; - } - $this->renameOSDialog = true; - $tmp = $this->handle->getOSTypes(); - - $smarty->assign("string",$tmp[$this->select_type]); - if(isset($_POST['string'])){ - $smarty->assign("string",$_POST['string']); - } - $smarty->assign("Method","rename"); - $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE)); - return($display); - } - - /* Open dialog to edit os types - */ - if($this->edit_os){ - $smarty->assign("Method","edit"); - $smarty->assign("OSs", $this->handle->getOSTypes()); - $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes())); - $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE)); - return($display); - } - - - - /* Show dialog to select a new contact person - * Select a contact person - */ - if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){ - $this->addUser = "contact"; - $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num"); - $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category)); - $this->cur_dialog->set_acl_base($this->dn); - - } - - /* Open dialog which allows to edit the manufacturers - */ - if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){ - $this->cur_dialog = new glpiManufacturer($this->config,$this->dn); - $this->dialog = true; - } - - /* Close manufacturer editing dialog - */ - if(isset($_POST['close_edit_manufacturer'])){ - $this->dialog = false; - $this->cur_dialog = false; - } - - /* Abort user selection - */ - $smarty->assign("AbortSelectUser","SelectUserCancel"); - if(isset($_POST['SelectUserCancel'])){ - $this->dialog = false; - $this->addUser =""; - $this->cur_dialog = false; - } - - /* Selecte technical responsible person - */ - if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){ - $this->addUser ="tech"; - $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num"); - $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category)); - $this->cur_dialog->set_acl_base($this->dn); - } - - /* Technical responsible person selected*/ - if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")&&(strlen($_GET['id']) > 100)){ - print_red(sprintf(_("Could not add the given user, the users dn is too long, only 100 characters are allowed here."))); - - }elseif(isset($_GET['act'])&&($_GET['act']=="user_tech_num") && strlen($_GET['id'])){ - - - /* Get posted id */ - $id = base64_decode($_GET['id']); - - /* Check if user is already created in glpi database */ - if(!in_array($id,$users)){ - - /* If this user doesn't exists in glpi db, we must create him */ - $ldap->cat($id, array('cn', 'mail', 'telephoneNumber')); - $atr = $ldap->fetch(); - $tmp = array(); - $use = array( "cn" =>"name", - "mail" =>"email", - "telephoneNumber" =>"phone"); - - /* Create array */ - foreach($use as $gosa => $glpi){ - if(isset($atr[$gosa])){ - $tmp[$glpi]= $atr[$gosa][0]; - } - } - - /* Add this user */ - $this->handle->addUser($tmp,$id); - } - - /* Re-read users */ - $users = ($this->handle->getUsers()); - - /* Get user */ - $tmp = array_flip($users); - $id=$tmp[$id]; - - /* Use user id, close dialog */ - if($this->addUser == "tech"){ - $this->tech_num = $id; - }else{ - $this->contact_num = $id; - } - $this->cur_dialog = false; - $this->dialog= false; - } - - /* if( cur_dialog != false || cur_dialog != NULL) - * There is a dialog which wants to be displayed - */ - if(isset($this->cur_dialog) && is_object($this->cur_dialog)){ - $this->cur_dialog->save_object(); - $this->dialog=true; - $this->cur_dialog->parent = &$this; - return($this->cur_dialog->execute()); - }else{ - $this->dialog= false; - } - - /* Assign smarty defaults */ - foreach(array("SystemTypes","SystemTypeKeys","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){ - $smarty->assign($attr,array()); - } - - /* Assign some vars to smarty - */ - foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){ - $smarty->assign($attr,""); - } - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Show tab dialog headers */ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove inventory"), - _("This device has inventory informations enabled. You can disable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Add inventory"), - _("This device has inventory informations disabled. You can enable them by clicking below.")); - return ($display); - } - - /* Assign system types - */ - $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes())); - $smarty->assign("SystemTypes", $this->handle->getSystemTypes()); - $smarty->assign("type", $this->type); - - /* Assign os types - */ - $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes())); - $smarty->assign("OSs", $this->handle->getOSTypes()); - $smarty->assign("os", $this->os); - - /* Dispaly installed devices */ - $smarty->assign("InstalledDevices" ,$this->getDevices()); - $smarty->assign("InstalledDeviceKeys" ,array_flip($this->getDevices())); - - /* Append manufacturers - */ - $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises())); - $smarty->assign("Manufacturers", $this->handle->getEnterprises()); - $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise); - - /* Assign used Attachments - */ - - $divlist = new divSelectBox("glpiAttachmentsList"); - $divlist-> SetHeight(130); - $atts = $this->getUsedAttachments(true); - $downlink = "%s"; - $del_link = ""; - foreach($atts as $id => $attachment){ - $divlist->AddEntry - ( - array( - array("string"=>$attachment['name']), - array("string"=>$attachment['mime']), - array("string"=>sprintf($downlink,$id,$attachment['filename'])), - array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"), - ) - ); - } - - $smarty->assign("AttachmentsDiv" ,$divlist->DrawList()); - /* Handle contact person - Assign name ... to smarty, if set - */ - if(isset($users[$this->contact_num])){ - $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid')); - $tr = $ldap->fetch(); - $str = ""; - if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } - if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } - if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } - $smarty->assign("contact_num", $str); - }else{ - $smarty->assign("contact_num", _("N/A")); - } - - /* Handle tech person - Assign name ... to smarty, if set - */ - if(isset($users[$this->tech_num])){ - $tr = $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid')); - $tr = $ldap->fetch(); - $str = ""; - if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } - if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } - if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } - $smarty->assign("tech_num", $str); - }else{ - $smarty->assign("tech_num", _("N/A")); - } - $smarty->assign("comments", $this->comments); - - $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE)); - return($display); - } - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){ - return; - } - if(function_exists("mysql_pconnect")){ - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - if($this->initially_was_account){ - $this->handle->removeComputerInformations($this->dn); - new log("remove","undefined/".get_class($this),$this->dn); - } - }else{ - print_red(_("Can't remove glpi account, while mysql extension is missing.")); - new log("remove","undefined/".get_class($this),$this->dn,array(),_("Can't remove glpi account, while mysql extension is missing.")); - } - - } - - function getDevices(){ - $ret = array(); - foreach($this->usedDevices as $type => $entries){ - foreach($entries as $ent){ - if(isset($ent['designation'])){ - $ret[] = $ent['designation']." [".$type."]"; - }else{ - $ret[] = $ent['name']." [".$type."]"; - } - } - } - return($ret); - } - - - /* Save data to object */ - function save_object() - { - if(!isset($_POST['glpi_tpl_posted'])) { - return ; - } - plugin::save_object(); - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - // if($this->TechnicalResponsible == ""){ - // $message[] = _("Please select a technical responsible person for this entry."); - // } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - if($this->is_account){ - $attrs = array(); - $this->date_mod = date("Y-m-d H:i:s"); - foreach($this->attributes as $attr){ - $attrs[$attr] = $this->$attr; - } - $attrs['name'] = $this->dn; - unset($attrs['ID']); - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - - /* check if we have to update, add */ - if($this->initially_was_account&&$this->is_account){ - $this->handle->updateComputerInformations($attrs,$this->orig_dn); - new log("modify","undefined/".get_class($this),$this->dn); - }elseif($this->is_account){ - $this->handle->addComputerInformations($attrs,$this->dn); - new log("create","undefined/".get_class($this),$this->dn); - } - $tmp = $this->handle->getComputerInformations($this->dn); - $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']); - } - } - - - /* Return used attachments */ - function getUsedAttachments($divlist = false) - { - $atts =$this->handle->getAttachments(); - $ret = array(); - foreach($atts as $entry){ - if(in_array($entry['ID'],$this->usedAttachments)){ - if($divlist){ - $ret[$entry['ID']] = $entry; - }else{ - $cm =""; - if(isset($entry['comment'])){ - $cm=" [".$entry['comment']."]"; - } - if(isset($entry['mime'])){ - $cm.=" -".$entry['mime'].""; - } - - $ret[$entry['ID']]= $entry['name'].$cm; - } - } - } - return($ret); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Glpi"), - "plDescription" => _("Inventory extension"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 20, - "plSection" => array("administration"), - "plCategory" => array("workstation","terminal","component","server","phone") , - "plProvidedAcls"=> array( - - "tech_num" => _("Technical responsible"), - "comments" => _("Comment"), - "os" => _("Operating system"), - "location" => _("Location"), - "contact_num" => _("Contact person"), - "model" => _("Model"), - "type" => _("Type"), - "FK_glpi_enterprise" => _("Manufacturer"), - "Attachments" => _("Attachments"), - "Devices" => _("Peripheral devices")) - )); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc b/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc deleted file mode 100644 index b50066029..000000000 --- a/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc +++ /dev/null @@ -1,362 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array("name","comment","mime","filename","date_mod"); - var $objectclasses = array("whatever"); - - var $parent; - var $edit = false; - var $entry = false; - var $date_mod =""; - var $name =""; - var $comment =""; - var $mime =""; - var $filename =""; - - var $Selected = array(); - - var $delAttach= ""; - - function glpiAttachmentPool (&$config, $dn= NULL,$used=NULL) - { - plugin::plugin ($config, $dn); - if(!isset($_SESSION['GlpiAttachmentFilter'])){ - $_SESSION['GlpiAttachmentFilter'] = array("filter"=>"*"); - } - - /* Assign used attributes */ - if($used !== NULL){ - $this->Selected = $used; - } - } - - function execute() - { - plugin::execute(); - $attach = $this->parent->handle->getAttachments(); - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - $only_once = true; - - /* walk through all posted objects */ - foreach($_POST as $name => $value){ - - /* Open dialog to create a new entry */ - if(preg_match("/new_attach/",$name)){ - $this->edit = true; - $this->entry=array(); - - /* Set default values */ - foreach($this->attributes as $attr) { - $this->$attr = ""; - $this->entry[$attr]=""; - } - } - - /* Remove attach*/ - if((preg_match("/^delAttach_/",$name))&&($only_once)){ - $only_once = false; - $str = preg_replace("/^delAttach_/","",$name); - $str = base64_decode(preg_replace("/_.*$/","",$str)); - - /* remove attach from db */ - $this->delAttach = $str; - $smarty->assign("warning", sprintf(_("You're about to delete the glpi attachment component '%s'."), $attach[$str]['name'])); - return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE))); - } - - /* Start editing entry */ - if((preg_match("/^editAttach_/",$name))&&($only_once)){ - $only_once = false; - $str = preg_replace("/^editAttach_/","",$name); - $str = base64_decode(preg_replace("/_.*$/","",$str)); - - /* Check if we have an attachment with given ID */ - foreach($attach as $att ){ - if($att['ID'] == $str ){ - - /* Entry was found, show dialog */ - $this->edit = true; - $this->entry = $att; - - foreach($att as $name => $value){ - $this->$name = $value; - } - } - } - } - } - - if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){ - if($this->parent->handle->is_attachmentUsed($this->delAttach)){ - $tmp = $this->parent->handle->is_attachmentUsed($this->delAttach); - - $names = ""; - foreach($tmp as $name){ - $names .= ", ".$name; - } - $names = preg_replace("/^, /","",$names); - $names = trim($names); - if(count($tmp) == 3){ - $names .= " ..."; - } - print_red(sprintf(_("You can't delete this attachment, it is still in use by these system(s) '%s'"),$names)); - - }else{ - $this->parent->handle->deleteAttachment($this->delAttach); - @unlink(CONFIG_DIR."/glpi/".$this->filename); - $attach = $this->parent->handle->getAttachments(); - } - } - - /* Someone tries to upload a file */ - if(($this->edit == true)&&(isset($_POST['upload']))){ - if(!isset($_FILES['filename'])){ - print_red(_("There is no valid file uploaded.")); - }else{ - $FILE = $_FILES['filename']; - if(!isset($FILE['name'])){ - print_red(_("There is no valid file uploaded.")); - }else{ - if($FILE['error']!=0) { - print_red(_("Upload wasn't successfull.")); - }else{ - if(!is_dir(CONFIG_DIR."/glpi/")){ - print_red(sprintf(_("Missing directory '%s/glpi/' to store glpi uploads."),CONFIG_DIR)); - }else{ - $filen = CONFIG_DIR."/glpi/".$FILE['name']; - if(file_exists($filen)){ - print_red(_("There is already a file with the same name uploaded.")); - }else{ - $fh = fopen($filen,"w"); - if(!$fh){ - print_red(sprintf(_("Can't create file '%s'."),$filen)); - }else{ - $str = file_get_contents($FILE['tmp_name']); - fwrite($fh,$str,strlen($str)); - fclose($fh); - $this->mime = $FILE['type']; - $this->filename = $FILE['name']; - } - } // File already exists - } - } // Check if any error occurred - } // check if valid filename was uploaded - } // ende check if file was uploaded - }// upload post - - /* save attachment*/ - if(($this->edit == true)&&(isset($_POST['SaveAttachment']))){ - if(count($this->check())==0){ - $this->date_mod = date("Y-m-d H:i:s"); - $this->save_entry(); - $this->edit= false; - $this->entry = array(); - $attach = $this->parent->handle->getAttachments(); - }else{ - foreach($this->check() as $msg){ - print_red($msg); - } - } - } - - /* Abort editing/adding attachment*/ - if(($this->edit == true)&&(isset($_POST['CancelAttachment']))){ - $this->edit = false; - $this->entry = array(); - } - - /* If edit == true, we have to show a dialog to edit or add an attach - */ - if($this->edit == true){ - foreach($this->attributes as $attr){ - $smarty->assign($attr,htmlentities(utf8_decode($this->$attr))); - } - if(!empty($this->filename)){ - if(is_readable(CONFIG_DIR."/glpi/".$this->filename)){ - $status =_("File is available."); - }else{ - $status =_("File is not readable, possibly the file is missing."); - } - }else{ - $status = _("Currently no file uploaded."); - } - $smarty->assign("status",$status); - return($smarty->fetch(get_template_path('glpiAttachmentEdit.tpl', TRUE))); - } - - /* Create list with checkboxes to select / deselect some attachents */ - $divlist = new divlist("Attachment"); - $divlist->SetPluginMode(); - $divlist->SetHeader(array( - array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), - array("string" => _("Name")), - array("string" => _("Mime"),"attach"=>"style='width:200px;'"), - array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); - - $divlist->SetSummary(_("This table displays all available attachments.")); - $divlist->SetEntriesPerPage(0); - - $editdel = ""; - $editdel.= ""; - - /* Add all given attachments to divlist - */ - foreach($attach as $entry){ - - /* Create display name*/ - if((empty($entry['name']))||(empty($entry['comment']))){ - - /* In glpi it is possible to add entries without name - so i've added this block - */ - if(empty($entry['name'])){ - $str1 = ""._("empty").""; - }else{ - $str1 = $entry['name']; - } - - if(!empty($entry['comment'])){ - $str1.= " [".$entry['comment']."]"; - } - }else{ - /* Both attributes given */ - $str1 = $entry['name']." [".$entry['comment']."]"; - } - - $edit = str_replace("%s",base64_encode($entry['ID']),$editdel); - $str2 = $entry['mime']." "; - - $chkbox = "". - ""; - - if(in_array($entry['ID'],$this->Selected)){ - $chkbox = preg_replace("/%CHECKED%/"," checked ",$chkbox); - }else { - $chkbox = preg_replace("/%CHECKED%/"," ",$chkbox); - } - $chkbox = preg_replace("/%s/",$entry['ID'],$chkbox); - $divlist->AddEntry(array( - array("string" => $chkbox, - "attach" => "style='text-align:center;width:20px;'"), - array("string"=> $str1), - array("string"=> $str2,"attach"=>"style='width:200px;'"), - array("string"=> $edit ,"attach" => "style='width:60px;border-right:0px;text-align:right;'") - )); - - } - - $listhead = "
". - "  ". - "
"; - - $smarty->assign("attachments", $divlist->DrawList()); - $smarty->assign("attachmenthead", $listhead); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("searchu_image", get_template_path('images/search_user.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info_small.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("attachment_regex", $_SESSION['GlpiAttachmentFilter']['filter']); - - $display.= $smarty->fetch(get_template_path('glpiAttachmentPool.tpl', TRUE)); - return($display); - } - - function save() - { - return($this->Selected); - } - - /* Adds new or saves edited entries */ - function save_entry() - { - if($this->edit){ - $tmp = array(); - foreach($this->attributes as $attr){ - $tmp[$attr] = $this->$attr; - } - $id = -1; - if(isset($this->entry['ID'])){ - $id = $this->entry['ID']; - } - $this->parent->handle->saveAttachments($tmp,$id); - } - } - - function save_object() - { - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - - /* Checkboxes are only posted, if they are checked - * To check if it was deselected, we check if wasOnPage - * was posted with given name, so we can deselect this entry - */ - - foreach($_POST as $name => $value){ - if(preg_match("/wasOnPage_/",$name)){ - $id=preg_replace("/wasOnPage_/","",$name); - if(isset($_POST["useMe_".$id])){ - $this->Selected[$id]=$id; - }else{ - if(isset($this->Selected[$id])){ - unset($this->Selected[$id]); - } - } - } - } - } - - /* Simple check */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if($this->edit){ - - /* check if given name is already in use */ - $att = $this->parent->handle->getAttachments(); - $ok = true; - $this->name=trim($this->name); - - foreach($att as $val){ - if(!isset($this->entry['ID'])){ - if($val['name'] == $this->name){ - $ok = false; - } - }else{ - if(($val['name'] == $this->name)&&($this->entry['ID'] != $val['ID'])){ - $ok = false; - } - } - } - if(!$ok){ - $message[] = _("This name is already in use."); - } - if(empty($this->name)){ - $message[] = _("Please specify a valid name for this attachment."); - } - } - return($message); - } - -}// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc b/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc deleted file mode 100644 index 0f24300d8..000000000 --- a/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc +++ /dev/null @@ -1,427 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes= array(); - var $objectclasses= array("whatever"); - - var $devices = array(); - var $ui; - - var $parent ; - var $EditEntry; - var $editMode =false; - - var $DeviceAttrs = array(); - var $AllowedDevices = array(); - - var $Selected = array(); - - var $delete = array(); - - function glpiDeviceManagement (&$config, $dn= NULL,$used=NULL) - { - plugin::plugin ($config, $dn); - - if(!isset($_SESSION['glpiDeviceRegex'])){ - $tmp['device_regex'] = "*"; - $_SESSION['glpiDeviceRegex'] = $tmp; - } - $this->ui = get_userinfo(); - - if(isset($used)){ - $this->Selected = $used; - } - - /* Specify which vars are allowed for a sepcific type of device */ - $this->DeviceAttrs['case'] = array("designation","format","comment","FK_glpi_enterprise"); - $this->DeviceAttrs['moboard'] = array("designation","chipset","comment","FK_glpi_enterprise"); - $this->DeviceAttrs['processor'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default"); - $this->DeviceAttrs['iface'] = array("designation","bandwidth","comment","FK_glpi_enterprise","specif_default"); - $this->DeviceAttrs['ram'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default","type"); - $this->DeviceAttrs['hdd'] = array("designation","rpm","interface","cache","comment","FK_glpi_enterprise","specif_default"); - $this->DeviceAttrs['drive'] = array("designation","speed","interface","is_writer","comment","FK_glpi_enterprise","specif_default"); - $this->DeviceAttrs['control'] = array("designation","interface","raid","comment","FK_glpi_enterprise"); - $this->DeviceAttrs['gfxcard'] = array("designation","ram","interface","comment","FK_glpi_enterprise","specif_default"); - $this->DeviceAttrs['sndcard'] = array("designation","type","comment","FK_glpi_enterprise","specif_default"); - $this->DeviceAttrs['power'] = array("designation","power","comment","FK_glpi_enterprise","atx"); - $this->DeviceAttrs['pci'] = array("designation","comment","FK_glpi_enterprise","specif_default"); - $this->DeviceAttrs['monitor'] = array("name","comments","serial","otherserial","size", - "flags_micro","flags_speaker","flags_subd","flags_bnc", - "location","type","FK_glpi_enterprise","is_global","deleted","is_template","tplname"); - - $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci","monitor"); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Get all defined devices */ - $this->reload(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* this var is used to ensure that every post is only performed once */ - $only_once = true; - - /* Check Post for some actions */ - foreach($_POST as $name => $value){ - - /* If new_ then we should create an new device */ - if((preg_match("/^new_/",$name))&&($only_once)){ - - /* don't do this twice */ - $only_once = false; - - /*extract device device_type */ - $deviceType = preg_replace("/_.*$/","",preg_replace("/^new_/","",$name)); - - /* Check if type is allowed, and create empty entry */ - $tmp = array(); - if((!isset($this->DeviceAttrs[$deviceType]))||((!in_array($deviceType,$this->AllowedDevices)))){ - print_red(sprintf(_("Internal Error can't create device of type '%s'"),$deviceType)); - }else{ - foreach($this->DeviceAttrs[$deviceType] as $attr){ - $tmp[$attr] = ""; - } - $tmp['device_type'] = $deviceType; - $this->EditEntry = $tmp; - $this->editMode =true; - } - } - } - - /* delete was requested ... show dialog */ - if((isset($_GET['act']))&&($_GET['act']=="del_device")){ - $id = base64_decode($_GET['id']); - $tmp = $this->devices[$id]; - - $this->delete = $tmp; - - if(isset($tmp['name'])){ - $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['name'])); - }elseif(isset($tmp['designation'])){ - $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['designation'])); - }else{ - print_red(_("Can't detect object name.")); - } - - return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE))); - } - - /* Delete entry, but check if this device is in currently in use */ - if(isset($_POST['delete_glpi_confirm'])){ - if(count($this->parent->handle->is_deviceUsed($this->delete))){ - - $tmp = $this->parent->handle->is_deviceUsed($this->delete); - - $names = ""; - foreach($tmp as $name){ - $names .= ", ".$name; - } - $names = preg_replace("/^, /","",$names); - $names = trim($names); - if(count($tmp) == 3){ - $names .= " ..."; - } - print_red(sprintf(_("You can't delete this device, it is still in use by these system(s) '%s'"),$names)); - }else{ - $this->parent->handle->deleteDevice($this->delete); - $this->reload(); - } - } - - /* Open entry for editing if requested */ - if((isset($_GET['act']))&&($_GET['act']=="edit_device")){ - $id = base64_decode($_GET['id']); - $this->editMode =true; - $this->EditEntry = $this->devices[$id]; - } - - /* Abort editing this entry */ - if(isset($_POST['AbortDeviceChanges'])){ - $this->EditEntry = array(); - $this->editMode = false; - } - - /* Save all changes made on currently selected entry */ - if(isset($_POST['SaveDeviceChanges'])){ - - /* First check if all changes made are allowed */ - if(count($this->check())==0){ - $this->save(); - $this->editMode = false; - $this->reload(); - }else{ - foreach($this->check() as $msg){ - print_red($msg); - } - } - - } - - /* Check if we are currently editing something ? */ - if($this->editMode == true){ - return ($this->editDevice($this->EditEntry)); - } - - /* ENDE : GET / POST handling - * Below, only output generation for headpage - */ - - $divlist = new divlist("glpi devices"); - $divlist->SetPluginMode(); - $divlist->SetEntriesPerPage(0); - $divlist->SetHeader(array( - array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), - array("string" => _("devices"), "attach" => "style=''"), - array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); - - $edit = "%s"; - $editdel = ""._("Edit").""; - $editdel.= ""._("Delete").""; - - $useDevice = ""; - - foreach($this->devices as $key=>$user){ - - if(isset($user['designation'])){ - $str = "designation"; - }else{ - $str = "name"; - } - - if(isset($this->Selected[$user['device_type']][$user[$str]])){ - $use = " checked "; - }else{ - $use =""; - } - - /* Dawn databse struckture ....*/ - if(empty($user['comment']) && isset($user['comments'])) { - $user['comment'] = $user['comments']; - } - - $field1 = array("string" => preg_replace("/%s/",base64_encode($key),preg_replace("/%USE%/",$use,$useDevice)), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]." [".$user['comment']."]"), "attach" => "style=''"); - $field3 = array("string" => sprintf($editdel,base64_encode($key),base64_encode($key)), - "attach" => "style='width:60px;border-right:0px;text-align:right;'"); - $divlist->AddEntry(array($field1,$field2,$field3)); - - } - - $listhead = "
". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "
"; - - $filter= $_SESSION['glpiDeviceRegex']; - $smarty->assign("devicehead", $listhead); - $smarty->assign("devices", $divlist->DrawList()); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("searchu_image", get_template_path('images/search_user.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info_small.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("device_regex", $filter['device_regex']); - - $display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE)); - return($display); - } - - /* Save device to glpi database - * If this is a new device, create a new entry, else update this entry - */ - function save() - { - if($this->parent->handle->deviceExists($this->EditEntry)){ - $this->parent->handle->updateDevices($this->EditEntry); - }else{ - $this->parent->handle->addDevice($this->EditEntry); - } - - } - - /* this only gets all already defined devices */ - function reload() - { - $this->devices = $this->parent->handle->getDevices(); - ksort($this->devices); - } - - /* This funtions saves all POST variables. - The variable must be in the array $this->EditEntry - */ - function save_object() - { - foreach($_POST as $name => $value){ - - if(preg_match("/wasOnPage_/",$name)){ - $dN = base64_decode($value); - - $device = $this->devices[$dN]; - $type = $device['device_type']; - - if(isset($device['designation'])){ - $str = "designation"; - }else{ - $str = "name"; - } - - if(isset($_POST['useDevice_'.$value])){ - $this->Selected[$type][$device[$str]] = $device; - }else{ - if(isset($this->Selected[$type][$device[$str]])){ - unset($this->Selected[$type][$device[$str]]); - } - } - } - } - - if(is_array($this->EditEntry)){ - foreach($this->EditEntry as $name => $value){ - if(isset($_POST[$name])){ - $this->EditEntry[$name] = $_POST[$name]; - } - - } - } - } - - /* returns the selected devices */ - function getSelected() - { - return($this->Selected); - } - - /* This function checks all created devices. - If you wan't to use device specific checks, - use >>if($attr['device_type']=="moboard")<< to create a device type depending check - */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - $attr = $this->EditEntry; - - if(isset($attr['designation'])){ - $str2 = "designation"; - }else{ - $str2 = "name"; - } - if(empty($attr[$str2])){ - $message[]=(_("You have to specify a valid name for this device.")); - } - - /* Avoid same name twice */ - $devices = ($this->parent->handle->getDevices()); - foreach($devices as $dev){ - - /* Some devices use designation some name for name - */ - if(isset($dev['designation'])){ - $str = "designation"; - }else{ - $str = "name"; - } - - if($dev[$str]==$attr[$str2]){ - - /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */ - if(isset($attr['ID'])){ - if(!(($dev['ID'] == $attr['ID'])&&($dev['device_type']==$attr['device_type']))){ - $message[] = _("This device name is already in use."); - } - }else{ - $message[] = _("This device name is already in use."); - } - } - } - - return($message); - } - - /* This functions displays the template for all available devices - * This function is also used if we create a new device - */ - function editDevice($entry) - { - $smarty = get_smarty(); - - /* Transfer given data to smarty */ - foreach($this->EditEntry as $name => $value){ - $smarty->assign($name,htmlentities(utf8_decode($value))); - } - - /* Set default select boxes, manufacturers ... */ - $smarty->assign("device_type",$entry['device_type']); - - $none = array(0 => _("none")); - $manufacturer = array_merge($none,$this->parent->handle->getEnterprises()); - - $ramtypes = $this->parent->handle->getRAMTypes(); - - $smarty->assign("RAMtypes", $ramtypes); - $smarty->assign("RAMtypeKeys", array_flip($ramtypes)); - - $deviceControlTypes = array_merge($none,$this->parent->handle->getGlpiDeviceControlTypes()); - - $smarty->assign("HDDInterfaceKeys",array_flip($deviceControlTypes)); - $smarty->assign("HDDInterfaces" , $deviceControlTypes); - - $gfxControlTypes = array("0"=>_("None"),"AGP"=>"AGP","PCI"=>"PCI","PCI-X"=>"PCI-X","Other"=>_("Other")); - - $smarty->assign("GFXInterfaceKeys",array_flip($gfxControlTypes)); - $smarty->assign("GFXInterfaces" , $gfxControlTypes); - - $smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer)); - $smarty->assign("FK_glpi_enterprises", $manufacturer); - - $smarty->assign("formats",array("Large","Medium","Micro")); - $smarty->assign("formats",array("Large","Medium","Micro")); - - $smarty->assign("formats",array("Large","Medium","Micro")); - $smarty->assign("formatKeys",array('Grand','Moyen','Micro')); - return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE))); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc b/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc deleted file mode 100644 index 8e676d8ee..000000000 --- a/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc +++ /dev/null @@ -1,170 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email"); - var $objectclasses= array("whatever"); - - var $ui; - - var $editMode = false; - var $Edit_Add = "edit"; - - var $name =""; - var $type =""; - var $address =""; - var $website =""; - var $phonenumber=""; - var $comments =""; - var $deleted =""; - var $fax =""; - var $email =""; - var $ID =-1; - - function glpiManufacturer(&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - $this->ui = get_userinfo(); - } - - function execute() - { - plugin::execute(); - $smarty = get_smarty(); - $display = ""; - - /* Remove enterprise from db */ - if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){ - - $tmp = $this->parent->handle->is_manufacturerUsed($_POST['manufacturer']); - if(count($tmp)){ - - $names = ""; - foreach($tmp as $name){ - $names .= ", ".$name; - } - $names = preg_replace("/^, /","",$names); - $names = trim($names); - if(count($tmp) == 3){ - $names .= " ..."; - } - print_red(sprintf(_("You can't delete this manufacturer, it is still in use by these system(s) '%s'"),$names)); - }else{ - $this->parent->handle->removeEnterprise($_POST['manufacturer']); - } - } - - /* Add new Manufactuer : Open dialog with empty fields */ - if(isset($_POST['add_manu'])){ - $this->editMode = true; - $this->Edit_Add = "add"; - foreach($this->attributes as $atr){ - $this->$atr = ""; - } - } - - /* Edit existing manuatctuerer data */ - if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){ - $this->editMode = true; - $this->Edit_Add = "edit"; - $tmp = $this->parent->handle->getEnterprise($_POST['manufacturer']); - $tmp = $tmp[0]; - foreach($this->attributes as $atr){ - $this->$atr = ""; - } - foreach($this->attributes as $atr){ - if(isset($tmp[$atr])){ - $this->$atr = $tmp[$atr]; - } - } - $this->ID = $_POST['manufacturer']; - } - - /* close Dialog without saving */ - if(isset($_POST['close_manufacturer'])){ - $this->editMode=false; - } - - /* close dialog an save all changes / adds */ - if(isset($_POST['save_manufacturer'])){ - $tmp = array(); - foreach($this->attributes as $attrs){ - $tmp[$attrs]=$this->$attrs; - } - - $allok = true; - if(empty($tmp['name'])){ - print_red(_("Please specify a name.")); - $allok = false; - } - - $attr = $this->parent->handle->getEnterprises(); - - if($this->ID == -1 ){ - if(in_array($tmp['name'],$attr)){ - $allok = false; - print_red(_("Specified name is already in use, please choose another one.")); - } - }else{ - unset($attr[$this->ID]); - if(in_array($tmp['name'],$attr)){ - $allok = false; - print_red(_("Specified name is already in use, please choose another one.")); - } - } - - /* all checks are ok , so save changes */ - if($allok){ - if($this->Edit_Add == "add"){ - $this->parent->handle->addEnterprise($tmp); - $this->editMode=false; - }else{ - $this->parent->handle->updateEnterprise($tmp,$this->ID); - $this->editMode=false; - } - } - } - - /* As long as this war is true, we have to display the edit dialog */ - if($this->editMode == true){ - $this->save_object(); - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - } - - $display.= $smarty->fetch(get_template_path('glpiManufacturerAdd.tpl', TRUE)); - return($display); - } - - - $smarty->assign("Manus", $this->parent->handle->getEnterprises()); - $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises())); - $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE)); - return($display); - } - - /* Save to LDAP */ - function save() - { - } - - function save_object() - { - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = stripslashes($_POST[$attr]); - } - } - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc b/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc deleted file mode 100644 index 049249cd5..000000000 --- a/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc +++ /dev/null @@ -1,807 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= FALSE; - var $attributes= array("ID","name","contact","ramSize","flags_serial","flags_par","flags_usb", - "tech_num","comments","date_mod","location","domain","network","contact_num","serial","otherserial", - "type","is_template","FK_glpi_enterprise","deleted"); - - var $ID ; // Is set if this entry is edited - var $name = ""; // This should be the dn of this entry - var $FK_glpi_enterprise = 0; // Manufacturer id - var $tech_num = ""; // Technical responsible person - var $contact_num = ""; // Contact person - - var $comments = ""; // Comment - - var $type = 0; // printer type id - var $serial = ""; - var $otherserial = ""; - var $ramSize = 0; - var $flags_serial = false; - var $flags_par = false; - var $flags_usb = false; - - var $date_mod = ""; // Modification timestamp - - var $location = 0; // Not used yet - var $domain = 0; // ? Set to 0 - var $network = 0; // ? Set to 0 - - var $is_template = 0; // Used as template ? - var $contact = ""; // Empty - var $deleted = "N"; // Deleted entries should have this set to Y - - var $rename = false; - var $select_type ; - - var $editManufacturer = false; - - /* Not necessary, cause we use mysql databse */ - var $objectclasses= array("whatever"); - - /* Used to remember if this was an account (simply: is this an edited entry) */ - var $initially_was_account = false; - - /* Remember current dialog */ - var $edit_type = false; - var $edit_os = false; - - var $data; - var $handle = NULL; // Glpi class handle used to query database - - var $cur_dialog = NULL; // This contains the sub dialog handle - - var $orig_dn; // To check if dn, has changed - var $ui; // Some GOsa specific user informations - - var $usedDevices = array(); // Which devices are currently selected - var $usedAttachments = array(); // Used Attachments - var $usedCartridges = array(); // Used Cartridges - - var $view_logged = FALSE; - - /* Contructor - Sets default values and checks if we already have an existing glpi account - */ - function glpiPrinterAccount (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - $this->ui= get_userinfo(); - - $this->is_account = false; - - /* Abort class construction, if no db is defined */ - if(!isset($this->config->data['SERVERS']['GLPI'])){ - return; - } - - // Get informations about databse connection - $this->data = $this->config->data['SERVERS']['GLPI']; - - // Abort if mysql extension is missing - if(!is_callable("mysql_connect")){ - return; - } - - // Create handle of glpi class, and check if database connection is established - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - - if(!$this->handle->is_connected){ - return; - } - - // If this dn is already used in database, then get all informations for this entry - if($this->handle->is_printer_account($this->dn)){ - $this->is_account = true; - $tmp = ($this->handle->getPrinterInformations($this->dn)); - - foreach(array("tech_num","FK_glpi_enterprise","type","comments","contact_num","flags_serial","flags_par","flags_usb","ramSize") as $attr){ - $this->$attr = $tmp[0][$attr]; - } - - $atts = $this->handle->getAssignPrinterAttachments($tmp[0]['ID']); - foreach($atts as $attachment){ - $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc']; - } - - $cart= $this->handle->getUsedCartridges($tmp[0]['ID']); - foreach($cart as $key => $cartridge){ - $this->usedCartridges[$key]=$cartridge; - $this->usedCartridges[$key]['status']="exists"; - } - - - }else{ - $this->is_account = false; - } - - /* set defaults */ - $this->name = $this->dn; - $this->orig_dn = $this->dn; - $this->initially_was_account = $this->is_account; - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","printer/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - $smarty->assign("CartridgesACL",$this->getacl("Cartridges")); - - /* Assign smarty defaults - To avoid undefined indexes, if there is an error with the glpi db - */ - foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers", - "Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){ - $smarty->assign($attr,array()); - } - foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){ - $smarty->assign($attr,""); - } - - /* Assign acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Check if there is a glpi database server defined - */ - if(!isset($this->config->data['SERVERS']['GLPI'])){ - print_red(_("There is no server with valid glpi database service.")); - return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE))); - } - - $this->data = $this->config->data['SERVERS']['GLPI']; - - /* Check if we can call mysql_connect - If we can't, there is no the mysql-php extension - */ - if(!is_callable("mysql_connect")){ - print_red(_("Can't connect to glpi database, the php-mysql extension is missing.")); - return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE))); - } - - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - - /* If handle == false, abort - Seems that the server, username and or password is wrong - */ - if(!$this->handle->is_connected){ - print_red(_("Can't connect to glpi database, check configuration twice.")); - return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE))); - } - - /* All checks are ok - Lets handle Posts, templates etc below ... - */ - - $users = $this->handle->getUsers(); - $ldap= $this->config->get_ldap_link(); - - - /* ########################################################################## - * Some tab management - */ - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Show tab dialog headers */ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove inventory"), - _("This server has inventory features enabled. You can disable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Add inventory"), - _("This server has inventory features disabled. You can enable them by clicking below.")); - return ($display); - } - - - /* ########################################################################## - * Printer type management - * Dialog - */ - - /* Rename was requested */ - if(isset($_POST['Rename_PType_OK']) && $this->acl_is_writeable("type")){ - $tmp = $this->handle->getPrinterTypes(); - $allok = true; - foreach($tmp as $id => $name){ - if(trim($name) == trim($_POST['string'])){ - $allok = false; - } - } - if($allok){ - $this->handle->updatePrinterType($_POST['string'],$this->select_type); - $this->rename = false; - }else{ - print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['string'])); - } - } - - /* abort rename - */ - if(isset($_POST['Rename_Cancel'])){ - $this->rename = false; - } - - /* Printer type management - */ - if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){ - $this->dialog = true; - $this->edit_type=true; - } - - /* This closes the printer type editing dialog - */ - if(isset($_POST['close_edit_type'])){ - $this->edit_type=false; - $this->dialog = false; - } - - /* This appends a new printer to our sytem types - */ - if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){ - - $tmp = $this->handle->getPrinterTypes(); - $allok = true; - foreach($tmp as $id => $name){ - if(trim($name) == trim($_POST['type_string'])){ - $allok = false; - } - } - if($allok){ - $this->handle->addPrinterType($_POST['type_string']); - }else{ - print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string'])); - } - } - - /* Remove selected type from our printer types list - */ - if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){ - $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']); - if(count($tmp)){ - $str = ""; - foreach($tmp as $id => $name){ - $str .= $name.", "; - } - $str = preg_replace("/, $/","",$str); - print_red(sprintf(_("Can't delete printer type, it is still in use by '%s'."),$str)); - }else{ - $this->handle->removePrinterType($_POST['select_type']); - } - } - - /* Rename selected printer type to given string - */ - if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename) && $this->acl_is_writeable("type")){ - $this->rename = true; - - $smarty->assign("Method","rename"); - - $tmp = $this->handle->getPrinterTypes(); - - if(isset($_POST['select_type'])){ - $this->select_type = $_POST['select_type']; - } - $smarty->assign("string",$tmp[$this->select_type]); - if(isset($_POST['string'])){ - $smarty->assign("string",$_POST['string']); - } - - $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE)); - return($display); - } - - /* Someone wants to edit the printer types ... - So, lets open a new dialog which provides some buttons to edit the types - */ - if($this->edit_type){ - $smarty->assign("Method","edit"); - $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes()); - $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes())); - $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE)); - return($display); - } - - - /* ########################################################################## - * Edit manufacturers - * Dialog - */ - - /* Open dialog which allows to edit the manufacturers - */ - if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){ - $this->cur_dialog = new glpiManufacturer($this->config,$this->dn); - $this->dialog = true; - $this->editManufacturer =true; - } - - /* Close manufacturer editing dialog - */ - if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){ - $this->dialog = false; - $this->cur_dialog = false; - $this->editManufacturer=false; - } - - - /* ########################################################################## - * Technical responsible person - * Contact person - * Dialog - */ - - /* Show dialog to select a new contact person - * Select a contact person - */ - if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){ - $this->addUser = "contact"; - $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num"); - } - - /* Selecte technical responsible person - */ - if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){ - $this->addUser ="tech"; - $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num"); - } - - /* Abort user selection - */ - $smarty->assign("AbortSelectUser","SelectUserCancel"); - if(isset($_POST['SelectUserCancel'])){ - $this->dialog = false; - $this->addUser =""; - $this->cur_dialog = false; - } - - /* Technical responsible/contact person selected */ - if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")){ - - /* Get posted id */ - $id = base64_decode($_GET['id']); - - /* Check if user is already created in glpi database */ - if(!in_array($id,$users)){ - - /* If this user doesn't exists in glpi db, we must create him */ - $ldap->cat($id, array('cn', 'mail', 'telephoneNumber')); - $atr = $ldap->fetch(); - $tmp = array(); - $use = array( "cn" =>"name", - "mail" =>"email", - "telephoneNumber" =>"phone"); - - /* Create array */ - foreach($use as $gosa => $glpi){ - if(isset($atr[$gosa])){ - $tmp[$glpi]= $atr[$gosa][0]; - } - } - - /* Add this user */ - $this->handle->addUser($tmp,$id); - } - - /* Re-read users */ - $users = ($this->handle->getUsers()); - - /* Get user */ - $tmp = array_flip($users); - $id=$tmp[$id]; - - /* Use user id, close dialog */ - if($this->addUser == "tech"){ - $this->tech_num = $id; - }else{ - $this->contact_num = $id; - } - $this->cur_dialog = false; - $this->dialog= false; - } - - - /* ########################################################################## - * Handle attachments - */ - - /* Attachment pool was closed with use - */ - if(isset($_POST['UseAttachment']) && $this->acl_is_writeable("Attachments")){ - if(count($this->cur_dialog->check())){ - foreach($this->cur_dialog->check() as $msg){ - print_red($msg); - } - }else{ - $this->cur_dialog->save_object(); - $this->usedAttachments = $this->cur_dialog->save(); - $this->cur_dialog = false; - $this->edit_type = false; - } - } - - /* Attachment pool was closed with abort - */ - if(isset($_POST['AbortAttachment'])){ - $this->cur_dialog = false; - $this->edit_type = false; - } - - /* Open Attachment pool to add/edit Attachments - */ - if(isset($_POST['AddAttachment']) && $this->acl_is_writeable("Attachments")){ - $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments); - $this->dialog = true; - } - - /* Remove Attachment from this tab - */ - $once = true; - foreach($_POST as $name => $value){ - if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){ - $once= false; - $name = preg_replace("/^delAttachment_/","",$name); - $entry = preg_replace("/_.*$/","",$name); - if(isset($this->usedAttachments[$entry])){ - unset($this->usedAttachments[$entry]); - } - } - } - if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && $this->acl_is_writeable("Attachments")){ - if(isset($this->usedAttachments[$_POST['Attachments']])){ - unset($this->usedAttachments[$_POST['Attachments']]); - } - } - - /* ########################################################################## - * Printer Cartridge handling - */ - - /* Abort cartridge select dialog - */ - if(isset($_POST['SelectCartridgeCancel'])){ - $this->cur_dialog = false; - $this->edit_type = false; - } - - /* Get selected cartridges and add them to our list - */ - if(isset($_POST['SelectCartridgeSave'])){ - $this->cur_dialog->save_object(); - $carts = $this->cur_dialog->save(); - foreach($carts as $cart){ - $cart['status'] = "new"; - $this->usedCartridges[] = $cart; - } - $this->cur_dialog = false; - $this->edit_type = false; - } - - /* Remove cartridge - */ - if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges'])) && $this->acl_is_writeable("ManageCartridges")){ - - foreach($_POST['Cartridges'] as $cartID){ - - if(isset($this->usedCartridges[$cartID])){ - if($this->usedCartridges[$cartID]['status'] == "exists"){ - $this->usedCartridges[$cartID]['status'] = "deleted"; - }else{ - unset($this->usedCartridges[$cartID]); - } - } - } - } - - /* Open Attachment pool to add/edit Attachments - */ - if(isset($_POST['AddCartridge']) && $this->acl_is_writeable("ManageCartridges")){ - $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type); - $this->dialog = true; - } - - - /* ########################################################################## - * Draw Dialogs - */ - /* if( cur_dialog != false || cur_dialog != NULL) - * There is a dialog which wants to be displayed - */ - if($this->cur_dialog && is_object($this->cur_dialog)){ - $this->cur_dialog->save_object(); - $this->dialog=true; - $this->cur_dialog->parent = &$this; - return($this->cur_dialog->execute()); - }else{ - $this->dialog= false; - } - - - /* ########################################################################## - * Assign listbox / checkbox .... values to smarty - */ - /* Assign smarty defaults */ - foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){ - $smarty->assign($attr,array()); - } - - /* Assign some vars to smarty - */ - foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){ - $smarty->assign($attr,""); - } - - $smarty->assign("comments", $this->comments); - $smarty->assign("flags_serial", $this->flags_serial); - $smarty->assign("flags_par", $this->flags_par); - $smarty->assign("flags_usb", $this->flags_usb); - - /* Assign system types - */ - $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes()); - $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes())); - $smarty->assign("type", $this->type); - - /* Append manufacturers - */ - $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises())); - $smarty->assign("Manufacturers", $this->handle->getEnterprises()); - $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise); - - /* Assign used Attachments - */ - - $divlist = new divSelectBox("glpiAttachmentsList"); - $divlist-> SetHeight(120); - $atts = $this->getUsedAttachments(true); - $downlink = "%s"; - $del_link = ""; - foreach($atts as $id => $attachment){ - $divlist->AddEntry - ( - array( - array("string"=>$attachment['name']), - array("string"=>$attachment['mime']), - array("string"=>sprintf($downlink,$id,$attachment['filename'])), - array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"), - ) - ); - } - - $smarty->assign("AttachmentsDiv" ,$divlist->DrawList()); - $smarty->assign("Attachments", $this->getUsedAttachments()); - $smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments())); - - /* Assign Cartridges - */ - $smarty->assign("Cartridges", $this->getUsedCartridges()); - $smarty->assign("CartridgeKeys", $this->getUsedCartridges(true)); - - /* ########################################################################## - * Assign contact and technical responsible person - */ - if(isset($users[$this->contact_num])){ - $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid')); - $tr = $ldap->fetch(); - $str = ""; - if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } - if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } - if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } - $smarty->assign("contact_num", $str); - }else{ - $smarty->assign("contact_num", _("N/A")); - } - - /* Handle tech person - Assign name ... to smarty, if set - */ - if(isset($users[$this->tech_num])){ - $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid')); - $tr = $ldap->fetch(); - $str = ""; - if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } - if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } - if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } - $smarty->assign("tech_num", $str); - }else{ - $smarty->assign("tech_num", _("N/A")); - } - - /* If theres a cartridge selected, you can't change the printer type. - */ - $disp = true; - - foreach($this->usedCartridges as $cart){ - if($cart['status'] != "deleted"){ - $disp = false; - } - } - if($disp==false){ - $smarty->assign("typeACL", $this->getacl("type",true)); - } - - $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)); - return($display); - } - - function remove_from_parent() - { - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - if($this->initially_was_account){ - $this->handle->removePrinterInformations($this->dn); - new log("remove","printer/".get_class($this),$this->dn); - } - } - - - /* Save data to object */ - function save_object() - { - if(isset($_POST['glpiPrinterFlagsPosted'])){ - plugin::save_object(); - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - } - } - - if(isset($_POST['FK_glpi_enterprise']) && $this->acl_is_writeable("FKglpienterprise")){ - $this->FK_glpi_enterprise = $_POST['FK_glpi_enterprise']; - } - - foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){ - if($this->acl_is_writeable($checkboxes)){ - if(isset($_POST[$checkboxes])){ - $this->$checkboxes = 1; - }else{ - $this->$checkboxes = 0; - } - } - } - } - - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - // if($this->TechnicalResponsible == ""){ - // $message[] = _("Please select a technical responsible person for this entry."); - // } - - return ($message); - } - - /* Save to LDAP */ - function save() - { - if($this->is_account){ - $attrs = array(); - $this->date_mod = date("Y-m-d H:i:s"); - foreach($this->attributes as $attr){ - $attrs[$attr] = $this->$attr; - } - $attrs['name'] = $this->dn; - unset($attrs['ID']); - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - if($this->initially_was_account&&$this->is_account){ - $this->handle->updatePrinterInformations($attrs,$this->dn); - new log("modify","printer/".get_class($this),$this->dn); - }elseif($this->is_account){ - $this->handle->addPrinterInformations($attrs,$this->dn); - new log("create","printer/".get_class($this),$this->dn); - } - $tmp = $this->handle->getPrinterInformations($this->dn); - $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']); - - foreach($this->usedCartridges as $cart){ - if($cart['status'] == "deleted"){ - $this->handle->removeCartridgeFromPrinter($cart['ID']); - }elseif($cart['status'] == "new"){ - $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']); - } - } - } - } - - /* Return used attachments */ - function getUsedAttachments($divlist = false) - { - $atts =$this->handle->getAttachments(); - $ret = array(); - foreach($atts as $entry){ - if(in_array($entry['ID'],$this->usedAttachments)){ - if($divlist){ - $ret[$entry['ID']] = $entry; - }else{ - $cm =""; - if(isset($entry['comment'])){ - $cm=" [".$entry['comment']."]"; - } - if(isset($entry['mime'])){ - $cm.=" -".$entry['mime'].""; - } - - $ret[$entry['ID']]= $entry['name'].$cm; - } - } - } - return($ret); - } - - function getUsedCartridges($flip = false) - { - $ret = array(); - foreach($this->usedCartridges as $key => $value){ - if($value['status'] == "deleted") continue; - if($flip){ - $ret[$key] = $key; - }else{ - $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use']; - } - } - return($ret); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Glpi"), - "plDescription" => _("Printer inventory extension"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 10, - "plSection" => array("administration"), - "plCategory" => array("printer"), - - "plProvidedAcls"=> array( - "flags_serial" => _("Supports serial interface"), - "flags_par" => _("Supports parallel interface"), - "flags_usb" => _("Supports usb interface"), - "tech_num" => _("Technical responsible"), - "comments" => _("Comments"), - "location" => _("Location"), - "contact_num" => _("Contact person"), - "type" => _("Type"), - "FKglpienterprise" => _("Manufacturer"), - - "Attachments" => _("Attachments"), - - "ManageCartridges" => _("Cartridge settings")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc b/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc deleted file mode 100644 index 3d9d63010..000000000 --- a/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc +++ /dev/null @@ -1,298 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array("whatever"); - - var $parent = NULL; // Contains parent class, to access glpi db handle - var $usedCartridges = array(); // IDs of used cartridges for this printer - var $PrinterType = 0; // Specifies which cartridge types are available - - var $cur_dialog = false; - var $cur_sub_dialog = false; - - var $editManufacturer = false; - var $del = 0; - - - function glpiPrinterCartridges (&$config,$dn,$type) - { - plugin::plugin ($config, $dn); - - /* Assign some basic settings */ - $this->ui = get_userinfo(); - if(!isset($_SESSION['glpiCartridgeRegex'])){ - $_SESSION['glpiCartridgeRegex'] = "*"; - } - - /* Only display cartridges for this type of printer */ - $this->PrinterType = $type; - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - $display =""; - $smarty = get_smarty(); - $filter = $_SESSION['glpiCartridgeRegex']; - - /* Filter settings, remove double* */ - if(isset($_GET['search'])){ - $filter = preg_replace("/\*\**/","*",$_GET['search']."*"); - }elseif(isset($_POST['cartridge_regex'])){ - $filter = preg_replace("/\*\**/","*",$_POST['cartridge_regex']); - } - if(empty($filter)) { - $filter = "*"; - } - $_SESSION['glpiCartridgeRegex']= $filter; - - /* Open dialog which allows to edit the manufacturers - */ - if(isset($_POST['edit_manufacturer_cartridges'])){ - $this->cur_sub_dialog = new glpiManufacturer($this->config,$this->dn); - $this->dialog = true; - $this->editManufacturer =true; - } - - /* Close manufacturer editing dialog - */ - if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){ - $this->dialog = false; - $this->cur_sub_dialog = false; - $this->editManufacturer=false; - } - - /* Check poted vars and do the requested job, but only once */ - $only_once = true; - foreach($_POST as $name => $value){ - - /* We have to create a new cartridge */ - if(preg_match("/^newcartridge/",$name)&&($only_once)){ - $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType); - $only_once = false; - } - } - - /* Edit cartridge */ - if(isset($_GET['act'])&&$_GET['act']=="edit_cartridge"){ - $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id'])); - $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$_GET['id']]); - } - - /* remove cartridge */ - if(isset($_GET['act'])&&$_GET['act']=="del_cartridge"){ - /* remove attach from db */ - $this->del = $_GET['id']; - $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id'])); - $smarty->assign("warning", sprintf(_("You're about to delete the glpi cartridge type '%s'."), $val[$this->del]['name'])); - return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE))); - } - - if(isset($_POST['delete_cancel'])){ - $this->del = false; - } - - /* Delete this entry */ - if(isset($_POST['delete_glpi_confirm'])&&($this->del)) { - $tmp = $this->parent->handle->is_cartridgeTypeUsed($this->del); - if(count($tmp)){ - - $str = ""; - foreach($tmp as $id => $name){ - $str .= $name.", "; - } - $str = preg_replace("/, $/","",$str); - - print_red(sprintf(_("You can't delete this cartridge type, it is still in use by this printer(s) '%s'."),$str)); - }else{ - $val = ($this->parent->handle->getCartridgeTypeInformations($this->del)); - $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$this->del]); - $this->cur_dialog->parent = $this->parent; - $this->cur_dialog->remove_from_parent(); - $this->cur_dialog= false; - } - } - - /* Abort edit / add dialog */ - if(isset($_POST['CancelCartridge'])){ - $this->cur_dialog = false; - } - - /* Save changes if check is ok */ - if(isset($_POST['SaveCartridge'])){ - $this->cur_dialog->save_object(); - if(count($this->cur_dialog->check())) { - foreach($this->cur_dialog->check() as $checks){ - print_red($checks); - } - }else{ - $this->cur_dialog->save(); - $this->cur_dialog = false; - } - } - - /* If we have a dialog open, display it */ - if($this->cur_sub_dialog){ - $this->cur_sub_dialog->parent = $this->parent; - $this->cur_sub_dialog->save_object(); - return($this->cur_sub_dialog->execute()); - } - /* If we have a dialog open, display it */ - if($this->cur_dialog){ - $this->cur_dialog->parent = $this->parent; - $this->cur_dialog->save_object(); - return($this->cur_dialog->execute()); - } - - /* Create divlist */ - $divlist = new divlist("glpi devices"); - $divlist->SetPluginMode(); - $divlist->SetEntriesPerPage(0); - $divlist->SetHeader(array( - array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), - array("string" => _("Cartridges"), "attach" => "style=''"), - array("string" => _("Action"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); - - /* Links for editing,adding.... */ - $edit = "%s"; - $editdel = ""._("Edit").""; - $editdel.= ""._("Delete").""; - - /* Checkbox for selection of some cartridges */ - $useCartridge = ""; - - /* Add cartridges */ - $cart = $this->getCartridgeTypes(); - - /* Remove typically error possibilities */ - $f = str_replace("/","\/",$filter); - $f = str_replace(".","\.",$f); - $f = str_replace("*",".*",$f); - - /* Assign cartridges */ - foreach($cart as $key=>$cartr){ - - /* Skip if filter doesn't match*/ - if(!preg_match("/^".$f."$/i",$cartr['cartridgeName'])){ - continue; - } - - /* check if this cartridge is selected */ - $chk = ""; - if(isset($this->usedCartridges[$key])){ - $chk = " checked "; - } - - /* Add fields */ - $field1 = array("string" => preg_replace("/%s/",($key),preg_replace("/%CHECKED%/",$chk,$useCartridge)), - "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($edit,($key),$cartr['cartridgeName']." [".$cartr['cartridgeTypeName']."]"), - "attach" => "style=''"); - $field3 = array("string" => sprintf($editdel,($key),($key)), - "attach" => "style='width:60px;border-right:0px;text-align:right;'"); - - $divlist->AddEntry(array($field1,$field2,$field3)); - - } - - /* Create list header */ - $listhead = "
". - "  ". - "
"; - - /* Tell smarty some vars */ - $filter= $_SESSION['glpiCartridgeRegex']; - $smarty->assign("devicehead", $listhead); - $smarty->assign("devices", $divlist->DrawList()); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("searchu_image", get_template_path('images/search_user.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info_small.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("cartridge_regex", $filter); - - $display.= $smarty->fetch(get_template_path('glpiPrinterCartridges.tpl', TRUE)); - return($display); - } - - /* Save device to glpi database - * If this is a new device, create a new entry, else update this entry - */ - function save() - { - $carts = $this->getCartridgeTypes(); - $ret = array(); - foreach($this->usedCartridges as $key){ - $tmp =array(); - $tmp['date_use'] = date("Y-m-d"); - $tmp['ID'] = -1; - $tmp['type_ID'] = $carts[$key]['cartridgeID']; - $tmp['name'] = $carts[$key]['cartridgeName']; - $tmp['FK_glpi_printers']= -1; - $tmp['type_name'] = $carts[$key]['cartridgeTypeName']; - $ret[$key] = $tmp; - } - return($ret); - } - - /* this only gets all already defined devices */ - function reload() - { - $this->devices = $this->parent->handle->getDevices(); - ksort($this->devices); - } - - /* This funtions saves all POST variables. - The variable must be in the array $this->EditEntry - */ - function save_object() - { - /* Checkbox handling - * Check which checkbox is selected - */ - foreach($_POST as $name => $value){ - if(preg_match("/wasOnPage/",$name)){ - $id = preg_replace("/wasOnPage_/","",$name); - if(isset($_POST['useCartridge_'.$id])){ - $this->usedCartridges[$id]=$id; - }else{ - unset($this->usedCartridges[$id]); - } - } - } - } - - /* This function cehck all created devices if you wan't to create device specific check - use >>if($attr['device_type']=="moboard")<< to create a device type depending check - */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return($message); - } - - /* Return cartriges for our divlist */ - function getCartridgeTypes() - { - $ret = array(); - $ret = $this->parent->handle->getAvailableCartridgeTypes($this->PrinterType); - return($ret); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc b/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc deleted file mode 100644 index e1d86fcb6..000000000 --- a/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc +++ /dev/null @@ -1,337 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array("ID","name","ref","location","type","FK_glpi_enterprise","tech_num","deleted","comments","alarm"); - var $objectclasses = array("whatever"); - - var $printer_type = 0; - - var $additional_printer= array(); - var $needToCatch = true; - - var $parent = NULL; - - var $ID = ""; - var $name = ""; - var $ref = ""; - var $location = ""; - var $type = ""; - var $FK_glpi_enterprise = ""; - var $tech_num = ""; - var $deleted = ""; - var $comments = ""; - var $alarm = ""; - - var $cur_dialog = false; - var $edit_type =false; - - - function glpiPrinterCartridgesEdit (&$config, $dn,$printer_type,$values = NULL ) - { - plugin::plugin ($config, $dn); - foreach($this->attributes as $val){ - if(isset($values[$val])){ - $this->$val = $values[$val]; - }else{ - $this->$val = ""; - } - } - $this->needToCatch = true; - $this->printer_type = $printer_type; - } - - function remove_from_parent() - { - if($this->ID > 0){ - $this->parent->handle->removeCartridgeDropdownType($this->ID); - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Get all currently used/supported printer types for this cartridge type - */ - if($this->needToCatch){ - $this->needToCatch = false; - if(!empty($this->type)){ - $this->additional_printer= $this->parent->handle->getSupportedPrinterTypeIDsForCartridge($this->ID); - } - } - - - - - - - /* Printer type management - */ - if(isset($_POST['edit_type_cartridge'])){ - $this->dialog = true; - $this->edit_type=true; - } - - /* This closes the printer type editing dialog - */ - if(isset($_POST['close_edit_type_cartridge'])){ - $this->edit_type=false; - $this->dialog = false; - } - - /* This appends a new printer to our sytem types - */ - if((isset($_POST['add_cartridge_type']))&&(!empty($_POST['cartridge_type_string']))){ - print "Add"; - $this->parent->handle->addCartridgeDropdownType($_POST['cartridge_type_string']); - } - - /* Remove selected type from our printer types list - */ - if((isset($_POST['del_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))){ - $used = $this->parent->handle->getUsedDropdownTypes($_POST['select_type_cartridge']); - if(!count($used)){ - $this->parent->handle->removeCartridgeDropdownType($_POST['select_type_cartridge']); - }else{ - print_red(_("Can't delete this entry, it is still in use.")); - } - } - - /* Rename selected printer type to given string - */ - /* Update*/ - if((isset($_POST['rename_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))&&(!empty($_POST['cartridge_type_string']))){ - $this->parent->handle->updateCartridgeDropdownType($_POST['cartridge_type_string'],$_POST['select_type_cartridge']); - } - - /* Someone wants to edit the printer types ... - So, lets open a new dialog which provides some buttons to edit the types - */ - if($this->edit_type){ - $smarty->assign("PrinterTypes", $this->parent->handle->getCartridgeTypes()); - $smarty->assign("PrinterTypeKeys", array_flip($this->parent->handle->getCartridgeTypes())); - $display= $smarty->fetch(get_template_path('glpi_edit_cartridge_type.tpl', TRUE)); - return($display); - } - - /* Assign attributes */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Selecte technical responsible person - */ - if(isset($_POST['SelectCartridgeTechPerson'])){ - $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_cartridge_tech_num"); - } - - /* Abort user selection - */ - $smarty->assign("AbortSelectUser","SelectCartridgeUserCancel"); - $smarty->assign("SaveSelectUser" ,"user_cartridge_tech_num"); - if(isset($_POST['SelectCartridgeUserCancel'])){ - $this->dialog = false; - $this->addUser =""; - $this->cur_dialog = false; - } - - /* Start ldap, and get all glpiUsers */ - $ldap = $this->config->get_ldap_link(); - $users = ($this->parent->handle->getUsers()); - - /* Technical responsible/contact person selected - */ - if(isset($_GET['act'])&&($_GET['act']=="user_cartridge_tech_num")){ - - /* Get posted id */ - $id = base64_decode($_GET['id']); - - /* Check if user is already created in glpi database */ - if(!in_array($id,$users)){ - - /* If this user doesn't exists in glpi db, we must create him */ - $ldap->cat($id, array('cn', 'mail', 'telephoneNumber')); - $atr = $ldap->fetch(); - $tmp = array(); - $use = array( "cn" =>"name", - "mail" =>"email", - "telephoneNumber" =>"phone"); - - /* Create array */ - foreach($use as $gosa => $glpi){ - if(isset($atr[$gosa])){ - $tmp[$glpi]= $atr[$gosa][0]; - } - } - - /* Add this user */ - $this->parent->handle->addUser($tmp,$id); - } - - /* Re-read users */ - $users = ($this->parent->handle->getUsers()); - - /* Get user */ - $tmp = array_flip($users); - $id=$tmp[$id]; - - /* Close dialog and use this user */ - $this->tech_num = $id; - $this->cur_dialog = false; - $this->dialog= false; - } - - /* Execute dialog*/ - if($this->cur_dialog){ - $this->cur_dialog->save_object(); - $this->dialog=true; - $this->cur_dialog->parent = &$this; - return($this->cur_dialog->execute()); - }else{ - $this->dialog= false; - } - - /* Create matrix with all possible printer types - */ - $matrix = ""; - $types = $this->parent->handle->getPrinterTypes(); - - /* Specifies number of cols */ - $spalten = 2; - - $spalt = $spalten; - foreach($types as $key => $type){ - $spalt -- ; - - /* Create new row, if cols for this row reached $spalten */ - if($spalt < 0) { - $spalt = $spalten -1; - $matrix .= ""; - } - - /* Avoid deselecting every checkbox */ - if($key == $this->printer_type){ - $matrix.= ""; - }else{ - - /* Cehck checkbox */ - $check = ""; - if(isset($this->additional_printer[$key])){ - $check = " checked "; - } - $matrix.= ""; - } - } - - /* Complete table row, to avoid html errors */ - if($spalt >0){ - while($spalt >0){ - $spalt -- ; - $matrix .=""; - } - } - - $matrix .= "
".$type."".$type." 
"; - - /* Append manufacturers - */ - $smarty->assign("PrinterTypeMatrix", $matrix); - - $smarty->assign("ManufacturerKeys", array_flip($this->parent->handle->getEnterprises())); - $smarty->assign("Manufacturers", $this->parent->handle->getEnterprises()); - $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise); - - $smarty->assign("typeKeys", array_flip($this->parent->handle->getCartridgeTypes())); - $smarty->assign("types", $this->parent->handle->getCartridgeTypes()); - $smarty->assign("type", $this->type); - - /* Handle tech person - Assign name ... to smarty, if set - */ - if(isset($users[$this->tech_num])){ - $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid')); - $tr = $ldap->fetch(); - $str = ""; - if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } - if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } - if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; } - $smarty->assign("tech_num", $str); - }else{ - $smarty->assign("tech_num", _("N/A")); - } - - - $display.= $smarty->fetch(get_template_path('glpiPrinterCartridgesEdit.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - /* Check given values */ - function check(){ - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Avoid choosing an already used name */ - $types = $this->parent->handle->getCartridgeTypeInformations(); - foreach($types as $type){ - if($type['name'] == $this->name){ - if($type['ID'] != $this->ID){ - $message[]= _("The selected name is already in use."); - } - } - } - return $message; - } - - /* Save Post data */ - function save_object() - { - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr= $_POST[$attr]; - } - } - - /* Get selected checkboxes */ - foreach($_POST as $name => $value){ - if(preg_match("/wasOnPage_/",$name)){ - $id = preg_replace("/wasOnPage_/","",$name); - if(isset($_POST['UsePrinterType_'.$id])){ - $this->additional_printer[$id]=$id; - }else{ - if(isset($this->additional_printer[$id])){ - unset($this->additional_printer[$id]); - } - } - } - } - } - - /* Create / Update database with this new infos */ - function save() - { - $tmp = array(); - foreach($this->attributes as $attr){ - $tmp[$attr] = $this-> $attr; - } - $types = array(); - $types = $this->additional_printer; - $types[$this->printer_type]=$this->printer_type; - $this->parent->handle->Add_UpdateCatrigdeType($tmp,$types); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc b/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc deleted file mode 100644 index 7073b12a4..000000000 --- a/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc +++ /dev/null @@ -1,285 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes= array(); - var $objectclasses= array("whatever"); - - var $users = array(); - var $departments = array(); - - var $ui; - - var $PostVarName = ""; - - function glpiSelectUser (&$config, $dn= NULL,$postvar) - { - plugin::plugin ($config, $dn); - - $this->PostVarName = $postvar; - - if(!isset($_SESSION['glpi_user_filter'])){ - $tmp['users_regex'] = "*"; - $tmp['base'] = $this->config->current['BASE']; - $_SESSION['glpi_user_filter'] = $tmp; - } - - $this->ui = get_userinfo(); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if(isset($_POST['depselect'])){ - $_SESSION['glpi_user_filter']['base'] = $_POST['depselect']; - } - - $filter = $_SESSION['glpi_user_filter']; - - /* Filter settings, remove double* */ - if(isset($_GET['search'])){ - $filter['users_regex'] = preg_replace("/\*\**/","*",$_GET['search']."*"); - }elseif(isset($_POST['regex'])){ - $filter['users_regex'] = preg_replace("/\*\**/","*",$_POST['regex']); - } - if(empty($filter['users_regex'])) { - $filter = "*"; - } - - - $s_action=""; - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/dep_back.*/i",$key)){ - $s_action="back"; - }elseif(preg_match("/user_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/dep_home.*/i",$key)){ - $s_action="home"; - } - } - - /* Homebutton is posted */ - if($s_action=="home"){ - $filter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn)); - $filter['base']=(preg_replace("/^[^,]+,/","",$filter['base'])); - } - - if($s_action=="root"){ - $filter['base']=($this->config->current['BASE']); - } - - - /* If Backbutton is Posted */ - if($s_action=="back"){ - $base_back = preg_replace("/^[^,]+,/","",$filter['base']); - $base_back = convert_department_dn($base_back); - - if(isset($this->config->departments[trim($base_back)])){ - $filter['base']= $this->config->departments[trim($base_back)]; - }else{ - $filter['base']= $this->config->departments["/"]; - } - } - - if((isset($_GET['act']))&&($_GET['act']=="dep_open")){ - $entry = base64_decode($_GET['dep_id']); - $filter['base']= ($this->config->departments[$entry]); - } - - $_SESSION['glpi_user_filter'] = $filter; - - $this->reload(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - $divlist = new divlist("glpi users"); - $divlist->SetPluginMode(); - $divlist->SetEntriesPerPage(0); - $divlist->SetHeader(array( - array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), - array("string" => _("Users")." / "._("Departments"), "attach" => "style=''"), - array("string" => _("Use"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); - $linkopen = "%s"; - foreach($this->departments as $key=> $val){ - - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - - $non_empty=""; - $keys= str_replace("/","\/",$key); - foreach($this->config->departments as $keyd=>$vald ){ - if(preg_match("/".$keys."\/.*/",$keyd)){ - $non_empty="full"; - } - } - - $field1 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''"); - $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'"); - $divlist->AddEntry(array($field1,$field2,$field3)); - } - - $useruse = "%s"; - - foreach($this->users as $key=>$user){ - $field1 = array("string" => "user", "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($useruse,base64_encode($key),$user), "attach" => "style=''"); - $field3 = array("string" => sprintf($useruse,base64_encode($key),""._("use").""), - "attach" => "style='width:60px;border-right:0px;text-align:right;'"); - $divlist->AddEntry(array($field1,$field2,$field3)); - - } - - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - - - /* Get all departments within this subtree */ - $this->base = $_SESSION['glpi_user_filter']['base']; - $options =""; - $base = $this->config->current['BASE']; - $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "users", $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH); - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("users"); - $ids = $this->config->idepartments; - foreach($deps as $dep){ - if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){ - $value = $ids[$dep['dn']]; - if ($this->base == $dep['dn']){ - $options.= ""; - } else { - $options.= ""; - } - } - } - - $listhead = "
". - "  ". - "  ". - "  ". - "  ". -"  "._("Base")." ". - " ". - "  ". - "
"; - - - $filter= $_SESSION['glpi_user_filter']; - $smarty->assign("usershead", $listhead); - $smarty->assign("users", $divlist->DrawList()); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("searchu_image", get_template_path('images/search_user.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info_small.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("users_regex", $filter['users_regex']); - - - $display.= $smarty->fetch(get_template_path('glpiSelectUser.tpl', TRUE)); - return($display); - } - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Optionally execute a command after we're done */ -#$this->handle_post_events($mode); - } - - function reload() - { - - $filter= $_SESSION['glpi_user_filter']; - - $base = $filter['base']; - $regex= $filter['users_regex']; - /* NEW LIST MANAGMENT - * We also need to search for the departments - * So we are able to navigate like in konquerer - */ - - $res3= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))","users", - $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT); - - $this->departments= array(); - $tmp = array(); - foreach ($res3 as $value){ - $tmp[strtolower($value['dn']).$value['dn']]=$value; - } - ksort($tmp); - foreach($tmp as $value){ - if(isset($value["description"][0])){ - $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]"; - }else{ - $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0]; - } - } - - /* END NEW LIST MANAGMENT - */ - $ou = get_people_ou(); - - $res2= get_list("(&(|(cn=$regex)(sn=$regex))(objectClass=person))", "users", - $ou.$base, array("cn", "sn", "uid", "givenName", "description"), - GL_SUBSEARCH | GL_SIZELIMIT); - - $tmp = array(); - - foreach($res2 as $val){ - $str = ""; - if(isset($val['givenName'][0])){ - $str .= $val['givenName'][0]; - } - if(isset($val['sn'][0])){ - $str .= $val['sn'][0]; - } - if(isset($val['uid'][0])){ - $str .= $val['uid'][0]; - } - - $tmp[$str] = $val; - } - - ksort($tmp); - $this->users = array(); - foreach($tmp as $value){ - if (isset($value["givenName"][0]) && isset($value["sn"][0])){ - $this->users[$value['dn']]= $value["sn"][0].", ". - $value["givenName"][0]. - " [".$value["uid"][0]."]"; - } else { - $this->users[$value["dn"]]= "[".$value["uid"][0]."]"; - } - } - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/class_goGlpiServer.inc b/plugins/admin/systems/services/glpi/class_goGlpiServer.inc deleted file mode 100644 index 07c07d427..000000000 --- a/plugins/admin/systems/services/glpi/class_goGlpiServer.inc +++ /dev/null @@ -1,109 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goGlpiServer"); - var $attributes = array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword"); - var $StatusFlag = "goGlpiServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goGlpiServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $cn = ""; - var $acl; - - var $goGlpiServerStatus =""; - var $goGlpiAdmin =""; - var $goGlpiDatabase =""; - var $goGlpiPassword =""; - var $view_logged =FALSE; - - - function goGlpiServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("Inventory database"); - } - - - function execute() - { - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation ){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - return($smarty->fetch(get_template_path("goGlpiServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Inventory database service"); - $fields['AllowEdit'] = true; - return($fields); - } - - function check() - { - $message = plugin::check(); - if(empty($this->goGlpiAdmin)){ - $message[]= _("The attribute user is empty or contains invalid characters."); - } - if(empty($this->goGlpiDatabase)){ - $message[]= _("The attribute database is empty or contains invalid characters."); - } - return($message); - } - - - function save_object() - { - if(isset($_POST['goGlpiServer_posted'])){ - plugin::save_object(); - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Inventory database"), - "plDescription" => _("Inventory database")." ("._("Services").")" , - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 93, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - - "goGlpiAdmin" => _("Admin"), - "goGlpiDatabase" => _("Database"), - "goGlpiPassword" => _("Password")) - )); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/glpi/glpi.tpl b/plugins/admin/systems/services/glpi/glpi.tpl deleted file mode 100644 index 0d2f8db36..000000000 --- a/plugins/admin/systems/services/glpi/glpi.tpl +++ /dev/null @@ -1,138 +0,0 @@ - - - - - -
- - -

{t}Generic{/t}

- - - - - - - - - - - - - - - - - - - - - - -
{t}System type{/t} - -{render acl=$typeACL} - -{/render} -{render acl=$typeACL} - -{/render} -
{t}Operating system{/t} - -{render acl=$osACL} - -{/render} -{render acl=$osACL} - -{/render} -
{t}Manufacturer{/t} - -{render acl=$FK_glpi_enterpriseACL} - -{/render} -{render acl=$FK_glpi_enterpriseACL} - -{/render} -
- {t}Contact person{/t} - - {$contact_num}    -{render acl=$contact_numACL} - -{/render} -
{t}Technical responsible{/t}  - - {$tech_num}    -{render acl=$tech_numACL} - -{/render} -
-
- -

{t}Comment{/t}

- - - - -
-{render acl=$commentsACL} - -{/render} -
-
-

 

- - - - - -
-

{t}Installed devices{/t}

- - - - -
-{render acl=$DevicesACL} - -{/render} -{render acl=$DevicesACL} - -{/render} -
- -
-

{t}Attachments{/t}

- - - - -
-{render acl=$AttachmentsACL} - {$AttachmentsDiv} -{/render} -{render acl=$AttachmentsACL} - -{/render} -
-
- -

diff --git a/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl b/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl deleted file mode 100644 index 7d91e50af..000000000 --- a/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl +++ /dev/null @@ -1,78 +0,0 @@ -
-

{t}Attachment{/t}

- - - - - - -
- - - - - - - - - -
- {t}Name{/t} - - -
- {t}Comment{/t} - - -
-
- - - - - - - - - - - - - - - - - -
- {t}File{/t} - - -
- {t}Status{/t} - - {$status} -
- {t}Filename{/t} - - {$filename} -
- {t}Mime-type{/t} - - {$mime} -
-
- - -

 

-
-

- - -

-
- - diff --git a/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl b/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl deleted file mode 100644 index e3a73be8d..000000000 --- a/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl +++ /dev/null @@ -1,54 +0,0 @@ - - - - - -
-
-

- {t}List of attachments{/t} -

-
-
- {$attachmenthead} -
-
-
- {$attachments} - -
-
-
-

[i]{t}Information{/t}

-
-
- {t}This dialog allow you to attach additional objects (like manuals, guides, etc.) to your currently edited computer.{/t} -
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - -
- -
- {$apply} -
-
- - -

 

-
-

- - -

-
diff --git a/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl b/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl deleted file mode 100644 index ab2baa740..000000000 --- a/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl +++ /dev/null @@ -1,54 +0,0 @@ - - - - - -
-
-

- {t}List of devices{/t} -

-
-
- {$devicehead} -
-
-
- {$devices} - -
-
-
-

[i]{t}Information{/t}

-
-
- {t}This dialog allows you to attach a device to your currently edited computer.{/t} -
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - -
- -
- {$apply} -
-
- - -

 

-
-

- - -

-
diff --git a/plugins/admin/systems/services/glpi/glpiManufacturer.tpl b/plugins/admin/systems/services/glpi/glpiManufacturer.tpl deleted file mode 100644 index a15a29aa4..000000000 --- a/plugins/admin/systems/services/glpi/glpiManufacturer.tpl +++ /dev/null @@ -1,15 +0,0 @@ -

{t}Manage manufacturers{/t}

- -
- - - - -

 

-
-

- -

-
diff --git a/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl b/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl deleted file mode 100644 index c5b060d29..000000000 --- a/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl +++ /dev/null @@ -1,89 +0,0 @@ -

{t}Add/Edit manufacturer{/t}

- - - - - -
- - - - - - - - - - - - - -
{t}Name{/t} - - -
{t}Website{/t} - - -
{t}Address{/t} - - -
-
- - - - - - - - - - - - - - - - - -
{t}Phone number{/t} - - -
{t}Fax{/t} - - -
{t}Email{/t} - - -
{t}Comments{/t} - - -
-
- - - - - - - - - - - - - -
-

 

-
-

- - -

-
- - diff --git a/plugins/admin/systems/services/glpi/glpiPrinter.tpl b/plugins/admin/systems/services/glpi/glpiPrinter.tpl deleted file mode 100644 index 46e344678..000000000 --- a/plugins/admin/systems/services/glpi/glpiPrinter.tpl +++ /dev/null @@ -1,159 +0,0 @@ - - - - - -
- - -

{t}Generic{/t}

- - - - - - - - - -
{t}Printer type{/t} - -{render acl=$typeACL} - -{/render} -{render acl=$typeACL} - -{/render} -
{t}Manufacturer{/t} - -{render acl=$FKglpienterpriseACL} - -{/render} -{render acl=$FKglpienterpriseACL} - -{/render} -
-
-

{t}Supported interfaces{/t}

- - - - - - - - - - - - - -
-{render acl=$flags_serialACL} - -{/render} - - {t}Serial{/t} -
-{render acl=$flags_parACL} - -{/render} - - {t}Parallel{/t} -
-{render acl=$flags_usbACL} - -{/render} - - {t}USB{/t} -
- -
-

 

- - - - - -
-

{t}Contacts{/t}

- - - - - - - - - -
{t}Technical responsible{/t}  - - {$tech_num}    -{render acl=$tech_numACL} - -{/render} -
- {t}Contact person{/t} - - {$contact_num}    -{render acl=$contact_numACL} - -{/render} - -
-
-

{t}Attachments{/t}

- - - - -
-{render acl=$AttachmentsACL} - {$AttachmentsDiv} -{/render} -{render acl=$AttachmentsACL} - -{/render} -
-
-

 

- - - - - -
-

{t}Information{/t}

- - - - -
-{render acl=$commentsACL} - -{/render} -
-
-

{t}Installed cartridges{/t}

- - - - -
-{render acl=$CartridgesACL} - -{/render} -{render acl=$CartridgesACL} - -{/render} -{render acl=$CartridgesACL} - -{/render} -
-
diff --git a/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl b/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl deleted file mode 100644 index 5dcd2de13..000000000 --- a/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl +++ /dev/null @@ -1,54 +0,0 @@ - - - - - -
-
-

- {t}List of available cartridge type for this type of printer{/t} -

-
-
- {$devicehead} -
-
-
- {$devices} - -
-
-
-

[i]{t}Information{/t}

-
-
- {t}This dialog allows you to create new types of cartridges, and select one or more types for your printer. Cartridge types depends on the printer type you have selected. For each selected cartridge type there will be a new cartridge created, this allows you to select the same cartridge type for more then one printer.{/t} -
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - -
- -
- {$apply} -
-
- - -

 

-
-

- - -

-
diff --git a/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl b/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl deleted file mode 100644 index 6857efdb3..000000000 --- a/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl +++ /dev/null @@ -1,83 +0,0 @@ - - - - - -
-

{t}Generic{/t}

- - - - - - - - - -
{t}Name{/t} - - -
{t}Reference{/t} - - -
-

 

-

{t}Comments{/t}

- - - - - -
{t}Comment{/t} - - -
-
-

{t}Generic{/t}

- - - - - - - - - - - - - -
{t}Type{/t} - - - -
{t}Manufacturer{/t} - - - -
{t}Technical responsible{/t}  - - {$tech_num}    - -
-

 

- {$PrinterTypeMatrix} -
- -

 

-
-

-   -
-

-
- - diff --git a/plugins/admin/systems/services/glpi/glpiSelectUser.tpl b/plugins/admin/systems/services/glpi/glpiSelectUser.tpl deleted file mode 100644 index 75bf351bd..000000000 --- a/plugins/admin/systems/services/glpi/glpiSelectUser.tpl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - -
-
-

- {t}List of users{/t} -

-
-
- {$usershead} -
-
-
- {$users} - -
-
-
-

[i]{t}Information{/t}

-
-
- {t}This dialog allows you to select a user as technical responsible person.{/t} -
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - -
- -
- {$apply} -
-
- - -

 

-
-

- -

-
diff --git a/plugins/admin/systems/services/glpi/glpi_devices.tpl b/plugins/admin/systems/services/glpi/glpi_devices.tpl deleted file mode 100644 index 44de4fa93..000000000 --- a/plugins/admin/systems/services/glpi/glpi_devices.tpl +++ /dev/null @@ -1,763 +0,0 @@ -{if $device_type=="monitor"} -

 {t}Add/Edit monitor{/t}

-

 

-
- - - - - -
- - - - - - - - - - - - - - - - - -
{t}Name{/t} - - -
{t}Comments{/t} - - -
{t}Manufacturer{/t} - - -
{t}Monitor size{/t} - - {t}Inch{/t} -
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
{t}Integrated microphone{/t} - - {t}Yes{/t} - {t}No{/t} -
{t}Integrated speakers{/t} - - {t}Yes{/t} - {t}No{/t} -
{t}Sub-D{/t} - - {t}Yes{/t} - {t}No{/t} -
{t}BNC{/t} - - {t}Yes{/t} - {t}No{/t} -
{t}Serial number{/t} - - -
{t}Additional serial number{/t} - - -
-
- - -{elseif $device_type=="pci"} - -

 {t}Add/Edit other device{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - -
{t}Manufacturer{/t} - - -
-
- -{elseif $device_type=="power"} - -

 {t}Add/Edit power supply{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Atx{/t} - - {t}Yes{/t} - {t}No{/t} -
{t}Power{/t} - - -
-
-{elseif $device_type=="gfxcard"} - -

 {t}Add/Edit graphic card{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Interface{/t} - - -
{t}Ram{/t} - - -
-
-{elseif $device_type=="control"} - -

 {t}Add/Edit controller{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Interface{/t} - - -
{t}Size{/t} - - {t}Yes{/t} - {t}No{/t} -
-
- -{elseif $device_type=="drive"} - -

 {t}Add/Edit drive{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Speed{/t} - - -
{t}Interface{/t} - - -
{t}Writeable{/t} - - {t}Yes{/t} - {t}No{/t} -
-
- -{elseif $device_type=="hdd"} -

 {t}Add/Edit harddisk{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - - - - - - - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Rpm{/t} - - -
{t}Cache{/t} - - -
{t}Size{/t} - - -
{t}Type{/t} - - -
-
- -{elseif $device_type=="ram"} - -

 {t}Add/Edit memory{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - - - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Frequenz{/t} - - -
{t}Size{/t} - - -
{t}Type{/t} - - -
-
- -{elseif $device_type=="sndcard"} -

 {t}Add/Edit sound card{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Type{/t} - - -
-
-{elseif $device_type=="iface"} -

 {t}Add/Edit network interface{/t}

-

 

-
- - - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}MAC address{/t} - - -
{t}Bandwidth{/t} - - -
-
-{elseif $device_type=="processor"} -

 {t}Add/Edit processor{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Frequence{/t} - - -
{t}Default frequence{/t} - - -
-
- -{elseif $device_type=="moboard"} -

 {t}Add/Edit motherboard{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}Chipset{/t} - - -
-
-{elseif $device_type=="case"} -

 {t}Add/Edit computer case{/t}

-

 

-
- - - - - -
- - - - - - - - - -
{t}Name{/t} - - -
{t}Comment{/t} - - -
-
- - - - - - - - - -
{t}Manufacturer{/t} - - -
{t}format{/t} - - -
-
-{/if} - - -

 

-
-

- - -

-
diff --git a/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl b/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl deleted file mode 100644 index cbc91d95f..000000000 --- a/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl +++ /dev/null @@ -1,21 +0,0 @@ -
-
- - - - - -

 

-
-

- -

-
- - diff --git a/plugins/admin/systems/services/glpi/glpi_edit_os.tpl b/plugins/admin/systems/services/glpi/glpi_edit_os.tpl deleted file mode 100644 index 8e3726451..000000000 --- a/plugins/admin/systems/services/glpi/glpi_edit_os.tpl +++ /dev/null @@ -1,39 +0,0 @@ -

{t}Manage OS-types{/t}

-{if $Method == "edit"} - -
- - - - - -

 

-
-

- -

-
- -{else} -{t}Please enter a new name{/t}  -

 

-

-

- - -
-

- -{/if} - - diff --git a/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl b/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl deleted file mode 100644 index a63e9235e..000000000 --- a/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl +++ /dev/null @@ -1,40 +0,0 @@ -
-{if $Method == "edit"} -
- - - - - -

 

-
-

- -

-
- - -{else} - - {t}Please enter a new name{/t}  -

 

-

-

- - -
-

- - -{/if} - diff --git a/plugins/admin/systems/services/glpi/glpi_edit_type.tpl b/plugins/admin/systems/services/glpi/glpi_edit_type.tpl deleted file mode 100644 index 14a4f5431..000000000 --- a/plugins/admin/systems/services/glpi/glpi_edit_type.tpl +++ /dev/null @@ -1,37 +0,0 @@ -

{t}Manage System-types{/t}

-{if $Method == "edit"} - -
- - - - - -

 

-
-

- -

-
- -{else} -{t}Please enter a new name{/t}  -

 

-

-

- - -
-

- -{/if} diff --git a/plugins/admin/systems/services/glpi/goGlpiServer.tpl b/plugins/admin/systems/services/glpi/goGlpiServer.tpl deleted file mode 100644 index 36a2f2476..000000000 --- a/plugins/admin/systems/services/glpi/goGlpiServer.tpl +++ /dev/null @@ -1,36 +0,0 @@ -

{t}GLPI database information{/t}

- - - - - - - - - - - - - -
{t}Logging DB user{/t}{$must} -{render acl=$goGlpiAdminACL} - -{/render} -
{t}Password{/t} -{render acl=$goGlpiPasswordACL} - -{/render} -
{t}Database{/t}{$must} -{render acl=$goGlpiDatabaseACL} - -{/render} -
- - -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/glpi/remove_glpi.tpl b/plugins/admin/systems/services/glpi/remove_glpi.tpl deleted file mode 100644 index 4106caf06..000000000 --- a/plugins/admin/systems/services/glpi/remove_glpi.tpl +++ /dev/null @@ -1,17 +0,0 @@ -
- {t}Warning{/t} -
-

- {$warning} - {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}Best thing to do before performing this action would be to save the current contents of your MySql database in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- -   - -

diff --git a/plugins/admin/systems/services/gofax/class_goFaxServer.inc b/plugins/admin/systems/services/gofax/class_goFaxServer.inc deleted file mode 100644 index 1e5e04976..000000000 --- a/plugins/admin/systems/services/gofax/class_goFaxServer.inc +++ /dev/null @@ -1,103 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goFaxServer"); - var $attributes = array("goFaxAdmin", "goFaxPassword"); - var $StatusFlag = "goFaxServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goFaxServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $acl; - - var $goFaxAdmin = ""; - var $goFaxPassword = ""; - var $goFaxServerStatus = ""; - var $cn = ""; - var $view_logged =FALSE; - - function goFaxServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("FAX database"); - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* Assign acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation ){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("goFaxServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("FAX database configuration"); - $fields['AllowEdit'] = true; - return($fields); - } - - function check() - { - $message = plugin::check(); - if (empty($this->goFaxAdmin)){ - $message[]= _("The attribute user is empty or contains invalid characters."); - } - if (empty($this->goFaxPassword)){ - $message[]= _("The attribute password is empty or contains invalid characters."); - } - return($message); - } - - - function save_object() - { - if(isset($_POST['goFaxServerPosted'])){ - plugin::save_object(); - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Fax database"), - "plDescription" => _("Fax database")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 99, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "goFaxAdmin" => _("Login name"), - "goFaxPassword" => _("Password")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/gofax/goFaxServer.tpl b/plugins/admin/systems/services/gofax/goFaxServer.tpl deleted file mode 100644 index 27560b3f3..000000000 --- a/plugins/admin/systems/services/gofax/goFaxServer.tpl +++ /dev/null @@ -1,27 +0,0 @@ -

{t}FAX database information{/t}

- - - - - - - - - -
{t}FAX DB user{/t}{$must} -{render acl=$goFaxAdminACL} - -{/render} -
{t}Password{/t}{$must} -{render acl=$goFaxPasswordACL} - -{/render} -
- -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/gofon/class_goFonServer.inc b/plugins/admin/systems/services/gofon/class_goFonServer.inc deleted file mode 100644 index 2e69a849d..000000000 --- a/plugins/admin/systems/services/gofon/class_goFonServer.inc +++ /dev/null @@ -1,182 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goFonServer"); - var $attributes = array("goFonAdmin", "goFonPassword","goFonAreaCode", "goFonCountryCode"); - var $StatusFlag = "goFonServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goFonServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $cn =""; - var $acl; - - var $goFonServerStatus = ""; - var $goFonPassword = ""; - var $goFonAdmin = ""; - var $goFonAreaCode = ""; - var $goFonCountryCode = ""; - var $view_logged =FALSE; - - var $orig_dn = ""; - - function goFonServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("VoIP service"); - - $this->orig_dn = $dn; - } - - - function execute() - { - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - return($smarty->fetch(get_template_path("goFonServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("VoIP service - Asterisk management"); - $fields['AllowEdit'] = true; - return($fields); - } - - function check() - { - $message = plugin::check(); - if (empty($this->goFonAdmin)){ - $message[]= _("The attribute DB user is empty or contains invalid characters."); - } - if (empty($this->goFonPassword)){ - $message[]= _("The attribute password is empty or contains invalid characters."); - } - if (empty($this->goFonAreaCode)){ - $message[]= _("The attribute local dial prefix is empty or contains invalid characters."); - } - if (empty($this->goFonCountryCode)){ - $message[]= _("The attribute country dial prefix is empty or contains invalid characters."); - } - return($message); - } - - - function save_object() - { - if(isset($_POST['goFonServerPosted'])){ - plugin::save_object(); - } - } - - - function allow_remove() - { - /* Check if we are able to remove the asterisk database. If the database is still in use skip */ - if($this->is_account){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer")); - if($ldap->count()){ - - /* Number of entries shown in warning */ - $i = 3; - $str = ""; - while(($attrs = $ldap->fetch()) && $i >= 0){ - $i --; - if(isset($attrs['uid'][0])){ - $str .= $attrs['uid'][0]." "; - }else{ - $str .= $attrs['cn'][0]." "; - } - } - - /* Some entries found */ - if($i != 3){ - return(sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str))); - } - } - } - } - - - function save() - { - goService::save(); - /* Update goFonAccounts if server was is renamed. - Set attribute goFonHomeServer to current dn - */ - if(in_array("goFonServer",$this->objectclasses)){ - if($this->orig_dn != "new" && $this->orig_dn != $this->dn){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(goFonHomeServer=".$this->orig_dn.")(|(objectClass=goFonAccount)(objectClass=goFonConference)))",array("goFonHomeServer")); - $dns = array(); - while($attrs = $ldap->fetch()){ - $dns[] = $attrs['dn']; - } - foreach($dns as $dn){ - $ldap->cd($dn); - $ldap->modify(array("goFonHomeServer" => $this->dn)); - show_ldap_error($ldap->get_error(),sprintf(_("Updating gofon home server failed for '%s'."),$dn)); - } - } - - /* Updated config list of gofon servers */ - if($this->orig_dn == "new" || $this->orig_dn != $this->dn){ - $_SESSION['config']->load_servers(); - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("VoIP service"), - "plDescription" => _("VoIP - asterisk management")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 92, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - - "goFonAdmin" => _("Admin"), - "goFonPassword" => _("Password"), - "goFonAreaCode" => _("Area code"), - "goFonCountryCode"=> _("Country code")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/gofon/goFonServer.tpl b/plugins/admin/systems/services/gofon/goFonServer.tpl deleted file mode 100644 index 14a1603b8..000000000 --- a/plugins/admin/systems/services/gofon/goFonServer.tpl +++ /dev/null @@ -1,43 +0,0 @@ -

{t}VoIP database information{/t}

- - - - - - - - - - - - - - - - - -
{t}Asterisk DB user{/t}{$must} -{render acl=$goFonAdminACL} - -{/render} -
{t}Password{/t}{$must} -{render acl=$goFonPasswordACL} - -{/render} -
{t}Country dial prefix{/t}{$must} -{render acl=$goFonCountryCodeACL} - -{/render} -
{t}Local dial prefix{/t}{$must} -{render acl=$goFonAreaCodeACL} - -{/render} -
- -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/imap/class_goImapServer.inc b/plugins/admin/systems/services/imap/class_goImapServer.inc deleted file mode 100644 index e5681b942..000000000 --- a/plugins/admin/systems/services/imap/class_goImapServer.inc +++ /dev/null @@ -1,187 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goImapServer"); - - /* This class can't be assigned twice so it conflicts with itsself */ - - var $DisplayName = ""; - var $dn = NULL; - var $StatusFlag = "goImapServerStatus"; - var $attributes = array("goImapName","goImapConnect","goImapAdmin","goImapPassword", - "goImapSieveServer","goImapSievePort", - "cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL"); - - var $cn = ""; - - var $goImapName = ""; - var $goImapConnect = ""; - var $goImapAdmin = ""; - var $goImapPassword = ""; - - var $goImapSieveServer = ""; - var $goImapSievePort = ""; - - var $goImapServerStatus = ""; - - var $cyrusImap = false; - var $cyrusImapSSL = false; - var $cyrusPop3 = false; - var $cyrusPop3SSL = false; - var $is_account = false; - var $view_logged =FALSE; - - var $acl; - - var $Actions = array(); - var $conflicts = array("goImapServer","kolab"); - - function goImapServer(&$config,$dn) - { - goService::goService($config,$dn); - - $this->DisplayName = _("IMAP/POP3 service"); - - $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED, - SERVICE_STARTED => SERVICE_STARTED, - SERVICE_RESTARTED=>SERVICE_RESTARTED, - "repair_database"=>_("Repair database")); - - } - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* set new status */ - if(isset($_POST['ExecAction'])){ - if(isset($this->Actions[$_POST['action']])){ - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation) { - if(preg_match("/^".$_POST['action']."$/i",$name)){ - if($this->acl_is_writeable($name)){ - $this->setStatus($_POST['action']); - } - } - } - - } - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - $smarty->assign("Actions",$this->Actions); - $smarty->assign("is_new",$this->dn); - $smarty->assign("is_acc",$this->initially_was_account); - return($smarty->fetch(get_template_path("goImapServer.tpl",TRUE,dirname(__FILE__)))); - } - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("IMAP/POP3 (Cyrus) service"); - $fields['AllowRemove']= true; - $fields['AllowEdit'] = true; - return($fields); - } - - function check() - { - $message = plugin::check(); - if(empty($this->goImapName)){ - $message[] =_("Please specify a server identifier."); - } - if(empty($this->goImapConnect)){ - $message[] =_("Please specify a connect url."); - } - if(empty($this->goImapAdmin)){ - $message[] =_("Please specify an admin user."); - } - if(empty($this->goImapPassword)){ - $message[] =_("Please specify a password for the admin user."); - } - - /* Check connect string */ - if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){ - $message[]= sprintf(_("The imap connect string needs to be in the form '%s'."), - '{server-name:port/options}'); - } - if (!preg_match('/^[0-9]+$/', $this->goImapSievePort)){ - $message[]= _("The sieve port needs to be numeric."); - } - - return ($message); - } - - - function save_object() - { - if(isset($_POST['goImapServerPosted'])){ - plugin::save_object(); - - foreach(array("cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL") as $checkbox) { - - if($this->acl_is_writeable($checkbox)){ - if(!isset($_POST[$checkbox])){ - $this->$checkbox = false; - }else{ - $this->$checkbox = true; - } - } - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("IMAP/POP3"), - "plDescription" => _("IMAP/POP3")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 94, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - "repair_database" => _("Repair database"), - - "goImapName" =>_("Server identifier"), - "goImapConnect" =>_("Connect URL"), - "goImapAdmin" =>_("Admin user"), - "goImapPassword" =>_("Admin password"), - "goImapSievePort" =>_("Sieve port"), - "cyrusImap" =>_("Start IMAP service"), - "cyrusImapSSL" =>_("Start IMAP SSL service"), - "cyrusPop3" =>_("Start POP3 service"), - "cyrusPop3SSL" =>_("Start POP3 SSL service")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/imap/goImapServer.tpl b/plugins/admin/systems/services/imap/goImapServer.tpl deleted file mode 100644 index 17c40092d..000000000 --- a/plugins/admin/systems/services/imap/goImapServer.tpl +++ /dev/null @@ -1,120 +0,0 @@ -

{t}Generic{/t}

- - - - - -
- - - - - - - - - - - - - - - - - - - - - -
{t}Server identifier{/t}{$must} - -{render acl=$goImapNameACL} - -{/render} -
{t}Connect URL{/t}{$must} - -{render acl=$goImapConnectACL} - -{/render} -
{t}Admin user{/t}{$must} - -{render acl=$goImapAdminACL} - -{/render} -
{t}Password{/t}{$must} - -{render acl=$goImapPasswordACL} - -{/render} -
{t}Sieve port{/t}{$must} - -{render acl=$goImapSievePortACL} - -{/render} -
-
- - - - - - - - - - - - - - - - - -
-{render acl=$cyrusImapACL} - -{/render} - {t}Start IMAP service{/t} -
-{render acl=$cyrusImapSSLACL} - -{/render} - {t}Start IMAP SSL service{/t} -
-{render acl=$cyrusPop3ACL} - -{/render} - {t}Start POP3 service{/t} -
-{render acl=$cyrusPop3SSLACL} - -{/render} - {t}Start POP3 SSL service{/t} -
-
-

 

-
-

Action

-{if $is_new == "new"} - {t}The server must be saved before you can use the status flag.{/t} -{elseif !$is_acc} - {t}The service must be saved before you can use the status flag.{/t} -{/if} -
- - - -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/kerberos/class_goKrbServer.inc b/plugins/admin/systems/services/kerberos/class_goKrbServer.inc deleted file mode 100644 index 3eef127f4..000000000 --- a/plugins/admin/systems/services/kerberos/class_goKrbServer.inc +++ /dev/null @@ -1,107 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goKrbServer"); - var $attributes = array("goKrbRealm", "goKrbAdmin","goKrbPassword"); - var $StatusFlag = "goKrbServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goKrbServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $goKrbServerStatus= ""; - var $cn =""; - var $goKrbRealm = ""; - var $goKrbAdmin = ""; - var $goKrbPassword =""; - var $view_logged =FALSE; - - function goKrbServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("Kerberos service"); - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $tmp = $this->plinfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("goKrbServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Kerberos service (kadmin access informations)"); - $fields['AllowEdit'] = true; - return($fields); - } - - function check() - { - $message = plugin::check(); - /* goKrbPassword is a must field, if goKrbServer is used as objectClass */ - if (empty($this->goKrbPassword)){ - $message[]= sprintf(_("The specified kerberos password is empty."), $attr); - } - if (empty($this->goKrbAdmin)){ - $message[]= sprintf(_("The specified kerberos admin is empty."), $attr); - } - if (empty($this->goKrbRealm)){ - $message[]= sprintf(_("The specified kerberos realm is empty."), $attr); - } - - return($message); - } - - - function save_object() - { - if(isset($_POST['goKrbServerPosted'])){ - plugin::save_object(); - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Kerberos"), - "plDescription" => _("Kerberos access information")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 95, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "goKrbRealm" => _("Realm"), - "goKrbAdmin" => _("Admin"), - "goKrbPassword" => _("Password")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/kerberos/goKrbServer.tpl b/plugins/admin/systems/services/kerberos/goKrbServer.tpl deleted file mode 100644 index a0234ebe1..000000000 --- a/plugins/admin/systems/services/kerberos/goKrbServer.tpl +++ /dev/null @@ -1,34 +0,0 @@ -

{t}Kerberos kadmin access{/t}

- - - - - - - - - - - - - -
{t}Kerberos Realm{/t}{$must} -{render acl=$goKrbRealmACL} - -{/render} -
{t}Admin user{/t}{$must} -{render acl=$goKrbAdminACL} - -{/render} -
{t}Password{/t}{$must} -{render acl=$goKrbPasswordACL} - -{/render} -
-

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/kiosk/class_goKioskService.inc b/plugins/admin/systems/services/kiosk/class_goKioskService.inc deleted file mode 100644 index 287ed9e36..000000000 --- a/plugins/admin/systems/services/kiosk/class_goKioskService.inc +++ /dev/null @@ -1,245 +0,0 @@ -DisplayName = _("Kiosk profile service"); - $this->baseDir = $this->config->search('environment', 'kioskpath',array('menu','tabs')); - $this->server_path = preg_replace("/%cn/", $this->cn, $this->server_path); - - /* Load list of profiles and check if they still exists */ - if ($this->baseDir == ""){ - print_red(_("There is no KIOSKPATH defined in your gosa.conf. Can't manage kiosk profiles!")); - }else{ - $this->gotoKioskProfiles = array(); - if(isset($this->attrs['gotoKioskProfile']) && is_array($this->attrs['gotoKioskProfile'])){ - for($i = 0 ; $i < $this->attrs['gotoKioskProfile']['count']; $i ++){ - $url = $this->attrs['gotoKioskProfile'][$i]; - $this->server_path = preg_replace("/\/[^\/]*$/","",$url); - $name= preg_replace("/^.*\//","",$url); - $this->gotoKioskProfiles[] = array('url' => $url , - 'name' => $name , - 'initial' =>TRUE, - 'exists' => file_exists($this->baseDir."/".$name)); - } - } - } - } - - - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*/".$this->cn."/*))",array("cn")); - $str =""; - $cnt = 3; - while($cnt && $attrs = $ldap->fetch()){ - $str .= $attrs['cn'][0].", "; - $cnt --; - } - $str = preg_replace("/, $/","",$str); - if($cnt != 3){ - print_red(sprintf(_("Can not remove kiosk profile service, it is currently in use by following user(s) : %s."),$str)); - }else{ - goService::remove_from_parent(); - } - } - - - function execute() - { - /* log actions */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Add new kiosk profile - * in profile directory ($this->baseDir); - */ - if((isset($_POST['profileAdd']))&&(isset($_FILES['newProfile']))){ - $file = $_FILES['newProfile']; - if(!file_exists($this->baseDir.$file['name'])){ - $tmp = array( - 'url' => "" , - 'name' => $file['name'] , - 'initial' => FALSE, - 'tmp_name'=> $file['tmp_name'], - 'content' => file_get_contents($file['tmp_name']), - 'exists' => TRUE); - $this->gotoKioskProfiles[] = $tmp; - } - if(!is_writeable($this->baseDir)){ - print_red(sprintf(_("Can't save new kiosk profiles, possibly permission denied for folder: '%s'."),$this->baseDir)); - } - } - - $only_once = true; - foreach($_POST as $name => $value){ - - if((preg_match("/^delkiosk_/",$name))&&($only_once)){ - - /* Get id, name and path */ - $only_once = false; - $id = preg_replace("/^delkiosk_/","",$name); - $id = preg_replace("/_.*$/","",$id); - $name = $this->gotoKioskProfiles[$id]['name']; - $filename = $this->baseDir."/".$name; - - /* check if profile is still in use */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*".$name.")",array("cn","uid","gotoKioskProfile")); - $used_by = ""; - $cnt = 3; - while(($attrs = $ldap->fetch()) && ($cnt)){ - $cnt --; - $check = preg_replace("/^.*\//i","",$attrs['gotoKioskProfile'][0]); - if($check == $name){ - $used_by .= $attrs['cn'][0].", "; - } - } - $used_by = preg_replace("/, $/","",$used_by); - if(!empty($used_by)){ - print_red(sprintf(_("Can't remove kioks profile, it is still in use by the following objects '%s'."),$used_by)); - }else{ - if($this->gotoKioskProfiles[$id]['initial']){ - $res = @unlink($filename); - if(!$res){ - if(!is_writeable($filename)){ - print_red(sprintf(_("Can't delete '%s'. Error was: permission denied."), $filename)); - } - if(!file_exists($filename)){ - print_red(sprintf(_("Can't delete '%s'. Error was: file doesn't exist."), $filename)); - } - } - unset($this->gotoKioskProfiles[$id]); - } - } - } - } - - /* Display list of profiles */ - $divlist = new divSelectBox("KioskProfiles"); - $divlist -> SetHeight (300); - foreach($this->gotoKioskProfiles as $key => $val ){ - $divlist->AddEntry(array( - array("string"=>"".$val['name'].""), - array("string"=>"" , - "attach"=>" style='border-right: 0px;width:24px; text-align:center;' ") - )); - } - - /* Assign all existing profiles to smarty */ - $smarty->assign("divlist",$divlist->DrawList()); - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - $smarty->assign("server_path",$this->server_path); - return($smarty->fetch(get_template_path("goKioskService.tpl",TRUE,dirname(__FILE__)))); - } - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Kiosk profile service"); - $fields['AllowEdit'] = TRUE; - $fields['AllowStart'] = false; - $fields['AllowStop'] = false; - $fields['AllowRestart'] = false; - return($fields); - } - - function check() - { - $message = plugin::check(); - return($message); - } - - function save() - { - goService::save(); - - $method = $this->server_path."/"; - $method = preg_replace("/\/\/*$/","/",$method); - $this->attrs['gotoKioskProfile'] = array(); - foreach($this->gotoKioskProfiles as $profile){ - if(!$profile['initial']){ - - $contents = $profile['content']; - $path = $this->baseDir."/".$profile['name']; - $fp = @fopen($path,"w"); - if(!$fp){ - print_red(_("Can't save new kiosk profiles, possibly permission denied for folder")." : ",$path); - }else{ - fwrite($fp,$contents,strlen($contents)); - $this->attrs['gotoKioskProfile'][] = $method.$profile['name']; - } - @unlink($profile['tmp_name']); - }else{ - $this->attrs['gotoKioskProfile'][] = $method.$profile['name']; - } - } - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - show_ldap_error($ldap->get_error(),_("Wohl kaum")); - } - - - function save_object() - { - if(isset($_POST['goKioskPosted'])){ - goService::save_object(); - if(isset($_POST['server_path'])){ - $this->server_path = get_post("server_path"); - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Kiosk"), - "plDescription" => _("Kiosk profile management")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 100, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array() - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/kiosk/goKioskService.tpl b/plugins/admin/systems/services/kiosk/goKioskService.tpl deleted file mode 100644 index f81230464..000000000 --- a/plugins/admin/systems/services/kiosk/goKioskService.tpl +++ /dev/null @@ -1,24 +0,0 @@ -

 

- - - -{t}Server path{/t}  -
-
-{$divlist} - - - -

 

-
- -   - -
- - - diff --git a/plugins/admin/systems/services/kolab/class_servKolab.inc b/plugins/admin/systems/services/kolab/class_servKolab.inc deleted file mode 100644 index 7d31ff58d..000000000 --- a/plugins/admin/systems/services/kolab/class_servKolab.inc +++ /dev/null @@ -1,415 +0,0 @@ -"Eins ist toll", "zwei"=>"Zwei ist noch besser"); - - var $postfix_mydomain = ""; - var $cyrus_admins = ""; - var $postfix_mydestination = ""; - var $postfix_mynetworks = "127.0.0.1/8"; - var $postfix_enable_virus_scan = "TRUE"; - var $postfix_relayhost = ""; - var $postfix_mxrelayenabled = true; - var $postfix_allow_unauthenticated = "FALSE"; - var $cyrus_quotawarn = "80"; - var $kolabFreeBusyFuture = "1"; - var $k = "kolab"; - var $cyrus_imap = "TRUE"; - var $cyrus_pop3 = "FALSE"; - var $cyrus_imaps = "TRUE"; - var $cyrus_pop3s = "TRUE"; - var $cyrus_sieve = "TRUE"; - var $apache_allow_unauthenticated_fb = "TRUE"; - var $proftpd_ftp = "FALSE"; - var $apache_http = "TRUE"; - var $kolabHost = array(); - var $orig_cn = ""; - var $view_logged = FALSE; - - var $attributes = array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k", - "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http", - "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture", - "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", - "cyrus_quotawarn"); - var $objectclasses = array("top", "kolab"); - - /* Serverservice vars */ - var $conflicts = array("goImapServer","goMailServer"); - var $DisplayName = "Kolab mail service"; - var $StatusFlag = ""; - - function servkolab(&$config, $dn = NULL, $parent= NULL) - { - /* Setting the hostname and tell this Plugin that we are the kolab extension*/ - $this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn); - $this->dn = "k=kolab,".$config->current['BASE']; - - /* Load variables, if given*/ - plugin::plugin($config, $this->dn); - - /* Copy needed attributes */ - foreach($this->attributes as $val) { - $name = preg_replace('/_/', '-', $val); - if (isset($this->attrs["$name"][0])) { - $this->$val = $this->attrs["$name"][0]; - } - } - - /* Toggle relayhost */ - $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost); - $this->postfix_relayhost = preg_replace("/[\[\]]/","",$this->postfix_relayhost); - - /* Is this Server a member of the Kolab extension or not ?*/ - if(isset($this->attrs['kolabHost'])) { - $this->kolabHost= $this->attrs['kolabHost']; - unset($this->kolabHost['count']); - } - $this->is_account = false; - $this->initially_was_account = false; - foreach($this->kolabHost as $host){ - if($this->hostname == $host){ - $this->is_account = true; - $this->initially_was_account = true; - } - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /*************** - Variable initialisation - ***************/ - - $smarty = get_smarty(); - $display = ""; - $ldap = $this->config->get_ldap_link(); - - - /* Assemble free/busy string */ - $edit = sprintf('', - $this->kolabFreeBusyFuture); - $fbfuture = sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit); - - /* Assemble quota string */ - $edit = sprintf('', - $this->cyrus_quotawarn); - $quotastr = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit); - - /*************** - Assign informations to smarty - ***************/ - - /* Set relayhost and if we have MX lookup enabled*/ - if($this->postfix_mxrelayenabled) { - $smarty->assign("RelayMxSupportCheck"," checked "); - } else { - $smarty->assign("RelayMxSupportCheck",""); - } - - /* Set acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Initialize all attributes, that were submitted */ - foreach($this->attributes as $val) - { - /* Tell smarty which variables we are useing */ - $smarty->assign($val, $this->$val); - if (($this->$val != "FALSE") && !empty($this->$val)){ - $smarty->assign($val."Check", "checked"); - } else { - $smarty->assign($val."Check", ""); - } - } - - $smarty->assign("fbfuture", $fbfuture); - $smarty->assign("quotastr", $quotastr); - - /* Load Template */ - $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE)); - return ($display); - } - - function remove_from_parent() - { - - /* Remove status flag, it is not a memeber of - this->attributes, so ensure that it is deleted too */ - if(!empty($this->StatusFlag)){ - $this->attrs[$this->StatusFlag] = array(); - } - - - /* Only walk through following code, if this host - was a member of the kolab hosts, else skip this */ - if(!$this->initially_was_account){ - return; - } - - /* !!! Don't use "cn" in this function - hostname -> the initial name of the host - cn -> is the new name of the host, in case that it was renamed. - */ - - $ldap = $this->config->get_ldap_link(); - $this->dn = "k=kolab,".$this->config->current['BASE']; - - /* We can't simply remove the whole entry, it is possible that there are - some other hosts assigned to this object. - So, first of all check if we are the last host entry within the host - : Remove k=kolab entry - if we aren't alone, only remove host name from hosts entry and save */ - /* Are we alone? Remove complete entry... */ - - /* Check if we are definitly in kolabHosts */ - if(!in_array_ics($this->hostname,$this->kolabHost)) { - return; - } - - /* Integration check, not translated because they can't pop up at all, only for debug */ - if(count($this->kolabHost) == 0){ - print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists."); - return; - } - if(!isset($this->hostname) || (empty($this->hostname))){ - print_red("The required attribute hostname seams to empty."); - } - - /* Our hostname is in kolabHosts and there is a only one entry - = we are the last host entry, delete k=kolab entry */ - if (count($this->kolabHost) == 1){ - - /* Remove complete entry */ - $ldap->rmdir ($this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn)); - } else { - - /* Only modify kolabHost */ - $hosts= array(); - foreach ($this->kolabHost as $host){ - if($host != $this->hostname){ - $hosts[]= $host; - } - } - $attrs= array('kolabHost' => $hosts); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn)); - } - - new log("remove","server/".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"); - } - - - function save_object() - { - if (isset($_POST['kolabtab'])){ - plugin::save_object(); - - - foreach($this->attributes as $attr){ - if(($this->acl_is_writeable(preg_replace("/_/","",$attr))) && (isset($_POST[$attr]))){ - $this->$attr = $_POST[$attr]; - } - } - - /* Save checkboxes */ - foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated", - "cyrus_imap", "cyrus_pop3", "cyrus_imaps", - "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", - "proftpd_ftp", "apache_http") as $cb){ - - if($this->acl_is_writeable(preg_replace("/_/","",$cb))){ - if (isset($_POST[$cb])){ - $this->$cb= "TRUE"; - } else { - $this->$cb= "FALSE"; - } - } - } - - /* Toggell relay check */ - if($this->acl_is_writeable("postfixmxrelayenabled")){ - $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']); - } - } - - } - - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(($this->kolabFreeBusyFuture=="")) { - $message[] = _("Future days in Free/Busy settings must be set."); - }elseif(!is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){ - $message[] = _("Future days in Free/Busy settings must be a positive value."); - } - - if(!is_int((int)($this->cyrus_quotawarn))) { - $message[] = _("The given Quota settings value must be a number."); - }elseif(!(($this->cyrus_quotawarn<=100)&&($this->cyrus_quotawarn>=0))){ - $message[] = _("Please choose a value between 1 and 100 for Quota settings."); - }elseif(strcasecmp($this->cyrus_quotawarn,(int)$this->cyrus_quotawarn)){ - $message[] = _("Future days must be a value."); - } - - if(empty($this->postfix_mynetworks)) { - $message[] = _("No SMTP privileged networks set."); - } - - /*if(empty($this->postfix_relayhost)) { - $message[] = _("No SMTP smarthost/relayhost set."); - } - */ - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - /* Set ldap connection */ - $ldap = $this->config->get_ldap_link(); - - /* Open current dn*/ - $this->dn = "k=kolab,".$this->config->current['BASE']; - - /* Adapt relayhost */ - $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost); - if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){ - $this->postfix_relayhost= "[".$this->postfix_relayhost."]"; - } - - /* Check if this server was renamed, in this case we have to remove old cn first*/ - if($this->hostname != $this->cn){ - $tmp = array(); - if(in_array_ics($this->hostname,$this->kolabHost)){ - foreach($this->kolabHost as $host){ - if($host != $this->hostname){ - $tmp[] = $host; - } - } - $this->kolabHost = $tmp; - } - } - - /* Add ourselves to the list of kolabHost's if needed */ - if (!in_array_ics($this->cn,$this->kolabHost)){ - $this->kolabHost[]= $this->cn; - } - - /* Call parents save to prepare $this->attrs */ - plugin::save(); - - /* Save or modify? */ - $ldap->cat($this->dn, array('dn')); - if (!$ldap->fetch()){ - $mode= "add"; - } else { - $mode= "modify"; - } - - /* Do attribute conversion */ - foreach ($this->attrs as $key => $value){ - if (preg_match('/_/', $key)){ - $old_key= $key; - $key= preg_replace('/_/', '-', $key); - $this->attrs[$key]= $value; - unset($this->attrs[$old_key]); - } - } - /* Add kolab hosts */ - $this->attrs['kolabHost']= $this->kolabHost; - - /* Perform LDAP action */ - $ldap->cd($this->dn); - $this->cleanup();; - $ldap->$mode($this->attrs); - - if($mode == "add"){ - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/kolab with dn '%s' failed."),$this->dn)); - - /* 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"); - } - } else { - $this->handle_post_events("add"); - } - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Kolab mail service"); - $fields['AllowEdit'] = true; - return($fields); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Kolab"), - "plDescription" => _("Kolab mail service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 85, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "postfixmydomain" => _("Postfix mydomain") , - "postfixmydestination" => _("My destination") , - "cyrusadmins" => _("Cyrus admins") , - "proftpdftp" => _("FTP FreeBusy service") , - "postfixmynetworks" => _("SMTP privileged networks") , - "postfixenablevirusscan" => _("Enable virus scan") , - "postfixrelayhost" => _("Relayhost") , - "postfixmxrelayenabled" => _("Enable MX lookup for relayhost"), - "apachehttp" => _("HTTP FreeBusy service") , - "apacheallowunauthenticatedfb" => _("Allow unauthenticated free busy"), - "postfixallowunauthenticated" => _("Accept Internet Mail") , - "cyrusimap" => _("IMAP service") , - "kolabFreeBusyFuture" => _("kolabFreeBusyFuture") , - "cyruspop3" => _("POP3 service") , - "cyrusimaps" => _("IMAP/SSL service") , - "cyruspop3s" => _("POP3/SSL service") , - "cyrussieve" => _("Sieve service") , - "cyrusquotawarn" => _("Quota settings")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/kolab/servkolab.tpl b/plugins/admin/systems/services/kolab/servkolab.tpl deleted file mode 100644 index ec83b7801..000000000 --- a/plugins/admin/systems/services/kolab/servkolab.tpl +++ /dev/null @@ -1,249 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - -
{t}Generic{/t}
{t}Postfix mydomain{/t} - -{render acl=$postfixmydomainACL} - -{/render} -
{t}Postfix mydestination{/t} - -{render acl=$postfixmydestinationACL} - -{/render} -
{t}Cyrus admins{/t} - -{render acl=$cyrusadminsACL} - -{/render} -
-

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{t}Services{/t}
-{render acl=$cyruspop3ACL} - -{/render} - - -
-{render acl=$cyruspop3sACL} - -{/render} - - -
-{render acl=$cyrusimapACL} - -{/render} - - -
-{render acl=$cyrusimapsACL} - -{/render} - - -
-{render acl=$cyrussieveACL} - -{/render} - - -
-{render acl=$proftpdftpACL} - -{/render} - - -
-{render acl=$apachehttpACL} - -{/render} - - -
-{render acl=$postfixenablevirusscanACL} - -{/render} - - -
- -

 

-
- - - - - - - - -
- {t}Quota settings{/t} -
-{render acl=$cyrusquotawarnACL} - {$quotastr} -{/render} -
- -
- - - - - - - - - - - -
- {t}Free/Busy settings{/t} -
-{render acl=$apacheallowunauthenticatedfbACL} - {t}Allow unauthenticated downloading of Free/Busy information{/t} -{/render} -
-{render acl=$kolabFreeBusyFutureACL} - {$fbfuture} -{/render} -
- -

 

-
- - - - - - - -
- {t}SMTP privileged networks{/t} -
-
-{render acl=$postfixmynetworksACL} - -{/render} -
- ( {t}Enter multiple values, seperated with{/t} , ) -
- - -

 

-
- - - - - - - - - - - - -
- {t}SMTP smarthost/relayhost{/t} -
-{render acl=$postfixrelayhostACL} - -{/render} - -
-   -{render acl=$postfixrelayhostACL} - -{/render} -
- - -

 

-
- - - - - - - - - -
- {t}Accept Internet Mail{/t} -
-{render acl=$postfixallowunauthenticatedACL} - -{/render} - -
- - -
- - - -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/ldap/class_goLdapServer.inc b/plugins/admin/systems/services/ldap/class_goLdapServer.inc deleted file mode 100644 index c16df0387..000000000 --- a/plugins/admin/systems/services/ldap/class_goLdapServer.inc +++ /dev/null @@ -1,97 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goLdapServer"); - var $attributes = array("goLdapBase"); - var $StatusFlag = "goLdapServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goLdapServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $cn = ""; - var $goLdapServerStatus = ""; - var $goLdapBase = ""; - var $view_logged =FALSE; - - function goLdapServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("LDAP service"); - } - - - function execute() - { - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - return($smarty->fetch(get_template_path("goLdapServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("LDAP Service"); - $fields['AllowEdit'] = true; - return($fields); - } - - - - function check() - { - $message = plugin::check(); - if(empty($this->goLdapBase)){ - $message[] = _("The given base is empty or contains invalid characters."); - } - return($message); - } - - - function save_object() - { - if(isset($_POST['goLdapServerPosted'])){ - plugin::save_object(); - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Ldap"), - "plDescription" => _("Ldap")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 96, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "goLdapBase" => _("Ldap base")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/ldap/goLdapServer.tpl b/plugins/admin/systems/services/ldap/goLdapServer.tpl deleted file mode 100644 index 24e181771..000000000 --- a/plugins/admin/systems/services/ldap/goLdapServer.tpl +++ /dev/null @@ -1,13 +0,0 @@ -

{t}LDAP service{/t}

-{t}LDAP URI{/t}{$must} -{render acl=$goLdapBaseACL} - -{/render} - -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/log/class_gosaLogServer.inc b/plugins/admin/systems/services/log/class_gosaLogServer.inc deleted file mode 100644 index cade0e243..000000000 --- a/plugins/admin/systems/services/log/class_gosaLogServer.inc +++ /dev/null @@ -1,108 +0,0 @@ -DisplayName = _("GOsa MySQL logging service"); - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("gosaLogServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("GOsa MySQL logging service"); - $fields['AllowEdit'] = true; - $fields['AllowStart'] = FALSE; - $fields['AllowStop'] = FALSE; - $fields['AllowRestart'] = FALSE; - return($fields); - } - - - function check() - { - $message = plugin::check(); - if (empty($this->goLogDBUser)){ - $message[]= sprintf_("The attribute user is empty or contains invalid characters."); - } - if (empty($this->goLogDBPassword)){ - $message[]= sprintf_("The attribute password is empty or contains invalid characters."); - } - if (empty($this->goLogDB)){ - $message[]= sprintf_("The attribute database is empty or contains invalid characters."); - } - return($message); - } - - - function save_object() - { - if(isset($_POST['gosaLogServerPosted'])){ - plugin::save_object(); - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("GOsa logging service"), - "plDescription" => _("GOsa logging service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 98, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "goLogDB" => _("Database"), - "goLogDBUser" => _("User"), - "goLogDBPassword" => _("Password"), - "viewEntries" => _("Allow view of entries on this server")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/log/gosaLogServer.tpl b/plugins/admin/systems/services/log/gosaLogServer.tpl deleted file mode 100644 index 7dd032a36..000000000 --- a/plugins/admin/systems/services/log/gosaLogServer.tpl +++ /dev/null @@ -1,35 +0,0 @@ -

{t}GOsa logging database{/t}

- - - - - - - - - - - - - -
{t}Database user{/t}{$must} -{render acl=$goLogDBUserACL} - -{/render} -
{t}Password{/t}{$must} -{render acl=$goLogDBPasswordACL} - -{/render} -
{t}Database{/t}{$must} -{render acl=$goLogDBACL} - -{/render} -
- -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/mail/class_goMailServer.inc b/plugins/admin/systems/services/mail/class_goMailServer.inc deleted file mode 100644 index 742249ef7..000000000 --- a/plugins/admin/systems/services/mail/class_goMailServer.inc +++ /dev/null @@ -1,725 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goMailServer"); - - /* This class can't be assigned twice so it conflicts with itsself */ - var $DisplayName = ""; - var $dn = NULL; - var $StatusFlag = "goMailServerStatus"; - var $attributes = array("description","postfixHeaderSizeLimit", - "postfixMailboxSizeLimit","postfixMessageSizeLimit", - "postfixMyDestinations","postfixMyDomain","postfixMyhostname", - "postfixMyNetworks","postfixRelayhost","postfixTransportTable", - "postfixSenderRestrictions","postfixRecipientRestrictions"); - - var $goMailServerStatus ; - var $postfixHeaderSizeLimit = 0; - var $postfixMailboxSizeLimit = 0; - var $postfixMessageSizeLimit = 0; - var $postfixMyDestinations = array(); - var $postfixMyDomain = ""; - var $postfixMyhostname = ""; - var $postfixMyNetworks = array(); - var $postfixRelayhost = ""; - var $postfixTransportTable = array(); - var $postfixSenderRestrictions = array(); - var $postfixRecipientRestrictions = array(); - var $description = ""; - var $RestrictionFilters = array(); - var $TransportProtocols = array(); - var $Actions = array(); - var $cn = ""; - var $conflicts = array("goMailServer","kolab"); - var $view_logged =FALSE; - - function goMailServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("Mail smtp service (Postfix)"); - - $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED, - SERVICE_STARTED => SERVICE_STARTED, - SERVICE_RESTARTED=>SERVICE_RESTARTED); - - /* Fill RestrictionFilters TransportProtocols from external hooks */ - $str = $this->config->data['TABS']['SERVERSERVICE']; - $this->TransportProtocols =array("smtp"=>"SMTP"); - $this->RestrictionFilters = array("FILTER"=>"FILTER"); - foreach(array("ADDITIONALRESTRICTIONFILTERS"=>"RestrictionFilters", - "ADDITIONALPROTOCOLLS" =>"TransportProtocols") as $file => $var){ - if(isset($this->config->data['MAIN'][$file])){ - $file = $this->config->data['MAIN'][$file]; - if((isset($file)) && is_readable($file)){ - $tmp = file_get_contents($file); - $tmp2= split("\n",$tmp); - foreach($tmp2 as $entry){ - if(empty($entry)) continue; - if(preg_match("/:/",$entry)){ - $tmp3 = split(":",$entry); - $r = $this->$var; - $r[$tmp3[0]]=$tmp3[1]; - $this->$var = $r; - }else{ - $r = $this->$var; - $r[$entry] =$entry; - $this->$var = $r; - } - } - } - } - } - - - /* Get postfix my networks */ - $this->postfixMyNetworks = array(); - $tmp = array(); - if(isset($this->attrs['postfixMyNetworks'][0])){ - $tmp = split(",",$this->attrs['postfixMyNetworks'][0]); - foreach($tmp as $str){ - if(!empty($str)){ - $this->postfixMyNetworks[base64_encode($str)] = $str; - } - } - } - - - /* Create full name */ - if(isset($this->attrs['postfixMyDomain'][0])){ - $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0]; - } - - - /* Get postfix my domains */ - $this->postfixMyDestinations = array(); - if(isset($this->attrs['postfixMyDestinations'][0])){ - unset($this->attrs['postfixMyDestinations']['count']); - foreach($this->attrs['postfixMyDestinations'] as $str){ - $this->postfixMyDestinations[base64_encode($str)] = $str; - } - } - - - /* Get transport tables */ - $tmp = array(); - $this->postfixTransportTable = array(); - if(isset($this->attrs['postfixTransportTable'])){ - $tmp = array(); - unset($this->attrs['postfixTransportTable']['count']); - foreach($this->attrs['postfixTransportTable'] as $entry){ - - //0: offshore.vip.ms-europa.lhsystems.com smtp:172.28.0.2 - - $Number = preg_replace('/^([^:]+):.*$/', '\\1', $entry); - $Rest = trim(preg_replace("/^[0-9]*:/","",$entry)); - - $Protocol_Destination = preg_replace("/^.*\ /","",$Rest); - $Source = preg_replace("/\ .*$/","",$Rest); - - $Protocol = preg_replace ('/^([^:]+):.*$/', '\\1' ,trim($Protocol_Destination)); - $Destination = preg_replace ('/^[^:]+:(.*)$/', '\\1' ,trim($Protocol_Destination)); - - $Destination = preg_replace ("/[\[\]]/","",$Destination); - - $tmp[$Number]['src'] = $Source; - $tmp[$Number]['dst'] = $Destination; - $tmp[$Number]['prt'] = $Protocol; - } - ksort($tmp); - foreach($tmp as $entry){ - $this->postfixTransportTable[] = $entry; - } - } - - - /* Get sender restrictions */ - $tmp = array(); - $this->postfixSenderRestrictions = array(); - if(isset($this->attrs['postfixSenderRestrictions'])){ - unset($this->attrs['postfixSenderRestrictions']['count']); - foreach($this->attrs['postfixSenderRestrictions'] as $entry){ - $nr = preg_replace("/:.*$/","",$entry); - $rest= trim(preg_replace("/^[^:]+:/","",$entry)); - $src = preg_replace("/ .*$/","",$rest); - $rest= preg_replace("/^[^ ]+ /","",$rest); - $dst = preg_replace("/^.* /","",$rest); - $prt = preg_replace("/ .*$/","",$rest); - - $tmp[$nr]['src'] = $src; - $tmp[$nr]['dst'] = $dst; - $tmp[$nr]['filter'] = $prt; - } - ksort($tmp); - foreach($tmp as $entry){ - $this->postfixSenderRestrictions[] = $entry; - } - } - - - /* Get sender restrictions */ - $tmp = array(); - $this->postfixRecipientRestrictions = array(); - if(isset($this->attrs['postfixRecipientRestrictions'])){ - unset($this->attrs['postfixRecipientRestrictions']['count']); - foreach($this->attrs['postfixRecipientRestrictions'] as $entry){ - $nr = preg_replace("/:.*$/","",$entry); - $rest= trim(preg_replace("/^[^:]+:/","",$entry)); - $src = preg_replace("/ .*$/","",$rest); - $rest= preg_replace("/^[^ ]+ /","",$rest); - $dst = preg_replace("/^.* /","",$rest); - $prt = preg_replace("/ .*$/","",$rest); - - $tmp[$nr]['src'] = $src; - $tmp[$nr]['dst'] = $dst; - $tmp[$nr]['filter'] = $prt; - } - ksort($tmp); - foreach($tmp as $entry){ - $this->postfixRecipientRestrictions[] = $entry; - } - } - - } - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $delAr = array( - "TranslationDel_"=>"TranslationDel", - "SenderRestrictDel_"=>"SenderRestrictDel", - "RecipientRestrictDel_"=>"RecipientRestrictDel"); - - $once = true; - $s_action = ""; - $s_entry = ""; - - /* Check posts for some intruductions */ - foreach($_POST as $name => $value){ - foreach($delAr as $preg => $type){ - if((preg_match("/^".$preg."/",$name)) && ($once)){ - $once = false; - $s_action = $type; - $s_entry = preg_replace("/^".$preg."/","",$name); - $s_entry = preg_replace("/_[xy]$/","",$s_entry); - } - } - - - if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeablei("postfixTransportTableACL"))){ - $once = false; - $key = preg_replace("/^TranslationUp_/","",$name); - $key = preg_replace("/_[xy]$/","",$key); - $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ; - } - if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){ - $once = false; - $key = preg_replace("/^TranslationDown_/","",$name); - $key = preg_replace("/_[xy]$/","",$key); - $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ; - } - if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){ - $once = false; - $key = preg_replace("/^SenderRestrictUp_/","",$name); - $key = preg_replace("/_[xy]$/","",$key); - $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ; - } - if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){ - $once = false; - $key = preg_replace("/^SenderRestrictDown_/","",$name); - $key = preg_replace("/_[xy]$/","",$key); - $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ; - } - if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){ - $once = false; - $key = preg_replace("/^RecipientRestrictUp_/","",$name); - $key = preg_replace("/_[xy]$/","",$key); - $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ; - } - if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){ - $once = false; - $key = preg_replace("/^RecipientRestrictDown_/","",$name); - $key = preg_replace("/_[xy]$/","",$key); - $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ; - } - } - - - /* Add delete my network entry */ - if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){ - $str = $_POST['NewString_postfixMyNetworks']; - $this->postfixMyNetworks[base64_encode($str)] = $str; - } - - if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){ - foreach($_POST['Select_postfixMyNetworks'] as $str ){ - unset($this->postfixMyNetworks[$str]); - } - } - - - /* Add delete my domain entry */ - if($this->acl_is_writeable("postfixMyDestinations")){ - if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){ - $str = $_POST['NewString_postfixMyDestinations']; - $this->postfixMyDestinations[base64_encode($str)] = $str; - } - - if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){ - foreach($_POST['Select_postfixMyDestinations'] as $str ){ - unset($this->postfixMyDestinations[$str]); - } - } - } - - - /* Add sender restriction */ - if($this->acl_is_writeable("postfixSenderRestrictions")){ - if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){ - unset($this->postfixSenderRestrictions[$s_entry]); - } - - if(isset($_POST['AddpostfixSenderRestrictions'])){ - $src = $_POST['Source_postfixSenderRestrictions']; - $dst = $_POST['Destination_postfixSenderRestrictions']; - $Filter = $_POST['SenderRestrictionFilter']; - $tmp['src'] = $src; - $tmp['dst'] = $dst; - $tmp['filter'] = $Filter; - $this->postfixSenderRestrictions[] = $tmp; - } - } - - - /* Add sender restriction */ - if($this->acl_is_writeable("postfixRecipientRestrictions")){ - if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){ - unset($this->postfixRecipientRestrictions[$s_entry]); - } - - if(isset($_POST['AddpostfixRecipientRestrictions'])){ - $src = $_POST['Source_postfixRecipientRestrictions']; - $dst = $_POST['Destination_postfixRecipientRestrictions']; - $Filter = $_POST['RecipientRestrictionFilter']; - $tmp['src'] = $src; - $tmp['dst'] = $dst; - $tmp['filter'] = $Filter; - $this->postfixRecipientRestrictions[] = $tmp; - } - } - - /* Handle transports */ - if($this->acl_is_writeable("postfixTransportTable")){ - if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){ - unset($this->postfixTransportTable[$s_entry]); - } - - if(isset($_POST['AddpostfixTransportTable'])){ - $src = trim($_POST['Source_postfixTransportTable']); - $dst = trim($_POST['Destination_postfixTransportTable']); - $prt = trim($_POST['TransportProtocol']); - - if((!empty($src)) && (!empty($dst))){ - if(preg_match("/:/",$dst)){ - $tmp = split("\:",$dst); - $port = trim($tmp[1]); - $ip = trim($tmp[0]); - - if((is_ip($ip)) && (is_numeric($port))){ - $dst = "[".$ip."]:".$port; - } - } - if(is_ip($dst)){ - $dst = "[".$dst."]"; - } - $tmp2 ['src'] = $src; - $tmp2 ['dst'] = $dst; - $tmp2 ['prt'] = $prt; - - $this->postfixTransportTable[] = $tmp2; - } - } - } - - /* Set attributes */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - - /* Create divList for translation tables */ - $divTranslation = new divSelectBox("TransportProtocols"); - $divTranslation->SetHeight(90); - foreach($this->postfixTransportTable as $key => $entry){ - $img = ""; - - if($key != 0 && $this->acl_is_writeable("postfixTransportTable")){ - $img.= " "; - }else{ - $img.= ""; - } - if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){ - $img.= " "; - }else{ - $img.= ""; - } - - if($this->acl_is_writeable("postfixTransportTable")){ - $img.= " "; - } - $field1 = array("string"=> $entry['src']); - $field2 = array("string"=> $entry['dst']); - $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'"); - $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'"); - $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,)); - } - $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList()); - - - /* Create divList for sender restrictions */ - $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions"); - $DivSenderRestrict->SetHeight(90); - foreach($this->postfixSenderRestrictions as $key => $entry){ - $img =""; - - if($key != 0 && $this->acl_is_writeable("postfixSenderRestrictions")){ - $img.= " "; - }else{ - $img.= ""; - } - if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){ - $img.= " "; - }else{ - $img.= ""; - } - - if($this->acl_is_writeable("postfixSenderRestrictions")){ - $img.= " "; - } - - $field1 = array("string"=> $entry['src']); - $field2 = array("string"=> $entry['dst']); - $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'"); - $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'"); - $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,)); - } - $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList()); - - - /* Create divList for translation tables */ - $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions"); - $DivRecipientRestrict->SetHeight(90); - - foreach($this->postfixRecipientRestrictions as $key => $entry){ - $img = ""; - if($key != 0 && $this->acl_is_writeable("postfixRecipientRestrictions")){ - $img.= " "; - }else{ - $img.= ""; - } - if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){ - $img.= " "; - }else{ - $img.= ""; - } - - if($this->acl_is_writeable("postfixRecipientRestrictions")){ - $img.= " "; - } - $field1 = array("string"=> $entry['src']); - $field2 = array("string"=> $entry['dst']); - $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'"); - $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'"); - $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,)); - } - $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList()); - - - /* set new status */ - if(isset($_POST['ExecAction'])){ - if(isset($this->Actions[$_POST['action']])){ - $this->setStatus($_POST['action']); - } - } - - - $smarty->assign("is_new", $this->dn); - $smarty->assign("is_acc", $this->initially_was_account); - $smarty->assign("TransportProtocols", $this->TransportProtocols); - $smarty->assign("Actions", $this->Actions); - $smarty->assign("RestrictionFilters", $this->RestrictionFilters); - $smarty->assign("postfixTransportTable" , $this->getTransports()); - $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions()); - $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions()); - - return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__)))); - } - - - /* return transports formated for select box */ - function getTransports() - { - $ret = array(); - foreach($this->postfixTransportTable as $key => $vals){ - $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst']; - } - return($ret); - } - - - /* return sender restriction formated for select box */ - function getSenderRestrictions() - { - $ret = array(); - foreach($this->postfixSenderRestrictions as $key => $vals){ - $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst']; - } - return($ret); - } - - - /* return recipient restriction formated for select box */ - function getRecipientRestrictions() - { - $ret = array(); - foreach($this->postfixRecipientRestrictions as $key => $vals){ - $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst']; - } - return($ret); - } - - - /* Return list entry */ - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Mail smtp service (Postfix)"); - $fields['AllowEdit'] = true; - return($fields); - } - - - function save() - { - $this->postfixMyDomain = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname); - $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname); - - plugin::save(); - - /* Fix transport table*/ - $i = 0 ; - $this->attrs['postfixTransportTable'] = array(); - foreach($this->postfixTransportTable as $key => $entry){ - $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst']; - $i ++; - } - - - /* Fix sender restrictions */ - $i = 0; - $this->attrs['postfixSenderRestrictions'] =array(); - foreach($this->postfixSenderRestrictions as $key => $entry){ - $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; - $i ++; - } - - - /* Fix recipient restrictions */ - $i = 0; - $this->attrs['postfixRecipientRestrictions'] =array(); - foreach($this->postfixRecipientRestrictions as $key => $entry){ - $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst']; - $i ++; - } - - - /* Fix mydomains */ - $this->attrs['postfixMyDestinations'] = array(); - foreach($this->postfixMyDestinations as $entry){ - $this->attrs['postfixMyDestinations'][] =$entry; - } - - - /* Fix mydomains */ - if(count($this->postfixMyNetworks)){ - $this->attrs['postfixMyNetworks'] = ""; - foreach($this->postfixMyNetworks as $entry){ - $this->attrs['postfixMyNetworks'] .=$entry.","; - } - $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']); - }else{ - $this->attrs['postfixMyNetworks'] = array(); - } - - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/mail with dn '%s' failed."),$this->dn)); - if($this->initially_was_account){ - $this->handle_post_events("modify"); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - } - - - function check() - { - $message =plugin::check(); - - if(!is_numeric($this->postfixHeaderSizeLimit)){ - $message[] = _("Please specify a numeric value for header size limit."); - } - - if(!is_numeric($this->postfixMailboxSizeLimit)){ - $message[] = _("Please specify a numeric value for mailbox size limit."); - } - - if(!is_numeric($this->postfixMessageSizeLimit)){ - $message[] = _("Please specify a numeric value for message size limit."); - } - - return $message; - } - - - /* Combine new array */ - function combineArrays($ar0,$ar1,$ar2) - { - $ret = array(); - if(is_array($ar0)) - foreach($ar0 as $ar => $a){ - $ret[]=$a; - } - if(is_array($ar1)) - foreach($ar1 as $ar => $a){ - $ret[]=$a; - } - if(is_array($ar2)) - foreach($ar2 as $ar => $a){ - $ret[]=$a; - } - return($ret); - } - - - function getpos($atr,$attrs) - { - $i = 0; - foreach($attrs as $attr => $name) { - $i++; - if($attr == $atr){ - return($i); - } - } - - return(-1); - } - - - /* TRansports the geiven Arraykey one position up*/ - function ArrayUp($atr,$attrs) - { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == 1))){ - $before = array_slice($attrs,0,($pos-2)); - $mitte = array_reverse(array_slice($attrs,($pos-2),2)); - $unten = array_slice($attrs,$pos); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - - /* TRansports the geiven Arraykey one position up*/ - function ArrayDown($atr,$attrs) - { - $ret = $attrs; - $pos = $this->getpos($atr,$attrs) ; - $cn = count($attrs); - if(!(($pos == -1)||($pos == $cn))){ - $before = array_slice($attrs,0,($pos-1)); - $mitte = array_reverse(array_slice($attrs,($pos-1),2)); - $unten = array_slice($attrs,($pos+1)); - $ret = array(); - $ret = $this->combineArrays($before,$mitte,$unten); - } - return($ret); - } - - function save_object() - { - plugin::save_object(); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - $source_o = new goMailServer($this->config,$source['dn']); - foreach(array("postfixMyDomain","postfixMyhostname","postfixMyNetworks","postfixTransportTable","postfixSenderRestrictions","postfixRecipientRestrictions","postfixMyDestinations") as $attr){ - $this->$attr = $source_o->$attr; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Mail smtp (Postfix)"), - "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 98, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "postfixMyhostname" => _("Visible full qualified hostname"), - "description" => _("Description"), - "postfixHeaderSizeLimit" => _("Header size limit"), - "postfixMailboxSizeLimit" => _("Max mailbox size"), - "postfixMessageSizeLimit" => _("Max message size"), - "postfixMyDestinations" => _("Domains to accept mail for"), - "postfixMyNetworks" => _("Local networks"), - "postfixRelayhost" => _("Relay host"), - "postfixTransportTable" => _("Transport table"), - "postfixSenderRestrictions" => _("Restrictions for sender"), - "postfixRecipientRestrictions"=> _("Restrictions for recipient")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/mail/goMailServer.tpl b/plugins/admin/systems/services/mail/goMailServer.tpl deleted file mode 100644 index a17d08f04..000000000 --- a/plugins/admin/systems/services/mail/goMailServer.tpl +++ /dev/null @@ -1,225 +0,0 @@ -

{t}Generic{/t}

- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
{t}Visible full qualified hostname{/t} - -{render acl=$postfixMyhostnameACL} - -{/render} -
{t}Max mail header size{/t} - -{render acl=$postfixMyhostnameACL} -  {t}KB{/t} -{/render} -
{t}Max mailbox size{/t} - -{render acl=$postfixMailboxSizeLimitACL} -  {t}KB{/t} -{/render}
{t}Max message size{/t} - -{render acl=$postfixMessageSizeLimitACL} -  {t}KB{/t} -{/render} -
{t}Relay host{/t} - -{render acl=$postfixRelayhostACL} - -{/render} -
-
- - - - -
- {t}Local networks{/t}
-{render acl=$postfixMyNetworksACL} - -{/render} -{render acl=$postfixMyNetworksACL} - -{/render} -{render acl=$postfixMyNetworksACL} - -{/render} -{render acl=$postfixMyNetworksACL} - -{/render} -
-
-

 

-

{t}Domains and routing{/t}

-
- - - - -
- {t}Domains to accept mail for{/t}
-{render acl=$postfixMyDestinationsACL} - -{render acl=$postfixMyDestinationsACL} - -{/render} -{render acl=$postfixMyDestinationsACL} - -{/render} -{render acl=$postfixMyDestinationsACL} - -{/render} -
-
- - - - -
- {t}Transports{/t}
-{render acl=$postfixTransportTableACL} - {$Div_postfixTransportTable} -{/render} - -{render acl=$postfixTransportTableACL} - -{/render} -{render acl=$postfixTransportTableACL} - -{/render} -{render acl=$postfixTransportTableACL} - -{/render} -{render acl=$postfixTransportTableACL} - -{/render} -
-
-

 

-

{t}Restrictions{/t}

-
- - - - -
- {t}Restrictions for sender{/t}
-{render acl=$postfixSenderRestrictionsACL} - {$Div_postfixSenderRestrictions} -{/render} -{render acl=$postfixSenderRestrictionsACL} - -{/render} -{render acl=$postfixSenderRestrictionsACL} - -{/render} -{render acl=$postfixSenderRestrictionsACL} - -{/render} -{render acl=$postfixSenderRestrictionsACL} - -{/render} -
-
- - - - -
- {t}Restrictions for recipient{/t}
-{render acl=$postfixRecipientRestrictionsACL} - {$Div_postfixRecipientRestrictions} -{/render} -{render acl=$postfixRecipientRestrictionsACL} - -{/render} -{render acl=$postfixRecipientRestrictionsACL} - -{/render} -{render acl=$postfixRecipientRestrictionsACL} - -{/render} -{render acl=$postfixRecipientRestrictionsACL} - -{/render} -
-
- -

 

-
-

Action

-{if $is_new == "new"} - {t}The server must be saved before you can use the status flag.{/t} -{elseif !$is_acc} - {t}The service must be saved before you can use the status flag.{/t} -{/if} -
- - - -

 

-
- -   - -

- diff --git a/plugins/admin/systems/services/nfs/class_servNfs.inc b/plugins/admin/systems/services/nfs/class_servNfs.inc deleted file mode 100644 index 1386de1fc..000000000 --- a/plugins/admin/systems/services/nfs/class_servNfs.inc +++ /dev/null @@ -1,267 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array("description","type","charset","path","option", "volume"); - var $objectclasses = array("whatever"); - var $is_account = true; - - var $name =""; // Name of - var $description =""; // description - var $type =""; // Type FS/Samba/NCP - var $charset =""; // charset - var $host =""; // hostname - var $types =array(); // Array Types NFS/Samba/NCP/netatalk - var $charsets =array(); // Array with charsets - var $path =""; // Path - var $volume =""; // Volume - var $option =""; // Options - var $is_edit =false; - var $create_mount_init = false; //mount entry set for this entry (while editing)? - var $create_mount = false; //save mount entry - - var $parent = NULL; - var $view_logged = FALSE; - - function servnfs (&$config, $parent,$entry= false,$mount =false) - { - $this->parent = $parent; - $dn = $parent->dn; - plugin::plugin ($config, $dn); - - $this->types = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP"); - if($dn){ - $this->host = substr($dn, 3, strpos($dn, ',')-3); - } - - $this->charsets = array(); - - if(!file_exists(CONFIG_DIR."/encodings")){ - print_red(sprintf(_("The file '%s/encodings' does not exist, can't get supported charsets."),CONFIG_DIR)); - }else{ - if(!is_readable(CONFIG_DIR."/encodings")){ - print_red(sprintf(_("Can't read '%s/encodings', please check permissions."),CONFIG_DIR)); - }else{ - $fp = fopen(CONFIG_DIR."/encodings","r"); - $i = 100; - while(!feof($fp)&&$i){ - $i -- ; - $str = trim(fgets($fp,256)); - - /* Skip comments */ - if(!preg_match("/^#/",$str)){ - $arr = split("\=",$str); - if(count($arr)==2){ - $this->charsets[$arr[0]]=$arr[1]; - } - } - } - } - } - - if($entry){ - list($this->name, $this->description, $this->type, $this->charset, - $this->path, $this->option, $this->volume)= split("\|",$entry."|"); - $this->is_edit = true; - - }else{ - $this->attributes[] = "name"; - } - - - $this->create_mount_init = $mount; - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - - $smarty->assign("charsets" ,$this->charsets); - $smarty->assign("types" ,$this->types); - - /* attrs to smarty*/ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - $tmp = $this->parent->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->parent->getacl($name)); - } - - $smarty->assign("name",$this->name); - if($this->is_edit){ - $smarty->assign("nameACL", preg_replace("/w/","",$this->parent->getacl("name"))); - } - $smarty->assign("allow_mounts", $this->parent->allow_mounts); - $smarty->assign("mount_checked", ""); - - $smarty->assign("appleMountsACL", $this->getacl("appleMounts")); - - if (($this->type == "netatalk") || ($this->type == "NFS")) { - if ($this->create_mount_init) { - $smarty->assign("mount_checked", "checked"); - } else { - $tmp = split(",", $this->dn); - $clip = $tmp[0] . ",ou=servers,ou=systems,"; - $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip)); - switch ($this->type) { - case "netatalk" : { - $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn; - break; - } - case "NFS" : { - $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn; - break; - } - default : { - continue; - } - } - $ldap = $this->config->get_ldap_link(); - $ldap->cat($mountdn, array('dn')); - $attrs = $ldap->fetch(); - if (count($attrs) > 0) { - $smarty->assign("mount_checked", "checked"); - } - } - } - - $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE)); - return($display); - } - - function remove_from_parent() - { - /* This cannot be removed... */ - } - - - /* Save data to object */ - function save_object() - { - if(isset($_POST['servnfs_posted'])){ - - foreach($this->attributes as $name){ - if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){ - $this->$name = $_POST[$name]; - } - } - - if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) { - $this->create_mount = true; - } else { - $this->create_mount = false; - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - // fixme : a check for the path ? ? - if(empty($this->path)){ - $message[]=_("Please specify a valid path for your setup."); - } - - // only 0-9a-z - if(!$this->is_edit){ - if(!preg_match("/^[a-z0-9\._äüö]*$/ui",$this->name)){ - $message[]=_("Please specify a valid name for your share."); - } - if(empty($this->name)){ - $message[]=_("Please specify a name for your share."); - } - } - - if(!empty($this->description) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->description)){ - $message[]=_("Description contains invalid characters."); - } - - if(!empty($this->volume) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->volume)){ - $message[]=_("Volume contains invalid characters."); - } - - if(preg_match("/\|/",$this->path)){ - $message[]=_("Path contains invalid characters."); - } - - if(!empty($this->option) && preg_match("/^[^a-z0-9\._äüö,=\+ -]*$/ui",$this->option)){ - $message[]=_("Option contains invalid characters."); - } - - /* remove a / at the end of the path, we neither need it there nor - * do we want to check for it later. - */ - if(substr($this->path, -1, 1) == '/') { - $this->path=substr($this->path, 0, -1); - } - - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=goShareServer)", array("goExportEntry")); - while($test = $ldap->fetch()){ - if($test['dn']==$this->dn) - continue; - if(isset($test['goExportEntry'])){ - foreach($test['goExportEntry'] as $entry){ - $tmp = split("\|",$entry); - if($tmp[0] == $this->name){ - $message[]="Name already in use"; - } - } - } - } - return ($message); - } - - - /* Save to LDAP */ - function save() - { - /* Everything seems perfect, lets - generate an new export Entry - */ - - $s_return = ""; - - $s_return.= $this->name."|"; - $s_return.= $this->description."|"; - $s_return.= $this->type."|"; - $s_return.= $this->charset."|"; - $s_return.= $this->path."|"; - $s_return.= $this->option."|"; - $s_return.= $this->volume; - - return(array($this->name=>$s_return)); - } - - function should_create_mount() { - return $this->create_mount; - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/nfs/servnfs.tpl b/plugins/admin/systems/services/nfs/servnfs.tpl deleted file mode 100644 index 9fb70a5f4..000000000 --- a/plugins/admin/systems/services/nfs/servnfs.tpl +++ /dev/null @@ -1,144 +0,0 @@ -

 {t}Edit share{/t}

- - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- {t}Name{/t} {$must} - -{render acl=$nameACL} - -{/render} -
- {t}Description{/t} - -{render acl=$descriptionACL} - -{/render} -
- {t}Path{/t} / {t}Volume{/t} - -{render acl=$pathACL} - -{/render} -
-
{t}Server{/t}
-
-{render acl=$volumeACL} - -{/render} -
-
- - - - - - - - - - - - - - - -
- - {t}Type{/t} - -{render acl=$typeACL} - -{/render} - {if $allow_mounts == TRUE} -

-{render acl=$netatalkmountACL} - -{/render} - -
-
- {/if} - - {literal} - - {/literal} -
- {t}Codepage{/t} - -{render acl=$charsetACL} - -{/render} -
- {t}Option{/t} - -{render acl=$optionACL} - -{/render} -
-
-

 

-
- - -
- diff --git a/plugins/admin/systems/services/ntp/class_goNtpServer.inc b/plugins/admin/systems/services/ntp/class_goNtpServer.inc deleted file mode 100644 index b179ae95b..000000000 --- a/plugins/admin/systems/services/ntp/class_goNtpServer.inc +++ /dev/null @@ -1,147 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goNtpServer"); - var $attributes = array("goTimeSource"); - var $StatusFlag = "goNtpServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goNtpServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $goTimeSource = array(); - var $goNtpServerStatus= ""; - var $acl; - var $cn = ""; - var $view_logged =FALSE; - - function goNtpServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("Time service (NTP)"); - - /* Load arrays */ - $tmp = array(); - if (isset($this->attrs['goTimeSource'])){ - for ($i= 0; $i<$this->attrs['goTimeSource']['count']; $i++){ - $tmp[$this->attrs['goTimeSource'][$i]]= $this->attrs['goTimeSource'][$i]; - } - } - $this->goTimeSource= $tmp; - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* Here we add a new entry */ - if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "" && $this->acl_is_writeable("goTimeSource")) { - $this->goTimeSource[$_POST['NewNTPExport']]= $_POST['NewNTPExport']; - asort($this->goTimeSource); - } - - /* Deleting an Entry, is a bit more complicated than adding one*/ - if((isset($_POST['DelNTPEnt'])) && (isset($_POST['goTimeSource'])) && $this->acl_is_writeable("goTimeSource")) { - foreach ($_POST['goTimeSource'] as $entry){ - if (isset($this->goTimeSource[$entry])){ - unset($this->goTimeSource[$entry]); - } - } - } - - $smarty->assign("goNtpServerACL", $this->getacl("goNtpServer")) ; - $smarty->assign("goTimeSource" , $this->goTimeSource); - return($smarty->fetch(get_template_path("goNtpServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Time service (NTP)"); - $fields['AllowEdit'] = true; - return($fields); - } - - - function save() - { - plugin::save(); - $this->attrs['goTimeSource'] =array(); - foreach($this->goTimeSource as $entry){ - $this->attrs['goTimeSource'][] = $entry; - } - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/goNtpServer with dn '%s' failed."),$this->dn)); - if($this->initially_was_account){ - $this->handle_post_events("modify"); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Time service"), - "plDescription" => _("Time service - NTP")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 91, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "goTimeSource" =>_("Ntp source")) - )); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Load arrays */ - $tmp = array(); - if (isset($source['goTimeSource'])){ - for ($i= 0; $i<$source['goTimeSource']['count']; $i++){ - $tmp[$source['goTimeSource'][$i]]= $source['goTimeSource'][$i]; - } - } - $this->goTimeSource= $tmp; - - - } - - function check(){ return array();} - - function save_object(){;} -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/ntp/goNtpServer.tpl b/plugins/admin/systems/services/ntp/goNtpServer.tpl deleted file mode 100644 index 25a91d432..000000000 --- a/plugins/admin/systems/services/ntp/goNtpServer.tpl +++ /dev/null @@ -1,32 +0,0 @@ -
-

{t}Time server{/t}

-
- - - - -
-{render acl=$goNtpServerACL} - -{/render} -
-{render acl=$goNtpServerACL} - -{/render} -{render acl=$goNtpServerACL} - -{/render} -{render acl=$goNtpServerACL} - -{/render} -
- -

 

-
- -   - -
diff --git a/plugins/admin/systems/services/repository/class_servRepository.inc b/plugins/admin/systems/services/repository/class_servRepository.inc deleted file mode 100644 index 10321c024..000000000 --- a/plugins/admin/systems/services/repository/class_servRepository.inc +++ /dev/null @@ -1,366 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - // var $ignore_account = TRUE; - var $attributes = array("FAIrepository"); - var $objectclasses = array("FAIrepositoryServer"); - - /* Repositories */ - var $repositories = array(); - var $FAIrepository = array(); - var $conflicts = array("FAIrepositoryServer"); - var $DisplayName = ""; - var $StatusFlag = ""; - - var $view_logged = FALSE; - var $fai_activated = FALSE; - - var $divlist = NULL; - - function servrepository (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $this->DisplayName = _("Repository service"); - - /* Skip this if fai is deactivated */ - $tmp= $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - $this->fai_activated = TRUE; - }else{ - return; - } - - $this->repositories = array(); - if(isset($this->attrs['FAIrepository'])){ - for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){ - $tmp = split("\|",$this->attrs['FAIrepository'][$i]); - $tmp2 = array(); - $tmp3 = array(); - - if(isset($tmp[1])){ - $tmp2['ParentServer'] = $tmp[1]; - if(empty($tmp[1])){ - $tmp2['ParentServer'] = "none"; - } - }else{ - $tmp2['ParentServer'] = "none"; - } - - if(isset($tmp[0])){ - $tmp2['Url'] = $tmp[0]; - }else{ - $tmp2['Url'] = ""; - } - - if(isset($tmp[2])){ - $tmp2['Release'] = $tmp[2]; - }else{ - $tmp2['Release'] = ""; - } - - if(isset($tmp[3])){ - $tmp3 = split(",",$tmp[3]); - foreach($tmp3 as $sec){ - $tmp2['Sections'][$sec]=$sec; - } - }else{ - $tmp['Section']=array(); - } - - $this->repositories[$tmp[2]]=$tmp2; - } - } - - - /* Create divlist */ - $this->divlist = new divListRepository($this->config,$this); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - if(!$this->fai_activated){ - $str = "

"._("You can't use this plugin until FAI is activated.")."

"; - return $str; - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $smarty->assign("is_createable",$this->acl_is_createable()); - $display= ""; - - /* Show tab dialog headers */ - /* - ADD / EDIT Repository - Dialog Handling - */ - $once = false; - if(isset($_POST['servRepository'])){ - foreach($_POST as $name => $value){ - - if(preg_match("/AddRepository/",$name) && $this->acl_is_createable()){ - $once = true; - $this->dialog = new servRepositorySetup($this->config,$this->dn); - $this->dialog->parent = $this; - } - - if((preg_match("/^delete_/",$name)) && (!$once) && $this->acl_is_removeable()){ - $once = true; - $value = preg_replace("/delete_/","",$name); - $value = base64_decode(preg_replace("/_.*$/","",$value)); - - $url = $this->repositories[$value]['Url']; - $release = $this->repositories[$value]['Release']; - - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - - $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass")); - - $found = false; - $found_in = " "; - while($attrs = $ldap->fetch()){ - foreach($attrs['FAIclass'] as $class){ - if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){ - $found = true; - $found_in .= $attrs['cn'][0]." "; - } - } - } - - if($found){ - print_red(sprintf(_("You can't delete this release, it is still used by these workstations [%s]. Please solve this dependencies first, to keep data base consistency."),$found_in)); - }else{ - if(isset($this->repositories[$value])){ - unset($this->repositories[$value]); - } - } - } - - if((preg_match("/^edit_/",$name))&&(!$once)){ - $value = preg_replace("/edit_/","",$name); - $value = base64_decode(preg_replace("/_.$/","",$value)); - - if(isset($this->repositories[$value])){ - - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - - $url = $this->repositories[$value]['Url']; - $release = $this->repositories[$value]['Release']; - - $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass")); - - $found = false; - $found_in = " "; - while($attrs = $ldap->fetch()){ - foreach($attrs['FAIclass'] as $class){ - if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){ - $found = true; - $found_in .= $attrs['cn'][0]." "; - } - } - } - - if($found){ - print_red(sprintf(_("Be careful editing this release, it is still used by these workstations [%s]."),$found_in)); - } - - if(isset($this->repositories[$value])){ - $once = true; - $obj = $this->repositories[$value]; - - /* to be able to detect if this was renamed */ - $obj['initialy_was'] = $obj['Release']; - $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); - $this->dialog->parent = $this; - } - } - } - } - } - if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){ - $obj = $this->repositories[base64_decode($_GET['id'])]; - $obj['initialy_was'] = $obj['Release']; - $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); - $this->dialog->parent = $this; - } - - if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){ - $this->dialog->save_object(); - if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){ - print_red(_("This name is already in use.")); - }else - - if(count($this->dialog->check())!=0){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } - }else{ - $obj = $this->dialog->save(); - if($this->dialog->is_new_name()){ - $oldname = $this->dialog->initialy_was; - $this->repositories[$obj['Release']]=$obj; - unset($this->repositories[$oldname]); - }else{ - $this->repositories[$obj['Release']]=$obj; - } - $this->dialog = FALSE; - $this->is_dialog= false; - } - } - - if(isset($_POST['repository_setup_cancel'])){ - $this->dialog=FALSE; - $this->is_dialog = false; - } - - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $this->is_dialog = true; - return($this->dialog->execute()); - } - - /* - Repository setup dialog handling /END - */ - - - $link = "%s"; - $edit = " "; - - /* Hide delete icon, if delete is not allowed */ - if($this->acl_is_removeable()){ - $delete = ""; - }else{ - $delete = " "; - } - - $this->divlist->execute(); - $this->divlist->setEntries($this->repositories); - $smarty->assign("Repositories",$this->divlist->Draw()); - $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE)); - return($display); - } - - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - if(is_object($this->divlist)){ - $this->divlist->save_object(); - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - return ($message); - } - - - /* Save to LDAP */ - function save() - { - if(!$this->fai_activated) return; - - plugin::save(); - - $arr = array(); - foreach($this->repositories as $servername => $conf){ - $str = ""; - foreach($conf['Sections'] as $sec){ - $str.=$sec.","; - } - $str=preg_replace("/,$/","",$str); - - if($conf['ParentServer']=="none"){ - $conf['ParentServer'] =""; - } - - $arr[]=$conf['Url']."|".$conf['ParentServer']."|".$conf['Release']."|".$str; - } - $this->attrs['FAIrepository'] = $arr; - - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - - $ldap->cat($this->dn, array('dn')); - - if($ldap->count()){ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - $this->handle_post_events("modify"); - }else{ - $ldap->cd ($this->config->current['BASE']); - $ldap->create_missing_trees($this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - $this->handle_post_events("add"); - } - - if($this->initially_was_account){ - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Repository service"); - $fields['AllowEdit'] = true; - $fields['AllowStart'] = $fields['AllowStop'] = $fields['AllowRestart'] = false; - return($fields); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Repository"), - "plDescription" => _("Repository service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 84, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "cn" => _("Name"), - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - "Release" => _("Releases"), - "Section" => _("Sections"), - "ParentServer" => _("Parent server"), - "Url" => _("Url")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/repository/class_servRepositorySetup.inc b/plugins/admin/systems/services/repository/class_servRepositorySetup.inc deleted file mode 100644 index 40f37b062..000000000 --- a/plugins/admin/systems/services/repository/class_servRepositorySetup.inc +++ /dev/null @@ -1,225 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array("Release","ParentServer","Url","cn"); - var $objectclasses = array("whatever"); - - /* Attributes */ - var $Release = ""; - var $ParentServer = ""; - var $Url = ""; - var $Sections = array(); - var $ParentServers = ""; - var $initialy_was = false; - var $cn = ""; - var $parent = ""; - - function servRepositorySetup (&$config, $dn= NULL,$data = false) - { - plugin::plugin ($config, $dn); - if($data != false){ - foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){ - if(isset($data[$atr])){ - $this->$atr = $data[$atr]; - } - } - } - } - - function GetName() - { - return($this->Release); - } - - function is_new_name() - { - if(!$this->initialy_was){ - return(true); - }else{ - if($this->Release != $this->initialy_was){ - return(true); - } - } - return(false); - } - - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - - if((isset($_POST['AddSection']))&&(isset($_POST['SectionName']))&&(!empty($_POST['SectionName']))){ - - /* Replace multiple spaces with a single, and cut of white spaces (trim)*/ - $val = preg_replace("/\ \ * /" , " ", trim($_POST['SectionName'])); - - /* check if there are more than one entry given ( "section1 section2 )*/ - if(preg_match("/ /",$val)){ - - /* Generate list of new section names */ - $vals = split(" ",$val); - - /* Add new entries */ - foreach($vals as $entry){ - $entry = trim($entry); - $this->Sections[$entry]=$entry; - } - }else{ - $this->Sections[$val]=$val; - } - } - - foreach($_POST as $name => $value){ - if(preg_match("/^delete_/",$name)){ - - $val = preg_replace("/^delete_/","",$name); - $val = base64_decode(preg_replace("/_.*$/","",$val)); - - if(isset($this->Sections[$val])){ - unset($this->Sections[$val]); - } - } - } - - $divlist = new divSelectBox("servRepositorySetup"); - $divlist->setHeight("220"); - - $dellink = ""; - - foreach($this->Sections as $sec){ - $divlist->AddEntry(array( - array("string"=>$sec), - array("string"=>sprintf($dellink,base64_encode($sec),$sec),"attach"=>"style='border-right:0px;width:20px;'") - )); - } - - $smarty->assign("Sections",$divlist->DrawList()); - - /* Get && assign acls */ - $tmp = $this->parent->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->parent->getacl($name)); - } - - /* Assign values */ - foreach($this->attributes as $attr){ - $smarty->assign($attr ,$this->$attr); - } - - $tmp = $this->getParentServers(); - $smarty->assign("ParentServers" ,$tmp); - $smarty->assign("ParentServerKeys",array_flip($tmp)); - - return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE))); - } - - /* Save data to object */ - function save_object() - { - if(isset($_POST['servRepositorySetup_Posted'])) { - - foreach($this->attributes as $attr){ - if(($this->parent->acl_is_writeable($attr)) && (isset($_POST[$attr]))){ - $this->$attr = $_POST[$attr]; - } - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(empty($this->Release)){ - $message[]=_("Please enter a value for 'release'."); - } - - if(empty($this->Url)){ - $message[] = _("Please specify a valid value for 'url'."); - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - $tmp = array(); - $tmp['ParentServer'] = $this->ParentServer; - $tmp['Url'] = $this->Url; - $tmp['Release'] = $this->Release; - $tmp['Sections'] = $this->Sections; - return($tmp); - } - - function getParentServers() - { - $ret = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=FAIrepositoryServer)",array("*")); - while($attr = $ldap->fetch()){ - if($attr['cn'][0] == $this->cn) continue; - $ret[$attr['cn'][0]]= $attr['cn'][0]; - } - - $ret = array_merge($ret,$this->GetHookElements()); - - $ret['none']= " "; - asort($ret); - return($ret); - } - - /* this funtions calls a defined hook - and parses all additional serverdata - */ - function GetHookElements() - { - $ret = array(); - $cmd = $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs')); - if(!empty($cmd)){ - $res = shell_exec($cmd); - $res2 = trim($res); - if(!$res){ - print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s'. Please check your gosa.conf."),$cmd)); - }elseif(empty($res2)){ - print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd)); - }else{ - $tmp = split("\n",$res); - foreach($tmp as $hook){ - /* skip empty */ - if(empty($hook)) continue; - - if(preg_match("/;/",$hook)){ - $hookinfo = split(";",$hook); - $ret[$hookinfo[0]] = $hookinfo[0]; - }else{ - $ret[$hook] = $hook; - } - } - } - } - return($ret); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/repository/servRepository.tpl b/plugins/admin/systems/services/repository/servRepository.tpl deleted file mode 100644 index ca42710c1..000000000 --- a/plugins/admin/systems/services/repository/servRepository.tpl +++ /dev/null @@ -1,9 +0,0 @@ -{$Repositories} - - -

 

-
- -   - -
diff --git a/plugins/admin/systems/services/repository/servRepositorySetup.tpl b/plugins/admin/systems/services/repository/servRepositorySetup.tpl deleted file mode 100644 index 29691ec44..000000000 --- a/plugins/admin/systems/services/repository/servRepositorySetup.tpl +++ /dev/null @@ -1,58 +0,0 @@ -

 {t}Repository{/t}

- - - - - - -
- - - - - - - - - - - - - -
{t}Parent server{/t} - -{render acl=$ParentServerACL} - -{/render} -
{t}Release{/t} - -{render acl=$ReleaseACL} - -{/render} -
{t}URL{/t} - -{render acl=$UrlACL} - -{/render} -
-
- {t}Sections{/t}
-{render acl=$SectionACL} - {$Sections} -{/render} -{render acl=$SectionACL} - -{/render} -{render acl=$SectionACL} - -{/render} -
- -

- -   - -

- diff --git a/plugins/admin/systems/services/shares/class_goShareServer.inc b/plugins/admin/systems/services/shares/class_goShareServer.inc deleted file mode 100644 index 354d78037..000000000 --- a/plugins/admin/systems/services/shares/class_goShareServer.inc +++ /dev/null @@ -1,409 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goShareServer"); - var $attributes = array("goExportEntry"); - var $StatusFlag = "goShareServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goShareServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $cn = ""; - var $goShareServerStatus = ""; - var $goExportEntry = array(); - var $allow_mounts = false; - var $mounts_to_remove = array(); - var $mounts_to_add = array(); - var $view_logged =FALSE; - - function goShareServer(&$config,$dn) - { - goService::goService($config,$dn); - - $this->DisplayName = _("File service"); - - $tmp =array(); - if(isset($this->attrs['goExportEntry'])){ - if(isset($this->attrs['goExportEntry']['count'])){ - for($i= 0; $i<$this->attrs['goExportEntry']['count']; $i++){ - $entry= $this->attrs['goExportEntry'][$i]; - $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry; - } - } - } - $this->goExportEntryList = $tmp; - - $ldap = $this->config->get_ldap_link(); - $avl_objectclasses = $ldap->get_objectclasses(); - if (isset($avl_objectclasses["mount"])) { - $this->allow_mounts = true; - } - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - - if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList'])) && ($this->acl_is_writeable("name"))){ - if($this->allow_mounts){ - foreach($_POST['goExportEntryList'] as $entry){ - $this->deleteFromMountList($this->goExportEntryList[$entry]); - } - } - foreach($_POST['goExportEntryList'] as $entry){ - $this->deleteFromList($entry); - } - } - - if(isset($_POST['NewNfsAdd']) && ($this->acl_is_writeable("name"))){ - $this->oldone = NULL; - $this->o_subWindow = new servnfs($this->config, $this); - $this->o_subWindow->set_acl_category("server"); - $this->o_subWindow->set_acl_base($this->dn); - $this->dialog = true; - } - - if((isset($_POST['NewNfsEdit']))&&(isset($_POST['goExportEntryList']))){ - $entry = $this->goExportEntryList[$_POST['goExportEntryList'][0]]; - $add_mount=isset($this->mounts_to_add[$entry]); - $this->oldone=$entry; - $this->o_subWindow = new servnfs($this->config,$this,$entry,$add_mount); - $this->o_subWindow->set_acl_base($this->dn); - $this->o_subWindow->set_acl_category("server"); - $this->dialog = true; - } - if(isset($this->o_subWindow)){ - $this->o_subWindow->save_object(TRUE); - } - - /* Save NFS setup */ - if(isset($_POST['NFSsave']) && isset($this->o_subWindow) && is_object($this->o_subWindow)){ - if(count($this->o_subWindow->check())>0){ - foreach($this->o_subWindow->check() as $msg) { - print_red($msg); - } - }else{ - $this->o_subWindow->save_object(); - $newone = $this->o_subWindow->save(); - - $this->addToList($newone); - if($this->allow_mounts){ - if($this->oldone != NULL) { - $this->deleteFromMountList($this->oldone); - } - if ($this->o_subWindow->should_create_mount()) { - $this->addToMountList($newone); - } - } - unset($this->o_subWindow); - $this->dialog = false; - } - } - - /* Cancel NFS setup */ - if(isset($_POST['NFScancel'])){ - $this->oldone = NULL; - unset($this->o_subWindow); - $this->dialog = false; - } - - /* Execute NFS setup dialog*/ - if(isset($this->o_subWindow)){ - return $this->o_subWindow->execute(); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Set acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - $smarty->assign("createable",$this->acl_is_createable()); - $smarty->assign("removeable",$this->acl_is_removeable()); - - $tellSmarty= array(); - ksort($this->goExportEntryList); - foreach($this->goExportEntryList as $name=>$values){ - $tmp = split("\|",$values); - $tellSmarty[$name] = $tmp[0]." ".$tmp[4]." (".$tmp[2].")"; - } - $smarty->assign("goExportEntry",array_keys($tellSmarty)); - $smarty->assign("goExportEntryKeys",($tellSmarty)); - return($smarty->fetch(get_template_path("goShareServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("File service (Shares)"); - $fields['AllowEdit'] = true; - return($fields); - } - - - function save() - { - plugin::save(); - - /* Arrays */ - foreach (array("goExportEntryList"=>"goExportEntry") as $source => $destination){ - $this->attrs[$destination]= array(); - foreach ($this->$source as $element){ - $this->attrs[$destination][]= $element; - } - } - - - /* Process netatalk mounts */ - if($this->allow_mounts) { - $this->process_mounts(); - } - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/shares with dn '%s' failed."),$this->dn)); - if($this->initially_was_account){ - $this->handle_post_events("modify"); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - } - - - function check() - { - $message = plugin::check(); - return($message); - } - - - function save_object() - { - if(isset($_POST['goShareServerPosted'])){ - plugin::save_object(); - } - } - - function addToList($entry){ - $key = key($entry); - $this->goExportEntryList[$key]=$entry[$key]; - } - - function deleteFromList($id) - { - /* Check if the share is used by someone */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(|(gotoProfileServer=*|$id)(gotoShare=*|$id|*||*))", array("cn")); - $cnt= $ldap->count(); - if ($cnt){ - $msg= sprintf(_("The share can't be removed since it is still used by %d users:"), $cnt); - $msg.= "

    "; - while ($attrs= $ldap->fetch()){ - $msg.= "
  • ".$attrs["cn"][0]."
  • "; - } - $msg.= "
"._("Please correct the share-/profile settings of these users"); - print_red($msg); - - } else { - /* Finally remove it */ - unset($this->goExportEntryList[$id]); - } - } - - function process_mounts() { - - $clip = "cn=" . $this->cn . ",ou=servers,ou=systems,"; - $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip)); - - $mounts = array( - "objectClass" => "container", - "cn" => "mounts" - ); - - # load data from mounts container - $ldap = $this->config->get_ldap_link(); - $ldap->cat($mountsdn, array('dn')); - $attrs = $ldap->fetch(); - - # mounts container not present yet, so we create it - if (count($attrs) == 0) { - $ldap->cd($mountsdn); - $ldap->add($mounts); - show_ldap_error($ldap->get_error(), sprintf(_("Creating system server/shares (mount container) with dn '%s' failed."),$this->dn)); - new log("modify","server/".get_class($this),$mountsdn,array_keys($mounts),$ldap->get_error()); - } - - # remove deleted mounts from the container - foreach ($this->mounts_to_remove as $entry) { - $mount=$this->returnMountEntry($entry); - $mountdn = "cn=".$mount["cn"].","."$mountsdn"; - - $ldap->cat($mountdn, array('dn')); - $attrs = $ldap->fetch(); - - if (count($attrs) != 0) { - $ldap->rmdir($mountdn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing system server/shares (mount container) with dn '%s' failed."),$this->dn)); - new log("remove","server/".get_class($this),$mountdn,array_keys($mount),$ldap->get_error()); - } - } - - # add new mounts to the container - foreach ($this->mounts_to_add as $entry) { - $mount=$this->returnMountEntry($entry); - $mountdn = "cn=".$mount["cn"].","."$mountsdn"; - $ldap->cd($mountdn); - $ldap->add($mount); - show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/shares (mount container) with dn '%s' failed."),$this->dn)); - new log("create","server/".get_class($this),$mountdn,array_keys($mount),$ldap->get_error()); - } - } - - function addToMountList($entry) - { - if($this->acl_is_writeable("name")){ - $key = key($entry); - $type = $this->get_share_type($entry[$key]); - if (($type == "netatalk") || ($type == "NFS")) { - $this->mounts_to_add[$entry[$key]] = $entry[$key]; - unset($this->mounts_to_remove[$entry[$key]]); - } - } - } - - function deleteFromMountList($entry) - { - if($this->acl_is_writeable("name")){ - $type = $this->get_share_type($entry); - if (($type == "netatalk") || ($type == "NFS")) { - $this->mounts_to_remove[$entry] = $entry; - unset($this->mounts_to_add[$entry]); - } - } - } - - function get_share_type($share) - { - $tmp = split("\|", $share); - return $tmp[2]; - } - - function returnMountEntry($entry) - { - $item = split("\|", $entry); - $name = $item[0]; - $description = $item[1]; - $type = $item[2]; - $charset = $item[3]; - $path = $item[4]; - $options = $item[5]; - - switch ($type) { - case "netatalk" : { - $mount = array( - "mountDirectory" => "/Network/Servers/", - "mountOption" => array( - "net", - "url==afp://;AUTH=NO%20USER%20AUTHENT@".$this->cn."/$name/" - ), - "mountType" => "url", - "objectClass" => "mount", - "cn" => $this->cn .":/".$name - ); - break; - } - case "NFS" : { - $mount = array( - "mountDirectory" => "/Network/Servers/", - "mountOption" => "net", - "mountType" => "nfs", - "objectClass" => "mount", - "cn" => $this->cn .":".$path - ); - break; - } - default : { - continue; - } - } - return $mount; - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - $tmp =array(); - if(isset($source['goExportEntry'])){ - if(isset($source['goExportEntry']['count'])){ - for($i= 0; $i<$source['goExportEntry']['count']; $i++){ - $entry= $source['goExportEntry'][$i]; - $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry; - } - } - } - $this->goExportEntryList = $tmp; - $this->goExportEntry = $tmp; - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("File service (Shares)"), - "plDescription" => _("File service - Shares")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 90, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "name" => _("Name"), - "netatalkmount" => _("Apple mounts"), - "description" => _("Description"), - "type" => _("Type"), - "charset" => _("Charset"), - "path" => _("Path"), - "option" => _("Option"), - "volume" => _("Volume")) - - )); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/shares/goShareServer.tpl b/plugins/admin/systems/services/shares/goShareServer.tpl deleted file mode 100644 index 2c645c7f4..000000000 --- a/plugins/admin/systems/services/shares/goShareServer.tpl +++ /dev/null @@ -1,33 +0,0 @@ -

{t}Shares{/t}

- - - - -
-{render acl=$nameACL mode=read_active} - -{/render} -
- -{render acl=$nameACL} - -{/render} -{render acl=$nameACL mode=read_active} - -{/render} -{render acl=$nameACL} - -{/render} -
- - -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/spam/class_goSpamServer.inc b/plugins/admin/systems/services/spam/class_goSpamServer.inc deleted file mode 100644 index 82ff0fbaf..000000000 --- a/plugins/admin/systems/services/spam/class_goSpamServer.inc +++ /dev/null @@ -1,357 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goSpamServer"); - var $attributes = array("saRewriteHeader","saTrustedNetworks","saRequiredScore","saFlags","saRule"); - var $StatusFlag = "saStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goSpamServer"); - var $Flags = array("B","b","C","R","D","P"); - - var $DisplayName = ""; - var $dn = NULL; - var $cn = ""; - var $saStatus = ""; - - var $saRewriteHeader = ""; - var $saTrustedNetworks= array(); - var $TrustedNetworks = array(); - var $saRequiredScore = 0; - var $saFlags = ""; - var $Rules = array(); - var $saRule = array(); - - var $saFlagsB = false; - var $saFlagsb = false; - var $saFlagsC = false; - var $saFlagsR = false; - var $saFlagsD = false; - var $saFlagsP = false; - - var $ui = NULL; - var $acl = NULL; - var $view_logged =FALSE; - - function gospamserver(&$config,$dn, $parent= NULL) - { - /* Init class */ - goService::goService($config,$dn, $parent); - $this->DisplayName = _("Spamassassin"); - - /* Get userinfo & acls */ - $this->ui = get_userinfo(); - - /* Get Flags */ - foreach($this->Flags as $flag){ - $var = "saFlags".$flag; - if(preg_match("/".$flag."/",$this->saFlags)){ - $this->$var = TRUE; - } - } - - /* Get trusted networks */ - $this->TrustedNetworks = array(); - if(isset($this->attrs['saTrustedNetworks']) && is_array($this->attrs['saTrustedNetworks'])){ - $var = $this->attrs['saTrustedNetworks']; - for($i = 0 ; $i < $var['count'] ; $i ++ ){ - $var2 = $this->attrs['saTrustedNetworks'][$i]; - $this->TrustedNetworks[ $var2 ] = $var2; - } - } - - /* Get rules */ - $this->Rules = array(); - if(isset($this->attrs['saRule']) && is_array($this->attrs['saRule'])){ - $var = $this->attrs['saRule']; - for($i = 0 ; $i < $var['count'] ; $i ++ ){ - $var2 = $this->attrs['saRule'][$i]; - $name = preg_replace("/:.*$/","",$var2); - $value= base64_decode(preg_replace("/^.*:/","",$var2)); - $this->Rules[ $name ] = $value; - } - } - } - - - function execute() - { - $display =""; - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /* If displayed, it is ever true*/ - $this->is_account =true; - - /* Get acls */ - $tmp = $this->plinfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Add new trusted network */ - if(isset($_POST['AddNewTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){ - $this->AddTrust($_POST['NewTrustName']); - } - - /* Delete selected trusted network */ - if(isset($_POST['DelTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){ - $this->DelTrust($_POST['TrustedNetworks']); - } - - /* Add a new rule */ - if(isset($_POST['AddRule']) && $this->acl_is_writeable("saRule")){ - $this->dialog = new goSpamServerRule($this->config,$this->dn); - } - - /* Cancel adding/editing specified rule */ - if(isset($_POST['CancelRule'])){ - $this->dialog = FALSE; - } - - /* Handle post to delete rules */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^editRule_/",$name) && $once && $this->acl_is_readable("saRule")){ - $once = false; - $entry = preg_replace("/^editRule_/","",$name); - $entry = preg_replace("/_(x|y)$/","",$entry); - $rule = $this->Rules[$entry]; - $name = $entry; - $this->dialog = new goSpamServerRule($this->config,$this->dn,$name,$rule); - } - if(preg_match("/^delRule_/",$name) && $once && $this->acl_is_writeable("saRule")){ - $once = false; - $entry = preg_replace("/^delRule_/","",$name); - $entry = preg_replace("/_(x|y)$/","",$entry); - unset($this->Rules[$entry]); - } - } - - /* Save rules */ - if(isset($_POST['SaveRule'])){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)){ - foreach($msgs as $msg){ - print_red($msg); - } - }elseif($this->acl_is_writeable("saRule")){ - $ret = $this->dialog->save(); - if((!empty($ret['orig_name'])) && isset($this->Rules[$ret['orig_name']])){ - unset($this->Rules[$ret['orig_name']]); - } - $this->Rules[$ret['name']] = $ret['rule']; - $this->dialog = FALSE; - } - } - - /* Display dialog if available */ - if($this->dialog && $this->dialog->config){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - /* Assign smarty vars */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign checkbox states */ - foreach($this->Flags as $Flag){ - $var = "saFlags".$Flag; - $smarty->assign("saFlags".$Flag."ACL", $this->getacl($Flag)); - if($this->$var){ - $smarty->assign("saFlags".$Flag."CHK"," checked " ); - }else{ - $smarty->assign("saFlags".$Flag."CHK",""); - } - } - - /* Create divlist */ - $DivRules = new divSelectBox("SpamRules"); - $DivRules->SetHeight(130); - - if($this->acl_is_writeable("saTrustedNetworks")){ - $actions = ""; - }else{ - - $actions = ""; - if($this->acl_is_writeable("saRule")){ - $actions.= ""; - } - } - - foreach($this->Rules as $key => $net){ - $field1 = array("string" => $key ); - $field2 = array("string" => sprintf($actions,$key,$key) , "attach" => "style='border-right:0px;width:36px;'"); - $DivRules->AddEntry(array($field1,$field2)); - } - $smarty->assign("divRules",$DivRules->DrawList()); - $smarty->assign("TrustedNetworks",$this->TrustedNetworks); - - /* Create Spam score select box entries */ - $tmp = array(); - for($i = 0 ; $i <= 20 ; $i ++ ){ - $tmp[$i] = $i; - } - $smarty->assign("SpamScore",$tmp); - - return($display.$smarty->fetch(get_template_path("goSpamServer.tpl",TRUE,dirname(__FILE__)))); - } - - - /* Add $post to list of configured trusted */ - function AddTrust($post) - { - if(!empty($post)){ - if(is_ip($post) || is_domain($post) || (is_ip_with_subnetmask($post))){ - $this->TrustedNetworks[$post] = $post; - }else{ - print_red(_("Specified value is not a valid 'trusted network' value.")); - } - } - } - - - /* Delete trusted network */ - function DelTrust($posts) - { - foreach($posts as $post){ - if(isset($this->TrustedNetworks[$post])){ - unset($this->TrustedNetworks[$post]); - } - } - } - - function save() - { - if(!$this->is_account) return; - plugin::save(); - - /* Create Flags */ - $this->attrs['saFlags'] = array(); - foreach($this->Flags as $flag){ - $var = "saFlags".$flag; - if($this->$var){ - $this->attrs['saFlags'].=$flag; - } - } - - /* Create trusted network entries */ - $this->attrs['saTrustedNetworks'] = array(); - foreach($this->TrustedNetworks as $net){ - $this->attrs['saTrustedNetworks'][] = $net; - } - - /* Rules */ - $this->attrs['saRule'] = array(); - foreach($this->Rules as $name => $rule){ - $this->attrs['saRule'][] = $name.":".base64_encode($rule); - } - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - if($this->initially_was_account){ - $this->handle_post_events("modify"); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/spamassassin with dn '%s' failed."),$this->dn)); - } - - function check() - { - $message = plugin::check(); - - /* Check if required score is numeric */ - if(!is_numeric($this->saRequiredScore)){ - $message[] = _("Required score must be a numeric value."); - } - - return($message); - } - - - function save_object() - { - if(isset($_POST['goSpamServer'])){ - - plugin::save_object(); - - /* Check flags */ - foreach($this->Flags as $flag){ - $var = "saFlags".$flag; - - if($this->acl_is_writeable($var)){ - if(isset($_POST[$var])){ - $this->$var = TRUE; - }else{ - $this->$var = FALSE; - } - } - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Spamassassin"), - "plDescription" => _("Spamassassin")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 89, - "plSection" => array("administration"), - "plCategory" => array("server"), - "plProvidedAcls"=> array( - - "saRewriteHeader" => _("Rewrite header"), - "saTrustedNetworks" => _("Trusted networks"), - "saRequiredScore" => _("Required score"), - "saRule" => _("Rules"), - - "saFlagB" => _("Enable use of bayes filtering"), - "saFlagb" => _("Enabled bayes auto learning"), - "saFlagC" => _("Enable RBL checks"), - "saFlagR" => _("Enable use of Razor"), - "saFlagD" => _("Enable use of DDC"), - "saFlagP" => _("Enable use of Pyzor")) - )); - } - - /* For newer service management dialogs */ - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Spamassassin"); - $fields['AllowEdit'] = true; - return($fields); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/spam/class_goSpamServerRule.inc b/plugins/admin/systems/services/spam/class_goSpamServerRule.inc deleted file mode 100644 index c8eed5d4e..000000000 --- a/plugins/admin/systems/services/spam/class_goSpamServerRule.inc +++ /dev/null @@ -1,61 +0,0 @@ -name = $this->orig_name= $name; - $this->rule = $rule; - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("goSpamServerRule.tpl",TRUE,dirname(__FILE__)))); - } - - function save_object() - { - plugin::save_object(); - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - } - - - function save() - { - $ret =array(); - $ret['orig_name'] = $this->orig_name; - $ret['name'] = $this->name; - $ret['rule'] = $this->rule; - return($ret); - } - - function check() - { - $messages = plugin::check(); - return($messages); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/spam/goSpamServer.tpl b/plugins/admin/systems/services/spam/goSpamServer.tpl deleted file mode 100644 index c8b58852f..000000000 --- a/plugins/admin/systems/services/spam/goSpamServer.tpl +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - -

Spam tagging

- - - - - - - - - - -
- {t}Rewrite header{/t} - -{render acl=$saRewriteHeaderACL} - -{/render} -
- {t}Required score{/t} - -{render acl=$saRequiredScoreACL} - -{/render} -
- -

Trusted networks

- - - - - -
-{render acl=$saTrustedNetworksACL} -
-{/render} -{render acl=$saTrustedNetworksACL} -   -{/render} -{render acl=$saTrustedNetworksACL} - -{/render} -{render acl=$saTrustedNetworksACL} - -{/render} -
- -
-

 

-
-

Flags

- - - - - -
-{render acl=$saFlagsBACL} -  {t}Enable use of bayes filtering{/t}
-{/render} -{render acl=$saFlagsbACL} -  {t}Enable bayes auto learning{/t}
-{/render} -{render acl=$saFlagsCACL} -  {t}Enable RBL checks{/t} -{/render} -
-
- - - - -
-{render acl=$saFlagsRACL} -  {t}Enable use of Razor{/t}
-{/render} -{render acl=$saFlagsDACL} -  {t}Enable use of DDC{/t}
-{/render} -{render acl=$saFlagsPACL} -  {t}Enable use of Pyzor{/t} -{/render} -
- -
-

 

-

Rules

- - - - - -
- {$divRules}
-{render acl=$saTrustedNetworksACL} - -{/render} -
- -
- - -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/spam/goSpamServerRule.tpl b/plugins/admin/systems/services/spam/goSpamServerRule.tpl deleted file mode 100644 index 6448ab556..000000000 --- a/plugins/admin/systems/services/spam/goSpamServerRule.tpl +++ /dev/null @@ -1,25 +0,0 @@ -

Edit spam rule

- - - - - - - - - -
- {t}Name{/t} - - -
- {t}Rule{/t} - -
-

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/syslog/class_goLogDBServer.inc b/plugins/admin/systems/services/syslog/class_goLogDBServer.inc deleted file mode 100644 index 3a193dbf2..000000000 --- a/plugins/admin/systems/services/syslog/class_goLogDBServer.inc +++ /dev/null @@ -1,106 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goLogDBServer"); - var $attributes = array("goLogAdmin", "goLogPassword"); - var $StatusFlag = "goLogDBServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goLogDBServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $acl; - var $cn = ""; - var $goLogDBServerStatus = ""; - var $goLogAdmin = ""; - var $goLogPassword = ""; - var $view_logged =FALSE; - - - function goLogDBServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("Syslog service database"); - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("goLogDBServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Syslog service database"); - $fields['AllowEdit'] = true; - return($fields); - } - - - function check() - { - $message = plugin::check(); - if (empty($this->goLogAdmin)){ - $message[]= sprintf_("The attribute user is empty or contains invalid characters."); - } - if (empty($this->goLogPassword)){ - $message[]= sprintf_("The attribute password is empty or contains invalid characters."); - } - return($message); - } - - - function save_object() - { - if(isset($_POST['goLogDBServerPosted'])){ - plugin::save_object(); - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Logging database"), - "plDescription" => _("Logging database")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 97, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - "goLogAdmin" => _("Admin"), - "goLogPassword" => _("Password")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/syslog/class_goSyslogServer.inc b/plugins/admin/systems/services/syslog/class_goSyslogServer.inc deleted file mode 100644 index 9461977e2..000000000 --- a/plugins/admin/systems/services/syslog/class_goSyslogServer.inc +++ /dev/null @@ -1,83 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goSyslogServer"); - var $attributes = array(); - var $StatusFlag = "goSyslogServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goSyslogServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $acl; - var $cn = ""; - var $goSyslogServerStatus = ""; - var $view_logged =FALSE; - - function goSyslogServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("Syslog server"); - } - - - function execute() - { - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - - $smarty = get_smarty(); - return($smarty->fetch(get_template_path("goSyslogServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Syslog server"); - $fields['AllowEdit'] = false; - return($fields); - } - - function check() - { - $message = plugin::check(); - return($message); - } - - - function save_object() - { - plugin::save_object(); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Logging service"), - "plDescription" => _("Logging service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 88, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array() - )); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/syslog/goLogDBServer.tpl b/plugins/admin/systems/services/syslog/goLogDBServer.tpl deleted file mode 100644 index 839507029..000000000 --- a/plugins/admin/systems/services/syslog/goLogDBServer.tpl +++ /dev/null @@ -1,27 +0,0 @@ -

{t}Logging database information{/t}

- - - - - - - - - -
{t}Logging DB user{/t}{$must} -{render acl=$goLogAdminACL} - -{/render} -
{t}Password{/t}{$must} -{render acl=$goLogPasswordACL} - -{/render} -
- -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/syslog/goSyslogServer.tpl b/plugins/admin/systems/services/syslog/goSyslogServer.tpl deleted file mode 100644 index a7ed661a8..000000000 --- a/plugins/admin/systems/services/syslog/goSyslogServer.tpl +++ /dev/null @@ -1,9 +0,0 @@ -

{t}Syslog Service{/t} {t}enabled{/t}

- -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/terminal/class_goTerminalServer.inc b/plugins/admin/systems/services/terminal/class_goTerminalServer.inc deleted file mode 100644 index e832de04c..000000000 --- a/plugins/admin/systems/services/terminal/class_goTerminalServer.inc +++ /dev/null @@ -1,141 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* This plugin only writes its objectClass */ - var $objectclasses = array("goTerminalServer"); - var $attributes = array("goXdmcpIsEnabled", "goFontPath"); - var $StatusFlag = "goTerminalServerStatus"; - - /* This class can't be assigned twice so it conflicts with itsself */ - var $conflicts = array("goTerminalServer"); - - var $DisplayName = ""; - var $dn = NULL; - var $acl; - var $cn = ""; - var $goTerminalServerStatus = ""; - var $goXdmcpIsEnabled = false; - var $goFontPath = ""; - var $view_logged =FALSE; - - - function goTerminalServer(&$config,$dn) - { - goService::goService($config,$dn); - $this->DisplayName = _("Terminal service"); - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - - $tmp = $this->plinfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Terminal service"); - $fields['AllowEdit'] = true; - return($fields); - } - - - function save() - { - plugin::save(); - - if(!$this->goXdmcpIsEnabled){ - $this->attrs['goXdmcpIsEnabled'] = "0"; - } - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/terminalServer with dn '%s' failed."),$this->dn)); - if($this->initially_was_account){ - $this->handle_post_events("modify"); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - } - - - function check() - { - $message = plugin::check(); - if(empty($this->goFontPath)){ - $message[]=_("Terminal server, must have fontpath specified."); - } - - return($message); - } - - - function save_object() - { - if(isset($_POST['goTerminalServerPosted'])){ - plugin::save_object(); - if($this->acl_is_writeable("goXdmcpIsEnabled")){ - if(isset($_POST['goXdmcpIsEnabled'])){ - $this->goXdmcpIsEnabled = true; - }else{ - $this->goXdmcpIsEnabled = false; - } - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Terminal service"), - "plDescription" => _("Terminal service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 87, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "goXdmcpIsEnabled" => _("Temporary disable login"), - "goFontPath" => _("Font path")) - )); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/terminal/goTerminalServer.tpl b/plugins/admin/systems/services/terminal/goTerminalServer.tpl deleted file mode 100644 index 5fca2091f..000000000 --- a/plugins/admin/systems/services/terminal/goTerminalServer.tpl +++ /dev/null @@ -1,27 +0,0 @@ -

{t}Terminal service{/t}

- - - - - - - - -
-{render acl=$goXdmcpIsEnabledACL} - -{/render} - {t}Temporary disable login{/t} -
{t}Font path{/t} -{render acl=$goXdmcpIsEnabledACL} - -{/render} -
- -

 

-
- -   - -
- diff --git a/plugins/admin/systems/services/virus/class_goVirusServer.inc b/plugins/admin/systems/services/virus/class_goVirusServer.inc deleted file mode 100644 index f91c5f5ae..000000000 --- a/plugins/admin/systems/services/virus/class_goVirusServer.inc +++ /dev/null @@ -1,248 +0,0 @@ -DisplayName = _("Anti virus"); - - /* Get userinfo & acls */ - $this->ui = get_userinfo(); - - /* Get Flags */ - foreach($this->Flags as $flag){ - $var = "avFlags".$flag; - if(preg_match("/".$flag."/",$this->avFlags)){ - $this->$var = TRUE; - } - } - } - - - function execute() - { - $smarty = get_smarty(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - - /* Set acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation) { - $smarty->assign($name."ACL",$this->getacl($name)); - } - - $display = ""; - $smarty->assign("servtabs",FALSE); - $this->is_account = true; - - /* Assign smarty vars */ - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign checkbox states */ - foreach($this->Flags as $Flag){ - $var = "avFlags".$Flag; - if($this->$var){ - $smarty->assign("avFlags".$Flag."CHK"," checked " ); - }else{ - $smarty->assign("avFlags".$Flag."CHK",""); - } - } - - /* Assign value for max thread select box */ - $tmp = array(); - for($i = 1 ; $i <= 20 ; $i ++){ - $tmp[$i] = $i; - } - $smarty->assign("ThreadValues",$tmp); - - if($this->avFlagsA){ - $smarty->assign("avFlagsAState" , "" ); - }else{ - $smarty->assign("avFlagsAState" , " disabled " ); - } - - return($display.$smarty->fetch(get_template_path("goVirusServer.tpl",TRUE,dirname(__FILE__)))); - } - - - function save() - { - if(!$this->is_account) return; - - /* Create Flags */ - $this->avFlags = ""; - foreach($this->Flags as $flag){ - $var = "avFlags".$flag; - if($this->$var){ - $this->avFlags .=$flag; - } - } - - plugin::save(); - - if(!$this->avFlagsA){ - $arr = array("avArchiveMaxFileSize","avArchiveMaxRecursion","avArchiveMaxCompressionRatio"); - foreach($arr as $attr){ - $this->attrs[$attr] = array(); - } - $this->attrs['avFlags'] = preg_replace("/E/","",$this->attrs['avFlags']); - } - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - if($this->initially_was_account){ - $this->handle_post_events("modify"); - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - $this->handle_post_events("add"); - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/anti virus with dn '%s' failed."),$this->dn)); - } - - function check() - { - $message = plugin::check(); - - $mustBeNumeric = array( - "avMaxDirectoryRecursions" =>_("Maximum directory recursions"), - "avMaxThreads" =>_("Maximum threads"), - "avArchiveMaxFileSize" =>_("Maximum file size"), - "avArchiveMaxRecursion" =>_("Maximum recursions"), - "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"), - "avChecksPerDay" =>_("Checks per day")); - - foreach($mustBeNumeric as $key => $trans){ - if(!is_numeric($this->$key)){ - $message[] = sprintf(_("The specified value for '%s' must be a numeric value."),$trans); - } - } - - foreach(array("avUser"=>_("Database user"),"avHttpProxyURL"=>_("Http proxy URL"),"avDatabaseMirror"=>_("Database mirror")) as $attr => $name){ - if(!preg_match("/^[a-z0-9:_\-\.\/]*$/",$this->$attr)){ - $message[] = sprintf(_("Please specify a valid value for '%s'."),$name); - } - } - - return($message); - } - - - function save_object() - { - if(isset($_POST['goVirusServer'])){ - plugin::save_object(); - foreach($this->Flags as $flag){ - - $var = "avFlags".$flag; - if($this->acl_is_writeable($var)){ - if(isset($_POST[$var])){ - $this->$var = TRUE; - }else{ - $this->$var = FALSE; - } - } - } - } - } - - - /* For newer service management dialogs */ - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['AllowEdit'] = true; - $fields['Message'] = _("Anti virus"); - return($fields); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Anti virus"), - "plDescription" => _("Anti virus")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 96, - "plSection" => array("administration"), - "plCategory" => array("server"), - "plProvidedAcls"=> array( - - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - - "avFlagsD" =>_("Enable debugging"), - "avFlagsS" =>_("Enable mail scanning"), - "avFlagsA" =>_("Enable scanning of archives"), - "avFlagsE" =>_("Block encrypted archives"), - - "avMaxThreads" =>_("Maximum threads"), - "avMaxDirectoryRecursions" =>_("Maximum directory recursions"), - "avUser" =>_("Anti virus user"), - "avArchiveMaxFileSize" =>_("Maximum file size"), - "avArchiveMaxRecursion" =>_("Maximum recursions"), - "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"), - "avDatabaseMirror" =>_("Database mirror"), - "avChecksPerDay" =>_("Checks per day"), - "avHttpProxyURL" =>_("Http proxy URL")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/services/virus/goVirusServer.tpl b/plugins/admin/systems/services/virus/goVirusServer.tpl deleted file mode 100644 index af14a2b1c..000000000 --- a/plugins/admin/systems/services/virus/goVirusServer.tpl +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - - - - - -
-

{t}Generic virus filtering{/t}

-
- - - - - - - - - - - - - - - - - -
- {t}Database user{/t} - -{render acl=$avUserACL} - -{/render} -
- {t}Database mirror{/t} - -{render acl=$avDatabaseMirrorACL} - -{/render} -
- {t}Http proxy URL{/t} - -{render acl=$avHttpProxyURLACL} - -{/render} -
- {t}Maximum threads{/t} - -{render acl=$avMaxThreadsACL} - -{/render} -
- -
- - - - - - - - - - - - - - - - -
- {t}Max directory recursions{/t} - -{render acl=$avMaxDirectoryRecursionsACL} - -{/render} -
- {t}Checks per day{/t} - -{render acl=$avChecksPerDayACL} - -{/render} -
-{render acl=$avFlagsDACL} - -{/render} - {t}Enable debugging{/t} -
-{render acl=$avFlagsSACL} - -{/render} - {t}Enable mail scanning{/t} -
-
-

 

-

{t}Archive scanning{/t}

-
- - - - - - - -
-{render acl=$avFlagsAACL} - -{/render} - {t}Enable scanning of archives{/t} -
-{render acl=$avFlagsEACL} - -{/render} - {t}Block encrypted archives{/t} -
- -
- - - - - - - - - - - - - -
{t}Maximum file size{/t} - -{render acl=$avArchiveMaxFileSizeACL} - -{/render} -
{t}Maximum recursion{/t} - -{render acl=$avArchiveMaxRecursionACL} - -{/render} -
{t}Maximum compression ratio{/t} - -{render acl=$avArchiveMaxCompressionRatioACL} - -{/render} -
- -
- -

 

-
- -   - -
- diff --git a/plugins/admin/systems/tabs_arpnewdevice.inc b/plugins/admin/systems/tabs_arpnewdevice.inc deleted file mode 100644 index fe12b4090..000000000 --- a/plugins/admin/systems/tabs_arpnewdevice.inc +++ /dev/null @@ -1,19 +0,0 @@ -by_object[$this->current]->execute()); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/tabs_component.inc b/plugins/admin/systems/tabs_component.inc deleted file mode 100644 index 941203e24..000000000 --- a/plugins/admin/systems/tabs_component.inc +++ /dev/null @@ -1,41 +0,0 @@ -addSpecialTabs(); - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - } - - - function save($ignore_account= FALSE) - { - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $baseobject= $this->by_object['componentGeneric']; - $this->dn= "cn=$baseobject->cn,ou=netdevices,ou=systems,".$baseobject->base; - $baseobject->dn= $this->dn; - - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->dn= $this->dn; - } - - tabs::save(TRUE); - - /* Fix tagging if needed */ - $baseobject->handle_object_tagging(); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/tabs_phone.inc b/plugins/admin/systems/tabs_phone.inc deleted file mode 100644 index 13d5ac3c7..000000000 --- a/plugins/admin/systems/tabs_phone.inc +++ /dev/null @@ -1,41 +0,0 @@ -addSpecialTabs(); - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - } - - - function save($ignore_account= FALSE) - { - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $baseobject= $this->by_object['phoneGeneric']; - $this->dn= "cn=$baseobject->cn,ou=phones,ou=systems,".$baseobject->base; - $baseobject->dn= $this->dn; - - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->dn= $this->dn; - } - - tabs::save(TRUE); - - /* Fix tagging if needed */ - $baseobject->handle_object_tagging(); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/tabs_printers.inc b/plugins/admin/systems/tabs_printers.inc deleted file mode 100644 index 92963d6b0..000000000 --- a/plugins/admin/systems/tabs_printers.inc +++ /dev/null @@ -1,65 +0,0 @@ -dn= $dn; - $this->config= $config; - - $baseobject= NULL; - - foreach ($data as $tab){ - $this->by_name[$tab['CLASS']]= $tab['NAME']; - - if ($baseobject === NULL){ - $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this); - $this->by_object[$tab['CLASS']]= $baseobject; - } else { - $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this); - } - - $this->by_object[$tab['CLASS']]->parent= &$this; - $this->by_object[$tab['CLASS']]->set_acl_category($category); - - /* Initialize current */ - if ($this->current == ""){ - $this->current= $tab['CLASS']; - } - } - - /* Add references/acls/snapshots */ - $this->addSpecialTabs(); - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - } - - - function save($ignore_account= FALSE) - { - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $baseobject= $this->by_object['printgeneric']; - $this->dn= "cn=$baseobject->cn,ou=printers,ou=systems,".$baseobject->base; - $baseobject->dn= $this->dn; - - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->dn= $this->dn; - } - - tabs::save(FALSE); - - /* Fix tagging if needed */ - $baseobject->handle_object_tagging(); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/tabs_server.inc b/plugins/admin/systems/tabs_server.inc deleted file mode 100644 index 564e92588..000000000 --- a/plugins/admin/systems/tabs_server.inc +++ /dev/null @@ -1,70 +0,0 @@ -dn= $dn; - $this->config= $config; - - $baseobject= NULL; - - foreach ($data as $tab){ - $this->by_name[$tab['CLASS']]= $tab['NAME']; - - if ($baseobject === NULL){ - $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this); - $this->by_object[$tab['CLASS']]= $baseobject; - } else { - $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this); - } - - $this->by_object[$tab['CLASS']]->parent= &$this; - $this->by_object[$tab['CLASS']]->set_acl_category($category); - - /* Initialize current */ - if ($this->current == ""){ - $this->current= $tab['CLASS']; - } - } - - /* Add references/acls/snapshots */ - $this->addSpecialTabs(); - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - } - - - function save($ignore_account= FALSE) - { - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $baseobject= $this->by_object['servgeneric']; - $this->dn= "cn=$baseobject->cn,ou=servers,ou=systems,".$baseobject->base; - $baseobject->dn= $this->dn; - - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->dn= $this->dn; - $this->by_object[$key]->cn= $baseobject->cn; - } - - tabs::save(FALSE); - - /* Reload server settings after saving */ - $config= $_SESSION['config']; - $config->load_servers(); - $_SESSION['config']= $config; - - /* Fix tagging if needed */ - $baseobject->handle_object_tagging(); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/tabs_terminal.inc b/plugins/admin/systems/tabs_terminal.inc deleted file mode 100644 index 3a3b77486..000000000 --- a/plugins/admin/systems/tabs_terminal.inc +++ /dev/null @@ -1,80 +0,0 @@ -dn= $dn; - $this->config= $config; - - $baseobject= NULL; - - foreach ($data as $tab){ - $this->by_name[$tab['CLASS']]= $tab['NAME']; - - if ($baseobject === NULL){ - $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this); - $this->by_object[$tab['CLASS']]= $baseobject; - } else { - $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this); - } - - $this->by_object[$tab['CLASS']]->parent= &$this; - $this->by_object[$tab['CLASS']]->set_acl_category($category); - - /* Initialize current */ - if ($this->current == ""){ - $this->current= $tab['CLASS']; - } - } - - /* Add references/acls/snapshots */ - $this->addSpecialTabs(); - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - - /* Update reference, transfer variables */ - if(isset($this->by_object['termstartup'])){ - $this->by_object['termstartup']->gotoTerminalPath= $this->by_object['termgeneric']->gotoTerminalPath; - } - - $base_obj = $this->by_object['termgeneric']; - foreach($this->by_object as $name => $plug){ - $this->by_object[$name]->cn = $base_obj->cn; - } - } - - - function save($ignore_account= FALSE) - { - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $baseobject= $this->by_object['termgeneric']; - $this->dn= "cn=".$baseobject->cn.",ou=terminals,ou=systems,".$baseobject->base; - $baseobject->dn= $this->dn; - - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->dn= $this->dn; - $this->by_object[$key]->cn= $baseobject->cn; - } - - tabs::save(TRUE); - if(isset($this->by_object['printgeneric'])){ - if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){ - $this->by_object['printgeneric']->remove_from_parent(); - } - } - - /* Fix tagging if needed */ - $baseobject->handle_object_tagging(); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/tabs_winstation.inc b/plugins/admin/systems/tabs_winstation.inc deleted file mode 100644 index cada48b80..000000000 --- a/plugins/admin/systems/tabs_winstation.inc +++ /dev/null @@ -1,47 +0,0 @@ -addSpecialTabs(); - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - } - - - function save($ignore_account= FALSE) - { - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - - /* add $ to end of name if mising */ - $baseobject= $this->by_object['wingeneric']; - if(!preg_match("/\\\$\$/",$baseobject->cn)){ - $baseobject->cn .= "$"; - } - - $this->dn= "uid=$baseobject->cn,".get_winstations_ou().$baseobject->base; - $baseobject->dn= $this->dn; - - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->dn= $this->dn; - } - - tabs::save(TRUE); - - /* Fix tagging if needed */ - $baseobject->handle_object_tagging(); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/tabs_workstation.inc b/plugins/admin/systems/tabs_workstation.inc deleted file mode 100644 index 6c34fd1e8..000000000 --- a/plugins/admin/systems/tabs_workstation.inc +++ /dev/null @@ -1,78 +0,0 @@ -dn= $dn; - $this->config= $config; - - $baseobject= NULL; - - foreach ($data as $tab){ - $this->by_name[$tab['CLASS']]= $tab['NAME']; - - if ($baseobject === NULL){ - $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this); - $this->by_object[$tab['CLASS']]= $baseobject; - } else { - $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this); - } - - $this->by_object[$tab['CLASS']]->parent= &$this; - $this->by_object[$tab['CLASS']]->set_acl_category($category); - - /* Initialize current */ - if ($this->current == ""){ - $this->current= $tab['CLASS']; - } - } - - /* Add references/acls/snapshots */ - $this->addSpecialTabs(); - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - - /* Assign current cn */ - $baseobject= $this->by_object['workgeneric']; - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->cn= $baseobject->cn; - } - } - - - function save($ignore_account= FALSE) - { - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $baseobject= $this->by_object['workgeneric']; - $this->dn= "cn=".$baseobject->cn.",ou=workstations,ou=systems,".$baseobject->base; - $baseobject->dn= $this->dn; - - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->dn= $this->dn; - $this->by_object[$key]->cn= $baseobject->cn; - } - - tabs::save(TRUE); - - if(isset($this->by_object['printgeneric'])){ - if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){ - $this->by_object['printgeneric']->remove_from_parent(); - } - } - - /* Fix tagging if needed */ - $baseobject->handle_object_tagging(); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/systems/terminal.tpl b/plugins/admin/systems/terminal.tpl deleted file mode 100644 index dc088f867..000000000 --- a/plugins/admin/systems/terminal.tpl +++ /dev/null @@ -1,176 +0,0 @@ -

{t}Properties{/t}

- - - - - -
- - - {if $cn eq 'default'} - - {else} - - - {/if} - - - - - -
{t}Terminal template{/t}{$must} -{render acl=$cnACL} - -{/render} -
{$must} - -{render acl=$baseACL} - -{/render} -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-{if $member_of_ogroup} -
-
-
- -{/if} -
- - - - - - - - - -
-{render acl=$gotoModeACL} - -{/render} -
-{render acl=$gotoSyslogServerACL} - -{/render} -
-
-

 

- - - - - -
- - - - - - - - - -
-{render acl=$gotoTerminalPathACL} - -{/render} -
-{render acl=$gotoSwapServerACL} - -{/render} -
-
- - - - - - - -
-{if $member_of_ogroup} -{render acl=$gotoNtpServerACL} - {t}Inherit time server attributes{/t} -{/render} -{else} - {t}Inherit time server attributes{/t} -{/if} -

-{render acl=$gotoNtpServerACL} - -{/render} -
-{render acl=$gotoNtpServerACL} - -{/render} -{render acl=$gotoNtpServerACL} - -{/render} -{render acl=$gotoNtpServerACL} - -{/render} -
- -
- -{if $cn neq 'default'} -

 

- -{$netconfig} -{/if} - -{if $fai_activated} -

 

-

{t}Action{/t}

- - - - - -
-{render acl=$gotoNtpServerACL} - -{/render} - -{render acl=$gotoNtpServerACL} - -{/render} -
-{/if} - - - - diff --git a/plugins/admin/systems/terminalService.tpl b/plugins/admin/systems/terminalService.tpl deleted file mode 100644 index 72ba28b1a..000000000 --- a/plugins/admin/systems/terminalService.tpl +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - - - - - - -
-

{t}Keyboard{/t}

- - - - - - - - - - - - - -
-{render acl=$gotoXKbModelACL} - -{/render} -
-{render acl=$gotoXKbLayoutACL} - -{/render} -
-{render acl=$gotoXKbVariantACL} - -{/render} -
- -
-   - -

{t}Mouse{/t}

- - - - - - - - - -
-{render acl=$gotoXMouseTypeACL} - -{/render} -
-{render acl=$gotoXMouseportACL} - -{/render} -
- -
-   - -

{t}Telephone hardware{/t}

- - - - -
{t}Telephone{/t}  -{render acl=$goFonHardwareACL} - {$hardware_list} -{/render} -
- -
- - - - - - - - - - - - - -

-

{t}Graphic device{/t}

- - - - - - - - - - - - - -
-{render acl=$gotoXDriverACL} - -{/render} -
-{render acl=$gotoXResolutionACL} - -{/render } -
-{render acl=$gotoXColordepthACL} - -{/render} -
-
-   - -

{t}Display device{/t}

- - - - - - - - - - - - -{/render} - - - - -{/render} - -
{t}Type{/t}{$gotoXMonitor}
-{render acl=$AutoSyncACL} - -{/render} - {t}Use DDC for automatic detection{/t}
-{render acl=$gotoXHsyncACL} - kHz
-{render acl=$gotoXVsyncACL} - Hz
- -
-   - -

{t}Remote desktop{/t}

- - - - - - - - - - - - - - - - -
-{render acl=$gotoXMethodACL} - -{/render} -
-{render acl=$gotoXdmcpServerACL} - -{/render} -
-{render acl=$gotoFontPathACL} - -{/render} -
- -
- - - - - - - - - -

-

-{render acl=$gotoLpdEnableACL} - -{/render} - {t}Provide print services{/t} -
- - - - - - - -
-{render acl=$gotoLpdServerACL} - -{/render} -
- -
-   - -

{t}Scan device{/t}

-{render acl=$gotoScannerEnableACL} - -{/render} - {t}Provide scan services{/t} -
- - - - - - -
-{render acl=$gotoScannerEnableACL} - -{/render} -
- -
- -
diff --git a/plugins/admin/systems/terminalStartup.tpl b/plugins/admin/systems/terminalStartup.tpl deleted file mode 100644 index ccfacfbaa..000000000 --- a/plugins/admin/systems/terminalStartup.tpl +++ /dev/null @@ -1,142 +0,0 @@ -

{t}Boot parameters{/t}

- - - - - - - - -
- - - - - - - - - -{/render} - - - - -
-{render acl=$gotoBootKernelACL} - -{/render} -
-{render acl=$gotoKernelParametersACL} -
-{render acl=$gotoLdapServerACL} -( - {t}inherit from group{/t}) -{if !$JS} - -{/if} -{/render} -{render acl=$gotoLdapServerACL_inherit} - {$gotoLdapServers} -{/render} -{render acl=$gotoLdapServerACL_inherit} - -{/render} -{render acl=$gotoLdapServerACL_inherit} - -{/render} -
- -
-   - -{render acl=$gotoKernelParametersACL} - -{/render} - {t}use graphical bootup{/t} -
-{render acl=$gotoKernelParametersACL} - -{/render} - {t}use standard linux textual bootup{/t} -
-{render acl=$gotoKernelParametersACL} - -{/render} - {t}use debug mode for startup{/t} -
- - - - - - - - - -

-

- {t}Kernel modules (format: name parameters){/t} -

-{render acl=$gotoModulesACL} - -{/render} -
-{render acl=$gotoModulesACL} - -{/render} -{render acl=$gotoModulesACL} -   -{/render} -{render acl=$gotoModulesACL} - -{/render} -
-

 

- - - - -
-{render acl=$gotoShareACL} - -{/render} -
-{render acl=$gotoShareACL} - -{/render} -{render acl=$gotoShareACL} - -{/render} -{render acl=$gotoShareACL} - -{/render} -{render acl=$gotoShareACL} - -{/render} -
-
- - - - diff --git a/plugins/admin/systems/wingeneric.tpl b/plugins/admin/systems/wingeneric.tpl deleted file mode 100644 index fb58a6d66..000000000 --- a/plugins/admin/systems/wingeneric.tpl +++ /dev/null @@ -1,42 +0,0 @@ - - - - - -
- - - - - - - - - - - -
{$must}
 
{$must} - - -
-
- - - - - -
-
- -

 

- -{$netconfig} - - - diff --git a/plugins/admin/systems/workstation.tpl b/plugins/admin/systems/workstation.tpl deleted file mode 100644 index ba8489947..000000000 --- a/plugins/admin/systems/workstation.tpl +++ /dev/null @@ -1,157 +0,0 @@ -

{t}Properties{/t}

- - - - - -
- - -{if $cn eq 'wdefault'} - -{else} - - -{/if} - - - - - - - - - -
{t}Workstation template{/t}{$must} -{render acl=$cnACL} - -{/render} -
-{render acl=$lACL} - -{/render} -
{$must} -{render acl=$baseACL} - -{/render} -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-{if $member_of_ogroup} -
-
-
- -{/if} -
- - - - - - - - - -
{t}Mode{/t} -{render acl=$gotoModeACL} - -{/render} -
-{render acl=$gotoSyslogServerACL} - -{/render} -
-

 

- - - - - - - -
-{if $member_of_ogroup} -{render acl=$gotoNtpServerACL} - {t}Inherit time server attributes{/t} -{/render} -{else} - {t}Inherit time server attributes{/t} -{/if} -

-{render acl=$gotoNtpServerACL} - -{/render} -
-{render acl=$gotoNtpServerACL} - -{/render} -{render acl=$gotoNtpServerACL} - -{/render} -{render acl=$gotoNtpServerACL} - -{/render} -
-
-{if $cn neq 'wdefault'} -

 

- -{$netconfig} -{/if} -

 

- -{if $fai_activated} -

{t}Action{/t}

- - - - - -
-{render acl=$FAIstateACL} - -{/render} - - -
-{/if} - - {if $cn eq 'wdefault'} - - - {else} - - {/if} - diff --git a/plugins/admin/systems/workstationService.tpl b/plugins/admin/systems/workstationService.tpl deleted file mode 100644 index e5171fe01..000000000 --- a/plugins/admin/systems/workstationService.tpl +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - - - - - - - -
-

{t}Keyboard{/t}

- - - - - - - - - - - - - -
- -{render acl=$gotoXKbModelACL} - -{/render} - -
- -{render acl=$gotoXKbLayoutACL} - -{/render} - -
- -{render acl=$gotoXKbVariantACL} - -{/render} - -
- -
-   - -

{t}Mouse{/t}

- - - - -{/render} - - - - - - -
- -{render acl=$gotoXMouseTypeACL} - -
- -{render acl=$gotoXMouseportACL} - -{/render} - -
- -
-   - -

{t}Telephone hardware{/t}

- - - - -
{t}Telephone{/t}  - -{render acl=$goFonHardwareACL} - {$hardware_list} -{/render} - -
- -
- - - - - - - - - - - - - -

-

{t}Graphic device{/t}

- - - - - - - - - - - - - -
- -{render acl=$gotoXDriverACL} - -{/render} - -
- -{render acl=$gotoXResolutionACL} - -{/render} - -
- -{render acl=$gotoXColordepthACL} - -{/render} - -
-
-   - -

{t}Display device{/t}

- - - - - - - - - - - - - - - - - -
{t}Type{/t}{if $gotoXMonitor==""}{t}unknown{/t}{/if}{$gotoXMonitor}
- -{render acl=$AutoSyncACL} - -{/render} - - {t}Use DDC for automatic detection{/t}
- -{render acl=$gotoXHsyncACL} - kHz -{/render} - -
- -{render acl=$gotoXVsyncACL} - Hz -{/render} - -
- -
-   - - - -

{t}Scan device{/t}

- -{render acl=$gotoScannerEnableACL} - -{/render} - - {t}Provide scan services{/t} -
-
- - -
- - - - - - diff --git a/plugins/admin/systems/workstationStartup.tpl b/plugins/admin/systems/workstationStartup.tpl deleted file mode 100644 index d69b2ec72..000000000 --- a/plugins/admin/systems/workstationStartup.tpl +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - -
-

{t}Boot parameters{/t}

- - - - - - - - - - - - - -
-{render acl=$gotoBootKernelACL} - -{/render} -
-{render acl=$gotoKernelParametersACL} - -{/render} -
-{render acl=$gotoLdapServerACL} -{if $member_of_ogroup} -( - {t}inherit from group{/t}) -{if !$JS} - -{/if} -{/if} -{/render} -{render acl=$gotoLdapServerACL_inherit} - {$gotoLdapServers} -{/render} -{render acl=$gotoLdapServerACL_inherit} - -{/render} -{render acl=$gotoLdapServerACL_inherit} - -{/render} -
- -
-   - - - {if $fai_activated} - - {if $FAIdebianMirror == "inherited"} - - - - - - - - - - -
-

 {t}FAI server{/t} -

-
-

 {t}Release{/t} -

-
- {render acl=$FAIdebianMirrorACL} - - {/render} - - -
-

-  {t}Assigned FAI classes{/t} -

- {render acl=$FAIclassACL} - {$FAIScriptlist} - {/render} - {else} - - - - - - - - - - -
-

 {t}FAI server{/t} -

-
-

 {t}Release{/t} -

-
- {render acl=$FAIdebianMirrorACL} - - {/render} - {if $javascript eq 'false'} - {render acl=$FAIdebianMirrorACL} - - {/render} - {/if} - - {render acl=$FAIreleaseACL} - - {/render} -
-

-  {t}Assigned FAI classes{/t} -

- {render acl=$FAIclassACL} - {$FAIScriptlist} - {/render} - - {render acl=$FAIclassACL} - - {/render} - {render acl=$FAIclassACL} - - {/render} - - {/if} - - {else} - -

{t}FAI Object assignment disabled. You can't use this feature until FAI is activated.{/t}

- - {/if} -
- - - - - - - - - -

-

- {t}Kernel modules (format: name parameters){/t} -

-{render acl=$gotoModulesACL} - -{/render} -
-{render acl=$gotoModulesACL} - -{/render} -{render acl=$gotoModulesACL} -   -{/render} -{render acl=$gotoModulesACL} - -{/render} -
-

 

- - - - -
-{render acl=$gotoShareACL} - -{/render} -
-{render acl=$gotoShareACL} - -{/render} -{render acl=$gotoShareACL} - -{/render} -{render acl=$gotoShareACL} - -{/render} -{render acl=$gotoShareACL} - -{/render} -
-
- - - diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc deleted file mode 100644 index 6ba71d714..000000000 --- a/plugins/admin/users/class_divListUsers.inc +++ /dev/null @@ -1,435 +0,0 @@ -parent = $parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of users")); - $this->SetSummary(_("List of users")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to create, edit and delete selected users. Having a great number of users, you may want to use the range selectors on top of the user list.")); - - $this->EnableAplhabet (true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 122; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=> " ", "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>_("Username")." / "._("Department"))); - $this->AddHeader(array("string"=>_("Properties"), "attach" => "style='width:166px;'")); - $this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); - - $this->AddCheckBox("ShowTemplates" ,_("Select to see template pseudo users") ,_("Show templates") , false); - $this->AddCheckBox("ShowFunctionalUsers",_("Select to see users that have only a GOsa object"),_("Show functional users") , true); - $this->AddCheckBox("ShowUnixUsers" ,_("Select to see users that have posix settings") ,_("Show unix users") , true); - $this->AddCheckBox("ShowMailUsers" ,_("Select to see users that have mail settings") ,_("Show mail users") , true); - $this->AddCheckBox("ShowSambaUsers" ,_("Select to see users that have samba settings") ,_("Show samba users") , true); - $this->AddCheckBox("ShowProxyUsers" ,_("Select to see users that have proxy settings") ,_("Show proxy users") , true); - - /* Add SubSearch checkbox */ - $this->AddCheckBox(SEPERATOR); - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Display users matching"),"*" , true); - } - - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("users"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get copy & paste icon */ - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"users") ; - $acl = $ui->get_permissions($this->selectedBase,"users/user"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - $listhead .= - _("Base")." ". - "  "; - - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("User")."|user_new|\n"; - $s.= "...|". - " "._("Template")."|user_tplnew|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Edit")."|"."multiple_edit|\n"; - $s.= "..|". - " "._("Change password")."|"."multiple_password_change|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - } - - /* so some basic settings */ - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - /******************** - Variable init - ********************/ - - $num_users = 0; - $num_templates = 0; - - /* Variable initialation */ - $enviro = $posix = $maila = $faxac = $samba = $netatalk = ""; - $empty = "-"; - $userimg = "User"; - $tplimg = "Template"; - $editlink = "%s"; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 122; - if($this->parent->snapshotEnabled()){ - $action_col_size += 38; - } - - /* Possilbe objectClass image combinations */ - $possibleAccounts = array( - "posixAccount" => array("VAR"=>"posix" ,"IMG"=>"posiximg"), - "gotoEnvironment" => array("VAR"=>"enviro" ,"IMG"=>"eviroimg"), - "gosaMailAccount" => array("VAR"=>"maila" ,"IMG"=>"mailimg"), - "goFaxAccount" => array("VAR"=>"faxac" ,"IMG"=>"faximg"), - "sambaSamAccount" => array("VAR"=>"samba" ,"IMG"=>"sambaimg"), - "apple-user" => array("VAR"=>"netatalk" ,"IMG"=>"netatalkimg")); - - /* Pictures for Extensions */ - $usrimg =""; - $posiximg = ""; - $eviroimg = ""; - $mailimg = ""; - $fonimg = ""; - $faximg = ""; - $sambaimg = ""; - $netatalkimg = ""; - $tplcreateuserimg = ""; - - /******************** - END :: Variable init - ********************/ - - - /******************** - Append entries to divlist - ********************/ - - $ui = get_userinfo(); - - // Test Every Entry and generate divlist Array - foreach($list as $key => $val){ - - /* Create action icons */ - $action= ""; - - /* Add copy & cut icons */ - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"users") ; - $acl = $ui->get_permissions($val['dn'],"users/user"); - if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){ - $action .= " "; - $action.= " "; - } - - /* Add deactivate status */ - $lock_status = ""; - - if(isset($val['userPassword'][0]) && preg_match("/^\{[^\}]/",$val['userPassword'][0])){ - if(preg_match("/^[^\}]*+\}!/",$val['userPassword'][0])){ - $lock_status = ""; - }else{ - $lock_status = ""; - } - }else{ - $lock_status = " "; - } - - /* Generate edit icon */ - $action.= ""; - - /* Add deactivate status if we are allowed to */ - if (preg_match("/w/",$acl_all)){ - $action.= $lock_status; - } - - /* Add Password change icon, if we are able to write users/password */ - if(!in_array_ics("gosaUserTemplate",$val['objectClass']) && preg_match("/w/",$ui->get_permissions($val['dn'],"users/password"))) { - $action.= ""; - }else{ - $action.= " "; - } - - /* Add snapshot icon */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $action.= $this->GetSnapShotActions($val['dn']); - } - - /* Add remove icon, if we are allowed to remove the current user */ - if(preg_match("/d/",$ui->get_permissions($val['dn'],"users/user"))) { - $action.= ""; - }else{ - $action.= " "; - } - - /* Create phonaccopunt informationm, if conencted && is phoneAccount */ - if((in_array("goFonAccount" ,$val['objectClass']))){ - - /* Set defaults */ - $fonac = preg_replace("/%image%/", "select_phone.png", $fonimg); - $fonac = preg_replace("/%KEY%/", "$key", $fonac); - $fonac = preg_replace("/%title%/", "", $fonac); - - }else{ - $fonac=$empty; - } - - /* Set images for different types of objectClasses */ - foreach($possibleAccounts as $objectClass => $Settigns){ - if(in_array($objectClass ,$val['objectClass'])){ - $$Settigns['VAR'] = preg_replace("/%KEY%/", "$key", $$Settigns['IMG']); - }else{ - $$Settigns['VAR'] = $empty; - } - } - - /* Create userimg */ - if(in_array("gosaUserTemplate",$val['objectClass'])){ - $tpl = preg_replace("/%KEY%/", "$key", $tplimg); - $s_img_create_from_template = preg_replace("/%KEY%/", "$key", $tplcreateuserimg); - $num_templates ++; - }else{ - $s_img_create_from_template = ""; - $tpl = $userimg; - $num_users ++; - } - - /* Insert key into userimg */ - $usrimg2 = preg_replace("/%KEY%/", "$key", $usrimg); - - // Generate caption for rows - if (isset($val["sn"]) && isset($val["givenName"])){ - $display= $val["sn"][0].", ".$val["givenName"][0]." [".$val["uid"][0]."]"; - } else { - $display= "[".$val["uid"][0]."]"; - } - - /* Connect all images */ - $UseImg = $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$netatalk; - - /* Cutted objects should be displayed in light grey */ - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => sprintf($tpl,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); - $field3 = array("string" => $UseImg, "attach" => "style='width:166px;'"); - $field4 = array("string" => $s_img_create_from_template.preg_replace("/%KEY%/", "$key", $action), - "attach" => "style='width:".$action_col_size."px;border-right:0px; text-align:right;'"); - /* Add to list */ - $add = array($field0,$field1,$field2,$field3,$field4); - $this->AddElement($add); - - // Template or User - if(in_array("gosaUserTemplate",$val['objectClass'])){ - $tpls[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add; - }else{ - $users[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add; - } - } - - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_users = count($list); - - $num_user_str = _("Number of listed users"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_user_str." ".$num_users."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow::save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc deleted file mode 100644 index a031e89d9..000000000 --- a/plugins/admin/users/class_userManagement.inc +++ /dev/null @@ -1,1117 +0,0 @@ - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -class userManagement extends plugin -{ - /* Plugin definitions */ - var $plHeadline= "Users"; - var $plDescription= "This does something"; - - /* Dialog attributes */ - var $usertab = NULL; - var $ui = NULL; - var $templates = array(); - var $got_uid = false; - var $CopyPasteHandler = NULL; - var $CPPasswordChange = ""; // Contains the entry id which should get a new password - var $DivListUsers; - - var $pwd_change_queue = array(); - - var $start_pasting_copied_objects = FALSE; - var $current_action =""; - var $msg_dialog= NULL; - - function userManagement(&$config, $ui) - { - /* Save configuration for internal use */ - $this->config= &$config; - $this->ui= &$ui; - - /* Copy & Paste handler */ - if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){ - $this->CopyPasteHandler= new CopyPasteHandler($this->config); - } - - /* Creat dialog object */ - $this->DivListUsers = new divListUsers($this->config,$this); - - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* LOCK MESSAGE Vars */ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_users/","/^multiple_edit/","/menu_action/"); - - $smarty = get_smarty(); // Smarty instance - $s_action = ""; // Contains the action to be taken - $s_entry = ""; // The value for s_action - - /* Edit entry button pressed? */ - if( isset($_GET['act']) && $_GET['act'] == "edit_entry" ){ - $s_action= "edit"; - $s_entry= validate($_GET['id']); - } - - /* Test relevant POST values */ - foreach($_POST as $key => $val){ - - /* Get every possible POST combination and set s_action/s_entry accordingly */ - foreach(array("del" => "user_del", - "edit" => "user_edit", - "new" => "user_new", - "new_tpl" => "user_tplnew", - "del_multiple" => "^remove_multiple_users", - "create_user_from_tpl" => "userfrom_tpl", - "change_pw" => "user_chgpw", - "editPaste" => "editPaste", - "copy_multiple" => "multiple_copy_users", - "multiple_edit" => "multiple_edit", - "cut_multiple" => "multiple_cut_users", - "multiple_password_change" => "multiple_password_change", - "copy" => "^copy", - "toggle_lock_status" => "toggle_lock_status", - "cut" => "^cut") as $act => $name){ - - if (preg_match("/".$name.".*/", $key)){ - $s_action= $act; - $s_entry= preg_replace("/".$name."_/i", "", $key); - break; - } - } - - } /* ...Test POST */ - - /* Remove coordinate prefix from POST, required by some browsers */ - $s_entry= preg_replace("/_.$/", "", $s_entry); - - /* Seperate possibly encoded tab and entry, default to tab "user" */ - if(preg_match("/.*-.*/", $s_entry)){ - $s_tab= preg_replace("/^[^-]*-/i", "" ,$s_entry); - $s_entry= preg_replace("/-[^-]*$/i", "", $s_entry); - }else{ - $s_tab= "user"; - } - - if(!$this->config->search($s_tab, 'class',array('tabs'))){ - $s_tab = "user"; - } - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "user_new"){ - $s_action = "new"; - } - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "user_tplnew"){ - $s_action = "new_tpl"; - } - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "multiple_edit"){ - $s_action = "multiple_edit"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_password_change/",$_POST['menu_action'])){ - $s_action = "multiple_password_change"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - /******************** - Copy & Paste - ********************/ - - /* Display the copy & paste dialog, if it is currently open */ - if($this->CPPasswordChange == ""){ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - } - - - /******************** - Change password confirmed - ********************/ - - /* Perform password change */ - if (isset($_POST['password_finish'])){ - - /* For security reasons, check if user is allowed to set password again */ - $dn = $this->dn; - $acl = $this->ui->get_permissions($dn, "users/password"); - $cacl= $this->ui->get_permissions($dn, "users/user"); - - if (preg_match('/w/', $acl) || preg_match('/c/', $cacl)){ - - /* Check input and feed errors into 'message' */ - $message= array(); - - /* Sanity checks... */ - if ($_POST['new_password'] != $_POST['repeated_password']){ - - /* Matching passwords in new and repeated? */ - $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match."); - } else { - - /* Empty password is not permitted by default. */ - if ($_POST['new_password'] == ""){ - $message[]= _("The password you've entered as 'New password' is empty."); - } - } - - /* Errors, or password change? */ - if (count($message) != 0){ - - /* Show error message and continue editing */ - show_errors ($message); - return($smarty->fetch(get_template_path('password.tpl', TRUE))); - } - - $config= $this->config; - $ldap_ui= $this->config->get_ldap_link(); - if(isset($this->usertab->dn)){ - $ldap_ui->cat($this->usertab->dn,array("uid")); - $user = $ldap_ui->fetch(); - }else{ - $ldap_ui->cat($this->dn,array("uid")); - $user = $ldap_ui->fetch(); - } - if((is_array($user))&&(isset($user['uid']))){ - $username= $user['uid'][0]; - } - - /* Set password, perform required steps */ - if ($this->usertab){ - if ($this->usertab->password_change_needed()){ - $obj= $this->usertab->by_object['user']; - change_password ($this->usertab->dn, $_POST['new_password'],0, $obj->pw_storage); - if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){ - exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr); - } - new log("modify","users/".get_class($this),$this->usertab->dn,array(),"Password has been changed"); - unset($this->usertab); - $this->usertab= NULL; - } - } else { - change_password ($this->dn, $_POST['new_password']); - if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){ - exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr); - } - new log("modify","users/".get_class($this),$this->dn,array(),"Password has been changed"); - } - } else { - - /* Missing permissions, show message */ - msg_dialog::display(_("Password change failed."),_("You are not allowed to set this users password!"),WARNING_DIALOG); - } - /* Clean session, delete lock */ - del_lock ($this->dn); - unset ($this->usertab); - $this->usertab= NULL; - $this->lognames= array();; - $this->sn= ""; - $this->givenName= ""; - $this->uid= ""; - unset ($_SESSION['objectinfo']); - } - - - /******************** - Change multiple passwords requested - ********************/ - - if($s_action == "multiple_password_change"){ - $this->pwd_change_queue = $this->list_get_selected_items(); - } - - - /******************** - Change password requested - ********************/ - - /* Password change requested */ - if (($s_action == "change_pw") || (!empty($this->CPPasswordChange)) || count($this->pwd_change_queue)){ - - /* Get users whose passwords should be changed. */ - if(count($this->pwd_change_queue)){ - $s_entry= array_pop($this->pwd_change_queue); - } - - if(!empty($this->CPPasswordChange)){ - $s_entry = $this->CPPasswordChange; - $this->CPPasswordChange = ""; - } - - /* Get 'dn' from posted 'uid' */ - $this->dn= $this->list[trim($s_entry)]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - if (preg_match("/w/",$this->ui->get_permissions($this->dn,"users/password"))){ - - /* User is allowed to change passwords, save 'dn' and 'acl' for next - dialog. */ - $_SESSION['objectinfo']= $this->dn; - return ($smarty->fetch(get_template_path('password.tpl', TRUE))); - - - } else { - /* User is not allowed. Show message and cancel. */ - msg_dialog::display(_("Password change"),_("You are not allowed to set this users password!"),WARNING_DIALOG); - } - } - - - - /******************** - Edit existing entry - ********************/ - - /* User wants to edit data? */ - if (($s_action=="edit") && (!isset($this->usertab->config))){ - - /* Get 'dn' from posted 'uid', must be unique */ - $this->dn= $this->list[trim($s_entry)]['dn']; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so everyone will get the - above dialog */ - add_lock ($this->dn, $this->ui->dn); - - /* Register usertab to trigger edit dialog */ - $this->usertab= new usertabs($this->config, - $this->config->data['TABS']['USERTABS'], $this->dn); - - /* Switch tab, if it was requested by the user */ - $this->usertab->current = $s_tab; - - /* Set ACL and move DN to the headline */ - $this->usertab->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; - } - - - /******************** - Edit multiple entries - ********************/ - - /* User wants to edit data? */ - if ($s_action == "multiple_edit" && !isset($this->usertab->config)){ - - $this->dn = array(); - foreach($this->list_get_selected_items() as $id){ - $this->dn[] = $this->list[$id]['dn'];; - } - $tmp = new multi_plug($this->config,"usertabs",$this->config->data['TABS']['USERTABS'], - $this->dn,$this->DivListUsers->selectedBase,"user"); - if ($tmp->entries_locked()){ - return($tmp->display_lock_message()); - } - $tmp->lock_entries($this->ui->dn); - if($tmp->multiple_available()){ - $this->usertab = $tmp; - $this->usertab->set_active_tab($s_tab); - $_SESSION['objectinfo']= $this->usertab->get_object_info(); - } - } - - - /******************** - Edit canceled - ********************/ - - /* Reset all relevant data, if we get a _cancel request */ - if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ - if (isset($this->usertab)){ - del_lock ($this->usertab->dn); - unset ($this->usertab); - } - $this->usertab= NULL; - $this->lognames= array();; - $this->sn= ""; - $this->givenName= ""; - $this->uid= ""; - unset ($_SESSION['objectinfo']); - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - $this->dns = array(); - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->list[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $info = sprintf(_("You're about to delete the following entry: %s"), @LDAP::fix($dns_names)); - } else { - $info = sprintf(_("You're about to delete the following entries: %s"), @LDAP::fix($dns_names)); - } - $this->msg_dialog = new msg_dialog(_("Delete users"),$info,CONFIRM_DIALOG); - $this->current_action = $s_action; - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if ($this->current_action == "del_multiple" && is_object($this->msg_dialog) && $this->msg_dialog->is_confirmed()){ - - $this->current_action = ""; - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - $acl = $this->ui->get_permissions($dn, "users/user"); - if (preg_match('/d/', $acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$dn); - $this->usertab->set_acl_base(); - $this->usertab->delete (); - unset ($this->usertab); - $this->usertab= NULL; - } else { - msg_dialog::display(_("User delete"),sprintf(_("You are not allowed to delete the user '%s'!"),$dn),WARNING_DIALOG); - if(isset($this->ui->uid)){ - new log("security","users/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_user_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Toggle lock status for user - ********************/ - - if($s_action == "toggle_lock_status" && isset($this->list[$s_entry])){ - - /* Get entry check current status */ - $val = $this->list[$s_entry]; - $pwd = $val['userPassword'][0]; - - if(!preg_match("/^\{[^\}]/",$pwd)){ - trigger_error("Can not deactivate user which is using clear password encryption."); - }else{ - - $locked = false; - if(preg_match("/^[^\}]*+\}!/",$pwd)){ - $locked = true; - } - - /* Create ldap array to update status */ - $attrs = array("userPassword" => $pwd); - if($locked){ - $attrs['userPassword'] = preg_replace("/(^[^\}]+\})!(.*$)/","\\1\\2",$attrs['userPassword']); - }else{ - $attrs['userPassword'] = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$attrs['userPassword']); - } - - /* Write new status back to ldap */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($val['dn']); - $ldap->modify($attrs); - if($locked){ - show_ldap_error($ldap->get_error(),_("Could not set user status from locked to unlocked.")); - }else{ - show_ldap_error($ldap->get_error(),_("Could not set user status from unlocked to locked.")); - } - } - } - - - /******************** - Delete entry requested, display confirm dialog - ********************/ - - /* Remove user was requested */ - if ($s_action=="del"){ - - /* Get 'dn' from posted 'uid' */ - $this->dn= $this->list[trim($s_entry)]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - - /* Lock the current entry, so nobody will edit it during deletion */ -# add_lock ($this->dn, $this->ui->dn); -# $smarty->assign("info", sprintf(_("You're about to delete the user %s."), @LDAP::fix($this->dn))); -# $smarty->assign("multiple", false); -# return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - $this->msg_dialog = new msg_dialog( _("Delete user"),sprintf(_("You're about to delete the user %s."), @LDAP::fix($this->dn)),CONFIRM_DIALOG); - $this->current_action = $s_action; - } - - - /******************** - Delete entry confirmed - ********************/ - - /* Confirmation for deletion has been passed. User should be deleted. */ - if ($this->current_action == "del" && is_object($this->msg_dialog) && $this->msg_dialog->is_confirmed()){ - - $this->current_action = ""; - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - - $acl = $this->ui->get_permissions($this->dn, "users/user"); - - if (preg_match('/d/', $acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$this->dn); - $this->usertab->set_acl_base(); - $this->usertab->delete (); - unset ($this->usertab); - $this->usertab= NULL; - msg_dialog::display(_("User delted"),_("User successfully removed."),INFO_DIALOG); - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - msg_dialog::display(_("User delete"),_("You are not allowed to delete this user!"),WARNING_DIALOG); - - if(isset($this->ui->uid)){ - new log("security","users/".get_class($this),$this->dn,array(),"Tried to trick deletion."); - } - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - - /******************** - Delete entry Canceled - ********************/ - - /* Delete user canceled? */ - if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); - } - - - /******************** - Edit entry finished (Save) - ********************/ - - /* Finish user edit is triggered by the tabulator dialog, so - the user wants to save edited data. Check and save at this - point. */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->usertab->config))){ - - /* Check tabs, will feed message array */ - $this->usertab->last= $this->usertab->current; - $this->usertab->save_object(); - $message= $this->usertab->check(); - - /* Save, or display error message? */ - if (count($message) == 0){ - - /* No errors. Go ahead and prepare to ask for a password - in case we're creating a new user. 'dn' will be 'new' - in this case. It is set to the correct value later. */ - if ($this->dn == "new"){ - $set_pass= 1; - } else { - $set_pass= 0; - } - - /* Save user data to ldap */ - if($this->usertab->save() == 1){ - return; - } - - if (!isset($_POST['edit_apply'])){ - /* User has been saved successfully, remove lock from LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - - /* In case of new users, ask for a password, skip this for templates */ - if (($set_pass || $this->usertab->password_change_needed()) && !$this->is_template){ - $this->dn = $this->usertab->dn; - return($smarty->fetch(get_template_path('password.tpl', TRUE))); - } - - unset ($this->usertab); - $this->usertab= NULL; - unset ($_SESSION['objectinfo']); - } - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /******************** - We want to create a new user, so fetch all available user templates - ********************/ - - /* Generate template list */ - if (($s_action=="new")||($s_action=="create_user_from_tpl")){ - - $this->templates= array(); - $ldap= $this->config->get_ldap_link(); - - /* Create list of templates */ - foreach ($this->config->departments as $key => $value){ - - /* Get acls from different ou's */ - $acl = $this->ui->get_permissions("cn=dummy,".get_people_ou().$value,"users/user") ; - - /* If creation of a new user is allowed, append this template */ - if (preg_match("/c/",$acl)){ - - /* Search all templates from the current dn */ - $ldap->cd (get_people_ou().$value); - $ldap->search ("(objectClass=gosaUserTemplate)", array("uid")); - - /* Append */ - if ($ldap->count() != 0){ - while ($attrs= $ldap->fetch()){ - $this->templates[$ldap->getDN()]= - $attrs['uid'][0]." - ".@LDAP::fix($key); - } - $this->templates['none']= _("none"); - } - } - } - - /* Sort templates */ - natcasesort ($this->templates); - reset ($this->templates); - } - - - /******************** - Create a new user,template, user from template - ********************/ - - /* Check selected options for template */ - if (isset($_POST['template_continue'])){ - $message = array(); - if(!isset($_POST['template']) || (empty($_POST['template']))){ - $message[] = _("Please select a valid template."); - } - if(!isset($_POST['sn']) || (empty($_POST['sn']))){ - $message[]= _("The required field 'Name' is not set."); - } - if(!isset($_POST['givenName']) || (empty($_POST['givenName']))){ - $message[]= _("The required field 'Given name' is not set."); - } - - /* Show error message / continue editing */ - if (count($message) > 0){ - show_errors ($message); - - foreach(array("sn", "givenName", "uid", "template") as $attr){ - if(isset($_POST[$attr])){ - $smarty->assign("$attr", $_POST[$attr]); - }else{ - $smarty->assign("$attr", ""); - } - } - $smarty->assign("templates",$this->templates); - $smarty->assign("got_uid",$this->got_uid); - $smarty->assign("edit_uid",false); - return($smarty->fetch(get_template_path('template.tpl', TRUE))); - - } - } - - /* New user/template request */ - if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){ - /* By default we set 'dn' to 'new', all relevant plugins will - react on this. */ - $this->dn= "new"; - - if (isset($this->config->current['IDGEN'])){ - $this->got_uid= false; - } else { - $this->got_uid= true; - } - - /* Create new usertab object */ - $this->usertab= new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn); - $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase; - $this->usertab->set_acl_base('dummy,'.$this->DivListUsers->selectedBase); - - /* Take care about templates */ - if ($s_action=="new_tpl"){ - $this->is_template= TRUE; - $this->usertab->set_template_mode (); - } else { - $this->is_template= FALSE; - } - - /* Use template if there are any of them */ - if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){ - foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){ - $smarty->assign("$attr", $this->$attr); - } - if ($s_action=="create_user_from_tpl"){ - $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']); - } else { - $smarty->assign("template", "none"); - } - $smarty->assign("edit_uid", ""); - return($smarty->fetch(get_template_path('template.tpl', TRUE))); - } - } - - /******************** - Template selected continue edit - ********************/ - - /* Continue template editing */ - if ((isset($_POST['template_continue'])) && ($_POST['template'] != 'none') && (!isset($_POST['uid']))){ - - $this->sn = $_POST['sn']; - $this->givenName = $_POST['givenName']; - - /* Check for requred values */ - $message= array(); - if ($this->sn == "") { - $message[]= _("The required field 'Name' is not set."); - } - if ($this->givenName == "") { - $message[]= _("The required field 'Given name' is not set."); - } - - /* Check if dn is used */ - $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']); - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($dn); - $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName")); - if ($ldap->count () != 0){ - $message[]= _("A person with the choosen name is already used in this tree."); - } - - /* Show error message / continue editing */ - if (count($message) > 0){ - show_errors ($message); - } else { - $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName); - if (isset($this->config->current['IDGEN']) && - $this->config->current['IDGEN'] != ""){ - $uids= gen_uids ($this->config->current['IDGEN'], $attributes); - if (count($uids)){ - $smarty->assign("edit_uid", "false"); - $smarty->assign("uids", $uids); - $this->uid= current($uids); - } - } else { - $smarty->assign("edit_uid", ""); - $this->uid= ""; - } - $this->got_uid= true; - } - - foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){ - $smarty->assign("$attr", $this->$attr); - } - if (isset($_POST['template'])){ - $smarty->assign("template", $_POST['template']); - } - return($smarty->fetch(get_template_path('template.tpl', TRUE))); - } - - /******************** - No template selected continue edit - ********************/ - - /* No template. Ok. Lets fill data into the normal user dialog */ - if (isset($_POST['template_continue']) && $_POST['template'] == 'none'){ - foreach(array("sn", "givenName", "uid") as $attr){ - if (isset($_POST[$attr])){ - $this->usertab->by_object['user']->$attr= $_POST[$attr]; - } - } - } - - - /******************** - Template selected continue edit - ********************/ - - /* Finish template preamble */ - if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){ - - /* Might not be filled if IDGEN is unset */ - $this->sn = $_POST['sn']; - $this->givenName = $_POST['givenName']; - - /* Move user supplied data to sub plugins */ - $this->uid = $_POST['uid']; - $this->usertab->uid = $this->uid; - $this->usertab->sn = $this->sn; - $this->usertab->givenName = $this->givenName; - $template_dn = $_POST['template']; - $this->usertab->adapt_from_template($template_dn); - $template_base = preg_replace("/^[^,]+,".normalizePreg(get_people_ou())."/", '', $template_dn); - $this->usertab->by_object['user']->base= $template_base; - } - - - /******************** - If no template was selected set base - ********************/ - - if (isset($_POST['template_continue']) && ($_POST['template'] == 'none')){ - $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase; - } - - - /******************** - Display subdialog - ********************/ - - /* Show tab dialog if object is present */ - if(isset($this->usertab->config)){ - $display= $this->usertab->execute(); - - /* Don't show buttons if tab dialog requests this */ - - $dia = FALSE; - if(isset($this->usertab->by_object[$this->usertab->current]->dialog)){ - $dia = $this->usertab->by_object[$this->usertab->current]->dialog; - } - - if(!is_object($dia) && $dia != TRUE){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - return ($display); - } - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListUsers->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Return rendered main page */ - /* Display dialog with system list */ - $this->DivListUsers->parent = $this; - $this->DivListUsers->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListUsers->SubSearch){ - $this->DivListUsers->AddDepartments($this->DivListUsers->selectedBase,4,1); - } - $this->reload(); - $this->DivListUsers->setEntries($this->list); - return($this->DivListUsers->Draw()); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array(get_people_ou().$this->DivListUsers->selectedBase)); - } - - - function reload() - { - /* Set base for all searches */ - $base= $this->DivListUsers->selectedBase; - $this->list =array(); - - /* Get filter configuration */ - $Regex = $this->DivListUsers->Regex; - $SubSearch = $this->DivListUsers->SubSearch; - $ShowTemplates = $this->DivListUsers->ShowTemplates; - $ShowFunctionalUsers = $this->DivListUsers->ShowFunctionalUsers; - $ShowUnixUsers = $this->DivListUsers->ShowUnixUsers; - $ShowMailUsers = $this->DivListUsers->ShowMailUsers; - $ShowSambaUsers = $this->DivListUsers->ShowSambaUsers; - $ShowProxyUsers = $this->DivListUsers->ShowProxyUsers; - - /* Setup filter depending on selection */ - $filter=""; - if ($this->config->current['SAMBAVERSION'] == 3){ - $samba= "sambaSamAccount"; - } else { - $samba= "sambaAccount"; - } - - if ($ShowFunctionalUsers){ - $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)". - "(objectClass=gosaMailAccount)(objectClass=$samba)". - "(objectClass=gosaProxyAccount))))"; - } - if ($ShowUnixUsers){ - $filter.= "(objectClass=posixAccount)"; - } - if ($ShowMailUsers){ - $filter.= "(objectClass=gosaMailAccount)"; - } - if ($ShowSambaUsers){ - $filter.= "(objectClass=$samba)"; - } - if ($ShowProxyUsers){ - $filter.= "(objectClass=gosaProxyAccount)"; - } - if ($ShowTemplates){ - $filter= "(|(objectClass=gosaUserTemplate)(&(objectClass=gosaAccount)(|$filter)))"; - } else { - $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|$filter))"; - } - $filter= "(&(|(uid=".normalizeLdap($Regex).")(sn=".normalizeLdap($Regex).")(givenName=".normalizeLdap($Regex)."))$filter)"; - - /* Generate userlist */ - $ldap= $this->config->get_ldap_link(TRUE); - - if ($SubSearch){ - $ListTemp = get_list($filter, "users", $base, - array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SUBSEARCH | GL_SIZELIMIT); - } else { - $base= get_people_ou().$base; - $ListTemp = get_list($filter, "users", $base, - array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SIZELIMIT); - } - $SortTemp = array(); - $List = array(); - foreach($ListTemp as $Key => $Entry){ - - /* Skip entries that are not located under the people ou (normaly 'ou=people,') - * Else winstations will be listed too, if you use the subtree flag. - */ - if(!preg_match("/".normalizePreg(get_people_ou())."/i",$Entry['dn'])){ - continue; - }else{ - - // Generate caption for rows - if (isset($Entry["sn"]) && isset($Entry["givenName"])){ - $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]"; - } else { - $display= "[".$Entry["uid"][0]."]"; - } - - $display = strtolower($display); - $List[$display] = $Entry; - $SortTemp[$display] = $display; - } - } - sort($SortTemp); - reset($SortTemp); - - $this->list = array(); - foreach($SortTemp as $Key){ - $this->list[] = $List[$Key]; - } - } - - function remove_lock() - { - /* Remove user lock if a DN is marked as "currently edited" */ - if (isset($this->usertab->dn)){ - del_lock ($this->usertab->dn); - } - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->list[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"usertabs","USERTABS","users"); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->list[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","usertabs","USERTABS","users"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","usertabs","USERTABS","users"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListUsers->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */ - if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){ - $s_entry = $this->CopyPasteHandler->last_entry(); - $this->reload(); - foreach($this->list as $key => $entry){ - if($entry['dn'] == $s_entry){ - $this->CPPasswordChange = $key; - } - } - } - - /* Return dialog data */ - if(!empty($data) && $this->CPPasswordChange == ""){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - function save_object() - { - /* Handle divlist filter && department selection*/ - if(!is_object($this->usertab)){ - $this->DivListUsers->save_object(); - } - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - /* A set of disabled and therefore overloaded functions. They are - not needed in this class. */ - function remove_from_parent() { } - function check() { } - function save() { } - function adapt_from_template($dn) { } - function password_change_needed() { } - -} /* ... class userManagement */ -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/users/main.inc b/plugins/admin/users/main.inc deleted file mode 100644 index d545835f7..000000000 --- a/plugins/admin/users/main.inc +++ /dev/null @@ -1,65 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('userManagement'); - } -} else { - /* Create usermanagement object on demand */ - if (!isset($_SESSION['userManagement']) || - (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['userManagement']= new userManagement ($config, $_SESSION['ui']); - $_SESSION['userManagement']->set_acl_category("users"); - } - $userManagement= $_SESSION['userManagement']; - $userManagement->save_object(); - $output= $userManagement->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/user.png'), - _("User administration"), - "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/user.png'), - _("User administration")); - } - - /* Generate dialog output */ - $display.= $output; - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('userManagement'); - } - - /* Show and save dialog */ - $_SESSION['userManagement']= $userManagement; -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/users/password.tpl b/plugins/admin/users/password.tpl deleted file mode 100644 index 83dfc2494..000000000 --- a/plugins/admin/users/password.tpl +++ /dev/null @@ -1,32 +0,0 @@ -

- {t}To change the user password use the fields below. The changes take effect immediately. Please memorize the new password, because the user wouldn't be able to login without it.{/t} -

- -

- {t}Changing the password affects your authentification on mail, proxy, samba and unix services.{/t} -

- - - - - - - - - - -
-
-

- -   - -

- - - diff --git a/plugins/admin/users/remove.tpl b/plugins/admin/users/remove.tpl deleted file mode 100644 index eb4147166..000000000 --- a/plugins/admin/users/remove.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - - - {else} - - - {/if} -   -

- diff --git a/plugins/admin/users/tabs_user.inc b/plugins/admin/users/tabs_user.inc deleted file mode 100644 index c6565337e..000000000 --- a/plugins/admin/users/tabs_user.inc +++ /dev/null @@ -1,142 +0,0 @@ -base= $this->by_object['user']->base; - - /* Add references/acls/snapshots */ - $this->addSpecialTabs(); - - } - - function save_object($save_current= FALSE) - { - tabs::save_object($save_current); - - /* Update reference, transfer variables */ - $baseobject= $this->by_object['user']; - foreach ($this->by_object as $name => $obj){ - - /* Adding uid to sub plugins of connectivity */ - if($name == "connectivity"){ - foreach ($obj->plugin_name as $plg_name){ - if(isset($obj->plugin[$plg_name]->uid)){ - $obj->plugin[$plg_name]->uid = $baseobject->uid; - } - } - } - - /* Don't touch base object */ - if ($name != 'user'){ - $obj->parent= &$this; - $obj->uid= $baseobject->uid; - $obj->sn= $baseobject->uid; - $obj->givenName= $baseobject->uid; - } - - /* Copy mail if needed */ - if ($name == "gofaxAccount"){ - if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){ - $obj->mail= $this->by_object['mailAccount']->mail; - } - } - - $this->by_object[$name]= $obj; - - /* Update parent in base object */ - $this->by_object['user']->parent= &$this; - } - - /* Move facsimile / phone number if nessecary */ - if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){ - - /* Move number to fax plugin */ - $this->by_object['gofaxAccount']->facsimileTelephoneNumber= - $this->by_object['user']->facsimileTelephoneNumber; - - /* Move phone number if plugin exists */ - if (isset($this->by_object['phoneAccount']) && - !$this->by_object['phoneAccount']->is_account){ - $this->by_object['phoneAccount']->phoneNumbers= array(); - if ($this->by_object['user']->telephoneNumber != ""){ - $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber; - } - } - } - - /* Move number from fax plugin */ - if ($this->last == "gofaxAccount"){ - - $this->by_object['user']->facsimileTelephoneNumber= - $this->by_object['gofaxAccount']->facsimileTelephoneNumber; - } - - /* Move number from fax plugin */ - if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){ - reset($this->by_object['phoneAccount']->phoneNumbers); - $number= key($this->by_object['phoneAccount']->phoneNumbers); - - /* Only the first phoneAccount number, if it is not empty */ - if(!empty($number)){ - $this->by_object['user']->telephoneNumber= $number; - } - } - - /* Possibly change acl base */ - $this->set_acl_base(); - } - - function save($ignore_account= FALSE) - { - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $baseobject= $this->by_object['user']; - $baseobject->update_new_dn(); - if ($this->dn != 'new'){ - - $new_dn= $baseobject->new_dn; - - if (strtolower($this->dn) != strtolower($new_dn)){ - - /* Udpate acls */ - $baseobject->update_acls($this->dn,$new_dn); - $baseobject->move($this->dn, $new_dn); - $this->by_object['user']= $baseobject; - - /* Did we change ourselves? Update ui object. */ - change_ui_dn($this->dn, $new_dn); - } - } - - $this->dn= $baseobject->new_dn; - - return tabs::save(); - } - - - function set_template_mode() - { - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->is_template= TRUE; - } - } - - function saveCopyDialog() - { - tabs::saveCopyDialog(); - $baseobject= $this->by_object['user']; - $uid = $baseobject->uid; - foreach($this->by_object as $name => $obj){ - $this->by_object[$name]->uid = $uid; - } - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/users/template.tpl b/plugins/admin/users/template.tpl deleted file mode 100644 index 37237f9fc..000000000 --- a/plugins/admin/users/template.tpl +++ /dev/null @@ -1,60 +0,0 @@ -
- {t}Creating a new user using templates{/t} -
- -

- {t}Creating a new user can be assisted by using templates. Many database records will be filled automatically. Choose 'none' to skip the usage of templates.{/t} -

- -

 

- -
- - - - - - - - - - - - - - - {if $got_uid eq "true"} - - - - - {/if} -
- -
{t}Login{/t} - {if $edit_uid eq "false"} - - {else} - - {/if} -
- -
-

- -   - -

- - - - - diff --git a/plugins/generic/references/class_reference.inc b/plugins/generic/references/class_reference.inc deleted file mode 100644 index 472e42e11..000000000 --- a/plugins/generic/references/class_reference.inc +++ /dev/null @@ -1,181 +0,0 @@ -config= &$config; - $this->dn= $dn; - - /* Fill translation array */ - $this->obtypes= array( "gosaAccount" => array( "text" => _("Generic"), - "image" => "penguin.png"), - "posixAccount" => array( "text" =>_("UNIX"), - "image" => "select_user.png"), - "gosaMailAccount" => array("text" => _("Mail"), - "image" => "mailto.png"), - "sambaSamAccount" => array("text" => _("Samba"), - "image" => "select_winstation.png"), - "sambaAccount" => array( "text" => _("Samba"), - "image" => "select_winstation.png"), - "goFaxAccount" => array( "text" => _("FAX"), - "image" => "fax_small.png"), - "gosaProxyAccount" => array("text" => _("Proxy"), - "image" => "select_proxy.png"), - "PureFTPdUser" => array( "text" => _("FTP"), - "image" => "select_proxy.png"), - "posixGroup" => array( "text" => _("Group"), - "image" => "select_groups.png"), - "gosaDepartment" => array( "text" => _("Department"), - "image" => "select_department.png"), - "goFonHardware" => array( "text" => _("Phone"), - "image" => "select_phone.png"), - "gosaApplication" => array("text" => _("Application"), - "image" => "select_application.png"), - "goServer" => array( "text" => _("Server"), - "image" => "select_server.png"), - "gotoTerminal" => array( "text" => _("Thin Client"), - "image" => "select_terminal.png"), - "gotoWorkstation" => array("text" => _("Workstation"), - "image" => "select_workstation.png"), - "gosaGroupOfNames" => array("text" => _("Object group"), - "image" => "select_ogroup.png"), - "gotoPrinter" => array( "text" => _("Printer"), - "image" => "select_printer.png")); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Set government mode */ - $smarty= get_smarty(); - - if (isset($_GET['show'])){ - $dn= base64_decode($_GET['show']); - if (isset($this->fold["$dn"])){ - unset($this->fold["$dn"]); - } else { - $this->fold["$dn"]= "$dn"; - } - } - - /* Fill array */ - $this->reload(); - $smarty->assign("objectList", $this->objectlist); - - /* Show main page */ - return ($smarty->fetch (get_template_path('contents.tpl', TRUE, dirname(__FILE__)))); - } - - function reload() - { - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(|(member=".$this->dn.")(memberUid=".$this->uid."))",array("memberUid","member","cn","description","objectClass")); - - $cycle= array("F5F5F5", "ECECEC"); - $id= 0; - $this->objectlist= ""; - while ($attrs= $ldap->fetch()){ - - /* Add more information? */ - $addon= ""; - if (in_array($attrs['dn'], $this->fold)){ - $memberattr= ""; - if (isset($attrs['memberUid'])){ - unset($attrs['memberUid']['count']); - $memberattr= "memberUid"; - } - if (isset($attrs['member'])){ - unset($attrs['member']['count']); - $memberattr= "member"; - } - if ($memberattr == ""){ - continue; - } - foreach ($attrs[$memberattr] as $uid){ - $content= $this->getCacheObject($uid); - if ($content === NULL) { - continue; - } - $addon.= '   '.$content['name'].''.$content['description'].''.$content['type'].' '; - } - } - - /* Build final entry */ - if (isset($attrs['description'])){ - $description= $attrs['description'][0]; - } else { - $description= "-"; - } - $content= $this->createContentString($attrs['objectClass']); - if ($addon == ""){ - $img= "images/expand.png"; - } else { - $img= "images/sort_down.png"; - } - $this->objectlist.= ' '.$attrs['cn'][0].''.$description.''.$content.' '.$addon; - - $id++; - } - - } - - function getCacheObject($dn) - { - if (!isset($this->objectCache[$dn])){ - $ldap= $this->config->get_ldap_link(); - if (preg_match('/,/', $dn)){ - $ldap->cat($dn, array("cn", "objectClass", "description","ou")); - } else { - $ldap->search("(uid=$dn)", array("cn", "objectClass", "description","ou")); - } - if ($ldap->count()){ - $attrs= $ldap->fetch(); - - if(isset($attrs['ou']) && !isset($attrs['cn'])){ - $attrs['cn'] = $attrs['ou']; - } - - if (isset($attrs['description'])){ - $description= $attrs['description'][0]; - } else { - $description= "-"; - } - $this->objectCache[$dn]= array( 'name' => $attrs['cn'][0], - 'description' => "$description", - 'type' => $this->createContentString($attrs['objectClass'])); - } else { - return NULL; - } - } - return ($this->objectCache[$dn]); - } - - function createContentString($classes) - { - $result= ""; - if(!is_null($classes)) { - foreach ($classes as $class){ - if (isset($this->obtypes[$class])){ - $result.= "\"\" ".$this->obtypes[$class]['text']." "; - } - } - } - return (preg_replace('/ $/', '', $result)); - } - -} - -?> diff --git a/plugins/generic/references/contents.tpl b/plugins/generic/references/contents.tpl deleted file mode 100644 index e953da19f..000000000 --- a/plugins/generic/references/contents.tpl +++ /dev/null @@ -1,19 +0,0 @@ -{if $objectList ne ""} - - - - - - - - - - - - - {$objectList} - -
{t}Object name{/t}{t}Description{/t}{t}Contents{/t}
-{else} -{t}This object has no relationship to other objects.{/t} -{/if} diff --git a/plugins/generic/welcome/main.inc b/plugins/generic/welcome/main.inc deleted file mode 100644 index eb0c63cd9..000000000 --- a/plugins/generic/welcome/main.inc +++ /dev/null @@ -1,30 +0,0 @@ -assign("iconmenu", $plist->show_iconmenu()); - $smarty->assign("header", print_header(get_template_path('images/hdd_linux_unmount.png'), sprintf(_("Welcome %s!"), $ui->cn))); - $smarty->assign("year", date("Y")); - $smarty->assign("revision", get_gosa_version()); - $display= $smarty->fetch(get_template_path('welcome.tpl', TRUE)); -} - -?> diff --git a/plugins/generic/welcome/welcome.tpl b/plugins/generic/welcome/welcome.tpl deleted file mode 100644 index 35a27edf4..000000000 --- a/plugins/generic/welcome/welcome.tpl +++ /dev/null @@ -1,19 +0,0 @@ -{$header} - -

- {t}This is the GOsa main menu. You can select your tasks from the menu on the left, or by choosing one of the pictograms below. All changes apply directly to your companies LDAP server.{/t} -

- -

- {t}Use 'Sign out' on the upper left to close the connection and 'Main' to get back to the pictogram view.{/t} -

- -{$iconmenu} - -
- - - - - diff --git a/plugins/gofax/blocklists/class_blocklistGeneric.inc b/plugins/gofax/blocklists/class_blocklistGeneric.inc deleted file mode 100644 index 19284661d..000000000 --- a/plugins/gofax/blocklists/class_blocklistGeneric.inc +++ /dev/null @@ -1,371 +0,0 @@ -type = BLOCK_LIST_SEND; - - /* Load defined numbers */ - if($dn != "new"){ - - /* We will not be able to rename edited blocklists */ - $this->readonly = TRUE; - - /* Get blocklist type and defined numbers */ - if (in_array("goFaxSBlock",$this->attrs['objectClass'])){ - if(isset($this->attrs["goFaxSBlocklist"])){ - for ($i= 0; $i<$this->attrs["goFaxSBlocklist"]["count"]; $i++){ - $this->goFaxBlocklist[]= $this->attrs["goFaxSBlocklist"][$i]; - } - } - $this->type= BLOCK_LIST_SEND; - } elseif (in_array("goFaxRBlock",$this->attrs['objectClass'])){ - if(isset($this->attrs["goFaxRBlocklist"])){ - for ($i= 0; $i<$this->attrs["goFaxRBlocklist"]["count"]; $i++){ - $this->goFaxBlocklist[]= $this->attrs["goFaxRBlocklist"][$i]; - } - } - $this->type= BLOCK_LIST_RECEIVE; - } - } - - /* Set base */ - if ($this->dn == "new"){ - if(isset($_SESSION['CurrentMainBase'])){ - $this->base= $_SESSION['CurrentMainBase']; - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn); - } - } - - public function execute() - { - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","blocklist/".get_class($this),$this->dn); - } - - - /************** - * Base select dialog - **************/ - - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - - }else{ - return($this->dialog->execute()); - } - } - - - /*************** - Add numer to blocklist - ***************/ - - - /* Handle interactions: add */ - if (isset($_POST['add_number']) && $_POST['number'] != ""){ - if (is_phone_nr($_POST['number']) || preg_match ("/^[\/0-9 ()\^\.\$+*-]+$/",$_POST['number'])){ - $this->addNumber ($_POST['number']); - } else { - print_red (_("Please specify a valid phone number.")); - } - } - - - /*************** - Delete number from list - ***************/ - - /* Handle interactions: delete */ - if (isset($_POST['delete_number']) && isset($_POST['numbers']) && count($_POST['numbers']) > 0){ - $this->delNumber ($_POST['numbers']); - } - - - /*************** - Template output - ***************/ - - $smarty = get_smarty(); - foreach($this->attributes as $name){ - $smarty->assign($name,$this->$name); - } - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - $smarty->assign("goFaxBlocklist",$this->goFaxBlocklist); - $smarty->assign("cnACL",$this->getacl("cn",$this->readonly)); - $smarty->assign("typeACL",$this->getacl("type",$this->readonly)); - $smarty->assign("base",$this->base); - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("types", array(BLOCK_LIST_SEND => _("send"), BLOCK_LIST_RECEIVE => _("receive"))); - $smarty->assign("type", $this->type); - return($smarty->fetch(get_template_path('generic.tpl', TRUE))); - } - - - public function save_object() - { - if(isset($_POST['blocklist_posted'])){ - $tmp_cn = $this->cn; - plugin::save_object(); - $this->cn = $tmp_cn; - - /* Save base, since this is no LDAP attribute */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - $tmp = $this->attributes; - $tmp[] = "type"; - foreach($tmp as $attr){ - if(in_array($attr,array("cn","type")) && $this->readonly){ - continue; - }elseif(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){ - $this->$attr = $_POST[$attr]; - } - } - } - } - - - function remove_from_parent() - { - $ldap= $this->config->get_ldap_link(); - $ldap->rmDir($this->dn); - new log("remove","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of blocklist with dn '%s' failed."),$this->dn)); - $this->handle_post_events("remove"); - } - - - /* Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* check syntax: must cn */ - if ($this->cn == ""){ - $message[]= _("Required field 'Name' is not set."); - } else { - if (!is_uid($this->cn)){ - $message[]= _("Required field 'Name' contains invalid characters"); - } - if ($this->dn == 'new'){ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ("ou=gofax,ou=systems,".$this->config->current["BASE"]); - $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))(cn=".$this->cn."))", array("cn")); - if ($ldap->count() != 0){ - $message[]= _("Specified name is already used."); - } - } - } - return $message; - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Type selection */ - if ($this->type == BLOCK_LIST_SEND){ - $type= "goFaxSBlocklist"; - $this->attrs['objectClass']= "goFaxSBlock"; - } else { - $type= "goFaxRBlocklist"; - $this->attrs['objectClass']= "goFaxRBlock"; - } - - /* Add list */ - if (count($this->goFaxBlocklist)){ - $this->attrs[$type]= $this->goFaxBlocklist; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->base); - $ldap->cat($this->dn, array('dn')); - if ($ldap->count()){ - if (!isset($this->attrs[$type])){ - $this->attrs[$type]= array(); - } - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify($this->attrs); - new log("modify","faxblocklist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("modify"); - } else { - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - new log("create","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - $this->handle_post_events("add"); - } - show_ldap_error($ldap->get_error(), sprintf(_("Saving of blocklist with dn '%s' failed."),$this->dn)); - } - - - /* Add number */ - function addNumber($number) - { - if (!in_array($number, $this->goFaxBlocklist)){ - $this->goFaxBlocklist[]= $number; - sort($this->goFaxBlocklist); - } - } - - - /* Remove number from list */ - function delNumber($numbers) - { - $tmp= array(); - foreach ($this->goFaxBlocklist as $val){ - if (!in_array($val, $numbers)){ - $tmp[]= $val; - } - } - $this->goFaxBlocklist= $tmp; - } - - - function getCopyDialog() - { - $smarty = get_smarty(); - $smarty->assign("cn",$this->cn); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = get_post('cn'); - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* We will not be able to rename edited blocklists */ - $this->readonly = TRUE; - - /* Get blocklist type and defined numbers */ - if (in_array("goFaxSBlock",$source['objectClass'])){ - if(isset($source["goFaxSBlocklist"])){ - for ($i= 0; $i<$source["goFaxSBlocklist"]["count"]; $i++){ - $this->goFaxBlocklist[]= $source["goFaxSBlocklist"][$i]; - } - } - $this->type= BLOCK_LIST_SEND; - } elseif (in_array("goFaxRBlock",$source['objectClass'])){ - if(isset($source["goFaxRBlocklist"])){ - for ($i= 0; $i<$source["goFaxRBlocklist"]["count"]; $i++){ - $this->goFaxBlocklist[]= $source["goFaxRBlocklist"][$i]; - } - } - $this->type= BLOCK_LIST_RECEIVE; - } - - /* Set base */ - if ($this->dn == "new"){ - if(isset($_SESSION['CurrentMainBase'])){ - $this->base= $_SESSION['CurrentMainBase']; - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn); - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Fax"), - "plDescription" => _("Fax blocklists"), - "plSelfModify" => FALSE, - "plDepends" => array(), - - "plPriority" => 0, - "plSection" => array("administration" => _("FAX Blocklists")), - "plCategory" => array("gofaxlist" => array("description" => _("Fax blocklists"), - "objectClass" => array("goFaxRBlock","goFaxSBlock"))), - "plProvidedAcls" => array( - "cn" => _("Name"), - "description" => _("Description"), - "base" => _("Base"), - "goFaxBlocklist" => _("Blocklist"), - "type" => _("Blocklist type")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofax/blocklists/class_blocklistManagement.inc b/plugins/gofax/blocklists/class_blocklistManagement.inc deleted file mode 100644 index f9b19ea2a..000000000 --- a/plugins/gofax/blocklists/class_blocklistManagement.inc +++ /dev/null @@ -1,477 +0,0 @@ -ui = $ui; - $this->dn = ""; - $this->config = &$config; - $this->base = $_SESSION['CurrentMainBase']; - $this->DivListBlocklist = new divListBlocklist($this->config,$this); - - /* Initialize copy&paste queue */ - if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){ - $this->CopyPasteHandler= new CopyPasteHandler($this->config); - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - $_SESSION['LOCK_VARS_TO_USE'] = array("/^goFaxBlocklist_/","/^act$/","/^id$/","/^remove_multiple_blocklists/","/^item_selected/"); - - /*************** - Init vars - ***************/ - - /* Get global smarty instance */ - $smarty = get_smarty(); - $s_action = ""; // Contains the action to proceed - $s_entry = ""; // The value for s_action - $base_back = ""; // The Link for Backbutton - - - /*************** - Fetch posts - ***************/ - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/^goFaxBlocklist_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/^goFaxBlocklist_del_/i","",$key); - // Post for edit - }elseif(preg_match("/^goFaxBlocklist_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/^goFaxBlocklist_edit_/i","",$key); - // Post for new - }elseif(preg_match("/^goFaxBlocklist_new.*/",$key)){ - $s_action="new"; - }elseif(preg_match("/^remove_multiple_blocklists/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^copy/",$key)){ - $s_action = "copy"; - $s_entry= preg_replace("/^copy_/i", "", $key); - }elseif(preg_match("/^cut/",$key)){ - $s_action = "cut"; - $s_entry= preg_replace("/^cut_/i", "", $key); - } - - } - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; - } - - $s_entry = preg_replace("/_.$/","",$s_entry); - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "goFaxBlocklist_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - /*************** - Handle copy & paste - ***************/ - - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /*************** - Cancel some dialogs - ***************/ - - /* Cancel dialog */ - if (isset($_POST['edit_cancel']) || - isset($_POST['delete_blocklist_cancel']) || - isset($_POST['delete_lock'])){ - - del_lock ($this->dn); - $this->dialog = NULL; - unset($_SESSION['objectinfo']); - } - - - /*************** - Save blocklist - ***************/ - - /* What about finish? */ - if (isset($_POST['edit_finish']) || isset($_POST['edit_apply'])){ - - /* No errors, save object */ - $this->dialog->save_object(); - $message= $this->check(); - if (count ($message) == 0){ - - $this->dialog->save (); - - if (!isset($_POST['edit_apply'])){ - del_lock ($this->dn); - $this->dn= ""; - $this->dialog = NULL; - unset($_SESSION['objectinfo']); - } - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - - /*************** - Create a new blocklist (dialog) - ***************/ - - /* Create new blocklist? */ - if ($s_action=="new"){ - $this->dn= "new"; - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->set_acl_base($this->base); - } - - - /*************** - Edit blocklist - ***************/ - - if ($s_action=="edit" && !is_object($this->dialog)){ - - $this->dn=$this->blocklists[$s_entry]['dn']; - - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message($user, $this->dn)); - }else{ - add_lock ($this->dn, $this->ui->dn); - } - $_SESSION['objectinfo']= trim($this->dn); - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->set_acl_base($this->dn); - } - - - /*************** - Display dialog - ***************/ - - if(is_object($this->dialog) && ($this->dialog instanceof faxblocktabs)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - - $this->dns = array(); - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - foreach($ids as $id){ - $dn = $this->blocklists[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - $smarty->assign("info", sprintf(_("You're about to delete the following blocklists(s) %s"), @LDAP::fix($dns_names))); - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. */ - if (isset($_POST['delete_multiple_blocklist_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){ - $this->dn = $dn; - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->delete(); - $this->dialog = NULL; - } else { - print_red (sprintf(_("You are not allowed to delete the blocklist '%s'!"),$dn)); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - $this->reload(); - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_blocklist_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /*************** - Remove blocklist - ***************/ - - /* Delete blocklist requested */ - if ($s_action=="del"){ - $this->dn=$this->blocklists[$s_entry]['dn']; - - /* Check locking */ - if (($user= get_lock($this->dn)) != ""){ - $_SESSION['dn']= $this->dn; - return(gen_locked_message($user, $this->dn)); - } else { - - // Lock this dn for editing - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the blocklist '%s'."), $this->dn)); - $smarty->assign("multiple", false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /*************** - Remove blocklist confirmed - ***************/ - - /* Finally delete blocklist */ - if (isset($_POST['delete_blocklist_confirm'])){ - if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){ - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->delete(); - $this->dialog = NULL; - del_lock ($this->dn); - } else { - print_red (_("You have no permission to remove this blocklist.")); - } - } - - /*************** - Divlist dialog - ***************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListBlocklist->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Display dialog with system list */ - $this->DivListBlocklist->parent = $this; - $this->DivListBlocklist->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListBlocklist->SubSearch){ - $this->DivListBlocklist->AddDepartments($this->DivListBlocklist->selectedBase,3,1); - } - $this->reload(); - $this->DivListBlocklist->setEntries($this->blocklists); - return($this->DivListBlocklist->Draw()); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array("ou=gofax,ou=systems,". $this->DivListBlocklist->selectedBase)); - } - - - /* Reload the list of known blocklists */ - function reload() - { - /* Init some vars */ - $filter = $filter2 = ""; - $base = $this->DivListBlocklist->selectedBase; - $Regex = $this->DivListBlocklist->Regex; - $SubSearch = $this->DivListBlocklist->SubSearch; - $ShowSendBocklists = $this->DivListBlocklist->ShowSendBocklists; - $ShowReceiveBlocklists = $this->DivListBlocklist->ShowReceiveBlocklists; - $Flags = GL_SIZELIMIT; - $res = $res2 = array(); - - /* Append subsearch to Flags */ - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - }else{ - $base = "ou=gofax,ou=systems,".$base; - } - - /* Create filter */ - if ($ShowSendBocklists){ - $filter = "(&(objectClass=goFaxSBlock)(|(cn=".$Regex.")(goFaxSBlocklist=".$Regex.")))"; - $res= get_list($filter, "gofaxlist", $base,array("*"), $Flags); - } - if ($ShowReceiveBlocklists){ - $filter2= "(&(objectClass=goFaxRBlock)(|(cn=".$Regex.")(goFaxRBlocklist=".$Regex.")))"; - $res2= get_list($filter2, "gofaxlist", $base,array("*"), $Flags); - } - - $this->blocklists = array_merge($res,$res2); - - /* appen && sort */ - $tmp=array(); - foreach($this->blocklists as $tkey => $val ){ - - $acl = $this->ui ->get_permissions($base,"gofaxlist/blocklist"); - if(preg_match("/r/",$acl)){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - } - ksort($tmp); - $this->blocklists=array(); - foreach($tmp as $val){ - $this->blocklists[]=$val; - } - reset ($this->blocklists); - } - - - /* Save data to object */ - function save_object() - { - $this->DivListBlocklist->save_object(); - } - - - - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->blocklists[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->blocklists[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListBlocklist->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofax/blocklists/class_divListBlocklists.inc b/plugins/gofax/blocklists/class_divListBlocklists.inc deleted file mode 100755 index 8b8a505a6..000000000 --- a/plugins/gofax/blocklists/class_divListBlocklists.inc +++ /dev/null @@ -1,291 +0,0 @@ -parent = $parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of blocklists")); - $this->SetSummary(_("List of blocklists")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to create, delete and edit selected blocklists. Having a large size of lists, you might prefer the range selectors on top of the select box.")); - - $this->EnableAplhabet (true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 100; - if($this->parent->snapshotEnabled()){ - $action_col_size += 20; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Blocklist name")." / "._("Department"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" )); - - /* Add Checkboxes / SubSearch checkbox */ - $this->AddCheckBox("ShowSendBocklists" , _("Select to see send blocklists"), _("Show send blocklists"),true); - $this->AddCheckBox("ShowReceiveBlocklists" , _("Select to see receive blocklists"), _("Show receive blocklists"),true); - - $this->AddCheckBox(SEPERATOR); - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching list names"),"*" , true); - } - - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("gofaxlist"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get acls */ - $ui = get_userinfo(); - $acl = $ui->get_permissions($this->selectedBase,"gofaxlist/blocklist"); - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"gofaxlist"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* Append department selector */ - $listhead .= " "._("Base")." ". - "  "; - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acl)) { - $s.= "...|". - " "._("Blocklist")."|goFaxBlocklist_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - // User and Template Images - $blockimg = "User"; - $editlink = "%s"; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 100; - if($this->parent->snapshotEnabled()){ - $action_col_size += 20; - } - - /* Append to list */ - $ui = get_userinfo(); - foreach($list as $key => $val){ - - $acl = $ui->get_permissions($val['dn'],"gofaxlist/blocklist"); - if(!preg_match("/r/",$acl)){ - continue; - } - - /* Edit link ; requires read access */ - $action= ""; - - - /* Create snapshot ; requires write access && create access */ - if(preg_match("/w/",$acl) && preg_match("/c/",$acl)){ - $action.= $this->GetSnapShotActions($val['dn']); - } - - /* Add copy & cut icons */ - if(preg_match("/(c.*w|w.*c)/",$acl) && $this->parent->CopyPasteHandler){ - $action .= " "; - $action.= " "; - } - - - /* Delete entry ; requires remove access */ - if(preg_match("/d/",$acl)){ - $action.= ""; - } - - // Generate Array to Add - if(isset($val["description"][0])){ - $display= $val["cn"][0]." [".$val["description"][0]."]"; - }else{ - $display= $val["cn"][0]; - } - - /* Cutted objects should be displayed in light grey */ - if(isset($this->parent->CopyPasteHandler->queue) && is_array($this->parent->CopyPasteHandler->queue)){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); - $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement( array($field0,$field1,$field2,$field3)); - } - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_objs = count($list); - - $num_obj_str = _("Number of listed blocklists"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_obj_str." ".$num_objs."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofax/blocklists/generic.tpl b/plugins/gofax/blocklists/generic.tpl deleted file mode 100644 index df9f84a6b..000000000 --- a/plugins/gofax/blocklists/generic.tpl +++ /dev/null @@ -1,109 +0,0 @@ -

{t}Generic{/t}

- - - - - - - - - -
- - - - - - - - - -
{$must} - -{render acl=$cnACL} - -{/render} -
{$must} -{render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-
-   - - - - - - - - - - -
-{render acl=$typeACL} - -{/render} -
-{render acl=$descriptionACL} - -{/render} -
-
- -

 

- - - - - - - -
-

{t}Blocked numbers{/t}

-{render acl=$goFaxBlocklistACL} - -{/render} -
-{render acl=$goFaxBlocklistACL} -   -{/render} -{render acl=$goFaxBlocklistACL} -   -{/render} -{render acl=$goFaxBlocklistACL} - -{/render} -
-   - -

{t}Information{/t}

-

- {t}Numbers can also contain wild cards.{/t} -

-
- -

- - - -

- - - diff --git a/plugins/gofax/blocklists/main.inc b/plugins/gofax/blocklists/main.inc deleted file mode 100644 index 71c0b81a3..000000000 --- a/plugins/gofax/blocklists/main.inc +++ /dev/null @@ -1,34 +0,0 @@ -dn); - sess_del ('blocklist'); - } -} else { - /* Create blocklist object on demand */ - if (!isset($_SESSION['blocklist']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['blocklist']= new blocklist($config, $ui); - $_SESSION['blocklist']->set_acl_category("gofaxlist"); - } - $blocklist= $_SESSION['blocklist']; - $blocklist->save_object(); - $output= $blocklist->execute(); - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('blocklist'); - } - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management"), "\"\"align=\"middle\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/blocklists.png'), _("Blocklist management")); - } - $display.= $output; - - $_SESSION['blocklist']= $blocklist; -} -?> diff --git a/plugins/gofax/blocklists/paste_generic.tpl b/plugins/gofax/blocklists/paste_generic.tpl deleted file mode 100644 index ac4cef972..000000000 --- a/plugins/gofax/blocklists/paste_generic.tpl +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -
- -
diff --git a/plugins/gofax/blocklists/remove.tpl b/plugins/gofax/blocklists/remove.tpl deleted file mode 100644 index ebea1e3ca..000000000 --- a/plugins/gofax/blocklists/remove.tpl +++ /dev/null @@ -1,24 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

- diff --git a/plugins/gofax/blocklists/tabs_blocklist.inc b/plugins/gofax/blocklists/tabs_blocklist.inc deleted file mode 100644 index 9293903e1..000000000 --- a/plugins/gofax/blocklists/tabs_blocklist.inc +++ /dev/null @@ -1,38 +0,0 @@ -addSpecialTabs(); - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['blocklistGeneric']; - - /* Check for new 'dn', in order to propagate the 'dn' to all plugins */ - $new_dn= "cn=".$baseobject->cn.",ou=gofax,ou=systems,".$baseobject->base; - - /* Move group? */ - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->move($this->dn, $new_dn); - $this->by_object['blocklistGeneric']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - tabs::save(); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofax/faxaccount/class_gofaxAccount.inc b/plugins/gofax/faxaccount/class_gofaxAccount.inc deleted file mode 100644 index eca222857..000000000 --- a/plugins/gofax/faxaccount/class_gofaxAccount.inc +++ /dev/null @@ -1,857 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - - /* Department list shown in the divSelectList*/ - var $departments; - - /* Fax attributes */ - var $goFaxDeliveryMode= ""; - var $facsimileTelephoneNumber= ""; - var $goFaxIsEnabled= 1; - var $goFaxPrinter= ""; - var $goFaxDivertNumber= ""; - var $goFaxLanguage= ""; - var $goFaxFormat= ""; - var $goFaxRBlocklist = array(); - var $goFaxRBlockgroups= array(); - var $goFaxSBlocklist= array(); - var $goFaxSBlockgroups= array(); - var $mail= ""; - var $facsimileAlternateTelephoneNumber= array(); - var $fax_formats = array("pdf","ps","png","mtiff","tiff"); - - /* Internal variables */ - var $printerList= array(); - var $has_mailAccount= FALSE; - var $locals_dialog= FALSE; - var $in_blocklist_dialog= FALSE; - var $out_blocklist_dialog= FALSE; - var $current_blocklist= array(); - var $view_logged = FALSE; - - /* Copy & paste variables */ - var $CopyPasteVars=array("facsimileTelephoneNumber");//,"goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups"); - - /* attribute list for save action */ - var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","facsimileAlternateTelephoneNumber","goFaxRBlocklist","goFaxRBlockgroups","goFaxSBlocklist","goFaxSBlockgroups","goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail","facsimileTelephoneNumber"); - - var $uid =""; - - var $objectclasses= array("goFaxAccount"); - - function gofaxAccount (&$config, $dn= NULL) - { - /* General initialization */ - plugin::plugin ($config, $dn); - - /* Set uid, it is used in handle_post_events */ - if(isset($this->attrs['uid'])){ - $this->uid = $this->attrs['uid'][0]; - } - - /* Hickert : 11.11.05 - * Added to be able to handle department selection in divSelelect - */ - if(!isset($_SESSION["Fax_Filter"])){ - $_SESSION['Fax_Filter']['depselect'] = $this->config->current['BASE']; - } - - if ($dn != "new"){ - /* Get arrays */ - foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", - "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") 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]); - } - } - } - - /* Set up has_mailAccount */ - if (in_array("gosaMailAccount", $this->attrs['objectClass'])){ - $this->has_mailAccount= TRUE; - } - } - - /* Load printer list */ - if (isset($this->config->data['SERVERS']['CUPS'])){ - $this->printerList= get_printer_list ($this->config->data['SERVERS']['CUPS']); - asort ($this->printerList); - } - - /* Check if the currently selected printer is still available. - If not, append current printer to list of available. - It could be possible, that we are not allowed to view printers and so the list is empty ... */ - if(!empty($this->goFaxPrinter) && !isset($this->printerList[$this->goFaxPrinter])) { - $this->printerList[$this->goFaxPrinter] = "[".$this->goFaxPrinter."]"; - } - - /* Get global filter config */ - if (!is_global("faxfilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $faxfilter= array( "depselect" => $base, - "fuser" => "*", - "regex" => ""); - register_global("faxfilter", $faxfilter); - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Hickert : 11.11.05 - * Added to be able to handle department selection in divSelelect - */ - if((isset($_GET['act']))&&($_GET['act']=="dep_open")){ - - if(strlen(base64_decode($_GET['dep_id']))>= strlen($this->config->current['BASE'])){ - $_SESSION['Fax_Filter']['depselect']= base64_decode($_GET['dep_id']); - }else{ - $_SESSION['Fax_Filter']['depselect']= $this->config->current['BASE']; - } - } - - /* Edit mode specifies if we are editing from my accout */ - $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit'])); - - /* Load smarty stuff */ - $smarty= get_smarty(); - - /* Check if mail account is active. We'll display an additional - mail address field if this is not the case. Some people may - want goFax, but have a mailserver which is not managed with - GOsa */ - if (!@isset($this->parent->by_object['mailAccount'])) { - $smarty->assign("has_mailaccount", $this->has_mailAccount?"true":"false"); - } elseif ( !$this->parent->by_object['mailAccount']->is_account){ - $smarty->assign("has_mailaccount", "false"); - $this->has_mailAccount= false; - } else { - $smarty->assign("has_mailaccount", "true"); - } - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This account has no fax extensions.").""; - $display.= back_to_main(); - return ($display); - } - - /* Show tab dialog headers */ - $display= ""; - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove fax account"), - _("This account has fax features enabled. You can disable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Create fax account"), - _("This account has fax features disabled. You can enable them by clicking below.")); - return ($display); - } - } - - /* Trigger Add local fax alternatives dialog */ - if (isset($_POST['add_local_alternate'])){ - if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ - $this->locals_dialog= TRUE; - $this->dialog= TRUE; - } - } - - /* Add alternatives from dialog */ - if (isset($_POST['add_locals_finish']) && isset($_POST['local_list'])){ - if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ - foreach ($_POST['local_list'] as $val){ - $this->addAlternate($val); - $this->is_modified= TRUE; - } - } - } - - /* Add alternatives */ - if (isset($_POST['add_alternate']) && !empty($_POST['forward_address']) && is_phone_nr($_POST['forward_address'])){ - if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ - $this->addAlternate($_POST['forward_address']); - } - } - - /* Delete alternate fax number */ - if (isset($_POST['delete_alternate']) && isset($_POST['alternate_list']) && count($_POST['alternate_list'])){ - if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){ - $this->delAlternate ($_POST['alternate_list']); - } - } - - - /* Edit incoming blocklists */ - if (isset($_POST['edit_incoming'])){ - if($this->acl_is_writeable("goFaxRBlocklist",$edit_mode)) { - $this->current_blocklist= array_merge($this->goFaxRBlocklist,$this->goFaxRBlockgroups); - sort($this->current_blocklist); - reset($this->current_blocklist); - - $this->in_blocklist_dialog= TRUE; - $this->dialog= TRUE; - } - } - - /* Edit outgoing blocklists */ - if (isset($_POST['edit_outgoing'])){ - $this->current_blocklist= array_merge($this->goFaxSBlocklist,$this->goFaxSBlockgroups); - sort($this->current_blocklist); - reset($this->current_blocklist); - - $this->out_blocklist_dialog= TRUE; - $this->dialog= TRUE; - } - - /* Add number to blocklist (dialog) */ - if (isset($_POST['add_blocklist_number']) && $_POST['block_number'] != ""){ - if (!is_phone_nr($_POST['block_number'])){ - print_red (_("You're trying to add an invalid phone number.")); - } else { - array_push($this->current_blocklist, $_POST['block_number']); - $this->current_blocklist= array_unique($this->current_blocklist); - sort($this->current_blocklist); - reset($this->current_blocklist); - } - } - - /* Hickert : 11.11.05 - * Add selection from divSelelect to our Blocklist - */ - /* Add list to blocklist */ - if (isset($_POST['add_blocklist'])){ - foreach($_POST as $name => $value){ - if(preg_match("/ADDLIST_/i",$name)){ - $this->current_blocklist= array_merge($this->current_blocklist, array(base64_decode($value))); - - } - } - $this->current_blocklist= array_unique($this->current_blocklist); - sort($this->current_blocklist); - reset($this->current_blocklist); - } - - /* Add list to blocklist */ - if (isset($_GET['add'])){ - if(!is_array($this->current_blocklist)) $this->current_blocklist=array(); - $this->current_blocklist= array_merge($this->current_blocklist, array( base64_decode($_GET['add']))); - $this->current_blocklist= array_unique($this->current_blocklist); - sort($this->current_blocklist); - reset($this->current_blocklist); - } - - /* Delete from blocklist */ - if (isset($_POST['delete_blocklist_number']) && isset($_POST['block_list'])){ - $tmp= array(); - foreach($this->current_blocklist as $val){ - if (!in_array($val, $_POST['block_list'])){ - $tmp[]= $val; - } - } - $this->current_blocklist= $tmp; - } - - - /* Blocklist edit finished */ - if (isset($_POST['edit_blocklists_finish'])){ - - /* Incoming or outgoing? */ - if ($this->in_blocklist_dialog){ - $this->goFaxRBlocklist = array(); - $this->goFaxRBlockgroups = array(); - - foreach ($this->current_blocklist as $val){ - if (is_phone_nr($val)){ - $this->goFaxRBlocklist[]=$val; - } else { - $this->goFaxRBlockgroups[]= $val; - } - } - } else { - $this->goFaxSBlocklist = array(); - $this->goFaxSBlockgroups = array(); - - /* Transfer values to ourself */ - foreach ($this->current_blocklist as $val){ - if (is_phone_nr($val)){ - $this->goFaxSBlocklist[]=$val; - } else { - $this->goFaxSBlockgroups[]= $val; - } - } - } - $this->is_modified= TRUE; - } - - - /* Set departments */ - if ($this->locals_dialog || $this->in_blocklist_dialog || $this->out_blocklist_dialog){ - - $list= array (); - $ldap= $this->config->get_ldap_link(); - if (isset ($_POST['department'])){ - $ldap->cd ($_POST['department']); - } else { - $ldap->cd ($this->config->current['BASE']); - } - } - - /* Cancel dialogs */ - if (isset($_POST['add_locals_cancel']) || isset($_POST['edit_blocklists_finish']) || - isset($_POST['edit_blocklists_cancel']) || isset($_POST['add_locals_finish'])){ - - $this->locals_dialog= FALSE; - $this->in_blocklist_dialog= FALSE; - $this->out_blocklist_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Manage locals dialog */ - if ($this->locals_dialog){ - - /* Save data */ - $faxfilter= get_global("faxfilter"); - foreach( array("depselect", "fuser", "regex") as $type){ - if (isset($_POST[$type])){ - $faxfilter[$type]= $_POST[$type]; - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $faxfilter['fuser']= $s; - } - - if ($faxfilter['regex'] != '*' && $faxfilter['regex'] != ""){ - $regex= $faxfilter['regex']; - $filter= "(facimileTelephoneNumber=$regex)"; - } else { - $filter= ""; - } - if ($faxfilter['fuser'] != ""){ - $user= $faxfilter['fuser']; - $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))"; - } - - $base= $faxfilter['depselect']; - $res= get_list("(&(objectClass=goFaxAccount)$filter)", "gofax", $base, - array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH); - - foreach ($res as $attrs){ - $list[$attrs['facsimileTelephoneNumber'][0]]= - $attrs['sn'][0].", ". - $attrs['givenName'][0]." [". - $attrs['facsimileTelephoneNumber'][0]."]"; - } - - /* Show dialog */ - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("usearch_image", get_template_path('images/search_user.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("departments", $this->config->idepartments); - $smarty->assign("list", $list); - if (isset($_POST['depselect'])){ - $smarty->assign("depselect", $_POST['depselect']); - } - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("hint", print_sizelimit_warning()); - foreach( array("depselect", "fuser", "regex") as $type){ - $smarty->assign("$type", $faxfilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - - $display.= $smarty->fetch (get_template_path('locals.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - - /* Manage incoming blocklists */ - if ($this->in_blocklist_dialog){ - - /* This handles the divSelectBox */ - - /* The base specifies the current position in the ldap tree - * The current base was specified by $_GET['dep_id'] before. Or contains the default value. - */ - $base = $_SESSION['Fax_Filter']['depselect']; - $ldap->cd($base); - - /* Ge all Blocklists */ - $ldap->search ("(objectClass=goFaxRBlock)",array("cn","description")); - while ($attrs= $ldap->fetch()){ - - /* Generate list depending on description */ - if(isset($attrs['description'][0])){ - $list[$attrs['cn'][0]]= - $attrs['description'][0]. - " [".$attrs['cn'][0]."]"; - }else{ - $list[$attrs['cn'][0]]= $attrs['cn'][0]; - } - } - - /* Create our divselect box */ - $divSel = new divSelectBox("divSelectPredefined"); - $divSel->setHeight(296); - - /* NEW LIST MANAGMENT - * We also need to search for the departments - * So we are able to navigate like in konquerer - */ - $this->departments= array(); - - /* Get all departments within the current department */ - $base = $_SESSION['Fax_Filter']['depselect']; - $ldap->ls("(objectClass=gosaDepartment)",$base); - - /* Base back is used to go one department up in our ldap tree */ - $base_back = preg_replace("/^[^,]+,/","",$base); - - /* Only show base_back if it is needed */ - if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){ - $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; - } - - /* Fetch all returned departments an add them to our divlist */ - while($value = $ldap->fetch()){ - if($value["description"][0]!=".."){ - $this->departments[$value['dn']]=@LDAP::fix(convert_department_dn($value['dn'])." - [".$value["description"][0]."]"); - }else{ - $this->departments[$value['dn']]=$value["description"][0]; - } - } - /* END NEW LIST MANAGMENT - */ - - // This links specifies the department open link - $linkopen = "%s"; - - /* Insert departments in divsel */ - foreach($this->departments as $key=> $val){ - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); - $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'"); - $divSel->AddEntry(array($field1,$field2)); - } - - /* Append predefined Blocklists */ - foreach($list as $entry => $value){ - $divSel->AddEntry(array( - array("string"=>""), - array("string"=>$value,"attach"=>"style='border:0px;'") - )); - } - - /* Show dialog */ - $smarty->assign("cblocklist", $this->current_blocklist); - $smarty->assign("departments", $this->config->idepartments); - $smarty->assign("divSelectPredefined", $divSel->DrawList()); - $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /* Manage outgoing blocklists */ - - if ($this->out_blocklist_dialog){ - - /* This handles the divSelectBox */ - - /* The base specifies the current position in the ldap tree - * The current base was specified by $_GET['dep_id'] before. Or contains the default value. - */ - $base = $_SESSION['Fax_Filter']['depselect']; - $ldap->cd($base); - - /* Ge all Blocklists */ - $ldap->search ("(objectClass=goFaxSBlock)",array("cn","description")); - while ($attrs= $ldap->fetch()){ - if(isset($attrs['description'][0])){ - $list[$attrs['cn'][0]]= - $attrs['description'][0]. - " [".$attrs['cn'][0]."]"; - }else{ - $list[$attrs['cn'][0]]= $attrs['cn'][0]; - } - } - - /*Create DivSel*/ - $divSel = new divSelectBox("divSelectPredefined"); - $divSel->setHeight(296); - - /* NEW LIST MANAGMENT - * We also need to search for the departments - * So we are able to navigate like in konquerer - */ - $this->departments= array(); - $ldap->ls("(objectClass=gosaDepartment)",$base); - - /* Generate Back url, and append if it is needed */ - $base_back = preg_replace("/^[^,]+,/","",$base); - if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($base!=$this->config->current['BASE'])){ - $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; - } - - /* Get all departments */ - while($value = $ldap->fetch()){ - if(isset($value["description"][0])){ - $this->departments[$value['dn']]=@LDAP::fix(convert_department_dn($value['dn'])." - [".$value["description"][0]."]"); - }else{ - $this->departments[$value['dn']]=$value["description"][0]; - } - } - /* END NEW LIST MANAGMENT - */ - - // Defining Links - $linkopen = "%s"; - - /* Insert departments in divlist*/ - foreach($this->departments as $key=> $val){ - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } - - $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); - $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" style='border:none'"); - $divSel->AddEntry(array($field1,$field2)); - } - - /* Append Blocklits */ - foreach($list as $entry => $value){ - $divSel->AddEntry(array( - array("string"=>""), - array("string"=>$value,"attach"=>"style='border:0px;'") - )); - } - - /* Show dialog */ - $smarty->assign("cblocklist", $this->current_blocklist); - $smarty->assign("departments", $this->config->idepartments); - $smarty->assign("divSelectPredefined", $divSel->DrawList()); - $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - - /* Show main page */ - $smarty->assign("languages", get_languages(TRUE)); - - $smarty->assign("formats", $this->fax_formats); - $smarty->assign("printers", $this->printerList); - - /* Load attributes */ - foreach(array("goFaxIsEnabled", "goFaxDeliveryMode", "facsimileTelephoneNumber", - "goFaxPrinter", "goFaxLanguage", "goFaxFormat", - "facsimileAlternateTelephoneNumber", "mail") as $val){ - - $smarty->assign("$val", $this->$val); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $acl => $desc){ - $smarty->assign($acl."ACL",$this->getacl($acl,$edit_mode)); - } - - /* Load checkboxes */ - if ($this->goFaxIsEnabled == "1"){ - $smarty->assign("goFaxIsEnabled", ""); - } else { - $smarty->assign("goFaxIsEnabled", "checked"); - } - /* goFaxAccount has "mail" as must! Block if no mailaddress is specified... */ - if ($this->goFaxDeliveryMode & 32) { - $smarty->assign("faxtomail", "checked"); - } else { - $smarty->assign("faxtomail", ""); - } - if ($this->goFaxDeliveryMode & 64) { - $smarty->assign("faxtoprinter", "checked"); - } else { - $smarty->assign("faxtoprinter", ""); - } - - - $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - plugin::remove_from_parent(); - - /* Adapt mail settings if needed */ - if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){ - unset($this->attrs['mail']); - } - - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/fax account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove',array("uid"=> $this->uid)); - } - - - /* Check formular input */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* must: facsimileTelephoneNumber */ - if ($this->facsimileTelephoneNumber == ""){ - $message[]= _("The required field 'Fax' is not set."); - } - - if (!is_phone_nr($this->facsimileTelephoneNumber)){ - $message[]= _("Please enter a valid telephone number in the 'Fax' field."); - } - - /* IF mail is specified (which is only the case if there's no mail account - present), check if it's valid.. */ - if (@isset($this->parent->by_object['mailAccount']) && - $this->goFaxDeliveryMode & 32){ - if ($this->mail == ""){ - $message[]= _("Mail delivery is checked, but no address has been specified."); - } elseif (!is_email($this->mail)){ - $message[]= _("The mail address you've entered is invalid."); - } - } - - // IE Fix, IE lets you choose disabled option, stupid browser ... - if((empty($this->goFaxPrinter))&&($this->goFaxDeliveryMode & 64)){ - $message[]= _("Deliver fax to printer, is only possible if valid printer is given. Please correct your choice."); - } - - return ($message); - } - - /* Save data to object */ - function save_object() - { - $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit'])); - if (isset($_POST['faxTab'])){ - plugin::save_object(); - - - $tmp = 0+$this->goFaxDeliveryMode; - - if($this->acl_is_writeable("faxtomail",$edit_mode)){ - if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){ - $tmp |= 32; - }elseif($tmp & 32){ - $tmp &= (!32); - } - } - if($this->acl_is_writeable("faxtoprinter",$edit_mode)){ - if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){ - $tmp |= 64; - }elseif($tmp & 64){ - $tmp &= !64; - } - } - $this->goFaxDeliveryMode = $tmp; - - if($this->acl_is_writeable("goFaxIsEnabled",$edit_mode)){ - if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){ - $this->goFaxIsEnabled= "0"; - } else { - $this->goFaxIsEnabled= "1"; - } - } - - - if (isset($_POST['mail']) && $this->acl_is_writeable("faxtomail",$edit_mode)){ - $this->mail= $_POST['mail']; - } - - /* Check if mail account is active and correct the internal - reference to represent the current status. */ - if(isset($this->parent)){ - if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){ - $this->has_mailAccount= TRUE; - } - } - } - - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Save arrays */ - foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", - "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ - - $this->attrs[$val]= $this->$val; - } - - if(!$this->attrs['goFaxDeliveryMode']){ - $this->attrs['goFaxDeliveryMode'] = 0; - } - - /* Do not save mail address ... it was possibly changed by mail plugin */ - /* Adapt mail settings if needed */ - if ((isset($this->parent->by_object['mailAccount']->is_account)) && ($this->parent->by_object['mailAccount']->is_account)){ - unset($this->attrs['mail']); - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/fax account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - if ($this->initially_was_account == $this->is_account){ - if ($this->is_modified){ - $this->handle_post_events("mofidy",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - - } - - - /* Adapt from template, using 'dn' */ - function adapt_from_template($dn) - { - plugin::adapt_from_template($dn); - - foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", - "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){ - - if (isset($this->attrs[$val])){ - $this->$val= $this->attrs[$val]; - } - } - } - - - - /* Add alternate fax recipient */ - function addAlternate($number) - { - $this->facsimileAlternateTelephoneNumber[]= "$number"; - $this->facsimileAlternateTelephoneNumber= - array_unique ($this->facsimileAlternateTelephoneNumber); - - sort ($this->facsimileAlternateTelephoneNumber); - reset ($this->facsimileAlternateTelephoneNumber); - } - - function delAlternate($numbers) - { - $this->facsimileAlternateTelephoneNumber= array_remove_entries ($numbers, - $this->facsimileAlternateTelephoneNumber); - } - - function getCopyDialog() - { - $str = ""; - $smarty = get_smarty(); - $smarty->assign("facsimileTelephoneNumber", $this->facsimileTelephoneNumber); - $str['string'] = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - $str['status'] =""; - return($str); - } - - function SaveCopyDialog() - { - if(isset($_POST['facsimileTelephoneNumber'])){ - $this->facsimileTelephoneNumber = $_POST['facsimileTelephoneNumber']; - } - } - - - /* Return plugin informations for acl handling - #FIXME some attributes are still missing in this plugin acls */ - static function plInfo() - { - return (array( - "plShortName" => _("Fax"), - "plDescription" => _("Fax account settings"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 6, - "plSection" => "personal", - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "goFaxIsEnabled" => _("Enable/Disable fax"), - "goFaxRBlocklist" => _("Receive blocklist"), - "goFaxSBlocklist" => _("Send blocklist"), - "facsimileTelephoneNumber" => _("Fax number"), // goFaxDeliveryMode - "facsimileAlternateTelephoneNumber" => _("Alternate fax number"), // goFaxDeliveryMode - "faxtomail" => _("Deliver fax as mail"), - "faxtoprinter" => _("Deliver fax to printer"), - "goFaxFormat" => _("Delivery format"), - "goFaxLanguage" => _("Language")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofax/faxaccount/generic.tpl b/plugins/gofax/faxaccount/generic.tpl deleted file mode 100644 index cb56a6c11..000000000 --- a/plugins/gofax/faxaccount/generic.tpl +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - - - - - - -
{$must} - -{render acl=$facsimileTelephoneNumberACL} - -{/render} - -
- -{render acl=$goFaxLanguageACL} - -{/render} - -
- -{render acl=$goFaxFormatACL} - -{/render} -
- -
-   - -

 {t}Delivery methods{/t}

- -{render acl=$goFaxIsEnabledACL} - -{/render} - {t}Temporary disable fax usage{/t}
- - {if $has_mailaccount eq "false"} -{render acl=$faxtomailACL} - -{/render} -   -{render acl=$faxtomailACL} - -{/render} - {else} -{render acl=$faxtomailACL} - -{/render} - {t}Deliver fax as mail{/t} - {/if} -
- -{render acl=$faxtoprinterACL} - -{/render} - {t}Deliver fax to printer{/t}  -{render acl=$faxtoprinterACL} - -{/render} -
- -

 

- - - - - - -
-

 {t}Alternate fax numbers{/t}

-{render acl=$facsimileAlternateTelephoneNumberACL} - -{/render} -
-{render acl=$facsimileAlternateTelephoneNumberACL} - -{/render} -{render acl=$facsimileAlternateTelephoneNumberACL} -   -{/render} -{render acl=$facsimileAlternateTelephoneNumberACL} -   -{/render} -{render acl=$facsimileAlternateTelephoneNumberACL} - -{/render} -
-

 {t}Blocklists{/t}

- - - - - - - - - -
{t}Blocklists for incoming fax{/t} -{render acl=$goFaxRBlocklistACL} - -{/render} -
{t}Blocklists for outgoing fax{/t} -{render acl=$goFaxSBlocklistACL} - -{/render} -
-
- - - - - diff --git a/plugins/gofax/faxaccount/lists.tpl b/plugins/gofax/faxaccount/lists.tpl deleted file mode 100644 index 5817e6c7d..000000000 --- a/plugins/gofax/faxaccount/lists.tpl +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - -
- {t}Blocked numbers/lists{/t} -
- -
- -   - -
- {t}List of predefined blocklists{/t}
- - - - -
- {$divSelectPredefined} -
-
-
- -

- -   - -

- diff --git a/plugins/gofax/faxaccount/locals.tpl b/plugins/gofax/faxaccount/locals.tpl deleted file mode 100644 index ebf9a894f..000000000 --- a/plugins/gofax/faxaccount/locals.tpl +++ /dev/null @@ -1,64 +0,0 @@ - - - - - -
-
-

- {t}Select numbers to add{/t} {$hint}
-

-
-
-

- -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - -
-   - -
- - - - - -
- - -
- - - - - -
- - -
- {$apply} -
-
- -

- -   - -

- diff --git a/plugins/gofax/faxaccount/main.inc b/plugins/gofax/faxaccount/main.inc deleted file mode 100644 index d2786d889..000000000 --- a/plugins/gofax/faxaccount/main.inc +++ /dev/null @@ -1,112 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('gofaxAccount'); - } - - /* Create gofaxAccount object on demand */ - if (!isset($_SESSION['gofaxAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['gofaxAccount']= new gofaxAccount ($config, $ui->dn); - $_SESSION['gofaxAccount']->set_acl_base($ui->dn); - $_SESSION['gofaxAccount']->set_acl_category("users"); - - } - $gofaxAccount= $_SESSION['gofaxAccount']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $gofaxAccount->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $gofaxAccount->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $gofaxAccount->save (); - del_lock ($ui->dn); - sess_del ('edit'); - - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display.= $lock_msg; - }else{ - $display.= $gofaxAccount->execute (); - } - - $info= ""; - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['gofaxAccount']= $gofaxAccount; - } - - /* Show page footer depending on the mode */ - if (!$gofaxAccount->locals_dialog && - !$gofaxAccount->out_blocklist_dialog && - !$gofaxAccount->in_blocklist_dialog && - $gofaxAccount->is_account && - empty($lock_msg)){ - - $display.= "

\n"; - - /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " \n"; - $display.= "\n"; - $info= " ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/gofaxAccount"))){ - $info.= "\"\""._("Click the 'Edit' button below to change informations in this dialog"); - $display.= ""; - } - $display.= "\n"; - } - $display.= "

"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/fax.png'), _("FAX settings"), $info).$display; - -} -?> diff --git a/plugins/gofax/faxaccount/paste_generic.tpl b/plugins/gofax/faxaccount/paste_generic.tpl deleted file mode 100644 index 6efca1d5b..000000000 --- a/plugins/gofax/faxaccount/paste_generic.tpl +++ /dev/null @@ -1,31 +0,0 @@ - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {$must} - - -
- {t}Alternate fax numbers will not be copied{/t} -
-
- - diff --git a/plugins/gofax/faxreports/class_faxreport.inc b/plugins/gofax/faxreports/class_faxreport.inc deleted file mode 100644 index 41e0fc471..000000000 --- a/plugins/gofax/faxreports/class_faxreport.inc +++ /dev/null @@ -1,507 +0,0 @@ -config = $config; - $this->ui = &$ui; - $this->search_base = get_base_from_people($ui->dn); - $this->year = date("Y"); - $this->month = date("m"); - - /* Get global filter config and set class vars , - or create a filter */ - if (!is_global("faxreportfilter")){ - $faxreportfilter = array(); - foreach($this->attributes_SO as $name){ - $faxreportfilter[$name] = $this->$name; - } - register_global("faxreportfilter",$faxreportfilter); - }else{ - $faxreportfilter = get_global("faxreportfilter"); - foreach($this->attributes_SO as $name){ - $this->$name = $faxreportfilter[$name]; - } - } - } - - - /* Create Filter & Search & Display results */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /************ - Variable initialisation - ************/ - - /* Create months */ - $months= array(); - for($i = 1 ; $i <= 12 ; $i ++ ){ - $months[$i] = _(date("F",gmmktime(0,0,0,$i,1))); - } - - /* Create years */ - $current= date("Y"); - $years= array(); - for ($y= $current - 5; $y<=$current; $y++){ - $years[]= $y; - } - - - /************ - Set smarty defaults - ************/ - - $smarty= get_smarty(); - $smarty->assign("launchimage" , get_template_path('images/launch.png')); - $smarty->assign("search_image" , get_template_path('images/search.png')); - $smarty->assign("search_for" , $this->search_for); - $smarty->assign("bases" , $this->config->idepartments); - $smarty->assign("base_select" , $this->search_base); - $smarty->assign("months" , $months); - $smarty->assign("month_select" , $this->month); - $smarty->assign("years" , $years); - $smarty->assign("year_select" , $this->year); - $smarty->assign("search_result" , ""); - - - /************ - Check database accessibility - ************/ - - /* Some checks */ - if(!isset($this->config->data['SERVERS']['FAX'])){ - print_red(_("No fax extension defined in your server configuration, no reports can be shown!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - }elseif(!is_callable("mysql_connect")){ - print_red(_("There is no mysql extension available, please check your php setup.")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - }else{ - /* Connecting, selecting database */ - $cfg = $this->config->data['SERVERS']['FAX']; - $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); - if ($link === FALSE){ - print_red(_("Can't connect to fax database, no reports can be shown!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - if (! @mysql_select_db("gofax")){ - print_red(_("Can't select fax database for report generation!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - if (! mysql_query("SELECT * FROM faxlog;")){ - print_red(_("Can't query fax table 'faxlog' for report generation!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - } - - - /************ - Perform a deatil view - ************/ - - /* Do detail view? */ - if (isset($_GET['detail'])){ - - /* Create query */ - $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,sender_msn,receiver_id,". - "receiver_msn,pages,status_message,transfer_time FROM faxlog WHERE id=".$_GET['detail'].";"; - - /* Connecting, selecting database */ - $cfg= $this->config->data['SERVERS']['FAX']; - - /* Check if everything went ok*/ - $result = @mysql_query($query); - if ($result === false){ - print_red(_("Query for fax database failed!")); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query failed"); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - $line = mysql_fetch_array($result, MYSQL_ASSOC); - mysql_close($link); - - if (!preg_match ("/'".$line["uid"]."'/", $this->userfilter)){ - print_red (_("You have no permission to retrieve informations about this fax id!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - /* Check acls */ - $fax_uids = array_flip($this->fax_users); - $uid = $line['uid']; - $dn = $fax_uids[$uid]; - $acls = $this->ui->get_permissions($dn,"faxreport/faxreport"); - if(!preg_match("/r/",$acls)){ - print_red (_("You have no permission to retrieve informations about this fax id!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - $parts= array( "id", "uid", "queuing_time", "status", "sender_id", "sender_msn", - "receiver_id", "receiver_msn", "pages", "status_message", "transfer_time" ); - - foreach ($parts as $vname) { - - $final="fax_$vname"; - if($vname != "uid"){ - $v_acl = $this->ui->get_permissions($dn,"faxreport/faxreport",preg_replace("/_/","",$vname)); - }else{ - $v_acl = "r"; - } - - if ($line[$vname] != "" && preg_match("/r/",$v_acl)){ - $smarty->assign("$final", $line[$vname]); - } else { - $smarty->assign("$final", "-"); - } - } - $queuing_time= $line['queuing_time']; - - /* The user is allowed to download all fax images from those users - that are listed in $_SESSION['fuserfilter'] - Don't forget to check getfax.php if you change somthing here */ - $_SESSION['fuserfilter']= $this->userfilter; - $smarty->assign("plug", "?plug=".validate($_GET['plug'])); - $smarty->assign("detail", validate($_GET['detail'])); - - $format= _("Y-M-D"); - $date= preg_replace("/Y/", substr($queuing_time,0,4), $format); - $date= preg_replace("/M/", substr($queuing_time,4,2), $date); - $date= preg_replace("/D/", substr($queuing_time,6,2), $date); - $smarty->assign("date", $date); - $smarty->assign("time", substr($queuing_time,8,2).":". - substr($queuing_time,10,2).":". - substr($queuing_time,12,2)); - return($smarty->fetch(get_template_path('detail.tpl', TRUE))); - } - - - /************ - Search for uids matching the filter - ************/ - - /* Search button has been pressed */ - if ($this->search_for != ""){ - - if (is_integer (strpos($this->search_for, "*"))){ - $s= $this->search_for; - } else { - $s= "*".$this->search_for."*"; - } - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->search_base); - - /* Perform ldap search for potential users */ - $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))". - "(objectClass=goFaxAccount)". - "(|(uid=$s)(l=$s)(homePhone=$s)". - "(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)". - "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)". - "(title=$s)))"; - - $res = get_list($filter, "users", $this->search_base, array("uid"), GL_SUBSEARCH ); - - /* Check if we are allowed to collect fax data */ - $fax_users= array(); - foreach($res as $attrs){ - $acl = $this->ui->get_permissions($attrs['dn'],"users/user","uid"); - if(preg_match("/r/",$acl)){ - $fax_users[ $attrs['dn']]= $attrs["uid"][0]; - } - } - - $this->fax_users = $fax_users; - - /* Prepare SQL query */ - $this->userfilter= ""; - foreach ($fax_users as $user){ - $this->userfilter.= "uid = '$user' OR "; - } - $this->userfilter= preg_replace("/OR $/", "", $this->userfilter); - } - - /************ - Create filter - ************/ - - /* Perform SQL query */ - if ($this->userfilter){ - if ($this->sort_direction == "down"){ - $desc= "DESC"; - } else { - $desc= ""; - } - $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year)); - $end= date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year)); - $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,receiver_id,pages FROM faxlog ". - "WHERE ( ".$this->userfilter." ) AND queuing_time <= $end AND ". - "queuing_time >= $start ORDER BY ".$this->fields[$this->sort]." $desc;"; - - if(!is_callable("mysql_connect")){ - print_red("There is no mysql extension configured in your php setup."); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - - /************ - Create results - ************/ - - /* Connecting, selecting database */ - $cfg= $this->config->data['SERVERS']['FAX']; - $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); - - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - $result = @mysql_query($query); - if ($result === false){ - print_red(_("Query for fax database failed!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - $this->report_list= array(); - $user_ids = array_flip($fax_users); - while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { - - /* Check permissions for each field */ - $dn = $user_ids[$line['uid']]; - - /* Hide restricted attributes */ - foreach(array("pages","receiverid","senderid","status","queuingtime","detailedView") as $attr){ - $var = $attr."ACL"; - $$var = $this->ui->get_permissions($dn,"faxreport/faxreport",$attr); - } - - /* Restricted attributes will not be displayed, this will be displayed instead */ - $no_acl = ""._("Insufficient permissions").""; - - /* Create date */ - if((!empty($line["queuing_time"])) && preg_match("/r/",$queuingtimeACL)){ - $hour= substr($line["queuing_time"], 8, 2); - $minute=substr($line["queuing_time"], 10, 2); - $format= _("Y-M-D"); - $date= preg_replace("/Y/", substr($line["queuing_time"], 0, 4), $format); - $date= preg_replace("/M/", substr($line["queuing_time"], 4, 2), $date); - $date= preg_replace("/D/", substr($line["queuing_time"], 6, 2), $date); - $str_date = $date." ".$hour.":".$minute; - }else{ - $str_date = $no_acl; - } - - /* Create entry html str */ - - if(preg_match("/r/",$detailedViewACL)){ - $str = " - - \"\" -  ".$line["uid"]. - " - - $str_date"; - }else{ - $str = " - \"\" -  ".$line["uid"]." - $str_date"; - } - - /* Add Status td */ - if(preg_match("/r/",$statusACL)){ - $str.="".$this->status[$line["status"]].""; - }else{ - $str.="".$no_acl.""; - } - - /* Add sender_id td */ - if(preg_match("/r/",$senderidACL)){ - $str.="".$line["sender_id"].""; - }else{ - $str.="".$no_acl.""; - } - - /* Add receiver_id td */ - if(preg_match("/r/",$receiveridACL)){ - $str.="".$line["receiver_id"].""; - }else{ - $str.="".$no_acl.""; - } - - /* Add receiver_id td */ - if(preg_match("/r/",$pagesACL)){ - $str.="".$line["pages"].""; - }else{ - $str.="".$no_acl.""; - } - $this->report_list[] = $str; - } - - mysql_close($link); - } - - /************ - Create output out of results - ************/ - - /* Generate output */ - $mod= 0; - $output= ""; - foreach ($this->report_list as $val){ - if ($mod < $this->start) { - $mod++; - continue; - } - if ($mod >= ($this->start + $this->range)){ - $mod++; - break; - } - if ( ($mod++) & 1){ - $col= "background-color: #ECECEC;"; - } else { - $col= "background-color: #F5F5F5;"; - } - $output.= "$val"; - } - - - /************ - Display results - ************/ - - if (isset($fax_users) && count($fax_users)){ - $smarty->assign("search_result", $output); - $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start, $this->range,"EntriesPerPage")); - }else{ - $smarty->assign("search_result", ""); - } - - /* Show main page */ - $smarty->assign("plug", "?plug=".validate($_GET['plug'])); - for($i= 0; $i<7; $i++){ - $smarty->assign("mode$i", ""); - } - $smarty->assign("mode".$this->sort, "\"\"sort_direction. - ".png\" border=0 align=middle>"); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - - /* Save ui input, and store it in $_SESSION - to remember last search next time*/ - function save_object() - { - $faxreportfilter = get_global("faxreportfilter"); - if(isset($_POST['EntriesPerPage'])){ - $this->range = $_POST['EntriesPerPage']; - } - - if (isset($_GET['start'])){ - $this->start= (int)$_GET['start']; - } - - /* Adapt sorting */ - if (isset($_GET['sort'])){ - if ($this->sort == (int)$_GET['sort']){ - if ($this->sort_direction == "down"){ - $this->sort_direction= "up"; - } else { - $this->sort_direction= "down"; - } - } - $this->sort= (int)$_GET['sort']; - if ($this->sort < 0 || $this->sort > 5){ - $this->sort= 0; - } - } - foreach( array("year", "month", "search_for", "search_base") as $type){ - if (isset($_POST[$type])){ - $faxreportfilter[$type]= $_POST[$type]; - - /* reset start page, if filter has changed */ - if(!isset($_GET['start'])){ - $this->start = 0; - } - } - $this->$type= $faxreportfilter[$type]; - - } - foreach($this->attributes_SO as $name){ - $faxreportfilter[$name] = $this->$name; - } - register_global("faxreportfilter",$faxreportfilter); - } - - - /* Return plugin informations for acl handling - #FIXME You can only read attributes within this report plugin */ - static function plInfo() - { - - return (array( - "plShortName" => _("Fax report"), - "plDescription" => _("Fax report")." "._("All entries are readonly")."", - "plSelfModify" => TRUE, - "plDepends" => array(), - "plPriority" => 1, // Position in tabs - "plSection" => array("administration"), // This belongs to personal - "plCategory" => array("faxreport" => array("description" => _("Fax reports"), - "objectClass" => array())), - "plOptions" => array(), - - "plProvidedAcls" => array( - "detailedView" => _("Detailed view"), - "id" => _("Fax ID"), - "queuingtime" => _("Date")." / "._("Time"), - "status" => _("Status"), - "senderid" => _("Sender ID"), - "sendermsn" => _("Sender MSN"), - "receiverid" => _("Receiver ID"), - "receivermsn" => _("Receiver MSN"), - "pages" => _("Number of pages"), - "statusmessage" => _("Status Message"), - "transfertime" => _("Transfer time")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofax/faxreports/contents.tpl b/plugins/gofax/faxreports/contents.tpl deleted file mode 100644 index 197c5b8c8..000000000 --- a/plugins/gofax/faxreports/contents.tpl +++ /dev/null @@ -1,59 +0,0 @@ -
-

[F]{t}Filter{/t}

-
-
-

-  {t}Search for{/t} - - {t}in{/t} - - {t}during{/t} - - {t}in{/t} - -   - -

-
- -
- -{if $search_result ne ""} - - - - - - - - - - {$search_result} -
{t}User{/t} {$mode0}{t}Date{/t} {$mode1}{t}Status{/t} {$mode2}{t}Sender{/t} {$mode3}{t}Receiver{/t} {$mode4}{t}# pages{/t} {$mode5}
- - - - - -
{$range_selector}
-

-   -

- -{else} - {t}Search returned no results...{/t} -{/if} - - - - diff --git a/plugins/gofax/faxreports/detail.tpl b/plugins/gofax/faxreports/detail.tpl deleted file mode 100644 index 20b6123b8..000000000 --- a/plugins/gofax/faxreports/detail.tpl +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - -
- - {t}FAX preview - please wait{/t} - -

- {t}Click on fax to download{/t} -

-
-   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{t}FAX ID{/t}{$fax_id}
{t}User{/t}{$fax_uid}
{t}Date / Time{/t}{$date} / {$time}
{t}Sender MSN{/t}{$fax_sender_msn}
{t}Sender ID{/t}{$fax_sender_id}
{t}Receiver MSN{/t}{$fax_receiver_msn}
{t}Receiver ID{/t}{$fax_receiver_id}
{t}Status{/t}{$fax_status}
{t}Status message{/t}{$fax_status_message}
{t}Transfer time{/t}{$fax_transfer_time}
{t}# pages{/t}{$fax_pages}
- -
- -

- -

- diff --git a/plugins/gofax/faxreports/main.inc b/plugins/gofax/faxreports/main.inc deleted file mode 100644 index ac80ff340..000000000 --- a/plugins/gofax/faxreports/main.inc +++ /dev/null @@ -1,19 +0,0 @@ -save_object(); - $display= $faxreport->execute (); - $display.= "\n"; - $display= print_header(get_template_path('images/reports.png'), _("FAX reports")).$display; - - /* Store changes in session */ - $_SESSION['faxreport']= $faxreport; -} -?> diff --git a/plugins/gofon/conference/class_divListConferences.inc b/plugins/gofon/conference/class_divListConferences.inc deleted file mode 100755 index cdcdcbc9d..000000000 --- a/plugins/gofon/conference/class_divListConferences.inc +++ /dev/null @@ -1,317 +0,0 @@ -parent = $parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of conference rooms")); - $this->SetSummary(_("List of conference rooms")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to create, delete and edit selected phone conferences. Having a large number of phone conferences, you might prefer the range selectors on top of the conferences list.")); - - $this->EnableAplhabet(true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 100; - if($this->parent->snapshotEnabled()){ - $action_col_size += 20; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" =>_("Name - Number"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'")); - $this->AddHeader(array("string" => _("PIN"), "attach" => "style='width:50px;'")); - $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); - - /* Add Checkboxes / SubSearch checkbox */ - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching conference names"),"*" , true); - } - - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("gofonconference"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get acls */ - $acls = $ui->get_permissions($this->selectedBase,"gofonconference/conference"); - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"gofonconference") ; - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* Add the rest (base select ....)*/ - $listhead .= _("Base")." ". - "  "; - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s.= "...|". - " "._("Conference")."|conference_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(is_object($this->parent->CopyPasteHandler)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acls)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - $linkopen= "%s"; - - $userimg = "User"; - $editlink = "%s"; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 100; - if($this->parent->snapshotEnabled()){ - $action_col_size += 20; - } - - /* Insert conferneces*/ - foreach($list as $conferencekey => $conference ){ - - $acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference"); - $acl_all = $this->ui->has_complete_category_acls($conference['dn'],"gofonconference"); - - /* You will need at least read access for the - current conference informations to display it */ - if(!preg_match("/r/",$acl)){ - continue; - } - - $actions =""; - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions.= " "; - $actions.= " "; - } - - /* Add edit icon - This is allowed when we have at least read access. */ - $actions.= ""; - - /* Add snapshot icon - This is allowed when we have create and write access for the current entry */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $actions.= $this->GetSnapShotActions($conference['dn']); - } - - /* Create delete link - Only if we are allowed to delete this entry */ - if(preg_match("/d/",$acl)){ - $actions.= ""; - } - - /* Display PIN icon, only if we are the owner of the given conference */ - $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0]; - $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN"); - if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){ - $pin = "PIN"; - }else{ - $pin = " "; - } - - /* Display numer of the conference if we are allowed to view it */ - $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber"); - if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){ - $number = " - ".$conference['telephoneNumber'][0]; - }else{ - $number = "  - ?"; - } - - /* Get conference owner name */ - $ldap= $this->parent->config->get_ldap_link(); - $ldap->cat($conference['goFonConferenceOwner'][0], array('cn')); - $data = $ldap->fetch(); - if(isset($data['cn'][0])){ - $cn = $data['cn'][0]; - }else{ - $cn = _("Unknown"); - } - - /* Create title */ - $title = " title='".preg_replace("/ /"," ",@LDAP::fix($data['dn']))."' "; - - /* Cutted objects should be displayed in light grey */ - $display = $conference['cn'][0].$number; - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $conference['dn']) { - $display = "".$display.""; - break; - } - } - } - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'"); - $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$display), "attach" => $title." style=''"); - $a_field3 = array("string"=> $cn , "attach" => $title." style='width:200px;'"); - $a_field4 = array("string"=> $pin, "attach" => $title." style='width:50px;'"); - $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), - "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - - $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5)); - } - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_objs = count($list); - - $num_obj_str = _("Number of listed conferences"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_obj_str." ".$num_objs."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/conference/class_phoneConferenceGeneric.inc b/plugins/gofon/conference/class_phoneConferenceGeneric.inc deleted file mode 100644 index e0364dc54..000000000 --- a/plugins/gofon/conference/class_phoneConferenceGeneric.inc +++ /dev/null @@ -1,794 +0,0 @@ -is_account = TRUE; - $this->ui = get_userinfo(); - $this->orig_dn = $dn; - - $this->languages= get_languages(TRUE,TRUE); - - - /* Check server configurations - * Load all server configuration in $this->goFonHomeServers if available - * and use first server as default if necessary. - */ - $a_SETUP= array(); - if(array_key_exists('config',$_SESSION) && - array_key_exists('SERVERS',$_SESSION['config']->data) && - array_key_exists('FON',$_SESSION['config']->data['SERVERS']) && - count($_SESSION['config']->data['SERVERS']['FON']) && - is_callable("mysql_connect") - ) { - - /* Set available server */ - $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON']; - - /* Set default server */ - if($this->dn == "new"){ - $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; - } - - /* Remember inital home server, to be able to remove old entries */ - $this->init_HomeServer = $this->goFonHomeServer; - - /* get config */ - if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){ - print_red(sprintf(_("The specified home server '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry while ignoring old accounts."),$this->goFonHomeServer, $this->goFonHomeServers[0]['DN'])); - - $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; - $this->init_HomeServer = $this->goFonHomeServers[0]['DN']; - } - $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer]; - } - - /* Set base */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - if(isset($_SESSION['CurrentMainBase'])){ - $this->base = $_SESSION['CurrentMainBase']; - }else{ - $this->base= dn2base($ui->dn); - } - } else { - - /* The base is something like this - "cn=Confis,ou=conferences,ou=asterisk,ou=configs,ou=systems," */ - $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,/", "", $this->dn); - } - - $this->goFonConferenceOwner=$this->ui->dn; - - /* Parse Options ... - * Parameter|Lifetime|number - */ - if($this->dn!="new"){ - $tmp1= split("\|",$this->attrs['goFonConferenceOption'][0]); - - for($i = 0 ; $i < strlen($tmp1[0]);$i++){ - $varname = "goFonConferenceOption_".$tmp1[0][$i]; - if($tmp1[0][$i]=="d"){ - $this->goFonConferenceOption_D = $tmp1[0][$i]; - }else{ - $this->$varname = $tmp1[0][$i]; - } - } - - $this->goFonConferenceOptionLifetime = $tmp1[1]; - if(isset($tmp1[2]) && isset($this->languages[$tmp1[2]])){ - $this->language = $tmp1[2]; - } - - $this->old_tele_number = $this->telephoneNumber; - } - $this->old_dn = $this->dn; - $this->old_cn = $this->cn; - $this->old_base = $this->base; - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log last action */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","gofonconference/".get_class($this),$this->dn); - } - - $smarty= get_smarty(); - - $smarty->assign("bases" ,$this->config->idepartments); - $smarty->assign("base" ,$this->base); - - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - foreach ($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - if(!$this->$val){ - $smarty->assign($val."CHK", ""); - }else{ - $smarty->assign($val."CHK", " checked "); - } - } - - /* Create array with goFonHomeServer */ - $tmp = array(); - foreach($this->goFonHomeServers as $dn => $val){ - if(!is_numeric($dn)){ - $tmp[$dn] = $val['SERVER']; - } - } - $smarty->assign("language",$this->language); - $smarty->assign("languages",$this->languages); - $smarty->assign("goFonHomeServers",$tmp); - $smarty->assign("goFonConferenceOptions", array("D"=>"Conference ","d"=>"Conference without PIN")); - $smarty->assign("goFonConferenceOptionFormats", array("WAV"=>"Wave","GSM"=>"GSM","WAV49"=>"Wave49")); - $smarty->assign("goFonConferenceOption", $this->goFonConferenceOption_D); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - if($this->acl_is_writeable("base")){ - $smarty->assign("baseSelect",true); - }else{ - $smarty->assign("baseSelect",false); - } - - $smarty->assign("bases" ,$this->get_allowed_bases()); - $smarty->assign("base_select" ,$this->base); - - - if($_SESSION['js']==1){ - if($this->goFonConferenceOption_P != "P"){ - $smarty->assign("goFonPINACL", $this->getacl("goFonPIN",TRUE)); - $smarty->assign("goFonPIN",""); - } - if($this->goFonConferenceOption_r != "r"){ - $smarty->assign("goFonConferenceOptionFormatACL", $this->getacl("goFonConferenceOptionr",TRUE)); - } - } - return($smarty->fetch (get_template_path('generic.tpl', TRUE))); - } - - - function remove_from_parent() - { - /* Check if 'old' home server is available in gosa FON server configuration - * Try to remove this entry from database and display errors. - */ - if(isset($this->goFonHomeServers[$this->goFonHomeServer])){ - $str = $this->SQL_remove_me(true); - if($str){ - print_red($str); - return false; - } - }else{ - print_red(_("Could not remove the conference entry from database on home server (%s). Please check your asterisk database configuration.")); - return false; - } - - /* Remove ldap entry */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->recursive_remove(); - - new log("remove","gofonconference/".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'); - } - - - /* Save data to object */ - function save_object() - { - if(isset($_POST['phoneConferenceGeneric'])){ - - /* Get selected language */ - if(isset($_POST['language']) && isset($this->languages[get_post('language')])){ - $this->language = get_post('language'); - } - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - /* Save base, since this is no LDAP attribute */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s", - "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){ - - /* Acl can't contain _ so we remove it here. */ - $acl_name = preg_replace("/_/","",$attrs); - - if($this->acl_is_writeable($acl_name)){ - - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - }else{ - $this->$attrs = false; - } - } - } - } - } - - - function check_database_accessibility() - { - /* Check if mysql extension is available */ - if(!is_callable("mysql_pconnect")){ - return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup.")); - } - - /******************** - * Check currently selected home server - ********************/ - - $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer]; - $r_current = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); - if(!$r_current){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_current)); - - return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), - $cfg_Current['SERVER'],$cfg_Current['LOGIN'])); - } - $db_current = @mysql_select_db($cfg_Current['DB'],$r_current); - if(!$db_current){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_current)); - mysql_close($r_current); - return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER'])); - } - - /******************** - * Check init home server - ********************/ - - if($this->goFonHomeServers != $this->init_HomeServer){ - $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ; - $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']); - if(!$r_init){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init)); - - return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), - $cfg_Init['SERVER'],$cfg_Init['LOGIN'])); - } - $db_init = @mysql_select_db($cfg_Init['DB'],$r_init); - if(!$db_init){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init)); - mysql_close($r_init); - return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER'])); - } - } - } - - /* Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if($this->is_number_used()){ - $message[] = $this->is_number_used(); - } - - /* Check if previously selected server is still available */ - if($this->initially_was_account && !isset($this->goFonHomeServers[$this->goFonHomeServer])){ - $message[]= sprintf(_("The previously selected asterisk home server (%s) is no longer available."),preg_replace("/,/",", ",$this->goFonHomeServer)); - return($message); - } - - if((empty($this->goFonPIN))&&($this->goFonConferenceOption_P=="P")&&($this->goFonConferenceOption_D=="D")){ - $message[]= _("Please enter a PIN."); - } - - if(empty($this->cn)){ - $message[] =_("Please enter a name for the conference."); - } - - if(!is_numeric($this->telephoneNumber)){ - $message[] =_("Only numeric chars are allowed in Number field."); - } - - if(!((is_numeric($this->goFonConferenceOptionLifetime))||(empty($this->goFonConferenceOptionLifetime)))){ - $message[] =_("Only numbers are allowed in Lifetime."); - } - - /* Check if add could be successful */ - $str = $this->SQL_add_me(false); - if(!empty($str)){ - $message[] = $str; - } - - if($this->old_cn != $this->cn || $this->base != $this->old_base){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd("ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->base); - $ldap->search("(&(objectClass=goFonConference)(cn=".$this->cn."))",array("cn")); - if($ldap->count()){ - $message[] =_("There is already a conference with this name in the current tree."); - } - } - return $message; - } - - - function SQL_add_me($save) - { - /* Check if there is at least on server configuration */ - if(!count($this->goFonHomeServers)){ - return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); - } - - /******************** - * Get configuration and try to connect - ********************/ - - /* Check if databases are reachable, returns an error string if anything fails */ - $error_str = $this->check_database_accessibility(); - if($error_str){ - return($error_str); - } - - /* Remove old entries, returns an error string if anything fails */ - $error_str = $this->SQL_remove_me($save); - if($error_str){ - return($error_str); - } - - /* Connect to current database to be able to add new entries */ - $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer] ; - $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); - $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur); - - /******************** - * Remove entries that could cause trouble - ********************/ - - /* If the current home server is different to the initial home server, - * there may be already some entries with the given telephoneNumber and/or cn. - * We must remove those entries to avoid duplicate use of the same extension name. - */ - if($this->goFonHomeServer != $this->init_HomeServer){ - $query = "SELECT id FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->telephoneNumber."' OR exten='".$this->cn."';"; - $res = @mysql_query($query,$res_cur); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - if(!$res){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur)); - return(_("Can not check if there are already some entries with given telephone number and/or cn in the destination home server."). - " "._("Please have a look a the gosa logfiles.")); - } - if($save && mysql_affected_rows($res_cur)) { - $SQL = "DELETE FROM ".$cfg_Current['EXT_TABLE']." - WHERE (exten='".$this->telephoneNumber."') - OR (exten='".$this->cn."')"; - - /* Query and ensure that everything went fine */ - $res = @mysql_query($SQL,$res_cur); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$SQL, "Database query"); - if(!$res){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur)); - return(_("Can not remove entries with some telephone number and/or cn from destination home server."). - " "._("Please have a look a the gosa logfiles.")); - } - } - } - - /******************** - * Add new conference entry - ********************/ - if((!empty($this->telephoneNumber))&&($save==true)){ - - /* Create string out of conference Flags */ - $parameter =""; - foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s", - "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){ - $parameter .= $this->$attrs; - } - - $i=1; - $EXT=array(); - $context="GOsa"; - // Set Language to German - $EXT[$i]['exten'] =$this->telephoneNumber; - $EXT[$i]['context'] = $context; - $EXT[$i]['priority']= $i; - $EXT[$i]['app'] ="SetLanguage"; - $EXT[$i]['appdata'] =$this->language; - $i++; - - if($this->goFonConferenceOption_r == "r"){ - - // Recordingformat for conference - $EXT[$i]['exten'] =$this->telephoneNumber; - $EXT[$i]['context'] =$context; - $EXT[$i]['priority']= $i; - $EXT[$i]['app'] ="Setvar"; - $EXT[$i]['appdata'] ="MEETME_RECORDINGFORMAT=".$this->goFonConferenceOptionFormat; - $i++; - - } - - // Answer Call - $EXT[$i]['exten'] =$this->telephoneNumber; - $EXT[$i]['context'] =$context; - $EXT[$i]['priority']=$i; - $EXT[$i]['app'] ="answer"; - $EXT[$i]['appdata'] =""; - $i++; - - // Start Conference - $EXT[$i]['exten'] =$this->telephoneNumber; - $EXT[$i]['context'] =$context; - $EXT[$i]['priority']=$i; - $EXT[$i]['app'] ="MeetMe"; - - if(empty($this->goFonPIN)) { - $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter; - }else{ - $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter."|".$this->goFonPIN; - } - $i++; - - // Start Conference - $EXT[$i]['exten'] =$this->cn; - $EXT[$i]['context'] =$context; - $EXT[$i]['priority']=1; - $EXT[$i]['app'] ="Goto"; - $EXT[$i]['appdata'] =$this->telephoneNumber."|1"; - $SQL=array(); - - foreach($EXT as $keytop => $valtop){ - $s_keys = ""; - $s_values = ""; - foreach($valtop as $key=>$val){ - $s_keys .="`".$key."`,"; - $s_values .="'".$val."',"; - } - $s_keys =preg_replace("/\,$/","",$s_keys); - $s_values =preg_replace("/\,$/","",$s_values); - $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$s_keys.") VALUES (".$s_values.");"; - } - foreach($SQL as $sqlsyn){ - mysql_query($sqlsyn,$res_cur); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$sqlsyn, "Database query"); - } - } - - @mysql_close($res_cur); - } - - - /* Remove initial entry from database - * This function checks if there is an entry in the - * initial home server that uses this->old_cn or $this->old_tele_number - * and removes this entries. - * This function is called from save and remove_from parent. - * - * The parameter '$save' is false if we just - * want to check if a remove is possible. - * And true if we realy want to remove the entries. - */ - function SQL_remove_me($save) - { - /* check database access */ - $str = $this->check_database_accessibility(); - if($str){ - return($str); - } - - /* Connect to old database */ - $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ; - $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']); - $db_init = @mysql_select_db($cfg_Init['DB'],$r_init); - - /* Check if there is an old entry */ - $query = "SELECT id FROM ".$cfg_Init['EXT_TABLE']." WHERE exten='".$this->old_tele_number."' OR exten='".$this->old_cn."';"; - $res = @mysql_query($query,$r_init); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - if(!$res){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init)); - return(_("Can not check if entry exists in old database. Please have a look a the gosa logfiles.")); - } - - /* There are entries using this cn and/or phone number */ - if($save && mysql_affected_rows($r_init)) { - $SQL = "DELETE FROM ".$cfg_Init['EXT_TABLE']." - WHERE (exten='".$this->old_tele_number."') - OR (exten='".$this->old_cn."')"; - - /* Query and ensure that everything went fine */ - $res = @mysql_query($SQL,$r_init); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$SQL, "Database query"); - if(!$res){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init)); - return(_("Can not remove old entries from initial home server. Please have a look a the gosa logfiles.")); - } - - }//ENDE old num availiable ... - @mysql_close($r_init); - return(false); - } - - - - /* This function checks if the given phonenumbers are available or already in use*/ - function is_number_used() - { - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid")); - while($attrs = $ldap->fetch()) { - unset($attrs['telephoneNumber']['count']); - foreach($attrs['telephoneNumber'] as $tele){ - if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn']; - if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn']; - $numbers[$tele]=$attrs; - } - } - - $num = $this->telephoneNumber; - if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!=$this->old_cn))){ - if(isset($numbers[$num]['uid'][0])){ - return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]); - }else{ - return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]); - } - } - } - - - /* Save to LDAP */ - function save() - { - - if((!isset($this->attrs['goFonPIN']))){ - $pin_use = false; - }else{ - $pin_use = true; - } - - /* Unset PIN if this is a conference without PIN */ - if((!empty($this->goFonPIN)||($this->goFonConferenceOption_P=="P"))&&($this->goFonConferenceOption_D=="d")){ - $this->goFonPIN = ""; - } - - plugin::save(); - - if(empty($this->old_tele_number)){ - $this->old_tele_number= $this->telephoneNumber; - } - - $this->SQL_add_me(true); - - if(empty($this->goFonConferenceOption_P)){ - if($pin_use){ - $this->attrs['goFonPIN']=array(); - }else{ - unset($this->attrs['goFonPIN']); - } - } - $this->attrs['goFonConferenceOption']=""; - foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s", - "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D","goFonConferenceOptionFormat") as $attrs){ - $this->attrs['goFonConferenceOption'] .= $this->$attrs; - unset($this->attrs[$attrs]); - } - - $this->attrs['goFonConferenceOption'].="|".$this->goFonConferenceOptionLifetime; - $this->attrs['goFonConferenceOption'].="|".$this->language; - unset($this->attrs['goFonConferenceOptionLifetime']); - - /* Write back to ldap */ - - unset($this->attrs['base']); - - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn, array('dn')); - - if ($ldap->count()){ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - $this->handle_post_events('modify'); - } else { - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - $this->handle_post_events('add'); - } - - /* Log last action */ - if($this->initially_was_account){ - new log("modify","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of goFonConference/generic with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->postcreate(); - } - - - function getCopyDialog() - { - $smarty = get_smarty(); - $smarty->assign("cn" ,$this->cn); - $smarty->assign("telephoneNumber" ,$this->telephoneNumber); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - if(isset($_POST['telephoneNumber'])){ - $this->telephoneNumber = $_POST['telephoneNumber']; - } - } - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source) ; - - $source_o = new conference($this->config,$source['dn']); - - foreach($this->attributes as $attr){ - $this->$attr = $source_o->$attr; - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Conference"), - "plDescription" => _("Phone conference management"), - "plSelfModify" => TRUE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("addons" => _("Addons")), - "plCategory" => array("gofonconference" => array("description" => _("GOfon conference"), - "objectClass" => "gofonConference")), - - "plProvidedAcls" => array( - "cn" => _("Name"), - "base" => _("Base"), - "description" => _("Description"), - "goFonPIN" => _("Conference PIN"), - - "goFonHomeServer" => _("Home server"), - "goFonConferenceOptionP" => _("Preset PIN"), - "goFonConferenceOptionr" => _("Record conference"), - "goFonConferenceOptionM" => _("Play music on hold"), - "goFonConferenceOptions" => _("Activate menu"), - "goFonConferenceOptioni" => _("Announce user activity"), - "goFonConferenceOptionc" => _("Count user"), - "goFonConferenceOptionD" => _("Conference type"), - - "goFonConferenceOptionFormat" => _("Format"), - "goFonConferenceOptionLifetime" => _("Lifetime"), - "telephoneNumber" => _("Telephone number"), - "goFonConferenceOwner" => _("Owner")) - )); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/conference/class_phoneConferenceManagment.inc b/plugins/gofon/conference/class_phoneConferenceManagment.inc deleted file mode 100644 index 023e52e36..000000000 --- a/plugins/gofon/conference/class_phoneConferenceManagment.inc +++ /dev/null @@ -1,555 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $attributes = array(); - var $objectclasses = array(); - - var $conferences = array(); - var $conftab = false; - var $ui = NULL; - var $DivListConference = NULL; - - var $CopyPasteHandler = NULL; - var $start_pasting_copied_objects = FALSE; - - /* Initialise Class */ - function phoneConferenceManagment (&$config, $ui) - { - $this->ui = $ui; - $this->dn = ""; - $this->config = $config; - $this->DivListConference = new divListConference($this->config,$this); - - /* Copy & Paste enabled ?*/ - if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - } - - - /* Execute class and display something */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - $_SESSION['LOCK_VARS_TO_USE'] = array("/^id$/","/^act$/","/^conference_/","/^item_selected/","/^remove_multiple_conferences/"); - - /*************** - Variable initialisation - ***************/ - - /* Reload departments */ - $smarty = get_smarty(); - $display = ""; - $s_action = ""; // Will contain an action, like del or edit - $s_entry = ""; // The entry name for edit delete -... - - - /*************** - Check posts - ***************/ - - foreach($_POST as $key => $post){ - if(preg_match("/^conference_new.*/i",$key)){ - $s_action = "new"; - // Post for delete - }elseif(preg_match("/^conference_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/^conference_del_/i","",$key); - $s_entry = preg_replace("/_.*$/","",$s_entry); - // Post for edit - }elseif(preg_match("/conference_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/conference_edit_/i","",$key); - $s_entry = preg_replace("/_.*$/","",$s_entry); - }elseif(preg_match("/^remove_multiple_conferences/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^editPaste.*/i",$key)){ - $s_action="editPaste"; - }elseif(preg_match("/^copy_.*/",$key)){ - $s_action="copy"; - $s_entry = preg_replace("/^copy_/i","",$key); - $s_entry = preg_replace("/_.$/","",$s_entry); - }elseif(preg_match("/^cut_.*/",$key)){ - $s_action="cut"; - $s_entry = preg_replace("/^cut_/i","",$key); - $s_entry = preg_replace("/_.$/","",$s_entry); - }elseif(preg_match("/^multiple_copy_objects/",$key)){ - $s_action = "copy_multiple"; - }elseif(preg_match("/^multiple_cut_objects/",$key)){ - $s_action = "cut_multiple"; - } - } - - /* Edit Entry */ - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action = "edit"; - $s_entry = $_GET['id']; - } - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "conference_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - /*************** - Cancel dialogs - ***************/ - - /* Reset requested? */ - if (isset($_POST['edit_cancel'])){ - if (isset($this->conftab)){ - del_lock ($this->conftab->dn); - unset ($this->conftab); - } - $this->conftab= NULL; - $this->lognames= array();; - $this->cn= ""; - unset ($_SESSION['objectinfo']); - } - - - /******************** - Copy & Paste Handling ... - ********************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->conferences[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - $smarty->assign("info", sprintf(_("You're about to delete the following user(s) %s"), @LDAP::fix($dns_names))); - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_conference_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - $this->dn = $dn; - $acl = $this->ui->get_permissions($this->dn,"gofonconference/conference"); - if(preg_match("/d/",$acl)){ - $this->remove_from_parent(); - } else { - print_red (_("You have no permission to remove this department.")); - } - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_conference_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /*************** - Delete - ***************/ - - /* Delete Entry if Posted action (s_action) == del - * The entry which will be deleted is defined in $s_entry - */ - if ($s_action =="del"){ - - $acl = $this->ui->get_permissions($this->conferences[$s_entry]['dn'],"gofonconference/conference"); - if(preg_match("/d/",$acl)){ - $this->dn= $this->conferences[$s_entry]['dn']; - - /* Check locking */ - if (($conf= get_lock($this->dn)) != ""){ - $_SESSION['dn']= $this->dn; - return(gen_locked_message($conf, $this->dn)); - } else { - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), $this->dn)); - $smarty->assign("multiple", false); - $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE)); - return ($display); - } - } - } - - - /*************** - Delete confirmed - ***************/ - - /* If department deletion is accepted ... - * Finally delete department - */ - if (isset($_POST['delete_department_confirm'])){ - $acl = $this->ui->get_permissions($this->dn,"gofonconference/conference"); - if(preg_match("/d/",$acl)){ - $this->remove_from_parent(); - } else { - print_red (_("You have no permission to remove this department.")); - } - } - - - /*************** - Edit - ***************/ - - /* Edit Entry if Posted action (s_action) == edit - * The entry which will be edited is defined in $s_entry - */ - if (($s_action=="edit") && (!isset($this->conftab->config))){ - - $this->dn= $this->conferences[$s_entry]['dn']; - - if (($conf= get_lock($this->dn)) != ""){ - return(gen_locked_message ($conf, $this->dn)); - } - - /* Lock the current entry, so everyone will get the above dialog */ - add_lock ($this->dn, $this->ui->dn); - - /* Register conftab to trigger edit dialog */ - $this->conftab= new conferencetabs($this->config,$this->config->data['TABS']['CONFERENCETABS'], $this->dn,"gofonconference"); - $this->conftab->set_acl_base($this->dn); - $_SESSION['objectinfo']= $this->dn; - } - - - /*************** - Create new - ***************/ - - /* Insert new entry*/ - if($s_action == "new" ){ - - $dummy_dn = "cn=dummy,ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->DivListConference->selectedBase; - $acl = $this->ui->get_permissions($dummy_dn,"gofonconference/conference"); - if(preg_match("/c/",$acl)){ - /* Set up the users ACL's for this 'dn' */ - $this->dn= "new"; - $this->conftab= new conferencetabs($this->config,$this->config->data['TABS']['CONFERENCETABS'], $this->dn,"gofonconference"); - $this->conftab->set_acl_base($dummy_dn); - unset($_SESSION['objectinfo']); - } - } - - - /*************** - Save entry - ***************/ - - /* Edit finished, check and save changes */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->conftab->config))){ - /* Check tabs, will feed message array */ - $this->conftab->last= $this->conftab->current; - $this->conftab->save_object(); - $message= $this->conftab->check(); - - if (count($message) == 0){ - if($this->conftab->save() == 1){ - gosa_log ("goFonConference object '".$this->dn."' saving failed."); - return; - } - gosa_log ("goFonConference object '".$this->dn."' has been saved"); - - if (!isset($_POST['edit_apply'])){ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - } - - del_lock ($this->conftab->dn);; - unset ($this->conftab); - $this->conftab= NULL; - unset ($_SESSION['objectinfo']); - } else { - show_errors($message); - } - } - - - /*************** - Display dialogs - ***************/ - - /* if edit or new, show dialog */ - if(($this->conftab) && (isset($this->conftab->config))){ - $display= $this->conftab->execute(); - - /* Don't show buttons if tab dialog requests this */ - if (!$this->conftab->by_object[$this->conftab->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - return ($display); - } - - - /*************** - display divlist - ***************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListConference->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Return rendered main page */ - /* Display dialog with system list */ - $this->DivListConference->parent = $this; - $this->DivListConference->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListConference->SubSearch){ - $this->DivListConference->AddDepartments($this->DivListConference->selectedBase,5,1); - } - $this->reload(); - $this->DivListConference->setEntries($this->conferences); - return($this->DivListConference->Draw()); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array("ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->DivListConference->selectedBase)); - } - - - /* Reload entries for divlist. - * reload all conferences for the current base, with the given regex - */ - function reload() - { - $Base = "ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->DivListConference->selectedBase; - $SubSearch = $this->DivListConference->SubSearch; - $Regex = $this->DivListConference->Regex; - $Flags = GL_SIZELIMIT ; - $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=goFonConference))"; - $Attrs = array("cn","goFonConferenceOwner","goFonPIN","telephoneNumber"); - - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - } - - $this->conferences= get_list($Filter, "gofonconference", $Base, $Attrs, $Flags); - } - - function remove_from_parent() - { - /* Ehm what are we doinf here ? */ - - $cfg = new conference($this->config, $this->dn); - $cfg->set_acl_category("gofonconference"); - $cfg->set_acl_base($this->dn); - - $cfg->remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->recursive_remove(); - - /* Optionally execute a command after we're done */ - $this->postremove(); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new conftab($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->conferences[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"conferencetabs","CONFERENCETABS","gofonconference"); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->conferences[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","conferencetabs","CONFERENCETABS","gofonconference"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","conferencetabs","CONFERENCETABS","gofonconference"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListConference->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - function save_object() - { - $this->DivListConference->save_object(); - } - - function remove_lock() - { - if (isset($this->dn)){ - del_lock ($this->dn); - } - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/conference/generic.tpl b/plugins/gofon/conference/generic.tpl deleted file mode 100644 index 63938a43c..000000000 --- a/plugins/gofon/conference/generic.tpl +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
-

- {t}Properties{/t} -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
- - {$must} - -{render acl=$cnACL} - -{/render} -
- - {$must} - -{render acl=$goFonConferenceOptionDACL} - -{/render} -
-
-
- - {$must} - - -{render acl=$baseACL} - -{/render} - -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} - -
{$must} -{render acl=$goFonHomeServerACL} - -{/render} -
{t}Language{/t} - - -
-
-   - - - - - - - - - - - - - - -
- - -{render acl=$descriptionACL} - -{/render} -
- {t}Lifetime (in days){/t} - -{render acl=$goFonConferenceOptionLifetimeACL} - -{/render} -
- {t}Phone number{/t} - {$must} - -{render acl=$telephoneNumberACL} - -{/render} -
- -
-

 

-
-

- {t}Options{/t} -

-
- - - - - - - - - - - - - - - - - -
-{render acl=$goFonConferenceOptionPACL} - -{/render} - - {t}Preset PIN{/t} -
-   - - {t}PIN{/t} -{render acl=$goFonPINACL} - -{/render} -
-{render acl=$goFonConferenceOptionrACL} - -{/render} - {t}Record conference{/t} -
-   - - {t}Sound file format{/t}  -{render acl=$goFonConferenceOptionFormatACL} - -{/render} -
- -
-   - - - - - - - - - - - - - - - -
-{render acl=$goFonConferenceOptionMACL} - -{/render} - {t}Play music on hold{/t} -
-{render acl=$goFonConferenceOptionsACL} - -{/render} - {t}Activate session menu{/t} -
-{render acl=$goFonConferenceOptioniACL} - -{/render} - {t}Announce users joining or leaving the conference{/t} -
-{render acl=$goFonConferenceOptioncACL} - -{/render} - {t}Count users{/t} -
- -
- - - - - - diff --git a/plugins/gofon/conference/headpage.tpl b/plugins/gofon/conference/headpage.tpl deleted file mode 100644 index 5b5a95a89..000000000 --- a/plugins/gofon/conference/headpage.tpl +++ /dev/null @@ -1,45 +0,0 @@ - - - - - -
-
-

- {t}List of conference rooms{/t} {$hint} -

-
-
- {$conferencehead} -
-
-
- {$conferences} - -
-
-
-

[i]{t}Information{/t}

-
-
-

- {t}This menu allows you to create, delete and edit selected phone conferences. Having a large number of phone conferences, you might prefer the range selectors on top of the conferences list.{/t} -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- -
- {$apply} -
- - -
- - diff --git a/plugins/gofon/conference/main.inc b/plugins/gofon/conference/main.inc deleted file mode 100644 index d75fc78d9..000000000 --- a/plugins/gofon/conference/main.inc +++ /dev/null @@ -1,56 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('conference'); - } -} else { - /* Create usermanagement object on demand */ - if (!isset($_SESSION['conference']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['conference']= new phoneConferenceManagment($config, $ui); - } - $conference= $_SESSION['conference']; - $conference->save_object(); - $output= $conference->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header(get_template_path('images/conference.png'), _("Conference management"), "\"\" ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/conference.png'), _("Conference management")); - } - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('conference'); - } - - /* Show and save dialog */ - $conference->save_object(); - $display.= $output; - $_SESSION['conference']= $conference; -} - -?> diff --git a/plugins/gofon/conference/paste_generic.tpl b/plugins/gofon/conference/paste_generic.tpl deleted file mode 100644 index fa72f3f24..000000000 --- a/plugins/gofon/conference/paste_generic.tpl +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - -
- - {$must} - - -
- {t}Phone number{/t} - {$must} - - -
- diff --git a/plugins/gofon/conference/remove.tpl b/plugins/gofon/conference/remove.tpl deleted file mode 100644 index 970abd4be..000000000 --- a/plugins/gofon/conference/remove.tpl +++ /dev/null @@ -1,24 +0,0 @@ -
-  {t}Warning{/t} -
- {$info} -

- {t}This includes 'all' accounts, systems, etc. in this subtree. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

-{if $multiple} - -   - -{else} - -   - -{/if} -

- diff --git a/plugins/gofon/conference/tabs_conference.inc b/plugins/gofon/conference/tabs_conference.inc deleted file mode 100644 index 5b58065ee..000000000 --- a/plugins/gofon/conference/tabs_conference.inc +++ /dev/null @@ -1,41 +0,0 @@ -base= $this->by_object['conference']->base; - - /* Add references/acls/snapshots */ - $this->addSpecialTabs(); - } - - function check($ignore_account= FALSE) - { - return (tabs::check(TRUE)); - } - - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['conference']; - $new_dn= 'cn='.$baseobject->cn.',ou=conferences,ou=asterisk,ou=configs,ou=systems,'.$baseobject->base; - - if(strtolower($this->dn)==strtolower($new_dn)){ - $this->dn=$new_dn; - } - - if($this->dn != $new_dn){ - $baseobject->recursive_move($this->dn, $new_dn); - } - $this->dn= $new_dn; - - tabs::save(TRUE); - } - -} - -?> diff --git a/plugins/gofon/fonreports/class_fonreport.inc b/plugins/gofon/fonreports/class_fonreport.inc deleted file mode 100644 index a63a78f3e..000000000 --- a/plugins/gofon/fonreports/class_fonreport.inc +++ /dev/null @@ -1,415 +0,0 @@ -config = $config; - $this->ui = $ui; - $this->search_base= get_base_from_people($ui->dn); - - $this->month = date("m"); - $this->year = date("Y"); - - /* Use filter settings if we have already searched */ - if (!is_global("fonfilter")){ - $fonfilter = array(); - foreach($this->attributes_SO as $name){ - $fonfilter[$name]=$this->$name; - } - register_global("fonfilter", $fonfilter); - }else{ - $fonfilter = get_global("fonfilter"); - foreach($this->attributes_SO as $name){ - $this->$name = $fonfilter[$name]; - } - } - } - - - /* Save ui interactions and store results in session, - to remember settings */ - function save_object() - { - $fonfilter= get_global("fonfilter"); - if(isset($_POST['EntryPerPage'])){ - $this->range = $_POST['EntryPerPage']; - } - if (isset($_GET['start'])){ - $this->start= (int)$_GET['start']; - } - foreach( array("year", "month", "search_for", "search_base") as $type){ - if (isset($_POST[$type])){ - $this->$type= $_POST[$type]; - } - } - - /* Adapt sorting */ - if (isset($_GET['sort'])){ - if ($this->sort == (int)$_GET['sort']){ - if ($this->sort_direction == "down"){ - $this->sort_direction= "up"; - } else { - $this->sort_direction= "down"; - } - } - $this->sort= (int)$_GET['sort']; - if ($this->sort < 0 || $this->sort > 6){ - $this->sort= 0; - } - } - - /* remove unwanted tags */ - $this->search_for = stripslashes(preg_replace("/[^0-9a-z\*\+ \-]/i","",$this->search_for)); - - foreach($this->attributes_SO as $name){ - $fonfilter[$name] = $this->$name; - } - register_global("fonfilter", $fonfilter); - } - - - /* Search & display results */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* GVet template engine */ - $smarty= get_smarty(); - - /* Log view */ - if(!$this->view_logged){ - $this->view_logged = TRUE; - new log("view","gofon/".get_class($this),$this->dn); - } - - /***************** - Variable Init - *****************/ - - $fields_str = ""; - - $months= array(); - for($i = 1 ; $i <= 12 ; $i ++ ){ - $months[$i] = _(date("F",gmmktime(0,0,0,$i))); - } - - /* Prepare template */ - $current= date("Y"); - $years= array(); - for ($y= $current - 5; $y<=$current; $y++){ - $years[$y]= $y; - } - - /***************** - Smarty - *****************/ - $bases = array(); - $cat_bases = $this->ui->get_module_departments("gofon"); - foreach($this->config->idepartments as $dn => $name){ - if(in_array_ics($dn,$cat_bases)){ - $bases[$dn] = $name; - } - } - - if(!isset($bases[$this->search_base])){ - $this->search_base = key($bases); - } - - $smarty->assign("plug", "?plug=".validate($_GET['plug'])); - $smarty->assign("launchimage", get_template_path('images/launch.png')); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("search_for", $this->search_for); - $smarty->assign("bases", $bases); - $smarty->assign("base_select", $this->search_base); - $smarty->assign("months", $months); - $smarty->assign("month_select", $this->month); - $smarty->assign("years", $years); - $smarty->assign("year_select", $this->year); - $smarty->assign("search_result", ""); - - - /***************** - Check Database , Table , Connection - *****************/ - - /* Connecting, selecting database */ - if (!isset($this->config->data['SERVERS']['FON'][0])){ - print_red(_("Can't connect to phone database, no reports can be shown!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - }elseif(!is_callable("mysql_connect")){ - print_red(_("There is no mysql extension available, please check your php setup.")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - }else{ - - $cfg= $this->config->data['SERVERS']['FON'][0]; - $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); - if ($link === FALSE){ - print_red(_("Can't connect to phone database, no reports can be shown!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - if (! @mysql_select_db("gophone")){ - print_red(_("Can't select phone database for report generation!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - } - - - /***************** - Get Query String && Search - *****************/ - - $query = $this->CreateQuerySyntax(); - $cfg = $this->config->data['SERVERS']['FON'][0]; - $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); - - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - - $result = @mysql_query($query); - if ($result === false){ - print_red(_("Query for phone database failed!")); - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - /***************** - Fetch results - *****************/ - - $report_list= array(); - - /* Restricted attributes will not be displayed, this will be displayed instead */ - $no_acl = ""._("Insufficient permissions").""; - - $no_acl = " "; - - while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { - - foreach($line as $attr => $value){ - - if($attr == "duration") continue; - - $acl = $this->ui->get_permissions($this->search_base,"gofon/fonreport",$attr); - if(!preg_match("/r/",$acl)){ - $line[$attr] = $no_acl; - } - } - - if($this->ui->get_permissions($this->search_base,"gofon/fonreport","calldate")){ - $hour= substr($line["calldate"], 11, 2); - $minute=substr($line["calldate"], 14, 2); - $format= _("Y-M-D"); - $date= preg_replace("/Y/", substr($line["calldate"], 0, 4), $format); - $date= preg_replace("/M/", substr($line["calldate"], 5, 2), $date); - $date= preg_replace("/D/", substr($line["calldate"], 8, 2), $date); - $date_str = $date." ".$hour.":".$minute; - }else{ - $date_str = $no_acl; - } - - $append_str = ""; - $append_str .= "".$date_str.""; - - foreach(array("src","dst","channel","lastapp","disposition") as $atr){ - if(isset($line[$atr])){ - $append_str .= "".$line[$atr].""; - } - } - - if($this->ui->get_permissions($this->search_base,"gofon/fonreport","duration")){ - $append_str .= "".$this->gen_duration($line["duration"]).""; - }else{ - $append_str .= "".$no_acl.""; - } - $report_list[] = $append_str; - } - - $this->report_list= $report_list; - @mysql_close($link); - - - /***************** - Create list of results - *****************/ - - /* Generate output */ - $mod = 0; - $output = ""; - if(count($this->report_list) < $this->start){ - $this->start = 0; - } - foreach($this->report_list as $val){ - if ($mod < $this->start) { - $mod++; - continue; - } - if ($mod >= ($this->start + $this->range)){ - $mod++; - break; - } - if ( ($mod++) & 1){ - $col= "background-color: #ECECEC;"; - } else { - $col= "background-color: #F5F5F5;"; - } - $output.= "$val"; - } - - /***************** - Tell smarty what we have found - *****************/ - - if ($output != ""){ - $smarty->assign("search_result", $output); - $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start,$this->range,"EntryPerPage")); - } else { - $smarty->assign("search_result", ""); - } - - /* Show main page */ - for($i= 0; $i<7; $i++){ - $smarty->assign("mode$i", ""); - } - $smarty->assign("mode".$this->sort, "\"\"sort_direction.".png\" border=0 align=middle>"); - - return($smarty->fetch(get_template_path('contents.tpl', TRUE))); - } - - - /* Create duration string 12'11" */ - function gen_duration($seconds) - { - if ($seconds / 60 > 1){ - $minutes= (int)($seconds / 60); - $seconds= $seconds % 60; - return ("$minutes’$seconds”"); - } - return ("$seconds”"); - } - - - /* Create WHERE part for our mysql serach */ - function GetUidMatchingFilter() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->search_base); - $s = $this->search_for; - - $s = preg_replace("/\%/","",$s); - $s2 = preg_replace("/\*/","%",$s); - - $filter = "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))". - "(|(uid=$s)(l=$s)(homePhone=$s)(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)". - "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)(title=$s)))"; - - $attrs = array("uid"); - $res = get_list($filter,"users",$this->search_base,$attrs); - - $str = " AND ("; - $fields = array("dstchannel","channel"); - if(count($res)){ - foreach($res as $attrs){ - $uid = $attrs["uid"][0]; - foreach($fields as $name){ - $str .= $name." like '%".$uid."%' OR "; - } - } - } - $str .= " channel like '%".$s."%' OR - dstchannel like '%".$s."%' OR - dst like '".$s2."' OR - src like '".$s2."' OR - lastapp like '".$s2."')"; - return($str); - } - - - /* Create query string */ - function CreateQuerySyntax() - { - /* Get extended search filter which contain uids and so on */ - $uidstring = $this->GetUidMatchingFilter(); - - /* Create string with all fields seperated by ,*/ - $fields_str =""; - foreach($this->fields as $field){ - if($field == "calldate") { - continue; - } - $fields_str .= $field.", "; - } - $fields_str = preg_replace("/, $/","",$fields_str); - - /* Create Sort tag */ - if ($this->sort_direction == "down"){ - $desc= "DESC"; - } else { - $desc= "ASC"; - } - /* Create times */ - $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year)); - $end= date ("YmdHis", mktime(23,59,59,($this->month +1),0,$this->year)); - $query = "SELECT ".$fields_str.",calldate FROM cdr ". - "WHERE - calldate <= $end - AND - calldate >= $start - ". $uidstring." - ORDER BY ".$this->fields[$this->sort]." $desc;"; - return($query); - } - - - /* Return plugin informations for acl handling - #FIXME You can only read attributes within this report plugin */ - static function plInfo() - { - return (array( - "plShortName" => _("Phone reports"), - "plDescription" => _("Phone reports")." "._("All entries are readonly")."", - "plSelfModify" => TRUE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("fonreport"), - - "plProvidedAcls" => array( - "calldate" =>_("Date"), - "src" =>_("Source"), - "dst" =>_("Destination"), - "channel" =>_("Channel"), - "lastapp" =>_("Application called"), - "disposition" =>_("Disposition"), - "duration" =>_("Duration")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/fonreports/contents.tpl b/plugins/gofon/fonreports/contents.tpl deleted file mode 100644 index d8cf0a47f..000000000 --- a/plugins/gofon/fonreports/contents.tpl +++ /dev/null @@ -1,59 +0,0 @@ -
-

[F]{t}Filter{/t}

-
-
-

-  {t}Search for{/t} - - {t}in{/t} - - {t}during{/t} - - {t}in{/t} - -   - -

-
- -
- -{if $search_result } - - - - - - - - - - - {$search_result} -
{t}Date{/t} {$mode0}{t}Source{/t} {$mode1}{t}Destination{/t} {$mode2}{t}Channel{/t} {$mode3}{t}Application{/t} {$mode4}{t}Status{/t} {$mode5}{t}Duration{/t} {$mode6}
- - - - - -
{$range_selector}
- -

-   -

-{else} - {t}Search returned no results...{/t} -{/if} - - - diff --git a/plugins/gofon/fonreports/main.inc b/plugins/gofon/fonreports/main.inc deleted file mode 100644 index 5d1741db6..000000000 --- a/plugins/gofon/fonreports/main.inc +++ /dev/null @@ -1,21 +0,0 @@ -save_object(); - $display= $fonreport->execute (); - $display.= "\n"; - - /* Page header*/ - $display= print_header(get_template_path('images/phonereport.png'), _("Phone reports")).$display; - - /* Store changes in session */ - $_SESSION['fonreport']= $fonreport; -} -?> diff --git a/plugins/gofon/macro/class_divListMacros.inc b/plugins/gofon/macro/class_divListMacros.inc deleted file mode 100755 index de822bb54..000000000 --- a/plugins/gofon/macro/class_divListMacros.inc +++ /dev/null @@ -1,298 +0,0 @@ -parent = $parent; - $this->ui = get_userinfo(); - - /* Set list strings */ - $this->SetTitle(_("List of macros")); - $this->SetSummary(_("List of macros")); - - /* Result page will look like a headpage */ - $this->SetHeadpageMode(); - $this->SetInformation(_("This menu allows you to add, edit and remove selected macros. You may want to use the range selector on top of the macro listbox, when working with a large number of macros.")); - - $this->EnableAplhabet (true); - - /* Disable buttonsm */ - $this->EnableCloseButton(false); - $this->EnableSaveButton (false); - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 100; - if($this->parent->snapshotEnabled()){ - $action_col_size += 20; - } - - /* Toggle all selected / deselected */ - $chk = ""; - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Macro name")." / "._("Department"), "attach" => "style=''")); - $this->AddHeader(array("string" => _("Visible"), "attach" => "style='width:50px;'")); - $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" )); - - /* Add Checkboxes / SubSearch checkbox */ - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - - /* Name ,Text ,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching macro names"),"*" , true); - } - - function GenHeader() - { - /* Prepare departments, - which are shown in the listbox on top of the listbox - */ - $options= ""; - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - $first = ""; - $found = FALSE; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("gofonmacro"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - $acls = $ui->get_permissions($this->selectedBase,"gofonmacro/macro"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - $listhead .= _("Base")." ". - "  "; - - /* Create Layers menu */ - $s = ".|"._("Actions")."|\n"; - $s .= "..|". - " "._("Create")."|\n"; - - /* Append create options */ - if(preg_match("/c/",$acls)){ - $s.= "...|". - " "._("Macro")."|goFonMacro_new|\n"; - } - - /* Multiple options */ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Remove")."|"."remove_multiple|\n"; - - /* Add multiple copy & cut icons */ - if(preg_match("/(c.*w|w.*c)/",$acls) && is_object( $this->parent->CopyPasteHandler)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } - - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acls)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - - $this->SetDropDownHeaderMenu($s); - - - - - $this->SetListHeader($listhead); - } - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - - $empty = ""; - $macroimg = ""._("Macro").""; - $visible = ""._("yes").""; - $invisible = ""._("no").""; - $editlink = "%s"; - - /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 100; - if($this->parent->snapshotEnabled()){ - $action_col_size += 20; - } - - $ui = get_userinfo(); - - foreach($list as $key => $val){ - - $sacl = $ui->get_permissions($val['dn'],"gofonmacro/macro"); - - $action = ""; - if(!preg_match("/r/",$sacl)){ - continue; - } - - if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$sacl)){ - $action.= " "; - $action.= " "; - } - - $action.= ""; - - if(preg_match("/c/",$sacl) && preg_match("/w/",$sacl)){ - $action.= $this->GetSnapShotActions($val['dn']); - } - - if(preg_match("/d/",$sacl)){ - $action.= ""; - } - - if(isset($val['goFonMacroVisible']['0'])&&($val['goFonMacroVisible']['0'] == "1")){ - $pic1 = $visible; - }else{ - $pic1 = $invisible; - } - - $display= $val["displayName"][0]." (".$val["cn"][0].")"; - if(isset($val['description'][0])){ - - $desc = $val['description'][0]; - if(strlen($desc) > 55){ - $desc = substr($desc,0,52)."..."; - } - - $display .= " [".$desc."]"; - } - - /* Cutted objects should be displayed in light grey */ - if($this->parent->CopyPasteHandler){ - foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ - if($queue_data['dn'] == $val['dn']) { - $display = "".$display.""; - break; - } - } - } - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => sprintf($macroimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); - $field3 = array("string" => $pic1, "attach" => "style='width:50px;'"); - $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - - $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); - } - - /* Create summary string for list footer */ - $num_deps=0; - if(!$this->SubSearch){ - $num_deps = count($this->Added_Departments); - } - $num_objs = count($list); - - $num_obj_str = _("Number of listed macros"); - $num_dep_str = _("Number of listed departments"); - - $str = "".$num_obj_str." ".$num_objs."    "; - $str.= "".$num_dep_str." ".$num_deps."    "; - - $this->set_List_Bottom_Info($str); - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/macro/class_gofonMacro.inc b/plugins/gofon/macro/class_gofonMacro.inc deleted file mode 100755 index 1dbb4ee22..000000000 --- a/plugins/gofon/macro/class_gofonMacro.inc +++ /dev/null @@ -1,593 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /*! Macro attributes, */ - var $generate_error= ""; - - /*! The name of the Macro in the openldap drirectory */ - var $cn = ""; - - /*! Display error once */ - var $error_shown = false; - - /*! This ist the variable that contains the description of the macro*/ - var $description = ""; - - /*! The base of the macro, is used to save the macro in the correct directory tree */ - var $base = ""; - - /*! This is the name of the macro which the enduser will see, instead of the cn */ - var $displayName = ""; - - /*! Here is the macro content, the real macroscript */ - var $goFonMacroContent= ""; - - /*! To allow user to use this macro this var must be true, else false */ - var $goFonMacroVisible= 0; - - /*! attribute list for save action */ - var $attributes = array("cn","base", "description","displayName","goFonMacroContent","goFonMacroVisible"); - var $view_logged = FALSE; - var $orig_cn = ""; - /*! Objectclasses that this calls handles */ - var $objectclasses = array("top", "goFonMacro"); - - var $goFonHomeServers = array(); // Contains all available asterisk database server - - //! The Konstructor - /*! Konstructor, load class with attributes of the given dn*/ - function macro (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - /* This is always an account */ - $this->is_account= TRUE; - - /* Edit or new one ?*/ - if ($this->dn == "new"){ - if(isset($_SESSION['CurrentMainBase'])){ - $this->base = $_SESSION['CurrentMainBase']; - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - $this->orig_cn=$this->cn; - $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,/", "", $this->dn); - } - - /* Check server configurations - * Load all server configuration in $this->goFonHomeServers if available - */ - $a_SETUP= array(); - if(array_key_exists('config',$_SESSION) && - array_key_exists('SERVERS',$_SESSION['config']->data) && - count($_SESSION['config']->data['SERVERS']['FON']) && - array_key_exists('FON',$_SESSION['config']->data['SERVERS'])) { - - /* Set available server */ - $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON']; - - /* Remove default entry, not necessary here */ - if(isset($this->goFonHomeServers[0])){ - unset($this->goFonHomeServers[0]); - } - } - } - - - /*! Execute this plugin */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","gofonmacro/".get_class($this),$this->dn); - } - - /* Variables */ - $vars = ""; - $tmp = array(); - $number = 0; - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* A new base was selected, check if it is a valid one */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - $smarty->assign("bases", $this->get_allowed_bases()); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - if($this->acl_is_writeable("base")){ - $smarty->assign("baseSelect",true); - }else{ - $smarty->assign("baseSelect",false); - } - - - /* Assign all vars to Smarty */ - foreach($this->attributes as $ar){ - $smarty->assign($ar, $this->$ar); - } - /* Checkboxes */ - $smarty->assign("base_select", $this->base); - $smarty->assign("vars", $vars); - - if($this->goFonMacroVisible){ - $smarty->assign("goFonMacroVisibleChecked"," checked "); - }else{ - $smarty->assign("goFonMacroVisibleChecked",""); - } - - $smarty->assign("cnACL",$this->getacl("cn",$this->initially_was_account)); - $smarty->assign("cn",$this->cn); - - /* Ensure that macro content is displayed correctly encoded */ - $smarty->assign("goFonMacroContent",htmlentities(utf8_decode ($this->goFonMacroContent))); - - /* Show main page */ - return($smarty->fetch (get_template_path('generic.tpl', TRUE))); - } - - - /* This method check if all databases are reachable. - * Returns with error message or an empty string on success. - * - * - Is mysql extension available - * - Is every server reachable - * - Does the database exists/is accessible - */ - function check_database_accessibility() - { - /* Check if mysql extension is available */ - if(!is_callable("mysql_pconnect")){ - return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup.")); - } - - /******************** - * Check all home server - ********************/ - foreach($this->goFonHomeServers as $goFonHomeServer => $cfg_Current){ - $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(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), - $cfg_Current['SERVER'],$cfg_Current['LOGIN'])); - } - $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(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER'])); - } - } - } - - - /* Remove current macro from all asterisk server. - * First of all check if we have access to all databases. - * - Remove old entries - */ - function remove_from_database($save) - { - /* Check if all databases are reachable */ - $str = $this->check_database_accessibility(); - if($str){ - return($str); - } - - /* Create query string */ - $context = addslashes("macro-".$this->cn); - - /* Remove current macro from each server available */ - if($save){ - foreach($this->goFonHomeServers as $dn => $Server){ - $query = "DELETE FROM ".$Server['EXT_TABLE']." WHERE context='".$context."';"; - $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){ - new log("debug","gofonmacro/".get_class($this),"",array(),@mysql_error($r_current)); - return(sprintf(_("Removing macro from '%s' failed. Check GOsa log for mysql error."),$Server['SERVER'])); - } - @mysql_close($r_current); - } - } - } - - - /* Add current macro to all asterisk server. - * First of all check if we have access to all databases. - * - Remove old entries - * - Add new entries - */ - function add_to_database($save) - { - /* Check if all databases are reachable */ - $str = $this->check_database_accessibility(); - if($str){ - return($str); - } - - /* Remove old entries first. Else we got duplicated entries */ - $str = $this->remove_from_database($save); - if($str){ - return($str); - } - - /* Create query string */ - $context = "macro-".$this->cn; - - /************ - * Parse Macro content - ************/ - $sql = - "INSERT INTO %TABLENAME% ". - " (context,exten,priority,app,appdata) ". - " VALUES "; - - $a_contentLines = split("\n",$this->goFonMacroContent); - foreach($a_contentLines as $i_linenum => $s_linestr){ - - /* Remove the 'exten => ' string in front of the macro content line - * example line 'exten => s,2,GotoIf(${ARG3}?3:5)' - * Remove comments introduced by ; - * Skip empty lines - */ - $s_linestr = trim($s_linestr); - $s_linestr = preg_replace("/;.*$/","",$s_linestr) ; - $s_linestr = preg_replace ("/^.*=\> /","",$s_linestr); - - if(empty($s_linestr)){ - continue; - } - - /* A line that passes the check above should look like this - * s,1,SetLanguage(de) - * 3 parts seperated by , - * If there are more or less parts, abort. - * The preg_replace exclude parameters from split .. - */ - $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)); - } - /* 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 - * to each database. - */ - $exten = addslashes($tmp[0]); - $prio = addslashes($tmp[1]); - $app = addslashes(preg_replace("/\(.*\).*$/","",$tmp[2])); - $para = addslashes(preg_replace("/^.*\(/","",$tmp[2])); - $para = preg_replace("/\).*$/","",$para); - $sql.= " ('".$context."','".$exten."','".$prio."','".$app."','".$para."'),"; - } - - /* Remove last , from query string */ - $sql = preg_replace("/,$/","",$sql); - - /* Save current changes to the database */ - if($save){ - - /* Macro are spread to each asterisk server */ - foreach($this->goFonHomeServers as $dn => $cfg){ - $r_con = @mysql_pconnect($cfg['SERVER'],$cfg['LOGIN'],$cfg['PASSWORD']); - $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){ - new log("debug","gofonmacro/".get_class($this),"",array(),@mysql_error($r_con)); - return(sprintf(_("Insert of new macro failed for server '%s'."),$cfg['SERVER'])); - } - @mysql_close($r_con); - } - } - } - - - function save_object() - { - if (isset($_POST['gofonMacroGenericPosted'])){ - - $old_cn = $this->cn; - $old_visible = $this->goFonMacroVisible; - - /* Create a base backup and reset the - base directly after calling plugin::save_object(); - Base will be set seperatly a few lines below */ - $base_tmp = $this->base; - plugin::save_object(); - $this->base = $base_tmp; - - /* Save base, since this is no LDAP attribute */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; - } - } - - /* Restore old cn if we have insuficient acls to change cn ... */ - if(!$this->acl_is_writeable("cn",$this->initially_was_account)){ - $this->cn = $old_cn; - } - - /* check if we are allowed to toggle visibility */ - if($this->acl_is_writeable("goFonMacroVisible")) { - - /* Checkbox selected ? */ - if(isset($_POST['goFonMacroVisible'])) { - $this->goFonMacroVisible= 1 ; - }else { - if(isset($_POST['displayName'])){ - $this->goFonMacroVisible= 0 ; - } - } - }else{ - $this->goFonMacroVisible = $old_visible; - } - } - } - - - /*! Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(!count($this->goFonHomeServers)){ - $message[] = _("There must be at least one server with an asterisk database to save this phone macro."); - } - - /* Check if insert/replace is possible and all servers are available */ - $str = $this->add_to_database(false); - if($str){ - $message[] = $str; - } - - /* Check if cn is already used */ - if(($this->dn=="new")||($this->orig_cn!=$this->cn)){ - $ldap = $this->config->get_ldap_link(); - $ldap->search("(&(objectClass=goFonMacro)(cn=".$this->cn."))",array("cn")); - if($ldap->count()>0){ - $message[]=sprintf(_("The given cn '%s' already exists."),$this->cn); - } - } - - /* Check if display name is set */ - if(empty($this->displayName)){ - $message[] = _("You must specify the 'Display Name' in order to save this macro"); - } - /* CN is restricted to 20 chars */ - if(strlen("Makro-".$this->cn)>20 ){ - $message[]=_("The given cn is too long, to create a Makro entry, maximum 20 chars."); - } - - /* If this macro is still in use we should not change the visible for user flag to invisible */ - if(!$this->goFonMacroVisible){ - $ldap = $this->config->get_ldap_link(); - $res = $ldap->search("(&(objectClass=goFonAccount)(objectClass=gosaAccount)(goFonMacro=*))", array("goFonMacro")); - while ($val = $ldap->fetch()){ - if(strstr($val['goFonMacro'][0],$this->dn)){ - $message[] = _("This macro is still in use. It is necessary to mark this macro as visible for users."); - return($message); - } - } - } - - /* Macro content must be smaller than 100 lines */ - if(count(split("\n",$this->goFonMacroContent))>100){ - $message[] = _("Makro length must be lower than 100 lines"); - } - - /* Macro content must be smaller than 100 lines */ - if(empty($this->goFonMacroContent)){ - $message[] = _("You can't save an empty macro."); - } - return $message; - } - - - /*! Remove makro from all given databases - * and ldap too. - */ - function remove_from_parent() - { - $ldap= $this->config->get_ldap_link(); - - /* Skip remove if this macro is still in use */ - $res = $ldap->search("(&(objectClass=goFonAccount)(objectClass=gosaAccount)(goFonMacro=*))", array("goFonMacro")); - while ($val = $ldap->fetch()){ - if(strstr($val['goFonMacro'][0],$this->dn)){ - print_red(_("This macro is still in use. To delete this Macro ensure that nobody has selected it.")); - return false; - } - } - - /* Try to remove from database */ - if(count($this->goFonHomeServers)){ - $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.")); - 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)); - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $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)); - } - } - - - /*! Save to LDAP */ - function save() - { - plugin::save(); - unset($this->attrs['base']); - - /* Try to add entries to databases */ - $str = $this->add_to_database(true); - if($str){ - print_red($str); - }else{ - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('dn')); - $a= $ldap->fetch(); - - if (count($a)){ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - $this->handle_post_events("modify"); - } else { - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - $ldap->cd($this->dn); - $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)); - - /* Log last action */ - if($this->initially_was_account){ - new log("modify","gofonmacro/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create","gofonmacro/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - } - } - - - function getCopyDialog() - { - $smarty = get_smarty(); - $smarty->assign("cn" ,$this->cn); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE)); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - } - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Asterisk macro management"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("gofonmacro" => array("description" => _("GOfon macro"), - "objectClass" => "gofonMacro")), - - "plProvidedAcls" => array( - "cn" => _("Macro name"), - "base" => _("Base"), - "description" => _("Description"), - "displayName" => _("Display name"), - "goFonMacroContent" => _("Macro content and parameter"), - "goFonMacroVisible" => _("Visibility flag")) - )); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/macro/class_gofonMacroManagement.inc b/plugins/gofon/macro/class_gofonMacroManagement.inc deleted file mode 100755 index f25f49521..000000000 --- a/plugins/gofon/macro/class_gofonMacroManagement.inc +++ /dev/null @@ -1,555 +0,0 @@ -config= $config; - $this->ui= $ui; - - $this->DivListMacro = new divListMacro($this->config,$this); - - /* Copy & Paste enabled ?*/ - if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - $_SESSION['LOCK_VARS_TO_USE'] = array("/^goFonMacro_/","/^act$/","/^id$/","/^item_selected/","/^remove_multiple_macros/"); - - /***************** - Variable initialisation - *****************/ - - $s_action = ""; // Contains the action to proceed - $s_entry = ""; // The value for s_action - $base_back = ""; // The Link for Backbutton - $smarty= get_smarty(); - - - /***************** - Check Posts - *****************/ - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/^goFonMacro_del/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/^goFonMacro_del_/i","",$key); - // Post for edit - }elseif(preg_match("/^goFonMacro_edit_/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/^goFonMacro_edit_/i","",$key); - // Post for new - }elseif(preg_match("/^goFonMacro_new/",$key)){ - $s_action="new"; - }elseif(preg_match("/^remove_multiple_macros/",$key)){ - $s_action="del_multiple"; - }elseif(preg_match("/^editPaste.*/i",$key)){ - $s_action="editPaste"; - }elseif(preg_match("/^copy_.*/",$key)){ - $s_action="copy"; - $s_entry = preg_replace("/^copy_/i","",$key); - }elseif(preg_match("/^cut_.*/",$key)){ - $s_action="cut"; - $s_entry = preg_replace("/^cut_/i","",$key); - }elseif(preg_match("/^multiple_copy_objects/",$key)){ - $s_action = "copy_multiple"; - }elseif(preg_match("/^multiple_cut_objects/",$key)){ - $s_action = "cut_multiple"; - } - } - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; - } - $s_entry = preg_replace("/_.$/","",$s_entry); - - - /******************** - Copy & Paste Handling ... - ********************/ - - - /* handle C&P from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){ - $s_action = "copy_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){ - $s_action = "cut_multiple"; - } - if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){ - $s_action = "editPaste"; - } - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "goFonMacro_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /***************** - Create a new Macro - *****************/ - - /* New macro? */ - if ($s_action=="new"){ - - /* By default we set 'dn' to 'new', all relevant plugins will - react on this. */ - $this->dn= "new"; - - /* Create new usertab object */ - $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn,"gofonmacro"); - $this->macrotabs->set_acl_base($this->DivListMacro->selectedBase); - } - - /***************** - Edit || Password canceled - *****************/ - - /* Cancel dialogs */ - if (isset($_POST['edit_cancel'])){ - del_lock ($this->macrotabs->dn); - unset ($this->macrotabs); - $this->macrotabs= NULL; - unset ($_SESSION['objectinfo']); - } - - - /***************** - Edit finised - *****************/ - - /* Finish mac edit is triggered by the tabulator dialog, so - the user wants to save edited data. Check and save at this - point. */ - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->macrotabs->config))){ - - /* Check tabs, will feed message array */ - $this->macrotabs->last= $this->macrotabs->current; - $this->macrotabs->save_object(); - $message= $this->macrotabs->check(); - - /* Save, or display error message? */ - if (count($message) == 0){ - - /* Save data data to ldap */ - $this->macrotabs->save(); - - if (!isset($_POST['edit_apply'])){ - /* macro has been saved successfully, remove lock from - LDAP. */ - if ($this->dn != "new"){ - del_lock ($this->dn); - } - - unset ($this->macrotabs); - $this->macrotabs= NULL; - unset ($_SESSION['objectinfo']); - } - } else { - /* Ok. There seem to be errors regarding to the tab data, - show message and continue as usual. */ - show_errors($message); - } - } - - - /***************** - Edit macro - *****************/ - - /* User wants to edit data */ - if (($s_action=="edit") && (!isset($this->macrotabs->config))){ - - $dn = $this->macros[$s_entry]['dn']; - $acl = $this->ui->get_permissions($dn,"gofonmacro/macro"); - if(preg_match("/r/",$acl)){ - $this->dn = $dn; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so everyone will get the - above dialog */ - add_lock ($this->dn, $this->ui->dn); - /* Register macrotabs to trigger edit dialog */ - $this->macrotabs= new macrotabs($this->config, - $this->config->data['TABS']['MACROTABS'], $this->dn,"gofonmacro"); - $_SESSION['objectinfo']= $this->dn; - } - } - - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - - foreach($ids as $id){ - $dn = $this->macros[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; - } - - $dns_names = "
";
-        foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
-        }
-        $dns_names .="
"; - - /* Lock the current entry, so nobody will edit it during deletion */ - $smarty->assign("intro", sprintf(_("You're about to delete the following user(s) %s"), @LDAP::fix($dns_names))); - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_macro_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - $acl = $this->ui->get_permissions($dn,"gofonmacro/macro"); - if(preg_match("/d/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $dn,"gofonmacro"); - $this->macrotabs->delete (); - unset ($this->macrotabs); - $this->macrotabs= NULL; - - } else { - print_red (_("You are not allowed to delete this macro!")); - } - - /* Remove lock file after successfull deletion */ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_macro_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } - } - - - /***************** - Remove macro - *****************/ - - /* Remove user was requested */ - if ($s_action=="del"){ - - /* Get 'dn' from posted 'uid' */ - $dn = $this->macros[$s_entry]['dn']; - $acl = $this->ui->get_permissions($dn,"gofonmacro/macro"); - - if(preg_match("/d/",$acl)){ - - $this->dn = $dn; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return (gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty= get_smarty(); - $smarty->assign("intro", sprintf(_("You're about to delete the macro '%s'."), $this->dn)); - $smarty->assign("multiple", false); - return($smarty->fetch (get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and - clean session. */ - print_red (_("You are not allowed to delete this macro!")); - } - } - - - /***************** - Remove macro - *****************/ - - /* Confirmation for deletion has been passed. Macro should be deleted. */ - if (isset($_POST['delete_macro_confirm'])){ - - $acl = $this->ui->get_permissions($this->dn,"gofonmacro/macro"); - - if(preg_match("/r/",$acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn,"gofonmacro"); - $this->macrotabs->delete (); - unset ($this->macrotabs); - $this->macrotabs= NULL; - } else { - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this macro!")); - new log("security","gofonmacro/".get_class($this),$this->dn,array(),"Tried to trick deletion."); - } - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - - /***************** - Display open dialogs - *****************/ - - /* Show tab dialog if object is present */ - if (($this->macrotabs) && (isset($this->macrotabs->config))){ - $display= $this->macrotabs->execute(); - - /* Don't show buttons if tab dialog requests this */ - if (!$this->macrotabs->by_object[$this->macrotabs->current]->dialog){ - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - return ($display); - } - - - /***************** - Display entry list - *****************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListMacro->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ - return($str); - } - - /* Return rendered main page */ - /* Display dialog with system list */ - $this->DivListMacro->parent = $this; - $this->DivListMacro->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListMacro->SubSearch){ - $this->DivListMacro->AddDepartments($this->DivListMacro->selectedBase,4,1); - } - $this->reload(); - $this->DivListMacro->setEntries($this->macros); - return($this->DivListMacro->Draw()); - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->macros[$s_entry]['dn']; - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"macrotabs","MACROTABS","gofonmacro"); - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->macros[$id]['dn']; - - if($s_action == "copy_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","macrotabs","MACROTABS","gofonmacro"); - } - if($s_action == "cut_multiple"){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","macrotabs","MACROTABS","gofonmacro"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Load entry from queue and set base */ - $this->CopyPasteHandler->load_entry_from_queue(); - $this->CopyPasteHandler->SetVar("base",$this->DivListMacro->selectedBase); - - /* Get dialog */ - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array("ou=macros,ou=asterisk,ou=configs,ou=systems,".$this->DivListMacro->selectedBase)); - } - - - function reload() - { - /* Set base for all searches */ - $base = $this->DivListMacro->selectedBase; - $SubSearch = $this->DivListMacro->SubSearch; - $Regex = $this->DivListMacro->Regex; - $Filter = "(&(cn=".$Regex.")(objectClass=goFonMacro))"; - $Flags = GL_SIZELIMIT; - $Attrs = array("cn","description","displayName","goFonMacroVisible"); - - /* Prepare for ls or search*/ - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - }else{ - $base = "ou=macros,ou=asterisk,ou=configs,ou=systems,".$base; - } - - /* Generate macro list */ - $res= get_list($Filter, "gofonmacro", $base, $Attrs, $Flags); - - $tmp=array(); - foreach($res as $tkey => $val ){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - ksort($tmp); - $this->macros=array(); - foreach($tmp as $val){ - $this->macros[]=$val; - } - - reset ($this->macros); - } - - - /* Save data to object */ - function save_object() - { - $this->DivListMacro->save_object(); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function adapt_from_template($dn) { } - function check() { } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/macro/class_gofonMacroParameters.inc b/plugins/gofon/macro/class_gofonMacroParameters.inc deleted file mode 100755 index 5a08d3e22..000000000 --- a/plugins/gofon/macro/class_gofonMacroParameters.inc +++ /dev/null @@ -1,414 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Parameter Count*/ - var $para_count = 0 ; - /*! macro base */ - var $base= ""; - - /*! This array contains all Parameter defined for the macro*/ - var $goFonMacroParameter =array(); - - /*! This are the available types for a macro */ - var $type_shortcut= array("string" => array("selected", "", ""), - "combo" => array("", "selected", ""), - "bool" => array("", "", "selected")); - - /*! attribute list for save action */ - var $attributes= array("base","goFonMacroParameter"); - - /*! Objectclasses needed by the class*/ - var $objectclasses= array("top", "goFonMacro"); - var $ui; - - //! The konstructor of macroParameter - /*! The konstructor of macroParameter... - - reads goFonMacroParameter and parses them to an array - - Set attributes from openldap (edit) - - Set attributes from default (new) - */ - function macroParameter (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - $tmp = array(); // temporary Var - $tmp2 = array(); // temporary Var ... - $tmp3 = ""; - $ldap= $config->get_ldap_link(); - - $this->dn = $dn; - - /* This is always an account */ - $this->is_account= TRUE; - - /* Edit or new one ?*/ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } else { - $this->base= dn2base($this->dn); - } - - /* initialising macro parameter */ - if(isset($this->attrs['goFonMacroParameter']) && - isset($this->attrs['goFonMacroParameter']['count'])){ - unset($this->attrs['goFonMacroParameter']['count']); - } - - /* Set Parameters, or a new array if ther are no parameters */ - if(isset($this->attrs['goFonMacroParameter'])){ - $this->goFonMacroParameter = $this->attrs['goFonMacroParameter']; - }else{ - $this->goFonMacroParameter =array(); - } - - /* Create an array for parameters if not given yet */ - if(!is_array($this->goFonMacroParameter)){ - $tmp3 = $this->goFonMacroParameter; - $this->goFonMacroParameter =array(); - if(!empty($tmp3)) { - $this->goFonMacroParameter[] = $tmp3; - } - } - - /* Load parametersettings*/ - foreach($this->goFonMacroParameter as $para){ - $tmp = split("!",$para); - $num = $tmp[0]; - $tmp2[$num]['name'] = base64_decode($tmp[1]); - $tmp2[$num]['type'] = $tmp[2]; - $tmp2[$num]['default'] = $tmp[3]; - $tmp2[$num]['var'] = "var".$num; - } - - - /* Assign this array */ - $this->goFonMacroParameter = $tmp2; - - $this->para_count = count ($tmp2); - - $this->ui= get_userinfo(); - } - - //! Perform Parameter check - /*! - Compares the given parameters (goFonMacroParameters) with the parameters defined in goFonContent\n - -> Decide which attrs are new and which are unused\n - -> Sort result array (containing both parameters 'goFonMacroParameters/goFonContent' and new / unused info)\n - \param $content The given goFonContent for this macro\n - \param $goFonMacroParameter Array with the already given parameters \n - */ - function check_paras($content,$goFonMacroParameter) - { - /* Check contents for parameters */ - preg_match_all("/[$]\{ARG[0-9]*\}/",$content,$res,PREG_OFFSET_CAPTURE); - - $new = array(); - - /* Detect parameters with positions */ - foreach($res[0] as $val){ - $num = preg_replace("/[^0-9]/","",$val[0]); - $new[$num]['val'] = $val[0]; - $new[$num]['num'] = $num; - } - - /* Compare content parameter and macro parameter */ - foreach($goFonMacroParameter as $gokey => $goval){ - foreach($new as $nkey => $nval){ - if($gokey == $nval['num']){ - /* sign this as OK */ - $goFonMacroParameter[$gokey]['check']= true; - } - } - } - - /* Now check if there is new parameter in the content, which is not assigned yet */ - foreach($new as $key => $val){ - /* Assign std values */ - $goFonMacroParameter[$key]['var']="var".$key; - $goFonMacroParameter[$key]['check']= true; - - /* If this is a new Parameter, name it ${ARG#} by default*/ - if((!isset($goFonMacroParameter[$key]['name']))||(empty($goFonMacroParameter[$key]['name']))){ - $goFonMacroParameter[$key]['name']="\${ARG".$key."}"; - } - } - - foreach($goFonMacroParameter as $key => $val){ - /* All attributes with check == false, are unneeded so mark them with ['check']= false */ - if(!isset($goFonMacroParameter[$key]['check'])){ - $goFonMacroParameter[$key]['check']= false; - } - /* Ah no default given assign ="" to prevent unsigned index */ - if(!isset($goFonMacroParameter[$key]['default'])){ - $goFonMacroParameter[$key]['default'] = ""; - } - } - - /* Sort output for better reading */ - asort($goFonMacroParameter); - return($goFonMacroParameter); - - } - - //! Execute this Plugin - /*! - Perform Parameter check \n - Draw paramter table\n - Show tpl \n - */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Variables */ - $vars = ""; - $tmp = array(); - $number = 0; - - /* Get acls for this tab, - there is only one attribute to write, - so we use the acls from gofon/marco */ - $ACLs = $this->ui->get_permissions($this->dn,"gofonmacro/macro","goFonMarcoContent"); - - /* get current content */ - $content = $_SESSION['macroManagment']->macrotabs->by_object['macro']->goFonMacroContent; - - if(strstr($content,"ARG")){ - $vorpos = strpos($content,"ARG"); - $rest = substr($content,$vorpos, strlen($content)); - } - - /* Do we represent a valid group? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This 'dn' is no phone macro.").""; - return ($display); - } - - /* Fill templating stuff */ - $smarty= get_smarty(); - - /* Add an empty Parameter */ - if(isset($_POST['addvar']) && preg_match("/w/",$ACLs)){ - if(!is_array($this->goFonMacroParameter)){ - $vars = $this->goFonMacroParameter; - $this->goFonMacroParameter = array(); - $this->goFonMacroParameter[]= $vars; - } - $number= count($this->goFonMacroParameter); - $number++; - $this->goFonMacroParameter[]=array("var"=>"var","name"=>"new","type"=>"string","default"=>"test"); - } - - /*generate Table which shows als parameters */ - $FonParas = $this->check_paras($content,$this->goFonMacroParameter); - - /* Sort by Parameterid, and keep keys */ - ksort($FonParas); - - - - if(!preg_match("/r/",$ACLs)){ - $smarty->assign("readable",false); - }else{ - $smarty->assign("readable",true); - foreach($FonParas as $key=>$para) { - - /* Select correct item of combobox */ - if(isset($para['type'])){ - list($sel1, $sel2, $sel3)= $this->type_shortcut[$para['type']]; - }else{ - list($sel1, $sel2, $sel3)= array("", "", ""); - } - - /* Disable all input fields if we are not allowed to change the parameters */ - $disabled = ""; - if(!preg_match("/w/",$ACLs)){ - $key = ""; - $disabled = " disabled "; - } - - /* Assemble output table */ - $vars .=" - - - ARG".$key." - - - - - - -  "; - if($para['check']==false) { - $vars.=""; - } - - $vars.=" "; - } - } - - /* Checkboxes */ - $smarty->assign("base_select", $this->base); - $smarty->assign("vars", $vars); - - /* Show main page */ - return($smarty->fetch (get_template_path('parameter.tpl', TRUE))); - } - - //! Unused here - /*! - Unused here because goFonMacro will remove this Macro\n - */ - function remove_from_parent() - { - } - - //! Save our data - /*! - Save POST data to object \n - This gives us the possibility to leave a tab, without losing our typed informations\n - \n - Read the POST fields for the parameters and saves their info the the class\n - */ - function save_object() - { - if (isset($_POST['phoneparameters'])){ - plugin::save_object(); - } - /* read out post data, and assign it to the parameters */ - /* And or delete */ - foreach($_POST as $name=>$value){ - - /* Test if there is a variable begining with "del" */ - if(preg_match("/del/",$name)){ - - /* Extract entry id to delete */ - $nr = str_replace("del","",$name) ; - - /* unset entry */ - unset($this->goFonMacroParameter[$nr]); - - }elseif(preg_match("/number/",$name)){ - - /* Set Post vars */ - $key = $_POST[$name]; - - $this->goFonMacroParameter[$key]['var'] = $_POST["var".$key]; - $this->goFonMacroParameter[$key]['name'] = $_POST["varname".$key]; - $this->goFonMacroParameter[$key]['type'] = $_POST["vartype".$key]; - $this->goFonMacroParameter[$key]['default']= $_POST["default".$key]; - } - } - - } - - - //! Checks given values - /*! - Check values\n - If a user enters an invalid value, then this function will output an error msg\n - (In better words :prepare the errormessages that will be put out )\n - */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - foreach($this->goFonMacroParameter as $key=>$val){ - if((strstr($val['default'],"!"))||(strstr($val['default'],"#"))) { - $message[] = sprintf(_("The parameter %s contains invalid char. '!,#' is used as delimiter"),$val['name']); - } - switch($val['type']){ - case 'bool' : $possible = array("","0","1"); - if(!in_array($val['default'],$possible)) { - $message[] = sprintf(_("The parameter %s has incorrect value for type bool."),$val['name']); - };break; - case 'string' : - case 'combo' : - default : ; - - } - } - return $message; - } - - //! Save changes to openldap - /*! - Save to LDAP - This function saves given attributes to the ldap - */ - function save() - { - /* Post checks */ - - plugin::save(); - - $this->attrs['goFonMacroParameter']=array(); - - foreach($this->goFonMacroParameter as $key=>$fonpara){ - $this->attrs['goFonMacroParameter'][]=$key."!".base64_encode($fonpara['name'])."!".$fonpara['type']."!".$fonpara['default']; - } - - if($this->para_count != count($this->attrs['goFonMacroParameter'])){ - print_red(_("Parameter count of the macro changed, you must update each user which are using this macro '%s'."),$this->dn); - } - - unset($this->attrs['base']); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('dn')); - $a= $ldap->fetch(); - - if (count($a)){ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - $this->handle_post_events("modify"); - } else { - if(count($this->attrs['goFonMacroParameter']==0)){ - unset($this->attrs['goFonMacroParameter']); - } - $ldap->cd($this->dn); - $ldap->create_missing_trees( $this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - $this->handle_post_events("add"); - } - show_ldap_error($ldap->get_error(), sprintf(_("Removing of goFonMacro/generic account with dn '%s' failed."),$this->dn)); - } - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - $source_o = new macroParameter($this->config,$source['dn']); - $this->goFonMacroParameter = $source_o-> goFonMacroParameter; - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/macro/generic.tpl b/plugins/gofon/macro/generic.tpl deleted file mode 100755 index 7bedc5219..000000000 --- a/plugins/gofon/macro/generic.tpl +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - -
{$must} -{render acl=$cnACL} - -{/render} -
{$must} -{render acl=$displayNameACL} - -{/render} -
-
{$must} - {render acl=$baseACL} - - {/render} - - {render acl=$baseACL disable_picture='images/folder_gray.png'} - - {/render} - -
-
-   - - - - - - - - - -
-{render acl=$descriptionACL} - -{/render} -
-{render acl=$goFonMacroVisibleACL} - {t}Visible for user{/t} -{/render} -
-
-

 

-
-{t}Macro text{/t} -
-{render acl=$goFonMacroContentACL} - -{/render} - - - - - diff --git a/plugins/gofon/macro/headpage.tpl b/plugins/gofon/macro/headpage.tpl deleted file mode 100755 index 79a6fa289..000000000 --- a/plugins/gofon/macro/headpage.tpl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - -
-
-

- {t}List of macros{/t} {$hint} -

-
-
- {$macroshead} -
-
-
- {$macros} - -
-
-
-

[i]{t}Information{/t}

-
-
-

- {t}This menu allows you to add, edit and remove selected macros. You may want to use the range selector on top of the macro listbox, when working with a large number of macros.{/t} -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - -
- {t}Display macros matching{/t} - - -
- {$apply} -
-
- - diff --git a/plugins/gofon/macro/main.inc b/plugins/gofon/macro/main.inc deleted file mode 100755 index f35e23b6f..000000000 --- a/plugins/gofon/macro/main.inc +++ /dev/null @@ -1,61 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - sess_del ('macroManagment'); - } -} else { - - /* Create macroManagment object on demand */ - if (!isset($_SESSION['macroManagment']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['macroManagment']= new goFonMacro ($config, $_SESSION['ui']); - } - - /* Get object */ - $macroManagment= $_SESSION['macroManagment']; - $macroManagment->save_object(); - $output= $macroManagment->execute(); - - /* Page header*/ - if (isset($_SESSION['objectinfo'])){ - $display= print_header( get_template_path('images/macros.png'), - _("Phone macro management"), - "\"\" - ".@LDAP::fix($_SESSION['objectinfo'])); - } else { - $display= print_header(get_template_path('images/macros.png'), _("Phone macro management")); - } - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - sess_del ('macroManagment'); - } - - /* Show and save dialog */ - $display.= $output; - $_SESSION['macroManagment']= $macroManagment; -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/macro/parameter.tpl b/plugins/gofon/macro/parameter.tpl deleted file mode 100755 index 48e99cd82..000000000 --- a/plugins/gofon/macro/parameter.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{if $readable} - - - - - - - - - {$vars} -
{t}Argument{/t} - {t}Name{/t} - {t}type{/t} - {t}Default value{/t} - -   -
-{else} -

{t}You are not allowed to view the macro parameter settings{/t}

-{/if} - - - - diff --git a/plugins/gofon/macro/paste_generic.tpl b/plugins/gofon/macro/paste_generic.tpl deleted file mode 100644 index 0f5acf467..000000000 --- a/plugins/gofon/macro/paste_generic.tpl +++ /dev/null @@ -1,9 +0,0 @@ - - - - - -
- {$must} - -
diff --git a/plugins/gofon/macro/remove.tpl b/plugins/gofon/macro/remove.tpl deleted file mode 100755 index 4dbd248c5..000000000 --- a/plugins/gofon/macro/remove.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$intro} - {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

-

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

- {if $multiple} - -   - - {else} - -   - - {/if} -

- diff --git a/plugins/gofon/macro/tabs_macros.inc b/plugins/gofon/macro/tabs_macros.inc deleted file mode 100755 index 5c5bcf6c9..000000000 --- a/plugins/gofon/macro/tabs_macros.inc +++ /dev/null @@ -1,40 +0,0 @@ -addSpecialTabs(); - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['macro']; - - /* Check for new 'dn', in order to propagate the - 'dn' to all plugins */ - $new_dn= "cn=".$baseobject->cn.",ou=macros,ou=asterisk,ou=configs,ou=systems,".$baseobject->base; - - /* Move group? */ - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - if ($this->dn != "new"){ - $baseobject->move($this->dn, $new_dn); - $this->by_object['macro']= $baseobject; - } - - /* Happen to use the new one */ - $this->dn= $new_dn; - } - - tabs::save(); - } - -} - -?> diff --git a/plugins/gofon/phoneaccount/class_phoneAccount.inc b/plugins/gofon/phoneaccount/class_phoneAccount.inc deleted file mode 100644 index 6871854ed..000000000 --- a/plugins/gofon/phoneaccount/class_phoneAccount.inc +++ /dev/null @@ -1,1512 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $CopyPasteVars = array("phoneNumbers","macroarray","macrostillavailable"/*"phoneNumbers" -Reset- */, - "hardware_list","used_hardware"); - - var $attributes = array("goFonDeliveryMode", "goFonFormat","cn","goFonHomeServer", - "goFonHardware","goFonPIN","goFonVoicemailPIN","telephoneNumber", "goFonMacro","macro"); - var $objectclasses= array("goFonAccount"); - - var $uid; - - var $view_logged = FALSE; - - function phoneAccount (&$config, $dn= NULL, $parent= NULL) - { - plugin::plugin ($config, $dn, $parent); - - /* Assemble phone numbers */ - if (isset($this->attrs['telephoneNumber'])){ - for ($i= 0; $i<$this->attrs['telephoneNumber']['count']; $i++){ - $number= $this->attrs['telephoneNumber'][$i]; - $this->phoneNumbers[$number]= $number; - } - } - - /* Set up has_mailAccount */ - if (isset($this->attrs['objectClass'])){ - if (in_array("gosaMailAccount", $this->attrs['objectClass'])){ - $this->has_mailAccount= TRUE; - } - } - - /* Set uid */ - if((isset($this->parent->by_object['user']->uid))&&(!empty($this->parent->by_object['user']->uid))){ - $this->uid = $this->parent->by_object['user']->uid; - } - if((isset($this->parent->by_object['user']->cn))&&(!empty($this->parent->by_object['user']->cn))){ - $this->cn = $this->parent->by_object['user']->cn; - } - - /* Check server configurations - * Load all server configuration in $this->goFonHomeServers if available - * and first server as default if necessary. - * Check if connection is successfull for the selected server $this->goFonHomeServer - */ - - - /* Set available server */ - if(isset($_SESSION['config']->data['SERVERS']['FON'])){ - $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON']; - } - - $a_SETUP= array(); - if($this->is_account && - array_key_exists('config',$_SESSION) && - array_key_exists('SERVERS',$_SESSION['config']->data) && - array_key_exists('FON',$_SESSION['config']->data['SERVERS']) && - is_callable("mysql_connect") - ) { - - /* Servers defined? Watch here... */ - if (count($this->goFonHomeServers)){ - - /* Set default server */ - if(empty($this->goFonHomeServer) || $this->goFonHomeServer == "0"){ - $this->goFonHomeServer= $this->goFonHomeServers[0]['DN']; - } - - /* Remember inital home server, to be able to remove old entries */ - $this->init_HomeServer = $this->goFonHomeServer; - - /* Get config */ - if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){ - print_red(sprintf(_("The specified goFonHomeServer '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry ignoring old accounts."),$this->goFonHomeServer, $this->goFonHomeServers[0]['DN'])); - - $this->goFonHomeServer = $this->goFonHomeServers[0]['DN']; - $this->init_HomeServer = $this->goFonHomeServers[0]['DN']; - } - $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer]; - - $r_con = @mysql_pconnect($cur_cfg['SERVER'],$cur_cfg['LOGIN'],$cur_cfg['PASSWORD']); - if(!$r_con){ -# print_red( sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), -# $cur_cfg['SERVER'],$cur_cfg['LOGIN'])); - new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error()); - } - $db = @mysql_select_db($cur_cfg['DB'],$r_con); - if(!$db){ -# print_red(sprintf(_("Can't select database %s on %s."),$cur_cfg['DB'],$cur_cfg['SERVER'])); - new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error()); - } - - $first = false; - foreach($this->phoneNumbers as $key => $val){ - if(!$first){ - $first = $key; - } - } - } - } - - /* Get available phone hardware - * Search for all available phone hardware - */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=goFonHardware)", array('cn', 'description')); - while ($attrs= $ldap->fetch()){ - $cn= $attrs['cn'][0]; - if (isset($attrs['description'])){ - $description= " - ".$attrs['description'][0]; - } else { - $description= ""; - } - $this->hardware_list[$cn]= "$cn$description"; - } - - - /* Get available Macros - * Search for all Marcos that are visible and create - * an array with name and parameters - */ - $ldap->search("(&(objectClass=goFonMacro)(goFonMacroVisible=1))", array("*")); - - /* Add none for no macro*/ - $this->macros['none']=_("no macro"); - $this->macro ="none"; - - /* Fetch all Macros*/ - while ($attrs= $ldap->fetch()){ - - /* unset Count, we don't need that here */ - unset($attrs['displayName']['count']); - - /* Parse macro data, unset count for parameterarrays */ - if (isset($attrs['goFonMacroParameter']['count'])){ - unset($attrs['goFonMacroParameter']['count']); - } - - /* fill Selectfield variable with Macros */ - if(isset($attrs['displayName'][0])){ - $this->macros[$attrs['dn']] = $attrs['displayName'][0]." (".$attrs['cn'][0].")"; - }else{ - $this->macros[$attrs['dn']] = _("undefined"); - } - - /* Go through available parameters and parse all attributes, like parametername, type, default ...*/ - if((isset($attrs['goFonMacroParameter']))&&(is_array($attrs['goFonMacroParameter']))){ - - foreach($attrs['goFonMacroParameter'] as $pkey=>$pval){ - /* Split Data in readable values, by delimiter ! */ - $data = split("!",$attrs['goFonMacroParameter'][$pkey]); - - /* Set all attrs */ - $id = $data[0]; - $this->macroarray[$attrs['dn']][$id]['var'] ="var".$id; - $this->macroarray[$attrs['dn']][$id]['choosen']=$data[3]; - $this->macroarray[$attrs['dn']][$id]['id'] =$id; - $this->macroarray[$attrs['dn']][$id]['name'] =$data[1]; - $this->macroarray[$attrs['dn']][$id]['type'] =$data[2]; - $this->macroarray[$attrs['dn']][$id]['default']=$data[3]; - if($data[2] == "bool"){ - $this->macroarray[$attrs['dn']][$id]['choosen']=$data[3]; - } - }//foreach - }//is_array - }//while - - - /* Parse used Macro - * If we have a macro selected, parse it and set values - * in $this->macroarray[$this->macro]. - */ - $tmp = split("!",$this->goFonMacro); - if(is_array($tmp)){ - - /* First value is the macroname */ - $this->macro = $tmp[0]; - - /* Macroname saved, delete that index */ - unset($tmp[0]); - - /* Check if makro has been removed */ - if(!isset($this->macros[$this->macro])){ - $this->macrostillavailable = false; - }else{ - $this->macrostillavailable = true; - } - - /* for each parametervalues ( parameterID#value like 25#twentyfive) */ - foreach($tmp as $var){ - - /* Split this, so we have $varar[0] = parameterID $varar[1] = SelectedValue */ - $varar = split("#",$var); - - /* Only insert if the parameter still exists */ - if(isset($this->macroarray[$this->macro][$varar[0]])){ - /* Assign value */ - $this->macroarray[$this->macro][$varar[0]]['choosen']=$varar[1]; - } - } - } - - - /* Colorize phones - * Used phones will be colored in grey, - * so we must detect which phones are currently in use. - */ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware')); - while($attrs = $ldap->fetch()){ - $cn = $attrs['goFonHardware'][0]; - if(isset($this->hardware_list[$cn])){ - $this->used_hardware[$cn]= $cn; - } - } - $this->hardware_list["automatic"]= _("automatic"); - ksort($this->hardware_list); - $this->a_old_telenums = $this->phoneNumbers; - - /* Get voicemail PIN from MySQL DB - * Because every user can change his PIN directly from the phone - * without any update to the ldap - * This means, the PIN in the DB is up to date - */ - // Connect to DB server - if((is_callable("mysql_pconnect"))&&(isset($cur_cfg))&&(isset($cur_cfg['SERVER']))&&(isset($cur_cfg['LOGIN']))&&(isset($cur_cfg['PASSWORD']))){ - $r_con = @mysql_pconnect($cur_cfg['SERVER'],$cur_cfg['LOGIN'],$cur_cfg['PASSWORD']); - if($r_con){ - $r_db = @mysql_select_db($cur_cfg['DB'],$r_con); - - $query_tmp = "SELECT ".$cur_cfg['VOICE_TABLE'].".password FROM ".$cur_cfg['VOICE_TABLE'].", ". - $cur_cfg['SIP_TABLE']." WHERE customer_id = sip_users.mailbox AND name='".$this->uid."'"; - - $vp = mysql_fetch_row(mysql_query($query_tmp)); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query_tmp, "Database query"); - if((isset($vp[0]))&&(!empty($vp[0]))){ - $this->goFonPINVoice = $vp[0]; - } - } - } - $this->lastmacro=$this->macro; - - if(is_callable("mysql_close")&&(isset($r_con))&&($r_con)){ - @mysql_close($r_con) ; - } - } - - - /* This function generates the Database entries. - * The Parameter 'save' could be true or false. - * false - means only testing no database transactions. - * true - write database entries. - * - * 'sip_users','voice_mail' and 'extensions' table entries will be created. - * - * If the phone hardware is 'automatic' the table entries will only be removed - * and not added. - */ - function generate_mysql_entension_entries($save = false) - { - /* Check if there is at least one server available - * If not, return and tell the user that saving failed - */ - if(!count($this->goFonHomeServers)){ - if($save){ - print_red(_("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); - } - return(true); - } - - /* Check if Mysql extension is available */ - if(!is_callable("mysql_pconnect")){ - if($save) - print_red(_("Can't save any changes to asterisk database, there is no mysql extension available.")); - return(true); - } - - /********************** - * Attribute Initialisation - **********************/ - - $old_connection = false; - - // Get Configuration for Mysql database Server - $s_parameter = ""; // Contains paramter for selected Macro - $r_con = false; // DB connection - $r_db = false; // Selected DB - $r_res = false; // Result resource - $a_ldap_attrs = array(); // - - $s_ip = NULL; // Contains ip for Sip entry - $s_host = NULL; // Contains host for Sip entry - $s_qualify = "yes"; // Qualify entry - $s_pin = NULL; // Entry for secret - $s_type = NULL; // Entry for phone type (friend , peer ..) - - $sip_data_array = array(); // Contains complete sip entry, to generate SQL syntax - $i_old_key = false; // Contains index for first old phonenumber, to delete old entries corectly - $i_new_key = false; // Contains index for first new phonenumber, to generate new entries corectly - - $s_sip_values = ""; // Contains string with all values for given attributes in SQL syntax - $s_sip_keys = ""; // Contains all needed attributes to generate sip entry in DB - - $s_sip_key = ""; // Key for SIP entry index - $s_sip_val = ""; // Value for SIP entry index - - $b_first_deleted= false; // Only delete first entry, - $s_telenums = ""; // for each value variable - - $i_is_accounted = false; // Ensure that extension entry, for name to number is only once in table - - restore_error_handler(); - - /* Prepare some basic attributes */ - foreach($this->a_old_telenums as $tele){ - $oldnums[]= preg_replace("/[^0-9]/","",$tele); - } - foreach($this->phoneNumbers as $tele){ - $newnums[]= preg_replace("/[^0-9]/","",$tele); - } - - /* If deletion starts from userslist, cn uid are not set */ - if((isset($this->parent->by_object['user']->uid))&&(!empty($this->parent->by_object['user']->uid))){ - $this->uid = $this->parent->by_object['user']->uid; - } - if((isset($this->parent->by_object['user']->cn))&&(!empty($this->parent->by_object['user']->cn))){ - $this->cn = $this->parent->by_object['user']->cn; - } - /* Create voicemail entry - */ - if((!isset($this->cn))||(empty($this->cn))){ - $CNname= $this->uid; - }else{ - $CNname= $this->cn; - } - - if((isset($this->parent))&&(isset($this->parent->by_object['mailAccount']))&&($this->parent->by_object['mailAccount']->is_account==true)){ - $s_mail = $this->parent->by_object['mailAccount']->mail; - }else{ - $s_mail = ""; - } - /* Get phonehardware to setup sip entry */ - $ldap = $this->config->get_ldap_link(); - $r_res = $ldap->search("(&(objectClass=goFonHardware)(cn=".$this->goFonHardware."))", array('*')); - $a_ldap_attrs = $ldap->fetch(); - - /* Check selected phone hardware, is a default IP set? */ - if(((isset($a_ldap_attrs['goFonDefaultIP'][0]))&&($a_ldap_attrs['goFonDefaultIP'][0] != "dynamic"))){ - $s_ip = $a_ldap_attrs['goFonDefaultIP'][0]; - $s_host = $s_ip; - }else{ - $s_ip = NULL; - $s_host = "dynamic"; - } - - // Attribute GoFonQualify set ? - if(isset($a_ldap_attrs['goFonQualify'])){ - $s_qualify = $a_ldap_attrs['goFonQualify'][0]; - } - - // Attribute GoFonPIN set ? - if(isset($this->goFonPIN)){ - $s_pin = $this->goFonPIN; - } - - // Attribute GoFonType set ? - if(isset($a_ldap_attrs['goFonType'])){ - $s_type = $a_ldap_attrs['goFonType'][0]; - } - - if(isset($a_ldap_attrs['goFonDmtfMode'][0])){ - $sip_data_array['dtmfmode'] = $a_ldap_attrs['goFonDmtfMode'][0]; - }else{ - $sip_data_array['dtmfmode'] ="rfc2833"; - } - - /* Check if phone number is used */ - if($this->is_number_used()){ - $this->generate_error = $this->is_number_used(); - return false; - } - - - - /********************** - * Check Server Connection Information - **********************/ - - /* Create Mysql handle for the current goFonHomeServer, if possible - * Get configuration to old asterisk home server - */ - $a_New = $this->goFonHomeServers[$this->goFonHomeServer]; // DB Configuration - $new_connection = @mysql_pconnect($a_New['SERVER'],$a_New['LOGIN'],$a_New['PASSWORD']); - if(!$new_connection){ - $this->generate_error = sprintf( - _("The MySQL Server '%s' isn't reachable as user '%s'. Abort saving entries to keep the database consistent, check GOsa log for mysql error."), - $a_New['SERVER'],$a_New['LOGIN']); - new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error($new_connection)); - return false; - } - $new_database = @mysql_select_db($a_New['DB'],$new_connection); - if(!$new_database){ - $this->generate_error = sprintf( - _("Can't select database %s on %s. Abort saving entries to keep the database consistent, check GOsa log for mysql error."), - $a_New['DB'],$a_New['SERVER']); - new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error($new_connection)); - return false; - } - - /* If the home server has changed, we must remove entries from old - * server and add new entries in new server. - */ - if($this->init_HomeServer != $this->goFonHomeServer){ - - /* Get configuration to old asterisk home server */ - $a_Remove = $this->goFonHomeServers[$this->init_HomeServer]; // DB Configuration - - /* Create connection to the database that contains the old entry. - */ - $old_connection = @mysql_pconnect($a_Remove['SERVER'],$a_Remove['LOGIN'],$a_Remove['PASSWORD']); - if(!$old_connection){ - $this->generate_error = sprintf( - _("The old MySQL home server '%s' isn't reachable as user '%s'. Abort saving entries to keep the database consistent, check GOsa log for mysql error."), - $a_Remove['SERVER'],$a_Remove['LOGIN']); - new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error($old_connection)); - return false; - } - $old_database = @mysql_select_db($a_Remove['DB'],$old_connection); - if(!$old_database){ - $this->generate_error = sprintf( - _("Can't select database %s on %s. Abort saving entries to keep the database consistent, check GOsa log for mysql error."), - $a_Remove['DB'],$a_Remove['SERVER']); - new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error($old_connection)); - return false; - } - } - - /* Save means that we must save changes, not only test */ - if($save == true){ - - /********************** - * Remove entries from old home server - **********************/ - - /* Check if there is an old entry - * If there is an old entry, get callerid and remove voicemail and extensions - */ - if($old_connection){ - $query = "SELECT id,name,callerid FROM ".$a_Remove['SIP_TABLE']." WHERE name='".$this->uid."';"; - $rid = mysql_query($query,$old_connection); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - - /* Old entry found, remove it */ - $query_a = array(); - if(mysql_affected_rows($old_connection)){ - $result = mysql_fetch_assoc($rid); - $query_a[]= "DELETE FROM ".$a_Remove['SIP_TABLE']." WHERE name='".$this->uid."';"; - $query_a[]= "DELETE FROM ".$a_Remove['VOICE_TABLE']." WHERE customer_id='".$result['callerid']."';"; - $query_a[]= "DELETE FROM ".$a_Remove['EXT_TABLE']." WHERE exten='".$this->uid."';"; - foreach($oldnums as $s_telenums) { - $query_a[]= "DELETE FROM ".$a_Remove['EXT_TABLE']." WHERE exten='".$s_telenums."';"; - } - - foreach($query_a as $qry){ - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$qry, "Database query"); - if(!mysql_query($qry,$old_connection)){ - echo mysql_error($old_connection); - } - } - } - } - - /********************** - * Update / Insert sip_users entry - **********************/ - - /* Set the first given phone number as callerid */ - reset($newnums); - $i_new_key = key($newnums); - $sip_data_array['callerid'] =$newnums[$i_new_key]; - $sip_data_array['mailbox'] =$newnums[$i_new_key]; - - /* Check if there is already an entry in sip_users for this uid */ - $SQL_query_array = array(); - $query = "SELECT * FROM ".$a_New['SIP_TABLE']." WHERE name='".$this->uid."';\n"; - $rid = mysql_query($query,$new_connection); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - if(mysql_affected_rows($new_connection)){ - - /********************** - * Update sip_users entry - **********************/ - $result = mysql_fetch_assoc($rid); - $sip_data_array['host'] = $s_host; - $sip_data_array['qualify'] = $s_qualify; - $sip_data_array['secret'] = $this->goFonPIN; - $sip_data_array['type'] = $s_type ; - $sip_data_array['username'] = $this->uid; - $sip_data_array['ipaddr'] = $s_ip; - - /* Remove not changed attributes, to avoid updating table with same values */ - foreach($sip_data_array as $name => $value){ - if($result[$name] == $value){ - unset($sip_data_array[$name]); - } - } - /* Only update entry if there is something to uopdate */ - if(count($sip_data_array)){ - $query = "UPDATE ".$a_New['SIP_TABLE']." SET "; - foreach($sip_data_array as $key => $val){ - $query.= "".$key."='".$val."',"; - } - $query = preg_replace("/,$/","",$query); - $query.= " WHERE name='".$this->uid."';"; - $SQL_query_array[] = $query; - } - } else { - - /********************** - * Insert sip_users entry - **********************/ - //generate SIP entry - $sip_data_array['id'] = ""; - $sip_data_array['name'] = $this->uid; - $sip_data_array['accountcode'] = NULL; - $sip_data_array['amaflags'] = NULL; - $sip_data_array['callgroup'] = NULL; - $sip_data_array['canreinvite'] = "no"; - $sip_data_array['context'] = "default"; - $sip_data_array['defaultip'] = NULL; - $sip_data_array['fromuser'] = NULL; - $sip_data_array['fromdomain'] = NULL; - $sip_data_array['host'] = $s_host; - $sip_data_array['insecure'] = NULL; - $sip_data_array['language'] = NULL; - $sip_data_array['mailbox'] = $newnums[$i_new_key]; - $sip_data_array['md5secret'] = NULL; - $sip_data_array['nat'] = "no"; - $sip_data_array['permit'] = NULL; - $sip_data_array['deny'] = NULL; - $sip_data_array['mask'] = NULL; - $sip_data_array['pickupgroup'] = NULL; - $sip_data_array['port'] = NULL; - $sip_data_array['qualify'] = $s_qualify; - $sip_data_array['restrictcid'] = "n"; - $sip_data_array['rtptimeout'] = NULL; - $sip_data_array['rtpholdtimeout']=NULL; - $sip_data_array['secret'] = $this->goFonPIN; - $sip_data_array['type'] = $s_type ; - $sip_data_array['username'] = $this->uid; - $sip_data_array['disallow'] = NULL; - $sip_data_array['allow'] = NULL; - $sip_data_array['musiconhold'] = NULL; - $sip_data_array['regseconds'] = NULL; - $sip_data_array['ipaddr'] = $s_ip; - $sip_data_array['regexten'] = NULL; - $sip_data_array['cancallforward']=NULL; - - /* There is currently no entry for this user in the sip_users table. - * We should create one i - */ - foreach($sip_data_array as $s_sip_key=>$s_sip_val){ - if($s_sip_val === NULL) continue; - $s_sip_values.="'".$s_sip_val."',"; - $s_sip_keys .="`".$s_sip_key."`,"; - } - $s_sip_values = preg_replace("/,$/","",$s_sip_values); - $s_sip_keys = preg_replace("/,$/","",$s_sip_keys); - - /* Add sip entries to mysql queries */ - $SQL_query_array[] ="INSERT INTO ".$a_New['SIP_TABLE']." (".$s_sip_keys.") VALUES (".$s_sip_values.");"; - } - - - /********************** - * Update / Insert Voice mail entry - **********************/ - - $customer_id = $newnums[$i_new_key]; - - $voice_data_array = array( - "customer_id" => $customer_id, - "mailbox" => $customer_id, - "password" => $this->goFonVoicemailPIN, - "fullname" => $CNname, - "email" => $s_mail); - - /* Set pager number if available */ - if(isset($this->parent->by_object['user']->pager)){ - $voice_data_array['pager'] = $this->parent->by_object['user']->pager; - } - - /* Check if there is already an entry in sip_users for this uid */ - $query_tmp = "SELECT * FROM ".$a_New['VOICE_TABLE']." WHERE customer_id='".$customer_id."';\n"; - $rid = mysql_query($query_tmp,$new_connection); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query_tmp, "Database query"); - if(mysql_affected_rows($new_connection)){ - - /********************** - * Update Voice mail entry - **********************/ - $result = mysql_fetch_assoc($rid) ; - - foreach($voice_data_array as $name => $value){ - if($result[$name] == $value){ - unset($voice_data_array[$name]); - } - } - - /* Only update entry if there is something to uopdate */ - if(count($voice_data_array)){ - $query = "UPDATE ".$a_New['VOICE_TABLE']." SET "; - foreach($voice_data_array as $key => $val){ - $query.= "".$key."='".$val."',"; - } - $query = preg_replace("/,$/","",$query); - $query.= " WHERE customer_id='".$customer_id."';"; - $SQL_query_array[] = $query; - } - }else{ - - /********************** - * Insert Voice mail entry - **********************/ - $voice_data_array['context'] = "default"; - - /* There is currently no voice mail entry for this user. - * We should create one - */ - $s_voi_values = $s_voi_keys = ""; - foreach($voice_data_array as $s_voi_key=>$s_voi_val){ - if($s_voi_val === NULL) continue; - $s_voi_values.="'".$s_voi_val."',"; - $s_voi_keys .="`".$s_voi_key."`,"; - } - $s_voi_values = preg_replace("/,$/","",$s_voi_values); - $s_voi_keys = preg_replace("/,$/","",$s_voi_keys); - - /* Add sip entries to mysql queries */ - $SQL_query_array[] ="INSERT INTO ".$a_New['VOICE_TABLE']." (".$s_voi_keys.") VALUES (".$s_voi_values.");"; - } - - - /********************** - * Remove/Insert extension entries - **********************/ - - /* Remove old entries */ - $query = array(); - $query[]= "DELETE FROM ".$a_New['EXT_TABLE']." WHERE exten=\"".$this->uid."\";"; - foreach($oldnums as $s_telenums){ - $query[]= "DELETE FROM ".$a_New['EXT_TABLE']." WHERE exten=\"".$s_telenums."\";"; - } - foreach($newnums as $s_telenums){ - $query[]= "DELETE FROM ".$a_New['EXT_TABLE']." WHERE exten=\"".$s_telenums."\";"; - } - foreach($query as $qry){ - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$qry, "Database query"); - if(!mysql_query($qry,$new_connection)){ - echo mysql_error($new_connection); - } - } - - /********************** - * Insert extension entries - **********************/ - - // Get selected Macro Parameter and create parameter entry - if(isset($this->macroarray[$this->macro])){ - foreach($this->macroarray[$this->macro] as $key => $val ){ - $s_parameter .= $val['choosen']."|"; - } - $s_parameter = preg_replace("/\|$/","",$s_parameter); - } - - $i = 0; - $EXT = array(); - if(!is_numeric($this->uid)){ - $EXT[$i]['context'] = 'GOsa'; - $EXT[$i]['exten'] = $this->uid; - $EXT[$i]['priority']= 1; - $EXT[$i]['app'] = "Goto"; - $EXT[$i]['appdata'] = $newnums[$i_new_key]."|1"; - $i ++; - } - - // Entension entries Hint / Dial / Goto - foreach($newnums as $s_telenums){ - - /* Hint Entry */ - $EXT[$i]['context'] = 'GOsa'; - $EXT[$i]['exten'] = $s_telenums; - $EXT[$i]['priority']= "Hint"; - $EXT[$i]['app'] = 'SIP/'.$this->uid; - $i ++; - /* SetCID */ - //$EXT[$i]['context'] = 'GOsa'; - //$EXT[$i]['exten'] = $s_telenums; - //$EXT[$i]['priority']= 1; - //$EXT[$i]['app'] = "SetCIDName"; - //$EXT[$i]['appdata'] = $CNname; - //$i ++; - - // If no macro is selected use Dial - if($this->macro!="none"){ - $macroname = preg_replace("/,.*$/","",$this->macro); - $macroname = preg_replace("/^.*=/","",$macroname); - $s_app = "Macro";$macroname; - $s_par = $macroname."|".$s_parameter; - }else{ - $s_app = "Dial"; - $s_par = 'SIP/'.$this->uid."|20|r"; - } - - $EXT[$i]['context'] = 'GOsa'; - $EXT[$i]['exten'] = $s_telenums; - $EXT[$i]['priority']= 1; - $EXT[$i]['app'] = $s_app; - $EXT[$i]['appdata'] = $s_par; - $i ++; - } - - // Append all these Entries - foreach($EXT as $entr){ - $SQL_syn = "INSERT INTO ".$a_New['EXT_TABLE']." ("; - foreach($entr as $key2 => $val2){ - $SQL_syn.= "`".$key2."`,"; - } - $SQL_syn = preg_replace("/,$/","",$SQL_syn); - $SQL_syn .= ") VALUES ("; - foreach($entr as $key2 => $val2){ - $SQL_syn .= "'".$val2."',"; - } - $SQL_syn = preg_replace("/,$/","",$SQL_syn); - $SQL_syn .=");\n"; - - $SQL_query_array[] =$SQL_syn; - $SQL_syn =""; - } - - // Perform queries ... - if($this->goFonHardware != "automatic"){ - foreach($SQL_query_array as $query){ - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - if(!@mysql_query($query,$new_connection)){ - print_red(_("Error while performing query:")." ".mysql_error()); - return false; - } - } - } - } - @mysql_close($new_connection); - return true; - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - $display = ""; - $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - if(empty($this->macro)&&(!empty($this->goFonMacro))){ - - /* Go through already saved values, for a parameter */ - $tmp = split("!",$this->goFonMacro); - - /* it is possible that nothing has been saved yet */ - if(is_array($tmp)){ - - /* First value is the macroname */ - $this->macro = $tmp[0]; - - /* Macroname saved, delete that index */ - unset($tmp[0]); - - /* Check if macro has been removed */ - if(!isset($this->macroarray[$this->macro])){ - $this->macrostillavailable = false; - }else{ - $this->macrostillavailable = true; - } - - /* for each parametervalues ( parameterID#value like 25#twentyfive) */ - foreach($tmp as $var){ - - /* Split this, so we have $varar[0] = parameterID $varar[1] = SelectedValue */ - $varar = split("#",$var); - - /* Only insert if the parameter still exists */ - if(isset($this->macroarray[$this->macro][$varar[0]])){ - /* Assign value */ - $this->macroarray[$this->macro][$varar[0]]['choosen']=$varar[1]; - } - } - } - } - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This account has no phone extensions.").""; - $display.= back_to_main(); - return ($display); - } - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Select no macro if, state is empty, this is the case, if the selected macro is no longer available */ - if(empty($this->macro)){ - $this->macro ="none"; - } - - /* Prepare templating */ - $smarty= get_smarty(); - - /* tell user that the selected plugin is no longer available */ - if((!$this->macrostillavailable)&&($this->macro!="none")){ - print_red(_("The macro you selected, is no longer available for you, please choose another one.")); - } - - /* Assing macroselectbox values */ - $smarty->assign("macros",$this->macros); - $smarty->assign("macro", $this->macro); - - /* check if there is a FON server created */ - if(!count($this->goFonHomeServer)){ - print_red(_("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database.")); - } - - /* Create html parameter table for selected macro parameters - * skip if no parameters given - */ - if(!isset($this->macroarray[$this->macro])){ - $macrotab=""; - }else{ - - $macrotab =""; - /* for every single parameter-> display textfile,combo, or true false switch*/ - - foreach($this->phoneNumbers as $phonenum){ - $tmp[] = $phonenum; - } - - if($this->macro != $this->lastmacro){ - /* Go through all params */ - foreach($this->macroarray[$this->macro] as $key => $paras){ - - $string = $paras['default']; - - $string=preg_replace("/%uid/i",$this->uid,$string); - - if(isset($this->cn)){ - $string=preg_replace("/%cn/i",$this->cn,$string); - } - - for($i = 0 ; $i < 10; $i++){ - if(isset($tmp[$i])){ - $string = preg_replace("/%telephoneNumber_".($i+1)."/i",$tmp[$i],$string); - } - } - if(isset($tmp[0])){ - $string = preg_replace("/%telephoneNumber/i",$tmp[0],$string); - } - $this->macroarray[$this->macro][$key]['choosen']=$string; - } - } - - foreach($this->macroarray[$this->macro] as $paras){ - - /* get al vars */ - $var = $paras['var']; - $name = $paras['name']; - $default = $paras['default']; - $type = $paras['type']; - $choosen = $paras['choosen'] ; - $str = $default; - - $dis = ""; - if(!$this->acl_is_writeable("goFonMacro",$SkipWrite)){ - $dis = " disabled "; - } - - /* in case of a combo box display a combobox with selected attr */ - $macrotab.= ""; - switch ($type){ - - case "combo": - $str= ""; - $macrotab.= ""; - - } - $macrotab.="
".base64_decode($name)."$str"; - break; - - case "bool": - if(!$choosen){ - $str="\n"; - }else{ - $str="\n"; - } - $macrotab.= "$str ".base64_decode($name).""; - break; - - case "string": - $str=""; - $macrotab.= "".base64_decode($name)."$str"; - break; - - } - $macrotab.= "
"; - }//is_array() - - /* Give smarty the table */ - $smarty->assign("macrotab",$macrotab); - - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This account has no phone extensions.").""; - $display.= back_to_main(); - return($display); - } - - $display= ""; - /* Show tab dialog headers */ - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove phone account"), - _("This account has phone features enabled. You can disable them by clicking below.")); - } else { - if(empty($this->uid)){ - $display= $this->show_enable_header(_("Create phone account"), - _("This account has phone features disabled. You can't enable them while no uid is set."),TRUE,TRUE); - }else{ - $display= $this->show_enable_header(_("Create phone account"), - _("This account has phone features disabled. You can enable them by clicking below.")); - } - return ($display); - } - } - - /* Add phone number */ - if (isset($_POST["add_phonenumber"]) && $_POST['phonenumber']){ - if (is_phone_nr($_POST['phonenumber'])){ - $number= $_POST["phonenumber"]; - $this->phoneNumbers[$number]= $number; - $this->is_modified= TRUE; - } else { - print_red(_("Please enter a valid phone number!")); - } - } - - /* Remove phone number */ - if (isset($_POST["delete_phonenumber"]) && isset($_POST["phonenumber_list"])){ - foreach ($_POST['phonenumber_list'] as $number){ - unset($this->phoneNumbers[$number]); - $this->is_modified= TRUE; - } - } - - /* Assign acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Transfer ACL's */ - foreach($this->attributes as $val){ - if(isset($this->$val)){ - $smarty->assign($val,$this->$val); - }else{ - $smarty->assign($val,""); - } - } - - /* Create home server array */ - $tmp = array(); - foreach($this->goFonHomeServers as $dn => $attrs){ - if(!is_numeric($dn)){ - $tmp[$dn] = $attrs['SERVER']; - } - } - $smarty->assign("goFonHomeServers",$tmp); - - /* Fill arrays */ - $smarty->assign ("goFonHardware", $this->goFonHardware); - if (!count($this->phoneNumbers)){ - $smarty->assign ("phoneNumbers", array()); - } else { - $smarty->assign ("phoneNumbers", $this->phoneNumbers); - } - - $dis = ""; - if(!$this->acl_is_writeable("goFonHardware",$SkipWrite)){ - $dis= " disabled "; - } - $hl= "\n"; - $smarty->assign ("hardware_list", $hl); - - /* Show main page */ - $this->lastmacro = $this->macro; - $display.= $smarty->fetch(get_template_path('generic.tpl', TRUE, dirname(__FILE__))); - return($display); - } - - - function save_object() - { - $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - if (isset($_POST["phoneTab"])){ - - plugin::save_object(); - - /* Save checkbox */ - $tmp = preg_replace("/[^a-z]/i","",$this->goFonDeliveryMode); - if($this->acl_is_writeable("goFonDeliveryMode",$SkipWrite)){ - if(isset($_POST['fon_to_mail']) && !preg_match("/M/",$this->goFonDeliveryMode)){ - $tmp .= "M"; - }elseif(!isset($_POST['fon_to_mail']) && preg_match("/M/",$this->goFonDeliveryMode)){ - $tmp = preg_replace ("/M/","",$tmp); - } - } - $this->goFonDeliveryMode= "[".$tmp."]"; - - - /* Every macro in the select box are available */ - if((isset($_POST['macro']))){ - $this->macrostillavailable=true; - } - - if(isset($_POST['macro']) && $_POST['macro'] != $this->macro){ - $this->is_modified =true; - } - - if(is_array($this->phoneNumbers)){ - foreach($this->phoneNumbers as $telenumms) { - $nummsinorder[]=$telenumms; - } - }else{ - $nummsinorder=array(""); - } - - - /* get all Postvars */ - if(isset($this->macroarray[$this->macro])){ - - if($this->acl_is_writeable("goFonMarco",$SkipWrite)){ - foreach($this->macroarray[$this->macro] as $key => $paras){ - - $backup = $this->macroarray[$this->macro][$key]; - - if(isset($_POST[$paras['var']])){ - $this->macroarray[$this->macro][$key]['choosen'] = $_POST[$paras['var']]; - } - - /* Checkboxes are special, they are not Posted if they are not selected, so the won't be changed with the above code - We need this code below to read and save checkboxes correct - */ - - if(isset($_POST['post_success'])){ - if($this->macroarray[$this->macro][$key]['type']=="bool"){ - if(isset($_POST[$this->macroarray[$this->macro][$key]['var']])) { - $this->macroarray[$this->macro][$key]['choosen']=$_POST[$paras['var']]; - }else{ - $this->macroarray[$this->macro][$key]['choosen']=false; - } - } - } - } - if(count(array_diff($this->macroarray[$this->macro][$key],$backup))){ - $this->modified = TRUE; - } - } - } - } - } - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(!count($this->goFonHomeServers)){ - $message[] = _("There must be at least one server with an asterisk database to create a phone account."); - } - - if(empty($this->goFonHomeServer)){ - $message[] = _("Please select a valid goFonHomeServer."); - } - - if((strlen($this->goFonVoicemailPIN)==0)||(strlen($this->goFonVoicemailPIN)>4)){ - $message[]=(_("Voicemail PIN must be between 1-4 characters.")); - }else{ - if(preg_match("/[^0-9]/",$this->goFonVoicemailPIN)){ - $message[]=(_("The specified Voicemail PIN contains invalid characters, only numeric values are allowed here.")); - } - } - - if(preg_match("/[^0-9a-z]/i",$this->goFonPIN)){ - $message[]=(_("The specified phone PIN contains invalid characters, only aphanumeric values are allowed here.")); - } - - if ($this->initially_was_account != $this->is_account || $this->is_modified){ - if(!$this->generate_mysql_entension_entries()){ - $message[] = $this->generate_error; - } - } - - /* We need at least one phone number */ - if (count($this->phoneNumbers) == 0){ - $message[]= sprintf(_("You need to specify at least one phone number!")); - } - - /* check for ! in any parameter setting*/ - if(isset($this->macroarray[$this->macro])){ - foreach($this->macroarray[$this->macro] as $val){ - if((strstr($val['choosen'],"!"))||(strstr($val['choosen'],"#"))){ - $message[] = sprintf(_("The parameter %s contains invalid char. '!,#' is used as delimiter"),$val['name']); - } - } - } - return ($message); - } - - - - function save() - { - plugin::save(); - - /* Force saving macro again - * This ensures that - * - the macro is available on the destiantion server. - * - the macro saved is up to date on the destination server. - */ - if(!empty($this->macro) && $this->macro != "none") { - $macro_tab= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->macro,"gofonmacro"); - $macro_tab -> save(); - } - - /* Save arrays */ - $tmp_numbers = array(); - foreach ($this->phoneNumbers as $number){ - $tmp_numbers[] = $number; - } - - /* Save settings, or remove goFonMacro attribute*/ - if($this->macro!="none"){ - $this->attrs['goFonMacro']=$this->macro; - if(isset($this->macroarray[$this->macro])){ - foreach($this->macroarray[$this->macro] as $paras) { - $this->attrs['goFonMacro'].="!".$paras['id']."#".$paras['choosen']; - } - } - }else{ - $this->attrs['goFonMacro']=array(); - } - unset($this->attrs['macro']) ; - - $this->attrs['goFonForwarding']=array(); - - if ($this->initially_was_account != $this->is_account || $this->is_modified){ - $str = $this->generate_mysql_entension_entries(true); - if(empty($str)){ - print_red($str); - } - } - - if($this->attrs['goFonMacro']==""){ - $this->attrs['goFonMacro']=array(); - } - - unset($this->attrs['cn']); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - - /* Force saving numbers, else it will be overwriten by user account. */ - $this->attrs['telephoneNumber'] =$tmp_numbers; - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/phone account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - - } - - - function adapt_from_template($dn) - { - plugin::adapt_from_template($dn); - - /* Assemble phone numbers */ - if (isset($this->attrs['telephoneNumber'])){ - for ($i= 0; $i<$this->attrs['telephoneNumber']['count']; $i++){ - $number= $this->attrs['telephoneNumber'][$i]; - $this->phoneNumbers[$number]= $number; - } - } - } - - - function remove_from_parent() - { - if(!$this->initially_was_account) return; - - foreach($this->attributes as $key=>$val){ - if(in_array($val,array("uid","cn"))){ - unset($this->attributes[$key]); - unset($this->$val); - } - } - if(count($this->goFonHomeServers) && !empty($this->init_HomeServer) && is_callable("mysql_pconnect")){ - - // Get Configuration for initial Mysql database Server - $a_SETUP = $this->goFonHomeServers[$this->init_HomeServer]; - $s_parameter =""; - - // Connect to DB server - $r_con = @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); - - // Check if we are connected correctly - if(!$r_con){ - print_red(sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), - $a_SETUP['SERVER'],$a_SETUP['LOGIN'])); - new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error()); - return false; - } - - // Select database for Extensions - $db = @mysql_select_db($a_SETUP['DB'],$r_con); - - // Test if we have the database selected correctly - if(!$db){ - print_red(sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER'])); - new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error()); - return false; - } - - $SQL=""; - - /* If deletion starts from userslist, cn uid are not set */ - if((isset($this->parent->by_object['user']->uid))&&(!empty($this->parent->by_object['user']->uid))){ - $this->uid = $this->parent->by_object['user']->uid; - } - - if((isset($this->parent->by_object['user']->cn))&&(!empty($this->parent->by_object['user']->cn))){ - $this->cn = $this->parent->by_object['user']->cn; - } - - $first_num = false; - // Delete old entries - foreach($this->a_old_telenums as $s_telenums){ - if(!$first_num){ - $first_num = $s_telenums; - } - $SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$s_telenums."';\n"; - } - - $SQL[] = "DELETE FROM ".$a_SETUP['VOICE_TABLE']." WHERE customer_id='".$first_num."';"; - $SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$this->uid."';\n"; - $SQL[] = "DELETE FROM ".$a_SETUP['SIP_TABLE']." WHERE name='".$this->uid."';\n"; - - foreach($SQL as $query){ - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); - if(!@mysql_query($query,$r_con)){ - print_red(_("Stop".mysql_error())); - return false; - } - } - }else{ - print_red(_("Can't remove phone account, the mysql extension is not present in php configuration.")); - return false; - } - - /* unset macro attr, it will cause an error */ - $tmp = array_flip($this->attributes); - unset($tmp['macro']); - $this->attributes=array_flip($tmp); - - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - plugin::remove_from_parent(); - - /* Just keep one phone number */ - if (count($this->telephoneNumber) && $this->telephoneNumber != ""){ - $this->attrs['telephoneNumber']= $this->telephoneNumber; - } else { - $this->attrs['telephoneNumber']= array(); - } - - - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=goFonQueue)(member=*))", array("member")); - while($attr = $ldap->fetch()){ - if(in_array($this->dn,$attr['member'])){ - $new =new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'],$attr['dn']); - unset($new->by_object['ogroup']->memberList[$this->dn]); - unset($new->by_object['ogroup']->member[$this->dn]); - $new->save(); - print_red(sprintf(_("Removed user '%s' from phone queue '%s'."),$this->uid,$new->by_object['ogroup']->cn)); - } - } - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/phone account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - @mysql_close($r_con); - $this->handle_post_events('remove',array("uid"=> $this->uid)); - } - - - - /* This function checks if the given phonenumbers are available or already in use*/ - function is_number_used() - { - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid")); - while($attrs = $ldap->fetch()) { - unset($attrs['telephoneNumber']['count']); - foreach($attrs['telephoneNumber'] as $tele){ - if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn']; - if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn']; - $numbers[$tele]=$attrs; - } - } - - foreach($this->phoneNumbers as $num){ - if(!isset($this->cn)) $this->cn = ""; - - if((isset($numbers[$num]))&&(($numbers[$num]['uid'][0]!=$this->uid))){ - if(isset($numbers[$num]['uid'][0])){ - return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]); - }else{ - return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]); - } - } - } - } - - - /* Create phoneAccount part of copy & paste dialog */ - function getCopyDialog() - { - if(!$this->is_account) return(""); - $smarty = get_smarty(); - if (!count($this->phoneNumbers)){ - $smarty->assign ("phoneNumbers", array("")); - } else { - $smarty->assign ("phoneNumbers", $this->phoneNumbers); - } - - $smarty->assign("goFonVoicemailPIN",$this->goFonVoicemailPIN); - $smarty->assign("goFonPIN",$this->goFonPIN); - - $display= $smarty->fetch(get_template_path('paste_generic.tpl', TRUE, dirname(__FILE__))); - $ret =array(); - $ret['string'] = $display; - $ret['status'] = ""; - return($ret); - } - - /* Save posts from copy & paste dialog dialog */ - function saveCopyDialog() - { - if(!$this->is_account) return; - $this->execute(); - if(isset($_POST['goFonVoicemailPIN'])) { - $this->goFonVoicemailPIN = $_POST['goFonVoicemailPIN']; - } - if(isset($_POST['goFonPIN'])){ - $this->goFonPIN = $_POST['goFonPIN']; - } - } - - - function allow_remove() - { - /* Check if previously selected server is still available */ - if($this->initially_was_account && !isset($this->goFonHomeServers[$this->goFonHomeServer])){ - return sprintf(_("The previously selected asterisk home server (%s) is no longer available. Remove aborted."),preg_replace("/,/",", ",$this->goFonHomeServer)); - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Phone"), - "plDescription" => _("Phone account settings"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 7, // Position in tabs - "plSection" => "personal", // This belongs to personal - "plCategory" => array("gofonreport" => array("description" => _("GOfon reports"), - "objectClass" => "")), - - "plOptions" => array(), - - "plProvidedAcls" => array( - "telephoneNumber" => _("Telephone number"), - "goFonHomeServer" => _("Home server"), - "goFonMacro" => _("Macro settings"), - "goFonHardware" => _("Phone hardware"), - "goFonPIN" => _("Telephone pin"), - "goFonVoicemailPIN" => _("Voicemail pin")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/gofon/phoneaccount/generic.tpl b/plugins/gofon/phoneaccount/generic.tpl deleted file mode 100644 index f034afeb7..000000000 --- a/plugins/gofon/phoneaccount/generic.tpl +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - -
-

- -  {t}Phone numbers{/t} -

-{render acl=$telephoneNumberACL} - -{/render} -
-{render acl=$telephoneNumberACL} - -{/render} -{render acl=$telephoneNumberACL} -   -{/render} -{render acl=$telephoneNumberACL} - -{/render} -
- - - - - -
-

 {t}Telephone hardware{/t}

- - - - - - - - - - - - - - - - - - -
{t}Telephone{/t}{$hardware_list}
{t}Home server{/t}{$must} - -{render acl=$goFonHomeServerACL} - -{/render} -
- - -{render acl=$goFonVoicemailPINACL} - -{/render} -
- - -{render acl=$goFonPINACL} - -{/render} -
-
-
 
-

- -  {t}Phone macro{/t} -

- - - - -
-{render acl=$goFonMacroACL} - -{/render} - {if $javascript eq 'false'} -{render acl=$goFonMacroACL} - -{/render} - {/if} -
-
- {$macrotab} -
- - - - diff --git a/plugins/gofon/phoneaccount/main.inc b/plugins/gofon/phoneaccount/main.inc deleted file mode 100644 index 683057ad2..000000000 --- a/plugins/gofon/phoneaccount/main.inc +++ /dev/null @@ -1,125 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('phoneAccount'); - } - - /* Create phoneAccount object on demand */ - if (!isset($_SESSION['phoneAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['phoneAccount']= new phoneAccount ($config, $ui->dn); - $_SESSION['phoneAccount']->set_acl_base($ui->dn); - $_SESSION['phoneAccount']->set_acl_category("users"); - } - $phoneAccount= $_SESSION['phoneAccount']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $phoneAccount->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $phoneAccount->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $phoneAccount->save (); - - del_lock ($ui->dn); - sess_del ('edit'); - - /* Write back to session */ - $_SESSION['phoneAccount']= $phoneAccount; - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display.= $lock_msg; - }else{ - $display.= $phoneAccount->execute (); - } - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['phoneAccount']= $phoneAccount; - } - - $info= ""; - if ($phoneAccount->is_account && empty($lock_msg)){ - $display.= "

"; - - /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/phoneAccount"))){ - $info.= "\"\""._("Click the 'Edit' button below to change informations in this dialog"); - $display.= "\n"; - } - $display.= "\n"; - } - $display.= "

\n"; - $display.= "\n"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/phone.png'), _("Phone settings"), $info).$display; - -} -?> diff --git a/plugins/gofon/phoneaccount/paste_generic.tpl b/plugins/gofon/phoneaccount/paste_generic.tpl deleted file mode 100644 index d643e9f69..000000000 --- a/plugins/gofon/phoneaccount/paste_generic.tpl +++ /dev/null @@ -1,55 +0,0 @@ -

{t}Phone settings{/t}

- - - - - - - - -
-

-  {t}Phone numbers{/t} -

-
- -
- - - -
- - - - -
-

- -  {t}Telephone hardware{/t} -

- - - - - - - - - -
- - - -
- - - -
-
-
- -
-
diff --git a/plugins/personal/connectivity/class_connectivity.inc b/plugins/personal/connectivity/class_connectivity.inc deleted file mode 100644 index 70cfd87a7..000000000 --- a/plugins/personal/connectivity/class_connectivity.inc +++ /dev/null @@ -1,190 +0,0 @@ - - \version 2.30 - \date 29.03.2005 - - This class provides the functionality to read and write all attributes - relevant for connectivity settings from/to the LDAP. It does syntax checking - and displays the formulars required. - */ - -class connectivity extends plugin -{ - /* Definitions */ - var $plHeadline= "Connectivity"; - var $plDescription= "This does something"; - - /* attribute list for save action */ - var $attributes= array(); - var $objectclasses= array(); - - var $ignore_account= TRUE; - var $plugin= array(); - var $plugin_name= array(); - var $CopyPasteVars = array("plugin","plugin_name"); - - - function connectivity (&$config, $dn= NULL,$parent =NULL) - { - /* Preseed permissions */ - $this->dn= $dn; - $ui= get_userinfo(); - - /* Load accounts */ - foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){ - $name= $plug['CLASS']; - $this->plugin_name[]= $name; - $this->plugin[$name]= new $name($config, $dn,$parent); - - /* Acl base && category configuration, - these settings will be overloaded in main.inc, - if we are editing ourself */ - $this->plugin[$name]-> set_acl_category("users"); - $this->plugin[$name]-> set_acl_base($this->dn); - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - $display= ""; - - /* Prepare templating */ - $smarty= get_smarty(); - - /* Do we represent a valid account? */ - if ($this->parent === NULL){ - $enabled= true; - foreach ($this->plugin_name as $name){ - if ($this->plugin[$name]->is_account){ - $enabled= true; - break; - } - } - if (!$enabled){ - $display= "\"\" ". - _("This account has no connectivity extensions.").""; - $display.= back_to_main(); - return ($display); - } - } - - /* Remove checkboxes in single edit mode */ - if ($this->parent !== NULL){ - foreach ($this->plugin_name as $name){ - $this->plugin[$name]->parent= $this->parent; - } - } - - /* Execude objects */ - $is_first= true; - - $ReadOnly = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - - foreach ($this->plugin_name as $name){ - $this->plugin[$name]->ReadOnly = $ReadOnly; - if (!$is_first){ - $display.= '

 

'; - } else { - $is_first= false; - } - $display.= $this->plugin[$name]->execute(); - } - - /* Mark me as connectivity tab */ - $display.= ""; - - return($display); - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['connectivityTab'])){ - foreach ($this->plugin_name as $name){ - $this->plugin[$name]->save_object(); - } - } - } - - function check() - { - $message= plugin::check(); - - foreach ($this->plugin_name as $name){ - $tmp= $this->plugin[$name]->check(); - - $message= array_merge($message, $tmp); - } - - return ($message); - } - - function set_acl_category($cat) - { - plugin::set_acl_category($cat); - foreach ($this->plugin_name as $name){ - $this->plugin[$name]->set_acl_category( $cat); - } - } - - function set_acl_base($base) - { - plugin::set_acl_base($base); - foreach ($this->plugin_name as $name){ - $this->plugin[$name]->set_acl_base( $base); - } - } - - /* Save to LDAP */ - function save() - { - /* Save objects */ - foreach ($this->plugin_name as $name){ - $this->plugin[$name]->dn= $this->dn; - - if ($this->plugin[$name]->is_account){ - $this->plugin[$name]->save(); - } else { - $this->plugin[$name]->remove_from_parent(); - } - } - } - - function remove_from_parent() - { - /* Remove objects */ - foreach ($this->plugin_name as $name){ - $this->plugin[$name]->dn= $this->dn; - $this->plugin[$name]->remove_from_parent(); - } - } - - function adapt_from_template($dn) - { - /* Adapt objects */ - foreach ($this->plugin_name as $name){ - $this->plugin[$name]->dn= $this->dn; - $this->plugin[$name]->adapt_from_template($dn); - } - } - - /* Prepare the connectivity obj - */ - function PrepareForCopyPaste($obj) - { - $tmp = $this->plugin; - plugin::PrepareForCopyPaste($obj); - $this->plugin = $tmp; - foreach( $this->plugin as $key => $plug){ - $this->plugin[$key]->PrepareForCopyPaste($obj); - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_intranetAccount.inc b/plugins/personal/connectivity/class_intranetAccount.inc deleted file mode 100644 index c2b9573d3..000000000 --- a/plugins/personal/connectivity/class_intranetAccount.inc +++ /dev/null @@ -1,213 +0,0 @@ - - \version 1.00 - \date 1.07.2005 - - \brief Enables Apache authentification for Intranet through openldap with .htaccess files - */ - -class intranetAccount extends plugin -{ - /*! Definitions */ - var $plHeadline= "Intranet"; - /*! Definitions */ - var $plDescription= "This does something"; - - /* attribute list for save action */ - var $attributes= array(); - /* ObjectClasses list for save action */ - var $objectclasses= array("gosaIntranetAccount"); - var $ReadOnly = false; - - var $uid =""; - - var $view_logged = FALSE; - - /*! \brief Konstructor - - \param $config The Config Object used to initialise plugin - \param $dn The DN of the currently edited entry - \author Harald Falk - \version 1.00 - \date 1.07.2005 - */ - function intranetAccount (&$config, $dn= NULL, $parent=NULL) - { - plugin::plugin ($config, $dn,$parent); - - /* Setting uid to default */ - if(isset($this->attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - } - - /*! - \brief General execution - \author Harald Falk - \version 1.00 - \date 1.07.2005 - - Load smarty Template and assign needed smarty vars - */ - - - function execute() - { - /* Call parent execute */ - // plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - $display= ""; - - $smarty= get_smarty(); - - if ($this->is_account){ - $smarty->assign("intranetState", "checked"); - $smarty->assign("wstate", ""); - } else { - $smarty->assign("wstate", "disabled"); - $smarty->assign("intranetState", ""); - } - - //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. ) - if ($this->parent !== NULL){ - $smarty->assign("tabbed", 1); - }else{ - $smarty->assign("tabbed", 0); - } - - - $smarty->assign('gosaIntranetACL', " disabled "); - if((!$this->ReadOnly) && ( ($this->is_account && $this->acl_is_removeable()) - || (!$this->is_account && $this->acl_is_createable()))){ - $smarty->assign('gosaIntranetACL', ""); - } - - $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /*! - \brief Delete ext from User - \author Harald Falk - \version 1.00 - \date 1.07.2005 - Handles deletion of this object - */ - function remove_from_parent() - { - if($this->acl_is_removeable() && $this->initially_was_account){ - plugin::remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* Log last action */ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->postremove(array("uid"=>$this->uid)); - } - } - - - /*! - \brief handles Post data - \author Harald Falk - \version 1.00 - \date 1.07.2005 - Save data to object - */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - if (isset($_POST['intranet'])){ - if (!$this->is_account && $_POST['intranet'] == "B"){ - if($this->acl_is_createable()){ - $this->is_account= TRUE; - } - } - } else { - if($this->acl_is_removeable()){ - $this->is_account= FALSE; - } - } - } - - plugin::save_object(); - if (isset($_POST["INTRANETStatus"])){ - $this->INTRANETStatus = "disabled"; - } else { - $this->INTRANETStatus = "enabled"; - } - } - - - /*! \brief Handles LDAP saves - \author Harald Falk - \version 1.00 - \date 1.07.2005 - Save objectClass for User in LDAP - - */ - function save() - { - plugin::save(); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->postcreate(array("uid" => $this->uid)); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Intranet"), - "plDepends" => array("user"), - "plPriority" => 25, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plDescription" => _("Intranet account settings")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - - "plProvidedAcls" => array() - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_kolabAccount.inc b/plugins/personal/connectivity/class_kolabAccount.inc deleted file mode 100644 index c72977de8..000000000 --- a/plugins/personal/connectivity/class_kolabAccount.inc +++ /dev/null @@ -1,486 +0,0 @@ -attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - /* Pull arrays */ - foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){ - if (isset($this->attrs["$attr"]["count"])){ - $tmp = array(); - for ($i= 0; $i<$this->attrs["$attr"]["count"]; $i++){ - $tmp[]=$this->attrs["$attr"][$i]; - } - $this->$attr = $tmp; - } - } - - /* If this one is empty, preset with ACT_MANUAL for anonymous users */ - if (count ($this->kolabInvitationPolicy) == 0){ - $this->kolabInvitationPolicy= array("ACT_MANUAL"); - } - - /* Check is account state */ - $this->is_account = false; - if(count($this->kolabDelegate)){ - $this->is_account = true; - } - foreach(array("calFBURL","unrestrictedMailSize") as $attr){ - if(!empty($this->$attr)){ - $this->is_account = true; - } - } - - /* Transfer account states for this union */ - if (isset($this->parent->by_object['mailAccount']) && $this->parent->by_object['mailAccount']->is_account){ - $this->mail_Account = true; - }elseif( isset($this->attrs) && isset($this->attrs['kolabHomeServer'])){ - $this->mail_Account= true; - }else{ - $this->is_account = false; - $this->mail_Account = false; - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Show tab dialog headers */ - $display= ""; - - /* Show main page */ - $smarty= get_smarty(); - - /* Load attributes */ - foreach($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $acl => $description){ - $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly)); - $smarty->assign($acl."_W", $this->acl_is_writeable($acl,$this->ReadOnly)); - } - $smarty->assign("is_account" , $this->is_account); - - if($this->ReadOnly){ - $smarty->assign("is_removeable",false); - $smarty->assign("is_createable",false); - }else{ - $smarty->assign("is_removeable",$this->acl_is_removeable()); - $smarty->assign("is_createable",$this->acl_is_createable()); - } - - /* Check for invitation action */ - $nr= 0; - while (isset($_POST["policy$nr"])){ - if (isset($_POST["add$nr"])){ - $this->kolabInvitationPolicy[]= ": ACT_MANUAL"; - } - if (isset($_POST["remove$nr"])){ - $new= array(); - foreach ($this->kolabInvitationPolicy as $entry){ - if (!preg_match("/^".$this->imapping[$nr].":/", $entry)){ - $new[]= $entry; - } - } - $this->kolabInvitationPolicy= $new; - } - $nr++; - } - - /* Unify addresses */ - $new= array(); - foreach($this->kolabInvitationPolicy as $value){ - $address= preg_replace('/^([^:]+:).*$/', '\1', $value); - $new[$address]= $value; - } - $this->kolabInvitationPolicy= array(); - foreach($new as $value){ - $this->kolabInvitationPolicy[]= $value; - } - - /* Add delegation */ - if (isset($_POST['add_delegation'])){ - if ($_POST['delegate_address'] != ""){ - - /* Valid email address specified? */ - $address= $_POST['delegate_address']; - $valid= FALSE; - if (!is_email($address)){ - if (!is_email($address, TRUE)){ - print_red (_("You're trying to add an invalid email address to the list of delegations.")); - } - } else { - - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - $ldap->search('(mail='.$address.')',array("mail")); - if ($ldap->count() == 0){ - print_red (_("The mail address you're trying to add is no primary mail address of an existing user.")); - } else { - $valid= TRUE; - } - } - - if ($valid){ - /* Add it */ - if ($this->acl_is_writeable("kolabDelegate")){ - $this->addDelegate ($address); - $this->is_modified= TRUE; - } - - } - } - } - - /* Delete forward email addresses */ - if ((isset($_POST['delete_delegation'])) && (isset($_POST['delegate_list']))){ - if (count($_POST['delegate_list']) && $this->acl_is_writeable("kolabDelegate")){ - $this->delDelegate ($_POST['delegate_list']); - } - } - - /* Assemble policies */ - $policies= array( 'ACT_ALWAYS_ACCEPT' => _("Always accept"), - 'ACT_ALWAYS_REJECT' => _("Always reject"), - 'ACT_REJECT_IF_CONFLICTS' => _("Reject if conflicts"), - 'ACT_MANUAL_IF_CONFLICTS' => _("Manual if conflicts"), - 'ACT_MANUAL' => _("Manual")); - $smarty->assign('policies', $policies); - - /* Adjust checkbox */ - if ($this->unrestrictedMailSize){ - $smarty->assign('unrestrictedMailSizeState', "checked"); - } else { - $smarty->assign('unrestrictedMailSizeState', ""); - } - - /* Transfer delegation list */ - if (!count($this->kolabDelegate)){ - /* Smarty will produce and tidy don't like that, so tell smarty to create no option (array();)*/ - $smarty->assign("kolabDelegate", array()); - } else { - $smarty->assign("kolabDelegate", $this->kolabDelegate); - } - - $smarty->assign("mail_account",$this->mail_Account); - - /* Create InvitationPolicy table */ - $invitation= ""; - $this->imapping= array(); - $nr= 0; - $changeState = ""; - foreach ($this->kolabInvitationPolicy as $entry){ - - if($this->acl_is_writeable("kolabInvitationPolicy")){ - $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n - changeState('add".$nr."'); \n changeState('remove".$nr."'); \n"; - } - - if(!$this->acl_is_writeable("kolabInvitationPolicy")){ - $dis = " disabled "; - }else{ - if($this->is_account){ - $dis = " "; - }else{ - $dis = " disabled "; - } - } - $invitation.= ""; - - if(!$this->acl_is_readable("kolabInvitationPolicy")) { - } - - /* The default entry does not have colons... */ - if (!preg_match('/:/', $entry)){ - $invitation.= _("Anonymous"); - $name= ""; - $mode= $entry; - } else { - $name= preg_replace('/:.*$/', '', $entry); - $mode= preg_replace('/^[^:]*: */', '', $entry); - - if(!$this->acl_is_readable("kolabInvitationPolicy")){ - $name=''; - } - $invitation.= ""; - } - $invitation.= ""; - - /* Add mode switch */ - $invitation.= ""; - } - if ($nr != 0) { - $button.= ""; - } - - $invitation.= " $button\n"; - $this->imapping[$nr]= $name; - $nr++; - } - $smarty->assign("invitation", $invitation); - $smarty->assign("changeState", $changeState); - $smarty->assign("kolabState",$this->is_account); - $display.= $smarty->fetch (get_template_path('kolab.tpl', TRUE, dirname(__FILE__))); - - - return ($display); - } - - function remove_from_parent() - { - if(!$this->initially_was_account){ - return; - } - - /* Optionally execute a command after we're done */ - plugin::remove_from_parent(); - - if(!in_array("kolabInetOrgPerson",$this->attrs['objectClass'])){ - $this->attrs['objectClass'][] = "kolabInetOrgPerson"; - } - - $ldap = $this->config->get_ldap_linK(); - $ldap->cd($this->config->current['BASE']); - $ldap->cd ($this->dn); - $ldap->modify($this->attrs); - - /* Log last action */ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - $this->handle_post_events('remove',array("uid" => $this->uid)); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/kolab account with dn '%s' failed."),$this->dn)); - } - - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* FBFuture is in days... */ - if ($this->kolabFreeBusyFuture != "" && !preg_match('/^[0-9]+$/', $this->kolabFreeBusyFuture)){ - $message[]= _("The value specified as Free Busy future needs to be an integer."); - } - - /* Check for URL scheme... */ - if(!empty($this->calFBURL) && !preg_match("/http+(s)*:\/\//",$this->calFBURL)){ - $message[]= _("The value specified as Free Busy Information URL is invalid."); - } - - /* Check invitation policy for existing mail addresses */ - foreach($this->kolabInvitationPolicy as $policy){ - - /* Ignore anonymous string */ - if (!preg_match('/:/', $policy)){ - continue; - } - - $address= preg_replace('/^([^:]+).*$/', '\1', $policy); - if (!is_email($address)){ - if (!is_email($address, TRUE)){ - $message[]= sprintf(_("The invitation policy entry for address '%s' is not valid."), $address); - } - } else { - - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - $ldap->search('(mail='.$address.')',array("mail")); - if ($ldap->count() == 0){ - $message[]= sprintf(_("There's no mail user with address '%s' for your invitation policy!"), $address); - } else { - $valid= TRUE; - } - } - } - - return ($message); - } - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - - if(isset($_POST["kolabState"])){ - if($this->acl_is_createable()){ - $this->is_account = true; - } - }else{ - if($this->acl_is_removeable()){ - $this->is_account = false; - } - } - - if ($this->acl_is_writeable("unrestrictedMailSize")){ - if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){ - $this->unrestrictedMailSize= 1; - } else { - $this->unrestrictedMailSize= 0; - } - } - } - - plugin::save_object(); - - /* Save changes done in invitation policies */ - if($this->acl_is_writeable("kolabInvitationPolicy")){ - $nr= 0; - $this->kolabInvitationPolicy= array(); - while (isset($_POST["policy$nr"])){ - - /* Anonymous? */ - if (!isset($_POST["address$nr"])){ - $this->kolabInvitationPolicy[]= $_POST["policy$nr"]; - } else { - $this->kolabInvitationPolicy[]= $_POST["address$nr"].": ".$_POST["policy$nr"]; - } - - $nr++; - } - - /* If this one is empty, preset with ACT_MANUAL for anonymous users */ - if (count ($this->kolabInvitationPolicy) == 0){ - $this->kolabInvitationPolicy= array("ACT_MANUAL"); - } - } - } - - - /* Save to LDAP */ - function save() - { - /* Check mailmethod before doing something useful */ - plugin::save(); - - /* Transfer arrays */ - $this->attrs['kolabDelegate']= $this->kolabDelegate; - $this->attrs['kolabInvitationPolicy']= $this->kolabInvitationPolicy; - - /* unrestrictedMailSize is boolean */ - if($this->attrs['unrestrictedMailSize']){ - $this->attrs['unrestrictedMailSize'] = "TRUE"; - }else{ - $this->attrs['unrestrictedMailSize'] = "FALSE"; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/kolab account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - } - - - /* Add entry to delegation list */ - function addDelegate($address) - { - $this->kolabDelegate[]= $address; - $this->kolabDelegate= array_unique ($this->kolabDelegate); - - sort ($this->kolabDelegate); - reset ($this->kolabDelegate); - $this->is_modified= TRUE; - } - - function delDelegate($addresses) - { - $this->kolabDelegate= array_remove_entries ($addresses, $this->kolabDelegate); - $this->is_modified= TRUE; - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Kolab"), - "plDescription" => _("Kolab account settings")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 20, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "kolabFreeBusyFuture" => _("Free busy future"), - "unrestrictedMailSize" => _("Mail size restriction"), - "calFBURL" => _("Free busy information"), - "kolabDelegate" => _("Delegations"), - "kolabInvitationPolicy" => _("Invitation policy")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_opengwAccount.inc b/plugins/personal/connectivity/class_opengwAccount.inc deleted file mode 100644 index ff96e458e..000000000 --- a/plugins/personal/connectivity/class_opengwAccount.inc +++ /dev/null @@ -1,356 +0,0 @@ -ldap */ - var $attrsToUse = array( "salutation" =>"vocation", - "name" =>"sn", - "firstname" =>"givenName", - "login" =>"uid", - "degree" =>"academicTitle", - "birthday" =>"dateOfBirth", - "sex" =>"gender", - "street" =>"street", - "zip" =>"postalCode", - "value_string"=>"mail", - "number" =>"telephoneNumber" - ); - - var $serverCon = false; - var $handle = NULL; - var $is_account = false; - var $initialy_was_account = false; - var $OGWPassword = ""; - var $ReadOnly = false; - var $view_logged = FALSE; - var $uid = ""; - - function opengwAccount (&$config, $dn= NULL) - { - plugin::plugin ($config, $dn); - - /* Setting uid to default */ - if(isset($this->attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - $this->info=array(); - - /* is no account and was no account */ - $this->initialy_was_account = false; - $this->is_account = false; - - /* Get configurations */ - if($this->config->search("opengwAccount", 'USERNAME',array('tabs'))){ - $atr = array(); - $atr['LOGIN'] = $this->config->search("opengwAccount", 'USERNAME',array('tabs')); - $atr['PASSWORD']= $this->config->search("opengwAccount", 'PASSWORD',array('tabs')); - $atr['SERVER'] = $this->config->search("opengwAccount", 'DATAHOST',array('tabs')); - $atr['DB'] = $this->config->search("opengwAccount", 'DATABASE',array('tabs')); - $this->serverCon = $atr; - }elseif(isset($this->config->data['SERVERS']['OPENGROUPWARE'])){ - $this->serverCon = $this->config->data['SERVERS']['OPENGROUPWARE']; - }else{ - $this->serverCon = array(); - } - - /* check if datebase funktions are available, and if database configurations are available */ - if(is_callable("pg_connect") && count($this->serverCon)){ - - $this->handle = new ogw($this->serverCon['LOGIN'],$this->serverCon['PASSWORD'],$this->serverCon['SERVER'],$this->serverCon['DB']); - - /* Check if current configuration allows database connection */ - if($this->handle->connected){ - - /* Set login name, to check if this is_account */ - if(isset($this->attrs['uid'][0])){ - $this->handle->info['login'] = $this->attrs['uid'][0]; - }else{ - $this->handle->info['login'] = ""; - } - - /* If this is account get data from database first */ - if($this->handle->CheckExistence()){ - $this->info = $this->handle->GetInfos($this->attrs['uid'][0]); - - /* This is an account */ - $this->initialy_was_account = true; - $this->is_account= true; - }else{ - /* this is no account */ - $this->initialy_was_account = false; - $this->is_account= false; - - /* Selectable in GOsa */ - $this->info['template_user_id'] = 0; - $this->info['is_locked'] = 0; - $this->info['LocationTeamID'] = 0; - $this->info['TeamIDis'] = array(); - } - - /* Set settings from ldap */ - foreach($this->attrsToUse as $name=>$attr){ - if(isset($this->attrs[$attr][0])){ - $this->info[$name] = $this->attrs[$attr][0]; - }else{ - $this->info[$name] = false; - } - } - - /* Description is displayed as 'Nickname' */ - $this->info['description'] = $this->info['login']; - - if($this->info['sex'] == "F"){ - $this->info['sex'] = "female"; - }else{ - $this->info['sex'] = "male"; - } - - } - - /* Transmit data back to ogw handle */ - $this->handle->SetInfos($this->info); - } - } - - function execute() - { - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Show tab dialog headers */ - $display= ""; - $smarty= get_smarty(); - - $smarty->assign("serverCon",count($this->serverCon)); - $smarty->assign("validTeams",""); - $smarty->assign("is_account", " "); - $smarty->assign("OGWstate"," disabled "); - $smarty->assign("validLocationTeam",array(" ")); - $smarty->assign("validLocationTeams",array(" ")); - $smarty->assign("LocationTeam",0); - $smarty->assign("validTemplateUser",array(" ")); - $smarty->assign("validTemplateUsers",array(" ")); - $smarty->assign("TemplateUser",0); - $smarty->assign("is_lockedCHK", " "); - $smarty->assign("is_locked", " "); - - /* set default values */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $acl => $desc){ - $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly)); - } - - if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { - $smarty->assign('opengwAccountACL', ""); - }else{ - $smarty->assign('opengwAccountACL', " disabled "); - } - - if(count($this->serverCon)) - - /* Check database extension */ - if(!is_callable("pg_connect") && count($this->serverCon)){ - print_red(_("OpenGroupware: Your configuration is missing a postgresql extension. Can't perform any database queries.")); - }elseif(count($this->serverCon)){ - - /* Check if config exists */ - if($this->config->search("opengwAccount", 'DATABASE',array('tabs'))){ - print_red(_("OpenGroupware: Missing database configuration for opengroupware. Can't get or set any informations.")); - }else{ - - /* Create handle */ - $this->handle = new ogw($this->serverCon['LOGIN'],$this->serverCon['PASSWORD'],$this->serverCon['SERVER'],$this->serverCon['DB']); - - /* Check if we are successfully connected to db */ - if(!$this->handle->connected){ - print_red(_("OpenGroupware: Can't connect to specified database. Please check given configuration twice.")); - }else{ - - /* Assign LocationTeams */ - $tmp = array(""=>"none"); - foreach($this->handle->validLocationTeam as $id){ - $tmp[$id['company_id']] = $id['description']; - } - $smarty->assign("validLocationTeam",$tmp); - $smarty->assign("validLocationTeams",array_flip($tmp)); - $smarty->assign("LocationTeam",$this->info['LocationTeamID']); - - /* Assign TemplateUsers*/ - $tmp = array(); - foreach($this->handle->validTemplateUser as $id){ - $tmp[$id['company_id']] = $id['name']; - } - $smarty->assign("validTemplateUser",$tmp); - $smarty->assign("validTemplateUsers",array_flip($tmp)); - $smarty->assign("TemplateUser",$this->info['template_user_id']); - - /* Create Team membership */ - $str = ""; - if(($this->is_account)==""){ - $dis = ""; - }else{ - $dis = " disabled "; - } - - if($this->acl_is_readable("Teams")){ - foreach($this->handle->validTeams as $id){ - if(in_array($id['company_id'],$this->info['TeamIDis'])){ - $str .= "".$id['description']."
"; - }else{ - $str .= "".$id['description']."
"; - } - } - } - $smarty->assign("validTeams",$str); - - /* Assign ogw checkbox */ - if($this->is_account){ - $smarty->assign("OGWstate",""); - $smarty->assign("is_account", " checked "); - }else{ - $smarty->assign("is_account", " "); - $smarty->assign("OGWstate"," disabled "); - } - - /* Assign lock status */ - if($this->info['is_locked']){ - $smarty->assign("is_lockedCHK", " checked "); - }else{ - $smarty->assign("is_lockedCHK", " "); - } - $smarty->assign("is_locked", $this->info['is_locked']); - - } - } - } - $display.= $smarty->fetch (get_template_path('opengw.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - /* remove database entries */ - if($this->initialy_was_account){ - $this->handle = new ogw($this->serverCon['LOGIN'],$this->serverCon['PASSWORD'],$this->serverCon['SERVER'],$this->serverCon['DB']); - $this->handle->SetInfos($this->info); - $this->handle->Perform("REMOVE"); - - new log("remove","users/".get_class($this),$this->dn); - } - } - - - /* Save data to object */ - function save_object() - { - /* get post data */ - if($this->is_account){ - - /* Get selected team chkboxes */ - $this->info['TeamIDis'] = array(); - if($this->acl_is_writeable("Teams")) { - foreach($_POST as $name => $value ){ - if(preg_match("/team_/i",$name)){ - if(!in_array($value,$this->info['TeamIDis'])){ - $this->info['TeamIDis'][]=$value; - } - } - } - } - - - /* Get location Team*/ - if(isset($_POST['LocationTeam']) && $this->acl_is_writeable("LocationTeam")){ - $this->info['LocationTeamID'] = $_POST['LocationTeam']; - } - - /* Get template user */ - if(isset($_POST['TemplateUser']) && $this->acl_is_writeable("TemplateUser") ){ - $this->info['template_user_id'] = $_POST['TemplateUser']; - } - - /* get lock status */ - if($this->acl_is_writeable("Locked")){ - if(isset($_POST['is_locked'])){ - $this->info['is_locked'] = $_POST['is_locked']; - }else{ - $this->info['is_locked'] = 0; - } - } - } - - /* change account status */ - if(isset($_POST['is_account'])){ - if($this->acl_is_createable()){ - $this->is_account = $_POST['is_account']; - } - }else{ - if($this->acl_is_removeable()){ - $this->is_account = false;//$_POST['is_account']; - } - } - } - - - /* Save to LDAP */ - function save() - { - /* Save data */ - $this->handle = new ogw($this->serverCon['LOGIN'],$this->serverCon['PASSWORD'],$this->serverCon['SERVER'],$this->serverCon['DB']); - $this->handle->SetInfos($this->info); - $this->handle->checkInfos(); - if($this->initialy_was_account){ - $this->handle->Perform("EDIT"); - new log("modify","users/".get_class($this),$this->dn); - }else{ - $this->handle->Perform("ADD"); - new log("create","users/".get_class($this),$this->dn); - } - } - - - function PrepareForCopyPaste($src){ - // Nothing to do, because this object can't be copied ... yet - } - - - /* Return plugin informations for acl handling - #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */ - static function plInfo() - { - return (array( - "plShortName" => _("Opengroupware"), - "plDescription" => _("Open groupware account settings")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 26, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "LocationTeam" => _("Location team"), - "TemplateUser" => _("Template user"), - "Locked" => _("Locked"), - "Teams" => _("Teams")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_oxchangeAccount.inc b/plugins/personal/connectivity/class_oxchangeAccount.inc deleted file mode 100644 index ce4288fbb..000000000 --- a/plugins/personal/connectivity/class_oxchangeAccount.inc +++ /dev/null @@ -1,981 +0,0 @@ -config->data['TABS']['CONNECTIVITY']);$i++){ - if($this->config->data['TABS']['CONNECTIVITY'][$i]['CLASS']=='oxchangeAccount') { - $this->oxconf=$this->config->data['TABS']['CONNECTIVITY'][$i]; - break; - } - } - - /* Setting uid to default */ - if(isset($this->attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - $this->dnmode= $this->config->current['DNMODE']; - if(isset($this->attrs[$this->dnmode][0])){ - $this->dnModeValue = $this->attrs[$this->dnmode][0]; - } - } - - function execute() - { - /* Call parent execute */ - //plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - $display=""; - - /* Show main page */ - $smarty= get_smarty(); - - if (function_exists("pg_connect")){ - $smarty->assign("pg", true); - }else{ - $smarty->assign("pg", false); - } - - /* Load attributes */ - foreach($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - if ($this->is_account){ - $smarty->assign("oxchangeState", "checked"); - $smarty->assign("oxState", ""); - } else { - $smarty->assign("oxchangeState", ""); - $smarty->assign("oxState", "disabled"); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $key => $desc){ - $smarty->assign($key."ACL",$this->getacl($key,$this->ReadOnly)); - $smarty->assign($key."_W",$this->acl_is_writeable($key)); - } - - if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) ){ - $smarty->assign('oxchangeAccountACL', ""); - }else{ - $smarty->assign('oxchangeAccountACL', " disabled "); - } - - $smarty->assign("timezones", $this->timezones); - - - if ($this->parent !== NULL){ - $smarty->assign("tabbed", 1); - }else{ - $smarty->assign("tabbed", 0); - } - - /* Trying to open a Postgresql Database Server */ - if (function_exists("pg_connect")){ - if(isset($this->oxconf["PGUSER"]) and isset($this->oxconf["PGHOST"]) and isset($this->oxconf["PGDBNAME"]) and isset($this->oxconf["PGPASSWD"])){ - $pgcon = @pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]); - if (! $pgcon){ - $smarty->assign("pg", false); - } - }else{ - $smarty->assign("pg", false); - } - }else{ - $smarty->assign("pg", false); - } - - $display.= $smarty->fetch (get_template_path('oxchange.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - if(!$this->acl_is_removeable()) return; - $this->attrs[$this->dnmode][0] = $this->dnModeValue; - $sqldeluser=array( - "delete from prg_notes where (user_right like '".$this->attrs[$this->dnmode][0]."') and (group_right like 's')", - "delete from prg_documents_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_documents_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_docufolders_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_docufolders_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_date_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_date_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_dates_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_knowledge_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_knowledge_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_knowledge_folder_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_knowledge_folder_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_pin_board_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_pin_board_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_bookmarks_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_bookmarks_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_bookmarks_folder_read where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_bookmarks_folder_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_tasks_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_tasks_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_tasks_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_projects_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_projects_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')", - "delete from prg_projects_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')", - "delete from oxfolder_permissions where (entity like '".$this->attrs[$this->dnmode][0]."') AND ((role = 256) OR (role = 1024))", - "delete from oxfolder_standardfolders where owner like '".$this->attrs[$this->dnmode][0]."'", - "delete from prg_forum_read where user_right = '".$this->attrs[$this->dnmode][0]."'", - "delete from prg_forum_mod where user_right = '".$this->attrs[$this->dnmode][0]."'", - "delete from prg_forum_abo where user_right = '".$this->attrs[$this->dnmode][0]."'", - "delete from prg_forum_seen where username = '".$this->attrs[$this->dnmode][0]."'", - "delete from sys_holiday where (userid like '".$this->attrs[$this->dnmode][0]."')", - "delete from usr_holiday where (userid like '".$this->attrs[$this->dnmode][0]."')"); - - /* Trying to open a Postgresql Database Server */ - if (function_exists("pg_connect")){ - if(isset($this->oxconf["PGUSER"]) and - isset($this->oxconf["PGHOST"]) and - isset($this->oxconf["PGDBNAME"]) and - isset($this->oxconf["PGPASSWD"])){ - $pgcon = @pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]); - if (! $pgcon){ - print_red(_("Connectivity")." "._("Openexchange")." :"._("Couldn't connect to postgresql database!")); - return; - } - }else{ - print_red(_("Connectivity")." "._("Openexchange")." :"._("Needed parameters for openexchange connectivity plugin are missing!")); - return; - } - }else{ - print_red(_("Connectivity")." "._("Openexchange")." :"._("PHP4 module for postgresql database is missing!")); - return; - } - - plugin::remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - - if($ldap->dn_exists("ou=addr,".$this->dn)){ - $ldap->rmdir_recursive("ou=addr,".$this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/oxchange addressbook account with dn '%s' failed."),$this->dn)); - } - - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/oxchange addressbook account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->postremove(array("uid" => $this->uid)); - - /* Finally remove data from postgresql server */ - foreach ($sqldeluser as $sqls){ - @pg_exec($pgcon,$sqls); - } - pg_close(); - } - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - if (isset($_POST['oxchange'])){ - if (!$this->is_account && $_POST['oxchange'] == "B") { - if($this->acl_is_createable()){ - $this->is_account= TRUE; - } - } - } else { - if($this->acl_is_removeable()){ - $this->is_account= FALSE; - } - } - } - - /* Get objects */ - foreach(array("OXTimeZone","OXTaskDays","OXAppointmentDays") as $name) { - if($this->acl_is_writeable($name) && isset($_POST[$name])){ - $this->$name = $_POST[$name]; - } - } - -// plugin::save_object(); - if (isset($_POST["oxchangeStatus"])){ - $this->oxchangeStatus = "disabled"; - } else { - $this->oxchangeStatus = "enabled"; - } - } - - - /* Save to LDAP */ - function save() - { - - $needupdate=TRUE; - $istemplate=FALSE; - - -/* print "
".print_r($this->attrs, true)."
";*/ - - - /*First at all, we must check if this is new or is updated */ - /*Also check is we have a template, if is a template, is a new user */ - if (isset($this->attrs['objectClass'])){ - foreach ($this->attrs['objectClass'] as $object){ - if($object=="OXUserObject") $needupdate=FALSE; - if($object=="gosaUserTemplate") $istemplate=TRUE; - } - } - - $uidarray=array(); - preg_match("/^(\w+(?=\=))=((\w|\s|\.)+(?=\,)),.*/",$this->dn,$uidarray); - $uid=$uidarray[2]; - if (trim($uid) == "") { - print_red(_("The Open-Xchange accountname is empty and thus invalid! Check to make sure that you are not using any strange characters in the loginname.")); - return; - } - - if ($istemplate) $needupdate=TRUE; - - if($needupdate){ - /* Trying to open a Postgresql Database Server */ - if (function_exists("pg_connect")){ - if(isset($this->oxconf["PGUSER"]) and isset($this->oxconf["PGHOST"]) and isset($this->oxconf["PGDBNAME"]) and isset($this->oxconf["PGPASSWD"])){ - $pgcon = @pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]); - if (! $pgcon){ - print_red(_("Couldn't connect to postgresql database!")); - return; - } - }else{ - print_red(_("Needed parameters for openexchange connectivity plugin are missing!")); - return; - } - }else{ - print_red(_("PHP4 module for postgresql database is missing!")); - return; - } - } - - plugin::save(); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/oxchange account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->postcreate(array("uid" => $this->uid)); - - if($needupdate){ - $ldap->create_missing_trees("ou=addr,".$this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Creating of user/oxchange account with dn '%s' failed."),$this->dn)); - /* Finally save data to postgresql server */ - pg_set_client_encoding ("UNICODE"); - $nv = "SELECT nextval ('serial_id')"; - $ot = "insert into oxfolder_tree (fuid, parent, fname, module, type, owner, creator, creating_date, created_from, changing_date, changed_from) VALUES (%d, 1, '%s', '%s', 'private', '%s', '%s', 'now', 'System', 'now', 'System')"; - $op = "INSERT INTO oxfolder_permissions (puid, pid, role, entity, sealed, fp, orp, owp, odp) VALUES (%d, %d, 32768, '%s', 0, 128, 128, 128, 128)"; - $os = "insert into oxfolder_standardfolders (owner,module_calendar,module_contact,module_task) VALUES ('%s',%d,%d,%d)"; - $ugr= "INSERT INTO usr_general_rights SELECT creating_date, created_from, changing_date, changed_from,text('%s'), addr_u, addr_r, addr_d, cont_u, cont_r, cont_d, data_u, data_r, data_d, serie_u, serie_r, serie_d, task_u, task_r, task_d, refer, proj_u, proj_r, proj_d, dfolder_u, dfolder_r, dfolder_d, doc_u, doc_r, doc_d, knowl_u, knowl_r, knowl_d, bfolder_u, bfolder_r, bfolder_d, bookm_u, bookm_r, bookm_d, pin_u, pin_r, pin_d, forum_n, fentrie_n, setup, pin_public, internal, int_groups, kfolder_u, kfolder_r, kfolder_d, webmail FROM sys_gen_rights_template WHERE login LIKE 'default_template'"; - - $error = FALSE; - $res=@pg_exec($pgcon,$nv); - - if(!$res){ - $error = TRUE; - }else{ - $calendarid=pg_fetch_row($res); - pg_freeresult($res); - - $q=sprintf($ot,$calendarid[0],'My Appointments','calendar',$uid,$uid); - @pg_exec($pgcon,$q); - } - - $res=@pg_exec($pgcon,$nv); - - if(!$res){ - $error = TRUE; - }else{ - $nid=pg_fetch_row($res); - pg_freeresult($res); - - $q=sprintf($op,$nid[0],$calendarid[0],$uid); - @pg_exec($pgcon,$q); - } - - $res=@pg_exec($pgcon,$nv); - if(!$res){ - $error = TRUE; - }else{ - $contactsid=pg_fetch_row($res); - pg_freeresult($res); - - $q=sprintf($ot,$contactsid[0],'My Contacts','contact',$uid,$uid); - @pg_exec($pgcon,$q); - } - - $res=@pg_exec($pgcon,$nv); - if(!$res){ - $error = TRUE; - }else{ - $nid=pg_fetch_row($res); - pg_freeresult($res); - - $q=sprintf($op,$nid[0],$contactsid[0],$uid); - @pg_exec($pgcon,$q); - } - - $res=@pg_exec($pgcon,$nv); - if(!$res){ - $error = TRUE; - }else{ - $tasksid=pg_fetch_row($res); - pg_freeresult($res); - - $q=sprintf($ot,$tasksid[0],'My Tasks','task',$uid,$uid); - @pg_exec($pgcon,$q); - } - - $res=@pg_exec($pgcon,$nv); - if(!$res){ - $error = TRUE; - }else{ - $nid=pg_fetch_row($res); - pg_freeresult($res); - - $q=sprintf($op,$nid[0],$tasksid[0],$uid); - @pg_exec($pgcon,$q); - - $q=sprintf($os,$uid,$calendarid[0],$contactsid[0],$tasksid[0]); - @pg_exec($pgcon,$q); - - $q=sprintf($ugr,$uid); - @pg_exec($pgcon,$q); - } - - @pg_close($pgcon); - - if($error){ - print_red(_("Something went wrong while saving oxchange account. Please check the error log file.")); - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Open xchange"), - "plDescription" => _("Open xchange account settings")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 27, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "OXAppointmentDays" => _("OXAppointmentDays"), - "OXTaskDays" => _("OXTaskDays"), - "OXTimeZone" => _("OXTimeZone")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_phpgwAccount.inc b/plugins/personal/connectivity/class_phpgwAccount.inc deleted file mode 100644 index 7c5cf6e2c..000000000 --- a/plugins/personal/connectivity/class_phpgwAccount.inc +++ /dev/null @@ -1,172 +0,0 @@ -attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - } - - function execute() - { - /* Call parent execute */ -// plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Show tab dialog headers */ - $display= ""; - - /* Show main page */ - $smarty= get_smarty(); - - /* Load attributes */ - foreach($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - if ($this->is_account){ - $smarty->assign("phpgwState", "checked"); - } else { - $smarty->assign("phpgwState", ""); - } - - if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { - $smarty->assign('phpgwAccountACL', ""); - }else{ - $smarty->assign('phpgwAccountACL', " disabled "); - } - - $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - if($this->acl_is_removeable()){ - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - plugin::remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPgw account with dn '%s' failed."),$this->dn)); - - new log("remove","users/".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',array("uid" => $this->uid)); - } - } - - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - if (isset($_POST['phpgw'])){ - if (!$this->is_account && $_POST['phpgw'] == "B"){ - if($this->acl_is_createable()){ - $this->is_account= TRUE; - } - } - } else { - if($this->acl_is_removeable()){ - $this->is_account= FALSE; - } - } - } - - plugin::save_object(); - if (isset($_POST["phpgwStatus"])){ - $this->phpgwStatus = "disabled"; - } else { - $this->phpgwStatus = "enabled"; - } - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPgw account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("PHP GW"), - "plDescription" => _("PHP GW account settings")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 24, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array() - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_phpscheduleitAccount.inc b/plugins/personal/connectivity/class_phpscheduleitAccount.inc deleted file mode 100644 index 41454ea7c..000000000 --- a/plugins/personal/connectivity/class_phpscheduleitAccount.inc +++ /dev/null @@ -1,175 +0,0 @@ -is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Show tab dialog headers */ - $display= ""; - - /* Show main page */ - $smarty= get_smarty(); - - if ($this->is_account){ - $smarty->assign("phpscheduleitState", "checked"); - } else { - $smarty->assign("phpscheduleitState", ""); - $smarty->assign("wstate", "disabled"); - } - - if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { - $smarty->assign('gosaphpscheduleitACL', ""); - }else{ - $smarty->assign('gosaphpscheduleitACL', " disabled "); - } - - $display.= $smarty->fetch (get_template_path('phpscheduleit.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if ($this->acl_is_removeable()){ - - plugin::remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPscheduleit account with dn '%s' failed."),$this->dn)); - - if($this->is_account){ - new log("remove","users/".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',array("uid" => $this->uid)); - } - } - - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - if (isset($_POST['phpscheduleit'])){ - if (!$this->is_account && $_POST['phpscheduleit'] == "B"){ - if($this->acl_is_createable()) { - $this->is_account= TRUE; - } - } - } else { - if($this->acl_is_removeable()){ - $this->is_account= FALSE; - } - } - } - - plugin::save_object(); - if (isset($_POST["phpscheduleitStatus"])){ - $this->pptpStatus = "disabled"; - } else { - $this->pptpStatus = "enabled"; - } - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPscheduleit account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - - } - - - /* Return plugin informations for acl handling - #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */ - static function plInfo() - { - return (array( - "plShortName" => _("PHP Schedule it"), - "plDescription" => _("PHP Schedule it settings")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 29, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - - "plOptions" => array(), - - "plProvidedAcls" => array() - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_pptpAccount.inc b/plugins/personal/connectivity/class_pptpAccount.inc deleted file mode 100644 index 0c8c659cf..000000000 --- a/plugins/personal/connectivity/class_pptpAccount.inc +++ /dev/null @@ -1,188 +0,0 @@ -attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - } - - function execute() - { - /* Call parent execute */ - // plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Show tab dialog headers */ - $display= ""; - - /* Show main page */ - $smarty= get_smarty(); - - if ($this->is_account){ - $smarty->assign("pptpState", "checked"); - } else { - $smarty->assign("pptpState", ""); - $smarty->assign("wstate", "disabled"); - } - - if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { - $smarty->assign('gosapptpACL', ""); - }else{ - $smarty->assign('gosapptpACL', " disabled "); - } - - $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - if($this->acl_is_removeable()){ - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - plugin::remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* Log last action */ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PPTP account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove',array("uid" => $this->uid)); - } - } - - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - if (isset($_POST['pptp'])){ - if (!$this->is_account && $_POST['pptp'] == "B"){ - if($this->acl_is_createable()){ - $this->is_account= TRUE; - } - } - } else { - if($this->acl_is_removeable()){ - $this->is_account= FALSE; - } - } - } - - plugin::save_object(); - if (isset($_POST["pptpStatus"])){ - $this->pptpStatus = "disabled"; - } else { - $this->pptpStatus = "enabled"; - } - } - - - /* Save to LDAP */ - function save() - { - if($this->acl_is_createable()){ - plugin::save(); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PPTP account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - } - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("PPTP"), - "plDescription" => _("PPTP account")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 28, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array() - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_proxyAccount.inc b/plugins/personal/connectivity/class_proxyAccount.inc deleted file mode 100644 index 455bb53e5..000000000 --- a/plugins/personal/connectivity/class_proxyAccount.inc +++ /dev/null @@ -1,325 +0,0 @@ -attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - $display= ""; - - /* Prepare templating */ - $smarty= get_smarty(); - - $smarty->assign('proxyAccountACL', " disabled "); - - if((!$this->ReadOnly)&& (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))){ - $smarty->assign('proxyAccountACL', ""); - } - - /* Assign radio boxes */ - foreach (array("F", "T", "B", "N") as $val){ - - if (is_integer(strpos($this->gosaProxyAcctFlags, "$val"))) { - $smarty->assign("filter$val", "checked"); - - /* Add state variables for on-the-fly state-changing of checkboxes */ - $smarty->assign($val."state", ""); - - } else { - $smarty->assign("filter$val", ""); - - /* Same as above */ - if($_SESSION['js']==1){ - $smarty->assign($val."state", "disabled"); - }else{ - $smarty->assign($val."state", ""); - } - } - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $acl => $desc){ - $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly)); - $smarty->assign($acl."_W",$this->acl_is_writeable($acl,$this->ReadOnly)); - } - - /* Assign working time */ - $smarty->assign("starthour", (int)($this->gosaProxyWorkingStart / 60)); - $smarty->assign("startminute", (int)($this->gosaProxyWorkingStart % 60)); - $smarty->assign("stophour", (int)($this->gosaProxyWorkingStop / 60)); - $smarty->assign("stopminute", (int)($this->gosaProxyWorkingStop % 60)); - $hours= array(); - for($i=0; $i<24; $i++){ - $hours[]= sprintf("%02d",$i); - } - $smarty->assign("hours", $hours); - $smarty->assign("minutes", array("00","15","30","45")); - - /* Assign quota values */ - $smarty->assign("quota_unit", array("k" => _("KB"), "m" => _("MB"), "g" => _("GB"))); - $smarty->assign("quota_time", array("h" => _("hour"), "d" => _("day"), "w" => _("week"), "m" => _("month"))); - $smarty->assign("gosaProxyQuotaPeriod", $this->gosaProxyQuotaPeriod); - $smarty->assign("quota_size", preg_replace("/[a-z]$/i", "", $this->gosaProxyQuota)); - $smarty->assign("quota_u", preg_replace("/^[0-9]+/", "", $this->gosaProxyQuota)); - if ($this->is_account){ - $smarty->assign("proxyState", "checked"); - } else { - $smarty->assign("proxyState", ""); - } - - /* Prepare correct state */ - if (!$this->is_account){ - $smarty->assign("pstate", "disabled"); - } else { - $smarty->assign("pstate", ""); - } - - $changeA = ""; - - $ProxyWorkingStateChange ="\n"; - if($this->acl_is_writeable("gosaProxyFlagT")){ - $changeA .= "changeState('filterT');\n"; - - $ProxyWorkingStateChange.= "changeState('startHour'); \n"; - $ProxyWorkingStateChange.= "changeState('startMinute'); \n"; - $ProxyWorkingStateChange.= "changeState('stopHour'); \n"; - $ProxyWorkingStateChange.= "changeState('stopMinute'); \n"; - } - - if(preg_match("/F/",$this->gosaProxyAcctFlags)){ - $changeA .= $ProxyWorkingStateChange; - } - - $smarty->assign("ProxyWorkingStateChange",$ProxyWorkingStateChange); - - $changeB = ""; - if($this->acl_is_writeable("gosaProxyFlagB")){ - $changeA .= "changeState('filterB');"; - $changeB = - "changeSubselectState('filterB', 'quota_size'); - changeSubselectState('filterB', 'quota_unit'); - changeSubselectState('filterB', 'gosaProxyQuotaPeriod');"; - } - - $smarty->assign("changeB",$changeB); - $smarty->assign("changeA",$changeA); - - /* Show main page */ - $display.= $smarty->fetch(get_template_path('proxy.tpl', TRUE, dirname(__FILE__))); - return($display); - } - - function remove_from_parent() - { - if($this->acl_is_removeable() && $this->initially_was_account){ - - plugin::remove_from_parent(); - - $ldap= $this->config->get_ldap_link(); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* Log last action */ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/proxy account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove",array("uid" => $this->uid)); - } - } - - /* Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* We've got only one value to check for positive integer or emtpy field */ - if ($this->is_account){ - if($this->acl_is_writeable("gosaProxyQuota")){ - if (isset($_POST["quota_size"])){ - if ($_POST["quota_size"] == "gosaProxyQuota"){ - $message[]= _("Numerical value for Quota Setting is empty."); - }elseif ($_POST["quota_size"] <= 0){ - $message[]= _("Numerical value for Quota Setting is not valid."); - } - } - } - } - - return $message; - } - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - if (isset($_POST['proxy'])){ - if (!$this->is_account && $_POST['proxy'] == "B"){ - if($this->acl_is_createable()){ - $this->is_account= TRUE; - } - } - } else { - if($this->acl_is_removeable()){ - $this->is_account= FALSE; - } - } - } - - /* Save flag value */ - if ($this->is_account){ - - $flags= ""; - $acl= ""; - foreach(array("F", "T", "B") as $key){ - if($this->acl_is_writeable("gosaProxyFlag".$key)){ - - /* Add acl */ - if (isset($_POST["filter$key"])){ - $flags.= $key; - } - }else{ - - /* Keep all flags that can't be written*/ - if(preg_match("/".$key."/",$this->gosaProxyAcctFlags)){ - $flags .=$key; - } - } - } - if ("[$flags]" != $this->gosaProxyAcctFlags){ - $this->is_modified= TRUE; - } - $this->gosaProxyAcctFlags= "[$flags]"; - - /* Save time values */ - if ($this->acl_is_writeable("gosaProxyFlagT")){ - if(isset($_POST['startMinute'])){ - $old= $this->gosaProxyWorkingStart; - $this->gosaProxyWorkingStart= $_POST["startHour"] * 60 + $_POST["startMinute"]; - $this->is_modified= ($old != $this->gosaProxyWorkingStart)?TRUE:$this->is_modified; - } - - if (isset($_POST['stopMinute'])){ - $old= $this->gosaProxyWorkingStop; - $this->gosaProxyWorkingStop = $_POST["stopHour"] * 60 + $_POST["stopMinute"]; - $this->is_modified= ($old != $this->gosaProxyWorkingStop)?TRUE:$this->is_modified; - } - } - - /* Save quota values */ - if ($this->acl_is_writeable("gosaProxyFlagB")){ - if(isset($_POST["quota_size"]) && isset($_POST["quota_unit"])){ - $this->gosaProxyQuota= $_POST["quota_size"].$_POST["quota_unit"]; - } - } - - /*Save quota period */ - if($this->acl_is_writeable("gosaProxyFlagB")){ - if(isset($_POST["gosaProxyQuotaPeriod"])){ - $this->gosaProxyQuotaPeriod = $_POST["gosaProxyQuotaPeriod"]; - } - } - } - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/proxy account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - - } - - /* Return plugin informations for acl handling - #FIME There possibly some attributes that can be combined to one acl. */ - static function plInfo() - { - return (array( - "plShortName" => _("Proxy"), - "plDescription" => _("Proxy account")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 21, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "gosaProxyFlagF" => _("Filter unwanted content"), - "gosaProxyFlagT" => _("Limit proxy access"), - "gosaProxyFlagB" => _("Restrict proxy usage by quota")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_pureftpdAccount.inc b/plugins/personal/connectivity/class_pureftpdAccount.inc deleted file mode 100644 index 68de2e881..000000000 --- a/plugins/personal/connectivity/class_pureftpdAccount.inc +++ /dev/null @@ -1,256 +0,0 @@ -attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - } - - function execute() - { - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Show tab dialog headers */ - $display= ""; - - /* Show main page */ - $smarty= get_smarty(); - - /* Load attributes */ - foreach($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - - - $tmp = $this->plInfo(); - $changeState = ""; - foreach($tmp['plProvidedAcls'] as $key => $desc){ - $smarty->assign($key."ACL", $this->getacl($key,$this->ReadOnly)); - $smarty->assign($key."_W", $this->acl_is_writeable($key,$this->ReadOnly)); - - if($this->acl_is_writeable($key)){ - $changeState.= " changeState('".$key."'); \n"; - } - } - $smarty->assign("changeState",$changeState); - - - $smarty->assign("fstate", ""); - if ($this->is_account){ - $smarty->assign("pureftpdState", "checked"); - $smarty->assign("fstate", ""); - } else { - $smarty->assign("pureftpdState", ""); - if($_SESSION['js']==1){ - if($this->acl!="#none#") - $smarty->assign("fstate", "disabled"); - }else{ - $smarty->assign("fstate", ""); - } - } - $smarty->assign("use_FTPStatus", ($this->FTPStatus == "disabled") ? "checked" : ""); - - if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) ){ - $smarty->assign('pureftpdACL', ""); - }else{ - $smarty->assign('pureftpdACL', " disabled "); - } - - $display.= $smarty->fetch (get_template_path('pureftpd.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){ - return; - } - - plugin::remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* Log last action */ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/pureftpd account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove',array("uid" => $this->uid)); - } - - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - if (isset($_POST['pureftpd'])){ - if (!$this->is_account && $_POST['pureftpd'] == "B"){ - $this->is_account= TRUE; - } - } else { - $this->is_account= FALSE; - } - - plugin::save_object(); - - $old= $this->FTPStatus; - if (isset($_POST["FTPStatus"])){ - $this->FTPStatus = "disabled"; - } else { - $this->FTPStatus = "enabled"; - } - $this->is_modified= ($old != $this->FTPStatus)?TRUE:$this->is_modified; - - /* Ensure that these vars are numeric. Values starting with 0 like '0123' cause ldap errors */ - foreach(array("FTPQuotaFiles","FTPQuotaMBytes","FTPUploadRatio","FTPDownloadRatio","FTPUploadBandwidth","FTPDownloadBandwidth") as $testVar){ - $this->$testVar = (int) ($this->$testVar); - } - - - } - } - - - /* Check values */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* Check for positive integer values */ - if ($this->is_account){ - - if($this->acl_is_writeable("FTPUploadBandwidth") && !is_id($this->FTPUploadBandwidth)){ - $message[]= _("Value specified as 'Upload bandwidth' is not valid."); - } - if($this->acl_is_writeable("FTPDownloadBandwidth") && !is_id($this->FTPDownloadBandwidth)){ - $message[]= _("Value specified as 'Download bandwidth' is not valid."); - } - - if($this->acl_is_writeable("FTPQuotaFiles") && !is_id($this->FTPQuotaFiles)){ - $message[]= _("Value specified as 'Quota files' is not valid."); - } - if($this->acl_is_writeable("FTPQuotaMBytes") && !is_id($this->FTPQuotaMBytes)){ - $message[]= _("Value specified as 'Quota size' is not valid."); - } - if($this->acl_is_writeable("FTPUploadRatio") && !is_id($this->FTPUploadRatio)){ - $message[]= _("Value specified as 'Upload ratio' is not valid."); - } - if($this->acl_is_writeable("FTPDownloadRatio") && !is_id($this->FTPDownloadRatio)){ - $message[]= _("Value specified as 'Download ratio' is not valid."); - } - } - - return $message; - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $key => $desc){ - if(!$this->acl_is_writeable($key)){ - unset($this->attrs[$key]); - } - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/pureftpd account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - - } - - - /* Return plugin informations for acl handling - #FIME There possibly some attributes that can be combined to one acl. */ - static function plInfo() - { - return (array( - "plShortName" => _("Ftp"), - "plDescription" => _("Pure ftp account")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 22, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "FTPQuotaFiles" => _("Quota files"), - "FTPUploadRatio" => _("Upload ratio"), - "FTPQuotaMBytes" => _("Quota MBytes"), - "FTPDownloadRatio" => _("Download ratio"), - "FTPUploadBandwidth" => _("Upload bandwith"), - "FTPDownloadBandwidth" => _("Download bandwith"), - "FTPStatus" => _("Status")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/class_webdavAccount.inc b/plugins/personal/connectivity/class_webdavAccount.inc deleted file mode 100644 index 59fdb60ef..000000000 --- a/plugins/personal/connectivity/class_webdavAccount.inc +++ /dev/null @@ -1,171 +0,0 @@ -attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - } - - function execute() - { - /* Call parent execute */ -// plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Show tab dialog headers */ - $display= ""; - - /* Show main page */ - $smarty= get_smarty(); - - if ($this->is_account){ - $smarty->assign("webdavState", "checked"); - } else { - $smarty->assign("webdavState", ""); - $smarty->assign("wstate", "disabled"); - } - - if ($this->parent !== NULL){ - $smarty->assign("tabbed", 1); - } - - if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) { - $smarty->assign('webdavAccountACL', ""); - }else{ - $smarty->assign('webdavAccountACL', " disabled "); - } - - $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - if($this->acl_is_createable() || $this->is_account){ - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - plugin::remove_from_parent(); - $ldap= $this->config->get_ldap_link(); - - $ldap->cd($this->dn); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* Log last action */ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/webDAV account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove',array("uid" => $this->uid)); - } - } - - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - if (isset($_POST['webdav'])){ - if (!$this->is_account && $_POST['webdav'] == "B"){ - if($this->acl_is_createable()){ - $this->is_account= TRUE; - } - } - } else { - if($this->acl_is_removeable()){ - $this->is_account= FALSE; - } - } - } - - plugin::save_object(); - if (isset($_POST["WEBDAVStatus"])){ - $this->WEBDAVStatus = "disabled"; - } else { - $this->WEBDAVStatus = "enabled"; - } - } - - - /* Save to LDAP */ - function save() - { - if($this->acl_is_createable()){ - plugin::save(); - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/webDAV account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - } - } - - /* Return plugin informations for acl handling - #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */ - static function plInfo() - { - return (array( - "plShortName" => _("WebDAV"), - "plDescription" => _("WebDAV account")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 23, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array() - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/glpi.tpl b/plugins/personal/connectivity/glpi.tpl deleted file mode 100644 index 245b90303..000000000 --- a/plugins/personal/connectivity/glpi.tpl +++ /dev/null @@ -1 +0,0 @@ -

{if $tabbed eq 1}{/if}{t}GLPI account{/t}

diff --git a/plugins/personal/connectivity/intranet.tpl b/plugins/personal/connectivity/intranet.tpl deleted file mode 100644 index f768285fe..000000000 --- a/plugins/personal/connectivity/intranet.tpl +++ /dev/null @@ -1,4 +0,0 @@ -

- - {t}Intranet account{/t} -

diff --git a/plugins/personal/connectivity/kolab.tpl b/plugins/personal/connectivity/kolab.tpl deleted file mode 100644 index 8b7bd6ed1..000000000 --- a/plugins/personal/connectivity/kolab.tpl +++ /dev/null @@ -1,104 +0,0 @@ - -{if !$mail_account} -

{t}Kolab account{/t}

- {t}The kolab account is currently disabled. It's features can be adjusted if you add a mail account.{/t} -{else} - - - - - - -{t}Kolab account{/t} -
-
- - - - - - -
-
-{render acl=$kolabDelegateACL} - -{/render} -
-{render acl=$kolabDelegateACL} - -{/render} -{render acl=$kolabDelegateACL} -   -{/render} -{render acl=$kolabDelegateACL} - -{/render} -

- {t}Mail size{/t}
-{render acl=$unrestrictedMailSizeACL} -   {t}No mail size restriction for this account{/t} -{/render} -

-
-   - - - {t}Free Busy information{/t}
- - - - - - - - - -
-{render acl=$calFBURLACL} - -{/render} -
-{render acl=$kolabFreeBusyFutureACL} - - {t}days{/t} -{/render} -
- - - {t}Invitation policy{/t}
-{render acl=$kolabInvitationPolicyACL} - - {$invitation} -
-{/render} - -
- -{/if} diff --git a/plugins/personal/connectivity/main.inc b/plugins/personal/connectivity/main.inc deleted file mode 100644 index 14472f247..000000000 --- a/plugins/personal/connectivity/main.inc +++ /dev/null @@ -1,124 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('connectivity'); - } - - /* Create connectivity object on demand */ - if (!isset($_SESSION['connectivity']) || (isset($_GET['reset']) && - $_GET['reset'] == 1)){ - $_SESSION['connectivity']= new connectivity ($config, $ui->dn); - $_SESSION['connectivity']->enable_CSN_check(); - $_SESSION['connectivity']->set_acl_base($ui->dn); - $_SESSION['connectivity']->set_acl_category("users"); - - /* Adjust acl's to mode */ - foreach ($_SESSION['connectivity']->plugin_name as $name){ - $_SESSION['connectivity']->plugin[$name]->set_acl_category( "users"); - $_SESSION['connectivity']->plugin[$name]->set_acl_base($ui->dn); - } - } - $connectivity= $_SESSION['connectivity']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $connectivity->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if ((($username= get_lock($ui->dn)) != "") && (!isset($_SESSION['edit']))){ - $_SESSION['back_plugin']= $plug; - gen_locked_message ($username, $ui->dn); - exit (); - } - - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $connectivity->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $connectivity->save (); - del_lock ($ui->dn); - sess_del ('edit'); - - /* Remove from session */ - sess_del ('connectivity'); - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - $display= $connectivity->execute (); - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['connectivity']= $connectivity; - } - - $info= ""; - - $display.="
"; - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - $info.= "\"\""._("Click the 'Edit' button below to change informations in this dialog"); - $display.= "\n"; - $display.= "\n"; - } - $display.="
"; - - /* Page header*/ - $display= print_header(get_template_path('images/proxy.png'), - _("Connectivity"), $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/connectivity/opengw.tpl b/plugins/personal/connectivity/opengw.tpl deleted file mode 100644 index 568741719..000000000 --- a/plugins/personal/connectivity/opengw.tpl +++ /dev/null @@ -1,59 +0,0 @@ -

 {t}Opengroupware{/t}

- - - - - -
- - - - - - - - - - - - - -
- {t}Location team{/t}   - -{render acl=$LocationTeamACL} - -{/render} -
- {t}Template user{/t}   - -{render acl=$TemplateUserACL} - -{/render} -
- {t}Locked{/t}   - -{render acl=$LockedACL} - -{/render} -
-
- - - - - -
- {t}Teams{/t}   - -{render acl=$TeamsACL} - {$validTeams} -{/render} -
-
diff --git a/plugins/personal/connectivity/oxchange.tpl b/plugins/personal/connectivity/oxchange.tpl deleted file mode 100644 index 2bd204907..000000000 --- a/plugins/personal/connectivity/oxchange.tpl +++ /dev/null @@ -1,84 +0,0 @@ -{if !$pg} -

{t}Open-Xchange Account{/t} - {t}disabled, no Postgresql support detected. Or the specified database can't be reached{/t}

-{else} -

- -{t}Open-Xchange account{/t}

- - - - - - - - - - -
- - - - - - - - - - - - -
- {t}Remember{/t} -
- -{render acl=$OXAppointmentDaysACL} - -{/render} - {t}days{/t}
- -{render acl=$OXTaskDaysACL} - -{/render} - - {t}days{/t} -
-
-   - - - - - - - - - - - - - -
- {t}User Information{/t} -
- -{render acl=$OXTimeZoneACL} - -{/render} - -
-
-{/if} diff --git a/plugins/personal/connectivity/phpgw.tpl b/plugins/personal/connectivity/phpgw.tpl deleted file mode 100644 index 299da6716..000000000 --- a/plugins/personal/connectivity/phpgw.tpl +++ /dev/null @@ -1,4 +0,0 @@ -

- - {t}PHPGroupware account{/t} -

diff --git a/plugins/personal/connectivity/phpscheduleit.tpl b/plugins/personal/connectivity/phpscheduleit.tpl deleted file mode 100644 index 7e5510c3f..000000000 --- a/plugins/personal/connectivity/phpscheduleit.tpl +++ /dev/null @@ -1,4 +0,0 @@ -

- - {t}PHPscheduleit account{/t} -

diff --git a/plugins/personal/connectivity/pptp.tpl b/plugins/personal/connectivity/pptp.tpl deleted file mode 100644 index 15d28a792..000000000 --- a/plugins/personal/connectivity/pptp.tpl +++ /dev/null @@ -1,4 +0,0 @@ -

- - {t}PPTP account{/t} -

diff --git a/plugins/personal/connectivity/proxy.tpl b/plugins/personal/connectivity/proxy.tpl deleted file mode 100644 index 517823706..000000000 --- a/plugins/personal/connectivity/proxy.tpl +++ /dev/null @@ -1,114 +0,0 @@ -

- - {t}Proxy account{/t}

- - - - - -
- - - - - - - -
- -{render acl=$gosaProxyFlagFACL} - -{/render} - {t}Filter unwanted content (i.e. pornographic or violence related){/t} -
- -{render acl=$gosaProxyFlagTACL} - -{/render} - - -
- - - - -
- -{render acl=$gosaProxyFlagTACL} - -{/render} -  :  -{render acl=$gosaProxyFlagTACL} - -{/render} -  -  -{render acl=$gosaProxyFlagTACL} - -{/render} -  :  -{render acl=$gosaProxyFlagTACL} - -{/render} -
-
-   - -{render acl=$gosaProxyFlagBACL} - -{/render} - -
- - - - -
-{render acl=$gosaProxyFlagBACL} - -{/render} -   -{render acl=$gosaProxyFlagBACL} - -{/render} - - -{render acl=$gosaProxyFlagBACL} - -{/render} -
-
-
- diff --git a/plugins/personal/connectivity/pureftpd.tpl b/plugins/personal/connectivity/pureftpd.tpl deleted file mode 100644 index 714ef787b..000000000 --- a/plugins/personal/connectivity/pureftpd.tpl +++ /dev/null @@ -1,112 +0,0 @@ -

- - {t}FTP account{/t} -

- - - - - - - - - - - - - -
- - - - - - - - - - - - -
- {t}Bandwidth{/t} -
{t}Upload bandwidth{/t} -{render acl=$FTPUploadBandwidthACL} - -{/render} - {t}kb/s{/t}
{t}Download bandwidth{/t} -{render acl=$FTPDownloadBandwidthACL} - -{/render} - {t}kb/s{/t}
-
-   - - - - - - - - - - - - - -
- {t}Quota{/t} -
{t}Files{/t} -{render acl=$FTPQuotaFilesACL} - -{/render} -
{t}Size{/t} -{render acl=$FTPQuotaMBytesACL} - -{/render} - {t}MB{/t} -
-
- - - - - - - - -
- {t}Ratio{/t} -
{t}Uploaded / downloaded files{/t} - -{render acl=$FTPUploadRatioACL} - -{/render} - / -{render acl=$FTPDownloadRatioACL} - -{/render} -
-
- - - - - - -
- {t}Miscellaneous{/t} -
-{render acl=$FTPStatusACL} - -{/render} -{t}Temporary disable FTP access{/t}
-
- - - diff --git a/plugins/personal/connectivity/webdav.tpl b/plugins/personal/connectivity/webdav.tpl deleted file mode 100644 index ecd567cd3..000000000 --- a/plugins/personal/connectivity/webdav.tpl +++ /dev/null @@ -1,4 +0,0 @@ -

- - {t}WebDAV account{/t} -

diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc deleted file mode 100644 index 3d5de28c2..000000000 --- a/plugins/personal/environment/class_environment.inc +++ /dev/null @@ -1,1367 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = FALSE; - var $plHeadline = "Environment"; - var $plDescription = "This does something"; - var $dialog = false; // Indicates that we are currently editing in an seperate dialog - - var $in_dialog = false; - var $uid = ""; - - var $is_group = false; - var $view_logged = FALSE; - - /* Attribute definition - */ - - /* profile management */ - var $useProfile = false; // Specifies if we want to use a Server - var $gotoProfileServer = ""; // Specifies the selected profile server - var $gotoProfileServers = array();// Specifies all available and selectable servers - var $gotoProfileFlags = ""; // Flags enabled ? only used to set ACL and save - var $gotoProfileFlagC = ""; // Flag is set to C if we have the profile caching fucntion enabled - - var $gotoXResolution = "auto"; // The selected resolution eg: 1024x768 - var $gotoXResolutions = array();// Contains all available resolutions for this account - var $gotoProfileFlagL = ""; // Flag is set to L to enable runtime resolution change - var $gotoProfileQuota = ""; // User Quota Settings - - /* Logon script section*/ - var $gotoLogonScripts = array();// Contains all available Logon Scripts - var $gotoLogonScript = ""; // The selected Logon Script - - /* Printer */ - var $gotoPrinter = array();// All available Printer, with their configurations - var $gotoPrinterSel = ""; // The selected Printer - var $gosaDefaultPrinter = ""; // Default printer - - /* Share */ - var $gotoShares = array();// Current Share Options - var $gotoShare = ""; // currently selected Share Option - var $gotoShareSelections= array();// Available Shares for this account in Listbox format - var $gotoAvailableShares= array();// Available Shares for this account - - /* Kiosk profile */ - var $kiosk_enabled = FALSE; - var $gotoKioskProfile = ""; // The selected Kiosk Profile - var $gotoKioskProfile_Server = ""; // The selected Kiosk Profile - var $gotoKioskProfile_Profile = ""; // The selected Kiosk Profile - var $gotoKioskProfiles = array();// All available Kiosk profiles - - /* Hotplug Devices */ - var $gotoHotplugDevice = array(); // Selected hotplug - var $gotoHotplugDevices = array();// Already configured hotplug devices - var $gotoHotplugDeviceDN= array(); - - var $NewAddedPrinters = array(); - var $NewDeletedPrinters = array(); - - /* general settings */ - // Sets the attributes which will kept on page reload, which will be saved, ... - - var $CopyPasteVars = array("gotoHotplugDevices","gotoAvailableShares","gotoShareSelections","gotoPrinterSel","gotoProfileFlagL","gotoXResolutions","gotoProfileFlagC","gotoProfileServers","useProfile","is_group","in_dialog","OrigCn","gotoKioskProfile_Server","gotoKioskProfile_Profile"); - - var $attributes = array("uid","gotoProfileServer","gotoProfileFlags","gotoHotplugDeviceDN", - "gotoXResolution","gotoProfileQuota", - "gotoLogonScripts","gotoLogonScript", - "gotoPrinter", "gosaDefaultPrinter", - "gotoShares","gotoShare", - "gotoKioskProfile"); - var $objectclasses = array("gotoEnvironment"); // Specifies the objectClass which contains the attributes edited here - var $cn; - var $OrigCn; - var $add_del_printer_member_was_called = false; - - function environment (&$config, $dn= NULL) - { - plugin::plugin ($config, $dn); - - /* Setting uid to default */ - if(isset($this->attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - /* Check : Are we currently editing a group or user dialog */ - if((isset($this->attrs['cn'][0]))&&(!isset($this->attrs['uid'][0]))){ - $suffix="Group"; - $this->uid = $this->attrs['cn'][0]; - $this->attrs['uid'] = $this->attrs['cn'][0]; - $this->OrigCn = $this->attrs['cn'][0]; - }else{ - $suffix="User"; - } - - /* Get all Printer assignments */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoPrinter)(goto".$suffix."Printer=".$this->uid."))",array("*")); - while($printer = $ldap->fetch()){ - $this->gotoPrinter[$printer['cn'][0]]=$printer; - $this->gotoPrinter[$printer['cn'][0]]['mode']="user"; - } - $ldap->search("(&(objectClass=gotoPrinter)(goto".$suffix."AdminPrinter=".$this->uid."))",array("*")); - while($printer = $ldap->fetch()){ - $this->gotoPrinter[$printer['cn'][0]]=$printer; - $this->gotoPrinter[$printer['cn'][0]]['mode']="admin"; - } - - - /* Prepare hotplugs */ - if(isset($this->attrs['gotoHotplugDeviceDN']) && is_array($this->attrs['gotoHotplugDeviceDN'])){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - for($i = 0 ; $i < $this->attrs['gotoHotplugDeviceDN']['count'] ; $i ++){ - $ldap->cat($this->attrs['gotoHotplugDeviceDN'][$i]); - if($ldap->count()){ - $attrs = $ldap->fetch(); - - if(isset($attrs['gotoHotplugDevice'][0])){ - $tmp = preg_split("/\|/",$attrs['gotoHotplugDevice'][0]); - $tmp2 = array(); - $tmp2['name'] = $attrs['cn'][0]; - $tmp2['description'] = $tmp[0]; - $tmp2['id'] = $tmp[1]; - $tmp2['produkt'] = $tmp[2]; - $tmp2['vendor'] = $tmp[3]; - $tmp2['dn'] = $attrs['dn']; - $this->gotoHotplugDevices[] = $tmp2; - } - }else{ - print_red(sprintf(_("The selected hotplug device %s is no longer available, it will be removed when you save this account."),$this->attrs['gotoHotplugDeviceDN'][$i])); - } - } - } - - - /* prepare LogonScripts */ - if((isset($this->attrs['gotoLogonScript']))&&(is_array($this->attrs['gotoLogonScript']))){ - unset($this->attrs['gotoLogonScript']['count']); - foreach($this->attrs['gotoLogonScript'] as $device){ - $tmp = $tmp2 = array(); - $tmp = split("\|",$device); - $tmp2['LogonName'] = $tmp[0]; - $tmp2['LogonPriority'] = $tmp[2]; - if(preg_match("/O/i",$tmp[1])){ - $tmp2['LogonOverload'] = "O"; - }else{ - $tmp2['LogonOverload'] = ""; - } - if(preg_match("/L/i",$tmp[1])){ - $tmp2['LogonLast'] = "L"; - }else{ - $tmp2['LogonLast'] = ""; - } - $tmp2['LogonData'] = base64_decode($tmp[3]); - $tmp2['LogonDescription'] = $tmp[4]; - $this->gotoLogonScripts[$tmp[0]]=$tmp2; - } - } - - /* Prepare Shares */ - if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){ - unset($this->attrs['gotoShare']['count']); - foreach($this->attrs['gotoShare'] as $share){ - $tmp = $tmp2 = array(); - $tmp = split("\|",$share); - $tmp2['server'] =$tmp[0]; - $tmp2['name'] =$tmp[1]; - - /* Decode base64 if needed */ - if (!preg_match('%/%', $tmp[2])){ - $tmp2['mountPoint'] =base64_decode($tmp[2]); - } else { - $tmp2['mountPoint'] =$tmp[2]; - } - - if(isset($tmp[3])){ - $tmp2['PwdHash'] =$tmp[3]; - }else{ - $tmp2['PwdHash'] =""; - } - if(isset($tmp[4])){ - $tmp2['Username'] =$tmp[4]; - }else{ - $tmp2['Username'] =""; - } - $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; - } - } - - for($i = 0 ; $i < strlen($this->gotoProfileFlags) ; $i ++){ - $chr = $this->gotoProfileFlags[$i]; - $name = "gotoProfileFlag".$chr; - $this->$name=$chr; - } - - if((!empty($this->gotoProfileServer))||($this->gotoProfileFlagC=="C")){ - $this->useProfile = true; - }else{ - $this->useProfile = false; - } - - /* Set resolutions */ - $this->gotoXResolutions = array("auto"=>_("auto"), - "640x480" => "640x480", - "800x600" => "800x600", - "1024x768" => "1024x768", - "1152x864" => "1152x864", - "1280x768" => "1280x768", - "1280x1024" => "1280x1024"); - - if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){ - $file = $this->config->data['MAIN']['RESOLUTION_HOOK']; - - if(is_readable($file)){ - $str = file_get_contents($file); - $lines = split("\n",$str); - foreach($lines as $line){ - $line = trim($line); - if(!empty($line)){ - $this->gotoXResolutions[$line]=$line; - } - } - //natcasesort($this->gotoXResolutions); - }else{ - print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file)); - } - } - - $this->gotoProfileServers= $config->getShareServerList() ; - $this->gotoShareSelections= $config->getShareList(true); - $this->gotoAvailableShares= $config->getShareList(false); - - $this->update_kiosk_profiles(); - - $this->gotoKioskProfile= preg_replace("/^.*\//i","",$this->gotoKioskProfile); - } - - - function update_kiosk_profiles() - { - $tmp1 = array("none" => array(_("disabled"))); - $tmp2 = array("none" => _("disabled")); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=goEnvironmentServer)(gotoKioskProfile=*)(cn=*))",array("cn","gotoKioskProfile")); - $cnt = 0; - while($attrs = $ldap->fetch()){ - for($i = 0 ; $i < $attrs['gotoKioskProfile']['count'] ; $i ++){ - $name = preg_replace("/^.*kiosk\//","",$attrs['gotoKioskProfile'][$i]); - $tmp1[$attrs['cn'][0]][] = $name; - } - $tmp2[$attrs['cn'][0]]= $attrs['cn'][0]; - $cnt ++; - } - - if($cnt && $this->config->search("environment","kioskpath",array('menu','tabs'))){ - $this->kiosk_enabled = TRUE; - } - - $this->gotoKioskProfiles['BY_SERVER'] = $tmp1; - $this->gotoKioskProfiles['SERVERS'] = $tmp2; - - $this->gotoKioskProfile_Server = preg_replace("/^.*:\/\/([^\/]*).*$/","\\1",$this->gotoKioskProfile); - $this->gotoKioskProfile_Profile= preg_replace("/^.*\//","",$this->gotoKioskProfile); - - $error = false; - if(!in_array($this->gotoKioskProfile_Server, $this->gotoKioskProfiles['SERVERS'])){ - $this->gotoKioskProfile_Server = key($this->gotoKioskProfiles['SERVERS']); - $error = true; - } - if(!in_array($this->gotoKioskProfile_Profile, $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server])){ - $this->gotoKioskProfile_Profile = $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server][0]; - $error = true; - } - if($error && !empty($this->gotoKioskProfile)){ - print_red(sprintf(_("The selected kiosk profile wasn't available anymore. The current profile is now 'none'."), - $this->gotoKioskProfile_Server,$this->gotoKioskProfile_Profile)); - } - } - - - /* Detect type of edited object (user|group)*/ - function detect_grouptype() - { - if((!isset($this->parent))&&(!$this->is_account)){ - $this->is_group = false; - }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){ - $this->is_group = true; - }else{ - $this->is_group = false; - } - } - - - function execute() - { - - /* Call parent execute */ - plugin::execute(); - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - if(isset($this->parent->by_object['user']) || (isset($this->attrs['objectClass']) &&in_array("gosaAccount",$this->attrs['objectClass']))){ - new log("view","users/".get_class($this),$this->dn); - }else{ - new log("view","groups/".get_class($this),$this->dn); - } - } - - /* Are we editing from MyAccount and not editing a user */ - $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']); - - /* Check profile server */ - if($this->acl_is_writeable("gotoProfileServer",$WriteOnly)){ - if(!empty($this->gotoProfileServer) && !isset($this->gotoProfileServers[$this->gotoProfileServer])){ - if(count($this->gotoProfileServers)){ - - /* Get First Profile */ - $new = key($this->gotoProfileServers); - - /* Another profile server found */ - print_red(sprintf(_("Your selected profile server '%s' is no longer available. Setting profile server to '%s'."), - $this->gotoProfileServer,$new)); - }else{ - - /* No other profile servers found */ - print_red(sprintf(_("Your selected profile server '%s' is no longer available. Profile server configuration is resetted."), - $this->gotoProfileServer)); - $this->gotoProfileServer = ""; - } - } - } - - $this->detect_grouptype(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $smarty->assign("kiosk_enabled",$this->kiosk_enabled); - $display= ""; - - $smarty->assign("is_group",$this->is_group); - - /* Prepare all variables for smarty */ - foreach($this->attributes as $s_attr){ - /* Set value*/ - $smarty->assign($s_attr,$this->$s_attr); - - /* Set checkbox state*/ - if(empty($this->$s_attr)){ - $smarty->assign($s_attr."CHK",""); - }else{ - $smarty->assign($s_attr."CHK"," checked "); - } - - /* Prepare ACL settings*/ - $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly)); - } - - /* Is accout enabled | are we editing from usermenu or admin menu - All these tab management is done here - */ - - - /* Working from Usermenu an the Account is currently disbled - * this->parent : is only set if we are working in a list of tabs - * is_account : is only true if the needed objectClass is given - */ - if((!isset($this->parent))&&(!$this->is_account)){ - /* We are currently editing this tab from usermenu, but this account is not enabled */ - $smarty->assign("is_account",$this->is_account); - /* Load template */ - $display .= $smarty->fetch(get_template_path('environment.tpl', TRUE)); - /* Avoid the "You are currently editing ...." message when you leave this tab */ - $display .= back_to_main(); - /* Display our message to the user */ - return $display; - - - /* We are currently editing from group tabs, because - * $this->parent is set - * posixAccount is not set, so we are not in usertabs. - */ - }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){ - $smarty->assign("is_account","true"); - $this->uid = $this->cn; - $this->attrs['uid'] = $this->cn; - - /* Change state if needed */ - if (isset($_POST['modify_state'])){ - if(($this->acl_is_createable() && !$this->is_account) || - ($this->acl_is_removeable() && $this->is_account)){ - $this->is_account= !$this->is_account; - } - } - /* Group Dialog with enabled environment options */ - if ($this->is_account){ - $display= $this->show_enable_header(_("Remove environment extension"), - _("Environment extension enabled. You can disable it by clicking below.")); - } else { - - /* Environment is disabled - If theres is no posixAccount enabled, you won't be able to enable - environment extensions - */ - if((isset($this->parent->by_object['group']))||(isset($this->attrs['objectClass']))&&((in_array("posixAccount",$this->attrs['objectClass'])))){ - // 4. There is a PosixAccount - $display= $this->show_enable_header(_("Add environment extension"), - _("Environment extension disabled. You can enable it by clicking below.")); - return $display; - }else{ - // 4. There is no PosixAccount - $display= $this->show_enable_header(_("Add environment extension"), - _("Environment extension disabled. You have to setup a posix account before you can enable this feature.")); - return $display; - } - } - }else{ - /* Editing from Usermenu - * Tell smarty that this accoutn is enabled - */ - $smarty->assign("is_account","true"); - - /* Change state if needed */ - if (isset($_POST['modify_state'])){ - if(($this->acl_is_createable() && !$this->is_account) || - ($this->acl_is_removeable() && $this->is_account)){ - $this->is_account= !$this->is_account; - } - } - - if(isset($this->parent)){ - - // 3. Account enabled . Editing from adminmenu - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove environment extension"), - _("Environment extension enabled. You can disable it by clicking below.")); - } else { - - if($this->parent->by_object['posixAccount']->is_account==true){ - // 4. There is a PosixAccount - $display= $this->show_disable_header(_("Add environment extension"), - _("Environment extension disabled. You can enable it by clicking below.")); - return $display; - }else{ - // 4. There is a PosixAccount - $display= $this->show_disable_header(_("Add environment extension"), - _("Environment extension disabled. You have to setup a posix account before you can enable this feature."),TRUE,TRUE); - return $display; - } - } - } - } - /* Account is Account : is_accounbt=true. - * Else we won't reach this. - */ - - /* Prepare all variables for smarty */ - foreach($this->attributes as $s_attr){ - /* Set value*/ - $smarty->assign($s_attr,$this->$s_attr); - - /* Set checkbox state*/ - if(empty($this->$s_attr)){ - $smarty->assign($s_attr."CHK",""); - }else{ - $smarty->assign($s_attr."CHK"," checked "); - } - - /* Prepare ACL settings*/ - $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly)); - } - - foreach(array("gotoHotplugDevice","gotoProfileFlagC","gotoProfileFlagL") as $s_attr){ - $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly)); - } - - if($WriteOnly) { - $smarty->assign("gotoPrinterACL","r"); - }else{ - $smarty->assign("gotoPrinterACL","rw"); - } - - if(empty($this->useProfile)){ - $smarty->assign("useProfileCHK",""); - $smarty->assign("gotoProfileServerACL" , preg_replace("/w/","",$this->getacl("gotoProfileServer",$WriteOnly))); - $smarty->assign("gotoProfileQuotaACL" , preg_replace("/w/","",$this->getacl("gotoProfileQuota",$WriteOnly))); - $smarty->assign("gotoProfileFlagCACL" , preg_replace("/w/","",$this->getacl("gotoProfileFlagC",$WriteOnly))); - }else{ - $smarty->assign("useProfileCHK"," checked "); - } - - $smarty->assign("gotoProfileServerWriteable", $this->acl_is_writeable("gotoProfileServer",$WriteOnly)); - $smarty->assign("gotoProfileACL", $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly)); - - /* HANDLE Profile Settings here - * Assign available Quota and resolution settings - * Get all available profile server - * Get cache checkbox - * Assign this all to Smarty - */ - - if(empty($this->gotoProfileFlagL)){ - $smarty->assign("gotoProfileFlagLCHK"," "); - }else{ - $smarty->assign("gotoProfileFlagLCHK"," checked "); - } - - if(empty($this->gotoProfileFlagC)){ - $smarty->assign("gotoProfileFlagCCHK"," "); - }else{ - $smarty->assign("gotoProfileFlagCCHK"," checked "); - } - - - $smarty->assign("gotoXResolutions" , $this->gotoXResolutions); - $smarty->assign("gotoXResolutionKeys" , array_flip($this->gotoXResolutions)); - - $smarty->assign("gotoProfileServers",$this->gotoProfileServers); - if(!is_array($this->gotoProfileServers)){ - $this->gotoProfileServers =array(); - } - $smarty->assign("gotoProfileServerKeys",array_flip($this->gotoProfileServers)); - - /* Handle kiosk profiles*/ - $smarty->assign("kiosk_servers" , $this->gotoKioskProfiles['SERVERS']); - $smarty->assign("kiosk_server" , $this->gotoKioskProfile_Server); - $smarty->assign("kiosk_profiles" , $this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server]); - $smarty->assign("kiosk_profile" , $this->gotoKioskProfile_Profile); - - - /* Logonscript Management - * Get available LogonScripts (possibly grey out (or mark) these script that are defined for the group) - * Perform add Delete edit Posts - */ - - /* Dialog Save */ - if(isset($_POST['LogonSave'])){ - - if(!$this->acl_is_writeable("gotoLogonScript")){ - print_red(_("You are not allowed to write Logon scripts.")); - unset($this->dialog); - $this->dialog=FALSE; - $this->is_dialog=false; - }else{ - $this->dialog->save_object(); - if(count($this->dialog->check())!=0){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } - }else{ - $tmp = $this->dialog->save(); - unset($this->dialog); - $this->dialog=FALSE; - $this->is_dialog=false; - $this->gotoLogonScripts[$tmp['LogonName']]=$tmp; - } - } - } - - - /* Dialog Quit without saving */ - if(isset($_POST['LogonCancel'])){ - $this->is_dialog= false; - unset($this->dialog); - $this->dialog= FALSE; - } - - /* Check Edit Del New Posts for a selected LogonScript */ - if($this->acl_is_writeable("gotoLogonScript") && - (isset($_POST['gotoLogonScriptNew'])) || isset($_POST['gotoLogonScriptEdit']) ||isset($_POST['gotoLogonScriptDel'])){ - - /* New Logon Script: Open an edit dialog, we don't need a $_POST['gotoLogonScript'] here. - * In this case we create a new Logon Script. - */ - if(isset($_POST['gotoLogonScriptNew'])){ - $this->is_dialog = true; - $this->dialog = new logonManagementDialog($this->config,$this->dn); - } - - /* If we receive a Delete request and there is a Script selected in the selectbox, delete this one. - * We only can delete if there is an entry selected. - */ - if((isset($_POST['gotoLogonScriptDel']))&&(isset($_POST['gotoLogonScript']))){ - unset($this->gotoLogonScripts[$_POST['gotoLogonScript']]); - } - - /* In this case we want to edit an existing entry, we open a new Dialog to allow editing. - * There must be an entry selected to perform edit request. - */ - if((isset($_POST['gotoLogonScriptEdit']))&&(isset($_POST['gotoLogonScript']))){ - $is_entry = $this->gotoLogonScripts[$_POST['gotoLogonScript']]; - $this->is_dialog = true; - $this->dialog = new logonManagementDialog($this->config,$this->dn,$is_entry); - } - } - - /* Append List to smarty*/ - $ls = $this->printOutLogonScripts(); - $smarty->assign("gotoLogonScripts", $ls); - $smarty->assign("gotoLogonScriptKeys",array_flip($ls)); - $smarty->assign("gotoLogonScriptKeysCnt",count($ls)); - - /* In this section server shares will be defined - * A user can select one of the given shares and a mount point - * and attach this combination to his setup. - */ - - $smarty->assign("gotoShareSelections", $this->gotoShareSelections); - if(!is_array($this->gotoShareSelections)){ - print $this->gotoShareSelections; - $this->gotoShareSelections = array(); - } - $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections)); - - /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry - * This entry will be, a combination of mountPoint and sharedefinitions - */ - if(isset($_POST['gotoShareAdd']) && $this->acl_is_writeable("gotoShare")){ - - /* We assign a share to this user, if we don't know where to mount the share */ - if(!isset($_POST['gotoShareSelection']) || get_post('gotoShareSelection') == ""){ - print_red(_("You must select a valid share.")); - }elseif((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){ - print_red(_("You must specify a valid mount point.")); - }elseif(preg_match('/ /', $_POST['gotoShareMountPoint'])){ - print_red(_("Spaces are not allowed in the mount path!")); - }elseif(!( - preg_match("/^\//",$_POST['gotoShareMountPoint']) || - preg_match("/^~/",$_POST['gotoShareMountPoint']) || - preg_match("/^\$HOME/",$_POST['gotoShareMountPoint']) || - preg_match("/^.HOME/",$_POST['gotoShareMountPoint']) || - preg_match("/^\$USER/",$_POST['gotoShareMountPoint']) || - preg_match("/^.USER/",$_POST['gotoShareMountPoint']) || - preg_match("/^%/",$_POST['gotoShareMountPoint']) - ) - ){ - print_red(_("You must specify a valid mount point.")); - }else{ - $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']]; - $s_mount = $_POST['gotoShareMountPoint']; - $s_user = $_POST['ShareUser']; - /* Preparing the new assignment */ - $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share; - $this->gotoShares[$a_share['name']."|".$a_share['server']]['Username']=$s_user; - $this->gotoShares[$a_share['name']."|".$a_share['server']]['PwdHash']=""; - $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount; - } - } - - /* if the Post gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected) - * If there is no defined share selected, we will abort the deletion without any message - */ - $once = true; - if($this->acl_is_writeable("gotoShare")){ - foreach($_POST as $name => $value){ - if((preg_match("/^gotoShareDel_/",$name)) && ($once)){ - $once = false; - $key = preg_replace("/^gotoShareDel_/","",$name); - $key = preg_replace("/_+[xy]$/","",$key); - $key = base64_decode($key); - if(isset($this->gotoShares[$key])) { - unset($this->gotoShares[$key]); - } - - /* Remove corresponding password entry, too. This is a workaround - to get rid of old-style entries. */ - $key= preg_replace("/\|/", "|!", $key); - if(isset($this->gotoShares[$key])) { - unset($this->gotoShares[$key]); - } - } - if((preg_match("/^gotoShareResetPwd_/",$name)) && ($once)){ - $once = false; - $key = preg_replace("/^gotoShareResetPwd_/","",$name); - $key = preg_replace("/_+[xy]$/","",$key); - $key = base64_decode($key); - $this->gotoShares[$key]['PwdHash'] = ""; - if(preg_match("/^!/",$this->gotoShares[$key]['server'])){ - unset($this->gotoShares[$key]); - } - } - } - } - $divlistShares = new divSelectBox("gotoShares"); - $divlistShares->SetHeight(100); - - - $tmp = array(); - if($this->acl_is_readable("gotoShares")){ - $tmp = $this->printOutAssignedShares(); - } - - - foreach($tmp as $key => $value){ - $img = ""; - - /* Skip apssword only entries */ - if( empty($this->gotoShares[$key]['server']) && - empty($this->gotoShares[$key]['name']) && - empty($this->gotoShares[$key]['mountPoint']) && - empty($this->gotoShares[$key]['Username'])){ - continue; - } - - /* Check if entry starts with an ! */ - if(preg_match("/^!/",$this->gotoShares[$key]['server'])){ - - /* If we are currently editing groups environment, skip those ! entries */ - if($this->is_group) continue; - - /* Create pwd reset images */ - if($this->gotoShares[$key]['PwdHash'] != ""){ - $img.= ""; - } - $field1 = array("string" => "".$value."" ); - $field2 = array("string" => $img , "attach" => "style='border-right:0px;'"); - }else{ - - /* Create pwd reset img && delete image */ - if($this->gotoShares[$key]['PwdHash'] != ""){ - $img.= ""; - $img.= " "; - } - $img.= ""; - $field1 = array("string" => $value); - $field2 = array("string" => $img , "attach" => "style='border-right:0px;'"); - } - $divlistShares->AddEntry(array($field1,$field2)); - } - $smarty->assign("divlistShares",$divlistShares->DrawList()); - - /* Hotplug devices will be handled here - * There are 3 possible methods for this feature - * Create a new Hotplug, A Dialog will open where you can specify some hotplug information - * Delete will erase an entry, the entry must be selcted in the ListBox first - * Editing an entry will open a dialog where the informations about the selcted entry can be changed - */ - - /* We have to delete the selected hotplug from the list*/ - if((isset($_POST['gotoHotplugDeviceDel']))&&(isset($_POST['gotoHotplugDevice_post'])) && $this->acl_is_writeable("gotoHotplugDevice")){ - if($this->acl_is_writeable("gotoHotplugDevice")){ - foreach($_POST['gotoHotplugDevice_post'] as $name){ - unset($this->gotoHotplugDevices[$name]); - } - } - } - - /* There are already defined hotplugs from other users we could use */ - if(isset($_POST['gotoHotplugDeviceUse']) && $this->acl_is_writeable("gotoHotplugDevice")){ - $tmp =array(); - foreach($this->gotoHotplugDevices as $plugs){ - $tmp[] = $plugs['name']; - } - $this->dialog = new hotplugDialog($this->config,$tmp); - $this->is_dialog = true; - } - - /* Dialog Aborted */ - if(isset($_POST['HotPlugCancel'])){ - unset($this->dialog); - $this->dialog= FALSE; - $this->is_dialog = false; - } - - /* Dialod saved */ - if(isset($_POST['HotPlugSave'])){ - - $this->dialog->save_object(); - if(count($this->dialog->check())!=0){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } - }else{ - $this->dialog->save_object(); - $a_tmp = $this->dialog->save(); - - if(is_array($a_tmp)){ - foreach($a_tmp as $name => $hotplug){ - $this->gotoHotplugDevices[$name]= $hotplug; - } - } - unset($this->dialog); - $this->dialog= FALSE; - $this->is_dialog = false; - } - } - $smarty->assign("gotoHotplugDevices",$this->printOutHotPlugDevices()); - $smarty->assign("gotoHotplugDeviceKeys",array_flip($this->printOutHotPlugDevices())); - - /* Printer Assignment will managed below - * A printer can be assigned in two different ways and two different types - * There are 2 types of users assigned to a printer : user and admin - * They only differ in the member attribute they will be assigned to. user: gotoUserPrinter admin: gotoadminPrinter - * The different types of assigning a user are : 1 assigning a user to a printer 2. assigning a group to a printer - */ - - /* First handle Add Post. Open a dialog that allows us to select a printer or two */ - if(isset($_POST['gotoPrinterAdd'])){ - - $this->is_dialog=true; - $this->dialog = new selectPrinterDialog($this->config,$this->dn,$this->gotoPrinter); - } - - if(isset($_POST['PrinterCancel'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=FALSE; - } - - if(isset($_POST['PrinterSave'])){ - if(count($this->dialog->check())!=0){ - $tmp = $this->dialog->check(); - foreach($tmp as $msg){ - print_red($msg); - } - }else{ - $this->dialog->save_object(); - $tmp = $this->dialog->save(); - $tmp2= $this->dialog->getPrinter(true); - - foreach($tmp as $pname){ - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn'],"printer"); - $printerObj->set_acl_base($tmp2[$pname]['dn']); - - $type = false; - - if($this->is_group){ - if($this->dn == "new"){ - $type = "AddGroup"; - }elseif(isset($this->NewDeletedPrinters[$pname])){ - $type = "AddGroup"; - }elseif($printerObj->by_object['printgeneric']->AddMember("AddGroup",$this->dn)){ - $type = "AddGroup"; - } - }else{ - if(isset($this->NewDeletedPrinters[$pname])){ - $type = "AddUser"; - }elseif($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){ - $type = "AddUser"; - } - } - - if($type){ - $this->gotoPrinter[$pname]=$tmp2[$pname]; - $this->gotoPrinter[$pname]['mode']="user"; - $this->add_del_printer_member_was_called = true; - - $this->NewAddedPrinters[$pname] = $pname; - if(isset($this->NewDeletedPrinters[$pname])){ - unset($this->NewDeletedPrinters[$pname]); - } - } - } - - $this->is_dialog=false; - unset($this->dialog); - $this->dialog =FALSE; - } - } - - if((isset($_POST['gotoPrinterDel']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){ - $printer = $_POST['gotoPrinterSel']; - foreach($printer as $pname){ - - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$this->gotoPrinter[$pname]['dn'],"printer"); - $printerObj->set_acl_base($this->gotoPrinter[$pname]['dn']); - - $type = false; - if($this->is_group){ - if(isset($this->NewAddedPrinters[$pname])){ - $type = "Group"; - }elseif($printerObj->by_object['printgeneric']->DelMember("AddGroup",$this->cn)){ - $type = "Group"; - } - }else{ - if(isset($this->NewAddedPrinters[$pname])){ - $type = "User"; - }elseif($printerObj->by_object['printgeneric']->DelMember("AddUser",$this->uid)){ - $type = "User"; - } - } - if($type){ - $this->add_del_printer_member_was_called = true; - unset($this->gotoPrinter[$pname]); - - $this->NewDeletedPrinters[$pname] = $pname; - if(isset($this->NewAddedPrinters[$pname])){ - UNSET($this->NewAddedPrinters[$pname]); - } - } - } - } - - if((isset($_POST['gotoPrinterEdit']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){ - $printers = $_POST['gotoPrinterSel']; - $this->add_del_printer_member_was_called = true; - foreach($printers as $printer){ - if($this->gotoPrinter[$printer]['mode']=="user"){ - $this->gotoPrinter[$printer]['mode']="admin"; - }else{ - $this->gotoPrinter[$printer]['mode']="user"; - } - } - } - - if((isset($_POST['gotoPrinterDefault']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){ - if($this->is_group){ - print_red(_("GOsa default printer flag is not allowed within groups.")); - }else{ - if ($this->gosaDefaultPrinter == $_POST['gotoPrinterSel'][0]){ - $this->gosaDefaultPrinter= ""; - } else { - $this->gosaDefaultPrinter= $_POST['gotoPrinterSel'][0]; - } - } - } - - $smarty->assign("gotoPrinter",$this->printOutPrinterDevices()); - $smarty->assign("gotoPrinterKeys",array_flip($this->printOutPrinterDevices())); - - /* General behavior */ - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $disp =$this->dialog->execute(); - return($disp); - } - - /* Als smarty vars are set. Get smarty template and generate output */ - $display.= $smarty->fetch(get_template_path('environment.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - function remove_from_parent() - { - /* only if it was an account*/ - if (!$this->initially_was_account){ - return; - } - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - /* Don't save our template variables */ - $skip = array("uid","gotoLogonScripts","gotoPrinter","gotoShares","gotoHotplugDevices" ); - - /* Skip all these attributes */ - foreach($skip as $del){ - unset($this->attrs[$del]); - } - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save"); - - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - if($this->is_group){ - new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/environment account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove",array("uid" => $this->uid)); - } - - - /* Save data to object */ - function save_object() - { - /* Get all Posted vars - * Setup checkboxes - */ - $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']); - if(isset($_POST['iamposted'])){ - - $PACL = $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly); - - if(isset($_POST['kiosk_server'])){ - $tmp = $_POST['kiosk_server']; - if(isset($this->gotoKioskProfiles['SERVERS'][$tmp])){ - $this->gotoKioskProfile_Server = $_POST['kiosk_server']; - } - } - if(isset($_POST['kiosk_profile'])){ - $tmp = $_POST['kiosk_profile']; - if(in_array($tmp,$this->gotoKioskProfiles['BY_SERVER'][$this->gotoKioskProfile_Server])){ - $this->gotoKioskProfile_Profile = $_POST['kiosk_profile']; - } - } - - if(preg_match("/w/",$PACL)){ - if(isset($_POST['useProfile'])){ - $this->useProfile = true; - }else{ - $this->useProfile = false; - } - } - - if($this->acl_is_writeable("gotoProfileFlagC")){ - if(isset($_POST['gotoProfileFlagC'])){ - $this->gotoProfileFlagC = $_POST['gotoProfileFlagC']; - }else{ - $this->gotoProfileFlagC = false; - } - } - - if($this->acl_is_writeable("gotoProfileFlagL")){ - if(isset($_POST['gotoProfileFlagL'])){ - $this->gotoProfileFlagL = $_POST['gotoProfileFlagL']; - }else{ - $this->gotoProfileFlagL = false; - } - } - - plugin::save_object(); - foreach($this->attributes as $s_attr){ - if((!isset($_POST[$s_attr])) || - in_array($s_attr,array("gosaDefaultPrinter","gotoShares","gotoHotplugDevices","gotoPrinter","gotoLogonScripts","uid"))) continue; - if(!$this->acl_is_writeable($s_attr)){ - continue; - }else{ - if(isset($_POST[$s_attr])){ - $this->$s_attr = $_POST[$s_attr]; - }else{ - $this->$s_attr = false; - } - } - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - $this->detect_grouptype(); - - if(preg_match("/[^0-9]/",$this->gotoProfileQuota)) { - $message[]=_("Please set a valid profile quota size."); - } - if(!isset($this->attrs['objectClass'])){ - $this->attrs['objectClass']=array(); - } - if(!$this->is_group){ - if((!((in_array("posixAccount",$this->attrs['objectClass']))||($this->parent->by_object['posixAccount']->is_account==true)))&&(!$this->is_group)){ - $message[]=(_("You need to setup a valid posix extension in order to enable evironment features.")); - } - } - return ($message); - } - - - /* Save to LDAP */ - function save() - { - /* If group was renamed, all printer settings get lost - */ - /* only save changed variables ....*/ - if ($this->gotoKioskProfile_Server != "none"){ - if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ - $method="https://".$this->gotoKioskProfile_Server."/kiosk/".$this->gotoKioskProfile_Profile; - }else{ - $method="http://".$this->gotoKioskProfile_Server."/kiosk/".$this->gotoKioskProfile_Profile; - } - $this->gotoKioskProfile= $method; - }else{ - $this->gotoKioskProfile= array(); - } - - plugin::save(); - $ldap= $this->config->get_ldap_link(); - - $realyUsedAttrs= array(); - - /* Save already used objectClasses */ - $ocs = $this->attrs['objectClass']; - unset($ocs['count']); - $this->attrs = array(); - $this->attrs['objectClass']= gosa_array_merge($ocs,$this->objectclasses); - - /* 1. Search all printers that have our uid/cn as member - * 2. Delete this uid/cn from every single entry and save it again. - * 2.1 There are different types of members: Users / Groups, this will be defined in $suffix - * 2.2 And each type has two modes, Admin (e.g. 'gotoUserAdminPrinter') and Normal - */ - - $this->detect_grouptype(); - - if($this->add_del_printer_member_was_called){ - - $types = array( "gotoUserPrinter" => "AddUser", - "gotoGroupPrinter" => "AddGroup", - "gotoUserAdminPrinter" => "AddAdminUser", - "gotoGroupAdminPrinter" => "AddAdminGroup"); - - if($this->is_group){ - $s_suffix = "Group"; - $useVar = "cn"; - }else{ - $useVar = "uid"; - $s_suffix = "User"; - } - - /* Remove old entries */ - $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->$useVar."))",array("*")); - while($attr = $ldap->fetch()){ - $printerObj = NULL; - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer"); - $printerObj->set_acl_base($attr['dn']); - $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->$useVar); - $printerObj->by_object['printgeneric']->save(); - } - - $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->$useVar."))",array("*")); - while($attr = $ldap->fetch()){ - $printerObj = NULL; - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer"); - $printerObj->set_acl_base($attr['dn']); - $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->$useVar); - $printerObj->by_object['printgeneric']->save(); - } - - foreach($this->gotoPrinter as $printer){ - $printerObj = NULL; - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn'],"printer"); - $printerObj->set_acl_base($printer['dn']); - - - if($printer['mode'] == "admin") { - $attribute = "goto".$s_suffix."AdminPrinter"; - }else{ - $attribute = "goto".$s_suffix."Printer"; - } - - $printerObj->by_object['printgeneric']->AddMember($types[$attribute],$this->dn); - $printerObj->by_object['printgeneric']->save(); - } - } - - /* Prepare HotPlug devices */ - $this->attrs['gotoHotplugDeviceDN'] = array(); - foreach($this->gotoHotplugDevices as $name => $device){ - $this->attrs['gotoHotplugDeviceDN'][]= $device['dn']; - } - - /* Prepare LogonScripts */ - $this->attrs['gotoLogonScript'] = array(); - foreach($this->gotoLogonScripts as $name => $script){ - $this->attrs['gotoLogonScript'][] = $script['LogonName']."|". - $script['LogonOverload'].$script['LogonLast']."|". - $script['LogonPriority']."|". - base64_encode($script['LogonData'])."|". - $script['LogonDescription']; - } - - /* Prepare Shares */ - $this->attrs['gotoShare']=array(); - foreach($this->gotoShares as $name => $share){ - $mntp= $share['mountPoint']; - if (!preg_match('=^[a-z0-9+\._/%-]+$=i', $mntp)){ - $mntp= base64_encode($mntp); - } - $this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$mntp."|".$share['PwdHash']."|".$share['Username']; - } - - - if($this->gotoXResolution == "auto") $this->gotoXResolution =""; - $saveThis = array("gotoProfileQuota","gotoXResolution","gotoProfileServer","gotoKioskProfile","gosaDefaultPrinter"); - - foreach($saveThis as $tosave){ - if(!empty($this->$tosave)){ - $this->attrs[$tosave]=$this->$tosave; - }else{ - $this->attrs[$tosave]=array(); - } - } - - /* Prepare Flags */ - $this->attrs['gotoProfileFlags'] = array($this->gotoProfileFlagC.$this->gotoProfileFlagL); - if(empty($this->attrs['gotoProfileFlags'][0])){ - $this->attrs['gotoProfileFlags']=array(); - } - - if($this->useProfile == false){ - $this->attrs['gotoProfileFlags'] = preg_replace("/C/i","",$this->attrs['gotoProfileFlags']); - $this->attrs['gotoProfileServer']= array(); - } - - $ldap->cat ($this->dn, array('dn')); - if ($ldap->fetch()){ - $mode= "modify"; - } else { - $mode= "add"; - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - } - - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->$mode($this->attrs); - - $cat = "users"; - if($this->is_group){ - $cat = "groups"; - } - - /* Log last action */ - if($this->initially_was_account){ - new log("modify",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/environment account with dn '%s' failed."),$this->dn)); - $this->handle_post_events($mode,array("uid"=>$this->uid)); - } - - /* Generate ListBox frindly output for the defined shares - * Possibly Add or remove an attribute here, - */ - function printOutAssignedShares() - { - $a_return = array(); - if(is_array($this->gotoShares)){ - foreach($this->gotoShares as $share){ - if(preg_match("/^!/",$share['server'])){ - $a_return[$share['name']."|".$share['server']]= preg_replace("/^!/","",$share['server'])."://".$share['name']." - "._("group share"); - }else{ - $a_return[$share['name']."|".$share['server']]= $share['server']."://".$share['name']." on ".$share['mountPoint']." as ".$share['Username']; - } - } - natcasesort($a_return); - } - return($a_return); - } - - /* Generate ListBox frindly output for the definedhotplugs - * Possibly Add or remove an attribute here, - */ - function printOutHotPlugDevices() - { - $a_return= array(); - if(is_array($this->gotoHotplugDevices)){ - foreach($this->gotoHotplugDevices as $key=>$device){ - $a_return[$key] = $device['name']." - ".$device['id']; - } - } - return($a_return); - } - - /* Generates ListBox frienly output of used printer devices - * Append ' - admin' if printer is used in admin mode - */ - function printOutPrinterDevices() - { - $a_return = array(); - - if($this->acl_is_readable("gotoPrinter")){ - - if(is_array($this->gotoPrinter)){ - foreach($this->gotoPrinter as $printer){ - if($printer['mode'] == "admin"){ - $a_return[$printer['cn'][0]]= $printer['cn'][0]." - "._("Administrator"); - }else{ - $a_return[$printer['cn'][0]]= $printer['cn'][0]; - } - if ($printer['cn'][0] == $this->gosaDefaultPrinter){ - $a_return[$printer['cn'][0]].=" - "._("Default printer"); - } - } - } - } - return($a_return); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - $class= get_class($this); - $o_source = new $class($this->config,$source['dn']); - foreach($this->CopyPasteVars as $attr){ - $this->$attr = $o_source->$attr; - } - } - - - function saveCopyDialog() - { - if(isset($_POST['cn'])){ - $this->cn = $_POST['cn']; - $this->uid = $_POST['cn']; - } - } - - - /* Generates ListBox frienly output of used logonscripts - */ - function printOutLogonScripts() - { - $a_return = array(); - if(is_array($this->gotoLogonScripts)){ - foreach($this->gotoLogonScripts as $script){ - $a_return[$script['LogonName']]= $script['LogonPriority']." - ".$script['LogonName']; - } - } - return($a_return); - } - - - /* Return plugin informations for acl handling -#FIXME these ACLs should work for groups too */ - static function plInfo() - { - return (array("plShortName" => _("Environment"), - "plDescription" => _("Environment settings"), // Description - "plSelfModify" => TRUE, - "plDepends" => array("user", "posixAccount"), // This plugin depends on - "plPriority" => 3, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users", - "groups"), - "plOptions" => array("resolution_hook" => array("type" => "string", - "description" => _("Command to extend the list of possible screen resolutions"))), - - "plProvidedAcls" => array( - - "gotoProfileFlagL" => _("Resolution changeable during session") , - "gotoProfileFlagC" => _("Cache profile localy") , - - "gotoProfileQuota" => _("Profile quota") , - "gotoProfileServer" => _("Profile server") , - - "gotoXResolution" => _("Resolution") , - "gotoKioskProfile" => _("Kiosk profile") , - - "gosaDefaultPrinter" => _("Default printer") , - "gotoLogonScript" => _("Logon script") , - "gotoHotplugDevice" => _("Hotplug devices"), - "gotoShare" => _("Shares")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/environment/class_hotplugDialog.inc b/plugins/personal/environment/class_hotplugDialog.inc deleted file mode 100644 index 0dd418e13..000000000 --- a/plugins/personal/environment/class_hotplugDialog.inc +++ /dev/null @@ -1,112 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $hotplugDevices = ""; - var $hotplugDeviceList = array(); - var $regex = "*"; - var $depselect = "/"; - var $deplist = "/"; - var $skipThese = array(); - - function hotplugDialog (&$config,$skipThese = array()) - { - $this->skipThese = $skipThese; - $this->config = $config; - $this->depselect = $_SESSION['CurrentMainBase']; - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - if(isset($_POST['dialogissubmitted'])){ - $this->regex=$_POST['regexHot']; - $this->depselect = $_POST['depselectHot']; - } - - if((isset($_GET['search']))&&(!empty($_GET['search']))){ - $this->regex=$_GET['search']."*"; - $this->regex=preg_replace("/\*\*/","*",$this->regex); - } - - $this->deplist=$this->config->idepartments; - - $this->hotplugDevices = $this->getHotplugs(); - $smarty->assign("regexHot" ,$this->regex); - $smarty->assign("deplistHot" ,$this->deplist); - $smarty->assign("depselectHot",$this->depselect); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("deplist", $this->config->idepartments); - - - $smarty->assign("hotplugDevices",$this->hotplugDevices); - $smarty->assign("hotplugDeviceKeys",array_flip($this->hotplugDevices)); - $display.= $smarty->fetch(get_template_path('hotplugDialog.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - - /* Save to LDAP */ - function save() - { - $entries = array(); - foreach($_POST['hotplugName'] as $name){ - $entries[$name] = $this->hotplugDeviceList[$name]; - } - return $entries; - } - - function getHotplugs() - { - $ldap= $this->config->get_ldap_link(); - $ldap->cd("ou=devices,".$this->depselect); - $ldap->search("(&(objectClass=gotoDevice)(|(cn=".$this->regex.")(description=".$this->regex.")))",array("gotoHotplugDevice","cn","dn")); - - $a_return = array(); - $this->hotplugDeviceList = array(); - while($attr = $ldap->fetch()){ - - if(isset($attr['gotoHotplugDevice'][0])){ - - $hot_plug = $attr['gotoHotplugDevice'][0]; - $tmp = preg_split("/\|/",$hot_plug); - $tmp2 = array(); - - if(in_array($attr['cn'][0],$this->skipThese)){ - continue; - } - - $tmp2['name'] = $attr['cn'][0]; - $tmp2['description'] = $tmp[0]; - $tmp2['id'] = $tmp[1]; - $tmp2['produkt'] = $tmp[2]; - $tmp2['vendor'] = $tmp[3]; - $tmp2['dn'] = $attr['dn']; - - $a_return[$attr['cn'][0]]= $attr['cn'][0]." [".$tmp[0]."] ".$tmp[1]; - - $this->hotplugDeviceList[$attr['cn'][0]]=$tmp2; - } - } - return($a_return); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/environment/class_logonManagementDialog.inc b/plugins/personal/environment/class_logonManagementDialog.inc deleted file mode 100644 index f125ad096..000000000 --- a/plugins/personal/environment/class_logonManagementDialog.inc +++ /dev/null @@ -1,139 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array("LogonName","LogonPriority","LogonLast","LogonOverload","LogonData","LogonDescription"); - var $objectclasses = array("whatever"); - var $use_existing = false; - - var $LogonName =""; // Name for the LogonScript - var $LogonPriority =""; // Priority defines the order in which the scripts will be processed - var $LogonLast =""; // Is this script marked as the last, all following scripts will be skipped - var $LogonOverload =""; // If Overload is activated this script is overlaodable by a group script with same prio - var $LogonData =""; // The script itself - var $LogonDescription =""; - - var $nameIsEditable = true; - - var $real_LogonName = ""; - - function logonManagementDialog (&$config, $dn= NULL,$data=false) - { - plugin::plugin ($config, $dn); - - if($data){ - $this->LogonName = $data['LogonName']; - $this->LogonPriority = $data['LogonPriority']; - $this->LogonOverload = $data['LogonOverload']; - $this->LogonLast = $data['LogonLast']; - $this->LogonData = $data['LogonData']; - $this->LogonDescription = $data['LogonDescription']; - $this->nameIsEditable = false; - $this->real_LogonName = $data['LogonName']; - } - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - $smarty= get_smarty(); - $display= ""; - - if((isset($_POST['StartImport']))&&(isset($_FILES['importFile']))){ - $this->LogonData = file_get_contents($_FILES['importFile']['tmp_name']); - @unlink($_FILES['importFile']['tmp_name']); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - if($this->$attr){ - $smarty->assign($attr."CHK"," checked "); - }else{ - $smarty->assign($attr."CHK",""); - } - } - $prios=array(1,2,3,4,5,6,7,8,9,10); - $smarty->assign("LogonPrioritys",$prios); - $smarty->assign("LogonPriorityKeys",$prios); - - if(!$this->nameIsEditable){ - $smarty->assign("LogonNameACL"," disabled "); - }else{ - $smarty->assign("LogonNameACL",""); - } - - - $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - function save_object() - { - if(isset($_POST['dialogissubmitted'])){ - foreach($this->attributes as $attr){ - - if(!$this->nameIsEditable && $attr == 'LogonName'){ - continue; - } - if(isset($_POST[$attr])){ - $this->$attr = stripslashes($_POST[$attr]); - } - } - - foreach(array("LogonLast","LogonOverload") as $checkBoxes){ - if(isset($_POST[$checkBoxes])){ - $this->$checkBoxes = stripslashes($_POST[$checkBoxes]); - }else{ - $this->$checkBoxes = ""; - } - - } - } - } - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(preg_match("/[^a-zA-Z]/",$this->LogonName)){ - $message[] = _("Specified name should only consist of upper-/lowercase characters."); - } - - if(empty($this->LogonName)){ - $message[] = _("Please specify a valid script name."); - } - - if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){ - $message[] = _("Specified description contains invalid characters."); - } - - return $message; - } - - - function save() - { - $a_return= array(); - foreach($this->attributes as $attr){ - $a_return[$attr]=$this->$attr; - } - - if(!$this->nameIsEditable){ - $a_return['LogonName']=$this->real_LogonName; - } - - return($a_return); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/environment/class_selectPrinterDialog.inc b/plugins/personal/environment/class_selectPrinterDialog.inc deleted file mode 100644 index fea177be4..000000000 --- a/plugins/personal/environment/class_selectPrinterDialog.inc +++ /dev/null @@ -1,169 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array("whatever"); - var $AlreadyAssigned = array(); - var $regex = "*"; - var $depselect = "/"; - var $deplist = array("/"); - var $module = array("printer"); - var $ui = NULL; - var $subtreesearch = FALSE; - - function selectPrinterDialog (&$config, $dn= NULL,$alreadyused=array() ) - { - $this->AlreadyAssigned = $alreadyused; - plugin::plugin ($config, $dn); - - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - - /* Load possible departments */ - $ui= get_userinfo(); - $this->ui = $ui; - $tdeps= $ui->get_module_departments("users"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - $res = array(); - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - $res[$dep] = $ids[$dep]; //$tdeps[$dep]; - } - } - $this->deplist = $res; - $this->depselect = key($res); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - if(isset($_POST['dialogissubmitted'])){ - foreach(array('regexPrinter' => 'regex','depselectPrinter'=>'depselect') as $attr => $name){ - if(isset($_POST[$attr])){ - $this->$name =$_POST[$attr]; - } - } - } - - if(isset($_POST['subtrees'])){ - $this->subtreesearch= TRUE; - } else { - $this->subtreesearch= FALSE; - } - - if((isset($_GET['search']))&&(!empty($_GET['search']))){ - $this->regex=$_GET['search']."*"; - $this->regex=preg_replace("/\*\*/","*",$this->regex); - } - - $smarty->assign("regexPrinter" ,$this->regex); - $smarty->assign("deplistPrinter" ,$this->deplist); - $smarty->assign("depselectPrinter",$this->depselect); - $smarty->assign("gotoPrinters",$this->getPrinter()); - $smarty->assign("gotoPrinterKeys",array_flip($this->getPrinter())); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("subtrees", $this->subtreesearch?"checked":""); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("deplist", $this->config->idepartments); - - $display.= $smarty->fetch(get_template_path('selectPrinterDialog.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - function check(){ - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(empty($_POST['gotoPrinter'])){ - $message[] = _("Please select a printer or press cancel."); - } - return $message; - } - - /* Save to LDAP */ - function save() - { - return($_POST['gotoPrinter']); - } - - /* This function generates the Printerlist - * All printers are returned that match regex and and depselect - */ - function getPrinter($detailed = false) - { - $a_return=array(); - - - $filter = "(&(objectClass=gotoPrinter)(cn=".$this->regex."))"; - $module = $this->module; - $base = $this->depselect; - $attrs = array("cn","description"); - if ($this->subtreesearch){ - $res = get_list($filter,$module,$base,$attrs, GL_SIZELIMIT, GL_SUBSEARCH); - } else { - $base= "ou=printers,ou=systems,".$base; - $res = get_list($filter,$module,$base,$attrs, GL_SIZELIMIT); - } - - foreach($res as $printer) { - - $acl = $this->ui->get_permissions($printer['dn'],"printer/printgeneric","gotoUserPrinter"); - - if(!preg_match("/w/",$acl)){ - continue; - } - - if(isset($this->AlreadyAssigned[$printer['cn'][0]])) continue; - - if($detailed ==true){ - $a_return[$printer['cn'][0]] = $printer; - }else{ - if(isset($printer['description'][0])){ - $a_return[$printer['cn'][0]] = $printer['cn'][0]." - ".$printer['description'][0]; - }else{ - $a_return[$printer['cn'][0]] = $printer['cn'][0]; - } - } - } - return($a_return); - } -} - - - - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/environment/environment.tpl b/plugins/personal/environment/environment.tpl deleted file mode 100644 index ba6c35623..000000000 --- a/plugins/personal/environment/environment.tpl +++ /dev/null @@ -1,294 +0,0 @@ -{if $is_account ne 'true'} - - {t}The environment extension is currently disabled.{/t} -{else} - - - - -

- - {t}Profiles{/t} -

- - - - - - -
- - - - - - - - - -
-{render acl=$gotoProfileACL} - -{/render} - - -
  - - - - - - - - - - - - - -
- - -{render acl=$gotoProfileServerACL} - -{if $gotoProfileServerWriteable} - -{else} - -{/if} -{/render} -
- -
-
-
-{render acl=$gotoProfileQuotaACL} - {t}MB{/t} -{/render} -
-
-
-{render acl=$gotoProfileFlagCACL} -   -{/render} - -
-
-
- - -{if $kiosk_enabled } - - - - - - - - {else} - - - - -{/if} - - - - - - - -
- -
- {t}Server{/t} - - - {if $kiosk_server != "none"} - {t}Profile{/t} - - {else} -   - {/if} -
- - - - -
-
-{render acl=$gotoProfileFlagLACL} - -{/render} - -
- - -{render acl=$gotoXResolutionACL} - -{/render} -
- - - - - - -
- -

 

- - - - - - -
-

-   - -

- - - - -
- -{render acl=$gotoShareACL} - {$divlistShares} -{/render} -{render acl=$gotoShareACL} - @ -{/render} -{render acl=$gotoShareACL} - -{/render} - : -{render acl=$gotoShareACL} - -{/render} -{render acl=$gotoShareACL} - -{/render} - -
-
-

-   - -

- - - - -
-{render acl=$gotoLogonScriptACL} - -{/render} - -
-{render acl=$gotoLogonScriptACL} - -{/render} -{render acl=$gotoLogonScriptACL} - -{/render} -{render acl=$gotoLogonScriptACL} - -{/render} -
-
- -

 

- - - - - - -
-

-   - -

- - - - - - - -
-{render acl=$gotoHotplugDeviceACL} - -{/render} -
-{render acl=$gotoHotplugDeviceACL} - -{/render} -{render acl=$gotoHotplugDeviceACL} - -{/render} -
-
-

-   - -

- - - - -
-{render acl=$gotoPrinterACL} - -{/render} -
-{render acl=$gotoPrinterACL} - -{/render} -{render acl=$gotoPrinterACL} - -{/render} -{render acl=$gotoPrinterACL} - -{/render} -{render acl=$gosaDefaultPrinterACL} - -{/render} -
-
- -{/if} - diff --git a/plugins/personal/environment/hotplugDialog.tpl b/plugins/personal/environment/hotplugDialog.tpl deleted file mode 100644 index 868e72b00..000000000 --- a/plugins/personal/environment/hotplugDialog.tpl +++ /dev/null @@ -1,70 +0,0 @@ -

 {t}Add hotplug devices{/t}

- - - - - - - - - - -
-
-

- -

-
-
-

-
-

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - -
-   - -
- - - - - -
- - - -
- {$apply} -
-
- -

 

- -

- - -

- diff --git a/plugins/personal/environment/logonManagement.tpl b/plugins/personal/environment/logonManagement.tpl deleted file mode 100644 index 746be6fe1..000000000 --- a/plugins/personal/environment/logonManagement.tpl +++ /dev/null @@ -1,84 +0,0 @@ -

 {t}Logon script management{/t}

- - - - - - - - -
- - - - - - - - - - - - -
- - -
- - -
- - -
-
- - - - - - - -
- - -
- - -
-
-

 

- - - - -
-

 {t}Script{/t}

- - - - - - - -
- -
- - -
-
- -

 

-

- - -

- - - diff --git a/plugins/personal/environment/main.inc b/plugins/personal/environment/main.inc deleted file mode 100644 index 6b5d9366c..000000000 --- a/plugins/personal/environment/main.inc +++ /dev/null @@ -1,125 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('environment'); - } - - /* Create mail object on demand */ - if (!isset($_SESSION['environment']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['environment']= new environment ($config, $ui->dn); - $_SESSION['environment']->enable_CSN_check(); - $_SESSION['environment']->set_acl_category('users'); - $_SESSION['environment']->set_acl_base($ui->dn); - } - $environment= $_SESSION['environment']; - - /* save changes back to object */ - if (isset($_SESSION['edit'])){ - $environment->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $environment->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $environment->save (); - del_lock ($ui->dn); - sess_del ('edit'); - - /* Remove object */ - sess_del ('environment'); - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display = $lock_msg; - }else{ - $display = $environment->execute(); - } - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['environment']= $environment; - } - - $info= ""; - /* Show page footer depending on the mode */ - if (!$environment->in_dialog && $environment->is_account && empty($lock_msg)){ - $display.= "

"; - - /* Are we in edit mode? */ - if ((isset($_SESSION['edit']))&&($environment->dialog===NULL)){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/environment"))){ - $info.= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); - $display.= "\n"; - } - $display.= "\n"; - } - $display.= "

\n"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/email.png'), _("User environment settings"), $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/environment/selectPrinterDialog.tpl b/plugins/personal/environment/selectPrinterDialog.tpl deleted file mode 100644 index f07674d39..000000000 --- a/plugins/personal/environment/selectPrinterDialog.tpl +++ /dev/null @@ -1,72 +0,0 @@ -

 {t}Add printer devcies{/t}

- - - - - - - - -
-
-

- -

-
-
-

-
-

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - -
-   - -
- - -
- {t}Search in subtrees{/t} -
- - - - - -
- - - -
- {$apply} -
-
- -

 

-

- - -

- diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc deleted file mode 100644 index 57414ef0c..000000000 --- a/plugins/personal/generic/class_user.inc +++ /dev/null @@ -1,1572 +0,0 @@ - - \version 2.00 - \date 24.07.2003 - - This class provides the functionality to read and write all attributes - relevant for person, organizationalPerson, inetOrgPerson and gosaAccount - from/to the LDAP. It does syntax checking and displays the formulars required. - */ - -class user extends plugin -{ - /* Definitions */ - var $plHeadline= "Generic"; - var $plDescription= "This does something"; - - /* CLI vars */ - var $cli_summary= "Handling of GOsa's user base object"; - var $cli_description= "Some longer text\nfor help"; - var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Plugin specific values */ - var $base= ""; - var $orig_base= ""; - var $cn= ""; - var $new_dn= ""; - var $personalTitle= ""; - var $academicTitle= ""; - var $homePostalAddress= ""; - var $homePhone= ""; - var $labeledURI= ""; - var $o= ""; - var $ou= ""; - var $departmentNumber= ""; - var $employeeNumber= ""; - var $employeeType= ""; - var $roomNumber= ""; - var $telephoneNumber= ""; - var $facsimileTelephoneNumber= ""; - var $mobile= ""; - var $pager= ""; - var $l= ""; - var $st= ""; - var $postalAddress= ""; - var $dateOfBirth; - var $use_dob= "0"; - var $gender="0"; - var $preferredLanguage="0"; - - var $jpegPhoto= "*removed*"; - var $photoData= ""; - var $old_jpegPhoto= ""; - var $old_photoData= ""; - var $cert_dialog= FALSE; - var $picture_dialog= FALSE; - var $pwObject= NULL; - - var $userPKCS12= ""; - var $userSMIMECertificate= ""; - var $userCertificate= ""; - var $certificateSerialNumber= ""; - var $old_certificateSerialNumber= ""; - var $old_userPKCS12= ""; - var $old_userSMIMECertificate= ""; - var $old_userCertificate= ""; - - var $gouvernmentOrganizationalUnit= ""; - var $houseIdentifier= ""; - var $street= ""; - var $postalCode= ""; - var $vocation= ""; - var $ivbbLastDeliveryCollective= ""; - var $gouvernmentOrganizationalPersonLocality= ""; - var $gouvernmentOrganizationalUnitDescription= ""; - var $gouvernmentOrganizationalUnitSubjectArea= ""; - var $functionalTitle= ""; - var $role= ""; - var $publicVisible= ""; - - var $orig_dn; - var $dialog; - - /* variables to trigger password changes */ - var $pw_storage= "crypt"; - var $last_pw_storage= "unset"; - var $had_userCertificate= FALSE; - - var $view_logged = FALSE; - - /* attribute list for save action */ - var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle", - "homePostalAddress", "homePhone", "labeledURI", "ou", "o", "dateOfBirth", "gender","preferredLanguage", - "departmentNumber", "employeeNumber", "employeeType", "l", "st","jpegPhoto", - "roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12", - "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate"); - - var $objectclasses= array("top", "person", "organizationalPerson", "inetOrgPerson", - "gosaAccount"); - - /* attributes that are part of the government mode */ - var $govattrs= array("gouvernmentOrganizationalUnit", "houseIdentifier", "vocation", - "ivbbLastDeliveryCollective", "gouvernmentOrganizationalPersonLocality", - "gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea", - "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role", - "postalCode"); - - var $multiple_support = TRUE; - - /* constructor, if 'dn' is set, the node loads the given - 'dn' from LDAP */ - function user (&$config, $dn= NULL) - { - $this->config= $config; - /* Configuration is fine, allways */ - if ($this->config->current['GOVERNMENTMODE']){ - $this->attributes=array_merge($this->attributes,$this->govattrs); - } - - /* Load base attributes */ - plugin::plugin ($config, $dn); - - $this->orig_dn = $this->dn; - $this->new_dn = $dn; - - if ($this->config->current['GOVERNMENTMODE']){ - /* Fix public visible attribute if unset */ - if (!isset($this->attrs['publicVisible'])){ - $this->publicVisible == "nein"; - } - } - - /* Load government mode attributes */ - if ($this->config->current['GOVERNMENTMODE']){ - /* Copy all attributs */ - foreach ($this->govattrs as $val){ - if (isset($this->attrs["$val"][0])){ - $this->$val= $this->attrs["$val"][0]; - } - } - } - - /* Create me for new accounts */ - if ($dn == "new"){ - $this->is_account= TRUE; - } - - /* Make hash default to md5 if not set in config */ - if (!isset($this->config->current['HASH'])){ - $hash= "md5"; - } else { - $hash= $this->config->current['HASH']; - } - - /* Load data from LDAP? */ - if ($dn !== NULL){ - - /* Do base conversation */ - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } else { - $this->base= dn2base($dn); - } - - /* get password storage type */ - if (isset ($this->attrs['userPassword'][0])){ - /* Initialize local array */ - $matches= array(); - if (preg_match ("/^{([^}]+)}(.+)/", $this->attrs['userPassword'][0], $matches)){ - $this->pw_storage= strtolower($matches[1]); - } else { - if ($this->attrs['userPassword'][0] != ""){ - $this->pw_storage= "clear"; - } else { - $this->pw_storage= $hash; - } - } - } else { - /* Preset with vaule from configuration */ - $this->pw_storage= $hash; - } - - /* Load extra attributes: certificate and picture */ - $this->load_cert(); - $this->load_picture(); - if ($this->userCertificate != ""){ - $this->had_userCertificate= TRUE; - } - } - - /* Reset password storage indicator, used by password_change_needed() */ - if ($dn == "new"){ - $this->last_pw_storage= "unset"; - } else { - $this->last_pw_storage= $this->pw_storage; - } - - /* Generate dateOfBirth entry */ - if (isset ($this->attrs['dateOfBirth'])){ - /* This entry is ISO 8601 conform */ - list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3); - - $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year); - $this->use_dob= "1"; - } else { - $this->use_dob= "0"; - } - - /* Put gender attribute to upper case */ - if (isset ($this->attrs['gender'])){ - $this->gender= strtoupper($this->attrs['gender'][0]); - } - - $this->orig_base = $this->base; - } - - - - - /* execute generates the html output for this node */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - $smarty= get_smarty(); - - /* Fill calendar */ - if ($this->dateOfBirth == "0"){ - $date= getdate(); - } else { - if(is_array($this->dateOfBirth)){ - $date = $this->dateOfBirth; - - // Trigger on dates like 1985-04-01, getdate only understands timestamps - } else if (!empty($this->dateOfBirth) && !is_numeric($this->dateOfBirth)){ - $date= getdate(strtotime($this->dateOfBirth)); - - } else { - $date = getdate($this->dateOfBirth); - } - } - - $days= array(); - for($d= 1; $d<32; $d++){ - $days[$d]= $d; - } - $years= array(); - - if(($date['year']-100)<1901){ - $start = 1901; - }else{ - $start = $date['year']-100; - } - - $end = $start +100; - - for($y= $start; $y<=$end; $y++){ - $years[]= $y; - } - $years['-']= "- "; - $months= array(_("January"), _("February"), _("March"), _("April"), - _("May"), _("June"), _("July"), _("August"), _("September"), - _("October"), _("November"), _("December"), '-' => '- '); - $smarty->assign("day", $date["mday"]); - $smarty->assign("days", $days); - $smarty->assign("months", $months); - $smarty->assign("month", $date["mon"]-1); - $smarty->assign("years", $years); - $smarty->assign("year", $date["year"]); - - /* Assign sex */ - $sex= array(0 => " ", "F" => _("female"), "M" => _("male")); - $smarty->assign("gender_list", $sex); - $language= array_merge(array(0 => " ") ,get_languages(TRUE)); - $smarty->assign("preferredLanguage_list", $language); - - /* Get random number for pictures */ - srand((double)microtime()*1000000); - $smarty->assign("rand", rand(0, 10000)); - - - /* Do we represent a valid gosaAccount? */ - if (!$this->is_account){ - echo "\"\" ". - _("This account has no valid GOsa extensions.").""; - return; - } - - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Password configure dialog handling */ - if(is_object($this->pwObject) && $this->pwObject->display){ - $output= $this->pwObject->configure(); - if ($output != ""){ - $this->dialog= TRUE; - return $output; - } - $this->dialog= false; - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($this->dialog->isSelected()){ - - /* check if selected base is allowed to move to / create a new object */ - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$this->dialog->isSelected()])){ - $this->base = $this->dialog->isSelected(); - } - $this->dialog= false; - }else{ - return($this->dialog->execute()); - } - } - - /* Want password method editing? */ - if ($this->acl_is_writeable("userPassword")){ - if (isset($_POST['edit_pw_method'])){ - if (!is_object($this->pwObject) || $this->pw_storage != $this->pwObject->get_hash_name()){ - $temp= passwordMethod::get_available_methods(); - $this->pwObject= new $temp[$this->pw_storage]($this->config,$this->dn); - } - $this->pwObject->display = TRUE; - $this->dialog= TRUE; - return ($this->pwObject->configure()); - } - } - - /* Want picture edit dialog? */ - if($this->acl_is_writeable("userPicture")) { - if (isset($_POST['edit_picture'])){ - /* Save values for later recovery, in case some presses - the cancel button. */ - $this->old_jpegPhoto= $this->jpegPhoto; - $this->old_photoData= $this->photoData; - $this->picture_dialog= TRUE; - $this->dialog= TRUE; - } - } - - /* Remove picture? */ - if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){ - if (isset($_POST['picture_remove'])){ - $this->set_picture (); - $this->jpegPhoto= "*removed*"; - $this->is_modified= TRUE; - return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__)))); - } - } - - /* Save picture */ - if (isset($_POST['picture_edit_finish'])){ - - /* Check for clean upload */ - if ($_FILES['picture_file']['name'] != ""){ - if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) { - print_red(_("The specified file has not been uploaded via HTTP POST! Aborted.")); - }else{ - /* Activate new picture */ - $this->set_picture($_FILES['picture_file']['tmp_name']); - } - } - $this->picture_dialog= FALSE; - $this->dialog= FALSE; - $this->is_modified= TRUE; - } - - - /* Cancel picture */ - if (isset($_POST['picture_edit_cancel'])){ - - /* Restore values */ - $this->jpegPhoto= $this->old_jpegPhoto; - $this->photoData= $this->old_photoData; - - /* Update picture */ - $_SESSION['binary']= $this->photoData; - $_SESSION['binarytype']= "image/jpeg"; - $this->picture_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Toggle dateOfBirth information */ - if (isset($_POST['set_dob'])){ - $this->use_dob= ($this->use_dob == "0")?"1":"0"; - } - - - /* Want certificate= */ - if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){ - - /* Save original values for later reconstruction */ - foreach (array("certificateSerialNumber", "userCertificate", - "userSMIMECertificate", "userPKCS12") as $val){ - - $oval= "old_$val"; - $this->$oval= $this->$val; - } - - $this->cert_dialog= TRUE; - $this->dialog= TRUE; - } - - - /* Cancel certificate dialog */ - if (isset($_POST['cert_edit_cancel'])){ - - /* Restore original values in case of 'cancel' */ - foreach (array("certificateSerialNumber", "userCertificate", - "userSMIMECertificate", "userPKCS12") as $val){ - - $oval= "old_$val"; - $this->$val= $this->$oval; - } - $this->cert_dialog= FALSE; - $this->dialog= FALSE; - } - - - /* Remove certificate? */ - if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ - foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){ - if (isset($_POST["remove_$val"])){ - - /* Reset specified cert*/ - $this->$val= ""; - $this->is_modified= TRUE; - } - } - } - - /* Upload new cert and close dialog? */ - if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ - if (isset($_POST['cert_edit_finish'])){ - - /* for all certificates do */ - foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") - as $val){ - - /* Check for clean upload */ - if (array_key_exists($val."_file", $_FILES) && - array_key_exists('name', $_FILES[$val."_file"]) && - $_FILES[$val."_file"]['name'] != "" && - is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) { - $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']); - } - } - - /* Save serial number */ - if (isset($_POST["certificateSerialNumber"]) && - $_POST["certificateSerialNumber"] != ""){ - - if (!is_id($_POST["certificateSerialNumber"])){ - print_red (_("Please enter a valid serial number")); - - foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){ - if ($this->$cert != ""){ - $smarty->assign("$cert"."_state", "true"); - } else { - $smarty->assign("$cert"."_state", ""); - } - } - return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__)))); - } - - $this->certificateSerialNumber= $_POST["certificateSerialNumber"]; - $this->is_modified= TRUE; - } - - $this->cert_dialog= FALSE; - $this->dialog= FALSE; - } - } - /* Display picture dialog */ - if ($this->picture_dialog){ - return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__)))); - } - - /* Display cert dialog */ - if ($this->cert_dialog){ - $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))); - $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate")); - - foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){ - if ($this->$cert != ""){ - /* import certificate */ - $certificate = new certificate; - $certificate->import($this->$cert); - - /* Read out data*/ - $timeto = $certificate->getvalidto_date(); - $timefrom = $certificate->getvalidfrom_date(); - - - /* Additional info if start end time is '0' */ - $add_str_info = ""; - if($timeto == 0 && $timefrom == 0){ - $add_str_info = "
"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)").""; - } - - $str = " - - - - -
CN".preg_replace("/ /", " ", $certificate->getname())."

". - - sprintf(_("Certificate is valid from %s to %s and is currently %s."), - "".date('d M Y',$timefrom)."", - "".date('d M Y',$timeto)."", - $certificate->isvalid()?""._("valid")."": - ""._("invalid")."").$add_str_info; - - $smarty->assign($cert."info",$str); - $smarty->assign($cert."_state","true"); - } else { - $smarty->assign($cert."info", ""._("No certificate installed").""); - $smarty->assign($cert."_state",""); - } - } - $smarty->assign("governmentmode", "false"); - return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__)))); - } - - /* Prepare password hashes */ - if ($this->pw_storage == ""){ - $this->pw_storage= $this->config->current['HASH']; - } - - $temp= passwordMethod::get_available_methods(); - $is_configurable= FALSE; - $hashes = $temp['name']; - if(isset($temp[$this->pw_storage])){ - $test= new $temp[$this->pw_storage]($this->config); - $is_configurable= $test->is_configurable(); - }else{ - new msg_dialog(_("Password method"),_("The selected password method is no longer available."),WARNING_DIALOG); - } - - /* Load attributes and acl's */ - $ui =get_userinfo(); - foreach($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - if(in_array($val,$this->multi_boxes)){ - $smarty->assign("use_".$val,TRUE); - }else{ - $smarty->assign("use_".$val,FALSE); - } - } - foreach(array("base","pw_storage","edit_picture") as $val){ - if(in_array($val,$this->multi_boxes)){ - $smarty->assign("use_".$val,TRUE); - }else{ - $smarty->assign("use_".$val,FALSE); - } - } - - /* Set acls */ - $tmp = $this->plinfo(); - foreach($tmp['plProvidedAcls'] as $val => $translation){ - $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit'])))); - } - - $smarty->assign("pwmode", $hashes); - $smarty->assign("pwmode_select", $this->pw_storage); - $smarty->assign("pw_configurable", $is_configurable); - $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit'])))); - $smarty->assign("base_select", $this->base); - $smarty->assign("CertificatesACL", $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))); - $smarty->assign("userPictureACL", $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit'])))); - $smarty->assign("userPicture_is_readable", $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit'])))); - - /* Create base acls */ - $tmp = @$this->allowedBasesToMoveTo(); - $smarty->assign("bases", $tmp); - - /* Save government mode attributes */ - if (isset($this->config->current['GOVERNMENTMODE']) && - preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){ - $smarty->assign("governmentmode", "true"); - $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet", - "internet,ivbv", "internet,testa", "internet,ivbv,testa"); - $smarty->assign("ivbbmodes", $ivbbmodes); - foreach ($this->govattrs as $val){ - $smarty->assign("$val", $this->$val); - $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit'])))); - } - } else { - $smarty->assign("governmentmode", "false"); - } - - /* Special mode for uid */ - $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit']))); - if (isset ($this->dn)){ - if ($this->dn != "new"){ - $uidACL= preg_replace("/w/","",$uidACL); - } - } else { - $uidACL= preg_replace("/w/","",$uidACL); - } - - $smarty->assign("uidACL", $uidACL); - $smarty->assign("is_template", $this->is_template); - $smarty->assign("use_dob", $this->use_dob); - - if (isset($this->parent)){ - if (isset($this->parent->by_object['phoneAccount']) && - $this->parent->by_object['phoneAccount']->is_account){ - $smarty->assign("has_phoneaccount", "true"); - } else { - $smarty->assign("has_phoneaccount", "false"); - } - } else { - $smarty->assign("has_phoneaccount", "false"); - } - $smarty->assign("multiple_support" , $this->multiple_support_active); - return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__)))); - } - - - /* remove object from parent */ - function remove_from_parent() - { - /* Remove password extension */ - $temp= passwordMethod::get_available_methods(); - $this->pwObject= new $temp[$this->pw_storage]($this->config,$this->dn); - $this->pwObject->remove_from_parent(); - - /* Remove user */ - $ldap= $this->config->get_ldap_link(); - $ldap->rmdir ($this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn)); - - new log("remove","users/".get_class($this),$this->dn,$this->attributes,$ldap->get_error()); - - /* Delete references to groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid")); - while ($ldap->fetch()){ - $g= new group($this->config, $ldap->getDN()); - $g->removeUser($this->uid); - $g->save (); - } - - /* Delete references to object groups */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); - while ($ldap->fetch()){ - $og= new ogroup($this->config, $ldap->getDN()); - unset($og->member[$this->dn]); - $og->save (); - } - - /* If needed, let the password method do some cleanup */ - $tmp = new passwordMethod($_SESSION['config']); - $available = $tmp->get_available_methods(); - if (in_array_ics($this->pw_storage, $available['name'])){ - $test= new $available[$this->pw_storage]($this->config); - $test->attrs= $this->attrs; - $test->dn= $this->dn; - $test->remove_from_parent(); - } - - /* Remove ACL dependencies too */ - $tmp = new acl($this->config,$this->parent,$this->dn); - $tmp->remove_acl(); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove",array("uid" => $this->uid)); - } - - - /* Save data to object */ - function save_object() - { - if(isset($_POST['generic']) || isset($_POST['multiple_user_posted'])){ - - /* Make a backup of the current selected base */ - $base_tmp = $this->base; - - /* Parents save function */ - plugin::save_object (); - - /* Save government mode attributes */ - if ($this->config->current['GOVERNMENTMODE']){ - foreach ($this->govattrs as $val){ - if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){ - $data= stripcslashes($_POST["$val"]); - if ($data != $this->$val){ - $this->is_modified= TRUE; - } - $this->$val= $data; - } - } - } - - /* In template mode, the uid is autogenerated... */ - if ($this->is_template){ - $this->uid= strtolower($this->sn); - $this->givenName= $this->sn; - } - - /* Save base and pw_storage, since these are no LDAP attributes */ - if (isset($_POST['base'])){ - - $tmp = $this->get_allowed_bases(); - if(isset($tmp[$_POST['base']])){ - $base= validate($_POST['base']); - if ($base != $this->base){ - $this->is_modified= TRUE; - } - $this->base= $base; - }else{ - $this->base = $base_tmp; - print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base']))); - $this->set_acl_base('dummy,'.$this->base); - } - } - - /* Get pw_storage mode */ - if (isset($_POST['pw_storage'])){ - foreach(array("pw_storage") as $val){ - if(isset($_POST[$val])){ - $data= validate($_POST[$val]); - if ($data != $this->$val){ - $this->is_modified= TRUE; - } - $this->$val= $data; - } - } - } - - $this->set_acl_base('dummy,'.$this->base); - } - } - - function rebind($ldap, $referral) - { - $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']); - if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) { - $this->error = "Success"; - $this->hascon=true; - $this->reconnect= true; - return (0); - } else { - $this->error = "Could not bind to " . $credentials['ADMIN']; - return NULL; - } - } - - - /* Save data to LDAP, depending on is_account we save or delete */ - function save() - { - /* Only force save of changes .... - If this attributes aren't changed, avoid saving. - */ - if($this->gender=="0") $this->gender =""; - if($this->preferredLanguage=="0") $this->preferredLanguage =""; - - /* First use parents methods to do some basic fillup in $this->attrs */ - plugin::save (); - - if ($this->use_dob == "1"){ - /* If it is an array, the generic page has never been loaded - so there's no difference. Using an array would cause an error btw. */ - if(!is_array($this->attrs['dateOfBirth'])) { - $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth); - } - } - - /* Remove additional objectClasses */ - $tmp= array(); - foreach ($this->attrs['objectClass'] as $key => $set){ - $found= false; - foreach (array("ivbbentry", "gosaUserTemplate") as $val){ - if (preg_match ("/^$set$/i", $val)){ - $found= true; - break; - } - } - if (!$found){ - $tmp[]= $set; - } - } - - /* Replace the objectClass array. This is done because of the - separation into government and normal mode. */ - $this->attrs['objectClass']= $tmp; - - /* Add objectClasss for template mode? */ - if ($this->is_template){ - $this->attrs['objectClass'][]= "gosaUserTemplate"; - } - - /* Hard coded government mode? */ - if ($this->config->current['GOVERNMENTMODE'] != 'false'){ - $this->attrs['objectClass'][]= "ivbbentry"; - - /* Copy standard attributes */ - foreach ($this->govattrs as $val){ - if ($this->$val != ""){ - $this->attrs["$val"]= $this->$val; - } elseif (!$this->is_new) { - $this->attrs["$val"]= array(); - } - } - - /* Remove attribute if set to "nein" */ - if ($this->publicVisible == "nein"){ - $this->attrs['publicVisible']= array(); - if($this->is_new){ - unset($this->attrs['publicVisible']); - }else{ - $this->attrs['publicVisible']=array(); - } - - } - - } - - /* Special handling for attribute userCertificate needed */ - if ($this->userCertificate != ""){ - $this->attrs["userCertificate;binary"]= $this->userCertificate; - $remove_userCertificate= false; - } else { - $remove_userCertificate= true; - } - - /* Special handling for dateOfBirth value */ - if ($this->use_dob != "1"){ - if ($this->is_new) { - unset($this->attrs["dateOfBirth"]); - } else { - $this->attrs["dateOfBirth"]= array(); - } - } - if (!$this->gender){ - if ($this->is_new) { - unset($this->attrs["gender"]); - } else { - $this->attrs["gender"]= array(); - } - } - if (!$this->preferredLanguage){ - if ($this->is_new) { - unset($this->attrs["preferredLanguage"]); - } else { - $this->attrs["preferredLanguage"]= array(); - } - } - - /* Special handling for attribute jpegPhote needed, scale image via - image magick to 147x200 pixels and inject resulting data. */ - if ($this->jpegPhoto == "*removed*"){ - - /* Reset attribute to avoid writing *removed* as value */ - $this->attrs["jpegPhoto"] = array(); - - } else { - - /* Fallback if there's no image magick inside PHP */ - if (!function_exists("imagick_blob2image")){ - /* Get temporary file name for conversation */ - $fname = tempnam ("/tmp", "GOsa"); - - /* Open file and write out photoData */ - $fp = fopen ($fname, "w"); - fwrite ($fp, $this->photoData); - fclose ($fp); - - /* Build conversation query. Filename is generated automatically, so - we do not need any special security checks. Exec command and save - output. For PHP safe mode, you'll need a configuration which respects - image magick as executable... */ - $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -"; - @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, - $query, "Execute"); - - /* Read data written by convert */ - $output= ""; - $sh= popen($query, 'r'); - while (!feof($sh)){ - $output.= fread($sh, 4096); - } - pclose($sh); - - unlink($fname); - - /* Save attribute */ - $this->attrs["jpegPhoto"] = $output; - - } else { - - /* Load the new uploaded Photo */ - if(!$handle = imagick_blob2image($this->photoData)) { - new log("debug","users/".get_class($this),$this->dn,array(),"Could not access uploaded image"); - } - - /* Resizing image to 147x200 and blur */ - if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){ - new log("debug","users/".get_class($this),$this->dn,array(),"Could not resize uploaded image"); - } - - /* Converting image to JPEG */ - if(!imagick_convert($handle,"JPEG")) { - new log("debug","users/".get_class($this),$this->dn,array(),"Could not convert uploaded image to jepg"); - } - - /* Creating binary Code for the Image */ - if(!$dump = imagick_image2blob($handle)){ - new log("debug","users/".get_class($this),$this->dn,array(),"Could not create new user image"); - } - - /* Sending Image */ - $output= $dump; - - /* Save attribute */ - $this->attrs["jpegPhoto"] = $output; - } - - } - - /* This only gets called when user is renaming himself */ - $ldap= $this->config->get_ldap_link(); - if ($this->dn != $this->new_dn){ - - /* Write entry on new 'dn' */ - $this->update_acls($this->dn,$this->new_dn); - $this->move($this->dn, $this->new_dn); - - /* Happen to use the new one */ - change_ui_dn($this->dn, $this->new_dn); - $this->dn= $this->new_dn; - } - - - /* Save data. Using 'modify' implies that the entry is already present, use 'add' for - new entries. So do a check first... */ - $ldap->cat ($this->dn, array('dn')); - if ($ldap->fetch()){ - $mode= "modify"; - } else { - $mode= "add"; - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); - } - - /* Set password to some junk stuff in case of templates */ - if ($this->is_template){ - $this->attrs['userPassword']= '{crypt}N0T$3T4N0W'; - } - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save via $mode"); - - /* Finally write data with selected 'mode' */ - $this->cleanup(); - - if(isset($this->attrs['preferredLanguage'])){ - $_SESSION['ui']->language = $this->preferredLanguage; - $_SESSION['Last_init_lang'] = "update"; - } - - $ldap->cd ($this->dn); - $ldap->$mode ($this->attrs); - if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){ - return (1); - } - - /* Remove ACL dependencies too */ - if($this->dn != $this->orig_dn && $this->orig_dn != "new"){ - $tmp = new acl($this->config,$this->parent,$this->dn); - $tmp->update_acl_membership($this->orig_dn,$this->dn); - } - - if($mode == "modify"){ - 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()); - } - - /* Remove cert? - For some reason, the 'ldap' class doesn't want to remove binary entries, so I need - to work around myself. */ - if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){ - - /* Reset array, assemble new, this should be reworked */ - $this->attrs= array(); - $this->attrs['userCertificate;binary']= array(); - - /* Prepare connection */ - if (!($ds = ldap_connect($this->config->current['SERVER']))) { - die ("Could not connect to LDAP server"); - } - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); - if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") { - ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1); - ldap_set_rebind_proc($ds, array(&$this, "rebind")); - } - if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){ - ldap_start_tls($ds); - } - if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'], - $this->config->current['PASSWORD']))) { - die ("Could not bind to LDAP"); - } - - /* Modify using attrs */ - ldap_mod_del($ds,$this->dn,$this->attrs); - ldap_close($ds); - } - - /* If needed, let the password method do some cleanup */ - if ($this->pw_storage != $this->last_pw_storage){ - $tmp = new passwordMethod($_SESSION['config']); - $available = $tmp->get_available_methods(); - if (in_array_ics($this->last_pw_storage, $available['name'])){ - $test= new $available[$this->last_pw_storage]($this->config,$this->dn); - $test->attrs= $this->attrs; - $test->remove_from_parent(); - } - } - - /* Maybe the current password method want's to do some changes... */ - if (is_object($this->pwObject)){ - $this->pwObject->save($this->dn); - } - - /* Optionally execute a command after we're done */ - if ($mode == "add"){ - $this->handle_post_events("add", array("uid" => $this->uid)); - } elseif ($this->is_modified){ - $this->handle_post_events("modify", array("uid" => $this->uid)); - } - - /* Fix tagging if needed */ - $this->handle_object_tagging(); - - return (0); - } - - - function update_new_dn() - { - $pt= ""; - if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){ - if(!empty($this->personalTitle)){ - $pt = $this->personalTitle." "; - } - } - $this->cn= $pt.$this->givenName." ".$this->sn; - - /* Permissions for that base? */ - if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){ - $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base; - } else { - /* Don't touch dn, if cn hasn't changed */ - if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn && - $this->orig_base == $this->base ){ - $this->new_dn= $this->dn; - } else { - $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base); - } - } - } - - - /* Check formular input */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - $this->update_new_dn(); - - /* Set the new acl base */ - if($this->dn == "new") { - $this->set_acl_base($this->base); - } - - /* UID already used? */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(uid=$this->uid)", array("uid")); - $ldap->fetch(); - if ($ldap->count() != 0 && $this->dn == 'new'){ - $message[]= _("There's already a person with this 'Login' in the database."); - } - - /* In template mode, the uid and givenName are autogenerated... */ - if (!$this->is_template){ - if ($this->sn == ""){ - $message[]= _("The required field 'Name' is not set."); - } - if ($this->givenName == ""){ - $message[]= _("The required field 'Given name' is not set."); - } - if ($this->uid == ""){ - $message[]= _("The required field 'Login' is not set."); - } - if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){ - $ldap->cat($this->new_dn); - if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){ - $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database."); - } - } - } - - /* Check for valid input */ - if ($this->is_modified && !is_uid($this->uid)){ - $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed."); - } - if (!is_url($this->labeledURI)){ - $message[]= _("The field 'Homepage' contains an invalid URL definition."); - } - if (preg_match ("/[\\\\]/", $this->sn)){ - $message[]= _("The field 'Name' contains invalid characters."); - } - if (preg_match ("/[\\\\]/", $this->givenName)){ - $message[]= _("The field 'Given name' contains invalid characters."); - } - - /* Check phone numbers */ - if (!is_phone_nr($this->telephoneNumber)){ - $message[]= _("The field 'Phone' contains an invalid phone number."); - } - if (!is_phone_nr($this->facsimileTelephoneNumber)){ - $message[]= _("The field 'Fax' contains an invalid phone number."); - } - if (!is_phone_nr($this->mobile)){ - $message[]= _("The field 'Mobile' contains an invalid phone number."); - } - if (!is_phone_nr($this->pager)){ - $message[]= _("The field 'Pager' contains an invalid phone number."); - } - - /* Check for reserved characers */ - if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){ - $message[]= _("The field 'Given name' contains invalid characters."); - } - if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){ - $message[]= _("The field 'Name' contains invalid characters."); - } - - return $message; - } - - - /* Indicate whether a password change is needed or not */ - function password_change_needed() - { - if(in_array("pw_storage",$this->multi_boxes)){ - return(TRUE); - } - return($this->pw_storage != $this->last_pw_storage); - } - - - /* Load a jpegPhoto from LDAP, this is going to be simplified later on */ - function load_picture() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $data = $ldap->get_attribute($this->dn,"jpegPhoto"); - - if((!$data) || ($data == "*removed*")){ - - /* In case we don't get an entry, load a default picture */ - $this->set_picture ();//"./images/default.jpg"); - $this->jpegPhoto= "*removed*"; - }else{ - - /* Set picture */ - $this->photoData= $data; - $_SESSION['binary']= $this->photoData; - $_SESSION['binarytype']= "image/jpeg"; - $this->jpegPhoto= ""; - } - } - - - /* Load a certificate from LDAP, this is going to be simplified later on */ - function load_cert() - { - $ds= ldap_connect($this->config->current['SERVER']); - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); - if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") { - ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1); - ldap_set_rebind_proc($ds, array(&$this, "rebind")); - } - if(isset($this->config->current['TLS']) && - $this->config->current['TLS'] == "true"){ - - ldap_start_tls($ds); - } - - $r= ldap_bind($ds); - $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate")); - - if ($sr) { - $ei= @ldap_first_entry($ds, $sr); - - if ($ei) { - if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){ - $this->userCertificate= ""; - } else { - $this->userCertificate= $info[0]; - } - } - } else { - $this->userCertificate= ""; - } - - ldap_unbind($ds); - } - - - /* Load picture from file to object */ - function set_picture($filename ="") - { - if (!is_file($filename) || $filename =="" ){ - $filename= "./images/default.jpg"; - $this->jpegPhoto= "*removed*"; - } - - $fd = fopen ($filename, "rb"); - $this->photoData= fread ($fd, filesize ($filename)); - $_SESSION['binary']= $this->photoData; - $_SESSION['binarytype']= "image/jpeg"; - $this->jpegPhoto= ""; - - fclose ($fd); - } - - - /* Load certificate from file to object */ - function set_cert($cert, $filename) - { - if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return; - $fd = fopen ($filename, "rb"); - if (filesize($filename)>0) { - $this->$cert= fread ($fd, filesize ($filename)); - fclose ($fd); - $this->is_modified= TRUE; - } else { - print_red(_("Could not open specified certificate!")); - } - } - - /* Adapt from given 'dn' */ - function adapt_from_template($dn) - { - plugin::adapt_from_template($dn); - - /* Get base */ - $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn); - - if ($this->config->current['GOVERNMENTMODE']){ - - /* Walk through govattrs */ - foreach ($this->govattrs as $val){ - - if (isset($this->attrs["$val"][0])){ - - /* If attribute is set, replace dynamic parts: - %sn, %givenName and %uid. Fill these in our local variables. */ - $value= $this->attrs["$val"][0]; - - foreach (array("sn", "givenName", "uid") as $repl){ - if (preg_match("/%$repl/i", $value)){ - $value= preg_replace ("/%$repl/i", - $this->parent->$repl, $value); - } - } - $this->$val= $value; - } - } - } - - /* Get back uid/sn/givenName */ - if ($this->parent !== NULL){ - $this->uid= $this->parent->uid; - $this->sn= $this->parent->sn; - $this->givenName= $this->parent->givenName; - } - } - - - /* This avoids that users move themselves out of their rights. - */ - function allowedBasesToMoveTo() - { - /* Get bases */ - $bases = $this->get_allowed_bases(); - return($bases); - } - - - function getCopyDialog() - { - $str = ""; - - $_SESSION['binary'] = $this->photoData; - $_SESSION['binarytype']= "image/jpeg"; - - /* Get random number for pictures */ - srand((double)microtime()*1000000); - $rand = rand(0, 10000); - - $smarty = get_smarty(); - - $smarty->assign("passwordTodo","clear"); - - if(isset($_POST['passwordTodo'])){ - $smarty->assign("passwordTodo",$_POST['passwordTodo']); - } - - $smarty->assign("sn", $this->sn); - $smarty->assign("givenName",$this->givenName); - $smarty->assign("uid", $this->uid); - $smarty->assign("rand", $rand); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - - - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - } - - function saveCopyDialog() - { - /* Set_acl_base */ - $this->set_acl_base("cn=dummy,".get_people_ou().$this->base); - - if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){ - $this->set_picture($_FILES['picture_file']['tmp_name']); - } - - /* Remove picture? */ - if (isset($_POST['picture_remove'])){ - $this->jpegPhoto= "*removed*"; - $this->set_picture ("./images/default.jpg"); - $this->is_modified= TRUE; - } - - $attrs = array("uid","givenName","sn"); - foreach($attrs as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Reset certificate information addepted from source user - to avoid setting the same user certificate for the destination user. */ - $this->userPKCS12= ""; - $this->userSMIMECertificate= ""; - $this->userCertificate= ""; - $this->certificateSerialNumber= ""; - $this->old_certificateSerialNumber= ""; - $this->old_userPKCS12= ""; - $this->old_userSMIMECertificate= ""; - $this->old_userCertificate= ""; - } - - - static function plInfo() - { - - $govattrs= array( - "gouvernmentOrganizationalUnit" => _("Unit"), - "houseIdentifier" => _("House identifier"), - "vocation" => _("Vocation"), - "ivbbLastDeliveryCollective" => _("Last delivery"), - "gouvernmentOrganizationalPersonLocality" => _("Person locality"), - "gouvernmentOrganizationalUnitDescription" => _("Unit description"), - "gouvernmentOrganizationalUnitSubjectArea" => _("Subject area"), - "functionalTitle" => _("Functional title"), - "certificateSerialNumber" => _("Certificate serial number"), - "publicVisible" => _("Public visible"), - "street" => _("Street"), - "role" => _("Role"), - "postalCode" => _("Postal code")); - - $ret = array( - "plShortName" => _("Generic"), - "plDescription" => _("Generic user settings"), - "plSelfModify" => TRUE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users" => array("description" => _("Users"), - "objectClass" => "gosaAccount")), - - "plProvidedAcls" => array( - "base" => _("Base"), - "userPassword" => _("User password"), - "sn" => _("Surename"), - "givenName" => _("Given name"), - "uid" => _("User identification"), - "personalTitle" => _("Personal title"), - "academicTitle" => _("Academic title"), - "homePostalAddress" => _("Home postal address"), - "homePhone" => _("Home phone number"), - "labeledURI" => _("Homepage"), - "o" => _("Organization"), - "ou" => _("Department"), - "dateOfBirth" => _("Date of birth"), - "gender" => _("Gender"), - "preferredLanguage" => _("Preferred language"), - "departmentNumber" => _("Department number"), - "employeeNumber" => _("Employee number"), - "employeeType" => _("Employee type"), - "l" => _("Location"), - "st" => _("State"), - "userPicture" => _("User picture"), - "roomNumber" => _("Room number"), - "telephoneNumber" => _("Telefon number"), - "mobile" => _("Mobile number"), - "pager" => _("Pager number"), - "Certificate" => _("User certificates"), - - "postalAddress" => _("Postal address"), - "facsimileTelephoneNumber" => _("Fax number")) - ); - - /* Append government attributes if required */ - global $config; - if (isset($config->current['GOVERNMENTMODE']) && preg_match('/true/i', $config->current['GOVERNMENTMODE'])){ - foreach($govattrs as $attr => $desc){ - $ret["plProvidedAcls"][$attr] = $desc; - } - } - return($ret); - } - - function get_multi_edit_values() - { - $ret = plugin::get_multi_edit_values(); - if(in_array("pw_storage",$this->multi_boxes)){ - $ret['pw_storage'] = $this->pw_storage; - } - if(in_array("edit_picture",$this->multi_boxes)){ - $ret['jpegPhoto'] = $this->jpegPhoto; - $ret['photoData'] = $this->photoData; - $ret['old_jpegPhoto'] = $this->old_jpegPhoto; - $ret['old_photoData'] = $this->old_photoData; - } - if(isset($ret['dateOfBirth'])){ - unset($ret['dateOfBirth']); - } - if(isset($ret['cn'])){ - unset($ret['cn']); - } - $ret['is_modified'] = $this->is_modified; - if(in_array("base",$this->multi_boxes)){ - $ret['orig_base']="Changed_by_Multi_Plug"; - $ret['base']=$this->base; - } - return($ret); - } - - - function multiple_save_object() - { - plugin::multiple_save_object(); - - /* Get pw_storage mode */ - if (isset($_POST['pw_storage'])){ - foreach(array("pw_storage") as $val){ - if(isset($_POST[$val])){ - $data= validate(get_post($val)); - if ($data != $this->$val){ - $this->is_modified= TRUE; - } - $this->$val= $data; - } - } - } - if(isset($_POST['base'])){ - $this->base = get_post('base'); - } - - if(isset($_POST['user_mulitple_edit'])){ - foreach(array("base","pw_storage","edit_picture") as $val){ - if(isset($_POST["use_".$val])){ - $this->multi_boxes[] = $val; - } - } - } - } - - - function multiple_check() - { - /* Call check() to set new_dn correctly ... */ - $message = plugin::multiple_check(); - - /* Set the new acl base */ - if($this->dn == "new") { - $this->set_acl_base($this->base); - } - if (!is_url($this->labeledURI) && in_array("labeledURI",$this->multi_boxes)){ - $message[]= _("The field 'Homepage' contains an invalid URL definition."); - } - if (preg_match ("/[\\\\]/", $this->sn) && in_array("sn",$this->multi_boxes)){ - $message[]= _("The field 'Name' contains invalid characters."); - } - if (preg_match ("/[\\\\]/", $this->givenName) && in_array("givenName",$this->multi_boxes)){ - $message[]= _("The field 'Given name' contains invalid characters."); - } - if (!is_phone_nr($this->telephoneNumber) && in_array("telephoneNumber",$this->multi_boxes)){ - $message[]= _("The field 'Phone' contains an invalid phone number."); - } - if (!is_phone_nr($this->facsimileTelephoneNumber) && in_array("facsimileTelephoneNumber",$this->multi_boxes)){ - $message[]= _("The field 'Fax' contains an invalid phone number."); - } - if (!is_phone_nr($this->mobile) && in_array("mobile",$this->multi_boxes)){ - $message[]= _("The field 'Mobile' contains an invalid phone number."); - } - if (!is_phone_nr($this->pager) && in_array("pager",$this->multi_boxes)){ - $message[]= _("The field 'Pager' contains an invalid phone number."); - } - if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName) && in_array("givenName",$this->multi_boxes)){ - $message[]= _("The field 'Given name' contains invalid characters."); - } - if (preg_match ('/[,+"?\'()=<>;]/', $this->sn) && in_array("sn",$this->multi_boxes)){ - $message[]= _("The field 'Name' contains invalid characters."); - } - return($message); - } - - - - function multiple_execute() - { - return($this->execute()); - } - - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/generic/generic.tpl b/plugins/personal/generic/generic.tpl deleted file mode 100644 index 1127e9441..000000000 --- a/plugins/personal/generic/generic.tpl +++ /dev/null @@ -1,568 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
-

{t}Personal information{/t}

-
- - - - - - - -
- {if !$userPicture_is_readable} - {t}Personal picture{/t} - {else} - {t}Personal picture{/t} - {/if} -
-{render acl=$userPictureACL checkbox=$multiple_support checked=$use_edit_picture} - -{/render} -
-
- - {if $is_template ne "true"} - - - - - {else} - - - - - {/if} - - {if $is_template ne "true"} - - - - - - - - - {/if} - - - - - - - - - -{if !$multiple_support} - - - - - - - - -{/if} - - - - - - - - -
-{if $multiple_support} - -{else} -{render acl=$snACL} - -{/render} -{/if} -
{render acl=$snACL}{/render}
- -{if $multiple_support} - -{else} -{render acl=$givenNameACL} - -{/render} -{/if} -
- {if !$multiple_support} -{render acl=$uidACL} - -{/render} - {else} - - {/if} -
-
- -
-
-{render acl=$personalTitleACL checkbox=$multiple_support checked=$use_personalTitle} - -{/render} -
-{render acl=$academicTitleACL checkbox=$multiple_support checked=$use_academicTitle} - -{/render} -
-
- -
-
-{render acl=$dateOfBirthACL} - {if $use_dob eq 1} - - - - - - {else} - - {/if} -{/render} -
- - -{render acl=$genderACL} - -{/render} -
- - -{render acl=$preferredLanguageACL checkbox=$multiple_support checked=$use_preferredLanguage} - -{/render} -
-
- -
-
-{render acl=$baseACL checkbox=$multiple_support checked=$use_base} - -{/render} -{render acl=$baseACL disable_picture='images/folder_gray.png'} - -{/render} -
-
-   - - - - - - - - - - - - - - - - - - - - - - - - {if $is_template ne "true" && !$multiple_support} - - - - - {/if} - -
-{render acl=$homePostalAddressACL checkbox=$multiple_support checked=$use_homePostalAddress} - -{/render} -
- -{render acl=$homePhoneACL checkbox=$multiple_support checked=$use_homePhone} - -{/render} -
-{render acl=$labeledURIACL checkbox=$multiple_support checked=$use_labeledURI} - -{/render} -
-
-
-{render acl=$passwordStorageACL checkbox=$multiple_support checked=$use_pw_storage} - - {if $pw_configurable eq "true"} -   - {/if} -{/render} -
-{render acl=$CertificatesACL mode=read_active} - -{/render} -
-
- -

 

- - - - - - - - - - - - {if $governmentmode ne "true"} - - - - - - - - - - - - - - {else} - - - - - - - - - - {/if} - -
-

 {t}Organizational information{/t}

-
- - - - - - - - - - - - - - - - - - - - - -
-{render acl=$oACL checkbox=$multiple_support checked=$use_o} - -{/render} -
-{render acl=$ouACL checkbox=$multiple_support checked=$use_ou} - -{/render} -
-{render acl=$departmentNumberACL checkbox=$multiple_support checked=$use_departmentNumber} - -{/render} -
-{render acl=$employeeNumberACL checkbox=$multiple_support checked=$use_employeeNumber} - -{/render} -
-{render acl=$employeeTypeACL checkbox=$multiple_support checked=$use_employeeType} - -{/render} -
-
-   - - - - - - - {if $has_phoneaccount ne "true"} - - - - - {/if} - - - - - - - - - - - - -
-{render acl=$roomNumberACL checkbox=$multiple_support checked=$use_roomNumber} - -{/render} -
-{render acl=$telephoneNumberACL checkbox=$multiple_support checked=$use_telephoneNumber} - -{/render} -
-{render acl=$mobileACL checkbox=$multiple_support checked=$use_mobile} - -{/render} -
-{render acl=$pagerACL checkbox=$multiple_support checked=$use_pager} - -{/render} -
-{render acl=$facsimileTelephoneNumberACL checkbox=$multiple_support checked=$use_facsimileTelephoneNumber} - -{/render} -
-
-   - - - - - - - - - - - - - - -
-{render acl=$lACL checkbox=$multiple_support checked=$use_l} - -{/render} -
-{render acl=$stACL checkbox=$multiple_support checked=$use_st} - -{/render} -
-{render acl=$postalAddressACL checkbox=$multiple_support checked=$use_postalAddress} - -{/render} -
-
- - - - - - - - - - - - - - - - - - - - - -
-{render acl=$vocationACL checkbox=$multiple_support checked=$use_vocation} - -{/render} -
-{render acl=$gouvernmentOrganizationalUnitDescriptionACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnitDescription} - -{/render} -
-{render acl=$gouvernmentOrganizationalUnitSubjectAreaACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnitSubjectArea} - -{/render} -
-{render acl=$functionalTitleACL checkbox=$multiple_support checked=$use_functionalTitle} - -{/render} -
-{render acl=$roleACL checkbox=$multiple_support checked=$use_role} - -{/render} -
-
- - - - - - - - - - - - - - - - - - - - - -
-{render acl=$gouvernmentOrganizationalPersonLocalityACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalPersonLocality} - -{/render} -
-{render acl=$gouvernmentOrganizationalUnitACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnit} - -{/render} -
-{render acl=$streetACL checkbox=$multiple_support checked=$use_street} - -{/render} -
-{render acl=$postalCodeACL checkbox=$multiple_support checked=$use_postalCode} - -{/render} -
-{render acl=$houseIdentifierACL checkbox=$multiple_support checked=$use_houseIdentifier} - -{/render} -
-
- - - - - - - - - - - - - - - - - - - - - -
-{render acl=$roomNumberACL checkbox=$multiple_support checked=$use_roomNumber} - -{/render} -
-{render acl=$telephoneNumberACL checkbox=$multiple_support checked=$use_telephoneNumber} - {if $has_phoneaccount ne "true"} - - {else} - {t}Please use the phone tab{/t} - {/if} -{/render} -
-{render acl=$facsimileTelephoneNumberACL checkbox=$multiple_support checked=$use_facsimileTelephoneNumber} - -{/render} -
-{render acl=$ivbbLastDeliveryCollectiveACL checkbox=$multiple_support checked=$use_ivbbLastDeliveryCollective} - -{/render} -
-{render acl=$publicVisibleACL checkbox=$multiple_support checked=$use_publicVisible} - -{/render} -
-
- -{if $multiple_support} - -{/if} - - - - diff --git a/plugins/personal/generic/generic_certs.tpl b/plugins/personal/generic/generic_certs.tpl deleted file mode 100644 index 0b5e7597c..000000000 --- a/plugins/personal/generic/generic_certs.tpl +++ /dev/null @@ -1,96 +0,0 @@ - - -

{t}Certificates{/t}

- - - - - - - - -
- {t}Standard certificate{/t} - - - - {if $userCertificate_state ne "true"} - {render acl=$CertificateACL} - - {/render} - {else} - {render acl=$CertificateACL} - - {/render} - {/if} -
- -
- - - - - - - -
- {t}S/MIME certificate{/t} - - - - {if $userSMIMECertificate_state ne "true"} - {render acl=$CertificateACL} - - {/render} - {else} - {render acl=$CertificateACL} - - {/render} - {/if} -
- -
- - - - - - - - - {if $governmentmode eq "true"} - - - - - {/if} -
- {t}PKCS12 certificate{/t} - - - - {if $userPKCS12_state ne "true"} - {render acl=$CertificateACL} - - {/render} - {else} - {render acl=$CertificateACL} - - {/render} - {/if} -
- - - {render acl=$CertificateACL} - - {/render} -
- -

- {render acl=$CertificateACL} - - {/render} -   - -

- diff --git a/plugins/personal/generic/generic_picture.tpl b/plugins/personal/generic/generic_picture.tpl deleted file mode 100644 index 0e2b06cff..000000000 --- a/plugins/personal/generic/generic_picture.tpl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - -
-

{t}Personal picture{/t}

-
- - - - -
- {t}Personal picture{/t} -
-
- - -   - -
-
-

- -   - -

- diff --git a/plugins/personal/generic/main.inc b/plugins/personal/generic/main.inc deleted file mode 100644 index e35ee1eed..000000000 --- a/plugins/personal/generic/main.inc +++ /dev/null @@ -1,198 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('user'); - } - - /* Create user object on demand */ - if (!isset($_SESSION['user']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['user']= new user ($config, $ui->dn); - $_SESSION['user']->enable_CSN_check(); - $_SESSION['user']->set_acl_base($ui->dn); - $_SESSION['user']->set_acl_category("users"); - } - $user= $_SESSION['user']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $user->save_object (); - } - - /* Enter edit mode? */ - if ((isset($_POST['edit'])) && (!isset( $_SESSION['edit'])) &&preg_match("/w/",$ui->get_permissions($ui->dn,"users/user"))){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - } - - /* Perform password change */ - if (isset($_POST['password_finish'])){ - - /* For security reasons, check if user is allowed to set password again */ - if ($user->acl_is_writeable("userPassword") || $user->acl_is_createable()){ - - /* Check input and feed errors into 'message' */ - $message= array(); - - /* Sanity checks... */ - if ($_POST['new_password'] != $_POST['repeated_password']){ - - /* Matching passwords in new and repeated? */ - $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match."); - } else { - - /* Empty password is not permitted by default. */ - if ($_POST['new_password'] == ""){ - $message[]= _("The password you've entered as 'New password' is empty."); - } - } - - /* Errors, or change password? */ - if (count($message) != 0){ - - /* Show error message and continue editing */ - show_errors ($message); - $display.= $smarty->fetch(get_template_path('password.tpl', TRUE)); - return ($display); - } - change_password ($user->dn, $_POST['new_password'], 0, $user->pw_storage); - new log("modify","users/password","",array(),"Password has been changed"); - - } else { - - /* Missing permissions, show message */ - print_red (_("You are not allowed to set your password!")); - } - - del_lock ($ui->dn); - sess_del ('user'); - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $user->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $user->save (); - del_lock ($ui->dn); - sess_del ('edit'); - - /* Need to reset the password? */ - if($user->password_change_needed()){ - /* Save object */ - $_SESSION['user']= $user; - - $display.= $smarty->fetch(get_template_path('password.tpl', TRUE)); - return ($display); - } else { - sess_del ('user'); - } - - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display.= $lock_msg; - }else{ - $display.= $user->execute (); - } - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['user']= $user; - } - - $info = ""; - - /* Show page footer depending on the mode */ - if (!$user->cert_dialog && !$user->picture_dialog && !$user->dialog && $user->is_account && empty($lock_msg)){ - $display.= "

"; - - /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - - $info= "\"\" ".$ui->dn." "; - } else { - /* 'viewid' may be set by i.e. the phonelist plugin. This - means that we want to go back... */ - if (isset ($viewid)){ - $str= _("Back"); - $fn = "back"; - } else { - $str= _("Edit"); - $fn = "edit"; - $info= "\"\" ".$ui->dn." "; - } - - /* Only display edit button if there is at least one attribute editable */ - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/user"))){ - if ($fn == "edit"){ - $info.= "\"\" ". - _("Click the 'Edit' button below to change informations in this dialog"); - $display.= "\n"; - } - } - - $display.= "\n"; - } - $display.= "

\n"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/personal.png'), - _("Generic user information"), $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/generic/multiple_generic.tpl b/plugins/personal/generic/multiple_generic.tpl deleted file mode 100644 index d6f4f030b..000000000 --- a/plugins/personal/generic/multiple_generic.tpl +++ /dev/null @@ -1,482 +0,0 @@ - - - - - - - - - -
- -

{t}Personal information{/t}

-
- - - - -
- {t}Personal picture{/t} -
-
- - - - - - - - - - - - - -
- - - - -
- - - - -
-
-
- -
-
-
- - - -
-
- - - - - - - - - - - - - - - - - - -
- - - - -
- - - - -
- - - - -
-
-
-
-
-

- - - - - - - - {if $governmentmode ne "true"} - - - - - - - - - {else} - - - - - - - {/if} - -
-

- -  {t}Organizational information{/t}

-
- - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
-
-   - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
-
-   - - - - - - - - - - - - - - -
- - - - -
- - - - -
- - - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
-
- - - diff --git a/plugins/personal/generic/password.tpl b/plugins/personal/generic/password.tpl deleted file mode 100644 index 3d26511fc..000000000 --- a/plugins/personal/generic/password.tpl +++ /dev/null @@ -1,28 +0,0 @@ -

- {t}You have changed the method your password is stored in the ldap database. For that reason you've to enter your password at this point again. GOsa will then encode it with the selected method.{/t} -

- - - - - - - - - - -
-
-

- -   - -

- - - diff --git a/plugins/personal/generic/paste_generic.tpl b/plugins/personal/generic/paste_generic.tpl deleted file mode 100644 index 0fc160888..000000000 --- a/plugins/personal/generic/paste_generic.tpl +++ /dev/null @@ -1,59 +0,0 @@ -

{t}User settings{/t}

- - - - - -
- - - - - - - - - - - - - - - - - -
- {t}Password{/t} - - {t}Clear password{/t}
- {t}Set new password{/t} -
-
- - - - - - - - - - -
- - - - -
- {t}Personal picture{/t} -
-
- - {t}User picture{/t} - - -   - -
-
-
diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc deleted file mode 100644 index 4b6a7b9ef..000000000 --- a/plugins/personal/mail/class_mailAccount.inc +++ /dev/null @@ -1,1208 +0,0 @@ - - \version 2.00 - \date 24.07.2003 - - This class provides the functionality to read and write all attributes - relevant for gosaMailAccounts from/to the LDAP. It does syntax checking - and displays the formulars required. - */ - -class mailAccount extends plugin -{ - /* Definitions */ - var $plHeadline = "Mail"; - var $plDescription = "This does something"; - var $method = "mailMethod"; - - /* CLI vars */ - var $gosaVacationStart = 0; - var $gosaVacationStop = 0; - var $view_logged = FALSE; - - /* plugin specific values */ - var $mail = ""; - var $gosaMailAlternateAddress = array(); - var $gosaMailForwardingAddress = array(); - var $gosaMailDeliveryMode = "[L ]"; - var $gosaMailServer = ""; - var $gosaMailQuota = ""; - var $gosaMailMaxSize = ""; - var $gosaVacationMessage = ""; - var $gosaSpamSortLevel = ""; - var $gosaSpamMailbox = ""; - - var $quotaUsage = 0; - var $forward_dialog = FALSE; - var $folder_prefix = ""; - var $mailboxList = array("INBOX"); - var $default_permissions = "none"; - var $member_permissions = "post"; - var $members = array(); - var $admins = array(); - var $vacations = array(); - var $perms = array( "lrs" => "read", - "lrsp" => "post", - "lrsip" => "append", - "lrswipcd" => "write", - "lrswipcda" => "all" ); - - /* attribute list for save action */ - var $attributes= array("mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize","gosaMailForwardingAddress", - "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox","gosaMailAlternateAddress","gosaVacationStart","gosaVacationStop", - "gosaVacationMessage", "gosaMailAlternateAddress", "gosaMailForwardingAddress"); - var $objectclasses= array("gosaMailAccount"); - var $uid = ""; - - var $sieve_management = NULL; - - /* constructor, if 'dn' is set, the node loads the given - 'dn' from LDAP */ - function mailAccount (&$config, $dn= NULL) - { - global $class_mapping; - - /* Load bases attributes */ - plugin::plugin($config, $dn); - - /* Set uid */ - if(isset($this->attrs['uid'])){ - $this->uid = $this->attrs['uid'][0]; - } - - if(is_array($this->gosaMailServer) && isset($this->gosaMailServer[0])){ - $this->gosaMailServer = $this->gosaMailServer[0]; - } - - /* Save initial account state */ - $this->initially_was_account= $this->is_account; - - /* Set mailMethod to the one defined in gosa.conf */ - if (isset($this->config->current['MAILMETHOD'])){ - $method= $this->config->current['MAILMETHOD']; - - $cls = get_correct_class_name("mailMethod$method"); - if ($cls && class_exists($cls)){ - $this->method= $cls; - } else { - print_red(sprintf(_("There is no mail method '%s' specified in your gosa.conf available."), $method)); - } - } - - - /* Create the account prefix user. user/ - Preset folder prefix. Will change it later to respect - altnamespace. */ - if (isset($this->config->current['CYRUSUNIXSTYLE']) && $this->config->current['CYRUSUNIXSTYLE'] == "true"){ - $this->folder_prefix= "user/"; - }elseif (isset($this->config->data['MAIN']['CYRUSUNIXSTYLE']) && $this->config->data['MAIN']['CYRUSUNIXSTYLE'] == "true"){ - $this->folder_prefix= "user/"; - } else { - $this->folder_prefix= "user."; - } - - /* This is not a new account, parse additional attributes */ - if (($dn !== NULL) && ($dn != "new") && $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]); - } - } - } - - - /* Only do IMAP actions if gosaMailServer attribute is set */ - if (isset ($this->attrs["gosaMailServer"][0])){ - - $method = new $this->method($this->config); - $id = $method->uattrib; - - /* Adapt attributes if needed */ - $method->fixAttributesOnLoad($this); - - /* FixAttributesOnLoad possibly creates an array out of gosaMailServer. - If the mail tab wasn't opened once before saving, the account can't be saved */ - if(is_array($this->gosaMailServer)){ - $this->gosaMailServer = $this->gosaMailServer[0]; - } - - if ($method->connect($this->attrs["gosaMailServer"][0])){ - - /* Update quota values */ - $quota= $method->getQuota($this->folder_prefix.$this->$id); - - if($quota){ - if ($quota['gosaMailQuota'] == 2147483647){ - $this->quotaUsage = ""; - $this->gosaMailQuota = ""; - } else { - $this->quotaUsage = $quota['quotaUsage']; - $this->gosaMailQuota = $quota['gosaMailQuota']; - } - }else{ - $this->quotaUsage = ""; - $this->gosaMailQuota = ""; -// print_red(sprintf(_("Can't get quota information for '%s'."),$this->folder_prefix.$this->$id)); - } - - /* Get mailboxes / folder like INBOX ..*/ - $this->mailboxList= $method->getMailboxList($this->folder_prefix.$this->$id,$this->$id); - - $method->disconnect(); - }else{ - /* Could not connect to ldap. - */ - if (isset($this->attrs['gosaMailQuota'][0])){ - $this->gosaMailQuota = $this->attrs['gosaMailQuota'][0]; - } - } - } - } - - /* Fill vacation array */ - $this->vacation= array(); - if (isset($this->config->current['VACATIONDIR'])){ - $dir= $this->config->current['VACATIONDIR']; - if (is_dir($dir) && is_readable($dir)){ - - /* Look for files and build the vacation array */ - $dh= opendir($dir); - while ($file = readdir($dh)){ - $description= $this->parse_vacation("$dir/$file"); - if ($description != ""){ - $this->vacation["$dir/$file"]= $description; - } - } - closedir($dh); - } - } - - /* Create sieve management class */ - $method = new $this->method($this->config); - $id = $method->uattrib; - $this->sieve_management = new sieveManagement($this->config,$this->dn,$this,$id); - - /* Get global filter config */ - if (!is_global("mailfilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $mailfilter= array( "depselect" => $base, - "muser" => "", - "regex" => "*"); - register_global("mailfilter", $mailfilter); - } - } - - - function parse_vacation($file) - { - $desc= ""; - - if (is_file($file)){ - $fh = fopen($file, "r"); - $line= fgets($fh, 256); - - if (!preg_match('/^DESC:/', $line)){ - print_red (_("No DESC tag in vacation file:")." $file"); - return $desc; - } - fclose ($fh); - - $desc= trim(preg_replace('/^DESC:\s*/', '', $line)); - } - - return $desc; - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Initialise vars */ - - /* Load templating engine */ - $smarty= get_smarty(); - $display= ""; - - /* Get available mailserver */ - $mailserver= array(); - foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){ - $mailserver[]= $key; - } - - /* - * Sieve Management - */ - if(isset($_POST['sieveManagement']) - && preg_match("/C/",$this->gosaMailDeliveryMode) - && $this->acl_is_writeable("sieveManagement")) { - - $this->dialog = $this->sieve_management; - } - - /* Cancel sieve edit */ - if(isset($_POST['sieve_cancel'])){ - $this->dialog = FALSE; - } - - /* Save sieve changes */ - if(isset($_POST['sieve_finish'])){ - $this->sieve_management = $this->dialog; - $this->dialog = FALSE; - } - - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - - /* Handle account state */ - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This account has no mail extensions.").""; - - $display.= back_to_main(); - return ($display); - } - - /* Show tab dialog headers */ - if ($this->parent !== NULL){ - if ($this->is_account){ - if($this->accountDelegationsConfigured()){ - $display= $this->show_disable_header(_("Remove mail account"), - _("This account can't be removed while there are delegations configured. Remove those delegations first."),TRUE,TRUE); - }else{ - $display= $this->show_disable_header(_("Remove mail account"), - _("This account has mail features enabled. You can disable them by clicking below.")); - } - } else { - $display= $this->show_enable_header(_("Create mail account"), _("This account has mail features disabled. You can enable them by clicking below.")); - return ($display); - } - } - - - /* Forwarder subdialog */ - - /* Trigger forward add dialog? */ - if (isset($_POST['add_local_forwarder'])){ - $this->forward_dialog= TRUE; - $this->dialog= TRUE; - } - - /* Cancel forward add dialog? */ - if (isset($_POST['add_locals_cancel'])){ - $this->forward_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Finished adding of locals? */ - if (isset($_POST['add_locals_finish'])){ - - /* Check if we are able to write gosaMailForwardingAddress */ - if($this->acl_is_writeable("gosaMailForwardingAddress")){ - - /* Walk through list of forwarders, ignore own addresses */ - foreach ($_POST['local_list'] as $val){ - if (!in_array ($val, $this->gosaMailAlternateAddress) && - $val != $this->mail){ - - $this->addForwarder($val); - $this->is_modified= TRUE; - } - } - } - $this->forward_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Add forward email addresses */ - if (isset($_POST['add_forwarder'])){ - if ($_POST['forward_address'] != ""){ - - /* Valid email address specified? */ - $address= $_POST['forward_address']; - $valid= FALSE; - if (!is_email($address)){ - if (!is_email($address, TRUE)){ - if ($this->is_template){ - $valid= TRUE; - } else { - print_red (_("You're trying to add an invalid email address to the list of forwarders.")); - } - } - } elseif ($address == $this->mail - || in_array($address, $this->gosaMailAlternateAddress)) { - - print_red (_("Adding your one of your own addresses to the forwarders makes no sense.")); - - } else { - $valid= TRUE; - } - - if ($valid){ - - /* Add it, if we are able to write gosaMailForwardingAddress */ - if($this->acl_is_writeable("gosaMailForwardingAddress")){ - $this->addForwarder ($address); - $this->is_modified= TRUE; - } - } - } - } - - /* Delete forward email addresses */ - if (isset($_POST['delete_forwarder'])){ - $this->delForwarder ($_POST['forwarder_list']); - } - - - /* Add alternate email addresses */ - if (isset($_POST['add_alternate'])){ - - $valid= FALSE; - if (!is_email($_POST['alternate_address'])){ - if ($this->is_template){ - if (!(is_email($_POST['alternate_address'], TRUE))){ - print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); - } else { - $valid= TRUE; - } - } else { - print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); - } - - } else { - $valid= TRUE; - } - - if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){ - $ui= get_userinfo(); - if ($user != $ui->username){ - print_red (_("The address you're trying to add is already used by user")." '$user'."); - } - } - } - - /* Delete alternate email addresses */ - if (isset($_POST['delete_alternate']) && isset($_POST['alternates_list'])){ - $this->delAlternate ($_POST['alternates_list']); - } - - - /* Vacation message */ - - /* Import vacation message? */ - if (isset($_POST["import_vacation"]) && isset($this->vacation[$_POST["vacation_template"]])){ - $contents= ""; - $lines= file($_POST["vacation_template"]); - foreach ($lines as $line){ - if (!preg_match('/^DESC:/', $line)){ - $contents.= $line; - } - } - - /* Replace attributes */ - $attrs= $this->parent->by_object['user']->attributes; - foreach ($attrs as $val){ - - if(preg_match("/dateOfBirth/",$val)){ - if($this->parent->by_object['user']->use_dob){ - $contents= preg_replace("/%$val/",date("Y-d-m",$this->parent->by_object['user']->dateOfBirth),$contents); - } - }else { - $contents= preg_replace("/%$val/", - $this->parent->by_object['user']->$val, $contents); - } - - /* Replace vacation start and end time */ - if(preg_match("/%start/",$contents)){ - $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents); - } - if(preg_match("/%end/",$contents)){ - $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents); - } - } - - /* Save message */ - $this->gosaVacationMessage= htmlspecialchars($contents); - } - - - /* Display forward dialog if requested above */ - - /* Show forward add dialog */ - if ($this->forward_dialog){ - $ldap= $this->config->get_ldap_link(); - - /* Save data */ - $mailfilter= get_global("mailfilter"); - foreach( array("depselect", "muser", "regex") as $type){ - if (isset($_POST[$type])){ - $mailfilter[$type]= $_POST[$type]; - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $mailfilter['regex']= $s; - } - register_global("mailfilter", $mailfilter); - - /* Get actual list */ - $mailusers= array (); - if ($mailfilter['regex'] != '*' && $mailfilter['regex'] != ""){ - $regex= $mailfilter['regex']; - $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))"; - } else { - $filter= ""; - } - if ($mailfilter['muser'] != ""){ - $user= $mailfilter['muser']; - $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))"; - } - - /* Add already present people to the filter */ - $exclude= ""; - foreach ($this->gosaMailForwardingAddress as $mail){ - $exclude.= "(mail=$mail)"; - } - if ($exclude != ""){ - $filter.= "(!(|$exclude))"; - } - - $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $mailfilter['depselect'], - array("sn", "mail", "givenName"), GL_SIZELIMIT | GL_SUBSEARCH); - $ldap->cd($mailfilter['depselect']); - $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName")); - error_reporting (0); - while ($attrs= $ldap->fetch()){ - if(preg_match('/%/', $attrs['mail'][0])){ - continue; - } - $name= $this->make_name($attrs); - $mailusers[$attrs['mail'][0]]= $name."<". - $attrs['mail'][0].">"; - } - error_reporting (E_ALL | E_STRICT); - natcasesort ($mailusers); - reset ($mailusers); - - /* Show dialog */ - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("usearch_image", get_template_path('images/search_user.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("mailusers", $mailusers); - if (isset($_POST['depselect'])){ - $smarty->assign("depselect", $_POST['depselect']); - } - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("hint", print_sizelimit_warning()); - foreach( array("depselect", "muser", "regex") as $type){ - $smarty->assign("$type", $mailfilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - - $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /* Display mail account tab */ - - $smarty->assign("mailServers", $mailserver); - $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $transl){ - $smarty->assign("$name"."ACL", $this->getacl($name,$SkipWrite)); - } - - foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail", - "gosaMailAlternateAddress", "gosaMailForwardingAddress", - "gosaVacationMessage", "gosaMailDeliveryMode", "gosaVacationStart", - "gosaVacationStop", "gosaMailMaxSize", "gosaSpamSortLevel", "gosaSpamMailbox") as $val){ - $smarty->assign("$val", $this->$val); - } - - if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){ - $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true)); - $smarty->assign("quotadefined", "true"); - } else { - $smarty->assign("quotadefined", "false"); - } - - /* Disable mail field if needed */ - $method= new $this->method($this->config); - if ($method->uattrib == "mail" && $this->initially_was_account){ - $smarty->assign("mailACL", preg_replace("/w/","",$this->getacl("mail",$SkipWrite))); - } - - /* Disable/Enable range select, but do not disable them twice - * if they are already diabled by "use own sieve script" - */ - if (preg_match('/V/', $this->gosaMailDeliveryMode) || preg_match("/C/",$this->gosaMailDeliveryMode)){ - $smarty->assign('rangeEnabled', ""); - } else { - $smarty->assign('rangeEnabled', "disabled"); - } - - if (!preg_match("/L/", $this->gosaMailDeliveryMode)) { - $smarty->assign("only_local", "checked"); - } else { - $smarty->assign("only_local", ""); - } - - $types = array( - "V"=>"use_vacation", - "S"=>"use_spam_filter", - "R"=>"use_mailsize_limit", - "I"=>"drop_own_mails", - "C"=>"own_script"); - - /* Fill checkboxes */ - foreach($types as $option => $varname){ - if (preg_match("/".$option."/", $this->gosaMailDeliveryMode)) { - $smarty->assign($varname, "checked"); - } else { - $smarty->assign($varname, ""); - } - } - - /* Display mail account tab */ - if($this->gosaVacationStart ==0){ - $date= getdate(time()); - }else{ - $date= getdate($this->gosaVacationStart); - } - $days= array(); - for($d= 1; $d<32; $d++){ - $days[$d]= $d; - } - $years= array(); - for($y= $date['year']-10; $y<$date['year']+10; $y++){ - $years[]= $y; - } - $months= array(_("January"), _("February"), _("March"), _("April"), - _("May"), _("June"), _("July"), _("August"), _("September"), - _("October"), _("November"), _("December")); - $smarty->assign("start_day", $date["mday"]); - $smarty->assign("days", $days); - $smarty->assign("months", $months); - $smarty->assign("start_month", $date["mon"]-1); - $smarty->assign("years", $years); - $smarty->assign("start_year", $date["year"]); - - if($this->gosaVacationStop ==0){ - $date= getdate(time()); - $date["mday"]++; - }else{ - $date= getdate($this->gosaVacationStop); - } - $smarty->assign("end_day", $date["mday"]); - $smarty->assign("end_month", $date["mon"]-1); - $smarty->assign("end_year", $date["year"]); - - - - /* Have vacation templates? */ - $smarty->assign("template", ""); - if (count($this->vacation)){ - $smarty->assign("show_templates", "true"); - $smarty->assign("vacationtemplates", $this->vacation); - if (isset($_POST['vacation_template'])){ - $smarty->assign("template", $_POST['vacation_template']); - } - } else { - $smarty->assign("show_templates", "false"); - } - - /* Fill spam selector */ - $spamlevel= array(); - for ($i= 0; $i<21; $i++){ - $spamlevel[]= $i; - } - $smarty->assign("spamlevel", $spamlevel); - $smarty->assign("spambox", $this->mailboxList); - - $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - - /* remove object from parent */ - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - /* Zero arrays */ - $this->attrs['gosaMailAlternateAddress']= array(); - $this->attrs['gosaMailForwardingAddress']= array(); - - /* Adapt attributes if needed */ - $method= new $this->method($this->config); - $method->fixAttributesOnRemove($this); - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - - $ldap->modify ($this->attrs); - - /* Add "view" to logging class */ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/mail account with dn '%s' failed."),$this->dn)); - - /* Connect to IMAP server for account deletion */ - if ($this->gosaMailServer != ""){ - $method= new $this->method($this->config); - $id= $method->uattrib; - if ($method->connect($this->gosaMailServer)){ - - /* Remove account from IMAP server */ - $method->deleteMailbox($this->folder_prefix.$this->$id); - $method->disconnect(); - } - } - - /* Update shared folder membership, ACL may need to be updated */ - $this->updateSharedFolder(); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove",array("uid" => $this->uid)); - } - - - /* check if we have some delegations configured, those delegations must be removed first */ - function accountDelegationsConfigured() - { - /* We are in administrational edit mode. - Check tab configurations directly */ - if(isset($this->attrs)){ - $checkArray = array("kolabInvitationPolicy","unrestrictedMailSize", "calFBURL","kolabDelegate","kolabFreeBusyFuture"); - foreach($checkArray as $index){ - if(isset($this->attrs[$index])){ - return(true); - } - } - } - return(false); - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['mailTab'])){ - - /* Save ldap attributes */ - plugin::save_object(); - - - if(isset($_POST['own_script'])){ - - if(!preg_match("/C/",$this->gosaMailDeliveryMode)){ - $str= preg_replace("/[\[\]]/","",$this->gosaMailDeliveryMode); - $this->gosaMailDeliveryMode = "[".$str."C]"; - } - - }else{ - - /* Assemble mail delivery mode - The mode field in ldap consists of values between braces, this must - be called when 'mail' is set, because checkboxes may not be set when - we're in some other dialog. - - Example for gosaMailDeliveryMode [LR ] - L: Local delivery - R: Reject when exceeding mailsize limit - S: Use spam filter - V: Use vacation message - C: Use custm sieve script - I: Only insider delivery */ - - $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode); - - - /* Handle delivery flags */ - if($this->acl_is_writeable("gosaMailDeliveryModeL")){ - if(!preg_match("/L/",$tmp) && !isset($_POST['only_local'])){ - $tmp.="L"; - }elseif(preg_match("/L/",$tmp) && isset($_POST['only_local'])){ - $tmp = preg_replace("/L/","",$tmp); - } - } - - $opts = array( - "R" => "use_mailsize_limit", - "S" => "use_spam_filter", - "V" => "use_vacation", - "C" => "own_script", - "I" => "drop_own_mails"); - - foreach($opts as $flag => $post){ - if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){ - if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){ - $tmp.= $flag; - }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){ - $tmp = preg_replace("/".$flag."/","",$tmp); - } - } - } - - $tmp= "[$tmp]"; - if ($this->gosaMailDeliveryMode != $tmp){ - $this->is_modified= TRUE; - } - $this->gosaMailDeliveryMode= $tmp; - } - } - - } - - - /* Save data to LDAP, depending on is_account we save or delete */ - function save() - { - $ldap= $this->config->get_ldap_link(); - - /* Call parents save to prepare $this->attrs */ - plugin::save(); - - /* Save arrays */ - $this->attrs['gosaMailAlternateAddress']= $this->gosaMailAlternateAddress; - $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress; - - /* Adapt attributes if needed */ - $method= new $this->method($this->config); - $id= $method->uattrib; - - $method->fixAttributesOnStore($this); - - /* Remove Mailquota if = "" or "0" */ - if((isset($this->attrs['gosaMailQuota']))&&(!$this->attrs['gosaMailQuota'])) { - $this->attrs['gosaMailQuota']=0; - } - - if(empty($this->attrs['gosaSpamMailbox'])){ - unset($this->attrs['gosaSpamMailbox']); - } - - $this->attrs['mail'] = strtolower($this->attrs['mail']); - - /* Remove attributes - if not needed */ - if (!preg_match('/V/', $this->gosaMailDeliveryMode)){ - unset($this->attrs['gosaVacationStart']); - unset($this->attrs['gosaVacationStop']); - } - - - /* Remove attributes - if not needed */ - if (!preg_match('/V/', $this->gosaMailDeliveryMode)){ - unset($this->attrs['gosaVacationStart']); - unset($this->attrs['gosaVacationStop']); - } - - /* Save data to LDAP */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/mail account with dn '%s' failed."),$this->dn)); - - /* 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()); - } - - /* Only do IMAP actions if we are not a template */ - if (!$this->is_template){ - - if ($method->connect($this->gosaMailServer)){ - $method->updateMailbox($this->folder_prefix.$this->$id); - - $method->setQuota($this->folder_prefix.$this->$id, $this->gosaMailQuota); - $method->disconnect(); - - /* Ensure that this is an existing account */ - if(1==1 || $this->initially_was_account){ - - /* Write sieve information only if not in C mode */ - if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){ - $method->configureFilter($this->$id, - $this->gosaMailDeliveryMode, - $this->mail, - $this->gosaMailAlternateAddress, - $this->gosaMailMaxSize, - $this->gosaSpamMailbox, - $this->gosaSpamSortLevel, - $this->gosaVacationMessage); - $this->is_modified = TRUE; - }else{ - $this->sieve_management->save(); - } - } - } - } - - /* 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", array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add", array("uid" => $this->uid)); - } - - $this->updateSharedFolder(); - } - - - /* Check formular input */ - 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(); - - if(empty($this->gosaMailServer)){ - $message[]= _("There is no valid mailserver specified, please add one in the system setup."); - } - - /* must: mail */ - if ($this->mail == ""){ - $message[]= _("The required field 'Primary address' is not set."); - } - if ($this->is_template){ - if (!is_email($this->mail, TRUE)){ - $message[]= _("Please enter a valid email address in 'Primary address' field."); - } - } else { - if (!is_email($this->mail)){ - $message[]= _("Please enter a valid email address in 'Primary address' field."); - } - } - $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid")); - if ($ldap->count() != 0){ - $message[]= _("The primary address you've entered is already in use."); - } - - /* Check quota */ - if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){ - if (!is_numeric($this->gosaMailQuota)) { - $message[]= _("Value in 'Quota size' is not valid."); - } else { - $this->gosaMailQuota= (int) $this->gosaMailQuota; - } - } - - /* Check rejectsize for integer */ - if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailMaxSize")){ - if (!is_numeric($this->gosaMailMaxSize)){ - $message[]= _("Please specify a vaild mail size for mails to be rejected."); - } else { - $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize; - } - } - - /* Need gosaMailMaxSize if use_mailsize_limit is checked */ - if (is_integer(strpos($this->gosaMailDeliveryMode, "R")) && - $this->gosaMailMaxSize == ""){ - - $message[]= _("You need to set the maximum mail size in order to reject anything."); - } - - if((preg_match("/S/", $this->gosaMailDeliveryMode))&&(empty($this->gosaSpamMailbox))) { - $message[]= _("You specified Spam settings, but there is no Folder specified."); - } - - if (preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){ - $message[]= _("Time interval to show vacation message is not valid."); - } - - return ($message); - } - - - /* Adapt from template, using 'dn' */ - function adapt_from_template($dn) - { - plugin::adapt_from_template($dn); - - foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){ - $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); - } - } - array_push($this->$val, strtolower(rewrite($value))); - } - } - } - $this->mail= strtolower(rewrite($this->mail)); - } - - - /* Add entry to forwarder list */ - function addForwarder($address) - { - if($this->acl_is_writeable("gosaMailForwardingAddress")){ - $this->gosaMailForwardingAddress[]= $address; - $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress); - sort ($this->gosaMailForwardingAddress); - reset ($this->gosaMailForwardingAddress); - $this->is_modified= TRUE; - }else{ - print_red(_("You are not allowed to write mail forwarding.")); - } - } - - - /* Remove list of addresses from forwarder list */ - function delForwarder($addresses) - { - if($this->acl_is_writeable("gosaMailForwardingAddress")){ - $this->gosaMailForwardingAddress= array_remove_entries ($addresses, $this->gosaMailForwardingAddress); - $this->is_modified= TRUE; - }else{ - print_red(_("You are not allowed to write mail forwarding.")); - } - } - - - /* 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($this->acl_is_writeable("gosaMailAlternateAddress")){ - $ldap= $this->config->get_ldap_link(); - $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("uid")); - $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid")); - - if ($ldap->count() > 0){ - $attrs= $ldap->fetch (); - return ($attrs["uid"][0]); - } - - /* Add to list of alternates */ - if (!in_array($address, $this->gosaMailAlternateAddress)){ - $this->gosaMailAlternateAddress[]= $address; - $this->is_modified= TRUE; - } - - sort ($this->gosaMailAlternateAddress); - reset ($this->gosaMailAlternateAddress); - return (""); - }else{ - print_red(_("You are not allowed to write mail alternate address.")); - } - } - - - function delAlternate($addresses) - { - if($this->acl_is_writeable("gosaMailAlternateAddress")){ - $this->gosaMailAlternateAddress= array_remove_entries ($addresses,$this->gosaMailAlternateAddress); - $this->is_modified= TRUE; - }else{ - print_red(_("You are not allowed to write mail alternate address.")); - } - } - - 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.= " "; - } - - return ($name); - } - - - /* Create the mail part for the copy & paste dialog */ - function getCopyDialog() - { - if(!$this->is_account) return(""); - $smarty = get_smarty(); - $smarty->assign("mail",$this->mail); - $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress); - $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress); - $str = $smarty->fetch(get_template_path("copypaste.tpl",TRUE, dirname(__FILE__))); - - $ret = array(); - $ret['status'] = ""; - $ret['string'] = $str; - return($ret); - } - - function saveCopyDialog() - { - if(!$this->is_account) return; - - /* Execute to save mailAlternateAddress && gosaMailForwardingAddress */ - $this->execute(); - - if(isset($_POST['mail'])){ - $this->mail = $_POST['mail']; - } - - } - - function allow_remove() - { - if (isset($this->config->current['MAILMETHOD'])){ - $method= $this->config->current['MAILMETHOD']; - if(preg_match("/olab/i",$method)){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn); - if($ldap->count()){ - $attrs = $ldap->fetch(); - if(isset($attrs['kolabDeleteFlag'])){ - return(_("Waiting for kolab to remove mail properties.")); - }elseif(in_array("gosaMailAccount",$attrs['objectClass'])){ - return(_("Please remove the mail account first, to allow kolab to call its remove methods.")); - } - } - } - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Reset alternate mail addresses */ - $this->gosaMailAlternateAddress = array(); - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Mail"), - "plDescription" => _("Mail settings"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), // This plugin depends on - "plPriority" => 4, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "mail" => _("Mail address"), - "gosaMailServer" => _("Mail server"), - "gosaMailQuota" => _("Quota size"), - - "gosaMailDeliveryModeV" => _("Add vacation information"), // This is flag of gosaMailDeliveryMode - "gosaVacationMessage" => _("Vacation message"), - - "gosaMailDeliveryModeS" => _("Use spam filter"), // This is flag of gosaMailDeliveryMode - "gosaSpamSortLevel" => _("Spam level"), - "gosaSpamMailbox" => _("Spam mail box"), - - "sieveManagement" => _("Sieve management"), - - "gosaMailDeliveryModeR" => _("Reject due to mailsize"), // This is flag of gosaMailDeliveryMode - "gosaMailMaxSize" => _("Mail max size"), - - "gosaMailForwardingAddress" => _("Forwarding address"), - "gosaMailDeliveryModeL" => _("Local delivery"), // This is flag of gosaMailDeliveryMode - "gosaMailDeliveryModeI" => _("No delivery to own mailbox "), // This is flag of gosaMailDeliveryMode - "gosaMailAlternateAddress" => _("Mail alternative addresses"), - - "gosaMailForwardingAddress" => _("Forwarding address"), - "gosaMailDeliveryModeC" => _("Use custom sieve script")) // This is flag of gosaMailDeliveryMode - )); - } - - /* Upated shared folder ACLs - */ - function updateSharedFolder() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array('dn','cn')); - if(class_exists("grouptabs")){ - while($attrs = $ldap->fetch()){ - $tmp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']); - if(isset($tmp->by_object['mailgroup'])){ - $tmp->by_object['mailgroup']->members= $tmp->by_object['group']->memberUid; - if(!$this->is_account){ - $tmp->by_object['mailgroup']->removeUserAcl($this->uid); - $tmp->by_object['mailgroup']->removeUserAcl($this->mail); - } - $tmp->by_object['mailgroup']->save(); - } - } - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/mail/copypaste.tpl b/plugins/personal/mail/copypaste.tpl deleted file mode 100644 index 56ec107ff..000000000 --- a/plugins/personal/mail/copypaste.tpl +++ /dev/null @@ -1,70 +0,0 @@ -

{t}Mail settings{/t}

- - - - - - - - - -
- - - - - - - - -
{$must}
-

- -

-
-
- - - - -
-

- - -

-
-
- - - - -
- -
- -   -   - -
-
- - - - -
- -
- - - -
-
-
-
diff --git a/plugins/personal/mail/generic.tpl b/plugins/personal/mail/generic.tpl deleted file mode 100644 index 785fd44f6..000000000 --- a/plugins/personal/mail/generic.tpl +++ /dev/null @@ -1,314 +0,0 @@ - - - - - - - - -
- -

 {t}Generic{/t}

- - - - - - - - - - - - - - - - - -
{$must} -{render acl=$mailACL} - -{/render} -
-{render acl=$gosaMailServerACL} - -{/render} -
-
- {t}Quota usage{/t} -
-
- {if $quotadefined eq "true"} - {$quotausage} - {else} - {t}not defined{/t} - {/if} -
-{render acl=$gosaMailQuotaACL} - MB -{/render} -
-
-   - -

-{render acl=$gosaMailAlternateAddressACL} - -
-{render acl=$gosaMailAlternateAddressACL} - -{/render} -{render acl=$gosaMailAlternateAddressACL} - -{/render} -{render acl=$gosaMailAlternateAddressACL} - -{/render} -
- -

 

-

 {t}Mail options{/t}

- - - - - - - -
-{render acl=$gosaMailDeliveryModeCACL} - {t}Use custom sieve script{/t} ({t}disables all Mail options!{/t}) -{/render} -
-{render acl=$sieveManagementACL} - -{/render} -
- - -

 

- - - - - - - - - -
-{render acl=$gosaMailDeliveryModeIACL} - {t}No delivery to own mailbox{/t} -{/render} - -
-{render acl=$gosaMailDeliveryModeVACL} - {t}Activate vacation message{/t} -{/render} - -
- - - - - - - - - - -
- {t}from{/t} - -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} - -
- {t}till{/t} - -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} - -
- - -
-   - -{render acl=$gosaMailDeliveryModeSACL} - -{/render} - - -{render acl=$gosaSpamSortLevelACL} - -{/render} - -{render acl=$gosaSpamMailboxACL} - -{/render} -
-{render acl=$gosaMailDeliveryModeRACL} - -{/render} - -{render acl=$gosaMailMaxSizeACL} - {t}MB{/t} -{/render} -
-

- -

-{render acl=$gosaVacationMessageACL} - -{/render} -
- - {if $show_templates eq "true"} -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} - {/if} -
-

- -

-{render acl=$gosaMailForwardingAddressACL} - -{/render} -
-{render acl=$gosaMailForwardingAddressACL} - -{/render} -{render acl=$gosaMailForwardingAddressACL} -   -{/render} -{render acl=$gosaMailForwardingAddressACL} -   -{/render} -{render acl=$gosaMailForwardingAddressACL} - -{/render} -
-

 

- -

 {t}Advanced mail options{/t}

- - - - - -
-{render acl=$gosaMailDeliveryModeLACL} - -{/render} - {t}User is only allowed to send and receive local mails{/t} -
- - - - - diff --git a/plugins/personal/mail/mail_locals.tpl b/plugins/personal/mail/mail_locals.tpl deleted file mode 100644 index d277ceb45..000000000 --- a/plugins/personal/mail/mail_locals.tpl +++ /dev/null @@ -1,81 +0,0 @@ - - - - - -
-
-

- - - {$hint} - -
-

-
-
-

- -

-
-
-
-

- [F] - {t}Filters{/t} -

-
-
- - {$alphabet} -
- - - - -
- -   - -
- - - - - - -
- - - -
- - - - - - -
- {t}Display addresses of user{/t} - - -
- {$apply} -
-
- -

- -   - -

- diff --git a/plugins/personal/mail/main.inc b/plugins/personal/mail/main.inc deleted file mode 100644 index dda8cd770..000000000 --- a/plugins/personal/mail/main.inc +++ /dev/null @@ -1,130 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('mailAccount'); - } - - /* Create mail object on demand */ - if (!isset($_SESSION['mailAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['mailAccount']= new mailAccount ($config, $ui->dn); - $_SESSION['mailAccount']->enable_CSN_check(); - $_SESSION['mailAccount']->set_acl_base($ui->dn); - $_SESSION['mailAccount']->set_acl_category("users"); - } - $mailAccount= $_SESSION['mailAccount']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $mailAccount->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit']) && preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $mailAccount->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $mailAccount->save (); - del_lock ($ui->dn); - sess_del ('edit'); - - /* Remove object */ - sess_del ('mailAccount'); - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display.= $lock_msg; - }else{ - $display.= $mailAccount->execute (); - } - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['mailAccount']= $mailAccount; - } - - $info= ""; - /* Show page footer depending on the mode */ - if (!$mailAccount->forward_dialog && $mailAccount->is_account && empty($lock_msg)){ - $display.= "

"; - - /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - $info.= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); - - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){ - $display.= "\n"; - } - - $display.= "\n"; - } - $display.= "

\n"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/email.png'), _("User mail settings"), $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/mail/sieve-discard.txt b/plugins/personal/mail/sieve-discard.txt deleted file mode 100644 index 8ac4db68a..000000000 --- a/plugins/personal/mail/sieve-discard.txt +++ /dev/null @@ -1,3 +0,0 @@ -# Do not deliver to own mailbox -discard; - diff --git a/plugins/personal/mail/sieve-header.txt b/plugins/personal/mail/sieve-header.txt deleted file mode 100644 index 5222282e5..000000000 --- a/plugins/personal/mail/sieve-header.txt +++ /dev/null @@ -1,3 +0,0 @@ -###GOSA -require ["fileinto", "reject", "vacation"]; - diff --git a/plugins/personal/mail/sieve-mailsize.txt b/plugins/personal/mail/sieve-mailsize.txt deleted file mode 100644 index de639c26c..000000000 --- a/plugins/personal/mail/sieve-mailsize.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Reject mails with bigger size -if size :over {$maxsize}M{ - reject text: -Dear sender, - -the mail you sent to our mailsystem has been rejected due -to a user configured maximum mail size ($maxsize MB). - -Either ask the user to remove the sizelimit, or send smaller pieces. - -Thank you, - the mailserver -. - ; - discard; -} - diff --git a/plugins/personal/mail/sieve-spam.txt b/plugins/personal/mail/sieve-spam.txt deleted file mode 100644 index 63392d011..000000000 --- a/plugins/personal/mail/sieve-spam.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Sort mails with higher spam level -if header :contains "X-Spam-Level" "$spamlevel" { - fileinto "$spambox"; -} - diff --git a/plugins/personal/mail/sieve-vacation.txt b/plugins/personal/mail/sieve-vacation.txt deleted file mode 100644 index 3aed3a916..000000000 --- a/plugins/personal/mail/sieve-vacation.txt +++ /dev/null @@ -1,4 +0,0 @@ -# Vacation message -vacation :addresses [$addrlist] -"$vacmsg" ; - diff --git a/plugins/personal/nagios/class_nagiosAccount.inc b/plugins/personal/nagios/class_nagiosAccount.inc deleted file mode 100644 index 41b2de34c..000000000 --- a/plugins/personal/nagios/class_nagiosAccount.inc +++ /dev/null @@ -1,313 +0,0 @@ - - \author Benoit Mortier - \author Vincent Seynhaeve - \version 1.00 - \date 25.09.2005 - - This class provides the functionality to read and write all attributes - relevant for nagiosAccount from/to the LDAP. It does syntax checking - and displays the formulars required. - */ - -class nagiosAccount extends plugin -{ - /* Definitions */ - var $plHeadline= "Nagios"; - var $plDescription= "This does something"; - - /* CLI vars */ - var $cli_summary= "Manage users nagios account"; - var $cli_description= "Manage Account and autorization\nfor Nagios"; - var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* plugin specific values */ - var $NagiosAlias = ""; - var $NagiosPager = ""; - var $NagiosMail = ""; - - var $HostNotificationOptions = ""; - var $HostNotificationPeriod = ""; - var $ServiceNotificationPeriod = ""; - var $ServiceNotitificationPeriod = ""; - var $HostNotificationCommands = ""; - var $ServiceNotificationCommands = ""; - var $HostNotitificationOptions = ""; - var $ServiceNotificationOptions = ""; - - var $AuthorizedAllHosts = "unchecked"; - var $AuthorizedAllServices = "unchecked"; - var $AuthorizedSystemCommands = "unchecked"; - var $AuthorizedAllHostCommands = "unchecked"; - var $AuthorizedAllServiceCommands = "unchecked"; - var $AuthorizedConfigurationInformation = "unchecked"; - var $AuthorizedSystemInformation = "unchecked"; - - /* attribute list for save action */ - - var $attributes= array("NagiosAlias", "NagiosPager", "NagiosMail", "HostNotificationPeriod", - "ServiceNotificationPeriod", "HostNotificationCommands", "ServiceNotificationCommands", - "HostNotificationOptions", "ServiceNotificationOptions", "AuthorizedAllHosts", "AuthorizedAllServices", - "AuthorizedSystemCommands", "AuthorizedAllHostCommands", "AuthorizedAllServiceCommands", - "AuthorizedConfigurationInformation", "AuthorizedSystemInformation"); - - var $is_chk_box = array("AuthorizedAllHosts","AuthorizedAllServices","AuthorizedSystemCommands", - "AuthorizedAllHostCommands","AuthorizedAllServiceCommands", - "AuthorizedConfigurationInformation","AuthorizedSystemInformation"); - - var $objectclasses= array("nagiosContact","nagiosAuth"); - - var $uid = ""; - var $view_logged = FALSE; - - /* constructor, if 'dn' is set, the node loads the given - 'dn' from LDAP */ - function nagiosAccount (&$config, $dn= NULL) - { - /* Configuration is fine, allways */ - $this->config= $config; - - plugin::plugin ($config, $dn); - - /* Setting uid to default */ - if(isset($this->attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - /* Save initial account state */ - $this->initially_was_account= $this->is_account; - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Load templating engine */ - $smarty= get_smarty(); - $display= ""; - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\"src=\"images/stop.png\" ". - _("This account has no nagios extensions.").""; - - $display.= back_to_main(); - return ($display); - } - - /* Show tab dialog headers */ - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove nagios account"), - _("This account has nagios features enabled. You can disable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Create nagios account"), _("This account has nagios features disabled. You can enable them by clicking below.")); - return($display); - } - } - - /* Assign acls */ - $tmp = $this->plInfo(); - $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - foreach($tmp['plProvidedAcls'] as $acl => $desc){ - $smarty->assign($acl."ACL",$this->getacl($acl,$SkipWrite)); - } - - /* Assign attributes an ACL to smarty */ - foreach($this->attributes as $val) { - $smarty->assign("$val", $this->$val); - if(in_array($val,$this->is_chk_box)){ - if($this->$val == "checked"){ - $smarty->assign($val."CHK", " checked "); - }else{ - $smarty->assign($val."CHK", ""); - } - } - } - $smarty->assign('ServiceNotificationOptionsValues' ,array("d,u,r,v"=>"d,u,r,v" ,"d,u,r"=>"d,u,r" ,"d,u"=>"d,u")); - $smarty->assign('HostNotificationOptionsValues' ,array("w,u,c,r"=>"w,u,c,r" ,"w,u,c"=>"w,u,c" ,"c,w"=>"c,w")); - $smarty->assign('ServiceNotificationPeriodValues' ,array("24x7"=>"24x7" ,"24x5"=>"24x5" ,"8x5"=>"8x5")); - $smarty->assign('HostNotificationPeriodValues' ,array("24x7"=>"24x7" ,"24x5"=>"24x5" ,"8x5"=>"8x5")); - $display.= $smarty->fetch (get_template_path('nagios.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /* Save to LDAP */ - function save() - { - $ldap= $this->config->get_ldap_link(); - - /* Call parents save to prepare $this->attrs */ - plugin::save(); - - /* Adapt attributes if needed */ - //$method= new $this->method($this->config); - //$id= $method->uattrib; - //$method->fixAttributesOnStore($this); - - /* Write back to ldap */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/nagios account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add", array("uid" => $this->uid)); - } - } - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - $ldap= $this->config->get_ldap_link(); - /* must: mail */ - if ($this->NagiosAlias == ""){ - $message[]= _("The required field 'NagiosAlias' is not set."); - } - if ($this->NagiosMail == ""){ - $message[]= _("The required field 'NagiosMail' is not set."); - } - if ($this->is_template){ - if (!is_email($this->NagiosMail, TRUE)){ - $message[]= _("Please enter a valid email address in 'NagiosMail' field."); - } - } else { - if (!is_email($this->NagiosMail)){ - $message[]= _("Please enter a valid email address in 'NagiosMail' field."); - } - } - return($message); - } - - - /* Use Save_object for every Post handling */ - function save_object() - { - if (isset($_POST['nagiosTab'])){ - /* Save ldap attributes */ - plugin::save_object(); - - /* Specialhandling for checkboxes */ - foreach($this->is_chk_box as $val){ - if($this->acl_is_writeable($val)){ - if(isset($_POST[$val])){ - $this->$val = "checked"; - }else{ - $this->$val = "unchecked"; - } - } - } - } - } - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - /* Adapt attributes if needed */ - // $method= new $this->method($this->config); - // $method->fixAttributesOnRemove($this); - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - new log("view","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/nagios account with dn '%s' failed."),$this->dn)); - - /* remove the entry from LDAP */ - unset ($this->attrs['uid']); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove',array("uid" => $this->uid)); - } - - - - static function plInfo() - { - return (array( - "plShortName" => _("Nagios"), - "plDescription" => _("Nagios account settings"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 8, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - - "NagiosAlias" => _("Alias"), - "NagiosPager" => _("Pager number"), - "NagiosMail" => _("Mail address"), - - "HostNotificationCommands" => _("Host notification commands"), - "HostNotificationOptions" => _("Host notification options"), - "HostNotificationPeriod" => _("Host notification period"), - - "ServiceNotificationCommands" => _("Service notification commands"), - "ServiceNotificationOptions" => _("Service notification options"), - "ServiceNotificationPeriod" => _("Service notification period"), - - "AuthorizedAllHosts" => _("View all hosts"), - "AuthorizedAllServices" => _("View all services"), - - "AuthorizedSystemCommands" => _("Trigger system commands"), - "AuthorizedAllHostCommands" => _("Trigger all host commands"), - "AuthorizedAllServiceCommands" => _("Trigger all service commands"), - - "AuthorizedConfigurationInformation"=> _("View configuration information"), - "AuthorizedSystemInformation" => _("View system informations")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: - -?> diff --git a/plugins/personal/nagios/main.inc b/plugins/personal/nagios/main.inc deleted file mode 100644 index c6a61b3b9..000000000 --- a/plugins/personal/nagios/main.inc +++ /dev/null @@ -1,129 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('nagiosAccount'); - } - - /* Create mail object on demand */ - if (!isset($_SESSION['nagiosAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['nagiosAccount']= new nagiosAccount ($config, $ui->dn); - $_SESSION['nagiosAccount']->enable_CSN_check(); - $_SESSION['nagiosAccount']->set_acl_base($ui->dn); - $_SESSION['nagiosAccount']->set_acl_category("users"); - } - $nagiosAccount= $_SESSION['nagiosAccount']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $nagiosAccount->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $nagiosAccount->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $nagiosAccount->save (); - del_lock ($ui->dn); - sess_del ('edit'); - - /* Remove object */ - sess_del ('nagiosAccount'); - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display.= $lock_msg; - }else{ - $display.= $nagiosAccount->execute (); - } - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['nagiosAccount']= $nagiosAccount; - } - - $info= ""; - /* Show page footer depending on the mode */ - if ($nagiosAccount->is_account && empty($lock_msg)){ - $display.= "

"; - - /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/nagiosAccount"))){ - $info.= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); - $display.= "\n"; - } - $display.= "\n"; - } - $display.= "

\n"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/monitoring.png'), _("Nagios settings"), $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/nagios/nagios.tpl b/plugins/personal/nagios/nagios.tpl deleted file mode 100644 index e77529add..000000000 --- a/plugins/personal/nagios/nagios.tpl +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - -
-

-  {t}Nagios Account{/t}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{$must} -{render acl=$NagiosAliasACL} - -{/render} -
{$must} -{render acl=$NagiosMailACL} - -{/render} -
- {$must} - -{render acl=$HostNotificationPeriodACL} - -{/render} -
- {$must} - -{render acl=$ServiceNotificationPeriodACL} - -{/render} -
- {$must} - -{render acl=$ServiceNotificationOptionsACL} - -{/render} -
- {$must} - -{render acl=$HostNotificationOptionsACL} - -{/render} -
- - -{render acl=$NagiosPagerACL} - -{/render} -
- - -{render acl=$ServiceNotificationCommandsACL} - -{/render} -
- - -{render acl=$HostNotificationCommandsACL} - -{/render} -
-
-   - -

-  {t}Nagios authentification{/t} -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-{render acl=$AuthorizedSystemInformationACL} - {t}view system informations{/t} -{/render} -
-{render acl=$AuthorizedConfigurationInformationACL} - {t}view configuration information{/t} -{/render} -
-{render acl=$AuthorizedSystemCommandsACL} - {t}trigger system commands{/t} -{/render} -
-{render acl=$AuthorizedAllServicesACL} - {t}view all services{/t} -{/render} -
-{render acl=$AuthorizedAllHostsACL} - {t}view all hosts{/t} -{/render} -
-{render acl=$AuthorizedAllServiceCommandsACL} - {t}trigger all service commands{/t} -{/render} -
-{render acl=$AuthorizedAllHostCommandsACL} - {t}trigger all host commands{/t} -{/render} -
-
- - - - - - diff --git a/plugins/personal/netatalk/class_netatalk.inc b/plugins/personal/netatalk/class_netatalk.inc deleted file mode 100644 index 3693fda79..000000000 --- a/plugins/personal/netatalk/class_netatalk.inc +++ /dev/null @@ -1,387 +0,0 @@ - - Copyright (C) 2006 Bernd Zeimetz - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*! \brief netatalk plugin - \author Gina Haeussge - \author Bernd Zeimetz - \version 0.1 - \date 21.3.2006 - - This class provides the functionality to read and write all attributes - relevant for netatalk from/to the LDAP. It does syntax checking - and displays the formulars required. - */ - -class netatalk extends plugin { - - /* Definitions */ - var $plHeadline = "Netatalk"; - var $plDescription = "Manage netatalk account"; - - /* CLI vars */ - var $cli_summary = "Manage netatalk account"; - var $cli_description = "Manage Account \nfor netatalk"; - var $cli_parameters = array ("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); - var $view_logged = FALSE; - - /* Plugin specific values */ - var $apple_user_homepath_raw = ""; - var $apple_user_homeurl_raw = ""; - var $apple_user_homeurl_xml = ""; - var $apple_user_homeurl = ""; - var $apple_user_homeDirectory = ""; - var $apple_user_share = ""; - var $shares = array(); - var $shares_settings = array(); - var $selectedshare = ""; - var $mountDirectory = "/Network/Servers"; - - /* Attributes to save to LDAP */ - var $attributes = array ("apple-user-homeurl", "apple-user-homeDirectory"); - var $CopyPasteVars= array("apple_user_homeurl", "apple_user_homeDirectory","apple_user_share","shares_settings","apple_user_homepath_raw", - "apple_user_homeurl_raw","apple_user_homeurl_xml","apple_user_homeurl","selectedshare","mountDirectory"); - - /* Attributes to use in smarty template */ - var $smarty_attributes = array ("apple_user_homepath_raw", "shares", "selectedshare"); - - /* Attributes to save from $_POST */ - var $post_attributes = array ("apple_user_share", "apple_user_homepath_raw"); - - /* Objectclasses */ - var $objectclasses = array ("apple-user"); - - /* Checkboxes */ - var $is_chk_box = array (); - - var $uid =""; - - /* The constructor just saves a copy of the config. You may add what ever you need. */ - function netatalk(&$config, $dn = NULL) { - - /* Include config object */ - $this->config = $config; - plugin::plugin($config, $dn); - - /* set user id */ - if(isset($this->attrs['uid'])){ - $this->uid = $this->attrs['uid'][0]; - } - - /* Copy needed attributes */ - foreach($this->attributes as $val) { - if (isset($this->attrs["$val"][0])) { - $name = str_replace('-', '_', $val); - $this->$name = $this->attrs["$val"][0]; - } - } - - if (strlen($this->apple_user_homeDirectory) >0) { - $this->apple_user_homepath_raw = substr($this->apple_user_homeDirectory, strrpos($this->apple_user_homeDirectory, '/') + 1 ); - } - - /* get share list an set default values */ - $this->get_netatalk_shares(); - $this->apple_user_share = $this->selectedshare; - - /* Save initial account state */ - $this->initially_was_account = $this->is_account; - } - - - - /* Get netatalk shares */ - function get_netatalk_shares() - { - /* Get netatalk shares */ - $this->shares = array(); - $ldap = $this->config->get_ldap_link(); - - if($this->dn === "new" || $this->dn === NULL) { - $base = $_SESSION['CurrentMainBase']; - } else { - $base = preg_replace("/^[^,]+,".normalizePreg(get_people_ou())."/","",$this->dn); - } - - $ldap->cd($base); - $ldap->search ("(&(objectClass=mount)(|(mountType=url)(mountType=nfs))(cn=*))"); - - while ($attrs = $ldap->fetch()){ - $tmp = split(":", $attrs["cn"][0]); - $host = trim($tmp[0]); - $dir = trim($tmp[1]); - $mountType = trim($attrs["mountType"][0]); - if ($mountType == "url") { - $mountTypeReal = "netatalk"; - } else { - $mountTypeReal = $mountType; - } - $share = $attrs["cn"][0]. " (" . $mountTypeReal . ")"; - $this->shares[$share] = $share; - $this->shares_settings[$share]["mountType"]=$mountType; - $this->shares_settings[$share]["dir"]=$dir; - $this->shares_settings[$share]["host"]=$host; - - $oldShare=substr($this->apple_user_homeDirectory, 0, strrpos($this->apple_user_homeDirectory, '/')); - $newShare=($this->mountDirectory . "/". $host . $dir ); - if (strcmp($oldShare, $newShare)==0) { - $this->selectedshare = $share; - } - } - asort($this->shares); - } - - - /* Execute the plugin, produce the output. */ - function execute() - { - plugin :: execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Use the smarty templating engine here... */ - $smarty = get_smarty(); - $display = ""; - - /* Do we need to flip is_account state? */ - if (isset ($_POST['modify_state'])) { - $this->is_account = !$this->is_account; - } - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL) { - $display = "\"\"src=\"images/stop.png\" "._("This account has no netatalk extensions.").""; - - $display .= back_to_main(); - return ($display); - } - - /* Show tab dialog headers */ - if ($this->parent !== NULL) { - if ($this->is_account) { - $display = $this->show_disable_header(_("Remove netatalk account"), _("This account has netatalk features enabled. You can disable them by clicking below.")); - } else { - $errmsg=""; - $obj = $this->parent->by_object['posixAccount']; - if (!($obj->is_account) ) { - $errmsg.="Posix features are needed for netatalk accounts, enable them first. "; - } - if (count($this->shares)== 0) { - $errmsg.="At least one share with netatalk or NFS mount entry needed."; - } - if($errmsg==""){ - $display = $this->show_enable_header(_("Create netatalk account"), _("This account has netatalk features disabled. You can enable them by clicking below.")); - } else { - $display = $this->show_enable_header(_("Create netatalk account"), _($errmsg), TRUE); - } - return ($display); - } - } - - /* Assign attributes and ACL to smarty */ - $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - $smarty->assign("netatalkShareACL", $this->getacl("netatalkShare",$SkipWrite)); - $smarty->assign("netatalkUserHomepathACL", $this->getacl("netatalkUserHomepath",$SkipWrite)); - - foreach ($this->smarty_attributes as $val) { - $smarty->assign("$val", $this-> $val); - if (in_array($val, $this->is_chk_box)) { - if ($this-> $val == "checked") { - $smarty->assign($val."CHK", " checked "); - } else { - $smarty->assign($val."CHK", ""); - } - } - } - - /* Let smarty fetch and process the page. */ - $display .= ($smarty->fetch(get_template_path('netatalk.tpl', TRUE, dirname(__FILE__)))); - return ($display); - } - - - /* Check if we have correct data */ - function check() { - $message = array (); - - if (strlen($this->apple_user_share) == 0) { - $message[] = _("You must select a share to use."); - } - - return ($message); - } - - /* Save to LDAP */ - function save() { - /* remove a / at the end of the homepath, we neither need it there nor - * do we want to check for it later. - */ - if(substr($this->apple_user_homepath_raw, -1, 1) === '/') { - $this->apple_user_homepath_raw=substr($this->apple_user_homepath_raw, 0, -1); - } - - $mountType=$this->shares_settings[$this->apple_user_share]["mountType"]; - $dir=$this->shares_settings[$this->apple_user_share]["dir"]; - $host=$this->shares_settings[$this->apple_user_share]["host"]; - - /* Convert raw data to wished format */ - if ($this->is_account) { - if($mountType=="url") { - $this->apple_user_homeurl_xml = 'afp://'.$host.$dir . ''.$this->apple_user_homepath_raw.''; - $this->apple_user_homeurl = base64_encode($this->apple_user_homeurl_xml); - } else { - $this->apple_user_homeurl = ""; - } - $this->apple_user_homeDirectory = $this->mountDirectory . '/' . $host .$dir . '/' . $this->apple_user_homepath_raw; - } else { - $this->apple_user_homeurl = ""; - $this->apple_user_homeDirectory = ""; - } - - $ldap = $this->config->get_ldap_link(); - - /* Reset array of used attributes, because plugin::save() - will not work with '-' in attributes names - after calling save restore attributes array */ - $attributes = $this->attributes; - $this->attributes = array(); - plugin :: save(); - $this->attributes = $attributes; - - /* Do attribute conversion */ - foreach ($this->attributes as $val) { - $name = str_replace('-', '_', $val); - if ($this->$name != "") { - $this->attrs[$val] = $this->$name; - } else { - $this->attrs[$val] = array(); - } - unset ($this->attrs[$name]); - } - - /* Write back to ldap */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify($this->attrs); - - 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/netatalk account with dn '%s' failed."),$this->dn)); - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - } - - /* Use Save_object for every Post handling */ - function save_object() { - if (isset ($_POST['netatalkTab'])) { - /* Save ldap attributes */ - plugin :: save_object(); - - foreach($this->post_attributes as $val) { - if (isset ($_POST[$val])) { - $this->$val = $_POST[$val]; - } else { - $this->$val = ""; - } - } - - /* Specialhandling for checkboxes */ - foreach ($this->is_chk_box as $val) { - if (isset ($_POST[$val])) { - $this-> $val = "checked"; - } else { - $this-> $val = "unchecked"; - } - } - - $this->apple_user_homeurl_raw = 'afp://' . $this->apple_user_share; - } - } - - function remove_from_parent() { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account) { - return; - } - - /* include global link_info */ - $ldap = $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin :: remove_from_parent(); - - /* Adapt attributes if needed */ - // $method= new $this->method($this->config); - // $method->fixAttributesOnRemove($this); - - @ DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify($this->attrs); - - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/netatalk account with dn '%s' failed."),$this->dn)); - - /* remove the entry from LDAP */ - unset ($this->attrs['uid']); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove', array("uid" => $this->uid)); - } - - - /* Return plugin informations for acl handling*/ - static function plInfo() - { - return (array( - "plDescription" => _("Netatalk"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 6, - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "netatalkUserHomepath" => _("User home path"), - "netatalkShare" => _("Share")) - )); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/netatalk/main.inc b/plugins/personal/netatalk/main.inc deleted file mode 100644 index e1a62c965..000000000 --- a/plugins/personal/netatalk/main.inc +++ /dev/null @@ -1,117 +0,0 @@ - - Copyright (C) 2006 Bernd Zeimetz - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -if (!$remove_lock) { - /* Reset requested? */ - if (isset ($_POST['edit_cancel']) || (isset ($_GET['reset']) && $_GET['reset'] == 1)) { - del_lock($ui->dn); - sess_del('edit'); - sess_del('netatalk'); - } - - /* Create netatalk object on demand */ - if (!isset ($_SESSION['netatalk']) || (isset ($_GET['reset']) && $_GET['reset'] == 1)) { - $_SESSION['netatalk'] = new netatalk($config, $ui->dn); - $_SESSION['netatalk']->enable_CSN_check(); - $_SESSION['netatalk']->set_acl_base($ui->dn); - $_SESSION['netatalk']->set_acl_category("users"); - } - $netatalk = $_SESSION['netatalk']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])) { - $netatalk->save_object(); - } - - /* Enter edit mode? */ - if (isset ($_POST['edit'])) { - - /* Check locking */ - if (($username = get_lock($ui->dn)) != "") { - $_SESSION['back_plugin'] = $plug; - gen_locked_message($username, $ui->dn); - exit (); - } - - /* Lock the current entry */ - add_lock($ui->dn, $ui->dn); - $_SESSION['dn'] = $ui->dn; - $_SESSION['edit'] = TRUE; - } - - /* save changes to LDAP and disable edit mode */ - if (isset ($_POST['edit_finish'])) { - - /* Perform checks */ - $message = $netatalk->check(); - - /* No errors, save object */ - if (count($message) == 0) { - $netatalk->save(); - del_lock($ui->dn); - sess_del('edit'); - - /* Remove object */ - sess_del('netatalk'); - } else { - /* Errors found, show message */ - show_errors($message); - } - } - - /* Execute formular */ - $display = $netatalk->execute(); - - /* Store changes in session */ - if (isset ($_SESSION['edit'])) { - $_SESSION['netatalk'] = $netatalk; - } - - $info = ""; - /* Show page footer depending on the mode */ - if ($netatalk->is_account) { - $display .= "

"; - - /* Are we in edit mode? */ - if (isset ($_SESSION['edit'])) { - $display .= "\n"; - $display .= " "; - $display .= "\n"; - $info = "\"\" ".$ui->dn." "; - } else { - $info = "\"\" ".$ui->dn." "; - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/netatalk"))){ - $info .= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); - $display .= "\n"; - } - - $display .= "\n"; - } - $display .= "

\n"; - } - - /* Page header*/ - $display = print_header(get_template_path('images/netatalk.png'), _("Netatalk settings"), $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/netatalk/netatalk.tpl b/plugins/personal/netatalk/netatalk.tpl deleted file mode 100644 index c5bcc8ecc..000000000 --- a/plugins/personal/netatalk/netatalk.tpl +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - -
- - - -{render acl=$netatalkShareACL} - -{/render} -
- - -{render acl=$netatalkUserHomepathACL} - -{/render} -
- - - - - diff --git a/plugins/personal/password/changed.tpl b/plugins/personal/password/changed.tpl deleted file mode 100644 index 16db30001..000000000 --- a/plugins/personal/password/changed.tpl +++ /dev/null @@ -1,12 +0,0 @@ - -

- {t}You've successfully changed your password. Remember to change all programms configured to use it as well.{/t} -

- -
- -

- -

- - diff --git a/plugins/personal/password/class_password.inc b/plugins/personal/password/class_password.inc deleted file mode 100644 index f9d5ac44a..000000000 --- a/plugins/personal/password/class_password.inc +++ /dev/null @@ -1,154 +0,0 @@ -get_permissions($ui->dn,"users/password"); - $smarty->assign("ChangeACL" , $password_ACLS); - $smarty->assign("NotAllowed" , !preg_match("/w/i",$password_ACLS)); - - /* Display expiration template */ - if((isset($this->config->data['MAIN']['ACCOUNT_EXPIRATION'])) && - preg_match('/true/i', $this->config->data['MAIN']['ACCOUNT_EXPIRATION'])){ - $expired= ldap_expired_account($this->config, $ui->dn, $ui->username); - if($expired == 4){ - return($smarty->fetch(get_template_path("nochange.tpl", TRUE))); - } - } - - /* Pwd change requested */ - if (isset($_POST['password_finish'])){ - - /* Should we check different characters in new password */ - $check_differ = isset($this->config->data['MAIN']['PWDIFFER']); - $differ = @$this->config->data['MAIN']['PWDIFFER']; - - /* Enable length check ? */ - $check_length = isset($this->config->data['MAIN']['PWMINLEN']); - $length = @$this->config->data['MAIN']['PWMINLEN']; - - /* Call external password quality hook ?*/ - $check_hook = isset($this->config->data['MAIN']['EXTERNALPWDHOOK']); - $hook = @$this->config->data['MAIN']['EXTERNALPWDHOOK']." ".$ui->username." ".$_POST['current_password']." ".$_POST['new_password']; - if($check_hook){ - exec($hook,$resarr); - $check_hook_output = ""; - if(count($resarr) > 0) { - $check_hook_output= join('\n', $resarr); - } - } - - /* Check given values */ - if(!isset($_POST['current_password']) || empty($_POST['current_password'])){ - msg_dialog::display(_("User password"), - _("You need to specify your current password in order to proceed."),WARNING_DIALOG); - }elseif ($_POST['new_password'] != $_POST['repeated_password']){ - msg_dialog::display(_("User password"), - _("The passwords you've entered as 'New password' and 'Repeated new password' do not match."),WARNING_DIALOG); - } elseif ($_POST['new_password'] == ""){ - msg_dialog::display(_("User password"), - _("The password you've entered as 'New password' is empty."),WARNING_DIALOG); - }elseif($check_differ && (substr($_POST['current_password'], 0, $differ) == substr($_POST['new_password'], 0, $differ))){ - msg_dialog::display(_("User password"), - _("The password used as new and current are too similar."),WARNING_DIALOG); - }elseif($check_length && (strlen($_POST['new_password']) < $length)){ - msg_dialog::display(_("User password"), - _("The password used as new is to short."),WARNING_DIALOG); - }elseif($check_hook && $check_hook_output != ""){ - msg_dialog::display(_("User password"), - sprintf(_("External password changer reported a problem: %s."),$check_hook_output),WARNING_DIALOG); - }else{ - - /* Try to connect via current password */ - $tldap = new LDAP( - $ui->dn, - $_POST['current_password'], - $this->config->current['SERVER'], - isset($this->config->current['RECURSIVE']) && preg_match("/true/i",$this->config->current['RECURSIVE']), - isset($this->config->current['TLS']) && preg_match("/true/i",$this->config->current['TLS'])); - - /* connection Successfull ? */ - if ($tldap->error != "Success"){ - msg_dialog::display(_("User password"), - _("The password you've entered as your current password doesn't match the real one."),WARNING_DIALOG); - }else{ - - /* Check GOsa permissions */ - if (!preg_match("/w/i",$password_ACLS)){ - msg_dialog::display(_("User password"), - _("You have no permissions to change your password."),WARNING_DIALOG); - }else{ - change_password ($ui->dn, $_POST['new_password']); - gosa_log ("User/password has been changed"); - $ui->password= $_POST['new_password']; - $_SESSION['ui']= $ui; -#$this->handle_post_events("modify",array("userPassword" => $_POST['new_password'])); - return($smarty->fetch(get_template_path("changed.tpl", TRUE))); - } - } - } - } - return($smarty->fetch(get_template_path("password.tpl", TRUE))); - } - - function remove_from_parent() - { - $this->handle_post_events("remove"); - } - - function save() - { - } - - static function plInfo() - { - return (array( - "plDescription" => _("User password"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 10, - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array()) - ); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/password/main.inc b/plugins/personal/password/main.inc deleted file mode 100644 index b8135bc6a..000000000 --- a/plugins/personal/password/main.inc +++ /dev/null @@ -1,51 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('password'); - } - - /* Create password object on demand */ - if (!isset($_SESSION['password']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['password']= new password ($config, $ui->dn); - } - $password= $_SESSION['password']; - - /* Execute formular */ - $display.= $password->execute (); - - /* Page header*/ - $display= print_header(get_template_path('images/password.png'), - _("Password settings"), "").$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/password/nochange.tpl b/plugins/personal/password/nochange.tpl deleted file mode 100644 index d7164f67e..000000000 --- a/plugins/personal/password/nochange.tpl +++ /dev/null @@ -1,11 +0,0 @@ -
- {t}Password change not allowed{/t}> -
- -

- {t}You are not allowed to change your password at this time{/t} -

- -
- - diff --git a/plugins/personal/password/password.tpl b/plugins/personal/password/password.tpl deleted file mode 100644 index 0787b7056..000000000 --- a/plugins/personal/password/password.tpl +++ /dev/null @@ -1,44 +0,0 @@ -

- {t}To change your personal password use the fields below. The changes take effect immediately. Please memorize the new password, because you wouldn't be able to login without it.{/t} -

- -

- {t}Changing the password affects your authentification on mail, proxy, samba and unix services.{/t} -

- - - - - - - - - - - - - - -
- -
- -

- -   - -

- - - - - - diff --git a/plugins/personal/posix/class_posixAccount.inc b/plugins/personal/posix/class_posixAccount.inc deleted file mode 100644 index e1a5412c9..000000000 --- a/plugins/personal/posix/class_posixAccount.inc +++ /dev/null @@ -1,1433 +0,0 @@ - - \version 2.00 - \date 24.07.2003 - - This class provides the functionality to read and write all attributes - relevant for posixAccounts and shadowAccounts from/to the LDAP. It - does syntax checking and displays the formulars required. - */ - -class posixAccount extends plugin -{ - /* Definitions */ - var $plHeadline= "UNIX"; - var $plDescription= "This does something"; - - /* CLI vars */ - var $cli_summary= "Manage users posix account"; - var $cli_description= "Some longer text\nfor help"; - var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Plugin specific values */ - var $homeDirectory= ""; - var $loginShell= "/bin/bash"; - var $uidNumber= ""; - var $gidNumber= ""; - var $gecos= ""; - var $shadowMin= "0"; - var $shadowMax= "0"; - var $shadowWarning= "0"; - var $shadowLastChange= "0"; - var $shadowInactive= "0"; - var $shadowExpire= "0"; - var $gosaDefaultPrinter= ""; - var $accessTo= array(); - var $trustModel= ""; - - var $glist=array(); - var $status= ""; - var $loginShellList= array(); - var $groupMembership= array(); - var $savedGroupMembership= array(); - var $savedUidNumber= ""; - var $savedGidNumber= ""; - var $use_shadowMin= "0"; - var $use_shadowMax= "0"; - var $use_shadowWarning= "0"; - var $use_shadowInactive= "0"; - var $use_shadowExpire= "0"; - var $mustchangepassword= "0"; - var $force_ids= 0; - var $group_dialog= FALSE; - var $show_ws_dialog= FALSE; - var $secondaryGroups= array(); - var $primaryGroup= 0; - var $was_trust_account= FALSE; - var $memberGroup = array(); - var $grouplist = array(); - var $ui = array(); - - var $GroupRegex = "*"; - var $GroupUserRegex = "*"; - var $SubSearch = false; - - var $view_logged = FALSE; - - /* attribute list for save action */ - var $CopyPasteVars = - array("grouplist","groupMembership","use_shadowMin", - "use_shadowMax","use_shadowWarning","use_shadowInactive","use_shadowExpire", - "must_change_password","printerList","grouplist","savedGidNumber","savedUidNumber"); - - var $attributes = array("homeDirectory", "loginShell", "uidNumber", "gidNumber", "gecos", - "shadowMin", "shadowMax", "shadowWarning", "shadowInactive", "shadowLastChange", - "shadowExpire", "gosaDefaultPrinter", "uid","accessTo","trustModel"); - - var $objectclasses= array("posixAccount", "shadowAccount"); - - var $uid= ""; - var $multiple_support = TRUE; - - /* constructor, if 'dn' is set, the node loads the given - 'dn' from LDAP */ - function posixAccount (&$config, $dn= NULL) - { - /* Configuration is fine, allways */ - $this->config= $config; - - /* Load bases attributes */ - plugin::plugin($config, $dn); - - /* Setting uid to default */ - if(isset($this->attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - $ldap= $this->config->get_ldap_link(); - - if ($dn !== NULL){ - - /* Correct is_account. shadowAccount is not required. */ - if (isset($this->attrs['objectClass']) && - in_array ('posixAccount', $this->attrs['objectClass'])){ - - $this->is_account= TRUE; - } - - /* Is this account a trustAccount? */ - if ($this->is_account && isset($this->attrs['trustModel'])){ - $this->trustModel= $this->attrs['trustModel'][0]; - $this->was_trust_account= TRUE; - } else { - $this->was_trust_account= FALSE; - $this->trustModel= ""; - } - - $this->accessTo = array(); - if ($this->is_account && isset($this->attrs['accessTo'])){ - for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){ - $tmp= $this->attrs['accessTo'][$i]; - $this->accessTo[$tmp]= $tmp; - } - } - $this->initially_was_account= $this->is_account; - - /* Fill group */ - $this->primaryGroup= $this->gidNumber; - - /* Generate status text */ - $current= date("U"); - - $current= floor($current / 60 /60 / 24); - - if (($current >= $this->shadowExpire) && $this->shadowExpire){ - $this->status= _("expired"); - if (($current - $this->shadowExpire) < $this->shadowInactive){ - $this->status.= ", "._("grace time active"); - } - } elseif (($this->shadowLastChange + $this->shadowMin) >= $current){ - $this->status= _("active, password not changable"); - } elseif (($this->shadowLastChange + $this->shadowMax) >= $current){ - $this->status= _("active, password expired"); - } else { - $this->status= _("active"); - } - - /* Get group membership */ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("cn", "description")); - - while ($this->attrs= $ldap->fetch()){ - if (!isset($this->attrs["description"][0])){ - $entry= $this->attrs["cn"][0]; - } else { - $dsc= preg_replace ('/^Group of user/', _("Group of user"), $this->attrs["description"][0]); - $entry= $this->attrs["cn"][0]." [$dsc]"; - } - $this->groupMembership[$ldap->getDN()]= $entry; - } - asort($this->groupMembership); - reset($this->groupMembership); - $this->savedGroupMembership= $this->groupMembership; - $this->savedUidNumber= $this->uidNumber; - $this->savedGidNumber= $this->gidNumber; - } - - /* Adjust shadow checkboxes */ - foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive", - "shadowExpire") as $val){ - - if ($this->$val != 0){ - $oval= "use_".$val; - $this->$oval= "1"; - } - } - - /* Convert to seconds */ - $this->shadowExpire= $this->convertToSeconds($this->shadowExpire); - - /* Generate shell list from CONFIG_DIR./shells */ - if (file_exists(CONFIG_DIR.'/shells')){ - $shells = file (CONFIG_DIR.'/shells'); - foreach ($shells as $line){ - if (!preg_match ("/^#/", $line)){ - $this->loginShellList[]= trim($line); - } - } - } else { - if ($this->loginShell == ""){ - $this->loginShellList[]= _("unconfigured"); - } - } - - /* Insert possibly missing loginShell */ - if ($this->loginShell != "" && !in_array($this->loginShell, $this->loginShellList)){ - $this->loginShellList[]= $this->loginShell; - } - - /* Generate group list */ - $this->ui = get_userinfo(); - $this->secondaryGroups[]= "- "._("automatic")." -"; - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=posixGroup)", array("cn", "gidNumber")); - while($attrs = $ldap->fetch()){ - $this->secondaryGroups[$attrs['gidNumber'][0]]= $attrs['cn'][0]; - } - asort ($this->secondaryGroups); - - /* Get global filter config */ - if (!is_global("sysfilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $sysfilter= array( "depselect" => $base, - "regex" => "*"); - register_global("sysfilter", $sysfilter); - } - $this->ui = get_userinfo(); - } - - - /* execute generates the html output for this node */ - function execute($isCopyPaste = false) - { - /* Call parent execute */ - plugin::execute(); - $display= ""; - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Department has changed? */ - if(isset($_POST['depselect'])){ - $_SESSION['CurrentMainBase']= validate($_POST['depselect']); - } - - if($this->multiple_support_active){ - $this->is_account = TRUE; - } - - if(!$isCopyPaste && ! $this->multiple_support_active){ - - /* Do we need to flip is_account state? */ - 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; - } - } - - /* Do we represent a valid posixAccount? */ - if (!$this->is_account && $this->parent === NULL ){ - $display= "\"\" ". - _("This account has no unix extensions.").""; - $display.= back_to_main(); - return ($display); - } - - - /* Show tab dialog headers */ - if ($this->parent !== NULL){ - if ($this->is_account){ - if (isset($this->parent->by_object['sambaAccount'])){ - $obj= $this->parent->by_object['sambaAccount']; - } - if (isset($obj) && $obj->is_account == TRUE && - ((isset($this->parent->by_object['sambaAccount']))&&($this->parent->by_object['sambaAccount']->is_account)) - ||(isset($this->parent->by_object['environment'] ))&&($this->parent->by_object['environment'] ->is_account)){ - - /* Samba3 dependency on posix accounts are enabled - in the moment, because I need to rely on unique - uidNumbers. There'll be a better solution later - on. */ - $display= $this->show_disable_header(_("Remove posix account"), - _("This account has unix features enabled. To disable them, you'll need to remove the samba / environment account first."), TRUE); - } else { - $display= $this->show_disable_header(_("Remove posix account"), - _("This account has posix features enabled. You can disable them by clicking below.")); - } - } else { - $display= $this->show_enable_header(_("Create posix account"), - _("This account has posix features disabled. You can enable them by clicking below.")); - return($display); - } - } - } - /* Trigger group edit? */ - if (isset($_POST['edit_groupmembership'])){ - $this->group_dialog= TRUE; - $this->dialog= TRUE; - } - - /* Cancel group edit? */ - if (isset($_POST['add_groups_cancel']) || - isset($_POST['add_groups_finish'])){ - $this->group_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Add selected groups */ - if (isset($_POST['add_groups_finish']) && isset($_POST['groups']) && - count($_POST['groups'])){ - - $this->addGroup ($_POST['groups']); - } - - /* Delete selected groups */ - if (isset($_POST['delete_groupmembership']) && - isset($_POST['group_list']) && count($_POST['group_list'])){ - - $this->delGroup ($_POST['group_list']); - } - - /* Add user workstation? */ - if (isset($_POST["add_ws"])){ - $this->show_ws_dialog= TRUE; - $this->dialog= TRUE; - } - - /* Add user workstation? */ - if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){ - foreach($_POST['wslist'] as $ws){ - $this->accessTo[$ws]= $ws; - } - ksort($this->accessTo); - $this->is_modified= TRUE; - } - - /* Remove user workstations? */ - if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){ - foreach($_POST['workstation_list'] as $name){ - unset ($this->accessTo[$name]); - } - $this->is_modified= TRUE; - } - - /* Add user workstation finished? */ - if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){ - $this->show_ws_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Templates now! */ - $smarty= get_smarty(); - - /* Show ws dialog */ - if ($this->show_ws_dialog){ - /* Save data */ - $sysfilter= get_global("sysfilter"); - foreach( array("depselect", "regex") as $type){ - if (isset($_POST[$type])){ - $sysfilter[$type]= $_POST[$type]; - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $sysfilter['regex']= $s; - } - register_global("sysfilter", $sysfilter); - - /* Get workstation list */ - $exclude= ""; - foreach($this->accessTo as $ws){ - $exclude.= "(cn=$ws)"; - } - if ($exclude != ""){ - $exclude= "(!(|$exclude))"; - } - $regex= $sysfilter['regex']; - $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))"; - $res= get_list($filter, "groups", $sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT); - $wslist= array(); - foreach ($res as $attrs){ - $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]); - } - asort($wslist); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("alphabet", generate_alphabet()); - foreach( array("depselect", "regex") as $type){ - $smarty->assign("$type", $sysfilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - $smarty->assign("wslist", $wslist); - $smarty->assign("apply", apply_filter()); - $display= $smarty->fetch (get_template_path('trust_machines.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /* Manage group add dialog */ - if ($this->group_dialog){ - - /* Get global filter config */ - $this->reload(); - - /* remove already assigned groups */ - $glist= array(); - foreach ($this->grouplist as $key => $value){ - if (!isset($this->groupMembership[$key]) && obj_is_writable($key,"groups/group","memberUid")){ - $glist[$key]= $value; - } - } - - if($this->SubSearch){ - $smarty->assign("SubSearchCHK"," checked "); - }else{ - $smarty->assign("SubSearchCHK",""); - } - - $smarty->assign("regex",$this->GroupRegex); - $smarty->assign("guser",$this->GroupUserRegex); - $smarty->assign("groups", $glist); - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("depselect",$_SESSION['CurrentMainBase']); - $smarty->assign("hint", print_sizelimit_warning()); - - $smarty->assign("apply", apply_filter()); - $display.= $smarty->fetch (get_template_path('posix_groups.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - /* Show main page */ - $smarty= get_smarty(); - - /* In 'MyAccount' mode, we must remove write acls if we are not in editing mode. */ - $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - - /* Depending on pwmode, currently hardcoded because there are no other methods */ - if ( 1 == 1 ){ - $smarty->assign("pwmode", dirname(__FILE__)."/posix_shadow"); - - $shadowMinACL = $this->getacl("shadowMin",$SkipWrite); - $smarty->assign("shadowmins", sprintf(_("Password can't be changed up to %s days after last change"), - "shadowMin."\">")); - - $shadowMaxACL = $this->getacl("shadowMax",$SkipWrite); - $smarty->assign("shadowmaxs", sprintf(_("Password must be changed after %s days"), - "shadowMax."\">")); - - $shadowInactiveACL= $this->getacl("shadowInactive",$SkipWrite); - $smarty->assign("shadowinactives", sprintf(_("Disable account after %s days of inactivity after password expiery"), - "shadowInactive."\">")); - - $shadowWarningACL = $this->getacl("shadowWarning",$SkipWrite); - $smarty->assign("shadowwarnings", sprintf(_("Warn user %s days before password expiery"), - "shadowWarning."\">")); - - foreach( array("use_shadowMin", "use_shadowMax", - "use_shadowExpire", "use_shadowInactive","use_shadowWarning") as $val){ - if ($this->$val == 1){ - $smarty->assign("$val", "checked"); - } else { - $smarty->assign("$val", ""); - } - $smarty->assign("$val"."ACL", $this->getacl($val,$SkipWrite)); - } - - if($this->mustchangepassword){ - $smarty->assign("mustchangepassword", "checked"); - } else { - $smarty->assign("mustchangepassword", ""); - } - $smarty->assign("mustchangepasswordACL", $this->getacl("mustchangepassword",$SkipWrite)); - } - - /* Fill calendar */ - /* If this $this->shadowExpire is empty - use current date as base for calculating selectbox values. - (This attribute is empty if this is a new user )*/ - if(empty($this->shadowExpire)){ - $date= getdate(time()); - }else{ - $date= getdate($this->shadowExpire); - } - - $days= array(); - for($d= 1; $d<32; $d++){ - $days[$d]= $d; - } - $years= array(); - for($y= $date['year']-10; $y<$date['year']+10; $y++){ - $years[]= $y; - } - $months= array(_("January"), _("February"), _("March"), _("April"), - _("May"), _("June"), _("July"), _("August"), _("September"), - _("October"), _("November"), _("December")); - $smarty->assign("day", $date["mday"]); - $smarty->assign("days", $days); - $smarty->assign("months", $months); - $smarty->assign("month", $date["mon"]-1); - $smarty->assign("years", $years); - $smarty->assign("year", $date["year"]); - - /* Fill arrays */ - $smarty->assign("shells", $this->loginShellList); - $smarty->assign("secondaryGroups", $this->secondaryGroups); - $smarty->assign("primaryGroup", $this->primaryGroup); - if (!count($this->groupMembership)){ - $smarty->assign("groupMembership", array(" ")); - } else { - $smarty->assign("groupMembership", $this->groupMembership); - } - if (count($this->groupMembership) > 16){ - $smarty->assign("groups", "too_many_for_nfs"); - } else { - $smarty->assign("groups", ""); - } - - /* Avoid "Undefined index: forceMode" */ - $smarty->assign("forceMode", ""); - - /* Checkboxes */ - if ($this->force_ids == 1){ - $smarty->assign("force_ids", "checked"); - if ($_SESSION['js']){ - $smarty->assign("forceMode", ""); - } - } else { - if ($_SESSION['js']){ - $smarty->assign("forceMode", "disabled"); - } - $smarty->assign("force_ids", ""); - } - - - - $smarty->assign("force_idsACL", $this->getacl("uidNumber",$SkipWrite).$this->getacl("gidNumber",$SkipWrite)); - - foreach(array("primaryGroup") as $val){ - if(in_array($val,$this->multi_boxes)){ - $smarty->assign("use_".$val,TRUE); - }else{ - $smarty->assign("use_".$val,FALSE); - } - } - - - /* Load attributes and acl's */ - foreach($this->attributes as $val){ - if(in_array($val,$this->multi_boxes)){ - $smarty->assign("use_".$val,TRUE); - }else{ - $smarty->assign("use_".$val,FALSE); - } - - if(($_SESSION["js"])&&(($val=="uidNumber")||($val=="gidNumber"))) - { - $smarty->assign("$val"."ACL",$this->getacl($val,$SkipWrite)); - $smarty->assign("$val", $this->$val); - continue; - } - $smarty->assign("$val", $this->$val); - $smarty->assign("$val"."ACL", $this->getacl($val,$SkipWrite)); - } - if($SkipWrite){ - $smarty->assign("groupMembershipACL","r"); - }else{ - $smarty->assign("groupMembershipACL","rw"); - } - $smarty->assign("status", $this->status); - - /* Work on trust modes */ - $smarty->assign("trusthide", " disabled "); - $smarty->assign("trustmodeACL", $this->getacl("trustModel",$SkipWrite)); - if ($this->trustModel == "fullaccess"){ - $trustmode= 1; - // pervent double disable tag in html code, this will disturb our clean w3c html - $smarty->assign("trustmode", $this->getacl("trustModel",$SkipWrite)); - - } elseif ($this->trustModel == "byhost"){ - $trustmode= 2; - $smarty->assign("trusthide", ""); - } else { - // pervent double disable tag in html code, this will disturb our clean w3c html - $smarty->assign("trustmode", $this->getacl("trustModel",$SkipWrite)); - $trustmode= 0; - } - $smarty->assign("trustmode", $trustmode); - $smarty->assign("trustmodes", array( 0 => _("disabled"), 1 => _("full access"), - 2 => _("allow access to these hosts"))); - - - - if((count($this->accessTo))==0) - $smarty->assign("emptyArrAccess",true); - else - $smarty->assign("emptyArrAccess",false); - - - - $smarty->assign("workstations", $this->accessTo); - - $smarty->assign("apply", apply_filter()); - $smarty->assign("multiple_support" , $this->multiple_support_active); - $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); - return($display); - } - - - /* remove object from parent */ - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){ - return; - } - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - /* Zero out array */ - $this->attrs['gosaHostACL']= array(); - - /* Keep uid, because we need it for authentification! */ - unset($this->attrs['uid']); - unset($this->attrs['trustModel']); - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/posix account with dn '%s' failed."),$this->dn)); - - /* Delete group only if cn is uid and there are no other - members inside */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn", "memberUid")); - if ($ldap->count() != 0){ - $attrs= $ldap->fetch(); - if ($attrs['cn'][0] == $this->uid && - !isset($this->attrs['memberUid'])){ - - $ldap->rmDir($ldap->getDN()); - } - } - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove",array("uid" => $this->uid)); - } - - - function save_object() - { - if (isset($_POST['posixTab'])){ - /* Save values to object */ - plugin::save_object(); - - - /* Save force GID checkbox */ - if($this->acl_is_writeable("gidNumber") || $this->acl_is_writeable("uidNumber")){ - if (isset ($_POST['force_ids'])){ - $data= 1; - } else { - $data= 0; - } - if ($this->force_ids != $data){ - $this->is_modified= TRUE; - } - $this->force_ids= $data; - } - - /*Save primary group settings */ - if($this->acl_is_writeable("primaryGroup") && isset($_POST['primaryGroup'])){ - $data= $_POST['primaryGroup']; - if ($this->primaryGroup != $data){ - $this->is_modified= TRUE; - } - $this->primaryGroup= $_POST['primaryGroup']; - } - - foreach(array("shadowMin","shadowMax","shadowExpire","shadowInactive","shadowWarning","mustchangepassword") as $var) { - if($this->acl_is_writeable($var)){ - $use_var = "use_".$var; - if(isset($_POST['use_'.$var])){ - $this->$use_var = true; - $this->$var = $_POST[$var]; - }else{ - $this->$use_var = false; - $this->$var = 0; - } - } - } - - /* Trust mode - special handling */ - if($this->acl_is_writeable("trustModel")){ - if (isset($_POST['trustmode'])){ - $saved= $this->trustModel; - if ($_POST['trustmode'] == "1"){ - $this->trustModel= "fullaccess"; - } elseif ($_POST['trustmode'] == "2"){ - $this->trustModel= "byhost"; - } else { - $this->trustModel= ""; - } - if ($this->trustModel != $saved){ - $this->is_modified= TRUE; - } - } - } - } - - /* Get regex from alphabet */ - if(isset($_GET['search'])){ - $this->GroupRegex = $_GET['search']."*"; - } - - /* Check checkboxes and regexes */ - if(isset($_POST["PosixGroupDialogPosted"])){ - - if(isset($_POST['SubSearch']) && ($_POST['SubSearch'])){ - $this->SubSearch = true; - }else{ - $this->SubSearch = false; - } - if(isset($_POST['guser'])){ - $this->GroupUserRegex = $_POST['guser']; - } - if(isset($_POST['regex'])){ - $this->GroupRegex = $_POST['regex']; - } - } - $this->GroupRegex = preg_replace("/\*\**/","*",$this->GroupRegex); - $this->GroupUserRegex = preg_replace("/\*\**/","*",$this->GroupUserRegex); - } - - - /* Save data to LDAP, depending on is_account we save or delete */ - function save() - { - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Adapt shadow values */ - if (!$this->use_shadowExpire){ - $this->shadowExpire= "0"; - } else { - /* Transform seconds to days here */ - $this->shadowExpire= (int)($this->shadowExpire / (60 * 60 * 24)) ; - } - if (!$this->use_shadowMax){ - $this->shadowMax= "0"; - } - if ($this->mustchangepassword){ - $this->shadowLastChange= (int)(date("U") / 86400) - $this->shadowMax - 1; - } else { - $this->shadowLastChange= (int)(date("U") / 86400); - } - if (!$this->use_shadowWarning){ - $this->shadowWarning= "0"; - } - - /* Check what to do with ID's */ - if ($this->force_ids == 0){ - - /* Use id's that are already set */ - if ($this->savedUidNumber != ""){ - $this->uidNumber= $this->savedUidNumber; - $this->gidNumber= $this->savedGidNumber; - } else { - - /* Calculate new id's. We need to place a lock before calling get_next_id - to get real unique values. */ - $wait= 10; - while (get_lock("uidnumber") != ""){ - sleep (1); - - /* Oups - timed out */ - if ($wait-- == 0){ - print_red (_("Failed: overriding lock")); - break; - } - } - - add_lock ("uidnumber", "gosa"); - $this->uidNumber= $this->get_next_id("uidNumber", $this->dn); - if ($this->savedGidNumber != ""){ - $this->gidNumber= $this->savedGidNumber; - } else { - $this->gidNumber= $this->get_next_id("gidNumber", $this->dn); - } - } - - if ($this->primaryGroup != 0){ - $this->gidNumber= $this->primaryGroup; - } - } - - if ($this->use_shadowMin != "1" ) { - $this->shadowMin = ""; - } - - if (($this->use_shadowMax != "1") && ($this->mustchangepassword != "1")) { - $this->shadowMax = ""; - } - - if ($this->use_shadowWarning != "1" ) { - $this->shadowWarning = ""; - } - - if ($this->use_shadowInactive != "1" ) { - $this->shadowInactive = ""; - } - - if ($this->use_shadowExpire != "1" ) { - $this->shadowExpire = ""; - } - - /* Fill gecos */ - if (isset($this->parent) && $this->parent !== NULL){ - $this->gecos= rewrite($this->parent->by_object['user']->cn); - if (!preg_match('/^[a-z0-9 -]+$/i', $this->gecos)){ - $this->gecos= ""; - } - } - - foreach(array("shadowMin","shadowMax","shadowWarning","shadowInactive","shadowExpire") as $attr){ - $this->$attr = (int) $this->$attr; - } - /* Call parents save to prepare $this->attrs */ - plugin::save(); - - /* Trust accounts */ - $objectclasses= array(); - foreach ($this->attrs['objectClass'] as $key => $class){ - if (preg_match('/trustAccount/i', $class)){ - continue; - } - $objectclasses[]= $this->attrs['objectClass'][$key]; - } - $this->attrs['objectClass']= $objectclasses; - if ($this->trustModel != ""){ - $this->attrs['objectClass'][]= "trustAccount"; - $this->attrs['trustModel']= $this->trustModel; - $this->attrs['accessTo']= array(); - if ($this->trustModel == "byhost"){ - foreach ($this->accessTo as $host){ - $this->attrs['accessTo'][]= $host; - } - } - } else { - if ($this->was_trust_account){ - $this->attrs['accessTo']= array(); - $this->attrs['trustModel']= array(); - } - } - - if(empty($this->attrs['gosaDefaultPrinter'])){ - $thid->attrs['gosaDefaultPrinter']=array(); - } - - - /* Save data to LDAP */ - $ldap->cd($this->dn); - $this->cleanup(); - unset($this->attrs['uid']); - $ldap->modify ($this->attrs); - - /* 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/posix account with dn '%s' failed."),$this->dn)); - - /* Remove lock needed for unique id generation */ - del_lock ("uidnumber"); - - /* Posix accounts have group interrelationship, - take care about these here if this is a new user without forced gidNumber. */ - if ($this->force_ids == 0 && $this->primaryGroup == 0 && !$this->initially_was_account){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn")); - - /* Create group if it doesn't exist */ - if ($ldap->count() == 0){ - $groupdn= preg_replace ('/^'.$this->config->current['DNMODE'].'=[^,]+,'.get_people_ou().'/i', 'cn='.$this->uid.','.get_groups_ou(), $this->dn); - - $g= new group($this->config, $groupdn); - $g->cn= $this->uid; - $g->force_gid= 1; - $g->gidNumber= $this->gidNumber; - $g->description= "Group of user ".$this->givenName." ".$this->sn; - $g->save (); - } - } - - /* Take care about groupMembership values: add to groups */ - foreach ($this->groupMembership as $key => $value){ - if (!isset($this->savedGroupMembership[$key])){ - $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key,"groups"); - $g->set_acl_base($key); - $g->by_object['group']->addUser($this->uid); - $g->save(); - } - } - - /* Remove from groups not listed in groupMembership */ - foreach ($this->savedGroupMembership as $key => $value){ - if (!isset($this->groupMembership[$key])){ - $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key,"groups"); - $g->set_acl_base($key); - $g->by_object['group']->removeUser ($this->uid); - $g->save(); - } - } - - /* 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",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add" ,array("uid"=> $this->uid)); - } - } - - /* Check formular input */ - function check() - { - /* Include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Append groups as memberGroup: to check hook - */ - $tmp_attributes = $this->attributes; - $this->attributes[] = "memberGroup"; - $this->memberGroup = array(); - foreach($this->groupMembership as $dn => $name){ - $this->memberGroup[] = $name; - } - - /* Call common method to give check the hook */ - $message= plugin::check(); - $this->attributes = $tmp_attributes; - - /* must: homeDirectory */ - if ($this->homeDirectory == ""){ - $message[]= _("The required field 'Home directory' is not set."); - } - if (!is_path($this->homeDirectory)){ - $message[]= _("Please enter a valid path in 'Home directory' field."); - } - - /* Check ID's if they are forced by user */ - if ($this->force_ids == "1"){ - - /* Valid uid/gid? */ - if (!is_id($this->uidNumber)){ - $message[]= _("Value specified as 'UID' is not valid."); - } else { - if ($this->uidNumber < $this->config->current['MINID']){ - $message[]= _("Value specified as 'UID' is too small."); - } - } - if (!is_id($this->gidNumber)){ - $message[]= _("Value specified as 'GID' is not valid."); - } else { - if ($this->gidNumber < $this->config->current['MINID']){ - $message[]= _("Value specified as 'GID' is too small."); - } - } - } - - /* Check shadow settings, well I like spaghetties... */ - if ($this->use_shadowMin){ - if (!is_id($this->shadowMin)){ - $message[]= _("Value specified as 'shadowMin' is not valid."); - } - } - if ($this->use_shadowMax){ - if (!is_id($this->shadowMax)){ - $message[]= _("Value specified as 'shadowMax' is not valid."); - } - } - if ($this->use_shadowWarning){ - if (!is_id($this->shadowWarning)){ - $message[]= _("Value specified as 'shadowWarning' is not valid."); - } - if (!$this->use_shadowMax){ - $message[]= _("'shadowWarning' without 'shadowMax' makes no sense."); - } - if ($this->shadowWarning > $this->shadowMax){ - $message[]= _("Value specified as 'shadowWarning' should be smaller than 'shadowMax'."); - } - if ($this->use_shadowMin && $this->shadowWarning < $this->shadowMin){ - $message[]= _("Value specified as 'shadowWarning' should be greater than 'shadowMin'."); - } - } - if ($this->use_shadowInactive){ - if (!is_id($this->shadowInactive)){ - $message[]= _("Value specified as 'shadowInactive' is not valid."); - } - if (!$this->use_shadowMax){ - $message[]= _("'shadowInactive' without 'shadowMax' makes no sense."); - } - } - if ($this->use_shadowMin && $this->use_shadowMax){ - if ($this->shadowMin > $this->shadowMax){ - $message[]= _("Value specified as 'shadowMin' should be smaller than 'shadowMax'."); - } - } - - // if(empty($this->gosaDefaultPrinter)){ - // $message[]= _("You need to specify a valid default printer."); - // } - - return ($message); - } - - function addGroup ($groups) - { - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Walk through groups and add the descriptive entry if not exists */ - foreach ($groups as $value){ - if (!array_key_exists($value, $this->groupMembership)){ - $ldap->cat($value, array('cn', 'description', 'dn')); - $attrs= $ldap->fetch(); - error_reporting (0); - if (!isset($attrs['description'][0])){ - $entry= $attrs["cn"][0]; - } else { - $dsc= preg_replace ('/^Group of user/', _("Group of user"), $attrs["description"][0]); - $entry= $attrs["cn"][0]." [$dsc]"; - } - error_reporting (E_ALL | E_STRICT); - - if(obj_is_writable($attrs['dn'],"groups/group","memberUid")){ - $this->groupMembership[$attrs['dn']]= $entry; - } - } - } - - /* Sort groups */ - asort ($this->groupMembership); - reset ($this->groupMembership); - } - - - /* Del posix user from some groups */ - function delGroup ($groups) - { - $dest= array(); - foreach($groups as $dn_to_del){ - if(isset($this->groupMembership[$dn_to_del]) && obj_is_writable($dn_to_del,"groups/group","memberUid")){ - unset($this->groupMembership[$dn_to_del]); - } - } - } - - - /* Adapt from template, using 'dn' */ - function adapt_from_template($dn) - { - /* Include global link_info */ - $ldap= $this->config->get_ldap_link(); - - plugin::adapt_from_template($dn); - $template= $this->attrs['uid'][0]; - - /* Adapt group membership */ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->attrs["uid"][0]."))", array("description", "cn")); - - while ($this->attrs= $ldap->fetch()){ - if (!isset($this->attrs["description"][0])){ - $entry= $this->attrs["cn"][0]; - } else { - $entry= $this->attrs["cn"][0]." [".$this->attrs["description"][0]."]"; - } - $this->groupMembership[$ldap->getDN()]= $entry; - } - - /* Fix primary group settings */ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=posixGroup)(cn=$template)(gidNumber=".$this->gidNumber."))", array("cn")); - if ($ldap->count() != 1){ - $this->primaryGroup= $this->gidNumber; - } - - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaUserTemplate)(uid=".$template.")(accessTo=*))", array("cn","accessTo")); - while($attr = $ldap->fetch()){ - $tmp = $attr['accessTo']; - unset ($tmp['count']); - $this->accessTo = $tmp; - } - - /* Adjust shadow checkboxes */ - foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive") as $val){ - if ($this->$val != 0){ - $oval= "use_".$val; - $this->$oval= "1"; - } - } - - /* FIXME: NEED review of this section */ - /* Need to check shadowExpire separately */ - - /* - * If shadowExpire is not enabled in the template, it's a UNIX timestamp - so don't convert it to seconds. - * The check is a hack - if difference between timestamp generated above and here is max 1 day. - */ - if(abs($this->shadowExpire - time())>86400) { - $this->shadowExpire= $this->convertToSeconds($this->shadowExpire); - } - - /* Only enable checkbox, if shadowExpire is in the future */ - if($this->shadowExpire > time()) { - $this->use_shadowExpire= "1"; - } - } - - function convertToSeconds($val) - { - if ($val != 0){ - $val*= 60 * 60 * 24; - } else { - $date= getdate(); - $val= floor($date[0] / (60*60*24)) * 60 * 60 * 24; - } - return($val); - } - - - function get_next_id($attrib, $dn) - { - $ids= array(); - $ldap= $this->config->get_ldap_link(); - - $ldap->cd ($this->config->current['BASE']); - if (preg_match('/gidNumber/i', $attrib)){ - $oc= "posixGroup"; - } else { - $oc= "posixAccount"; - } - $ldap->search ("(&(objectClass=$oc)($attrib=*))", array("$attrib")); - - /* Get list of ids */ - while ($attrs= $ldap->fetch()){ - $ids[]= (int)$attrs["$attrib"][0]; - } - - /* Add the nobody id */ - $ids[]= 65534; - - /* get the ranges */ - $tmp = array('0'=> 1000); - if (preg_match('/posixAccount/', $oc) && isset($this->config->current['UIDBASE'])) { - $tmp= split('-',$this->config->current['UIDBASE']); - } elseif(isset($this->config->current['GIDBASE'])){ - $tmp= split('-',$this->config->current['GIDBASE']); - } - - /* Set hwm to max if not set - for backward compatibility */ - $lwm= $tmp[0]; - if (isset($tmp[1])){ - $hwm= $tmp[1]; - } else { - $hwm= pow(2,32); - } - - /* Find out next free id near to UID_BASE */ - if (!isset($this->config->current['BASE_HOOK'])){ - $base= $lwm; - } else { - /* Call base hook */ - $base= get_base_from_hook($dn, $attrib); - } - for ($id= $base; $id++; $id < pow(2,32)){ - if (!in_array($id, $ids)){ - return ($id); - } - } - - /* Should not happen */ - if ($id == $hwm){ - print_red(_("Too many users, can't allocate a free ID!")); - exit; - } - - } - - function reload() - { - /* Set base for all searches */ - $base = $_SESSION['CurrentMainBase']; - $base = $base; - $ldap = $this->config->get_ldap_link(); - $attrs = array("cn", "description", "gidNumber"); - $Flags = GL_SIZELIMIT; - - /* Get groups */ - if ($this->GroupUserRegex == '*'){ - $filter = "(&(objectClass=posixGroup)(cn=".$this->GroupRegex."))"; - } else { - $filter= "(&(objectClass=posixGroup)(cn=".$this->GroupRegex.")(memberUid=".$this->GroupUserRegex."))"; - } - if($this->SubSearch){ - $Flags |= GL_SUBSEARCH; - }else{ - $base = get_groups_ou().$base; - } - - $res= get_list($filter, "groups", $base,$attrs, $Flags); - - /* check sizelimit */ - if (preg_match("/size limit/i", $ldap->error)){ - $_SESSION['limit_exceeded']= TRUE; - } - - /* Create a list of users */ - $this->grouplist = array(); - foreach ($res as $value){ - $this->grouplist[$value['gidNumber'][0]]= $value; - } - - $tmp=array(); - foreach($this->grouplist as $tkey => $val ){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - - /* Sort index */ - ksort($tmp); - - /* Recreate index array[dn]=cn[description]*/ - $this->grouplist=array(); - foreach($tmp as $val){ - if(isset($val['description'])){ - $this->grouplist[$val['dn']]=$val['cn'][0]." [".$val['description'][0]."]"; - }else{ - $this->grouplist[$val['dn']]=$val['cn'][0]; - } - } - - reset ($this->grouplist); - } - - - /* Get posts from copy & paste dialog */ - function saveCopyDialog() - { - if(isset($_POST['homeDirectory'])){ - $this->homeDirectory = $_POST['homeDirectory']; - if (isset ($_POST['force_ids'])){ - $data= 1; - $this->gidNumber = $_POST['gidNumber']; - $this->uidNumber = $_POST['uidNumber']; - } else { - $data= 0; - } - if ($this->force_ids != $data){ - $this->is_modified= TRUE; - } - $this->force_ids= $data; - } - } - - - /* Create the posix dialog part for copy & paste */ - function getCopyDialog() - { - /* Skip dialog creation if this is not a valid account*/ - if(!$this->is_account) return(""); - if ($this->force_ids == 1){ - $force_ids = "checked"; - if ($_SESSION['js']){ - $forceMode = ""; - } - } else { - if ($_SESSION['js']){ - if($this->acl != "#none#") - $forceMode ="disabled"; - } - $force_ids = ""; - } - - $sta = ""; - - /* Open group add dialog */ - if(isset($_POST['edit_groupmembership'])){ - $this->group_dialog = TRUE; - $sta = "SubDialog"; - } - - /* If the group-add dialog is closed, call execute - to ensure that the membership is updatd */ - if(isset($_POST['add_groups_finish']) || isset($_POST['add_groups_cancel'])){ - $this->execute(); - $this->group_dialog =FALSE; - } - - if($this->group_dialog){ - $str = $this->execute(true); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = $sta; - return($ret); - } - - /* If a group member should be deleted, simply call execute */ - if(isset($_POST['delete_groupmembership'])){ - $this->execute(); - } - - /* Assigned informations to smarty */ - $smarty = get_smarty(); - $smarty->assign("homeDirectory",$this->homeDirectory); - $smarty->assign("uidNumber",$this->uidNumber); - $smarty->assign("gidNumber",$this->gidNumber); - $smarty->assign("forceMode",$forceMode); - $smarty->assign("force_ids",$force_ids); - if (!count($this->groupMembership)){ - $smarty->assign("groupMembership", array(" ")); - } else { - $smarty->assign("groupMembership", $this->groupMembership); - } - - /* Display wars message if there are more than 16 group members */ - if (count($this->groupMembership) > 16){ - $smarty->assign("groups", "too_many_for_nfs"); - } else { - $smarty->assign("groups", ""); - } - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - - $ret = array(); - $ret['string'] = $str; - $ret['status'] = $sta; - return($ret); - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - - /* Avoid using the same gid/uid number as source user */ - $this->savedUidNumber = $this->get_next_id("gidNumber", $this->dn); - $this->savedGidNumber = $this->get_next_id("uidNumber", $this->dn); - } - - - function multiple_execute() - { - return($this->execute()); - } - - - static function plInfo() - { - return (array( - "plDescription" => _("POSIX account"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 2, - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - - "homeDirectory" => _("Home directory"), - "loginShell" => _("Shell"), - "uidNumber" => _("User ID"), - "gidNumber" => _("Group ID"), - - "mustchangepassword"=> _("Force password change on login"), - "shadowMin" => _("Shadow min"), - "shadowMax" => _("Shadow max"), - "shadowWarning" => _("Shadow warning"), - "shadowInactive" => _("Shadow inactive"), - "shadowExpire" => _("Shadow expire"), - "trustModel" => _("System trust model"))) - ); - } - - function get_multi_edit_values() - { - $ret = plugin::get_multi_edit_values(); - return($ret); - } - - - function multiple_save_object() - { - if(isset($_POST['posix_mulitple_edit'])){ - plugin::multiple_save_object(); - foreach(array("primaryGroup") as $val){ - if(isset($_POST["use_".$val])){ - $this->multi_boxes[] = $val; - } - } - - /* Save primary group settings */ - if($this->acl_is_writeable("primaryGroup") && isset($_POST['primaryGroup'])){ - $data= $_POST['primaryGroup']; - if ($this->primaryGroup != $data){ - $this->is_modified= TRUE; - } - $this->primaryGroup= $_POST['primaryGroup']; - } - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/posix/generic.tpl b/plugins/personal/posix/generic.tpl deleted file mode 100644 index c9dc98d47..000000000 --- a/plugins/personal/posix/generic.tpl +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - -
-

{t}Generic{/t}

- - - - - - - - - - - - - -{if !$multiple_support} - - - - -{/if} -
{$must} -{render acl=$homeDirectoryACL checkbox=$multiple_support checked=$use_homeDirectory} - -{/render} -
-{render acl=$loginShellACL checkbox=$multiple_support checked=$use_loginShell} - -{/render} -
-{render acl=$gidNumberACL checkbox=$multiple_support checked=$use_primaryGroup} - -{/render} -
{t}Status{/t}{$status}
- -{if !$multiple_support} - - - - - - - - - - - - - - -
-{render acl=$force_idsACL} - -{/render} - - - - - -{render acl=$uidNumberACL} - -{/render} -
- - -{render acl=$gidNumberACL} - -{/render} -
-{/if} -
-   - -

{t}Group membership{/t}

- {if $groups eq "too_many_for_nfs"} - {t}(Warning: more than 16 groups are not supported by NFS!){/t} -
- {/if} -{render acl=$groupMembershipACL} - -{/render} -
-{render acl=$groupMembershipACL} -   -{/render} -{render acl=$groupMembershipACL} - -{/render} -
- -

 

- - - - - - - -
-

{t}Account{/t}

- {include file="$pwmode.tpl"} -
-   - -

{t}System trust{/t}

- {t}Trust mode{/t}  -{render acl=$trustmodeACL} - -{/render} -{render acl=$trustmodeACL} - -{/render} -
-{render acl=$trustmodeACL} -   -{/render} -{render acl=$trustmodeACL} - -{/render} -
-{if $multiple_support} - -{/if} - - - - - diff --git a/plugins/personal/posix/main.inc b/plugins/personal/posix/main.inc deleted file mode 100644 index 31994ef3f..000000000 --- a/plugins/personal/posix/main.inc +++ /dev/null @@ -1,133 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('posixAccount'); - } - - /* Create posixAccount object on demand */ - if (!isset($_SESSION['posixAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['posixAccount']= new posixAccount ($config, $ui->dn); - $_SESSION['posixAccount']->enable_CSN_check(); - $_SESSION['posixAccount']->set_acl_base($ui->dn); - $_SESSION['posixAccount']->set_acl_category("users"); - } - $posixAccount= $_SESSION['posixAccount']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $posixAccount->save_object (); - } - - /* Enter edit mode? */ - if ((isset($_POST['edit'])) && (!isset($_SESSION['edit']))){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - } - - /* save changes to LDAP and disable edit mode */ - $info= ""; - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $posixAccount->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $posixAccount->save (); - del_lock ($ui->dn); - sess_del ('edit'); - - /* Remove from session */ - sess_del ('posixAccount'); - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display = $lock_msg; - }else{ - $display.= $posixAccount->execute (); - } - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['posixAccount']= $posixAccount; - } - - /* Show page footer depending on the mode */ - if (!$posixAccount->group_dialog && !$posixAccount->show_ws_dialog && $posixAccount->is_account && empty($lock_msg)){ - - $display.= "

"; - - /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - /* Only display edit button if there is at least one attribute editable */ - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/posixAccount"))){ - $info.= "\"\" ". - _("Click the 'Edit' button below to change informations in this dialog"); - - $display.= "\n"; - } - $display.= "\n"; - } - $display.= "

\n"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/posix.png'), - _("Unix settings"), $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/posix/paste_generic.tpl b/plugins/personal/posix/paste_generic.tpl deleted file mode 100644 index b08feb59c..000000000 --- a/plugins/personal/posix/paste_generic.tpl +++ /dev/null @@ -1,70 +0,0 @@ - - - - -
-

{t}Posix settings{/t}

- - - - - -
- - - -
- - - - - - - - - - - - - -
- - - -   - - - -
  - - - -
- - - - - - - -
-

{t}Group membership{/t}

-
- - {if $groups eq "too_many_for_nfs"} - {t}(Warning: more than 16 groups are not supported by NFS!){/t} -
- {/if} - -
-   - -
-
-
-
diff --git a/plugins/personal/posix/posix_groups.tpl b/plugins/personal/posix/posix_groups.tpl deleted file mode 100644 index 841d8a87a..000000000 --- a/plugins/personal/posix/posix_groups.tpl +++ /dev/null @@ -1,83 +0,0 @@ - - - - - -
-
-

- {t}Select groups to add{/t} {$hint} -

-
-
-

- - -

-
-
-
-

- [F]{t}Filters{/t} -

-
-
- - {$alphabet} -
- - - - - - -
-  {t}Display groups of department{/t} - - -
- - - - - -
-  {t}Display groups matching{/t} - - -
- - - - - -
-  {t}Display groups of user{/t} - - -
- - - - -
- - {t}Search in subtrees{/t} -
- {$apply} -
-
- -

- -   - -

- diff --git a/plugins/personal/posix/posix_shadow.tpl b/plugins/personal/posix/posix_shadow.tpl deleted file mode 100644 index bd7862c6d..000000000 --- a/plugins/personal/posix/posix_shadow.tpl +++ /dev/null @@ -1,79 +0,0 @@ - - - - -
- - -{render acl=$mustchangepasswordACL} - -{/render} - {t}User must change password on first login{/t} -
- - -{render acl=$shadowMinACL} - -{/render} -{render acl=$shadowMinACL} - {$shadowmins} -{/render} -
- - -{render acl=$shadowMaxACL} - -{/render} -{render acl=$shadowMaxACL} - {$shadowmaxs} -{/render} -
- - -{render acl=$shadowExpireACL} - -{/render} - {t}Password expires on{/t} -{render acl=$shadowExpireACL} - -{/render} -{render acl=$shadowExpireACL} - -{/render} -{render acl=$shadowExpireACL} - - -{/render} -
- - -{render acl=$shadowInactiveACL} - -{/render} -{render acl=$shadowInactiveACL} - {$shadowinactives} -{/render} -
- - -{render acl=$shadowWarningACL} - -{/render} -{render acl=$shadowWarningACL} - {$shadowwarnings} -{/render} -
- - - diff --git a/plugins/personal/posix/trust_machines.tpl b/plugins/personal/posix/trust_machines.tpl deleted file mode 100644 index 3550fcf29..000000000 --- a/plugins/personal/posix/trust_machines.tpl +++ /dev/null @@ -1,42 +0,0 @@ - - - - - -
-
-

- {t}Select systems to add{/t} {$hint}
-

-
-
-

- -

-
-
-
-

[F]{ -t}Filters{/t}

-
-
- - {$alphabet} -
- -
 {t}Display systems of department{/t}
- -
 {t}Display systems matching{/t}
- {$apply} -
-
- -

- -   - -

diff --git a/plugins/personal/samba/class_sambaAccount.inc b/plugins/personal/samba/class_sambaAccount.inc deleted file mode 100644 index bd71c8f7a..000000000 --- a/plugins/personal/samba/class_sambaAccount.inc +++ /dev/null @@ -1,1142 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* Switch for Samba version */ - var $samba3= FALSE; - var $uidNumber= 65535; - var $gidNumber= 65535; - - /* Samba 2 attributes */ - var $pwdLastSet= "0"; - var $logonTime= "0"; - var $logoffTime= "2147483647"; - var $kickoffTime= "2147483647"; - var $pwdCanChange= "0"; - var $pwdMustChange= "0"; - var $password_expires= 0; - var $acctFlags= "[UX ]"; - var $smbHome= ""; - var $homeDrive= ""; - var $scriptPath= ""; - var $profilePath= ""; - var $rid= ""; - var $primaryGroupID= ""; - - /* Samba 3 attributes */ - var $SID= ""; - var $ridBase= 0; - var $sambaSID= ""; - var $sambaPwdLastSet= "0"; - var $sambaLogonTime= "0"; - var $sambaLogoffTime= "2147483647"; - var $sambaKickoffTime= "2147483647"; - var $sambaPwdCanChange= ""; - var $sambaPwdMustChange= "0"; - var $sambaAcctFlags= "[UX ]"; - var $sambaHomePath= ""; - var $sambaHomeDrive= ""; - var $sambaLogonScript= ""; - var $sambaProfilePath= ""; - var $sambaPrimaryGroupSID= ""; - var $sambaDomainName= ""; - var $sambaUserWorkstations= ""; - var $sambaBadPasswordCount= ""; - var $sambaBadPasswordTime= ""; - var $sambaPasswordHistory= ""; - var $sambaLogonHours= ""; - var $orig_sambaDomainName= ""; - var $sambaMungedDial= ""; - var $mungedObject; - - /* Helper */ - var $show_ws_dialog= FALSE; - var $logon_time_set= 0; - var $logoff_time_set= 0; - var $kickoff_time_set= 0; - - /* attribute list for save action */ - var $ctxattributes= array(); - var $attributes= array(); - var $objectclasses= array(); - - var $uid= ""; - var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName"); - - function sambaAccount (&$config, $dn= NULL) - { - /* Load attributes depending on the samba version */ - $this->samba3= ($config->current['SAMBAVERSION'] == 3); - - if ($this->samba3){ - $this->attributes= array ("sambaSID", "sambaPwdLastSet", "sambaLogonTime", - "sambaLogoffTime", "sambaKickoffTime", "sambaPwdCanChange", - "sambaPwdMustChange", "sambaAcctFlags", "uid", "sambaMungedDial", - "sambaHomePath", "sambaHomeDrive", "sambaLogonScript", - "sambaProfilePath", "sambaPrimaryGroupSID", "sambaDomainName", - "sambaUserWorkstations", "sambaPasswordHistory", - "sambaLogonHours", "sambaBadPasswordTime", - "sambaBadPasswordCount"); - $this->objectclasses= array ("sambaSamAccount"); - $this->mungedObject= new sambaMungedDial; - $this->ctxattributes= $this->mungedObject->ctxattributes; - } else { - $this->attributes= array ("pwdLastSet", "logonTime", "logoffTime", "kickoffTime", - "pwdCanChange", "pwdMustChange", "acctFlags", "profilePath", "uid", - "smbHome", "homeDrive", "scriptPath", "rid", "primaryGroupID"); - $this->objectclasses= array ("sambaAccount"); - } - - plugin::plugin ($config, $dn); - - /* Setting uid to default */ - if(isset($this->attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - /* Get samba Domain in case of samba 3 */ - if ($this->samba3 && $this->sambaSID != ""){ - $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID); - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase","sambaDomainName")); - if ($ldap->count() != 0){ - $attrs= $ldap->fetch(); - $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0]; - if ($this->sambaDomainName == ""){ - $this->sambaDomainName= $attrs['sambaDomainName'][0]; - } - } else { - if ($this->sambaDomainName == ""){ - $this->sambaDomainName= "DEFAULT"; - } - $this->ridBase= $this->config->current['RIDBASE']; - $this->SID= $this->config->current['SID']; - } - - /* Save in order to compare later on */ - $this->orig_sambaDomainName= $this->sambaDomainName; - } - - /* Fill mungedDial field */ - if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){ - $this->mungedObject->load($this->sambaMungedDial); - } - - /* Password expiery */ - if(isset($this->attrs['sambaPwdMustChange']) && - $this->attrs['sambaPwdMustChange'][0] != 0){ - $this->password_expires= 1; - } - - if(isset($this->attrs['sambaLogonTime']) && ! ( - $this->attrs['sambaLogonTime'][0] == 0 || - $this->attrs['sambaLogonTime'][0] == 2147483647 - )){ - $this->logon_time_set= 1; - } - if(isset($this->attrs['sambaLogoffTime']) && ! ( - $this->attrs['sambaLogoffTime'][0] == 0 || - $this->attrs['sambaLogoffTime'][0] == 2147483647 - )){ - $this->logoff_time_set= 1; - } - - /* Account expiery */ - if(isset($this->attrs['sambaKickoffTime']) && ! ( - $this->attrs['sambaKickoffTime'][0] == 0 || - $this->attrs['sambaKickoffTime'][0] == 2147483647 - )){ - $this->kickoff_time_set= 1; - } - - /* Get global filter config */ - if (!is_global("sambafilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $sambafilter= array( "depselect" => $base, "regex" => "*"); - register_global("sambafilter", $sambafilter); - } - - /* Save initial account state */ - $this->initially_was_account= $this->is_account; - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\"src=\"images/stop.png\" ". - _("This account has no samba extensions.").""; - $display.= back_to_main(); - return ($display); - } - - /* Show tab dialog headers */ - $display= ""; - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove samba account"), - _("This account has samba features enabled. You can disable them by clicking below.")); - } else { - $obj= $this->parent->by_object['posixAccount']; - - /* Samba3 dependency on posix accounts are enabled - in the moment, because I need to rely on unique - uidNumbers. There'll be a better solution later - on. */ - if ($obj->is_account){ - - $display= $this->show_enable_header(_("Create samba account"), - _("This account has samba features disabled. You can enable them by clicking below.")); - } else { - $display= $this->show_enable_header(_("Create samba account"), - _("This account has samba features disabled. Posix features are needed for samba accounts, enable them first."), TRUE); - } - return ($display); - } - } - - $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - - /* Open Samaba Logong hours dialog */ - if(isset($_POST['SetSambaLogonHours']) && $this->samba3 && $this->acl_is_writeable("sambaLogonHours")){ - $this->dialog = new sambaLogonHours($this->config,$this->dn,$this->sambaLogonHours); - } - - /* Cancel dialog */ - if(isset($_POST['cancel_logonHours'])){ - $this->dialog = FALSE; - } - - /* Save selected logon hours */ - if(isset($_POST['save_logonHours'])){ - $this->dialog->save_object(); - if($this->acl_is_writeable("sambaLogonHours")){ - $this->sambaLogonHours = $this->dialog->save(); - } - $this->dialog = FALSE; - } - - /* Display dialog */ - if((isset($this->dialog)) && (is_object($this->dialog))){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - - /* Prepare templating */ - $smarty= get_smarty(); - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $var => $rest){ - $smarty->assign($var."ACL",$this->getacl($var,$SkipWrite)); - } - - if ($this->sambaPwdMustChange=="0"){ - $date= getdate(); - } else { - $date= getdate($this->sambaPwdMustChange); - } - - if ($this->sambaLogonTime=="2147483647" || $this->sambaLogonTime=="0"){ - $sambaLogonTime_date= getdate(); - } else { - $sambaLogonTime_date= getdate($this->sambaLogonTime); - } - - if ($this->sambaLogoffTime=="2147483647" || $this->sambaLogoffTime=="0"){ - $sambaLogoffTime_date= getdate(); - } else { - $sambaLogoffTime_date= getdate($this->sambaLogoffTime); - } - - if ($this->sambaKickoffTime=="2147483647" || $this->sambaKickoffTime=="0"){ - $sambaKickoffTime_date= getdate(); - } else { - $sambaKickoffTime_date= getdate($this->sambaKickoffTime); - } - - /* Remove user workstations? */ - if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){ - - if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){ - - $tmp= $this->sambaUserWorkstations; - foreach($_POST['workstation_list'] as $name){ - $tmp= preg_replace("/$name/", '', $tmp); - $this->is_modified= TRUE; - } - $tmp= preg_replace('/,+/', ',', $tmp); - $this->sambaUserWorkstations= trim($tmp, ','); - } - } - - /* Add user workstation? */ - if (isset($_POST["add_ws"])){ - if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){ - $this->show_ws_dialog= TRUE; - $this->dialog= TRUE; - } - } - - /* Add user workstation finished? */ - if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){ - $this->show_ws_dialog= FALSE; - $this->dialog= FALSE; - } - - /* Add user workstation? */ - if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){ - $tmp= $this->sambaUserWorkstations; - foreach($_POST['wslist'] as $ws){ - $tmp.= ",$ws"; - } - $tmp= preg_replace('/,+/', ',', $tmp); - $this->sambaUserWorkstations= trim($tmp, ','); - $this->is_modified= TRUE; - } - - /* Show ws dialog */ - if ($this->show_ws_dialog){ - - /* Save data */ - $sambafilter= get_global("sambafilter"); - foreach( array("depselect", "regex") as $type){ - if (isset($_POST[$type])){ - $sambafilter[$type]= $_POST[$type]; - } - } - if (isset($_GET['search'])){ - $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; - if ($s == "**"){ - $s= "*"; - } - $sambafilter['regex']= $s; - } - register_global("sambafilter", $sambafilter); - - /* Get workstation list */ - $exclude= ""; - foreach(split(',', $this->sambaUserWorkstations) as $ws){ - $exclude.= "(cn=$ws$)"; - } - if ($exclude != ""){ - $exclude= "(!(|$exclude))"; - } - $regex= $sambafilter['regex']; - $filter= "(&(objectClass=sambaSAMAccount)$exclude(uid=*$)(|(uid=$regex)(cn=$regex)))"; - $res= get_list($filter, "winworkstation", $sambafilter['depselect'], array("uid"), GL_SUBSEARCH | GL_SIZELIMIT); - - $wslist= array(); - foreach ($res as $attrs){ - $wslist[]= preg_replace('/\$/', '', $attrs['uid'][0]); - } - asort($wslist); - - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("launchimage", get_template_path('images/small_filter.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("alphabet", generate_alphabet()); - foreach( array("depselect", "regex") as $type){ - $smarty->assign("$type", $sambafilter[$type]); - } - $smarty->assign("hint", print_sizelimit_warning()); - $smarty->assign("wslist", $wslist); - $smarty->assign("apply", apply_filter()); - $display= $smarty->fetch (get_template_path('samba3_workstations.tpl', TRUE, - dirname(__FILE__))); - return ($display); - } - - /* Fill calendar */ - $days= array(); - for($d= 1; $d<32; $d++){ - $days[]= $d; - } - $years= array(); - for($y= $date['year']-4; $y<$date['year']+4; $y++){ - $years[]= $y; - } - $months= array(_("January"), _("February"), _("March"), _("April"), - _("May"), _("June"), _("July"), _("August"), _("September"), - _("October"), _("November"), _("December")); - $smarty->assign("day", $date["mday"]); - $smarty->assign("days", $days); - $smarty->assign("months", $months); - $smarty->assign("month", $date["mon"]-1); - $smarty->assign("years", $years); - $smarty->assign("year", $date["year"]); - - $sambaLogonTime_days= array(); - for($d= 1; $d<32; $d++){ - $sambaLogonTime_days[]= $d; - } - $sambaLogonTime_years= array(); - for($y= $date['year']-4; $y<$date['year']+4; $y++){ - $sambaLogonTime_years[]= $y; - } - $sambaLogonTime_months= array(_("January"), _("February"), _("March"), _("April"), - _("May"), _("June"), _("July"), _("August"), _("September"), - _("October"), _("November"), _("December")); - $smarty->assign("sambaLogonTime_day", $sambaLogonTime_date["mday"]); - $smarty->assign("sambaLogonTime_days", $sambaLogonTime_days); - $smarty->assign("sambaLogonTime_months", $sambaLogonTime_months); - $smarty->assign("sambaLogonTime_month", $sambaLogonTime_date["mon"]-1); - $smarty->assign("sambaLogonTime_years", $sambaLogonTime_years); - $smarty->assign("sambaLogonTime_year", $sambaLogonTime_date["year"]); - - $sambaLogoffTime_days= array(); - for($d= 1; $d<32; $d++){ - $sambaLogoffTime_days[]= $d; - } - $sambaLogoffTime_years= array(); - for($y= $date['year']-4; $y<$date['year']+4; $y++){ - $sambaLogoffTime_years[]= $y; - } - $sambaLogoffTime_months= array(_("January"), _("February"), _("March"), _("April"), - _("May"), _("June"), _("July"), _("August"), _("September"), - _("October"), _("November"), _("December")); - $smarty->assign("sambaLogoffTime_day", $sambaLogoffTime_date["mday"]); - $smarty->assign("sambaLogoffTime_days", $sambaLogoffTime_days); - $smarty->assign("sambaLogoffTime_months", $sambaLogoffTime_months); - $smarty->assign("sambaLogoffTime_month", $sambaLogoffTime_date["mon"]-1); - $smarty->assign("sambaLogoffTime_years", $sambaLogoffTime_years); - $smarty->assign("sambaLogoffTime_year", $sambaLogoffTime_date["year"]); - - $sambaKickoffTime_days= array(); - for($d= 1; $d<32; $d++){ - $sambaKickoffTime_days[]= $d; - } - $sambaKickoffTime_years= array(); - for($y= $date['year']-4; $y<$date['year']+4; $y++){ - $sambaKickoffTime_years[]= $y; - } - $sambaKickoffTime_months= array(_("January"), _("February"), _("March"), _("April"), - _("May"), _("June"), _("July"), _("August"), _("September"), - _("October"), _("November"), _("December")); - //$smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]-1); - $smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]); // hickert - $smarty->assign("sambaKickoffTime_days", $sambaKickoffTime_days); - $smarty->assign("sambaKickoffTime_months", $sambaKickoffTime_months); - $smarty->assign("sambaKickoffTime_month", $sambaKickoffTime_date["mon"]-1); - $smarty->assign("sambaKickoffTime_years", $sambaKickoffTime_years); - $smarty->assign("sambaKickoffTime_year", $sambaKickoffTime_date["year"]); - - /* Fill boxes */ - if ($this->samba3){ - $domains= array(); - foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){ - $domains[]= $name; - } - $smarty->assign("domains", $domains); - } - $letters= array(); - for ($i= 68; $i<91; $i++){ - $letters[]= chr($i).":"; - } - $smarty->assign("drives", $letters); - - /* Fill terminal server settings */ - if ($this->samba3){ - foreach ($this->ctxattributes as $attr){ - /* Fill common attributes */ - if (isset($this->mungedObject->ctx[$attr])){ - $smarty->assign("$attr", $this->mungedObject->ctx[$attr]); - // Set field to blank if value is 0 - if(in_array($attr, array("CtxMaxConnectionTime", "CtxMaxDisconnectionTime", "CtxMaxIdleTime"))) { - if($this->mungedObject->ctx[$attr] == 0) { - $smarty->assign("$attr", ""); - } - } - } else { - $smarty->assign("$attr", ""); - } - } - - /* Assign enum values for preset items */ - $shadowModeVals= array( "0" => _("disabled"), - "1" => _("input on, notify on"), - "2" => _("input on, notify off"), - "3" => _("input off, notify on"), - "4" => _("input off, nofify off")); - - $brokenConnModeVals= array( "0" => _("disconnect"), - "1" => _("reset")); - - $reConnModeVals= array( "0" => _("from any client"), - "1" => _("from previous client only")); - - /* Fill preset items */ - $smarty->assign("shadow", $shadowModeVals); - $smarty->assign("brokenconn", $brokenConnModeVals); - $smarty->assign("reconn", $reConnModeVals); - - /* Fill preset items with values */ - $smarty->assign("shadowmode", $this->mungedObject->getShadow()); - $smarty->assign("brokenconnmode", $this->mungedObject->getBrokenConn()); - $smarty->assign("reconnmode", $this->mungedObject->getReConn()); - - if($_SESSION['js']){ - /* Set form elements to disabled/enable state */ - $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled"); - - $smarty->assign("inheritstate", ""); - if($this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){ - $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":""); - } - - - - }else{ - $smarty->assign("tsloginstate", ""); - $smarty->assign("inheritstate", ""); - } - - /* Set checkboxes to checked or unchecked state */ - $smarty->assign("tslogin", $this->mungedObject->getTsLogin()?"checked":""); - $smarty->assign("inherit", $this->mungedObject->getInheritMode()?"checked":""); - $smarty->assign("connectclientdrives", - $this->mungedObject->getConnectClientDrives()?"checked":""); - $smarty->assign("connectclientprinters", - $this->mungedObject->getConnectClientPrinters()?"checked":""); - $smarty->assign("defaultprinter", - $this->mungedObject->getDefaultPrinter()?"checked":""); - $smarty->assign("CtxMaxConnectionTimeF", - $this->mungedObject->getCtxMaxConnectionTimeF()?"checked":""); - $smarty->assign("CtxMaxDisconnectionTimeF", - $this->mungedObject->getCtxMaxDisconnectionTimeF()?"checked":""); - $smarty->assign("CtxMaxIdleTimeF", - $this->mungedObject->getCtxMaxIdleTimeF()?"checked":""); - - /* Fill sambaUserWorkstations */ - $ws= split(",", $this->sambaUserWorkstations); - sort($ws); - - /* Tidy checks for empty option, and smarty will produce one if array[0]="" */ - if(($ws[0]=="")&&(count($ws)==1)) $ws=array(); - - - $smarty->assign("workstations", $ws); - } - - /* Variables */ - foreach($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - - /* 'sambaAcctFlags' checkboxes */ - /* Check for 'lock-account'-flag: 'D' or 'L' */ - if (is_integer(strpos($this->sambaAcctFlags, "D")) || - is_integer(strpos($this->sambaAcctFlags, "L"))) { - $smarty->assign("flagsD", "checked"); - } else { - $smarty->assign("flagsD", ""); - } - - /* Check for no_password_required flag 'N' */ - if (is_integer(strpos($this->sambaAcctFlags, "N"))) { - $smarty->assign("flagsN", "checked"); - } else { - $smarty->assign("flagsN", ""); - } - - if($this->samba3){ - if ($this->sambaPwdCanChange=="1"){ - $smarty->assign("flagsP", "checked"); - } else { - $smarty->assign("flagsP", ""); - } - }else{ - if ($this->pwdCanChange=="1"){ - $smarty->assign("flagsP", "checked"); - } else { - $smarty->assign("flagsP", ""); - } - } - - if ($this->password_expires=="1"){ - $smarty->assign("flagsC", "checked"); - } else { - $smarty->assign("flagsC", ""); - } - if ($this->logon_time_set=="1"){ - $smarty->assign("flagsT", "checked"); - } else { - $smarty->assign("flagsT", ""); - } - if ($this->logoff_time_set=="1"){ - $smarty->assign("flagsO", "checked"); - } else { - $smarty->assign("flagsO", ""); - } - if ($this->kickoff_time_set=="1"){ - $smarty->assign("flagsK", "checked"); - } else { - $smarty->assign("flagsK", ""); - } - - - /* In case of javascript, disable some fields on demand */ - if ($this->samba3){ - foreach($this->mungedObject->getOnDemandFlags() as $key => $value) { - $smarty->assign("$key", "$value"); - } - } - - /* Show main page */ - if ($this->samba3){ - $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__))); - } else { - $display.= $smarty->fetch (get_template_path('samba2.tpl', TRUE, dirname(__FILE__))); - } - - return ($display); - } - - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - plugin::remove_from_parent(); - - /* Keep uid attribute for gosaAccount */ - unset($this->attrs['uid']); - unset($this->attrs['uidNumber']); - unset($this->attrs['gidNumber']); - - /* Remove objectClass for sambaIdmapEntry */ - $tmp= array(); - for ($i= 0; $iattrs["objectClass"]); $i++){ - if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){ - $tmp[]= $this->attrs['objectClass'][$i]; - } - } - $this->attrs['objectClass']= $tmp; - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, - $this->attributes, "Save"); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/samba account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove", array("uid" => $this->uid)); - } - - - /* Check for input problems */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if ($this->samba3){ - - /* Strings */ - foreach (array( "sambaHomePath" => _("Home directory"), - "sambaProfilePath" => _("Profile path")) as $key => $val){ - if (!$this->mungedObject->is_samba_path($this->$key)){ - $message[]= sprintf(_("The value specified as '%s' contains invalid characters!"), $val); - } - } - - /* Numeric values */ - foreach (array( "CtxMaxConnectionTime" => _("Connection"), - "CtxMaxDisconnectionTime" => _("Disconnection"), - "CtxMaxIdleTime" => _("IDLE")) as $key => $val){ - - if (isset($this->mungedObject->ctx[$key]) && !is_id($this->mungedObject->ctx[$key]) && $val != 0){ - $message[]= sprintf(_("The timeout property '%s' is checked and contains invalid or no characters!"), $val); - } - } - - /* Too many workstations? Windows usrmgr only supports eight */ - if (substr_count($this->sambaUserWorkstations, ",") >= 8){ - $message[]= _("The windows user manager only allows eight clients. You've specified more than eight."); - } - } - - return ($message); - } - - - /* Save data to object */ - function save_object() - { - - $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']); - - /* We only care if we are on the sambaTab... */ - if (isset($_POST['sambaTab'])){ - plugin::save_object(); - - /* Take care about access options */ - if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){ - if ($this->samba3){ - $attrname= "sambaPwdCanChange"; - } else { - $attrname= "pwdCanChange"; - } - if (isset($_POST["allow_pwchange"]) && $_POST["allow_pwchange"] == 1){ - $tmp= 1; - } else { - $tmp= 0; - } - if ($this->$attrname != $tmp){ - $this->is_modified= TRUE; - } - $this->pwdCanChange= $tmp; - $this->sambaPwdCanChange= $tmp; - } - $tmp= "UX"; - if (isset($_POST["no_password_required"])){ - if ($_POST["no_password_required"] == 1){ - $tmp.= "N"; - } - } - if (isset($_POST["password_expires"])){ - if ($_POST["password_expires"] == 1){ - $this->password_expires= 1; - } - } else { - $this->password_expires= 0; - } - if (isset($_POST["temporary_disable"])){ - if ($_POST["temporary_disable"] == 1){ - if (is_integer(strpos($this->sambaAcctFlags, "L"))) { - $tmp.= "L"; - } else { - $tmp.= "D"; - } - } - } - if (isset($_POST["logon_time_set"])){ - if ($_POST["logon_time_set"] == 1){ - $this->logon_time_set= 1; - } - } else { - $this->logon_time_set= 0; - } - if (isset($_POST["logoff_time_set"])){ - if ($_POST["logoff_time_set"] == 1){ - $this->logoff_time_set= 1; - } - } else { - $this->logoff_time_set= 0; - } - if (isset($_POST["kickoff_time_set"])){ - if ($_POST["kickoff_time_set"] == 1){ - $this->kickoff_time_set= 1; - } - } else { - $this->kickoff_time_set= 0; - } - - $fill= ""; - for ($i= strlen($tmp); $i<12; $i++){ - $fill.= " "; - } - - $tmp= "[$tmp$fill]"; - - /* Only save if acl's are set */ - if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){ - if ($this->samba3){ - $attrname= "sambaAcctFlags"; - } else { - $attrname= "acctFlags"; - } - if ($this->$attrname != $tmp){ - $this->is_modified= TRUE; - } - $this->$attrname= $tmp; - } - - /* Save sambaDomain attribute */ - if ($this->acl_is_writeable("sambaDomainName",$SkipWrite) && $this->samba3 && isset ($_POST['sambaDomainName'],$SkipWrite)){ - $this->sambaDomainName= validate($_POST['sambaDomainName']); - } - - /* Save CTX values */ - if ($this->samba3){ - - /* Save obvious values */ - foreach($this->ctxattributes as $val){ - if (isset($_POST[$val]) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){ - if (get_magic_quotes_gpc()) { - $this->mungedObject->ctx[$val]= stripcslashes(validate($_POST[$val])); - } else { - $this->mungedObject->ctx[$val]= validate($_POST[$val]); - } - } - } - - /* Save checkbox states. */ - $this->mungedObject->setTsLogin(!isset($_POST['tslogin']) - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - // Need to do some index checking to avoid messages like "index ... not found" - if(isset($_POST['brokenconn'])) { - $this->mungedObject->setBrokenConn($_POST['brokenconn'] == '1' - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - } - if(isset($_POST['reconn'])) { - $this->mungedObject->setReConn($_POST['reconn'] == '1' - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - } - $this->mungedObject->setInheritMode(isset($_POST['inherit']) - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - $this->mungedObject->setCtxMaxConnectionTimeF(!isset($_POST['CtxMaxConnectionTimeF']) - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - $this->mungedObject->setCtxMaxDisconnectionTimeF( - !isset($_POST['CtxMaxDisconnectionTimeF']) - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - $this->mungedObject->setCtxMaxIdleTimeF(!isset($_POST['CtxMaxIdleTimeF']) - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - $this->mungedObject->setConnectClientDrives(isset($_POST['connectclientdrives']) - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - $this->mungedObject->setConnectClientPrinters(isset($_POST['connectclientprinters']) - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - $this->mungedObject->setDefaultPrinter(isset($_POST['defaultprinter']) - && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)); - - /* Save combo boxes. Takes two values */ - if(isset($_POST['reconn'])) { - $this->mungedObject->setShadow(isset($_POST['shadow']) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite),$_POST['shadow']); - } - - /* Check for changes */ - if ($this->sambaMungedDial != $this->mungedObject->getMunged()){ - $this->is_modified= TRUE; - } - } - } - } - - - /* Save to LDAP */ - function save() - { - /* Load uid and gid of this 'dn' */ - $ldap= $this->config->get_ldap_link(); - $ldap->cat($this->dn, array('uidNumber', 'gidNumber')); - $tmp= $ldap->fetch(); - $this->uidNumber= $tmp['uidNumber'][0]; - $this->gidNumber= $tmp['gidNumber'][0]; - - plugin::save(); - - /* Remove objectClass for sambaIdmapEntry */ - $tmp= array(); - for ($i= 0; $iattrs["objectClass"]); $i++){ - if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){ - $tmp[]= $this->attrs['objectClass'][$i]; - } - } - $this->attrs['objectClass']= $tmp; - - /* Generate rid / primaryGroupId */ - if ($this->samba3){ - if (!isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){ - print_red (_("Warning: This account has an undefined samba SID assigned. The problem can not be fixed by GOsa!")); - } else { - $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID']; - $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE']; - } - - /* Need to generate a new uniqe uid/gid combination? */ - if ($this->sambaSID == "" || $this->orig_sambaDomainName != $this->sambaDomainName){ - $uidNumber= $this->uidNumber; - while(TRUE){ - $sid= $this->SID."-".($uidNumber*2 + $this->ridBase); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(sambaSID=$sid)", array("sambaSID")); - if ($ldap->count() == 0){ - break; - } - $uidNumber++; - } - $this->attrs['sambaSID']= $sid; - - /* Check for users primary group */ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn")); - if ($ldap->count() != 1){ - print_red(_("Warning: Can't identify users primary group - no conversion to a samba group possible!")); - } else { - $attrs= $ldap->fetch(); - $g= new group($this->config, $ldap->getDN()); - if ($g->sambaSID == ""){ - $g->sambaDomainName= $this->sambaDomainName; - $g->smbgroup= TRUE; - $g->save (); - } - $this->attrs['sambaPrimaryGroupSID']= $g->sambaSID; - } - } - - if ($this->sambaHomeDrive == ""){ - $this->attrs["sambaHomeDrive"]= array(); - } - - /* Generate munged dial value */ - $this->attrs["sambaMungedDial"]= $this->mungedObject->getMunged(); - - /* User wants me to fake the idMappings? This is useful for - making winbind resolve the user names in a reasonable amount - of time in combination with larger databases. */ - if (isset($this->config->current['SAMBAIDMAPPING']) && - preg_match('/true/i', $this->config->current['SAMBAIDMAPPING'])){ - $this->attrs['objectClass'][]= "sambaIdmapEntry"; - } - - - /* Password expiery */ - if ($this->password_expires == "1"){ - $this->attrs['sambaPwdMustChange']= $this->sambaPwdMustChange; - } else { - $this->attrs['sambaPwdMustChange']= array(); - } - /* Make sure not to save zero in sambaPwdLastset */ - if ($this->sambaPwdLastSet != "0"){ - $this->attrs['sambaPwdLastSet']= $this->sambaPwdLastSet; - } else { - $this->attrs['sambaPwdLastSet']= array(); - } - /* Account expiery */ - if ($this->logon_time_set == "1"){ - $this->attrs['sambaLogonTime']= $this->sambaLogonTime; - } else { - $this->attrs['sambaLogonTime']= array(); - } - if ($this->logoff_time_set == "1"){ - $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime; - } else { - $this->attrs['sambaLogoffTime']= array(); - } - if ($this->kickoff_time_set == "1"){ - # Add one day in unixtime format to be compatible with usrmgr - //$this->attrs['sambaKickoffTime']= $this->sambaKickoffTime + 86400; - $this->attrs['sambaKickoffTime']= $this->sambaKickoffTime; //hickert - } else { - $this->attrs['sambaKickoffTime']= array(); - } - } else { - /* Not samba3 */ - $this->attrs['rid']= $this->uidNumber*2 + 1000; - $this->attrs['primaryGroupID']= $this->gidNumber*2 +1001; - - if ($this->homeDrive == ""){ - $this->attrs["homeDrive"]= array(); - } - - /* Password expiery */ - if ($this->password_expires == "1"){ - $this->attrs['pwdMustChange']= $this->pwdMustChange; - } else { - $this->attrs['pwdMustChange']= 2147483647; - } - /* Make sure not to save zero in pwdLastset */ - if ($this->pwdLastSet != "0"){ - $this->attrs['pwdLastSet']= $this->pwdLastSet; - } else { - $this->attrs['pwdLastSet']= array(); - } - /* Account expiery */ - if ($this->logon_time_set == "1"){ - $this->attrs['logonTime']= $this->logonTime; - } else { - $this->attrs['logonTime']= array(); - } - if ($this->logoff_time_set == "1"){ - $this->attrs['logoffTime']= $this->logoffTime; - } else { - $this->attrs['logoffTime']= array(); - } - if ($this->kickoff_time_set == "1"){ - # Add one day in unixtime format to be compatible with usrmgr - $this->attrs['kickoffTime']= $this->kickoffTime + 86400; - } else { - $this->attrs['kickoffTime']= array(); - } - } - - /* Write back to ldap */ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - 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()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/samba account with dn '%s' failed."),$this->dn)); - - /* 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", array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add", array("uid" => $this->uid)); - } - } - - - /* Force password set, if this account doesn't have any samba passwords */ - function password_change_needed() - { - if(!$this->initially_was_account && $this->is_account){ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("sambaLMPassword","sambaNTPassword")); - $attrs = $ldap->fetch(); - if(!isset($attrs['sambaLMPassword']) || !isset($attrs['sambaNTPassword'])){ - return(TRUE); - } - } - return(FALSE); - } - - - function adapt_from_template($dn) - { - plugin::adapt_from_template($dn); - $this->sambaSID= ""; - $this->sambaPrimaryGroupSID= ""; - - /* Fill mungedDial field */ - if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){ - $this->mungedObject->load($this->sambaMungedDial); - } - - /* Password expiery */ - if(isset($this->attrs['sambaPwdMustChange']) && - $this->attrs['sambaPwdMustChange'][0] != 0){ - $this->password_expires= 1; - } - - if(isset($this->attrs['sambaLogonTime']) && ! ( - $this->attrs['sambaLogonTime'][0] == 0 || - $this->attrs['sambaLogonTime'][0] == 2147483647 - )){ - $this->logon_time_set= 1; - } - if(isset($this->attrs['sambaLogoffTime']) && ! ( - $this->attrs['sambaLogoffTime'][0] == 0 || - $this->attrs['sambaLogoffTime'][0] == 2147483647 - )){ - $this->logoff_time_set= 1; - } - - /* Account expiery */ - if(isset($this->attrs['sambaKickoffTime']) && ! ( - $this->attrs['sambaKickoffTime'][0] == 0 || - $this->attrs['sambaKickoffTime'][0] == 2147483647 - )){ - $this->kickoff_time_set= 1; - } - - /* Get global filter config */ - if (!is_global("sambafilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); - $sambafilter= array( "depselect" => $base, "regex" => "*"); - register_global("sambafilter", $sambafilter); - } - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Samba"), - "plDescription" => _("Samba settings"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 5, - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "AllowLoginOnTerminalServer" => _("Allow login on terminal server"), - "InheritClientConfig" => _("Inherit client config"), - - "sambaPwdCanChange" => _("Allow user to change password") , - "sambaAcctFlagsN" => _("Login from windows client requires no password"), - "sambaAcctFlagsL" => _("Lock samba account"), - - - "sambaKickoffTime" => _("Account expires") , - "sambaPwdMustChange" => _("Password expires") , - - "sambaLogonTime" => _("Limit Logon Time") , - "sambaLogoffTime" => _("Limit Logoff Time") , - "sambaLogonHours" => _("Logon hours") , - - "sambaHomePath" => _("Generic home directory") , - "sambaHomeDrive" => _("Generic samba home drive") , - "sambaLogonScript" => _("Generic script path") , - "sambaProfilePath" => _("Generic profile path") , - "sambaDomainName" => _("Domain") , - "sambaUserWorkstations" => _("Allow connection from"))) - ); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/samba/class_sambaLogonHours.inc b/plugins/personal/samba/class_sambaLogonHours.inc deleted file mode 100644 index 95de60d0a..000000000 --- a/plugins/personal/samba/class_sambaLogonHours.inc +++ /dev/null @@ -1,148 +0,0 @@ -sambaLogonHours = $slh; - - /* Get default timezone */ - $zone = get_default_timezone(); - $this->timezone = $zone['value']; - - /* Convert to bin */ - $tmp = ''; - for($i = 0 ; $i < strlen($slh) ; $i ++){ - $tmp .= str_pad(base_convert($slh[$i],16,2),4,'0',STR_PAD_LEFT); - } - $slh = $tmp; - - /* Set to default if value is empty or seams to be broken */ - if(strlen($slh) != 168){ - $slh = str_pad('',168 , "1"); - } - - /* Rework string, because it was stored in little endian */ - $new = ''; - for($i = 0 ; $i < 21 ; $i ++ ){ - $part = strrev(substr($slh, $i * 8, 8)); - $byte['hi'] = substr($part,0,4); - $byte['low'] = substr($part,4,4); - $new .= $byte['hi'].$byte['low']; - } - - /* Shift string to match given timezone settings */ - $shift_by = (168 + $this->timezone) % 168; - for($i = 0 ; $i < $shift_by; $i ++){ - $new = $new[167].$new; - $new = substr($new,0,168); - } - - /* Create matrix */ - $this->Matrix = array(); - for($day = 0 ; $day < 7 ; $day ++ ){ - for($hour = 0 ; $hour < 24 ; $hour ++){ - $bitpos = ($day * 24 + $hour) % 168; - $this->Matrix[$day][$hour] = $new[$bitpos]; - } - } - } - - function execute() - { - - $week_days = array(); - $week_days[0]= _("Sunday"); - $week_days[1]= _("Monday"); - $week_days[2]= _("Tuesday"); - $week_days[3]= _("Wednesday"); - $week_days[4]= _("Thursday"); - $week_days[5]= _("Friday"); - $week_days[6]= _("Saturday"); - - $hours = array(); - for($i = 0 ; $i <24 ; $i++ ){ - $hours[$i] = $i ; - } - $ui =get_userinfo(); - - $smarty = get_smarty(); - $smarty->assign("sambaLogonHoursACL",$ui->get_permissions($this->acl_base,"user/generic","sambaLogonHours")); - $smarty->assign("Matrix",$this->Matrix); - $smarty->assign("Days" ,$week_days); - $smarty->assign("Hours" ,$hours); - return($smarty->fetch(get_template_path("sambaLogonHours.tpl",TRUE,dirname(__FILE__)))); - } - - function save_object() - { - /* Get userinfo */ - $ui = get_userinfo(); - - /* Check if dialog was opened and if there were any changes */ - if(isset($_POST['sambaLogonHoursPosted']) && preg_match("/w/i",$ui->get_permissions($this->acl_base,"user/generic","sambaLogonHours"))){ - foreach($this->Matrix as $day_key => $days){ - foreach($days as $hour_key => $hour){ - if(isset($_POST['day_'.$day_key.'_'.$hour_key])){ - $this->Matrix[$day_key][$hour_key] = 1; - }else{ - $this->Matrix[$day_key][$hour_key] = 0; - } - } - } - } - } - - function save() - { - - /* Convert Matrix to Hex */ - $slh = ""; - foreach($this->Matrix as $day_key => $days){ - foreach($days as $hour_key => $hour){ - $slh .= $hour; - } - } - - /* Shift string to match given timezone settings */ - $shift_by = (168 + ($this->timezone*(-1))) % 168; - for($i = 0 ; $i < $shift_by; $i ++){ - $slh = $slh[167].$slh; - $slh = substr($slh,0,168); - } - - /* Rework string, because it was stored in little endian */ - $new = ''; - for($i = 0 ; $i < 21 ; $i ++ ){ - $part = strrev(substr($slh, $i * 8, 8)); - $byte['hi'] = substr($part,0,4); - $byte['low'] = substr($part,4,4); - $new .= $byte['hi'].$byte['low']; - } - - /* Convert to bin */ - $tmp = ''; - for($i = 0 ; $i < 21 ; $i ++){ - $tmp .= str_pad(base_convert(substr($new,$i*8,8),2,16),2,'0',STR_PAD_LEFT); - } - - /* Create uppercase HEX chars */ - $ret = strtoupper( $tmp); - - /* All hours and days selected */ - if(substr_count($ret,'F') == 42){ - $ret = ""; - } - - return($ret); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/samba/main.inc b/plugins/personal/samba/main.inc deleted file mode 100644 index 0c198dc3e..000000000 --- a/plugins/personal/samba/main.inc +++ /dev/null @@ -1,130 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('sambaAccount'); - } - - /* Create sambaAccount object on demand */ - if (!isset($_SESSION['sambaAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['sambaAccount']= new sambaAccount ($config, $ui->dn); - $_SESSION['sambaAccount']->enable_CSN_check(); - $_SESSION['sambaAccount']->set_acl_base($ui->dn); - $_SESSION['sambaAccount']->set_acl_category("users"); - } - $sambaAccount= $_SESSION['sambaAccount']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $sambaAccount->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $sambaAccount->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $sambaAccount->save (); - del_lock ($ui->dn); - sess_del ('edit'); - - /* Remove from session */ - sess_del ('sambaAccount'); - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - if($lock_msg){ - $display.= $lock_msg; - }else{ - $display.= $sambaAccount->execute (); - } - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['sambaAccount']= $sambaAccount; - } - - $info= ""; - if (($sambaAccount->is_account) && (!$sambaAccount->show_ws_dialog) && empty($lock_msg)){ - $display.= "

"; - - /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/sambaAccount"))){ - - $info.= "\"\" ". - _("Click the 'Edit' button below to change informations in this dialog"); - $display.= "\n"; - } - $display.= "\n"; - } - $display.= "

\n"; - } - - /* Page header*/ - $display= print_header(get_template_path('images/samba.png'), _("Samba settings"), - $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/samba/samba2.tpl b/plugins/personal/samba/samba2.tpl deleted file mode 100644 index 11b28d8e2..000000000 --- a/plugins/personal/samba/samba2.tpl +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - -
-

 {t}Generic{/t}

-
- - - - - -
- -{render acl=$smbHomeACL} - -{/render} - -{render acl=$smbDriveACL} - -{/render} - -
-
-   - - - - - - - - - - -
-{render acl=$scriptPathACL} - -{/render} -
-{render acl=$profilePathACL} - -{/render} -
-
- -

 

- -

 {t}Access options{/t}

- - - - - - - -
-{render acl=$allow_pwchangeACL} - -{/render} - -
-{render acl=$no_password_requiredACL} - -{/render} - -
-{render acl=$temporary_disableACL} - -{/render} - -
-
-   - -{render acl=$password_expiresACL} - -{/render} - -{render acl=$sambaPwdMustChangeACL} - -{/render} -{render acl=$sambaPwdMustChangeACL} - -{/render} -{render acl=$sambaPwdMustChangeACL} - -{/render} - -
- - - - - diff --git a/plugins/personal/samba/samba3.tpl b/plugins/personal/samba/samba3.tpl deleted file mode 100644 index 251cf5354..000000000 --- a/plugins/personal/samba/samba3.tpl +++ /dev/null @@ -1,434 +0,0 @@ - - - - - - - - - - - -
-

 {t}Generic{/t}

-
- - - - - - - - - -
-{render acl=$sambaHomePathACL} - -{/render} -{render acl=$sambaHomeDriveACL} - -{/render} -
-{render acl=$sambaDomainNameACL} - -{/render} -
-
-   - - - - - - - - - - -
-{render acl=$sambaLogonScriptACL} - -{/render} -
-{render acl=$sambaProfilePathACL} - -{/render} -
-
- -

 

- -

 {t}Terminal Server{/t}

- - - - - - - -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} - {t}Allow login on terminal server{/t} - - - - - - - - - -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-
-   - -{render acl=$AllowLoginOnTerminalServerACL} - -{/render} - {t}Inherit client config{/t} - - - - - - - - - -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-
- -

 

- - - - - - - - - -
- {t}Timeout settings (in minutes){/t} - - - - - - - - - - - - - -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} - - - -{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} - - -{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} - - -{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-
-   - - - {t}Client devices{/t} - - - - - - - - - - -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} - -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} - -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} - -
- -
-   - - {t}Miscellaneous{/t} - - - - - - - - - - - - - -
- - -{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
-{render acl=$AllowLoginOnTerminalServerACL} - -{/render} -
- -
- -

 

- -

 {t}Access options{/t}

- - - - - - - -
-{render acl=$sambaPwdCanChangeACL} - -{/render} - -
-{render acl=$sambaAcctFlagsNACL} - -{/render} - -
-{render acl=$sambaAcctFlagsLACL} - -{/render} - -
-{render acl=$sambaPwdMustChangeACL} - -{/render} - -{render acl=$sambaPwdMustChangeACL} - -{/render} -{render acl=$sambaPwdMustChangeACL} - -{/render} -{render acl=$sambaPwdMustChangeACL} - -{/render} -
-{render acl=$sambaLogonTimeACL} - -{/render} - -{render acl=$sambaLogonTimeACL} - -{/render} -{render acl=$sambaLogonTimeACL} - -{/render} -{render acl=$sambaLogonTimeACL} - -{/render} -
-{render acl=$sambaLogoffTimeACL} - -{/render} - -{render acl=$sambaLogoffTimeACL} - -{/render} -{render acl=$sambaLogoffTimeACL} - -{/render} -{render acl=$sambaLogoffTimeACL} - -{/render} -
- -{render acl=$sambaKickoffTimeACL} - -{/render} - -{render acl=$sambaKickoffTimeACL} - -{/render} -{render acl=$sambaKickoffTimeACL} - -{/render} -{render acl=$sambaKickoffTimeACL} - -{/render} -
- - - - -
-{render acl=$sambaLogonHoursACL mode=read_active} - {t}Samba logon times{/t}  -{/render} - -
-   - - -
-{render acl=$sambaUserWorkstationsACL} - -{/render} -
-{render acl=$sambaUserWorkstationsACL} - -{/render} -{render acl=$sambaUserWorkstationsACL} - -{/render} -
- - - - - diff --git a/plugins/personal/samba/samba3_workstations.tpl b/plugins/personal/samba/samba3_workstations.tpl deleted file mode 100644 index f2ecfcc0b..000000000 --- a/plugins/personal/samba/samba3_workstations.tpl +++ /dev/null @@ -1,42 +0,0 @@ - - - - - -
-
-

- {$hint}
-

-
-
-

- -

-
-
-
-

[F] - {t}Filters{/t}

-
-
- - {$alphabet} -
-
{t}Display workstations of department{/t}  -
- -
 
- {$apply} -
-
- -

- -   - -

diff --git a/plugins/personal/samba/sambaLogonHours.tpl b/plugins/personal/samba/sambaLogonHours.tpl deleted file mode 100644 index 1eb730608..000000000 --- a/plugins/personal/samba/sambaLogonHours.tpl +++ /dev/null @@ -1,111 +0,0 @@ - - - - -

{t}Specify the hours this user is allowed to log in{/t}

-
- - - - - - - - - {foreach from=$Hours item=hours key=key_hours} - {if (($hours)%2) == 0 } - - {/foreach} - - - - - - {foreach from=$Hours item=hours key=key_hours} - {if (($hours)%2) == 0 } - - {/foreach} - - - - -{foreach from=$Matrix item=days key=key_day} - - - {foreach from=$days item=hours key=key_hour} - {if (($key_hour)%2) == 0 } - - {/foreach} - - - - -{/foreach} -
 {t}Hour{/t}
  - {else} - - {/if} - {$hours} -
-   - - {else} - - {/if} - -{render acl=$sambaLogonHoursACL} - -{/render} - - -{render acl=$sambaLogonHoursACL} - -{/render} -
- {$Days[$key_day]} - - {else} - - {/if} - {if $Matrix[$key_day].$key_hour} -{render acl=$sambaLogonHoursACL} - -{/render} - {else} -{render acl=$sambaLogonHoursACL} - -{/render} - {/if} - -{render acl=$sambaLogonHoursACL} - -{/render} -
-
- -
-

- -   - -

- - diff --git a/plugins/personal/scalix/class_scalixAccount.inc b/plugins/personal/scalix/class_scalixAccount.inc deleted file mode 100644 index 2d85f0d88..000000000 --- a/plugins/personal/scalix/class_scalixAccount.inc +++ /dev/null @@ -1,509 +0,0 @@ -, - based on work by Cajus Pollmeier - \version 0.01 - \date 20.10.2006 - - This class provides the functionality to read and write all attributes - relevant for scalixAccounts from/to the LDAP. It does syntax checking - and displays the formulars required. - */ - -class scalixAccount extends plugin -{ - /* Definitions */ - var $plHeadline = "Scalix"; - var $plDescription= "This does something"; - - /* plugin specific values - scalixUserClass */ - /* MUST */ - var $scalixScalixObject= TRUE; //TRUE or FALSE - var $scalixMailnode= ""; - /* INDIRECT MUST, scalix will complain if no email was specified */ - - /* MAY */ - var $scalixAdministrator= FALSE; - var $scalixMailboxAdministrator = FALSE; - var $scalixServerLanguage= ""; - var $scalixEmailAddress= array(); - var $scalixLimitMailboxSize= ""; - var $scalixLimitOutboundMail= FALSE; - var $scalixLimitInboundMail= FALSE; - var $scalixLimitNotifyUser= FALSE; - var $scalixHideUserEntry= FALSE; - var $scalixMailboxClass= ""; - - var $uid =""; - var $default_permissions= "none"; - var $member_permissions= "post"; - var $members= array(); - var $admins= array(); - var $vacations= array(); - var $perms= array( "lrs" => "read", - "lrsp" => "post", - "lrsip" => "append", - "lrswipcd" => "write", - "lrswipcda" => "all" ); - - /* attribute list for save action */ - var $attributes = array("scalixMailnode", "scalixServerLanguage", "scalixLimitMailboxSize", "scalixMailboxClass"); - var $fakeBooleanAttributes= array("scalixAdministrator", "scalixMailboxAdministrator", "scalixLimitOutboundMail", - "scalixLimitInboundMail", "scalixLimitNotifyUser", "scalixHideUserEntry"); - var $objectclasses = array("scalixUserClass"); - - - /* constructor, if 'dn' is set, the node loads the given - 'dn' from LDAP */ - function scalixAccount (&$config, $dn= NULL) - { - /* dn shouldn't be NULL */ - if($dn === NULL){ - trigger_error("Initialising scalixAccount without valid dn."); - } - - /* Load bases attributes */ - plugin::plugin($config, $dn); - - /* Load attributes */ - if ($dn != "new"){ - - /* Set user id */ - if(isset($this->attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - foreach ($this->fakeBooleanAttributes as $val){ - if (isset($this->attrs["$val"][0])&&$this->attrs["$val"][0]=="TRUE"){ - $this->$val = TRUE; - } else { - $this->$val = FALSE; - } - } - - /* Load attributes containing arrays */ - foreach (array("scalixEmailAddress") as $val){ - if (isset($this->attrs["$val"]["count"])){ - for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){ - array_push($this->$val, $this->attrs["$val"][$i]); - } - } - } - } - - /* Save initial account state */ - $this->initially_was_account= $this->is_account; - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Load templating engine */ - $smarty= get_smarty(); - $display= ""; - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; - } - - /* Show main page */ - $mailboxClasses = array("", "LIMITED", "FULL"); - $serverLanguages= array("", "GERMAN", "ENGLISH"); - - /* Do we represent a valid account? */ - if (!$this->is_account && $this->parent === NULL){ - $display= "\"\" ". - _("This account has no scalix extensions.").""; - - $display.= back_to_main(); - return ($display); - } - - /* Show tab dialog headers */ - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove scalix account"), - _("This account has scalix synchronization enabled. You can disable it by clicking below.")); - } else { - $display= $this->show_enable_header(_("Create scalix account"), _("This account has scalix synchronization disabled. You can enable it by clicking below.")); - return ($display); - } - } - - /* Trigger forward add dialog? */ - if (isset($_POST['add_local_forwarder'])){ - $this->forward_dialog= TRUE; - $this->dialog= TRUE; - } - - /* Cancel forward add dialog? */ - if (isset($_POST['add_locals_cancel'])){ - $this->forward_dialog= FALSE; - $this->dialog= FALSE; - } - - - $smarty->assign("mailboxClasses", $mailboxClasses); - $smarty->assign("serverLanguages", $serverLanguages); - foreach(array("perms", "scalixScalixObject", "scalixMailnode", "scalixAdministrator", "scalixMailboxAdministrator", - "scalixServerLanguage", "scalixLimitMailboxSize", "scalixLimitOutboundMail", "scalixEmailAddress", - "scalixLimitInboundMail", "scalixLimitNotifyUser", "scalixHideUserEntry", "scalixMailboxClass") as $val){ - - $smarty->assign("$val", $this->$val); - $smarty->assign("$val"."ACL", $this->getacl($val)); - } - - /* Fill checkboxes */ - if ($this->scalixAdministrator) { - $smarty->assign("scalixAdministrator", "checked"); - } else { - $smarty->assign("scalixAdministrator", ""); - } - if ($this->scalixMailboxAdministrator) { - $smarty->assign("scalixMailboxAdministrator", "checked"); - } else { - $smarty->assign("scalixMailboxAdministrator", ""); - } - if ($this->scalixLimitOutboundMail) { - $smarty->assign("scalixLimitOutboundMail", "checked"); - } else { - $smarty->assign("scalixLimitOutboundMail", ""); - } - if ($this->scalixLimitInboundMail) { - $smarty->assign("scalixLimitInboundMail", "checked"); - } else { - $smarty->assign("scalixLimitInboundMail", ""); - } - if ($this->scalixLimitNotifyUser) { - $smarty->assign("scalixLimitNotifyUser", "checked"); - } else { - $smarty->assign("scalixLimitNotifyUser", ""); - } - if ($this->scalixHideUserEntry) { - $smarty->assign("scalixHideUserEntry", "checked"); - } else { - $smarty->assign("scalixHideUserEntry", ""); - } - - $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - - /* remove object from parent */ - function remove_from_parent() - { - /* Cancel if there's nothing to do here */ - if (!$this->initially_was_account){ - return; - } - - /* include global link_info */ - $ldap= $this->config->get_ldap_link(); - - /* Remove and write to LDAP */ - plugin::remove_from_parent(); - - /* Zero arrays */ - $this->attrs['scalixEmailAddress']= array(); - - /* Unset fake boolean attributes from entry */ - foreach ($this->fakeBooleanAttributes as $val){ - $this->attrs["$val"]= array(); - } - - /*unset scalixScalixObject*/ - $this->attrs['scalixScalixObject']=array(); - - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save"); - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - show_ldap_error($ldap->get_error()); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove"); - } - - - /* Save data to object */ - function save_object() - { - if (isset($_POST['scalixTab'])){ - - /* Save ldap attributes */ - plugin::save_object(); - - /* Save fakeBooleanAttributes*/ - foreach ($this->fakeBooleanAttributes as $val){ - if ($this->acl_is_writeable($val)) { - if( isset ($_POST["$val"])) { - $data = TRUE; - } else { - $data = FALSE; - } - if ($this->$val != $data){ - $this->is_modified= TRUE; - } - - $this->$val= $data; - } - } - } - } - - - /* Save data to LDAP, depending on is_account we save or delete */ - function save() - { - $ldap= $this->config->get_ldap_link(); - - /* Call parents save to prepare $this->attrs */ - plugin::save(); - - /* Save arrays */ - $this->attrs['scalixEmailAddress']= $this->scalixEmailAddress; - - /* Save boolean vars ... the scalix schema expects them as strings */ - $this->attrs['scalixScalixObject'] = $this->scalixScalixObject?"TRUE":"FALSE"; - $this->attrs['scalixAdministrator'] = $this->scalixAdministrator?"TRUE":"FALSE"; - $this->attrs['scalixMailboxAdministrator'] = $this->scalixMailboxAdministrator?"TRUE":"FALSE"; - $this->attrs['scalixLimitOutboundMail'] = $this->scalixLimitOutboundMail?"TRUE":"FALSE"; - $this->attrs['scalixLimitInboundMail'] = $this->scalixLimitInboundMail?"TRUE":"FALSE"; - $this->attrs['scalixLimitNotifyUser'] = $this->scalixLimitNotifyUser?"TRUE":"FALSE"; - $this->attrs['scalixHideUserEntry'] = $this->scalixHideUserEntry?"TRUE":"FALSE"; - - /* Remove Mailquota if = "" */ - if((isset($this->attrs['scalixLimitMailboxSize']))&&($this->attrs['scalixLimitMailboxSize']=="")) { - $this->attrs['scalixLimitMailboxSize']=array(); - } - - /* Save data to LDAP */ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - show_ldap_error($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"); - } - } else { - $this->handle_post_events("add"); - } - - } - - /* Check formular input */ - function check() - { - $ldap= $this->config->get_ldap_link(); - - $message= array(); - - if(empty($this->scalixMailnode)){ - $message[]= _("There is no scalix mailnode specified."); - } - if(empty($this->scalixScalixObject)){ - $message[]= _("scalixScalixObject must be set!"); - } - - $ldap->cd($this->config->current['BASE']); - foreach($this->scalixEmailAddress as $k => $mail) { - $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=scalixUserClass)(scalixEmailAddress=". - $mail.")(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid")); - - if ($ldap->count() != 0){ - $message[]= _("The email address '$mail' you've entered is already in use."); - } - } - - /* Check quota */ - if ($this->scalixLimitMailboxSize != '' && $this->acl_is_writeable("scalixLimitMailboxSize")){ - if (!is_numeric($this->scalixLimitMailboxSize)) { - $message[]= _("Value in 'Limit Mailbox size' is not valid."); - } else { - $this->scalixLimitMailboxSize= (int) $this->scalixLimitMailboxSize; - } - } - - return ($message); - } - - /* Adapt from template, using 'dn' */ - function adapt_from_template($dn) - { - plugin::adapt_from_template($dn); - - foreach (array("scalixEmailAddress") as $val){ - $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); - } - } - array_push($this->$val, strtolower(rewrite($value))); - } - } - } - $this->mail= strtolower(rewrite($this->mail)); - } - - function addEmail($address) - { - $ldap= $this->config->get_ldap_link(); - - $address= strtolower($address); - - /* Is this address already assigned in LDAP? */ - $ldap->cd ($this->config->current['BASE']); - $ldap->search ("(&(objectClass=scalixUserClass)(|(scalixEmailAddress=$address)". - "(scalixEmailAddress=$address)))", array("uid")); - - if ($ldap->count() > 0){ - $attrs= $ldap->fetch (); - return ($attrs["uid"][0]); - } - - /* Add to list of alternates */ - if (!in_array($address, $this->scalixEmailAddress)){ - $this->scalixEmailAddress[]= $address; - $this->is_modified= TRUE; - } - - //sort ($this->scalixEmailAddress); //scalix makes the first email the destination, all others can receive - reset ($this->scalixEmailAddress); - - return (""); - } - - - function delEmail($addresses) - { - $this->scalixEmailAddress= array_remove_entries ($addresses, $this->scalixEmailAddress); - $this->is_modified= TRUE; - } - - - static function plInfo() - { - return (array( - "plDescription" => _("Scalix account"), - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 2, - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - - "scalixMailnode" => _("Scalix Mail node"), - "scalixMailboxClass" => _("Mailbox class"), - "scalixServerLanguage" => _("Server language"), - "scalixAdministrator" => _("Administrator"), - "scalixMailboxAdministrator"=> _("Mailbox administrator"), - "scalixHideUserEntry" => _("Hide user entry in Scalix"), - "scalixLimitMailboxSize" => _("Mailbox size limitations"), - "scalixLimitOutboundMail" => _("Limit outbound"), - "scalixLimitInboundMail" => _("Limit inbound"), - "scalixLimitNotifyUser" => _("Notify user"), - "scalixEmailAddress" => _("Scalix email addresses")) - - )); - } - - - function saveCopyDialog() - { - if (isset($_POST['scalixTab'])){ - - /* Add email addresses */ - if (isset($_POST['add_email'])){ - - /* Check write access */ -# if(!$this->acl_is_writeable("scalixEmailAddress")){ -# print_red(_("You are not allowed to modify alternate addresses")); -# }else{ - - /* Check if given value is not empty */ - if ($_POST['email_address'] != ""){ - $valid= FALSE; - - /* Valid mail address */ - if( ($this->is_template && !is_email($_POST['email_address'], TRUE)) || - (!$this->is_template && !is_email($_POST['email_address'])) ){ - print_red (_("You're trying to add an invalid email address to the list of alternate addresses.")); - }else{ - $valid = TRUE; - } - - /* Mail address already in use ? */ - if ($valid && ($user= $this->addEmail ($_POST['email_address'])) != ""){ - $ui= get_userinfo(); - if ($user != $ui->username){ - print_red (_("The address you're trying to add is already used by user")." '$user'."); - } - } -# } - } - } - - /* Delete email addresses */ - if (isset($_POST['delete_email']) && isset ($_POST['emails_list'])){ -# if(!$this->acl_is_writeable("scalixEmailAddress")){ -# print_red(_("You are not allowed to modify alternate addresses")); -# }else{ - if (count($_POST['emails_list'])){ - $this->delEmail ($_POST['emails_list']); -# } - } - } - } - } - - - function PrepareForCopyPaste($source) - { - plugin::PrepareForCopyPaste($source); - foreach ($this->fakeBooleanAttributes as $val){ - if (isset($source["$val"][0])&&$source["$val"][0]=="TRUE"){ - $this->$val = TRUE; - } else { - $this->$val = FALSE; - } - } - - /* Load attributes containing arrays */ - foreach (array("scalixEmailAddress") as $val){ - if (isset($source["$val"]["count"])){ - for ($i= 0; $i<$source["$val"]["count"]; $i++){ - array_push($this->$val, $source["$val"][$i]); - } - } - } - } - - - /* Create the posix dialog part for copy & paste */ - function getCopyDialog() - { - $smarty = get_smarty(); - $smarty->assign("scalixEmailAddress",$this->scalixEmailAddress); - $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); - $ret = array(); - $ret['string'] = $str; - $ret['status'] = ""; - return($ret); - - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:rulere -?> diff --git a/plugins/personal/scalix/generic.tpl b/plugins/personal/scalix/generic.tpl deleted file mode 100644 index 669d2ea17..000000000 --- a/plugins/personal/scalix/generic.tpl +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - - - - - -
{$must} -{render acl=$scalixMailnodeACL} - -{/render} -
-{render acl=$scalixMailboxClassACL} - -{/render} -
-{render acl=$scalixServerLanguageACL} - -{/render} -
- -

 

- - - -
-{render acl=$scalixAdministratorACL} - {t}Scalix Administrator{/t} -{/render} -
-{render acl=$scalixMailboxAdministratorACL} - {t}Scalix Mailbox Administrator{/t} -{/render} -
-{render acl=$scalixHideUserEntryACL} - {t}Hide this user entry in Scalix{/t} -{/render} -
-
- -

 

- - - - - - - - - -
-{render acl=$scalixLimitMailboxSizeACL} -  {t}MB{/t} -{/render} -
-{render acl=$scalixLimitOutboundMailACL} - {t}Limit Outbound Mail{/t} -{/render} -
-{render acl=$scalixLimitInboundMailACL} - {t}Limit Inbound Mail{/t} -{/render} -
-{render acl=$scalixLimitNotifyUserACL} - {t}Notify User{/t} -{/render} -
-
-
-   - -

-{render acl=$scalixEmailAddressACL} - -{/render} -
-{render acl=$scalixEmailAddressACL} - -{/render} -{render acl=$scalixEmailAddressACL} -   -{/render} -{render acl=$scalixEmailAddressACL} - -{/render} -
- - - - - diff --git a/plugins/personal/scalix/main.inc b/plugins/personal/scalix/main.inc deleted file mode 100644 index 0d2558a8a..000000000 --- a/plugins/personal/scalix/main.inc +++ /dev/null @@ -1,129 +0,0 @@ -dn); - sess_del ('edit'); - sess_del ('scalixAccount'); - } - - /* Create mail object on demand */ - if (!isset($_SESSION['scalixAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['scalixAccount']= new scalixAccount ($config, $ui->dn); - $_SESSION['scalixAccount']->enable_CSN_check(); - $_SESSION['scalixAccount']->set_acl_base($ui->dn); - $_SESSION['scalixAccount']->set_acl_category("users"); - } - $scalixAccount= $_SESSION['scalixAccount']; - - /* save changes back to object */ - if (isset ($_SESSION['edit'])){ - $scalixAccount->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - $_SESSION['back_plugin']= $plug; - $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/"); - $lock_msg = gen_locked_message ($username, $ui->dn); - - }else{ - - /* Lock the current entry */ - add_lock ($ui->dn, $ui->dn); - $_SESSION['dn']= $ui->dn; - $_SESSION['edit']= TRUE; - } - } - - /* save changes to LDAP and disable edit mode */ - if (isset($_POST['edit_finish'])){ - - /* Perform checks */ - $message= $scalixAccount->check (); - - /* No errors, save object */ - if (count ($message) == 0){ - $scalixAccount->save (); - gosa_log ("User/scalix object'".$ui->dn."' has been saved"); - $scalixAccount->acl= "#none#"; - del_lock ($ui->dn); - sess_del ('edit'); - - /* Remove object */ - sess_del ('scalixAccount'); - } else { - /* Errors found, show message */ - show_errors ($message); - } - } - - /* Execute formular */ - $display= $scalixAccount->execute (); - - /* Store changes in session */ - if (isset ($_SESSION['edit'])){ - $_SESSION['scalixAccount']= $scalixAccount; - } - - /* Show page footer depending on the mode */ - if ($scalixAccount->is_account){ - - $display.= "

"; - - /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/scalix"))){ - $info.= "\"\" ". - _("Click the 'Edit' button below to change informations in this dialog"); - - $display.= "\n"; - } - $display.= "\n"; - } - $display.= "

\n"; - } - - - $info= ""; - - /* Page header*/ - $display= print_header(get_template_path('images/scalix.png'), _("Scalix settings"), $info).$display; - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/personal/scalix/paste_generic.tpl b/plugins/personal/scalix/paste_generic.tpl deleted file mode 100644 index 4bdf489aa..000000000 --- a/plugins/personal/scalix/paste_generic.tpl +++ /dev/null @@ -1,25 +0,0 @@ - - - - -
-

- -
- -   - -
- - - - - diff --git a/setup/class_setup.inc b/setup/class_setup.inc deleted file mode 100644 index 753751c52..000000000 --- a/setup/class_setup.inc +++ /dev/null @@ -1,306 +0,0 @@ -o_steps[$i++] = new Step_Welcome(); - $this->o_steps[$i++] = new Step_Language(); - $this->o_steps[$i++] = new Step_Checks(); - $this->o_steps[$i++] = new Step_License(); - $this->o_steps[$i++] = new Step_Ldap(); - $this->o_steps[$i++] = new Step_Schema(); - $this->o_steps[$i++] = new Step_Config1(); - $this->o_steps[$i++] = new Step_Config2(); - $this->o_steps[$i++] = new Step_Config3(); - $this->o_steps[$i++] = new Step_Migrate(); - $this->o_steps[$i++] = new Step_Feedback(); - $this->o_steps[$i++] = new Step_Finish(); - $this->i_steps = $i-1; - - /* Ensure that setup is not reachable if gosa.conf (CONFIG_FILE) */ - if(file_exists(CONFIG_DIR."/".CONFIG_FILE)){ - session_destroy(); - header("Location: index.php") ; - exit(); - } - - foreach($this->o_steps as $key => $step){ - $this->o_steps[$key]->parent = &$this; - } - } - - function execute() - { - /* Display phpinfo() dialog when $_GET['info'] is set, - * but only do this, if user is allowed to use the setup. - * If setupStep_Welcome is_completed, we are allowed to view those infos- - */ - if(isset($_GET['info']) && preg_match("/Step_Welcome/i",get_class($this->o_steps[1])) && $this->o_steps[1]->is_completed()){ - phpinfo(); - exit(); - } - - /* display step error msgs */ - $msgs = $this->o_steps[$this->i_current]->check(); - foreach($msgs as $msg){ - print_red($msg); - } - - $this->o_steps[$this->i_last]->set_active(FALSE); - $this->o_steps[$this->i_current]->set_active(); - $content = $this->o_steps[$this->i_current]->execute(); - return($content); - } - - - /* Save posted attributes */ - function save_object() - { - /* Call save_object for current setup step */ - $this->o_steps[$this->i_current] -> save_object(); - - /* Get attributes from setup step */ - $tmp = $this->o_steps[$this->i_current]->get_attributes(); - foreach($tmp as $name => $value){ - $this->captured_values[$name] = $value; - } - - /* Set parent */ - foreach($this->o_steps as $key => $value){ - $this->o_steps[$key]->parent = $this; - } - - /* Check if image button requests next page */ - foreach($_POST as $name => $value){ - if(preg_match("/^next_(x|y)/",$name)){ - $_POST['next'] = TRUE; - } - if(preg_match("/^last_(x|y)/",$name)){ - $_POST['last'] = TRUE; - } - } - - /* Check if step was selected */ - if(isset($_GET['step']) || isset($_POST['next']) || isset($_POST['last'])){ - - /* check if current setup step is completed now - and activate the next step if possible */ - for($i = 1 ; $i <= $this->i_steps ; $i ++ ){ - if($this->o_steps[$i]->is_completed()){ - if(isset($this->o_steps[($i+1)])){ - $this->o_steps[($i+1)]->set_enabled(); - } - }else{ - $this->disable_steps_from($i+1); - } - } - } - - /* Disable all following steps, if one step isn't compelted right now .*/ - for($i = 1 ; $i <= $this->i_steps ; $i ++ ){ - if($this->o_steps[$i]->is_completed()){ - }else{ - $this->disable_steps_from($i+1); - } - } - - $step = -1; - - if(isset($_POST['setup_goto_step'])){ - $step= $_POST['setup_goto_step']; - } - - if(isset($_GET['step'])){ - $step = $_GET['step']; - }elseif(isset($_POST['next'])){ - $step = $this->i_current + 1; - }elseif(isset($_POST['last'])){ - $step = $this->i_current - 1; - } - - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^step_[0-9]*$/",$name) && $once ){ - $step = preg_replace("/^step_/","",$name); - } - } - - if($this->selectable_step($step)){ - $this->i_last = $this->i_current; - $this->i_current = $step; - } - } - - - function disable_steps_from($start) - { - $found = false; - foreach($this->o_steps as $key => $step){ - if($key == $start){ - $found = true; - } - - if($found){ - $this->o_steps[$key]->set_enabled(false); - $this->o_steps[$key]->set_completed(false); - } - } - } - - - /* Create navigation menu */ - function get_navigation_html() - { - $str = ""; - foreach($this->o_steps as $key => $step){ - - $step -> update_strings(); - - $s_title = $step -> get_title(); - $s_info = $step -> get_small_info(); - $b_active = $step -> is_active(); - $b_enabled = $step -> is_enabled(); - $b_completed= $step -> is_completed(); - - if($b_completed){ - $s = ""._("Completed")." "; - }else{ - $s = "  "; - } - - if($_SESSION['js']){ - - $str .="
"; - - if($b_enabled){ - if($b_active){ - $str .= ""; - }else{ - $str .= ""; - } - }else{ - $str .= ""; - } - $str .= "
" ; - }else{ - $str .="
"; - if($b_enabled){ - if($b_active){ - $str .= ""; - }else{ - $str .= ""; - } - }else{ - $str .= ""; - } - $str .= "
" ; - } - } - return($str); - } - - - - function get_bottom_html() - { - /* Skip adding forward/backward button, - * if the currently opened step is a sub dialog - */ - if($this->o_steps[$this->i_current]->dialog){ - $str =""; - }else{ - $str ="

 

"; - $str.="
"; - if(isset($this->o_steps[$this->i_current -1]) && $this->o_steps[$this->i_current -1]->is_enabled()){ - $str .= ""; - }else{ - $str .= ""; - } - $str.= " "; - $str .= ""; - $str .="
"; - } - return($str); - } - - - /* Create header entry */ - function get_header_html() - { - $str= $this->o_steps[$this->i_current]->print_header(); - return ($str); - } - - - /* Check if the given step id is valid and selectable */ - function selectable_step($id) - { - if(isset($this->o_steps[$id]) && $this->o_steps[$id]->is_enabled()){ - return(true); - } - return(false); - } - - function step_name_to_id($name) - { - foreach($this->o_steps as $id => $class){ - if(get_class($class) == $name){ - return($id); - } - } - return(0); - } - -} - - - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep.inc b/setup/class_setupStep.inc deleted file mode 100644 index 5364187e4..000000000 --- a/setup/class_setupStep.inc +++ /dev/null @@ -1,130 +0,0 @@ -s_title); - } - - function get_long_title() - { - return($this->s_title_long); - } - - function get_small_info() - { - return($this->s_info); - } - - function is_active() - { - return($this->is_active); - } - - function is_enabled() - { - return($this->is_enabled); - } - - function is_completed() - { - return($this->is_completed); - } - - function set_active($value = TRUE) - { - if($value){ - $this->is_active = TRUE; - }else{ - $this->is_active = FALSE; - } - } - - function set_enabled($value = TRUE) - { - if($value){ - $this->is_enabled = TRUE; - }else{ - $this->is_enabled = FALSE; - } - } - - function set_completed($value = TRUE) - { - if($value){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = FALSE; - } - } - - /* Return attributes handled by this setup step */ - function get_attributes() - { - $tmp = array(); - foreach($this->attributes as $attr){ - $tmp[$attr] = $this->$attr; - } - return($tmp); - } - - function print_header() - { - $image= get_template_path($this->header_image); - $display= "
"; - $display.= "

\"*\" ".$this->s_title_long."

\n"; - $display.= "
\n"; - - return($display); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Checks.inc b/setup/class_setupStep_Checks.inc deleted file mode 100644 index 99e34ddfa..000000000 --- a/setup/class_setupStep_Checks.inc +++ /dev/null @@ -1,312 +0,0 @@ -update_strings(); - } - - - function update_strings() - { - $this->s_title = _("Installation check"); - $this->s_title_long = _("Installation check"); - $this->s_info = _("Basic checks for PHP version and required extensions."); - } - - - /* Execute and display template */ - function execute() - { - $this->run_checks(); - $smarty = get_smarty(); - $smarty->assign("basic" ,$this->basic_checks); - $smarty->assign("config" ,$this->config_checks); - $smarty->assign("is_writeable",$this->is_writeable); - return($smarty->fetch(get_template_path("setup_checks.tpl",TRUE,dirname(__FILE__)))); - } - - - /* Execute all checks */ - function run_checks() - { - $this->basic_checks = array(); - $this->config_checks = array(); - $this->is_writeable = array(); - - /* PHP version check */ - $N = _("Checking PHP version"); - $D = sprintf(_("PHP must be of version %s or above."), "5.2.0"); - $S = _("GOsa requires functionality that is not available (or buggy) in older PHP versions. Please update to a supported version."); - $R = $this->check_php_version(); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking imap extension */ - $N = _("Checking for LDAP support"); - $D = _("This is the main extension used by GOsa and therefore really required."); - $S = _("The ldap extension (php5-ldap) is required to communicate with your LDAP server."); - $R = is_callable("ldap_bind"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check for gettext support */ - $N = _("Checking for gettext support"); - $D = _("Gettext support is required for internationalization."); - $S = _("Please make sure that the extension is activated."); - $R = is_callable("bindtextdomain"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checing for iconv */ - $N = _("Checking for iconv support"); - $D = _("This module is used by GOsa to convert samba munged dial informations and is therefore required. "); - $S = _("Please make sure that the extension is activated."); - $R = is_callable("iconv"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check for installed mhash module */ - $N = _("Checking for mhash support"); - $D = _("You'll need this module to make use of SSHA encryption"); - $S = _("The mhash module for PHP 5 is not available.Please install php5-mhash."); - $R = is_callable("mhash"); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Is imap module available */ - $N = _("Checking for IMAP support"); - $D = _("The IMAP module is needed to communicate with the IMAP server. GOsa retrieves status information, creates and deletes mail users, etc."); - $S = _("This module is used to communicate with your mail server. Please install php5-imap."); - $R = is_callable("imap_open"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check getacl in imap module */ - $N = _("Checking for getacl in IMAP implementation"); - $D = _("The getacl support is needed to handle shared folder permissions. Old IMAP extensions are not capable of reading acl's. You need a recent PHP version to use this feature."); - $S = $D; - $R = is_callable("imap_getacl"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Mysql module loaded ? */ - $N = _("Checking for MySQL support"); - $D = _("MySQL support is needed to communicate with several supported databases."); - $S = _("This module is required to communicate with database servers (GOfax, asterisk, GLPI, etc.). Please install php5-mysql"); - $R = is_callable("mysql_query"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking for kadm5 module */ - $N = _("Checking for kadm5 support"); - $D = _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network."); - $S = _("This module is required to manage user in kerberos, it is downloadable via PEAR network"); - $R = is_callable("kadm5_init_with_password"); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Snmp module available ? */ - $N = _("Checking for SNMP support"); - $D = _("The simple network management protocol is needed to get status information from clients."); - $S = _("This module is required for client monitoring. Please install php5-snmp."); - $R = is_callable("snmpget"); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking for Cups module */ - $N = _("Checking for CUPS support"); - $D = _("In order to read available printers via the IPP protocol instead of printcap files, you've to install the CUPS module."); - $S = $D; - $R = is_callable("cups_get_dest_list"); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking for F ping utility */ - $query= "LC_ALL=C LANG=C fping -v 2>&1"; - $output= shell_exec ($query); - $N = _("Checking for fping utility"); - $D = _("The fping utility is used if you've got a thin client based terminal environment."); - $S = _("The fping utility is only used in thin client based terminal environment."); - $R = preg_match("/^fping:/", $output); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking generate LM/NT password hashes */ - $query= "mkntpwd 2>&1"; - $output= shell_exec ($query); - $have_mkntpwd= preg_match("/^Usage: mkntpwd /", $output); - if (!$have_mkntpwd){ - $query= 'LC_ALL=C LANG=C perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen $ARGV[0]), $/;" &>/dev/null'; - system ($query, $ret); - $have_mkntpwd |= ($ret == 0); - } - - $N = _("SAMBA password hash generation"); - $D = _("In order to use SAMBA 2/3 passwords, you've to install additional packages to generate password hashes."); - $S = _("In order to use SAMBA 2/3 you've to install additional perl libraries. Take a look at mkntpasswd."); - $R = $have_mkntpwd; - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - - /* PHP Configuration checks - */ - - /* Register_globals off */ - $N = "register_globals = "._("Off").""; - $D = _("register_globals is a PHP mechanism to register all global variables to be accessible from scripts without changing the scope. This may be a security risk."); - $S = _("Search for 'register_globals' in your php.ini and switch it to 'Off'."); - $R = ini_get("register_globals") == 0; - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - - /* session lifetime set to >=86400 seconds ? */ - $N = "session.gc_maxlifetime >= 86400"; - $D = _("PHP uses this value for the garbage collector to delete old sessions.")." ". - _("Setting this value to one day will prevent loosing session and cookies before they really timeout."); - $S = _("Search for 'session.gc_maxlifetime' in your php.ini and set it to 86400 or higher."); - $R = ini_get("session.gc_maxlifetime") >= 86400; - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Session auto start must be turned off */ - $session_auto_start = ini_get('session.auto_start'); - $N = "session.auto_start = "._("Off").""; - $D = _("In Order to use GOsa without any trouble, the session.auto_register option in your php.ini should be set to 'Off'."); - $S = _("Search for 'session.auto_start' in your php.ini and set it to 'Off'."); - $R = !$session_auto_start['local_value']; - $M = TRUE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check if memory limit is set to 32 or > */ - $N = "memory_limit >= 32"; - $D = _("GOsa needs at least 32MB of memory. Setting it below this limit may cause errors that are not reproducable! Increase it for larger setups."); - $S = _("Search for 'memory_limit' in your php.ini and set it to '32M' or higher."); - $R = ini_get('memory_limit') >= 32 ; - $M = TRUE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Implicit Flush disabled can increase performance */ - $N = "implicit_flush = "._("Off").""; - $D = _("This option influences the PHP output handling. Turn this Option off, to increase performance."); - $S = _("Search for 'implicit_flush' in your php.ini and set it to 'Off'."); - $R = !ini_get('implicit_flush'); - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check if execution time is set to 30 */ - $N = "max_execution_time >= 30"; - $D = _("The Execution time should be at least 30 seconds."); - $S = _("Search for 'max_execution_time' in your php.ini and set it to '30' or higher."); - $R = ini_get("max_execution_time") >= 30 ; - $M = TRUE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Expose php should be set to off */ - $N = "expose_php = "._("Off").""; - $D = _("Increase the server security by setting expose_php to 'off'. PHP won't send any information about the server you are running in this case."); - $S = _("Search for 'expose_php' in your php.ini and set if to 'Off'."); - $R = !ini_get("expose_php"); - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Automatic quoting must be turned on */ - $N = "magic_quotes_gpc = "._("On").""; - $D = _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case."); - $S = _("Search for 'magic_quotes_gpc' in your php.ini and set it to 'On'."); - $R = ini_get('magic_quotes_gpc'); - $M = TRUE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Emulating old stuff? */ - $N = "zend.ze1_compatibility_mode = "._("Off").""; - $D = _("Increase your server performance by setting magic_quotes_gpc to 'off'."); - $S = _("Search for 'zend.ze1_compatibility_mode' in your php.ini and set it to 'Off'."); - $R = !ini_get('zend.ze1_compatibility_mode'); - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - - /* Configuration file - */ - - /* Check if we can create a config file.*/ - $N = _("Configuration writeable"); - $D = _("The configuration file can't be written"); - $S = sprintf(_("GOsa reads its configuration from a file located in (%s/%s). The setup can write the configuration directly if it is writeable."),CONFIG_DIR,CONFIG_FILE); - $R = ( file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR."/".CONFIG_FILE)) // is there a config file ? - || (!file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR)); // There is non, but can we create a file there ? - $M = FALSE; - $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* If we have writeaccess to the config dir, check if there is already a config file */ -# if($R){ -# -# /* check if there is already a config file. */ -# $N = _("No old configuration file."); -# $D = "";//_(""); -# $S = _("If there is already a configuration file, this file will be overwritten when GOsa setup finishes. Please move your old config file away."); -# $R = !file_exists(CONFIG_DIR."/".CONFIG_FILE); -# $M = FALSE; -# $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); -# } - } - - - function save_object() - { - /* If everything is fine, set this step to completed - * and allow switching to next setup step - */ - $failed = false; - foreach(array("basic_checks","config_checks","is_writeable") as $type){ - foreach($this->$type as $obj){ - - if($obj['MUST'] && !$obj['RESULT']){ - $failed = true; - break; - } - } - } - $this->is_completed = !$failed; - } - - - /* Check if current PHP version is compatible - with the current version of GOsa */ - function check_php_version() - { - return(version_compare(phpversion(),"5.2.0",">=")); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Config1.inc b/setup/class_setupStep_Config1.inc deleted file mode 100644 index 1087b6a2b..000000000 --- a/setup/class_setupStep_Config1.inc +++ /dev/null @@ -1,245 +0,0 @@ - 6, - "pwminlen_active" => FALSE, - "pwdiffer" => 5, - "pwdiffer_active" => FALSE, - "externalpwdhook" => "", - "externalpwdhook_active" => FALSE); - - var $id_settings = array( "idgen" => "{%sn}-{%givenName[2-4]}", - "idgen_active" => FALSE, - "minid" => "100", - "minid_active" => FALSE); - - var $crypt_methods = array(); - - var $attributes = array("compressed","peopleou","groupou","peopledn","uidbase","encryption","theme","krbsasl", - "base_hook","base_hook_active","account_expiration","strict","include_personal_title"); - - function Step_Config1() - { - $this->update_strings(); - - $tmp = @passwordMethod::get_available_methods(); - foreach($tmp['name'] as $name){ - $this->crypt_methods[$name] = $name; - } - } - - - function update_strings() - { - $this->s_title = _("GOsa settings 1/3"); - $this->s_title_long = _("GOsa settings 1/3"); - $this->s_info = _("GOsa generic settings"); - } - - - function execute() - { - $smarty = get_smarty(); - $smarty->assign("peopledns",array("uid","cn")); - $smarty->assign("id_settings",$this->id_settings); - $smarty->assign("crypt_methods",$this->crypt_methods); - $smarty->assign("themes",$this->get_themes()); - $smarty->assign("pwd_rules",$this->pwd_rules); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* !!! Attention strict is inverse. If you change this, - * don't forget to change save_object too - */ - $smarty->assign("strict",!$this->strict); - return($smarty -> fetch (get_template_path("../setup/setup_config1.tpl"))); - } - - - function get_themes() - { - $dir = opendir( "../ihtml/themes/"); - $themes = array(); - while (($file = readdir($dir)) !== false){ - if(is_dir("../ihtml/themes/".$file) && !preg_match("/^\./",$file)){ - $themes[$file] = $file; - } - } - return($themes); - } - - function check() - { - $message = array(); - - if(isset($this->id_settings['minid_active']) && !is_numeric($this->id_settings['minid'])){ - $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id")); - } - - if(preg_match("/,$/",$this->peopleou)){ - $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("People storage ou")); - } - - if(preg_match("/,$/",$this->groupou)){ - $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("Group storage ou")); - } - - if(!is_numeric($this->uidbase)){ - $message[] = _("Uid base must be numeric"); - } - - if(($this->pwd_rules['pwminlen_active']) && !is_numeric($this->pwd_rules['pwminlen'])){ - $message[] = _("The given password minimum length is not numeric."); - } - if(($this->pwd_rules['pwdiffer_active']) && !is_numeric($this->pwd_rules['pwdiffer'])){ - $message[] = _("The given password differ value is not numeric."); - } - return($message); - } - - function save_object() - { - if(isset($_POST['step5_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate(get_post($attr)); - } - } - - /* !!! Attention strict is inverse. If you change this, - * don't forget to change the smarty assignment too - */ - if(isset($_POST['strict'])){ - if($_POST['strict']){ - $this->strict = FALSE; - }else{ - $this->strict = TRUE; - } - } - - if(isset($_POST['minid_active'])){ - $this->id_settings['minid_active'] = TRUE; - if(isset($_POST['minid'])){ - $this->id_settings['minid'] = get_post('minid'); - } - }else{ - $this->id_settings['minid_active'] = FALSE; - } - - /* Generic settings */ - if(isset($_POST['idgen_active'])){ - $this->id_settings['idgen_active'] = TRUE; - if(isset($_POST['idgen'])){ - $this->id_settings['idgen'] = get_post('idgen'); - } - }else{ - $this->id_settings['idgen_active'] = FALSE; - } - - /* Get password settings */ - if(isset($_POST['pwdiffer_active'])){ - $this->pwd_rules['pwdiffer_active'] = TRUE; - if(isset($_POST['pwdiffer'])){ - $this->pwd_rules['pwdiffer'] = get_post('pwdiffer'); - } - }else{ - $this->pwd_rules['pwdiffer_active'] = FALSE; - } - - /* Get password minimum length posts */ - if(isset($_POST['pwminlen_active'])){ - $this->pwd_rules['pwminlen_active'] = TRUE; - if(isset($_POST['pwminlen'])){ - $this->pwd_rules['pwminlen'] = get_post('pwminlen'); - } - }else{ - $this->pwd_rules['pwminlen_active'] = FALSE; - } - - /* External pwd settings */ - if(isset($_POST['externalpwdhook_active'])){ - $this->pwd_rules['externalpwdhook_active'] = TRUE; - if(isset($_POST['externalpwdhook'])){ - $this->pwd_rules['externalpwdhook'] = get_post('externalpwdhook'); - } - }else{ - $this->pwd_rules['externalpwdhook_active'] = FALSE; - } - - /* base hook settings */ - if(isset($_POST['base_hook_active'])){ - $this->pwd_rules['base_hook_active'] = TRUE; - if(isset($_POST['base_hook'])){ - $this->pwd_rules['base_hook'] = get_post('base_hook'); - } - }else{ - $this->pwd_rules['base_hook_active'] = FALSE; - } - } - - $tmp = $this->check(); - if(count($tmp) == 0){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = FALSE; - } - }// if tempalte posted - - - /* Attributes that are interesting for configuration generation */ - function get_attributes() - { - $tmp = setup_step::get_attributes(); - foreach(array("pwd_rules","id_settings") as $attr){ - $tmp[$attr]= $this->$attr; - } - return($tmp); - } -}// CLass - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Config2.inc b/setup/class_setupStep_Config2.inc deleted file mode 100644 index e6b96b10c..000000000 --- a/setup/class_setupStep_Config2.inc +++ /dev/null @@ -1,312 +0,0 @@ - "/etc/gosa/vacation", - "vacationdir_active" => FALSE); - - var $generic_settings = array( "enableCopyPaste" => false, - "enableDNS" => false, - "enableDHCP" => false, - "wws_ou" => "ou=winstations", - "wws_ou_active" => FALSE, - "snapshot_active" => FALSE, - "snapshot_base" => "ou=snapshots,%base%", - "snapshot_user" => "%admin%", - "snapshot_password" => "", - "snapshot_server" => "%connection%"); - - var $samba_settings = array( "samba_sid" => "0-815-4711", - "samba_sid_active" => FALSE, - "samba_rid" => 1000, - "smbhash" => 'SMBHASH', - "samba_rid_active" => FALSE); - - var $sambaDomain_found = FALSE; - var $use_netatalk = FALSE; - var $enableFAI_management = FALSE; - var $enableMimeType = FALSE; - - var $timezone = "Europe/Berlin"; - var $timezones = array(); - - var $attributes = array("governmentmode","sambaidmapping","cyrusunixstyle","mail","use_netatalk","enableFAI_management","timezone","enableMimeType"); - var $called = FALSE; - - function Step_Config2() - { - $this->update_strings(); - $tmp = $this->get_available_mail_classes(); - foreach($tmp['name'] as $name){ - $this->mail_methods[$name] = $name; - } - - /* Look for samba password generation method */ - if(file_exists("/usr/bin/mkntpasswd")){ - $pwdhash = "/usr/bin/mkntpasswd"; - } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){ - $pwdhash= "mkntpwd"; - } else { - $pwdhash= 'perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;"'; - } - - $this->timezones = _get_tz_zones(); - $this->samba_settings['smbhash'] = $pwdhash; - } - - - function update_strings() - { - $this->s_title = _("GOsa settings 2/3"); - $this->s_title_long = _("GOsa settings 2/3"); - $this->s_info = _("Customize special parameters"); - } - - - function execute() - { - /* On first call check for rid/sid base */ - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - $ldap->search("(objectClass=sambaDomain)",array("dn")); - if($ldap->count()){ - $this->sambaDomain_found =TRUE; - }else{ - $this->sambaDomain_found =FALSE; - } - - if(!$this->called){ - if(!$this->sambaDomain_found){ - $this->samba_settings['samba_sid_active'] = TRUE; - $this->samba_settings['samba_rid_active'] = TRUE; - } - - /* Check if we can enable netatalk plugin */ - $tmp = $ldap->get_objectclasses(); - if(is_array($tmp) && isset($tmp['apple-user'])) { - $this->use_netatalk = TRUE; - } - - /* Check the FAI schema is used */ - if(is_array($tmp) && isset($tmp['FAIclass'])){ -# $this->enableFAI_management = TRUE; - } - - /* Check the MimeType schema is used */ - if(is_array($tmp) && isset($tmp['gotoMimeType'])){ - $this->enableMimeType = TRUE; - } - - if(is_array($tmp) && isset($tmp['dhcpClass'])){ - $this->generic_settings['enableDHCP'] = TRUE; - } - - if(is_array($tmp) && isset($tmp['dNSZone'])){ - $this->generic_settings['enableDNS'] = TRUE; - } - - $this->called = TRUE; - } - - /* Update snapshot values, with already collected values */ - foreach($this->generic_settings as $key => $value){ - foreach(array("snapshot_base","snapshot_user","snapshot_server") as $attr){ - foreach($this->parent->captured_values as $replace_name => $replace_value){ - if(is_string($replace_value)) { - $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]); - } - } - } - } - - $smarty = get_smarty(); - $smarty->assign("sambaDomain_found",$this->sambaDomain_found); - $smarty->assign("generic_settings",$this->generic_settings); - $smarty->assign("mail_settings",$this->mail_settings); - $smarty->assign("mail_methods",$this->mail_methods); - $smarty->assign("samba_settings",$this->samba_settings); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - $smarty->assign("timezone" ,$this->timezone); - $smarty->assign("timezones" ,$this->timezones); - return($smarty -> fetch (get_template_path("../setup/setup_config2.tpl"))); - } - - function save_object() - { - if(isset($_POST['step6_posted'])){ - - if(isset($_POST['timezone']) && isset($this->timezones['TIMEZONES'][$_POST['timezone']])){ - $this->timezone = $_POST['timezone']; - } - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate(get_post($attr)); - } - } - - /* Mail settings */ - if(isset($_POST['vacationdir_active'])){ - $this->mail_settings['vacationdir_active'] = TRUE; - if(isset($_POST['vacationdir'])){ - $this->mail_settings['vacationdir'] = get_post('vacationdir'); - } - }else{ - $this->mail_settings['vacationdir_active'] = FALSE; - } - - if(isset($_POST['enableCopyPaste'])){ - $this->generic_settings['enableCopyPaste'] = get_post('enableCopyPaste'); - } - if(isset($_POST['enableDNS'])){ - $this->generic_settings['enableDNS'] = get_post('enableDNS'); - } - if(isset($_POST['enableDHCP'])){ - $this->generic_settings['enableDHCP'] = get_post('enableDHCP'); - } - - if(isset($_POST['wws_ou_active'])){ - $this->generic_settings['wws_ou_active'] = TRUE; - if(isset($_POST['wws_ou'])){ - $this->generic_settings['wws_ou'] = get_post('wws_ou'); - } - }else{ - $this->generic_settings['wws_ou_active'] = FALSE; - } - - if(isset($_POST['snapshot_active'])){ - $this->generic_settings['snapshot_active'] = TRUE; - if(isset($_POST['snapshot_base'])){ - $this->generic_settings['snapshot_base'] = get_post('snapshot_base'); - } - if(isset($_POST['snapshot_user'])){ - $this->generic_settings['snapshot_user'] = get_post('snapshot_user'); - } - if(isset($_POST['snapshot_password'])){ - $this->generic_settings['snapshot_password'] = get_post('snapshot_password'); - } - if(isset($_POST['snapshot_server'])){ - $this->generic_settings['snapshot_server'] = get_post('snapshot_server'); - } - }else{ - $this->generic_settings['snapshot_active'] = FALSE; - } - - /* Samba settings */ - if(isset($_POST['samba_sid_active'])){ - $this->samba_settings['samba_sid_active'] = TRUE; - if(isset($_POST['samba_sid'])){ - $this->samba_settings['samba_sid'] = get_post('samba_sid'); - } - }else{ - $this->samba_settings['samba_sid_active'] = FALSE; - } - if(isset($_POST['samba_rid_active'])){ - $this->samba_settings['samba_rid_active'] = TRUE; - if(isset($_POST['samba_rid'])){ - $this->samba_settings['samba_rid'] = get_post('samba_rid'); - } - }else{ - $this->samba_settings['samba_rid_active'] = FALSE; - } - if(isset($_POST['smbhash'])){ - $this->samba_settings['smbhash'] = get_post('smbhash'); - } - - if(!$this->sambaDomain_found){ - $this->samba_settings['samba_sid_active'] = TRUE; - $this->samba_settings['samba_rid_active'] = TRUE; - } - } - - $tmp = $this->check(); - if(count($tmp) == 0){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = FALSE; - } - } - - - function check() - { - $message = array(); - return($message); - } - - - /* Attributes that are interesting for configuration generation */ - function get_attributes() - { - $tmp = setup_step::get_attributes(); - foreach(array("samba_settings","generic_settings","mail_settings") as $attr){ - $tmp[$attr]= $this->$attr; - } - return($tmp); - } - -/* Returns the classnames auf the mail classes */ - function get_available_mail_classes() - { - $dir = opendir( "../include"); - $methods = array(); - $suffix = "class_mail-methods-"; - $lensuf = strlen($suffix); - $prefix = ".inc"; - $lenpre = strlen($prefix); - $i = 0; - while (($file = readdir($dir)) !== false){ - - if(stristr($file,$suffix)) { - $lenfile = strlen($file); - $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre); - $methods['file'][$i] = $file; - $methods[$i]['file'] = $file; - $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre); - $i++; - } - } - return($methods); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Config3.inc b/setup/class_setupStep_Config3.inc deleted file mode 100644 index eaa5368b1..000000000 --- a/setup/class_setupStep_Config3.inc +++ /dev/null @@ -1,229 +0,0 @@ - "uid", - "mail" => "mail", - "uid,mail" => "both"); - var $optional = array( - "login_attribute" => "uid", - "strict_units" => false, - "list_summary" => false, - "forceglobals" => true, - "forcessl" => false, - "ldapstats" => false, - "warnssl" => true, - "user_filter_cookie" => true, - "ppd_path" => "/var/spool/ppd/", - "ppd_path_active" => FALSE, - "compile" => "/var/spool/gosa", - "snmpcommunity" => "goto", - "debuglevel" => 0, - "session_lifetime" => 7200, - "max_ldap_query_time" => "5.0", - "max_ldap_query_time_active" => FALSE, - - "mailQueueScriptPath" => "/usr/bin/sudo /usr/local/sbin/mailqueue %action %id %server", - "mailQueueScriptPath_active" => FALSE, - - "auto_network_hook" => "/usr/bin/net-resolver.sh", - "auto_network_hook_active" => FALSE, - - "notifydir" => "", - "notifydir_active" => FALSE, - - "uniq_identifier" => "entryCSN", - "uniq_identifier_active" => TRUE, - - "kioskpath" => "/var/spool/kiosk", - "kioskpath_active" => FALSE, - - "gotomasses_file" => "/etc/gosa/gotomasses", - "gotomasses_active" => FALSE, - - "noprimarygroup" => FALSE); - - var $attributes = array("errorlvl"); - - function Step_Config3() - { - $this->update_strings(); - } - - - function update_strings() - { - $this->s_title = _("GOsa settings 3/3"); - $this->s_title_long = _("GOsa settings 3/3"); - $this->s_info = _("Tweak some GOsa core behaviour"); - } - - - function execute() - { - $smarty = get_smarty(); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - $smarty->assign("uniq_identifiers",array( "entryCNS" => "entryCSN", - "contextCSN"=>"contextCSN" )); - $smarty->assign("optional", $this->optional); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - $smarty->assign("login_attributes",$this->login_attributes); - return($smarty -> fetch (get_template_path("../setup/setup_config3.tpl"))); - } - - - function save_object() - { - if(isset($_POST['step6a_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate(get_post($attr)); - } - } - - foreach(array("login_attribute","list_summary","strict_units","snmpcommunity","noprimarygroup","forceglobals","forcessl","ldapstats","user_filter_cookie","warnssl","compile","debuglevel","session_lifetime") as $name){ - if(isset($_POST[$name])){ - $this->optional[$name] = get_post($name); - } - } - - if(isset($_POST['ppd_path_active'])){ - $this->optional['ppd_path_active'] = TRUE; - if(isset($_POST['ppd_path'])){ - $this->optional['ppd_path'] = get_post('ppd_path'); - } - }else{ - $this->optional['ppd_path_active'] = FALSE; - } - - if(isset($_POST['max_ldap_query_time_active'])){ - $this->optional['max_ldap_query_time_active'] = TRUE; - if(isset($_POST['max_ldap_query_time'])){ - $this->optional['max_ldap_query_time'] = get_post('max_ldap_query_time'); - } - }else{ - $this->optional['max_ldap_query_time_active'] = FALSE; - } - - if(isset($_POST['mailQueueScriptPath_active'])){ - $this->optional['mailQueueScriptPath_active'] = TRUE; - if(isset($_POST['mailQueueScriptPath'])){ - $this->optional['mailQueueScriptPath'] = get_post('mailQueueScriptPath'); - } - }else{ - $this->optional['mailQueueScriptPath_active'] = FALSE; - } - - if(isset($_POST['kioskpath_active'])){ - $this->optional['kioskpath_active'] = TRUE; - if(isset($_POST['kioskpath'])){ - $this->optional['kioskpath'] = get_post('kioskpath'); - } - }else{ - $this->optional['kioskpath_active'] = FALSE; - } - - if(isset($_POST['gotomasses_active'])){ - $this->optional['gotomasses_active'] = TRUE; - if(isset($_POST['gotomasses_file'])){ - $this->optional['gotomasses_file'] = get_post('gotomasses_file'); - } - }else{ - $this->optional['gotomasses_active'] = FALSE; - } - - if(isset($_POST['auto_network_hook_active'])){ - $this->optional['auto_network_hook_active'] = TRUE; - if(isset($_POST['auto_network_hook'])){ - $this->optional['auto_network_hook'] = get_post('auto_network_hook'); - } - }else{ - $this->optional['auto_network_hook_active'] = FALSE; - } - - if(isset($_POST['notifydir_active'])){ - $this->optional['notifydir_active'] = TRUE; - if(isset($_POST['notifydir'])){ - $this->optional['notifydir'] = get_post('notifydir'); - } - }else{ - $this->optional['notifydir_active'] = FALSE; - } - - if(isset($_POST['uniq_identifier_active'])){ - $this->optional['uniq_identifier_active'] = TRUE; - if(isset($_POST['uniq_identifier'])){ - $this->optional['uniq_identifier'] = get_post('uniq_identifier'); - } - }else{ - $this->optional['uniq_identifier_active'] = FALSE; - } - } - - $tmp = $this->check(); - if(count($tmp) == 0){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = FALSE; - } - } - - - function check() - { - $message = array(); - - if(!is_numeric( $this->optional['session_lifetime'])){ - $message[] = _("Session lifetime must be a numeric value."); - } - - if(!is_numeric( $this->optional['max_ldap_query_time'])){ - $message[] = _("Maximal ldap query time must be a numeric value. "); - } - - return($message); - } - - - /* Attributes that are interesting for configuration generation */ - function get_attributes() - { - $tmp = setup_step::get_attributes(); - foreach(array("optional") as $attr){ - $tmp[$attr]= $this->$attr; - } - return($tmp); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Feedback.inc b/setup/class_setupStep_Feedback.inc deleted file mode 100644 index fbcfb4c97..000000000 --- a/setup/class_setupStep_Feedback.inc +++ /dev/null @@ -1,274 +0,0 @@ -is_enabled = TRUE; - $this->is_active = TRUE; - $this->update_strings(); - } - - - function init() - { - $cv = $this->parent->captured_values; - - /* Initialize values */ - $this->use_since = date("Y"); - $this->organization = preg_replace("/^[^=]*+=(.*),.*$/","\\1",$cv['base']); - $this->distribution = ""; - $this->web_server = $_SERVER['SERVER_SOFTWARE']; - $this->php_version = PHP_VERSION; - - /* On first call check for rid/sid base */ - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - $ldap->cd($cv['base']); - $ldap->search("(objectClass=*)",array("dn")); - $this->object_count=$ldap->count(); - - /* Preselect used features */ - $oc = $ldap->get_objectclasses(); - $this->features_used = array(); - $this->features_used['posix'] = array("USED" => isset($oc['posixAccount']) , - "NAME" => _("UNIX accounts/groups")); - $this->features_used['samba'] = array("USED" => isset($oc['sambaSamAccount']) || isset($oc['sambaAccount']) , - "NAME" => _("Samba management")); - $this->features_used['mail'] = array("USED" => $cv['mail'] != "none", - "NAME" => _("Mailsystem management")); - $this->features_used['fax'] = array("USED" => isset($oc['goFaxAccount']) , - "NAME" => _("FAX system administration")); - $this->features_used['asterisk'] = array("USED" => isset($oc['goFonAccount']), - "NAME" => _("Asterisk administration")); - $this->features_used['inventory'] = array("USED" => isset($oc['glpiAccount']) , - "NAME" => _("System inventory")); - $this->features_used['system'] = array("USED" => FALSE , - "NAME" => _("System-/Configmanagement")); - $this->features_used['addressbook'] = array("USED" => FALSE , - "NAME" => _("Addressbook")); - } - - - function update_strings() - { - $this->s_title = _("Notification and feedback"); - $this->s_info = _("Get notifications or send feedback"); - $this->s_title_long = _("Notification and feedback"); - } - - - function execute() - { - if(!$this->initialized){ - $this->initialized = TRUE; - $this->init(); - } - - $additional_info =""; - - if(isset($_POST['send_feedback'])){ - - $msgs = $this->check_feedback(); - if(count($msgs)){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $str = $this->create_serialise_data_string(); - $feedback_url = $this->feedback_url."?data=".base64_encode($str); - - $ret = @fopen($feedback_url,"r"); - - if(!$ret){ - print_red(sprintf(_("Could not connect to feedback server (%s). There is possibly no connection to the internet."),$this->feedback_url)); - }else{ - $ret_value=""; - while($ret && !feof($ret)){ - $ret_value.= fgets($ret,256); - } - if(!preg_match("/successful/i",$ret_value)){ - print_red(_("Error while sending your feedback. The service is possible temporary unavailable")); - }else{ - $additional_info = ""._("Feedback sucessfully send").""; - } - } - @fclose($ret); - } - } - - $years = array(); - for($i = date("Y") ; $i >= 2001; $i--){ - $years[$i] = $i; - } - - $this->is_completed=TRUE; - $smarty = get_smarty(); - - foreach($this->attributes as $attr){ - $smarty->assign($attr, $this->$attr); - } - $smarty->assign("years",$years); - $smarty->assign("features_used",$this->features_used); - $smarty->assign("additional_info",$additional_info); - $smarty->assign ("must", "*"); - return($smarty->fetch(get_template_path("setup_feedback.tpl",TRUE,dirname(__FILE__)))); - } - - - function check_feedback() - { - $msgs = array(); - if(!is_email($this->eMail) || empty($this->eMail)){ - $msgs[] = _("Please specify a valid email address."); - } - - if(!$this->subscribe && !$this->use_gosa_announce){ - $msgs[] = _("You should have enabled at least one option, to subscribe or send your feedback."); - } - - return($msgs); - } - - - function save_object() - { - if(isset($_POST['step_feedback'])){ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = get_post($attr); - } - } - - if(isset($_POST['subscribe'])){ - $this->subscribe = TRUE; - }else{ - $this->subscribe = FALSE; - } - - if(isset($_POST['use_gosa_announce'])){ - $this->use_gosa_announce = TRUE; - }else{ - $this->use_gosa_announce = FALSE; - } - - foreach($this->features_used as $key => $data){ - if(isset($_POST['feature_'.$key])){ - $this->features_used[$key]['USED'] = TRUE; - }else{ - $this->features_used[$key]['USED'] = FALSE; - } - } - } - } - - - function create_serialise_data_string() - { - $str = "#FEEDBACK ".date("H:i:s d:m:Y"); - if($this->subscribe){ - - $str.= "\n\nSubscribe"; - $str .= "\nOrganization: ".$this->organization; - $str .= "\nName: ".$this->name; - $str .= "\neMail: ".$this->eMail; - } - - if($this->use_gosa_announce){ - - $str.= "\n\nFeedback"; - - if($this->get_started) { - $str .= "\nGet started: TRUE"; - }else{ - $str .= "\nGet started: FALSE"; - } - $str .= "\nProblems : ".($this->problems_encountered); - - if($this->first_use){ - $str .= "\nFirst use: TRUE"; - }else{ - $str .= "\nFirst use: FALSE"; - } - $str .= "\nUsing GOsa since: ".$this->use_since; - - $str .="\nDistribution: ".$this->distribution; - $str .="\nWeb Server: ".$this->web_server; - $str .="\nPHP_Version: ".$this->php_version; - $str .="\nLDAP Server: ".$this->ldap_server; - $str .="\nObject count: ".$this->object_count; - $str .="\nMissing features: ".($this->want_to_see_next); - } - - $str .= "\n\nFeatures used"; - foreach($this->features_used as $name => $data){ - $str.="\n".$name.": "; - if($data['USED']){ - $str .= "TRUE"; - }else{ - $str .= "FALSE"; - } - } - - return($str); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Finish.inc b/setup/class_setupStep_Finish.inc deleted file mode 100644 index 3898c55c5..000000000 --- a/setup/class_setupStep_Finish.inc +++ /dev/null @@ -1,143 +0,0 @@ -update_strings(); - } - - - function update_strings() - { - $this->s_title = _("Finish"); - $this->s_info = _("Write configuration file"); - $this->s_title_long = _("Finish - write the configuration file"); - } - - - function get_conf_data() - { - $smarty = get_smarty(); - $smarty->assign("cv",$this->parent->captured_values); - $str = $smarty->fetch(CONFIG_TEMPLATE_DIR.$this->gosa_conf_contrib); - return($str); - } - - - function execute() - { - - $info= posix_getgrgid(posix_getgid()); - $webgroup = $info['name']; - - - /* Check if there is currently an active gosa.conf - */ - $exists = file_exists(CONFIG_DIR."/".CONFIG_FILE); - - /* Redirect to GOsa login, if : - * - gosa.conf exists - * - Permisssion are set correctly - */ - if(isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){ - session_destroy(); - header("Location: index.php"); - exit(); - } - - /* Downlaod config */ - if(isset($_POST['getconf'])){ - - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - header("Cache-Control: no-cache"); - header("Pragma: no-cache"); - header("Cache-Control: post-check=0, pre-check=0"); - header("Content-type: text/plain"); - - if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) || - preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){ - header('Content-Disposition: filename="'.CONFIG_FILE.'"'); - } else { - header('Content-Disposition: attachment; filename="'.CONFIG_FILE.'"'); - } - - $str = $this->get_conf_data(); - $str = preg_replace("/\n[ ]*\n/","",$str); - - echo $this->get_conf_data(); - exit(); - } - - $err_msg= ""; - - if($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){ - $err_msg = _("Your configuration file is currently world readable. Please updated the file permissions!"); - }elseif(!$exists){ - $err_msg = _("The configuration is currently not readable or it does not exists."); - } - - $smarty = get_smarty(); - $smarty->assign("err_msg",$err_msg); - $smarty->assign("webgroup", $webgroup); - $smarty->assign("CONFIG_DIR",CONFIG_DIR); - $smarty->assign("CONFIG_FILE" , CONFIG_FILE); - - $smarty->assign("msg2", sprintf(_("After downloading and placing the file under %s, please make sure that the user the webserver is running with is able to read %s, while other users shouldn't. You may want to execute these commands to achieve this requirement:"),CONFIG_DIR,CONFIG_FILE)); - - $smarty->assign("cv",$this->parent->captured_values); - return($smarty -> fetch (get_template_path("../setup/setup_finish.tpl"))); - } - - - /* check if given file is world readable */ - function is_world_readable($file) - { - clearstatcache(); - $p = fileperms($file); - $w_r = (decbin($p & 4) == TRUE); - return($w_r); - } - - - function save_object() - { - if(isset($_POST['step8_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate($_POST[$attr]); - } - } - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Language.inc b/setup/class_setupStep_Language.inc deleted file mode 100644 index e1b5e72ab..000000000 --- a/setup/class_setupStep_Language.inc +++ /dev/null @@ -1,72 +0,0 @@ -lang = get_browser_language(); - $this->lang_selected = ""; - $this->update_strings(); - } - - function update_strings() - { - $this->s_title = _("Language setup"); - $this->s_title_long = _("Language setup"); - $this->s_info = _("This step allows you to select your preferred language."); - } - - function execute() - { - $this->languages = array_merge(array("" => _("Automatic")),get_languages(TRUE)); - asort($this->languages); - $smarty = get_smarty(); - $smarty->assign("languages", $this->languages); - $smarty->assign("lang", $this->lang); - $smarty->assign("lang_selected",$this->lang_selected); - return($smarty->fetch(get_template_path("setup_language.tpl",TRUE,dirname(__FILE__)))); - } - - function save_object() - { - if((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) { - $this->lang_selected = $_POST['lang_selected']; - $this->is_completed = TRUE; - - if($this->lang_selected != ""){ - $_SESSION['lang'] = $this->lang_selected; - }else{ - $_SESSION['lang'] = $this->lang; - } - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Ldap.inc b/setup/class_setupStep_Ldap.inc deleted file mode 100644 index 9b5f670ea..000000000 --- a/setup/class_setupStep_Ldap.inc +++ /dev/null @@ -1,208 +0,0 @@ -update_strings(); - } - - - function update_strings() - { - $this->s_title = _("LDAP setup"); - $this->s_title_long = _("LDAP connection setup"); - $this->s_info = _("This dialog performs the basic configuration of the LDAP connectivity for GOsa."); - } - - - function execute() - { - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign connection status */ - $smarty->assign("connection_status",$this->get_connection_status()); - - /* Handle namingContext detection */ - $attr = @LDAP::get_naming_contexts($this->connection); - unset($attr['count']); - $smarty->assign("namingContexts",$attr); - $smarty->assign("namingContextsCount",count($attr)); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - - /* Addign resolved users */ - $smarty->assign("resolve_user",$this->resolve_user); - if($this->resolve_user){ - $tmp = $this->resolve_user(); - $smarty->assign("resolved_users",$tmp); - $smarty->assign("resolved_users_count",count($tmp)); - $smarty->assign("resolve_filter",$this->resolve_filter); - } - - $base_to_append = $this->base; - if(strlen($base_to_append) > 20){ - $base_to_append = substr($base_to_append,0,17)."..."; - } - $smarty->assign("base_to_append",$base_to_append); - return($smarty -> fetch (get_template_path("../setup/setup_ldap.tpl"))); - } - - function get_connection_status() - { - $this->connect_id = FALSE; - $this->bind_id = FALSE; - - @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); - $this->connect_id = @ldap_connect($this->connection); - - @ldap_set_option($this->connect_id, LDAP_OPT_PROTOCOL_VERSION, 3); - $this->bind_id = @ldap_bind($this->connect_id, $this->admin, $this->password); - - if(!$this->bind_id){ - $str = sprintf(_("Anonymous bind failed on server '%s'."),$this->connection); - if(!empty($this->admin)){ - $str = sprintf(_("Bind as user '%s' failed on server '%s'."),$this->admin,$this->connection); - } - return("".$str.""); - }else{ - if(empty($this->admin)){ - $str = sprintf(_("Anonymous bind on server '%s' succeeded."), $this->connection); - return("".$str." "._("Please specify user and password.").""); - }else{ - $str = sprintf(_("Bind as user '%s' on server '%s' succeeded."),$this->admin,$this->connection); - return("".$str.""); - } - } - } - - - function resolve_user() - { - $filter = $this->resolve_filter; - $ldap = new LDAP("","",$this->connection); - $ldap->cd($this->base); - $ldap->search("(&(objectClass=person)(|(uid=".$filter.")(cn=".$filter.")))"); - $tmp = array(); - while($attrs = $ldap->fetch()){ - $tmp[base64_encode($attrs['dn'])]= @LDAP::fix($attrs['dn']); - natcasesort($tmp); - } - return($tmp); - } - - - function save_object() - { - $reset = FALSE; - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - if(in_array($attr,array("base","connection")) && $this->$attr != get_post($attr)){ - $reset = TRUE; - } - $this->$attr = get_post($attr); - } - } - - if($reset){ - $this->parent->disable_steps_from(($this->parent->step_name_to_id(get_class($this))) +1); - $attr = @LDAP::get_naming_contexts($this->connection); - if(is_array($attr) && !in_array(get_post("base"),$attr)){ - if(isset($attr[0])){ - $this->base = $attr[0]; - } - } - } - - if(isset($_POST['resolve_user_x'])){ - $this->resolve_user = !$this->resolve_user; - } - if(isset($_POST['resolve_user'])){ - $this->resolve_user = !$this->resolve_user; - } - - /* Hide backward forward button*/ - $this->dialog = $this->resolve_user; - - if(isset($_POST['resolve_filter'])){ - $this->resolve_filter = get_post('resolve_filter'); - } - - if(isset($_POST['use_selected_user'])){ - - if(isset($_POST['admin_to_use'])){ - $this->admin = base64_decode(get_post('admin_to_use')); - $this->resolve_user = false; - } - } - - if(isset($_POST['append_base_to_admin_dn'])){ - $this->append_base_to_admin_dn = TRUE; - }else{ - $this->append_base_to_admin_dn = FALSE; - } - - if($this->append_base_to_admin_dn){ - $base = $this->base; - if(!preg_match("/,$/",$this->admin_given)){ - $base = ",".$base; - } - $this->admin = $this->admin_given.$base; - }else{ - $this->admin = $this->admin_given; - } - - $this->get_connection_status(); - if($this->bind_id && !empty($this->admin) && !empty($this->base)){ - $this->is_completed =TRUE; - }else{ - $this->is_completed =FALSE; - } - - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_License.inc b/setup/class_setupStep_License.inc deleted file mode 100644 index d46768ca6..000000000 --- a/setup/class_setupStep_License.inc +++ /dev/null @@ -1,94 +0,0 @@ -update_strings(); - } - - - function load_license() - { - if(!file_exists("../setup/license.txt")){ - $this->License = "License not found. Setup stops here."; - $this->license_found = false; - }else{ - $fp = fopen("../setup/license.txt","r"); - $this->License = ""; - while (!feof($fp)){ - $this->License .= fread($fp, 255); - } - $this->license_found = true; - } - } - - - function update_strings() - { - $this->s_title = _("License"); - $this->s_title_long = _("License"); - $this->s_info = _("Terms and conditions for usage"); - } - - - function execute() - { - $this->load_license(); - - $smarty = get_smarty(); - $smarty -> assign("License",nl2br($this->License)); - $smarty -> assign("license_found",$this->license_found); - $smarty -> assign("accepted",$this->accepted); - - return($smarty -> fetch (get_template_path("../setup/setup_license.tpl"))); - } - - - function save_object() - { - if(isset($_POST['step_license'])){ - if(isset($_POST['accepted'])){ - $this->accepted = TRUE; - }else{ - $this->accepted = FALSE; - } - } - - if($this->license_found && $this->accepted){ - $this->is_completed = true; - }else{ - $this->is_completed = false; - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Migrate.inc b/setup/class_setupStep_Migrate.inc deleted file mode 100644 index 5dcd8e649..000000000 --- a/setup/class_setupStep_Migrate.inc +++ /dev/null @@ -1,1946 +0,0 @@ -update_strings(); - } - - function update_strings() - { - $this->s_title = _("LDAP inspection"); - $this->s_title_long = _("LDAP inspection"); - $this->s_info = _("Analyze your current LDAP for GOsa compatibility"); - } - - function initialize_checks() - { - $this->checks = array(); - $this->checks['root']['TITLE'] = _("Checking for root object"); - $this->checks['root']['STATUS'] = FALSE; - $this->checks['root']['STATUS_MSG']= ""; - $this->checks['root']['ERROR_MSG'] = ""; - $this->checkBase(); - - $this->checks['permissions']['TITLE'] = _("Checking permissions on LDAP database"); - $this->checks['permissions']['STATUS'] = FALSE; - $this->checks['permissions']['STATUS_MSG']= ""; - $this->checks['permissions']['ERROR_MSG'] = ""; - $this->check_ldap_permissions(); - - $this->checks['deps_visible']['TITLE'] = _("Checking for invisible deparmtments"); - $this->checks['deps_visible']['STATUS'] = FALSE; - $this->checks['deps_visible']['STATUS_MSG']= ""; - $this->checks['deps_visible']['ERROR_MSG'] = ""; - $this->check_organizationalUnits(); - - $this->checks['users_visible']['TITLE'] = _("Checking for invisible users"); - $this->checks['users_visible']['STATUS'] = FALSE; - $this->checks['users_visible']['STATUS_MSG']= ""; - $this->checks['users_visible']['ERROR_MSG'] = ""; - $this->check_gosaAccounts(); - - $this->checks['acls']['TITLE'] = _("Checking for super administrator"); - $this->checks['acls']['STATUS'] = FALSE; - $this->checks['acls']['STATUS_MSG']= ""; - $this->checks['acls']['ERROR_MSG'] = ""; - $this->check_administrativeAccount(); - - $this->checks['outside_users']['TITLE'] = _("Checking for users outside the people tree"); - $this->checks['outside_users']['STATUS'] = FALSE; - $this->checks['outside_users']['STATUS_MSG']= ""; - $this->checks['outside_users']['ERROR_MSG'] = ""; - $this->search_outside_users(); - - $this->checks['outside_groups']['TITLE'] = _("Checking for groups outside the groups tree"); - $this->checks['outside_groups']['STATUS'] = FALSE; - $this->checks['outside_groups']['STATUS_MSG']= ""; - $this->checks['outside_groups']['ERROR_MSG'] = ""; - $this->search_outside_groups(); - - $this->checks['outside_winstations']['TITLE'] = _("Checking for windows workstations outside the winstation tree"); - $this->checks['outside_winstations']['STATUS'] = FALSE; - $this->checks['outside_winstations']['STATUS_MSG']= ""; - $this->checks['outside_winstations']['ERROR_MSG'] = ""; - $this->search_outside_winstations(); - - $this->checks['uidNumber_usage']['TITLE'] = _("Checking for duplicate uid numbers"); - $this->checks['uidNumber_usage']['STATUS'] = FALSE; - $this->checks['uidNumber_usage']['STATUS_MSG']= ""; - $this->checks['uidNumber_usage']['ERROR_MSG'] = ""; - $this->check_uidNumber(); - - $this->checks['gidNumber_usage']['TITLE'] = _("Checking for duplicate gid numbers"); - $this->checks['gidNumber_usage']['STATUS'] = FALSE; - $this->checks['gidNumber_usage']['STATUS_MSG']= ""; - $this->checks['gidNumber_usage']['ERROR_MSG'] = ""; - $this->check_gidNumber(); - } - - - /* Check if there are uidNumbers which are used more than once. - */ - function check_uidNumber() - { - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - $res = $ldap->search("uidNumber=*",array("dn","uidNumber")); - if(!$res){ - $this->checks['uidNumber_usage']['STATUS'] = FALSE; - $this->checks['uidNumber_usage']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['uidNumber_usage']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - return(false); - } - - $this->check_uidNumbers= array(); - $tmp = array(); - while($attrs = $ldap->fetch()){ - $tmp[$attrs['uidNumber'][0]][] = $attrs; - } - - foreach($tmp as $id => $entries){ - if(count($entries) > 1){ - foreach($entries as $entry){ - $this->check_uidNumbers[base64_encode($entry['dn'])] = $entry; - } - } - } - - if($this->check_uidNumbers){ - $this->checks['uidNumber_usage']['STATUS'] = FALSE; - $this->checks['uidNumber_usage']['STATUS_MSG']= ""._("Warning").""; - $this->checks['uidNumber_usage']['ERROR_MSG'] = - sprintf(_("Found %s duplicate values for attribute 'uidNumber'."),count($this->check_uidNumbers)); - return(false); - }else{ - $this->checks['uidNumber_usage']['STATUS'] = TRUE; - $this->checks['uidNumber_usage']['STATUS_MSG']= _("Ok"); - $this->checks['uidNumber_usage']['ERROR_MSG'] = ""; - return(TRUE); - } - } - - - /* Check if there are duplicated gidNumbers present in ldap - */ - function check_gidNumber() - { - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - $res = $ldap->search("(&(objectClass=posixGroup)(gidNumber=*))",array("dn","gidNumber")); - if(!$res){ - $this->checks['gidNumber_usage']['STATUS'] = FALSE; - $this->checks['gidNumber_usage']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['gidNumber_usage']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - return(false); - } - - $this->check_gidNumbers= array(); - $tmp = array(); - while($attrs = $ldap->fetch()){ - $tmp[$attrs['gidNumber'][0]][] = $attrs; - } - - foreach($tmp as $id => $entries){ - if(count($entries) > 1){ - foreach($entries as $entry){ - $this->check_gidNumbers[base64_encode($entry['dn'])] = $entry; - } - } - } - - if($this->check_gidNumbers){ - $this->checks['gidNumber_usage']['STATUS'] = FALSE; - $this->checks['gidNumber_usage']['STATUS_MSG']= ""._("Warning").""; - $this->checks['gidNumber_usage']['ERROR_MSG'] = - sprintf(_("Found %s duplicate values for attribute 'gidNumber'."),count($this->check_gidNumbers)); - return(false); - }else{ - $this->checks['gidNumber_usage']['STATUS'] = TRUE; - $this->checks['gidNumber_usage']['STATUS_MSG']= _("Ok"); - $this->checks['gidNumber_usage']['ERROR_MSG'] = ""; - return(TRUE); - } - } - - - /* Search for winstations outside the winstation ou - */ - function search_outside_winstations() - { - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Get winstation ou */ - if($cv['generic_settings']['wws_ou_active']) { - $winstation_ou = $cv['generic_settings']['ws_ou']; - }else{ - $winstation_ou = "ou=winstations"; - } - - if($cv['samba_version'] == 3){ - $oc = "sambaSamAccount"; - }else{ - $oc = "sambaAccount"; - } - - $ldap->cd($cv['base']); - $res = $ldap->search("(&(objectClass=".$oc.")(uid=*$))",array("dn","sambaSID")); - if(!$res){ - $this->checks['outside_winstations']['STATUS'] = FALSE; - $this->checks['outside_winstations']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['outside_winstations']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - return(false); - } - - $this->outside_winstations = array(); - while($attrs = $ldap->fetch()){ - if((!preg_match("/^[^,]+,".normalizePreg($winstation_ou)."/",$attrs['dn'])) && !preg_match("/,dc=addressbook,/",$attrs['dn'])){ - $attrs['selected'] = FALSE; - $attrs['ldif'] = ""; - $this->outside_winstations[base64_encode($attrs['dn'])] = $attrs; - } - } - - if(count($this->outside_winstations)){ - $this->checks['outside_winstations']['STATUS'] = FALSE; - $this->checks['outside_winstations']['STATUS_MSG']= _("Failed"); - $this->checks['outside_winstations']['ERROR_MSG'] = - sprintf(_("Found %s winstations outside the predefined winstation department ou '%s'."),count($this->outside_winstations),$winstation_ou); - $this->checks['outside_winstations']['ERROR_MSG'].= ""; - return(false); - }else{ - $this->checks['outside_winstations']['STATUS'] = TRUE; - $this->checks['outside_winstations']['STATUS_MSG']= _("Ok"); - $this->checks['outside_winstations']['ERROR_MSG'] = ""; - return(TRUE); - } - } - - - /* Search for groups outside the group ou - */ - function search_outside_groups() - { - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $group_ou = $cv['groupou']; - $ldap->cd($cv['base']); - - /*********** - * Get all gosaDepartments to be able to - * validate correct ldap tree position of every single user - ***********/ - $valid_deps = array(); - $valid_deps['/'] = $cv['base']; - $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn","ou")); - while($attrs = $ldap->fetch()){ - $valid_deps[] = $attrs['dn']; - } - - /*********** - * Get all groups - ***********/ - $res = $ldap->search("(objectClass=posixGroup)",array("dn")); - if(!$res){ - $this->checks['outside_groups']['STATUS'] = FALSE; - $this->checks['outside_groups']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['outside_groups']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - return(false); - } - - $this->outside_groups = array(); - while($attrs = $ldap->fetch()){ - $group_db_base = preg_replace("/^[^,]+,".normalizePreg($group_ou)."+,/i","",$attrs['dn']); - - /* Check if entry is not an addressbook only user - * and verify that he is in a valid department - */ - if( !preg_match("/".normalizePreg("dc=addressbook,")."/",$group_db_base) && - !in_array($group_db_base,$valid_deps) - ){ - $attrs['selected'] = FALSE; - $attrs['ldif'] = ""; - $this->outside_groups[base64_encode($attrs['dn'])] = $attrs; - } - } - - if(count($this->outside_groups)){ - $this->checks['outside_groups']['STATUS'] = FALSE; - $this->checks['outside_groups']['STATUS_MSG']= ""._("Warning").""; - $this->checks['outside_groups']['ERROR_MSG'] = - sprintf(_("Found %s groups outside the configured tree '%s'."),count($this->outside_groups),$group_ou); - $this->checks['outside_groups']['ERROR_MSG'].= " "; - return(false); - }else{ - $this->checks['outside_groups']['STATUS'] = TRUE; - $this->checks['outside_groups']['STATUS_MSG']= _("Ok"); - $this->checks['outside_groups']['ERROR_MSG'] = ""; - return(TRUE); - } - } - - /* Search for users outside the people ou - */ - function search_outside_users() - { - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - - - /*********** - * Get all gosaDepartments to be able to - * validate correct ldap tree position of every single user - ***********/ - $valid_deps = array(); - $valid_deps['/'] = $cv['base']; - $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn","ou")); - while($attrs = $ldap->fetch()){ - $valid_deps[] = $attrs['dn']; - } - - /*********** - * Search for all users - ***********/ - $res = $ldap->search("(&(objectClass=gosaAccount)(!(uid=*$)))",array("dn")); - if(!$res){ - $this->checks['outside_users']['STATUS'] = FALSE; - $this->checks['outside_users']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['outside_users']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - return(false); - } - - /*********** - * Check if returned users are within a valid GOsa deparmtment. (peopleou,gosaDepartment,base) - ***********/ - $this->outside_users = array(); - $people_ou = trim($cv['peopleou']); - if(!empty($people_ou)){ - $people_ou = $people_ou.","; - } - - while($attrs = $ldap->fetch()){ - $people_db_base = preg_replace("/^[^,]+,".normalizePreg($people_ou)."/i","",$attrs['dn']); - - /* Check if entry is not an addressbook only user - * and verify that he is in a valid department - */ - if( !preg_match("/".normalizePreg("dc=addressbook,")."/",$people_db_base) && - !in_array($people_db_base,$valid_deps) - ){ - $attrs['selected'] = FALSE; - $attrs['ldif'] = ""; - $this->outside_users[base64_encode($attrs['dn'])] = $attrs; - } - } - - if(count($this->outside_users)){ - $this->checks['outside_users']['STATUS'] = FALSE; - $this->checks['outside_users']['STATUS_MSG']= ""._("Warning").""; - $this->checks['outside_users']['ERROR_MSG'] = - sprintf(_("Found %s user(s) outside the configured tree '%s'."),count($this->outside_users),$people_ou); - $this->checks['outside_users']['ERROR_MSG'].= ""; - return(false); - }else{ - $this->checks['outside_users']['STATUS'] = TRUE; - $this->checks['outside_users']['STATUS_MSG']= _("Ok"); - $this->checks['outside_users']['ERROR_MSG'] = ""; - return(TRUE); - } - } - - - /* Check ldap accessibility - * Create and remove a dummy object, - * to ensure that we have the necessary permissions - */ - function check_ldap_permissions() - { - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Create dummy entry - */ - $name = "GOsa_setup_text_entry_".session_id().rand(0,999999); - $dn = "ou=".$name.",".$cv['base']; - $testEntry= array(); - $testEntry['objectClass'][]= "top"; - $testEntry['objectClass'][]= "organizationalUnit"; - $testEntry['objectClass'][]= "gosaDepartment"; - $testEntry['description']= "Created by GOsa setup, this object can be removed."; - $testEntry['ou'] = $name; - - /* check if simple ldap cat will be successful - */ - $res = $ldap->cat($cv['base']); - if(!$res){ - $this->checks['permissions']['STATUS'] = FALSE; - $this->checks['permissions']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['permissions']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - return(false); - } - - /* Try to create dummy object - */ - $ldap->cd ($dn); - $ldap->create_missing_trees($dn); - $res = $ldap->add($testEntry); - $ldap->cat($dn); - if(!$ldap->count()){ - new log("view","setup/".get_class($this),$dn,array(),$ldap->get_error()); - - $this->checks['permissions']['STATUS'] = FALSE; - $this->checks['permissions']['STATUS_MSG']= _("Failed"); - $this->checks['permissions']['ERROR_MSG'] = - sprintf(_("The specified user '%s' does not have full access to your ldap database."),$cv['admin']); - return(false); - } - - /* Try to remove created entry - */ - $res = $ldap->rmDir($dn); - $ldap->cat($dn); - if($ldap->count()){ - new log("view","setup/".get_class($this),$dn,array(),$ldap->get_error()); - $this->checks['permissions']['STATUS'] = FALSE; - $this->checks['permissions']['STATUS_MSG']= _("Failed"); - $this->checks['permissions']['ERROR_MSG'] = - sprintf(_("The specified user '%s' does not have full access to your ldap database."),$cv['admin']); - return(false); - } - - /* Create & remove of dummy object was successful */ - $this->checks['permissions']['STATUS'] = TRUE; - $this->checks['permissions']['STATUS_MSG']= _("Ok"); - $this->checks['permissions']['ERROR_MSG'] = ""; - return(true); - } - - - /* Check if there are users which will - * be invisible for GOsa - */ - function check_gosaAccounts() - { - /* Remember old list of ivisible users, to be able to set - * the 'html checked' status for the checkboxes again - */ - $cnt_ok = 0; - $old = $this->users_to_migrate; - $this->users_to_migrate = array(); - - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Get all invisible users - */ - $ldap->cd($cv['base']); - $res =$ldap->search("(&(|(objectClass=posixAccount)(&(objectClass=inetOrgPerson)(objectClass=organizationalPerson)))(!(objectClass=gosaAccount))(uid=*))",array("sn","givenName","cn","uid")); - while($attrs = $ldap->fetch()){ - if(!preg_match("/,dc=addressbook,/",$attrs['dn'])){ - $attrs['checked'] = FALSE; - $attrs['before'] = ""; - $attrs['after'] = ""; - - /* Set objects to selected, that were selected before reload */ - if(isset($old[base64_encode($attrs['dn'])])){ - $attrs['checked'] = $old[base64_encode($attrs['dn'])]['checked']; - } - $this->users_to_migrate[base64_encode($attrs['dn'])] = $attrs; - } - } - - /* No invisible */ - if(!$res){ - $this->checks['users_visible']['STATUS'] = FALSE; - $this->checks['users_visible']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['users_visible']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - }elseif(count($this->users_to_migrate) == 0){ - $this->checks['users_visible']['STATUS'] = TRUE; - $this->checks['users_visible']['STATUS_MSG']= _("Ok"); - $this->checks['users_visible']['ERROR_MSG'] = ""; - }else{ - $this->checks['users_visible']['STATUS'] = FALSE; - $this->checks['users_visible']['STATUS_MSG']= ""._("Warning").""; - $this->checks['users_visible']['ERROR_MSG'] = sprintf(_("Found %s user(s) that will not be visible in GOsa."), - count($this->users_to_migrate)); - $this->checks['users_visible']['ERROR_MSG'] .= ""; - } - } - - - /* Start user account migration - */ - function migrate_gosaAccounts($only_ldif = FALSE) - { - $this->show_details= $only_ldif; - - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Add gosaAccount objectClass to the selected users - */ - foreach($this->users_to_migrate as $key => $dep){ - if($dep['checked']){ - - /* Get old objectClasses */ - $ldap->cat($dep['dn'],array("objectClass")); - $attrs = $ldap->fetch(); - - /* Create new objectClass array */ - $new_attrs = array(); - $new_attrs['objectClass']= array("gosaAccount","inetOrgPerson","organizationalPerson"); - for($i = 0 ; $i < $attrs['objectClass']['count']; $i ++ ){ - if(!in_array_ics($attrs['objectClass'][$i], $new_attrs['objectClass'])){ - $new_attrs['objectClass'][] = $attrs['objectClass'][$i]; - } - } - - /* Set info attributes for current object, - * or write changes to the ldap database - */ - if($only_ldif){ - $this->users_to_migrate[$key]['before'] = $this->array_to_ldif($attrs); - $this->users_to_migrate[$key]['after'] = $this->array_to_ldif($new_attrs); - }else{ - $ldap->cd($attrs['dn']); - if(!$ldap->modify($new_attrs)){ - print_red(sprintf(_("Failed to migrate the department '%s' into GOsa, error message is as follows '%s'."),$attrs['dn'],$ldap->get_error())); - return(false); - } - } - } - } - return(TRUE); - } - - - /* Check if there are invisible organizational Units - */ - function check_organizationalUnits() - { - $cnt_ok = 0; - $old = $this->deps_to_migrate; - $this->deps_to_migrate = array(); - - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Skip GOsa internal departments */ - $skip_dns = array("/".$cv['peopleou']."/","/".$cv['groupou']."/","/^ou=people,/","/^ou=groups,/", - "/(,|)ou=configs,/","/(,|)ou=systems,/", - "/(,|)ou=apps,/","/(,|)ou=mime,/","/(,|)ou=devices/","/^ou=aclroles,/","/^ou=incoming,/", - "/ou=snapshots,/","/(,|)dc=addressbook,/","/^(,|)ou=machineaccounts,/", - "/(,|)ou=winstations,/"); - - /* Get all invisible departments */ - $ldap->cd($cv['base']); - $res = $ldap->search("(&(objectClass=organizationalUnit)(!(objectClass=gosaDepartment)))",array("ou","description","dn")); - while($attrs = $ldap->fetch()){ - $attrs['checked'] = FALSE; - $attrs['before'] = ""; - $attrs['after'] = ""; - - /* Set objects to selected, that were selected before reload */ - if(isset($old[base64_encode($attrs['dn'])])){ - $attrs['checked'] = $old[base64_encode($attrs['dn'])]['checked']; - } - $this->deps_to_migrate[base64_encode($attrs['dn'])] = $attrs; - } - - /* Filter returned list of departments and ensure that - * GOsa internal departments will not be listed - */ - foreach($this->deps_to_migrate as $key => $attrs){ - $dn = $attrs['dn']; - $skip = false;; - foreach($skip_dns as $skip_dn){ - if(preg_match($skip_dn,$dn)){ - $skip = true; - } - } - if($skip){ - unset($this->deps_to_migrate[$key]); - } - } - - /* If we have no invisible departments found - * tell the user that everything is ok - */ - if(!$res){ - $this->checks['deps_visible']['STATUS'] = FALSE; - $this->checks['deps_visible']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['deps_visible']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - }elseif(count($this->deps_to_migrate) == 0 ){ - $this->checks['deps_visible']['STATUS'] = TRUE; - $this->checks['deps_visible']['STATUS_MSG']= _("Ok"); - $this->checks['deps_visible']['ERROR_MSG'] = ""; - }else{ - $this->checks['deps_visible']['STATUS'] = TRUE; - $this->checks['deps_visible']['STATUS_MSG']= ''._("Warning").''; - $this->checks['deps_visible']['ERROR_MSG'] = sprintf(_("Found %s department(s) that will not be visible in GOsa."),count($this->deps_to_migrate)); - $this->checks['deps_visible']['ERROR_MSG'] .= " "; - } - } - - - - /* Start deparmtment migration */ - function migrate_organizationalUnits($only_ldif = FALSE) - { - $this->show_details= $only_ldif; - - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Add gosaDepartment objectClass to each selected entry - */ - foreach($this->deps_to_migrate as $key => $dep){ - if($dep['checked']){ - - /* Get current objectClasses */ - $ldap->cat($dep['dn'],array("objectClass","description")); - $attrs = $ldap->fetch(); - - /* Create new objectClass attribute including gosaDepartment*/ - $new_attrs = array(); - for($i = 0 ; $i < $attrs['objectClass']['count']; $i ++ ){ - $new_attrs['objectClass'][] = $attrs['objectClass'][$i]; - } - $new_attrs['objectClass'][] = "gosaDepartment"; - - /* Append description it is missing */ - if(!isset($attrs['description'])){ - $new_attrs['description'][] = "GOsa department"; - } - - /* Depending on the parameter >only_diff< we save the changes as ldif - * or we write our changes directly to the ldap database - */ - if($only_ldif){ - $this->deps_to_migrate[$key]['before'] = $this->array_to_ldif($attrs); - $this->deps_to_migrate[$key]['after'] = $this->array_to_ldif($new_attrs); - }else{ - $ldap->cd($attrs['dn']); - if(!$ldap->modify($new_attrs)){ - print_red(sprintf(_("Failed to migrate the department '%s' into GOsa, error message is as follows '%s'."),$attrs['dn'],$ldap->get_error())); - return(false); - } - } - } - } - return(TRUE); - } - - - /* Check Acls if there is at least one object with acls defined - */ - function check_administrativeAccount() - { - /* Establish ldap connection */ - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Search for gosaAcls */ - $ldap->cd($cv['base']); - $res = $ldap->cat($cv['base']); - - if(!$res){ - $this->checks['acls']['STATUS'] = FALSE; - $this->checks['acls']['STATUS_MSG']= _("LDAP query failed"); - $this->checks['acls']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); - }else{ - $found = false; - $username = ""; - $attrs = $ldap->fetch(); - if(isset($attrs['gosaAclEntry'])){ - $acls = $attrs['gosaAclEntry']; - for($i = 0 ; $i < $acls['count'] ; $i++){ - $acl = $acls[$i]; - $tmp = split(":",$acl); - if($tmp[1] == "psub"){ - $members = split(",",$tmp[2]); - foreach($members as $member){ - $member = base64_decode($member); - - /* Check if acl owner is a valid GOsa user account */ - $ldap->cat($member,array("objectClass","uid","cn")); - $ret = $ldap->fetch(); - - if(isset($ret['objectClass']) && in_array("posixGroup",$ret['objectClass'])){ - $found = TRUE; - $username .= "ACL-Group: ".$ret['cn'][0]."
"; - }elseif(isset($ret['objectClass']) && in_array("gosaAccount",$ret['objectClass']) && - in_array("organizationalPerson",$ret['objectClass']) && - in_array("inetOrgPerson",$ret['objectClass'])){ - $found = TRUE; - $username .= "ACL: ".$ret['uid'][0]."
"; - } - } - }elseif($tmp[1] == "role"){ - - /* Check if acl owner is a valid GOsa user account */ - $ldap->cat(base64_decode($tmp[2]),array("gosaAclTemplate")); - $ret = $ldap->fetch(); - - if(isset($ret['gosaAclTemplate'])){ - $cnt = $ret['gosaAclTemplate']['count']; - for($e = 0 ; $e < $cnt ; $e++){ - - $a_str = $ret['gosaAclTemplate'][$e]; - if(preg_match("/^[0-9]*:psub:/",$a_str) && preg_match("/:all;cmdrw$/",$a_str)){ - - $members = split(",",$tmp[3]); - foreach($members as $member){ - $member = base64_decode($member); - - /* Check if acl owner is a valid GOsa user account */ - $ldap->cat($member,array("objectClass","uid")); - $ret = $ldap->fetch(); - - if(isset($ret['objectClass']) && in_array("gosaAccount",$ret['objectClass']) && - in_array("organizationalPerson",$ret['objectClass']) && - in_array("inetOrgPerson",$ret['objectClass'])){ - $found = TRUE; - $username .= "ACL Role: ".$ret['uid'][0]."
"; - } - } - } - } - } - } - } - } - - # For debugging - #echo $username; - - if($found){ - $this->checks['acls']['STATUS'] = TRUE; - $this->checks['acls']['STATUS_MSG']= _("Ok"); - $this->checks['acls']['ERROR_MSG'] = ""; - }else{ - $this->checks['acls']['STATUS'] = FALSE; - $this->checks['acls']['STATUS_MSG']= _("Failed"); - $this->checks['acls']['ERROR_MSG']= _("There is no GOsa administrator account inside your LDAP.")." "; - $this->checks['acls']['ERROR_MSG'].= ""; - } - } - return($ldap->count()>=1); - } - - - - function create_admin($only_ldif = FALSE) - { - /* Reset '' */ - $this->acl_create_changes=""; - - /* Object that should receive admin acls */ - $dn = $this->acl_create_selected; - - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Get current base attributes */ - $ldap->cd($cv['base']); - $ldap->cat($cv['base'],array("dn","objectClass","gosaAclEntry")); - $attrs = $ldap->fetch(); - - /* Add acls for the selcted user to the base */ - $attrs_new['objectClass'] = array("gosaACL"); - - for($i = 0; $i < $attrs['objectClass']['count']; $i ++){ - if(!in_array_ics($attrs['objectClass'][$i],$attrs_new['objectClass'])){ - $attrs_new['objectClass'][] = $attrs['objectClass'][$i]; - } - } - - $acl = "0:psub:".base64_encode($dn).":all;cmdrw"; - $attrs_new['gosaAclEntry'][] = $acl; - if(isset($attrs['gosaAclEntry'])){ - for($i = 0 ; $i < $attrs['gosaAclEntry']['count']; $i ++){ - - $prio = preg_replace("/[:].*$/","",$attrs['gosaAclEntry'][$i]); - $rest = preg_replace("/^[^:]/","",$attrs['gosaAclEntry'][$i]); - - $data = ($prio+1).$rest; - $attrs_new['gosaAclEntry'][] = $data; - } - } - - if($only_ldif){ - $this->acl_create_changes ="\n".($ldap->fix($cv['base']))."\n"; - $this->acl_create_changes.=$this->array_to_ldif($attrs)."\n"; - $this->acl_create_changes.="\n".($ldap->fix($cv['base']))."\n"; - $this->acl_create_changes.=$this->array_to_ldif($attrs_new); - }else{ - - $ldap->cd($cv['base']); - if(!$ldap->modify($attrs_new)){ - print_red(sprintf(_("Adding acls for user '%s' failed, ldap says '%s'."),$dn,$ldap->get_error())); - return(FALSE); - }else{ - return(TRUE); - } - } - } - - - function create_admin_user() - { - $pw1 = $pw2 = ""; - $uid = ""; - - if(isset($_POST['new_user_uid'])){ - $uid = $_POST['new_user_uid']; - } - if(isset($_POST['new_user_password'])){ - $pw1 = $_POST['new_user_password']; - } - if(isset($_POST['new_user_password2'])){ - $pw2 = $_POST['new_user_password2']; - } - - if(empty($pw1) || empty($pw2) | ($pw1 != $pw2)){ - print_red(_("Specified passwords are empty or not equal.")); - return false; - } - - if(!is_uid($uid) || empty($uid)){ - print_red(_("Please specify a valid uid.")); - return false; - } - - - /* Establish ldap connection */ - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Get current base attributes */ - $ldap->cd($cv['base']); - - $people_ou = trim($cv['peopleou']); - if(!empty($people_ou)){ - $people_ou = trim($people_ou).","; - } - - if($cv['peopledn'] == "cn"){ - $dn = "cn=System Administrator,".$people_ou.$cv['base']; - }else{ - $dn = "uid=".$uid.",".$people_ou.$cv['base']; - } - - $methods = @passwordMethod::get_available_methods(); - $p_m = $methods[$cv['encryption']]; - $p_c = new $p_m(array()); - $hash = $p_c->generate_hash($pw2); - - $new_user=array(); - $new_user['objectClass']= array("top","person","gosaAccount","organizationalPerson","inetOrgPerson"); - $new_user['givenName'] = "System"; - $new_user['sn'] = "Administrator"; - $new_user['cn'] = "System Administrator"; - $new_user['uid'] = $uid; - $new_user['userPassword'] = $hash; - - $ldap->cd($cv['base']); - - $ldap->cat($dn,array("dn")); - if($ldap->count()){ - print_red(sprintf(_("Could not add administrative user, there is already an object with the same dn '%s' in your ldap database."),$dn)); - return(FALSE); - } - - $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$dn)); - $ldap->cd($dn); - $res = $ldap->add($new_user); - $this->acl_create_selected = $dn; - $this->create_admin(); - - if(!$res){ - print_red($ldap->get_error()); - return(FALSE); - } - - $this->acl_create_dialog=FALSE; - $this->check_administrativeAccount(); - return(TRUE); - } - - - function migrate_outside_winstations($perform = FALSE) - { - /* Establish ldap connection */ - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - - /* Check if there was a destination department posted */ - if(isset($_POST['move_winstation_to'])){ - $destination_dep = $_POST['move_winstation_to']; - }else{ - print_red(_("Couldn't move users to specified department.")); - return(false); - } - - foreach($this->outside_winstations as $b_dn => $data){ - $this->outside_winstations[$b_dn]['ldif'] =""; - if($data['selected']){ - $dn = base64_decode($b_dn); - $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn); - if(!$perform){ - $this->outside_winstations[$b_dn]['ldif'] = _("Winstation will be moved from").":
\t".($ldap->fix($dn))."
"._("to").":
\t".($ldap->fix($d_dn)); - - - /* Check if there are references to this object */ - $ldap->search("(&(member=".$dn.")(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))",array('dn')); - $refs = ""; - while($attrs = $ldap->fetch()){ - $ref_dn = $attrs['dn']; - $refs .= "
\t".$ref_dn; - } - if(!empty($refs)){ - $this->outside_winstations[$b_dn]['ldif'] .= "

"._("Updating following references too").":".$refs; - } - - }else{ - $this->move($dn,$d_dn); - } - } - } - } - - - function migrate_outside_groups($perform = FALSE) - { - /* Establish ldap connection */ - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - - /* Check if there was a destination department posted */ - if(isset($_POST['move_group_to'])){ - $destination_dep = $_POST['move_group_to']; - }else{ - print_red(_("Couldn't move users to specified department.")); - return(false); - } - - foreach($this->outside_groups as $b_dn => $data){ - $this->outside_groups[$b_dn]['ldif'] =""; - if($data['selected']){ - $dn = base64_decode($b_dn); - $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn); - if(!$perform){ - - $this->outside_groups[$b_dn]['ldif'] = _("Group will be moved from").":
\t".($ldap->fix($dn))."
"._("to").":
\t".($ldap->fix($d_dn)); - - /* Check if there are references to this object */ - $ldap->search("(&(member=".$dn.")(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))",array('dn')); - $refs = ""; - while($attrs = $ldap->fetch()){ - $ref_dn = $attrs['dn']; - $refs .= "
\t".$ref_dn; - } - if(!empty($refs)){ - $this->outside_groups[$b_dn]['ldif'] .= "

"._("Updating following references too").":".$refs; - } - - }else{ - $this->move($dn,$d_dn); - } - } - } - } - - - function migrate_outside_users($perform = FALSE) - { - /* Establish ldap connection */ - $cv = $this->parent->captured_values; - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - - /* Check if there was a destination department posted */ - if(isset($_POST['move_user_to'])){ - $destination_dep = $_POST['move_user_to']; - }else{ - print_red(_("Couldn't move users to specified department.")); - return(false); - } - - foreach($this->outside_users as $b_dn => $data){ - $this->outside_users[$b_dn]['ldif'] =""; - if($data['selected']){ - $dn = base64_decode($b_dn); - $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn); - if(!$perform){ - $this->outside_users[$b_dn]['ldif'] = _("User will be moved from").":
\t".($ldap->fix($dn))."
"._("to").":
\t".($ldap->fix($d_dn)); - - /* Check if there are references to this object */ - $ldap->search("(&(member=".$dn.")(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))",array('dn')); - $refs = ""; - while($attrs = $ldap->fetch()){ - $ref_dn = $attrs['dn']; - $refs .= "
\t".$ref_dn; - } - if(!empty($refs)){ - $this->outside_users[$b_dn]['ldif'] .= "

"._("The following references will be updated").":".$refs; - } - - }else{ - $this->move($dn,$d_dn); - } - } - } - } - - - function execute() - { - /* Initialise checks if this is the first call */ - if(!$this->checks_initialised || isset($_POST['reload'])){ - $this->initialize_checks(); - $this->checks_initialised = TRUE; - } - - /************* - * Winstations outside the group ou - *************/ - - if(isset($_POST['outside_winstations_dialog_cancel'])){ - $this->outside_winstations_dialog = FALSE; - $this->dialog = FALSE; - $this->show_details = FALSE; - } - - if(isset($_POST['outside_winstations_dialog_whats_done'])){ - $this->migrate_outside_winstations(FALSE); - } - - if(isset($_POST['outside_winstations_dialog_perform'])){ - $this->migrate_outside_winstations(TRUE); - $this->search_outside_winstations(); - $this->dialog = FALSE; - $this->show_details = FALSE; - $this->outside_winstations_dialog = FALSE; - } - - if(isset($_POST['outside_winstations_dialog'])){ - $this->outside_winstations_dialog = TRUE; - $this->dialog = TRUE; - } - - if($this->outside_winstations_dialog){ - - /* Fix displayed dn syntax */ - $tmp = $this->outside_winstations; - foreach($tmp as $key => $data){ - $tmp[$key]['dn'] = @LDAP::fix($data['dn']); - } - - $smarty = get_smarty(); - $smarty->assign("ous",$this->get_all_winstation_ous()); - $smarty->assign("method","outside_winstations"); - $smarty->assign("outside_winstations",$tmp); - return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); - } - /************* - * Groups outside the group ou - *************/ - - if(isset($_POST['outside_groups_dialog_cancel'])){ - $this->outside_groups_dialog = FALSE; - $this->show_details = FALSE; - $this->dialog = FALSE; - } - - if(isset($_POST['outside_groups_dialog_whats_done'])){ - $this->show_details= TRUE; - $this->migrate_outside_groups(FALSE); - } - - if(isset($_POST['outside_groups_dialog_refresh'])){ - $this->show_details= FALSE; - } - - if(isset($_POST['outside_groups_dialog_perform'])){ - $this->migrate_outside_groups(TRUE); - $this->dialog = FALSE; - $this->show_details = FALSE; - $this->outside_groups_dialog = FALSE; - $this->initialize_checks(); - } - - if(isset($_POST['outside_groups_dialog'])){ - $this->outside_groups_dialog = TRUE; - $this->dialog = TRUE; - } - - if($this->outside_groups_dialog){ - - /* Fix displayed dn syntax */ - $tmp = $this->outside_groups; - foreach($tmp as $key => $data){ - $tmp[$key]['dn'] = @LDAP::fix($data['dn']); - } - - $smarty = get_smarty(); - $smarty->assign("ous",$this->get_all_group_ous()); - $smarty->assign("method","outside_groups"); - $smarty->assign("outside_groups",$tmp); - $smarty->assign("group_details", $this->show_details); - return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); - } - - /************* - * User outside the people ou - *************/ - - if(isset($_POST['outside_users_dialog_cancel'])){ - $this->outside_users_dialog = FALSE; - $this->dialog = FALSE; - $this->show_details = FALSE; - } - - if(isset($_POST['outside_users_dialog_whats_done'])){ - $this->show_details= TRUE; - $this->migrate_outside_users(FALSE); - } - - if(isset($_POST['outside_users_dialog_perform'])){ - $this->migrate_outside_users(TRUE); - $this->initialize_checks(); - $this->dialog = FALSE; - $this->show_details = FALSE; - $this->outside_users_dialog = FALSE; - } - - if (isset($_POST['outside_users_dialog_refresh'])){ - $this->show_details= FALSE; - } - - if(isset($_POST['outside_users_dialog'])){ - $this->outside_users_dialog = TRUE; - $this->dialog = TRUE; - } - - if($this->outside_users_dialog){ - - /* Fix displayed dn syntax */ - $tmp = $this->outside_users; - foreach($tmp as $key => $data){ - $tmp[$key]['dn'] = @LDAP::fix($data['dn']); - } - - $smarty = get_smarty(); - $smarty->assign("ous",$this->get_all_people_ous()); - $smarty->assign("method","outside_users"); - $smarty->assign("outside_users",$tmp); - $smarty->assign("user_details", $this->show_details); - return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); - } - - /************* - * Root object check - *************/ - - if(isset($_POST['retry_root_create'])){ - - $state = $this->checks['root']['STATUS']; - $this->checkBase(FALSE); - if($state != $this->checks['root']['STATUS']){ - $this->initialize_checks(); - } - } - - /************* - * User Migration handling - *************/ - - if(isset($_POST['retry_acls'])){ - $this->check_administrativeAccount(); - } - - if(isset($_POST['create_acls'])){ - $this->acl_create_dialog = TRUE; - $this->dialog = TRUE; - } - - if(isset($_POST['create_acls_cancel'])){ - $this->acl_create_dialog = FALSE; - $this->dialog = FALSE; - $this->show_details = FALSE; - } - -# if(isset($_POST['create_acls_create_confirmed'])){ -# if($this->create_admin()){ -# $this->acl_create_dialog = FALSE; -# $this->dialog = FALSE; -# $this->show_details = FALSE; -# $this->initialize_checks(); -# } -# } - - if(isset($_POST['create_acls_create'])){ - $this->create_admin(TRUE); - } - - if(isset($_POST['create_admin_user'])){ - if($this->create_admin_user()){ - $this->dialog = FALSE; - $this->show_details = FALSE; - } - } - - if($this->acl_create_dialog){ - $smarty = get_smarty(); - - $uid = "admin"; - if(isset($_POST['new_user_uid'])){ - $uid = $_POST['new_user_uid']; - } - - $smarty->assign("new_user_uid",$uid); - $smarty->assign("new_user_password",@$_POST['new_user_password']); - $smarty->assign("new_user_password2",@$_POST['new_user_password2']); - $smarty->assign("method","create_acls"); - $smarty->assign("acl_create_selected",$this->acl_create_selected); - $smarty->assign("what_will_be_done_now",$this->acl_create_changes); - return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); - } - - /************* - * User Migration handling - *************/ - - /* Refresh list of deparments */ - if(isset($_POST['users_visible_migrate_refresh'])){ - $this->check_gosaAccounts(); - } - - /* Open migration dialog */ - if(isset($_POST['users_visible_migrate'])){ - $this->show_details= FALSE; - $this->users_migration_dialog = TRUE; - $this->dialog =TRUE; - } - - /* Close migration dialog */ - if(isset($_POST['users_visible_migrate_close'])){ - $this->users_migration_dialog = FALSE; - $this->dialog =FALSE; - $this->show_details = FALSE; - } - - /* Start migration */ - if(isset($_POST['users_visible_migrate_migrate'])){ - if($this->migrate_gosaAccounts()){ - $this->initialize_checks(); - $this->dialog = FALSE; - $this->show_details = FALSE; - $this->users_migration_dialog = FALSE; - } - } - - /* Start migration */ - if(isset($_POST['users_visible_migrate_whatsdone'])){ - $this->migrate_gosaAccounts(TRUE); - } - - /* Display migration dialog */ - if($this->users_migration_dialog){ - - /* Fix displayed dn syntax */ - $tmp = $this->users_to_migrate; - foreach($tmp as $key => $data){ - $tmp[$key]['dn'] = @LDAP::fix($data['dn']); - } - - $smarty = get_smarty(); - $smarty->assign("users_to_migrate",$tmp); - $smarty->assign("method","migrate_users"); - $smarty->assign("user_details", $this->show_details); - return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); - } - - - /************* - * Department Migration handling - *************/ - - /* Refresh list of deparments */ - if(isset($_POST['deps_visible_migrate_refresh'])){ - $this->check_organizationalUnits(); - $this->show_details= FALSE; - } - - /* Open migration dialog */ - if(isset($_POST['deps_visible_migrate'])){ - $this->dep_migration_dialog = TRUE; - $this->dialog =TRUE; - } - - /* Close migration dialog */ - if(isset($_POST['deps_visible_migrate_close'])){ - $this->dep_migration_dialog = FALSE; - $this->dialog =FALSE; - $this->show_details = FALSE; - } - - /* Start migration */ - if(isset($_POST['deps_visible_migrate_migrate'])){ - if($this->migrate_organizationalUnits()){ - $this->show_details= FALSE; - $this->check_organizationalUnits(); - $this->dialog = FALSE; - $this->dep_migration_dialog = FALSE; - } - } - - /* Start migration */ - if(isset($_POST['deps_visible_migrate_whatsdone'])){ - $this->migrate_organizationalUnits(TRUE); - } - - /* Display migration dialog */ - if($this->dep_migration_dialog){ - $smarty = get_smarty(); - - /* Fix displayed dn syntax */ - $tmp = $this->deps_to_migrate; - foreach($tmp as $key => $data){ - $tmp[$key]['dn'] = @LDAP::fix($data['dn']); - } - - $smarty->assign("deps_to_migrate",$tmp); - $smarty->assign("method","migrate_deps"); - $smarty->assign("deps_details", $this->show_details); - return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); - } - - $smarty = get_smarty(); - $smarty->assign("checks",$this->checks); - $smarty->assign("method","default"); - return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); - } - - - function save_object() - { - $this->is_completed= TRUE; - - /* Capture all selected winstations from outside_winstations_dialog */ - if($this->outside_winstations_dialog){ - foreach($this->outside_winstations as $dn => $data){ - if(isset($_POST['select_winstation_'.$dn])){ - $this->outside_winstations[$dn]['selected'] = TRUE; - }else{ - $this->outside_winstations[$dn]['selected'] = FALSE; - } - } - } - - /* Capture all selected groups from outside_groups_dialog */ - if($this->outside_groups_dialog){ - foreach($this->outside_groups as $dn => $data){ - if(isset($_POST['select_group_'.$dn])){ - $this->outside_groups[$dn]['selected'] = TRUE; - }else{ - $this->outside_groups[$dn]['selected'] = FALSE; - } - } - } - - /* Capture all selected users from outside_users_dialog */ - if($this->outside_users_dialog){ - foreach($this->outside_users as $dn => $data){ - if(isset($_POST['select_user_'.$dn])){ - $this->outside_users[$dn]['selected'] = TRUE; - }else{ - $this->outside_users[$dn]['selected'] = FALSE; - } - } - } - - /* Get "create acl" dialog posts */ - if($this->acl_create_dialog){ - - if(isset($_POST['create_acls_create_abort'])){ - $this->acl_create_selected = ""; - } - } - - /* Get selected departments */ - if($this->dep_migration_dialog){ - foreach($this->deps_to_migrate as $id => $data){ - if(isset($_POST['migrate_'.$id])){ - $this->deps_to_migrate[$id]['checked'] = TRUE; - }else{ - $this->deps_to_migrate[$id]['checked'] = FALSE; - } - } - } - - /* Get selected users */ - if($this->users_migration_dialog){ - foreach($this->users_to_migrate as $id => $data){ - if(isset($_POST['migrate_'.$id])){ - $this->users_to_migrate[$id]['checked'] = TRUE; - }else{ - $this->users_to_migrate[$id]['checked'] = FALSE; - } - } - } - } - - - /* Check if the root object exists. - * If the parameter just_check is true, then just check if the - * root object is missing and update the info messages. - * If the Parameter is false, try to create a new root object. - */ - function checkBase($just_check = TRUE) - { - /* Get collected setup informations */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Check if root object exists */ - $ldap->cd($cv['base']); - $res = $ldap->search("(objectClass=*)"); - $err = ldap_errno($ldap->cid); - - if( !$res || - $err == 0x20 || # LDAP_NO_SUCH_OBJECT - $err == 0x40) { # LDAP_NAMING_VIOLATION - - /* Root object doesn't exists - */ - if($just_check){ - $this->checks['root']['STATUS'] = FALSE; - $this->checks['root']['STATUS_MSG']= _("Failed"); - $this->checks['root']['ERROR_MSG'] = _("The LDAP root object is missing. It is required to use your LDAP service.").' '; - $this->checks['root']['ERROR_MSG'].= ""; - return(FALSE); - }else{ - - /* Add root object */ - $ldap->cd($cv['base']); - $res = $ldap->create_missing_trees($cv['base']); - - /* If adding failed, tell the user */ - if(!$res){ - $this->checks['root']['STATUS'] = FALSE; - $this->checks['root']['STATUS_MSG']= _("Failed"); - $this->checks['root']['ERROR_MSG'] = _("Root object couldn't be created, you should try it on your own."); - $this->checks['root']['ERROR_MSG'].= " "; - return($res);; - } - } - } - - /* Create & remove of dummy object was successful */ - $this->checks['root']['STATUS'] = TRUE; - $this->checks['root']['STATUS_MSG']= _("Ok"); - } - - - /* Return ldif information for a - * given attribute array - */ - function array_to_ldif($atts) - { - $ret = ""; - unset($atts['count']); - unset($atts['dn']); - foreach($atts as $name => $value){ - if(is_numeric($name)) { - continue; - } - if(is_array($value)){ - unset($value['count']); - foreach($value as $a_val){ - $ret .= $name.": ". $a_val."\n"; - } - }else{ - $ret .= $name.": ". $value."\n"; - } - } - return(preg_replace("/\n$/","",$ret)); - } - - - function get_user_list() - { - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - $ldap->search("(objectClass=gosaAccount)",array("dn")); - - $tmp = array(); - while($attrs = $ldap->fetch()){ - $tmp[base64_encode($attrs['dn'])] = @LDAP::fix($attrs['dn']); - } - return($tmp); - } - - - function get_all_people_ous() - { - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - $people_ou = trim($cv['peopleou']); - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - - /***************** - * If people ou is NOT empty - * search for for all objects matching the given container - *****************/ - if(!empty($people_ou)){ - $ldap->search("(".$people_ou.")",array("dn")); - - /* Create people ou if there is currently none */ - if($ldap->count() == 0 ){ - $add_dn = $cv['peopleou'].",".$cv['base']; - $naming_attr = preg_replace("/=.*$/","",$add_dn); - $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn); - $add = array(); - $add['objectClass'] = array("organizationalUnit"); - $add[$naming_attr] = $naming_value; - $ldap->cd($cv['base']); - $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn)); - $ldap->cd($add_dn); - $ldap->add($add); - } - - /* Create result */ - $ldap->search("(".$cv['peopleou'].")",array("dn")); - $tmp = array(); - while($attrs= $ldap->fetch()){ - if(!preg_match("/ou=snapshots,/",$attrs['dn'])){ - $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']); - } - } - } else{ - - /************ - * If people ou is empty - * Get all valid gosaDepartments - ************/ - $ldap->cd($cv['base']); - $tmp = array(); - $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn")); - $tmp[base64_encode($cv['base'])] = $ldap->fix($cv['base']); - while($attrs = $ldap->fetch()){ - $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);; - } - } - return($tmp); - } - - - function get_all_winstation_ous() - { - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Get winstation ou */ - if($cv['generic_settings']['wws_ou_active']) { - $winstation_ou = $cv['generic_settings']['ws_ou']; - }else{ - $winstation_ou = "ou=winstations"; - } - - $ldap->cd($cv['base']); - $ldap->search("(".$winstation_ou.")",array("dn")); - - if($ldap->count() == 0 ){ - $add_dn = $winstation_ou.",ou=systems,".$cv['base']; - $naming_attr = preg_replace("/=.*$/","",$add_dn); - $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn); - $add = array(); - $add['objectClass'] = array("organizationalUnit"); - $add[$naming_attr] = $naming_value; - - $ldap->cd($cv['base']); - $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn)); - $ldap->cd($add_dn); - $ldap->add($add); - } - - $ldap->search("(".$winstation_ou.")",array("dn")); - $tmp = array(); - while($attrs= $ldap->fetch()){ - if(!preg_match("/ou=snapshots,/",$attrs['dn'])){ - $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']); - } - } - return($tmp); - } - - - function get_all_group_ous() - { - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $group_ou = trim($cv['groupou']); - if(!empty($group_ou)){ - $group_ou = trim($group_ou); - } - - /************ - * If group ou is NOT empty - * Get all valid group ous, create one if necessary - ************/ - $ldap->cd($cv['base']); - if(!empty($group_ou)){ - $ldap->search("(".$group_ou.")",array("dn")); - if($ldap->count() == 0 ){ - $add_dn = $group_ou.$cv['base']; - $naming_attr = preg_replace("/=.*$/","",$add_dn); - $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn); - $add = array(); - $add['objectClass'] = array("organizationalUnit"); - $add[$naming_attr] = $naming_value; - - $ldap->cd($cv['base']); - $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn)); - $ldap->cd($add_dn); - $ldap->add($add); - } - $ldap->search("(".$group_ou.")",array("dn")); - $tmp = array(); - while($attrs= $ldap->fetch()){ - if(!preg_match("/ou=snapshots,/",$attrs['dn'])){ - $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']); - } - } - }else{ - /************ - * If group ou is empty - * Get all valid gosaDepartments - ************/ - $ldap->cd($cv['base']); - $tmp = array(); - $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn")); - $tmp[base64_encode($cv['base'])] = $ldap->fix($cv['base']); - while($attrs = $ldap->fetch()){ - $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);; - } - } - return($tmp); - } - - - function get_group_list() - { - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - $ldap->cd($cv['base']); - $ldap->search("(objectClass=posixGroup)",array("dn")); - - $tmp = array(); - while($attrs = $ldap->fetch()){ - $tmp[base64_encode($attrs['dn'])] = @LDAP::fix($attrs['dn']); - } - return($tmp); - } - - - function move($source,$destination) - { - /* Get collected configuration settings */ - $cv = $this->parent->captured_values; - - /* Establish ldap connection */ - $ldap = new LDAP($cv['admin'], - $cv['password'], - $cv['connection'], - FALSE, - $cv['tls']); - - /* Update object references in gosaGroupOfNames */ - $ogs_to_fix = array(); - $ldap->cd($cv['base']); - $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::fix($source).'))', array('cn','member')); - while ($attrs= $ldap->fetch()){ - $dn = $attrs['dn']; - $attrs = $this->cleanup_array($attrs); - $member_new = array($destination); - foreach($attrs['member'] as $member){ - if($member != $source){ - $member_new[] = $member; - } - } - $attrs['member'] = $member_new; - $ogs_to_fix[$dn] = $attrs; - } - - /* Copy source to destination dn */ - $ldap->cat($source); - $new_data = $this->cleanup_array($ldap->fetch()); - $ldap->cd($destination); - $res = $ldap->add($new_data); - - /* Display warning if copy failed */ - if(!$res){ - print_red(_("Failed to copy '%s' to '%s'. LDAP says '%s'."),$source,$destination,$ldap->get_error()); - }else{ - $res = $ldap->rmDir($source); - show_ldap_error($ldap->get_error(),_("Something went wrong while copying dns.")); - - /* Object is copied, so update its references */ - foreach($ogs_to_fix as $dn => $data){ - $ldap->cd($dn); - $ldap->modify($data); - } - } - } - - - /* Cleanup ldap result to be able to write it be to ldap */ - function cleanup_array($attrs) - { - foreach($attrs as $key => $value) { - if(is_numeric($key) || in_array($key,array("count","dn"))){ - unset($attrs[$key]); - } - if(is_array($value) && isset($value['count'])){ - unset($attrs[$key]['count']); - } - } - return($attrs); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Schema.inc b/setup/class_setupStep_Schema.inc deleted file mode 100644 index 2008128a4..000000000 --- a/setup/class_setupStep_Schema.inc +++ /dev/null @@ -1,110 +0,0 @@ -update_strings(); - } - - - function update_strings() - { - $this->s_title = _("LDAP schema check"); - $this->s_title_long = _("LDAP schema check"); - $this->s_info = _("Perform test on your current LDAP schema"); - } - - - function execute() - { - $this->check_schema(); - $failed_checks = 0 ; - foreach($this->checked as $val) { - if(!$val['STATUS']){ - $failed_checks ++; - } - } - - if($failed_checks == 0){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = TRUE; - } - - $smarty = get_smarty(); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - $smarty->assign("schema_readable",$this->schema_readable); - $smarty->assign("enable_schema_check",$this->enable_schema_check); - $smarty->assign("checks",$this->checked); - $smarty->assign("not_checked",$this->not_checked); - $smarty->assign("failed_checks",$failed_checks); - return($smarty -> fetch (get_template_path("../setup/setup_schema.tpl"))); - } - - function save_object() - { - if(isset($_POST['step7_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate($_POST[$attr]); - } - } - } - } - - function check_schema() - { - $cfg = $this->parent->captured_values; - $rfc2307bis = $cfg['rfc2307bis']; - $this->checked = check_schema($cfg,$rfc2307bis); - - /* Get objectclasses */ - $ldap = new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['tls']); - $objectclasses = $ldap->get_objectclasses(); - if(count($objectclasses) == 0){ - print_red(_("Can't get schema information from server. No schema check possible!")); - } - - /* Which samba version do we use? */ - if(isset($objectclasses['sambaSamAccount'])){ - $this->samba_version = 3; - } elseif(isset($objectclasses['sambaAccount'])) { - $this->samba_version = 2; - }else{ - $this->samba_version = 0; - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Welcome.inc b/setup/class_setupStep_Welcome.inc deleted file mode 100644 index f030f3121..000000000 --- a/setup/class_setupStep_Welcome.inc +++ /dev/null @@ -1,71 +0,0 @@ -is_enabled = TRUE; - $this->is_active = TRUE; - $this->update_strings(); - } - - function update_strings() - { - $this->s_title = _("Welcome"); - $this->s_info = _("The welcome message"); - $this->s_title_long = _("Welcome to GOsa setup wizard"); - } - - function execute() - { - $smarty = get_smarty(); - $smarty->assign('auth_id', session_id()); - return($smarty->fetch(get_template_path("setup_welcome.tpl",TRUE,dirname(__FILE__)))); - } - - function save_object() - { - $id = ""; - - /* Get auth ID from file */ - if (file_exists('/tmp/gosa.auth') && is_readable('/tmp/gosa.auth')){ - $contents= file('/tmp/gosa.auth'); - $id= chop($contents[0]); - } - - /* Continue if we've the correct ID */ - if ($id == session_id()){ - $this->is_completed = true; - } else { - $this->is_completed = false; - } - - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/license.txt b/setup/license.txt deleted file mode 100644 index 9140f02bf..000000000 --- a/setup/license.txt +++ /dev/null @@ -1,147 +0,0 @@ -Table of Contents - - * GNU GENERAL PUBLIC LICENSE - o Preamble - o TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - o How to Apply These Terms to Your New Programs - -GNU GENERAL PUBLIC LICENSE - -Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. - -For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - -We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. - -Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. - -Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and modification follow. -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - * a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. - * b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. - * c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: - - * a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - * b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - * c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. - -7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. - -10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -END OF TERMS AND CONDITIONS -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - -one line to give the program's name and an idea of what it does. -Copyright (C) yyyy name of author - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - -Gnomovision version 69, Copyright (C) year name of author -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details -type `show w'. This is free software, and you are welcome -to redistribute it under certain conditions; type `show c' -for details. - -The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright -interest in the program `Gnomovision' -(which makes passes at compilers) written -by James Hacker. - -signature of Ty Coon, 1 April 1989 -Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. - -Linking Joomla! statically or dynamically with other modules is making a combined work based on Joomla!. Thus, the terms and conditions of the GNU General Public License cover the whole combination. - -In addition, as a special exception, the copyright holders of Joomla! give you permission to combine Joomla! with free software programs or libraries that are released under the GNU LGPL and with independent modules that communicate with Joomla! solely through the Joomla! extension interface. You may copy and distribute such a system following the terms of the GNU GPL for Joomla! and the licenses of the other code concerned, provided that you include the source code of that other code when and as the GNU GPL requires distribution of source code. - -Note that people who make modified versions of Joomla! are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU General Public License gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. diff --git a/setup/main.inc b/setup/main.inc deleted file mode 100644 index bce41ef68..000000000 --- a/setup/main.inc +++ /dev/null @@ -1,35 +0,0 @@ -save_object(); -$display= $setup->execute(); - -/* Store changes in session */ -$_SESSION['setup']= $setup; - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/setup.tpl b/setup/setup.tpl deleted file mode 100644 index 3bb21f795..000000000 --- a/setup/setup.tpl +++ /dev/null @@ -1,4 +0,0 @@ -
-{$php_errors} -sadffasdsdfa -
diff --git a/setup/setup_checks.tpl b/setup/setup_checks.tpl deleted file mode 100644 index 90275fc27..000000000 --- a/setup/setup_checks.tpl +++ /dev/null @@ -1,122 +0,0 @@ - -
- - -
- -

{t}PHP module and extension checks{/t}

- - {foreach from=$basic item=val key=key} - - {if $basic[$key].SOLUTION != "" && !$basic[$key].RESULT} - - -
- {else} - - -
- {/if} - -
{$basic[$key].NAME}
-
- - {if $basic[$key].RESULT} -
{t}Ok{/t}
- {else} - {if $basic[$key].MUST} -
{t}Error{/t}
- {else} -
{t}Warning{/t}
- {/if} - {if $basic[$key].SOLUTION != ""} - - -
- {if $basic[$key].MUST} -
- {$basic[$key].SOLUTION} - {t}GOsa will NOT run without fixing this.{/t} - {else} -
- {$basic[$key].SOLUTION} - {t}GOsa will run without fixing this.{/t} - {/if} -
-
- {/if} - {/if} -
-
- {/foreach} -
-
- - - -
- - -
- - -

{t}PHP setup configuration{/t} ({t}show information{/t})

- - - {foreach from=$config item=val key=key} - - - {if $config[$key].SOLUTION != "" && !$config[$key].RESULT} - - -
- {else} - - -
- {/if} - - -
{$config[$key].NAME}
-
- {if $config[$key].RESULT} -
{t}Ok{/t}
- {else} - - {if $config[$key].MUST} -
{t}Error{/t}
- {else} -
{t}Warning{/t}
- {/if} - - {if $config[$key].SOLUTION != ""} - - -
- {if $config[$key].MUST} -
- {$config[$key].SOLUTION} - {t}GOsa will NOT run without fixing this.{/t} - {else} -
- {$config[$key].SOLUTION} - {t}GOsa will run without fixing this.{/t} - {/if} -
-
- {/if} - {/if} -
-
- {/foreach} - - -
-
- -
- diff --git a/setup/setup_config1.tpl b/setup/setup_config1.tpl deleted file mode 100644 index d041ae35f..000000000 --- a/setup/setup_config1.tpl +++ /dev/null @@ -1,225 +0,0 @@ -
-

{t}Look and feel{/t}

- -
-
- {t}Theme{/t} -
-
- -
-
- -

{t}Apache{/t}

- -
-
- {t}Compress output send to browser{/t} -
-
- -
-
-

{t}People and group storage{/t}

-
-
- {t}People DN attribute{/t} -
-
- -
-
- -
-
- {t}People storage subtree{/t} -
-
- -
-
- -
-
- {t}Group storage subtree{/t} -
-
- -
-
- -
-
- {t}Include personal title in user DN{/t} -
-
- -
-
- -
-
- {t}Relaxed naming policies{/t} -
-
- -
-
- -
-
- {t}Automatic uids{/t} -
-
- {if $id_settings.idgen_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}GID / UID min id{/t} -
-
- {if $id_settings.minid_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Number base for people/groups{/t} -
-
- -
-
-
-
- {t}Hook for number base{/t} -
-
- {if $base_hook_active == FALSE} - - - {else} - - - {/if} -
-
-
- -

{t}Password settings{/t}

- -
-
- {t}Password encryption algorithm{/t} -
-
- -
-
- -
-
- {t}Password restrictions{/t} -
-
- - {if $pwd_rules.pwminlen_active == FALSE} - - {t}Password minimum length{/t} - - {else} - - {t}Password minimum length{/t} - - {/if} -
- {if $pwd_rules.pwdiffer_active == FALSE} - - {t}Different characters from old password{/t} - - {else} - - {t}Different characters from old password{/t} - - {/if} - -
-
- -
-
- {t}Password change hook{/t} -
-
- {if $pwd_rules.externalpwdhook_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Use SASL for kerberos{/t} -
-
- -
-
- -
-
- {t}Use account expiration{/t} -
-
- -
-
- - - - - diff --git a/setup/setup_config2.tpl b/setup/setup_config2.tpl deleted file mode 100644 index 80c5cf6aa..000000000 --- a/setup/setup_config2.tpl +++ /dev/null @@ -1,323 +0,0 @@ -
-

{t}Samba settings{/t}

- -
-
- {t}Samba hash generator{/t} -
-
- -
-
- -
-
- {t}Samba SID{/t} -
-
- {if $samba_settings.samba_sid_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}RID base{/t} -
-
- {if $samba_settings.samba_rid_active == FALSE} - - - {else} - - - {/if} -
-
-
-
- {t}Workstation container{/t} -
-
- {if $generic_settings.wws_ou_active == FALSE} - - - {else} - - - {/if} -
-
-
-
- {t}Samba SID mapping{/t} -
-
- -
-
-
-
- {t}Timezone{/t} -
-
- -
-
- - -

{t}Additional GOsa settings{/t}

- -
-
- {t}Enable Copy & Paste{/t} -
-
- - -
-
- -
-
- {t}Enable DNS extension{/t} -
-
- - -
-
- -
-
- {t}Enable DHCP extension{/t} -
-
- - -
-
- -
-
- {t}Enable mime type management{/t} -
-
- - -
-
- -
-
- {t}Enable FAI release management{/t} -
-
- - -
-
- -
-
- {t}Enable user netatalk plugin{/t} -
-
- -
-
- -
-
- {t}Government mode{/t} -
-
- -
-
- -

{t}Mail settings{/t}

- -
-
- {t}Mail method{/t} -
-
- -
-
-
-
- -
-
- {t}Vacation templates{/t} -
-
- {if $mail_settings.vacationdir_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Use Cyrus UNIX style{/t} -
-
- -
-
- - -

{t}Snapshots / Undo{/t}

- {if $generic_settings.snapshot_active == FALSE} -
-
- {t}Enable snapshots{/t} -
-
-
-
-
- {t}Snapshot base{/t} -
-
- -
-
-
-
- {t}Server{/t} -
-
- -
-
-
-
- {t}User{/t} -
-
- -
-
-
-
- {t}Password{/t} -
-
- -
-
-
- - {else} -
-
- {t}Enable snapshots{/t} -
-
-
-
-
- {t}Snapshot base{/t} -
-
- -
-
-
-
- {t}Server{/t} -
-
- -
-
-
-
- {t}User{/t} -
-
- -
-
-
-
- {t}Password{/t} -
-
- -
-
-
- {/if} -
- - -
diff --git a/setup/setup_config3.tpl b/setup/setup_config3.tpl deleted file mode 100644 index a3d2a55c3..000000000 --- a/setup/setup_config3.tpl +++ /dev/null @@ -1,324 +0,0 @@ -
-

{t}GOsa core settings{/t}

- -
-
- {t}Disable primary group filter{/t} -
-
- - -
-
- -
-
- {t}Display summary in listings{/t} -
-
- - -
-
- -
-
- {t}Honour administrative units{/t} -
-
- - -
-
- -
-
- {t}Smarty compile directory{/t} -
-
- -
-
-
-
- {t}SNMP community{/t} -
-
- -
-
-
-
- {t}Path for PPD storage{/t} -
-
- {if $optional.ppd_path_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Path for kiosk profile storage{/t} -
-
- {if $optional.kioskpath_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Enable system deployment{/t} -
-
- {if $optional.gotomasses_active == FALSE} - - - {else} - - - {/if} -
-
- - -
-
- {t}Network resolv hook{/t} -
-
- {if $optional.auto_network_hook_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Mail queue script{/t} -
-
- {if $optional.mailQueueScriptPath_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Notification script{/t} -
-
- {if $optional.notifydir_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Enable edit locking{/t} -
-
- {if $optional.uniq_identifier_active == FALSE} - - - {else} - - - {/if} -
-
- -

{t}Login and session{/t}

-
-
- {t}Login attribute{/t} -
-
- -
-
- -
-
- {t}Enforce register_globals to be deactivated{/t} -
-
- - -
-
- -
-
- {t}Enforce encrypted connections{/t} -
-
- - -
-
- -
-
- {t}Warn if session is not encrypted{/t} -
-
- - -
-
- -
-
- {t}Remember dialog filter settings{/t} -
-
- - -
-
- -
-
- {t}Session lifetime{/t} -
-
- -
-
- -

{t}Debugging{/t}

- -
-
- {t}Show PHP errors{/t} -
-
- -
-
- - -
-
- {t}Maximum LDAP query time{/t} -
-
- {if $optional.max_ldap_query_time_active == FALSE} - - - {else} - - - {/if} -
-
- -
-
- {t}Log LDAP statistics{/t} -
-
- - -
-
- -
-
- {t}Debug level{/t} -
-
- -
-
-
- - diff --git a/setup/setup_feedback.tpl b/setup/setup_feedback.tpl deleted file mode 100644 index 20fae54e6..000000000 --- a/setup/setup_feedback.tpl +++ /dev/null @@ -1,144 +0,0 @@ -
- -

{$additional_info}

- -

-  {t}Subscribe to the gosa-announce mailinglist{/t} -

-

- {t}When checking this option, GOsa will try to connect http://oss.gonicus.de in order to subscribe you to the gosa-announce mailing list. You've to confirm this by mail.{/t} -

- - - - - - - - - - - - - -
- {t}Organization{/t} - - -
- {t}Name{/t} - - -
- {t}Mail address{/t}{$must} - - -
- - -

 

-

-  {t}Send feedback to the GOsa project team{/t} -

-

- {t}When checking this option, GOsa will try to connect http://oss.gonicus.de in order to submit your form anonymously.{/t} -

- {t}Generic{/t} - - - - - - - - - - - - - - - - - - - - - - - - - -
- {t}Did the setup procedure help you to get started?{/t} - - {t}Yes{/t} -
- {t}No{/t} -
- {t}If not, what problems did you encounter{/t}: - - -
- {t}Is this the first time you use GOsa?{/t} - - {t}Yes{/t} -
- {t}No{/t}, - {t}I use it since{/t} - -
- {t}What operating system / distribution do you use?{/t} - - -
- {t}What web server do you use?{/t} - - -
- {t}What PHP version do you use?{/t} - - -
- -
{t}LDAP{/t} - - - - - - - - - -
- {t}What kind of LDAP server(s) do you use?{/t} - -
{t}How many objects are in your LDAP?{/t} - -
- -
{t}Features{/t} - - - - - - - - - -
{t}What features of GOsa do you use?{/t} - - {foreach from=$features_used item=data key=key} - - {$data.NAME}
- {/foreach} -
{t}What features do you want to see in future versions of GOsa?{/t} - -
-
- - diff --git a/setup/setup_finish.tpl b/setup/setup_finish.tpl deleted file mode 100644 index 87b6732d3..000000000 --- a/setup/setup_finish.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
-

- {t}Create your configuration file{/t} -

-

- {$msg2} -

- - chown root.{$webgroup} {$CONFIG_DIR}/{$CONFIG_FILE}
- chmod 640 {$CONFIG_DIR}/{$CONFIG_FILE} -
-

- -

- {if $err_msg != ""} -

 

-
- {t}Status: {/t} - {$err_msg} - {/if} - -
- diff --git a/setup/setup_frame.tpl b/setup/setup_frame.tpl deleted file mode 100644 index 7da520583..000000000 --- a/setup/setup_frame.tpl +++ /dev/null @@ -1,47 +0,0 @@ - -{$php_errors} -
- {$msg_dialogs} - -
-
-
GOsa
-
{$version}
-
-
- {t}GOsa setup wizard{/t} -
- -
- -
-
- {t}Installation{/t}  {t}Steps{/t} -
- {$navigation} -
- -
-
- {$errors} - {$header} -
-
- {$contents} - {$bottom} -
-
-
-
-
-
- - - -
- - - - diff --git a/setup/setup_language.tpl b/setup/setup_language.tpl deleted file mode 100644 index 6d1b30b98..000000000 --- a/setup/setup_language.tpl +++ /dev/null @@ -1,13 +0,0 @@ -
-
-

{t}Please select the preferred language{/t}

-

- {t}At this point, you can select the site wide default language. Choosing 'automatic' will use the language requested by the browser. This setting can be overriden per user.{/t} -

-
-
- -
-
diff --git a/setup/setup_ldap.tpl b/setup/setup_ldap.tpl deleted file mode 100644 index b1ef46ee1..000000000 --- a/setup/setup_ldap.tpl +++ /dev/null @@ -1,136 +0,0 @@ -
- - {if $resolve_user} - -
-

- {t}Please choose the LDAP user to be used by GOsa{/t} -

- - - -

 

-
- - -
-
- -
- - {else} -

- {t}LDAP connection{/t} -

-
-
- {t}Location name{/t} -
-
- -
-
-
-
-
{t}Connection URL{/t}
-
-
- -
-
-
-
- {t}TLS connection{/t} -
-
- -
-
-
-
- {t}Base{/t} -
-
- {if $namingContextsCount >= 1} - - {else} - - {/if} - -
-
-

- {t}Authentication{/t} -

-
-
- {t}Admin DN{/t} -
-
- - {if $append_base_to_admin_dn},{$base_to_append}{/if} - -
-
- -
-
-
-
-  {t}Automatically append LDAP base to admin DN{/t} -
-
- - -
-
- {t}Admin password{/t} -
-
- -
-
- -

- {t}Schema based settings{/t} -

-
-
- {t}Use rfc2307bis compliant groups{/t} -
-
- -
-
- {/if} - - {if ! $resolve_user} -

- {t}Current status{/t} -

-
-
- {t}Information{/t} -
-
- {$connection_status} -
-
- {/if} - -
- - - diff --git a/setup/setup_license.tpl b/setup/setup_license.tpl deleted file mode 100644 index 47e7937cc..000000000 --- a/setup/setup_license.tpl +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
- {$License} -
-
-
- {t}I have read the license and accept it{/t} -
-
- diff --git a/setup/setup_migrate.tpl b/setup/setup_migrate.tpl deleted file mode 100644 index a1652162b..000000000 --- a/setup/setup_migrate.tpl +++ /dev/null @@ -1,364 +0,0 @@ -
-
- - {if $method == "default"} -

{t}During the LDAP inspection, we're going to check for several common pitfalls that may occur when migration to GOsa base LDAP administration. You may want to fix the problems below, in order to provide smooth services.{/t} -

- - {foreach from=$checks item=val key=key} -
- - {if $checks.$key.ERROR_MSG} - -
- {else} - -
- {/if} -
{$checks.$key.TITLE}
-
- {if $checks.$key.STATUS} -
{$checks.$key.STATUS_MSG}
- {else} -
{$checks.$key.STATUS_MSG}
- {/if} -
- {if $checks.$key.ERROR_MSG} - {$checks.$key.ERROR_MSG} - {/if} -
-
- {/foreach} -
- - - {elseif $method == "outside_winstations"} - -

{t}Move windows workstations into a valid windows workstation department{/t}

- - {t}This dialog allows you to move the displayed windows workstations into a valid department{/t} -
- {t}Be careful with this tool, there may be references pointing to this workstations that can't be migrated.{/t} -
-
- - {foreach from=$outside_winstations item=val key=key} - {if $outside_winstations.$key.selected} - - {else} - - {/if} - -  {$outside_winstations.$key.dn} - {if $outside_winstations.$key.ldif != ""} -
-
-
-								{$outside_winstations.$key.ldif}
-							
-
-
- {/if} -
- {/foreach} - - {t}Select all{/t} -

- {t}Move selected windows workstations into the following GOsa department{/t} : - -
- - -

- - -

 

-
- -
- - - {elseif $method == "outside_groups"} - -

{t}Move groups into configured group tree{/t}

- -

- {t}This dialog allows moving a couple of groups to the configured group tree. Doing this may straighten your LDAP service.{/t} -

-

- {t}Be careful with this option! There may be references pointing to these groups. The GOsa setup can't migrate references, so you may want to cancel the migration in this case in this case.{/t} -

-

- {t}Move selected groups into this group tree{/t}: - -

- - {foreach from=$outside_groups item=val key=key} - {if $outside_groups.$key.selected} - - {else} - - {/if} - -  {$outside_groups.$key.dn} - {if $outside_groups.$key.ldif != "" && $group_details} -
-
-
-{$outside_groups.$key.ldif}
-
-
-
- {/if} -
- {/foreach} - - - {t}Select all{/t} -
-

- {if $group_details} - - {else} - - {/if} -

- -

 

-
- -   - -
- - {elseif $method == "outside_users"} - -

{t}Move users into configured user tree{/t}

-

- {t}This dialog allows moving a couple of users to the configured user tree. Doing this may straighten your LDAP service.{/t} -

-

- {t}Be careful with this option! There may be references pointing to these users. The GOsa setup can't migrate references, so you may want to cancel the migration in this case.{/t} -

-

- {t}Move selected users into this people tree{/t}: - -

- {foreach from=$outside_users item=val key=key} - {if $outside_users.$key.selected} - - {else} - - {/if} - -  {$outside_users.$key.dn} - {if $outside_users.$key.ldif != "" && $user_details} -
-
-
-{$outside_users.$key.ldif}
-
-
-
- {/if} -
- {/foreach} - - {t}Select all{/t} -
- - {if $user_details} - - {else} - - {/if} - -

 

-
- -   - -
- - - {elseif $method == "create_acls"} - - {if $acl_create_selected != "" && $what_will_be_done_now!=""} -
-
-{$what_will_be_done_now}
-
-
- - - {else} -

{t}Create a new GOsa administrator account{/t}

- -

- {t}This dialog will automatically add a new super administrator to your LDAP tree.{/t} -

- - - - - - - - - - - - - - - - - -
- {t}Name{/t}:  - - System administrator -
- {t}User ID{/t}:  - -
-
- {t}Password{/t}:  - -
-
- {t}Password (again){/t}:  - -
-
- - - - -

 

-
- - -
- {/if} - {elseif $method == "migrate_deps"} - -

Department migration

- -

{t}The listed departments are currenlty invisble in the GOsa user interface. If you want to change this for a couple of entries, select them and use the migrate button below.{/t}

-

{t}If you want to know what will be done when migrating the selected entries, use the 'Show changes' button to see the LDIF.{/t}

- - {foreach from=$deps_to_migrate item=val key=key} - - {if $deps_to_migrate.$key.checked} - - {$deps_to_migrate.$key.dn} - {if $deps_to_migrate.$key.after != ""} -
- -{t}Current{/t} -
-
-dn: {$deps_to_migrate.$key.dn}
-{$deps_to_migrate.$key.before}
-
-
-{t}After migration{/t} -
-
-dn: {$deps_to_migrate.$key.dn}
-{$deps_to_migrate.$key.after}
-
-
-
- {/if} - {else} - - {$deps_to_migrate.$key.dn} - {/if} - -
- {/foreach} - - {t}Select all{/t} -
- - {if $deps_details} - - {else} - - {/if} - -

 

- -
- -   - -
- {elseif $method == "migrate_users"} - -

User migration

- -

{t}The listed users are currenlty invisble in the GOsa user interface. If you want to change this for a couple of users, just select them and use the 'Migrate' button below.{/t}

-

{t}If you want to know what will be done when migrating the selected entries, use the 'Show changes' button to see the LDIF.{/t}

- {foreach from=$users_to_migrate item=val key=key} - - {if $users_to_migrate.$key.checked} - - {$users_to_migrate.$key.dn} - {if $users_to_migrate.$key.after != ""} -
- -{t}Current{/t} -
-
-dn: {$users_to_migrate.$key.dn}
-{$users_to_migrate.$key.before}
-
-
-{t}After migration{/t} -
-
-dn: {$users_to_migrate.$key.dn}
-{$users_to_migrate.$key.after}
-
-
-
- {/if} - {else} - - {$users_to_migrate.$key.dn} - {/if} -
- {/foreach} - - {t}Select all{/t} -
- - {if $user_details} - - {else} - - {/if} - -

 

- -
- -   - -
- {/if} -
-
diff --git a/setup/setup_schema.tpl b/setup/setup_schema.tpl deleted file mode 100644 index e56538b1e..000000000 --- a/setup/setup_schema.tpl +++ /dev/null @@ -1,40 +0,0 @@ -
-

- {t}Schema specific settings{/t} -

-
-
- {t}Enable schema validation when logging in{/t} -
-
- -
-
-

- {t}Check status{/t} -

-
- {if $failed_checks == 0} - {t}Schema check succeeded{/t} - {else} - - {t}Schema check failed{/t} - {/if} -
-
- {foreach from=$checks item=val key=key} - {if !$checks[$key].STATUS} -
- {if $checks[$key].IS_MUST_HAVE} - {$checks[$key].MSG} - {else} - {$checks[$key].MSG} - {/if} -
- {/if} - {/foreach} -
-
- diff --git a/setup/setup_welcome.tpl b/setup/setup_welcome.tpl deleted file mode 100644 index e6f76c7b6..000000000 --- a/setup/setup_welcome.tpl +++ /dev/null @@ -1,37 +0,0 @@ -
-
-

- {t}This seems to be the first time you start GOsa - we didn't find any configuration right now. This simple wizard intends to help you while setting it up.{/t} -

- -

- {t}What will the wizard do for you?{/t} -

-
    -
  • {t}Create a basic, single site configuration{/t}
  • -
  • {t}Tries to find problems within your PHP and LDAP setup{/t}
  • -
  • {t}Let you choose from a set of basic and advanced configuration switches{/t}
  • -
  • {t}Guided migration of existing LDAP trees{/t}
  • -
-

- {t}What will the wizard NOT do for you?{/t} -

-
    -
  • {t}Find every possible configuration error{/t}
  • -
  • {t}Migrate every possible LDAP setup - create backup dumps!{/t}
  • -
- -

- {t}To continue...{/t} -

-

- {t}For security reasons you need to authenticate for the installation by creating the file '/tmp/gosa.auth', containing the current session ID on the servers local filesystem. This can be done by executing the following command:{/t} -

- - echo -n {$auth_id} > /tmp/gosa.auth - -

- {t}Click the 'Continue' button when you've finished.{/t} -

-
-