From: cajus Date: Thu, 17 Jan 2008 12:30:06 +0000 (+0000) Subject: Moved goto partly X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=118c8f12fdf0da25908fd63a1fa3a5e09651c861;p=gosa.git Moved goto partly git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8441 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/applications/class_applicationGeneric.inc b/gosa-core/plugins/admin/applications/class_applicationGeneric.inc deleted file mode 100644 index 247acf972..000000000 --- a/gosa-core/plugins/admin/applications/class_applicationGeneric.inc +++ /dev/null @@ -1,572 +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); - - $appfilter = session::get('appfilter') ; - - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)) { - if(!preg_match("/^".get_ou('applicationou')."/",$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::set('binary',$this->iconData); - session::set('binarytype',"image/jpeg"); - $this->gosaApplicationIcon= $this->iconData; - - /* This is always an account */ - $this->is_account= TRUE; - - if ($this->dn == "new"){ - if(session::is_set('CurrentMainBase')){ - $this->base = session::get('CurrentMainBase'); - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - - if($this->isReleaseApplikation){ - $this->base = preg_replace("/^.*,".get_ou('applicationou')."/","",$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::set('binary',$this->gotoLogonScript); - session::set('binarytype',"octet-stream"); - session::set('binaryfile',$this->cn.".gosaApplication"); - header("location: getbin.php "); - exit(); - } - } - - /* Reassign picture data, sometimes its corrupt cause we started a download of application scripts */ - session::set('binary',$this->iconData); - session::set('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=".LDAP::prepare4filter($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.",".get_ou('applicationou').$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')); - $appfilter = session::get('appfilter'); - if((!empty($tmp)) && (isset($appfilter['release']))){ - $baseDn = str_replace($this->config->current['BASE'],$this->base,$appfilter['release']); - $baseDn = preg_replace("/".get_ou('applicationou').".*/",get_ou('applicationou').$this->base,$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."))",get_ou('applicationou').$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::set('binary',$this->iconData); - session::set('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 deleted file mode 100644 index c7810321e..000000000 --- a/gosa-core/plugins/admin/applications/class_applicationManagement.inc +++ /dev/null @@ -1,647 +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 = get_ou('applicationou').$base; - $ret = array(); - $ret [get_ou('applicationou').$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::set('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; - session::un_set('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; - session::un_set('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::set('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); - session::un_set('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 = get_ou('applicationou').$base; - }else{ - if(isset($Releases[$release])){ - $use_base = $release; - }else{ - $use_base = get_ou('applicationou').$base; - } - } - - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - } - - $res= get_sub_list($Filter, "application",get_ou('applicationou'), $use_base, array("cn","description","dn","objectClass"), $Flags); - $tmp2 = array(); - foreach ($res as $val){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; - $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn']; - } - - natcasesort($tmp2); - $this->applications=array(); - foreach($tmp2 as $val){ - $this->applications[]=$tmp[$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 deleted file mode 100644 index 9f11eb6b9..000000000 --- a/gosa-core/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/gosa-core/plugins/admin/applications/class_divListApplication.inc b/gosa-core/plugins/admin/applications/class_divListApplication.inc deleted file mode 100644 index f70d5c618..000000000 --- a/gosa-core/plugins/admin/applications/class_divListApplication.inc +++ /dev/null @@ -1,323 +0,0 @@ -selectedRelease = get_ou('applicationou').session::get('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(); - $appfilter = session::get('appfilter'); - $appfilter['release'] = $this->selectedRelease; - session::set('appfilter',$appfilter); - } - -} -// 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 deleted file mode 100644 index b50ed7eb8..000000000 --- a/gosa-core/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/gosa-core/plugins/admin/applications/main.inc b/gosa-core/plugins/admin/applications/main.inc deleted file mode 100644 index 7b748386a..000000000 --- a/gosa-core/plugins/admin/applications/main.inc +++ /dev/null @@ -1,55 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - session::un_set ('applicationManagement'); - } -} else { - /* Create applicationManagement object on demand */ - if (!session::is_set('applicationManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - session::set('applicationManagement',new applicationManagement ($config, $ui)); - } - $applicationManagement = session::get('applicationManagement'); - $applicationManagement->save_object(); - $output= $applicationManagement->execute(); - - /* Page header*/ - if (session::is_set('objectinfo')){ - $display= print_header(get_template_path('images/application.png'), _("Application management"), "\"\" ".@LDAP::fix(session::get('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); - session::un_set ('applicationManagement'); - } - - /* Show and save dialog */ - $display.= $output; - session::set('applicationManagement',$applicationManagement); -} - -?> diff --git a/gosa-core/plugins/admin/applications/parameters.tpl b/gosa-core/plugins/admin/applications/parameters.tpl deleted file mode 100644 index 57c221971..000000000 --- a/gosa-core/plugins/admin/applications/parameters.tpl +++ /dev/null @@ -1,2 +0,0 @@ -{$table} -
diff --git a/gosa-core/plugins/admin/applications/release_select.tpl b/gosa-core/plugins/admin/applications/release_select.tpl deleted file mode 100644 index d58738f05..000000000 --- a/gosa-core/plugins/admin/applications/release_select.tpl +++ /dev/null @@ -1,16 +0,0 @@ -
-
-

[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 deleted file mode 100644 index 8598ed857..000000000 --- a/gosa-core/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/gosa-core/plugins/admin/applications/tabs_application.inc b/gosa-core/plugins/admin/applications/tabs_application.inc deleted file mode 100644 index 5b6e82989..000000000 --- a/gosa-core/plugins/admin/applications/tabs_application.inc +++ /dev/null @@ -1,59 +0,0 @@ -addSpecialTabs(); - } - - function set_release($newRelease) - { - $this->Release= preg_replace('/,'.get_ou('applicationou').'.*$/', '', $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')); - $appfilter = session::get('appfilter'); - if((!empty($tmp)) && (isset($appfilter['release']))){ - if(!$baseobject->isReleaseApplikation){ - $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$baseobject->base; - }else{ - $new_dn ="cn=".$baseobject->cn.",".$appfilter['release']; - } - }else{ - $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$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(); - } - -} -// 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 deleted file mode 100644 index bc870eb74..000000000 --- a/gosa-core/plugins/admin/devices/class_deviceGeneric.inc +++ /dev/null @@ -1,256 +0,0 @@ -is_account = TRUE; - - $this->types= array("camera" => _("Digital camera"), - "harddisk" => _("Harddisk"), - "stick" => _("USB stick"), - "cd" => _("CD/DVD drive"),); - asort($this->types); - - /* 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]; - if (isset($tmp[4])){ - $this->type= $tmp[4]; - } - } - - $this->orig_cn = $this->cn; - - /* Set Base */ - if ($this->dn == "new"){ - if(session::is_set('CurrentMainBase')){ - $this->base = session::get('CurrentMainBase'); - }else{ - $ui= get_userinfo(); - $this->base= dn2base($ui->dn); - } - } else { - $this->base =preg_replace ("/^[^,]+,".get_ou('deviceou')."/","",$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); - } - - $smarty->assign("type",$this->type); - $smarty->assign ("types", $this->types); - - 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 deleted file mode 100644 index 77c582575..000000000 --- a/gosa-core/plugins/admin/devices/class_deviceManagement.inc +++ /dev/null @@ -1,557 +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::set('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; - session::un_set('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; - session::un_set('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::set('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); - session::un_set('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(get_ou('deviceou').$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 = get_ou('deviceou').$base; - } - - /* Get results and create index */ - $res= get_sub_list($Filter,"devices",get_ou('deviceou'), $base, array("cn","description","dn","objectClass"), $Flags); - $tmp2 = array(); - foreach ($res as $val){ - $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn']; - $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; - } - - /* sort entries */ - natcasesort($tmp2); - $this->devices=array(); - foreach($tmp2 as $val){ - $this->devices[]=$tmp[$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 deleted file mode 100644 index e9d5f8522..000000000 --- a/gosa-core/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,".get_ou('deviceou').$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 deleted file mode 100644 index 863851e44..000000000 --- a/gosa-core/plugins/admin/devices/deviceGeneric.tpl +++ /dev/null @@ -1,75 +0,0 @@ - -

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

{t}Devices{/t}

- - - - -
- - - - - -
{$must} - - -
-
- - - - diff --git a/gosa-core/plugins/admin/devices/remove.tpl b/gosa-core/plugins/admin/devices/remove.tpl deleted file mode 100644 index 643056cd3..000000000 --- a/gosa-core/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/gosa-core/plugins/admin/devices/tabs_devices.inc b/gosa-core/plugins/admin/devices/tabs_devices.inc deleted file mode 100644 index 0feddfc4e..000000000 --- a/gosa-core/plugins/admin/devices/tabs_devices.inc +++ /dev/null @@ -1,38 +0,0 @@ -addSpecialTabs(); - } - - function save($ignore_account= FALSE) - { - $baseobject= $this->by_object['deviceGeneric']; - $new_dn= "cn=".$baseobject->cn.",".get_ou('deviceou').$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(); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/mimetypes/class_divListMimeTypes.inc b/gosa-core/plugins/admin/mimetypes/class_divListMimeTypes.inc deleted file mode 100644 index da73758aa..000000000 --- a/gosa-core/plugins/admin/mimetypes/class_divListMimeTypes.inc +++ /dev/null @@ -1,345 +0,0 @@ -selectedRelease = get_ou('mimetypeou').session::get('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,".get_ou('mimetypeou').$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); - } - $mimefilter = session::get('mimefilter'); - $mimefilter['release'] = $this->selectedRelease; - session::set('mimefilter',$mimefilter); - } - -} -// 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 deleted file mode 100644 index 03867ebab..000000000 --- a/gosa-core/plugins/admin/mimetypes/class_mimetypeGeneric.inc +++ /dev/null @@ -1,758 +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(session::is_set('CurrentMainBase')){ - $this->base= session::get('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::set('binary',$this->iconData); - session::set('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=".LDAP::prepare4filter($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"]); - - $mimefilter = session::get('mimefilter'); - - if($this->isReleaseMimeType && (isset($mimefilter['release']))){ - $baseDn = str_replace($this->config->current['BASE'],$this->base,$mimefilter['release']); - $baseDn = preg_replace("/".get_ou('mimetypeou').".*/",get_ou('mimetypeou').$this->base,$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."))",get_ou('mimetypeou').$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::set('binary',$this->iconData); - session::set('binarytype',"image/jpeg"); - fclose ($fd); - } - } - - /* Get picture link */ - function get_picture() - { - session::set('binary',$this->iconData); - session::set('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 deleted file mode 100644 index 7af6280d7..000000000 --- a/gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc +++ /dev/null @@ -1,666 +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 = get_ou('mimetypeou').$base; - $ret = array(); - $ret [get_ou('mimetypeou').$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::set('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; - session::un_set('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; - session::un_set('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::set('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); - session::un_set('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 = get_ou('mimetypeou').$use_base; - } - } - - /* Get results and create index */ - $res= get_sub_list($Filter, "mimetypes",get_ou('mimetypeou'), $use_base, array("cn","description","dn","objectClass"), $Flags); - $tmp2 = array(); - foreach ($res as $val){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; - $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn']; - } - - /* sort entries */ - natcasesort($tmp2); - $this->mimetypes=array(); - foreach($tmp2 as $val){ - $this->mimetypes[]=$tmp[$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 deleted file mode 100644 index 1cb6d7549..000000000 --- a/gosa-core/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/gosa-core/plugins/admin/mimetypes/main.inc b/gosa-core/plugins/admin/mimetypes/main.inc deleted file mode 100644 index de9214254..000000000 --- a/gosa-core/plugins/admin/mimetypes/main.inc +++ /dev/null @@ -1,57 +0,0 @@ -remove_lock(); - del_lock ($ui->dn); - session::un_set ('MimeTypeManagement'); - } -} else { - - /* Create MimeTypeManagement object on demand */ - if (!session::is_set('MimeTypeManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - session::set('MimeTypeManagement',new mimetypeManagement ($config, $ui)); - } - - /* Get object */ - $MimeTypeManagement = session::get('MimeTypeManagement'); - $MimeTypeManagement->save_object(); - $output= $MimeTypeManagement->execute(); - - /* Page header*/ - if (session::is_set('objectinfo')){ - $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "\"\" ".@LDAP::fix(session::get('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); - session::un_set ('MimeTypeManagement'); - } - - /* Show and save dialog */ - $display.= $output; - session::set('MimeTypeManagement',$MimeTypeManagement); -} -?> diff --git a/gosa-core/plugins/admin/mimetypes/paste_generic.tpl b/gosa-core/plugins/admin/mimetypes/paste_generic.tpl deleted file mode 100644 index 34b5e0751..000000000 --- a/gosa-core/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/gosa-core/plugins/admin/mimetypes/release_select.tpl b/gosa-core/plugins/admin/mimetypes/release_select.tpl deleted file mode 100644 index d58738f05..000000000 --- a/gosa-core/plugins/admin/mimetypes/release_select.tpl +++ /dev/null @@ -1,16 +0,0 @@ -
-
-

[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 deleted file mode 100644 index 30c423318..000000000 --- a/gosa-core/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/gosa-core/plugins/admin/mimetypes/tabs_mimetypes.inc b/gosa-core/plugins/admin/mimetypes/tabs_mimetypes.inc deleted file mode 100644 index 38570fde2..000000000 --- a/gosa-core/plugins/admin/mimetypes/tabs_mimetypes.inc +++ /dev/null @@ -1,61 +0,0 @@ -addSpecialTabs(); - } - - function set_release($newRelease) - { - $this->Release= preg_replace('/,'.get_ou('mimetypeou').'.*$/', '', $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')); - - $mimefilter = session::get('mimefilter'); - - if((!empty($tmp)) && (isset($mimefilter['release']))){ - if(!$baseobject->isReleaseMimeType){ - $new_dn= "cn=".$baseobject->cn.",".get_ou('mimetypeou').$baseobject->base; - }else{ - $new_dn ="cn=".$baseobject->cn.",".$mimefilter['release']; - } - }else{ - $new_dn= "cn=".$baseobject->cn.",".get_ou('mimetypeou').$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(); - } - -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/personal/environment/class_environment.inc b/gosa-core/plugins/personal/environment/class_environment.inc deleted file mode 100644 index fe0be1d01..000000000 --- a/gosa-core/plugins/personal/environment/class_environment.inc +++ /dev/null @@ -1,1772 +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; - - var $multiple_support =TRUE; - - var $use_gotoPrinter; - - 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{ - msg_dialog::display(_("Warning"), sprintf(_("Device '%s' is not available anymore. It will be removed!"), $this->attrs['gotoHotplugDeviceDN'][$i]), WARNING_DIALOG); - } - } - } - - - /* 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{ - msg_dialog::display(_("Configuration error"), sprintf(_("Cannot open file '%s'!"), $file), WARNING_DIALOG); - } - } - - $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)){ - $this->gotoKioskProfile_Server ="none"; - $this->gotoKioskProfile_Profile=""; - msg_dialog::display(_("Warning"), sprintf(_("Kiosk profile '%s' located on server '%s' is not available anymore. Kiosk profile will be disabled!"), $this->gotoKioskProfile_Profile, $this->gotoKioskProfile_Server), WARNING_DIALOG); - } - } - - - /* 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) && !session::is_set('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 */ - msg_dialog::display(_("Warning"), sprintf(_("Profile server '%s' is not available anymore. Switched to server '%s'."), $this->gotoProfileServer, $new), WARNING_DIALOG); - }else{ - - /* No other profile servers found */ - msg_dialog::display(_("Warning"), sprintf(_("Profile server '%s' is not available anymore. Kiosk profile will be disabled."), $this->gotoProfileServer), WARNING_DIALOG); - $this->gotoProfileServer = "none"; - } - } - } - - $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; - } - } - } - } - - /* Reset header toggle */ - if($this->multiple_support_active){ - $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"); - } - - - $smarty->assign("useProfile",$this->useProfile); - if(empty($this->useProfile) && !$this->multiple_support_active){ - $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")){ - msg_dialog::display(_("Permission error"), _("You have no permission to modify logon scripts!"), ERROR_DIALOG); - 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){ - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - }else{ - $tmp = $this->dialog->save(); - unset($this->dialog); - $this->dialog=FALSE; - $this->is_dialog=false; - - if($this->multiple_support_active){ - $tmp['UsedByAllUsers'] = TRUE; - } - $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*/ - if($this->multiple_support_active){ - $smarty->assign("gotoLogonScripts", $this->gotoLogonScripts); - $smarty->assign("gotoLogonScriptKeysCnt",count($this->gotoLogonScripts)); - }else{ - $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)){ - $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') == ""){ - msg_dialog::display(_("Error"), _("Please select a valid share!"), ERROR_DIALOG); - }elseif((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){ - msg_dialog::display(_("Error"), _("Please specify a valid mount point!"), ERROR_DIALOG); - }elseif(preg_match('/ /', $_POST['gotoShareMountPoint'])){ - msg_dialog::display(_("Error"), _("You cannot use spaces in the mount path!"), ERROR_DIALOG); - }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']) - ) - ){ - msg_dialog::display(_("Error"), _("Please specify a valid mount point!"), ERROR_DIALOG); - }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($this->multiple_support_active){ - $this->gotoShares[$a_share['name']."|".$a_share['server']]['UsedByAllUsers']= TRUE; - } - } - } - - /* 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; - } - - $color = ""; - if($this->multiple_support_active){ - if($this->gotoShares[$key]['UsedByAllUsers']){ - $value .= " ("._("Used by all users").")"; - }else{ - $color = "color: #999999;"; - $value .= " ("._("Used by some users").")"; - } - } - - /* 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."" , "attach" => "style='".$color."'"); - $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 , "attach" => "style='".$color."'"); - $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){ - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - }else{ - $this->dialog->save_object(); - $a_tmp = $this->dialog->save(); - - if(is_array($a_tmp)){ - foreach($a_tmp as $name => $hotplug){ - if($this->multiple_support_active){ - $hotplug['UsedByAllUsers'] = TRUE; - } - $this->gotoHotplugDevices[$name]= $hotplug; - } - } - unset($this->dialog); - $this->dialog= FALSE; - $this->is_dialog = false; - } - } - - if($this->multiple_support_active){ - $smarty->assign("gotoHotplugDevices",$this->gotoHotplugDevices); - }else{ - $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){ - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - }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($this->multiple_support_active){ - $type = "AddUser"; - }elseif(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){ - msg_dialog::display(_("Error"), _("Cannot set default printer flag for groups!"), ERROR_DIALOG); - }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); - } - - /* Assign used attributes for multiple edit */ - foreach(array("gotoPrinter","kiosk_server","gotoProfileFlagL","gotoXResolution", - "useProfile","gotoProfileServer","gotoProfileQuota","gotoProfileFlagC") as $box){ - $ubox ="use_".$box; - if(in_array($box,$this->multi_boxes)){ - $smarty->assign($ubox,TRUE); - }else{ - $smarty->assign($ubox,FALSE); - } - } - - /* Als smarty vars are set. Get smarty template and generate output */ - $smarty->assign("multiple_support",$this->multiple_support_active); - $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) && !session::is_set('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); - } - - - function multiple_execute() - { - /* Reset header toggle */ - $this->is_account = TRUE; - return($this->execute()); - } - - - /* Initialize plugin with given atribute arrays - */ - function init_multiple_support($attrs,$all) - { - plugin::init_multiple_support($attrs,$all); - - /* Prepare Shares */ - if((isset($this->multi_attrs_all['gotoShare']))&&(is_array($this->multi_attrs_all['gotoShare']))){ - unset($this->multi_attrs_all['gotoShare']['count']); - foreach($this->multi_attrs_all['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'] =""; - } - $tmp2['UsedByAllUsers'] = FALSE; - $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; - } - } - - /* Prepare Shares */ - if((isset($this->multi_attrs['gotoShare']))&&(is_array($this->multi_attrs['gotoShare']))){ - unset($this->multi_attrs['gotoShare']['count']); - foreach($this->multi_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'] =""; - } - $tmp2['UsedByAllUsers'] = TRUE; - $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; - } - } - - - /* prepare LogonScripts */ - if((isset($this->multi_attrs_all['gotoLogonScript']))&&(is_array($this->multi_attrs_all['gotoLogonScript']))){ - unset($this->multi_attrs_all['gotoLogonScript']['count']); - foreach($this->multi_attrs_all['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]; - $tmp2['UsedByAllUsers'] = FALSE; - $this->gotoLogonScripts[$tmp[0]]=$tmp2; - } - } - - /* prepare LogonScripts */ - if((isset($this->multi_attrs['gotoLogonScript']))&&(is_array($this->multi_attrs['gotoLogonScript']))){ - unset($this->multi_attrs['gotoLogonScript']['count']); - foreach($this->multi_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]; - $tmp2['UsedByAllUsers'] = TRUE; - $this->gotoLogonScripts[$tmp[0]]=$tmp2; - } - } - - /* Prepare hotplugs */ - if(isset($this->multi_attrs_all['gotoHotplugDeviceDN']) && is_array($this->multi_attrs_all['gotoHotplugDeviceDN'])){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - for($i = 0 ; $i < $this->multi_attrs_all['gotoHotplugDeviceDN']['count'] ; $i ++){ - $ldap->cat($this->multi_attrs_all['gotoHotplugDeviceDN'][$i]); - if($ldap->count()){ - $multi_attrs_all = $ldap->fetch(); - - if(isset($multi_attrs_all['gotoHotplugDevice'][0])){ - $tmp = preg_split("/\|/",$multi_attrs_all['gotoHotplugDevice'][0]); - $tmp2 = array(); - $tmp2['name'] = $multi_attrs_all['cn'][0]; - $tmp2['description'] = $tmp[0]; - $tmp2['id'] = $tmp[1]; - $tmp2['produkt'] = $tmp[2]; - $tmp2['vendor'] = $tmp[3]; - $tmp2['dn'] = $multi_attrs_all['dn']; - $tmp2['UsedByAllUsers'] = FALSE; - $this->gotoHotplugDevices[$tmp2['dn']] = $tmp2; - } - } - } - } - - /* Prepare hotplugs */ - if(isset($this->multi_attrs['gotoHotplugDeviceDN']) && is_array($this->multi_attrs['gotoHotplugDeviceDN'])){ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - for($i = 0 ; $i < $this->multi_attrs['gotoHotplugDeviceDN']['count'] ; $i ++){ - $ldap->cat($this->multi_attrs['gotoHotplugDeviceDN'][$i]); - if($ldap->count()){ - $multi_attrs = $ldap->fetch(); - - if(isset($multi_attrs['gotoHotplugDevice'][0])){ - $tmp = preg_split("/\|/",$multi_attrs['gotoHotplugDevice'][0]); - $tmp2 = array(); - $tmp2['name'] = $multi_attrs['cn'][0]; - $tmp2['description'] = $tmp[0]; - $tmp2['id'] = $tmp[1]; - $tmp2['produkt'] = $tmp[2]; - $tmp2['vendor'] = $tmp[3]; - $tmp2['dn'] = $multi_attrs['dn']; - $tmp2['UsedByAllUsers'] = TRUE; - $this->gotoHotplugDevices[$tmp2['dn']] = $tmp2; - } - } - } - } - $this->gotoHotplugDevices = array_values($this->gotoHotplugDevices); - for($i = 0 ; $i < strlen($this->gotoProfileFlags) ; $i ++){ - $chr = $this->gotoProfileFlags[$i]; - $name = "gotoProfileFlag".$chr; - $this->$name=$chr; - } - $this->update_kiosk_profiles(); - $this->gotoKioskProfile= preg_replace("/^.*\//i","",$this->gotoKioskProfile); - - if((!empty($this->gotoProfileServer))||($this->gotoProfileFlagC=="C")){ - $this->useProfile = true; - }else{ - $this->useProfile = false; - } - - } - - - function set_multi_edit_values($attrs) - { - $shares = $this->gotoShares; - $scripts= $this->gotoLogonScripts; - $plugs= $this->gotoHotplugDevices; - plugin::set_multi_edit_values($attrs); - - $this->gotoShares = $shares; - $this->gotoLogonScripts = $scripts; - $this->gotoHotplugDevices = $plugs; - - foreach($attrs['gotoShares'] as $name => $share){ - if($share['UsedByAllUsers'] == TRUE){ - $this->gotoShares[$name] = $share; - } - } - foreach($this->gotoShares as $name => $share){ - if(!isset($attrs['gotoShares'][$name])){ - unset($this->gotoShares[$name]); - } - } - foreach($attrs['gotoLogonScripts'] as $name => $script){ - if($script['UsedByAllUsers'] == TRUE){ - $this->gotoLogonScripts[$name] = $script; - } - } - foreach($this->gotoLogonScripts as $name => $script){ - if(!isset($attrs['gotoLogonScripts'][$name])){ - unset($this->gotoLogonScripts[$name]); - } - } - $tmp = array(); - foreach($this->gotoHotplugDevices as $entry){ - $tmp[$entry['dn']] = $entry; - } - - foreach($attrs['gotoHotplugDevices'] as $name => $plug){ - if($plug['UsedByAllUsers'] == TRUE){ - $tmp[$plug['dn']] = $plug; - } - } - foreach($tmp as $name => $plug){ - $found = false; - foreach($attrs['gotoHotplugDevices'] as $test){ - if($test['dn'] == $name){ - $found = true; - } - } - if(!$found){ - unset($tmp[$name]); - } - } - } - - - /* Return selected values for multiple edit */ - function get_multi_edit_values() - { - $ret = plugin::get_multi_edit_values(); - $ret['gotoShares'] = $this->gotoShares; - $ret['gotoLogonScripts'] = $this->gotoLogonScripts; - $ret['gotoHotplugDevices'] = $this->gotoHotplugDevices; - - if(in_array("gotoPrinter",$this->multi_boxes)){ - $ret['gotoPrinter'] = $this->gotoPrinter; - $ret['gotoPrinterSel'] = $this->gotoPrinterSel; - $ret['gosaDefaultPrinter'] = $this->gosaDefaultPrinter; - - /* Force printer reset */ - $ret['add_del_printer_member_was_called'] = TRUE; - } - - if(in_array("gotoProfileFlagL",$this->multi_boxes)){ - $ret['gotoProfileFlagL'] = $this->gotoProfileFlagL; - } - - if(in_array("useProfile",$this->multi_boxes)){ - $ret['useProfile']=$this->useProfile; - if(in_array("gotoProfileServer",$this->multi_boxes)){ - $ret['gotoProfileServer']=$this->gotoProfileServer; - } - if(in_array("gotoProfileQuota",$this->multi_boxes)){ - $ret['gotoProfileQuota']=$this->gotoProfileQuota; - } - if(in_array("gotoProfileFlagC",$this->multi_boxes)){ - $ret['gotoProfileFlagC'] = $this->gotoProfileFlagC; - } - } - if(in_array("gotoXResolution",$this->multi_boxes)){ - $ret['gotoXResolution'] = $this->gotoXResolution; - } - if(in_array("kiosk_server",$this->multi_boxes)){ - $ret['gotoKioskProfile_Server'] = $this->gotoKioskProfile_Server; - $ret['gotoKioskProfile_Profile'] = $this->gotoKioskProfile_Profile; - } - return($ret); - } - - - function multiple_check() - { - $message = plugin::multiple_check(); - $this->detect_grouptype(); - - if(preg_match("/[^0-9]/",$this->gotoProfileQuota) && in_array("gotoProfileQuota",$this->multi_boxes)) { - $message[]=_("Please set a valid profile quota size."); - } - return($message); - } - - - function multiple_save_object() - { - if(isset($_POST['environment_multiple_posted'])){ - plugin::multiple_save_object(); - - if(isset($_POST['useProfile'])){ - $this->useProfile = true; - }else{ - $this->useProfile = false; - } - if(isset($_POST['gotoProfileFlagC'])){ - $this->gotoProfileFlagC = $_POST['gotoProfileFlagC']; - }else{ - $this->gotoProfileFlagC = false; - } - - if(isset($_POST['gotoProfileFlagL'])){ - $this->gotoProfileFlagL = $_POST['gotoProfileFlagL']; - }else{ - $this->gotoProfileFlagL = false; - } - - foreach(array("gotoProfileFlagL","gotoPrinter","kiosk_server","gotoXResolution", - "useProfile","gotoProfileServer","gotoProfileQuota","gotoProfileFlagC") as $attr){ - $uattr = "use_".$attr; - if(isset($_POST[$uattr])){ - $this->multi_boxes[] = $attr; - } - } - 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']; - } - } - - } - } - - /* 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 deleted file mode 100644 index b3a20f894..000000000 --- a/gosa-core/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::get('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(get_ou('deviceou').$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 deleted file mode 100644 index f125ad096..000000000 --- a/gosa-core/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/gosa-core/plugins/personal/environment/class_selectPrinterDialog.inc b/gosa-core/plugins/personal/environment/class_selectPrinterDialog.inc deleted file mode 100644 index b1ebc4960..000000000 --- a/gosa-core/plugins/personal/environment/class_selectPrinterDialog.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(); - 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= get_ou('printerou').$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 deleted file mode 100644 index d1370f6d1..000000000 --- a/gosa-core/plugins/personal/environment/environment.tpl +++ /dev/null @@ -1,405 +0,0 @@ -{if $is_account ne 'true'} - - {t}The environment extension is currently disabled.{/t} -{else} - - - - -

- - {t}Profiles{/t} -

- - - - - - -
- - -{if $multiple_support} - - {render acl=$gotoProfileACL checkbox=$multiple_support checked=$use_useProfile} - {t}Use profile managment{/t} - {/render} -
- {render acl=$gotoProfileServerACL checkbox=$multiple_support checked=$use_gotoProfileServer} - {t}Profil path{/t} - - {/render} -
- {render acl=$gotoProfileQuotaACL checkbox=$multiple_support checked=$use_gotoProfileQuota} - {t}MB{/t} - {/render} -
- {render acl=$gotoProfileFlagCACL checkbox=$multiple_support checked=$use_gotoProfileFlagC} -   - {t}Cache profile localy{/t} - {/render} - -{else} - - - - - - - - - - - -
-{render acl=$gotoProfileACL} - -{/render} - - -
  - - - - - - - - - - - - - -
- - -{render acl=$gotoProfileServerACL} - -{if $gotoProfileServerWriteable} - -{else} - -{/if} -{/render} -
- -
-
-
-{render acl=$gotoProfileQuotaACL} - {t}MB{/t} -{/render} -
-
-
-{render acl=$gotoProfileFlagCACL} -   -{/render} - -
-
- -{/if} - -
- - -{if $kiosk_enabled } - - - - - - - - {else} - - - - -{/if} - - - - - - - -
- -
-{if $multiple_support} - -{/if} - {t}Server{/t} - - - {if $kiosk_server != "none"} - {t}Profile{/t} - - {else} -   - {/if} -
- - - - -
-
-{render acl=$gotoProfileFlagLACL checkbox=$multiple_support checked=$use_gotoProfileFlagL} - -{/render} - -
-{if $multiple_support} - -{/if} - - -{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} -
-
- - -{if $multiple_support} - -

- -   - -

- - - -{else} - -

-   - -

- - - - -
-{render acl=$gotoPrinterACL} - -{/render} -
-{render acl=$gotoPrinterACL} - -{/render} -{render acl=$gotoPrinterACL} - -{/render} -{render acl=$gotoPrinterACL} - -{/render} -{render acl=$gosaDefaultPrinterACL} - -{/render} -
- -{/if} - -
-{if $multiple_support} - -{/if} - -{/if} - diff --git a/gosa-core/plugins/personal/environment/hotplugDialog.tpl b/gosa-core/plugins/personal/environment/hotplugDialog.tpl deleted file mode 100644 index 868e72b00..000000000 --- a/gosa-core/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/gosa-core/plugins/personal/environment/logonManagement.tpl b/gosa-core/plugins/personal/environment/logonManagement.tpl deleted file mode 100644 index 746be6fe1..000000000 --- a/gosa-core/plugins/personal/environment/logonManagement.tpl +++ /dev/null @@ -1,84 +0,0 @@ -

 {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 deleted file mode 100644 index 4a31aef58..000000000 --- a/gosa-core/plugins/personal/environment/main.inc +++ /dev/null @@ -1,126 +0,0 @@ -dn); - session::un_set ('edit'); - session::un_set ('environment'); - } - - /* Create mail object on demand */ - if (!session::is_set('environment') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $environment= new environment ($config, $ui->dn); - $environment->enable_CSN_check(); - $environment->set_acl_category('users'); - $environment->set_acl_base($ui->dn); - session::set('environment',$environment); - } - $environment = session::get('environment'); - - /* save changes back to object */ - if (session::is_set('edit')){ - $environment->save_object (); - } - - /* Enter edit mode? */ - if (isset($_POST['edit'])){ - - /* Check locking */ - if (($username= get_lock($ui->dn)) != ""){ - session::set('back_plugin',$plug); - session::set('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::set('dn',$ui->dn); - session::set('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); - session::un_set ('edit'); - - /* Remove object */ - session::un_set ('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 (session::is_set('edit')){ - session::set('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 ((session::is_set('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 deleted file mode 100644 index f07674d39..000000000 --- a/gosa-core/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/gosa-plugins/goto/admin/applications/class_applicationGeneric.inc b/gosa-plugins/goto/admin/applications/class_applicationGeneric.inc new file mode 100644 index 000000000..247acf972 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/class_applicationGeneric.inc @@ -0,0 +1,572 @@ + "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); + + $appfilter = session::get('appfilter') ; + + $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)) { + if(!preg_match("/^".get_ou('applicationou')."/",$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::set('binary',$this->iconData); + session::set('binarytype',"image/jpeg"); + $this->gosaApplicationIcon= $this->iconData; + + /* This is always an account */ + $this->is_account= TRUE; + + if ($this->dn == "new"){ + if(session::is_set('CurrentMainBase')){ + $this->base = session::get('CurrentMainBase'); + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + + if($this->isReleaseApplikation){ + $this->base = preg_replace("/^.*,".get_ou('applicationou')."/","",$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::set('binary',$this->gotoLogonScript); + session::set('binarytype',"octet-stream"); + session::set('binaryfile',$this->cn.".gosaApplication"); + header("location: getbin.php "); + exit(); + } + } + + /* Reassign picture data, sometimes its corrupt cause we started a download of application scripts */ + session::set('binary',$this->iconData); + session::set('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=".LDAP::prepare4filter($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.",".get_ou('applicationou').$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')); + $appfilter = session::get('appfilter'); + if((!empty($tmp)) && (isset($appfilter['release']))){ + $baseDn = str_replace($this->config->current['BASE'],$this->base,$appfilter['release']); + $baseDn = preg_replace("/".get_ou('applicationou').".*/",get_ou('applicationou').$this->base,$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."))",get_ou('applicationou').$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::set('binary',$this->iconData); + session::set('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-plugins/goto/admin/applications/class_applicationManagement.inc b/gosa-plugins/goto/admin/applications/class_applicationManagement.inc new file mode 100644 index 000000000..c7810321e --- /dev/null +++ b/gosa-plugins/goto/admin/applications/class_applicationManagement.inc @@ -0,0 +1,647 @@ +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 = get_ou('applicationou').$base; + $ret = array(); + $ret [get_ou('applicationou').$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::set('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; + session::un_set('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; + session::un_set('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::set('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); + session::un_set('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 = get_ou('applicationou').$base; + }else{ + if(isset($Releases[$release])){ + $use_base = $release; + }else{ + $use_base = get_ou('applicationou').$base; + } + } + + if($SubSearch){ + $Flags |= GL_SUBSEARCH; + } + + $res= get_sub_list($Filter, "application",get_ou('applicationou'), $use_base, array("cn","description","dn","objectClass"), $Flags); + $tmp2 = array(); + foreach ($res as $val){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; + $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn']; + } + + natcasesort($tmp2); + $this->applications=array(); + foreach($tmp2 as $val){ + $this->applications[]=$tmp[$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-plugins/goto/admin/applications/class_applicationParameters.inc b/gosa-plugins/goto/admin/applications/class_applicationParameters.inc new file mode 100644 index 000000000..9f11eb6b9 --- /dev/null +++ b/gosa-plugins/goto/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-plugins/goto/admin/applications/class_divListApplication.inc b/gosa-plugins/goto/admin/applications/class_divListApplication.inc new file mode 100644 index 000000000..f70d5c618 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/class_divListApplication.inc @@ -0,0 +1,323 @@ +selectedRelease = get_ou('applicationou').session::get('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(); + $appfilter = session::get('appfilter'); + $appfilter['release'] = $this->selectedRelease; + session::set('appfilter',$appfilter); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/admin/applications/generic.tpl b/gosa-plugins/goto/admin/applications/generic.tpl new file mode 100644 index 000000000..b50ed7eb8 --- /dev/null +++ b/gosa-plugins/goto/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-plugins/goto/admin/applications/main.inc b/gosa-plugins/goto/admin/applications/main.inc new file mode 100644 index 000000000..7b748386a --- /dev/null +++ b/gosa-plugins/goto/admin/applications/main.inc @@ -0,0 +1,55 @@ +remove_lock(); + del_lock ($ui->dn); + session::un_set ('applicationManagement'); + } +} else { + /* Create applicationManagement object on demand */ + if (!session::is_set('applicationManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + session::set('applicationManagement',new applicationManagement ($config, $ui)); + } + $applicationManagement = session::get('applicationManagement'); + $applicationManagement->save_object(); + $output= $applicationManagement->execute(); + + /* Page header*/ + if (session::is_set('objectinfo')){ + $display= print_header(get_template_path('images/application.png'), _("Application management"), "\"\" ".@LDAP::fix(session::get('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); + session::un_set ('applicationManagement'); + } + + /* Show and save dialog */ + $display.= $output; + session::set('applicationManagement',$applicationManagement); +} + +?> diff --git a/gosa-plugins/goto/admin/applications/parameters.tpl b/gosa-plugins/goto/admin/applications/parameters.tpl new file mode 100644 index 000000000..57c221971 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/parameters.tpl @@ -0,0 +1,2 @@ +{$table} +
diff --git a/gosa-plugins/goto/admin/applications/release_select.tpl b/gosa-plugins/goto/admin/applications/release_select.tpl new file mode 100644 index 000000000..d58738f05 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/release_select.tpl @@ -0,0 +1,16 @@ +
+
+

[F]{t}Branches{/t}

+
+
+ + + + +
+ {t}Current release{/t}  + +
+
diff --git a/gosa-plugins/goto/admin/applications/remove.tpl b/gosa-plugins/goto/admin/applications/remove.tpl new file mode 100644 index 000000000..8598ed857 --- /dev/null +++ b/gosa-plugins/goto/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-plugins/goto/admin/applications/tabs_application.inc b/gosa-plugins/goto/admin/applications/tabs_application.inc new file mode 100644 index 000000000..5b6e82989 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/tabs_application.inc @@ -0,0 +1,59 @@ +addSpecialTabs(); + } + + function set_release($newRelease) + { + $this->Release= preg_replace('/,'.get_ou('applicationou').'.*$/', '', $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')); + $appfilter = session::get('appfilter'); + if((!empty($tmp)) && (isset($appfilter['release']))){ + if(!$baseobject->isReleaseApplikation){ + $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$baseobject->base; + }else{ + $new_dn ="cn=".$baseobject->cn.",".$appfilter['release']; + } + }else{ + $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$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(); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc b/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc new file mode 100644 index 000000000..bc870eb74 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc @@ -0,0 +1,256 @@ +is_account = TRUE; + + $this->types= array("camera" => _("Digital camera"), + "harddisk" => _("Harddisk"), + "stick" => _("USB stick"), + "cd" => _("CD/DVD drive"),); + asort($this->types); + + /* 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]; + if (isset($tmp[4])){ + $this->type= $tmp[4]; + } + } + + $this->orig_cn = $this->cn; + + /* Set Base */ + if ($this->dn == "new"){ + if(session::is_set('CurrentMainBase')){ + $this->base = session::get('CurrentMainBase'); + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->base =preg_replace ("/^[^,]+,".get_ou('deviceou')."/","",$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); + } + + $smarty->assign("type",$this->type); + $smarty->assign ("types", $this->types); + + 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-plugins/goto/admin/devices/class_deviceManagement.inc b/gosa-plugins/goto/admin/devices/class_deviceManagement.inc new file mode 100644 index 000000000..77c582575 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/class_deviceManagement.inc @@ -0,0 +1,557 @@ +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::set('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; + session::un_set('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; + session::un_set('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::set('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); + session::un_set('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(get_ou('deviceou').$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 = get_ou('deviceou').$base; + } + + /* Get results and create index */ + $res= get_sub_list($Filter,"devices",get_ou('deviceou'), $base, array("cn","description","dn","objectClass"), $Flags); + $tmp2 = array(); + foreach ($res as $val){ + $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn']; + $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; + } + + /* sort entries */ + natcasesort($tmp2); + $this->devices=array(); + foreach($tmp2 as $val){ + $this->devices[]=$tmp[$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-plugins/goto/admin/devices/class_divListDevices.inc b/gosa-plugins/goto/admin/devices/class_divListDevices.inc new file mode 100644 index 000000000..e9d5f8522 --- /dev/null +++ b/gosa-plugins/goto/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,".get_ou('deviceou').$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-plugins/goto/admin/devices/deviceGeneric.tpl b/gosa-plugins/goto/admin/devices/deviceGeneric.tpl new file mode 100644 index 000000000..863851e44 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/deviceGeneric.tpl @@ -0,0 +1,75 @@ + +

{t}Devices{/t}

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

{t}Devices{/t}

+ + + + +
+ + + + + +
{$must} + + +
+
+ + + + diff --git a/gosa-plugins/goto/admin/devices/remove.tpl b/gosa-plugins/goto/admin/devices/remove.tpl new file mode 100644 index 000000000..643056cd3 --- /dev/null +++ b/gosa-plugins/goto/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-plugins/goto/admin/devices/tabs_devices.inc b/gosa-plugins/goto/admin/devices/tabs_devices.inc new file mode 100644 index 000000000..0feddfc4e --- /dev/null +++ b/gosa-plugins/goto/admin/devices/tabs_devices.inc @@ -0,0 +1,38 @@ +addSpecialTabs(); + } + + function save($ignore_account= FALSE) + { + $baseobject= $this->by_object['deviceGeneric']; + $new_dn= "cn=".$baseobject->cn.",".get_ou('deviceou').$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(); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc new file mode 100644 index 000000000..da73758aa --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc @@ -0,0 +1,345 @@ +selectedRelease = get_ou('mimetypeou').session::get('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,".get_ou('mimetypeou').$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); + } + $mimefilter = session::get('mimefilter'); + $mimefilter['release'] = $this->selectedRelease; + session::set('mimefilter',$mimefilter); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc new file mode 100644 index 000000000..03867ebab --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc @@ -0,0 +1,758 @@ + "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(session::is_set('CurrentMainBase')){ + $this->base= session::get('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::set('binary',$this->iconData); + session::set('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=".LDAP::prepare4filter($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"]); + + $mimefilter = session::get('mimefilter'); + + if($this->isReleaseMimeType && (isset($mimefilter['release']))){ + $baseDn = str_replace($this->config->current['BASE'],$this->base,$mimefilter['release']); + $baseDn = preg_replace("/".get_ou('mimetypeou').".*/",get_ou('mimetypeou').$this->base,$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."))",get_ou('mimetypeou').$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::set('binary',$this->iconData); + session::set('binarytype',"image/jpeg"); + fclose ($fd); + } + } + + /* Get picture link */ + function get_picture() + { + session::set('binary',$this->iconData); + session::set('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-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc new file mode 100644 index 000000000..7af6280d7 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc @@ -0,0 +1,666 @@ +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 = get_ou('mimetypeou').$base; + $ret = array(); + $ret [get_ou('mimetypeou').$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::set('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; + session::un_set('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; + session::un_set('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::set('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); + session::un_set('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 = get_ou('mimetypeou').$use_base; + } + } + + /* Get results and create index */ + $res= get_sub_list($Filter, "mimetypes",get_ou('mimetypeou'), $use_base, array("cn","description","dn","objectClass"), $Flags); + $tmp2 = array(); + foreach ($res as $val){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; + $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn']; + } + + /* sort entries */ + natcasesort($tmp2); + $this->mimetypes=array(); + foreach($tmp2 as $val){ + $this->mimetypes[]=$tmp[$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-plugins/goto/admin/mimetypes/generic.tpl b/gosa-plugins/goto/admin/mimetypes/generic.tpl new file mode 100644 index 000000000..1cb6d7549 --- /dev/null +++ b/gosa-plugins/goto/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-plugins/goto/admin/mimetypes/main.inc b/gosa-plugins/goto/admin/mimetypes/main.inc new file mode 100644 index 000000000..de9214254 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/main.inc @@ -0,0 +1,57 @@ +remove_lock(); + del_lock ($ui->dn); + session::un_set ('MimeTypeManagement'); + } +} else { + + /* Create MimeTypeManagement object on demand */ + if (!session::is_set('MimeTypeManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + session::set('MimeTypeManagement',new mimetypeManagement ($config, $ui)); + } + + /* Get object */ + $MimeTypeManagement = session::get('MimeTypeManagement'); + $MimeTypeManagement->save_object(); + $output= $MimeTypeManagement->execute(); + + /* Page header*/ + if (session::is_set('objectinfo')){ + $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "\"\" ".@LDAP::fix(session::get('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); + session::un_set ('MimeTypeManagement'); + } + + /* Show and save dialog */ + $display.= $output; + session::set('MimeTypeManagement',$MimeTypeManagement); +} +?> diff --git a/gosa-plugins/goto/admin/mimetypes/paste_generic.tpl b/gosa-plugins/goto/admin/mimetypes/paste_generic.tpl new file mode 100644 index 000000000..34b5e0751 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/paste_generic.tpl @@ -0,0 +1,31 @@ + + + + + + + +
+

 {t}Generic{/t}

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

[F]{t}Branches{/t}

+
+
+ + + + +
+ {t}Current release{/t}  + +
+
diff --git a/gosa-plugins/goto/admin/mimetypes/remove.tpl b/gosa-plugins/goto/admin/mimetypes/remove.tpl new file mode 100644 index 000000000..30c423318 --- /dev/null +++ b/gosa-plugins/goto/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-plugins/goto/admin/mimetypes/tabs_mimetypes.inc b/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc new file mode 100644 index 000000000..38570fde2 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc @@ -0,0 +1,61 @@ +addSpecialTabs(); + } + + function set_release($newRelease) + { + $this->Release= preg_replace('/,'.get_ou('mimetypeou').'.*$/', '', $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')); + + $mimefilter = session::get('mimefilter'); + + if((!empty($tmp)) && (isset($mimefilter['release']))){ + if(!$baseobject->isReleaseMimeType){ + $new_dn= "cn=".$baseobject->cn.",".get_ou('mimetypeou').$baseobject->base; + }else{ + $new_dn ="cn=".$baseobject->cn.",".$mimefilter['release']; + } + }else{ + $new_dn= "cn=".$baseobject->cn.",".get_ou('mimetypeou').$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(); + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/personal/environment/class_environment.inc b/gosa-plugins/goto/personal/environment/class_environment.inc new file mode 100644 index 000000000..fe0be1d01 --- /dev/null +++ b/gosa-plugins/goto/personal/environment/class_environment.inc @@ -0,0 +1,1772 @@ + "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; + + var $multiple_support =TRUE; + + var $use_gotoPrinter; + + 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{ + msg_dialog::display(_("Warning"), sprintf(_("Device '%s' is not available anymore. It will be removed!"), $this->attrs['gotoHotplugDeviceDN'][$i]), WARNING_DIALOG); + } + } + } + + + /* 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{ + msg_dialog::display(_("Configuration error"), sprintf(_("Cannot open file '%s'!"), $file), WARNING_DIALOG); + } + } + + $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)){ + $this->gotoKioskProfile_Server ="none"; + $this->gotoKioskProfile_Profile=""; + msg_dialog::display(_("Warning"), sprintf(_("Kiosk profile '%s' located on server '%s' is not available anymore. Kiosk profile will be disabled!"), $this->gotoKioskProfile_Profile, $this->gotoKioskProfile_Server), WARNING_DIALOG); + } + } + + + /* 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) && !session::is_set('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 */ + msg_dialog::display(_("Warning"), sprintf(_("Profile server '%s' is not available anymore. Switched to server '%s'."), $this->gotoProfileServer, $new), WARNING_DIALOG); + }else{ + + /* No other profile servers found */ + msg_dialog::display(_("Warning"), sprintf(_("Profile server '%s' is not available anymore. Kiosk profile will be disabled."), $this->gotoProfileServer), WARNING_DIALOG); + $this->gotoProfileServer = "none"; + } + } + } + + $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; + } + } + } + } + + /* Reset header toggle */ + if($this->multiple_support_active){ + $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"); + } + + + $smarty->assign("useProfile",$this->useProfile); + if(empty($this->useProfile) && !$this->multiple_support_active){ + $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")){ + msg_dialog::display(_("Permission error"), _("You have no permission to modify logon scripts!"), ERROR_DIALOG); + 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){ + msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); + } + }else{ + $tmp = $this->dialog->save(); + unset($this->dialog); + $this->dialog=FALSE; + $this->is_dialog=false; + + if($this->multiple_support_active){ + $tmp['UsedByAllUsers'] = TRUE; + } + $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*/ + if($this->multiple_support_active){ + $smarty->assign("gotoLogonScripts", $this->gotoLogonScripts); + $smarty->assign("gotoLogonScriptKeysCnt",count($this->gotoLogonScripts)); + }else{ + $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)){ + $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') == ""){ + msg_dialog::display(_("Error"), _("Please select a valid share!"), ERROR_DIALOG); + }elseif((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){ + msg_dialog::display(_("Error"), _("Please specify a valid mount point!"), ERROR_DIALOG); + }elseif(preg_match('/ /', $_POST['gotoShareMountPoint'])){ + msg_dialog::display(_("Error"), _("You cannot use spaces in the mount path!"), ERROR_DIALOG); + }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']) + ) + ){ + msg_dialog::display(_("Error"), _("Please specify a valid mount point!"), ERROR_DIALOG); + }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($this->multiple_support_active){ + $this->gotoShares[$a_share['name']."|".$a_share['server']]['UsedByAllUsers']= TRUE; + } + } + } + + /* 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; + } + + $color = ""; + if($this->multiple_support_active){ + if($this->gotoShares[$key]['UsedByAllUsers']){ + $value .= " ("._("Used by all users").")"; + }else{ + $color = "color: #999999;"; + $value .= " ("._("Used by some users").")"; + } + } + + /* 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."" , "attach" => "style='".$color."'"); + $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 , "attach" => "style='".$color."'"); + $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){ + msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); + } + }else{ + $this->dialog->save_object(); + $a_tmp = $this->dialog->save(); + + if(is_array($a_tmp)){ + foreach($a_tmp as $name => $hotplug){ + if($this->multiple_support_active){ + $hotplug['UsedByAllUsers'] = TRUE; + } + $this->gotoHotplugDevices[$name]= $hotplug; + } + } + unset($this->dialog); + $this->dialog= FALSE; + $this->is_dialog = false; + } + } + + if($this->multiple_support_active){ + $smarty->assign("gotoHotplugDevices",$this->gotoHotplugDevices); + }else{ + $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){ + msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); + } + }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($this->multiple_support_active){ + $type = "AddUser"; + }elseif(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){ + msg_dialog::display(_("Error"), _("Cannot set default printer flag for groups!"), ERROR_DIALOG); + }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); + } + + /* Assign used attributes for multiple edit */ + foreach(array("gotoPrinter","kiosk_server","gotoProfileFlagL","gotoXResolution", + "useProfile","gotoProfileServer","gotoProfileQuota","gotoProfileFlagC") as $box){ + $ubox ="use_".$box; + if(in_array($box,$this->multi_boxes)){ + $smarty->assign($ubox,TRUE); + }else{ + $smarty->assign($ubox,FALSE); + } + } + + /* Als smarty vars are set. Get smarty template and generate output */ + $smarty->assign("multiple_support",$this->multiple_support_active); + $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) && !session::is_set('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); + } + + + function multiple_execute() + { + /* Reset header toggle */ + $this->is_account = TRUE; + return($this->execute()); + } + + + /* Initialize plugin with given atribute arrays + */ + function init_multiple_support($attrs,$all) + { + plugin::init_multiple_support($attrs,$all); + + /* Prepare Shares */ + if((isset($this->multi_attrs_all['gotoShare']))&&(is_array($this->multi_attrs_all['gotoShare']))){ + unset($this->multi_attrs_all['gotoShare']['count']); + foreach($this->multi_attrs_all['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'] =""; + } + $tmp2['UsedByAllUsers'] = FALSE; + $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; + } + } + + /* Prepare Shares */ + if((isset($this->multi_attrs['gotoShare']))&&(is_array($this->multi_attrs['gotoShare']))){ + unset($this->multi_attrs['gotoShare']['count']); + foreach($this->multi_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'] =""; + } + $tmp2['UsedByAllUsers'] = TRUE; + $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2; + } + } + + + /* prepare LogonScripts */ + if((isset($this->multi_attrs_all['gotoLogonScript']))&&(is_array($this->multi_attrs_all['gotoLogonScript']))){ + unset($this->multi_attrs_all['gotoLogonScript']['count']); + foreach($this->multi_attrs_all['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]; + $tmp2['UsedByAllUsers'] = FALSE; + $this->gotoLogonScripts[$tmp[0]]=$tmp2; + } + } + + /* prepare LogonScripts */ + if((isset($this->multi_attrs['gotoLogonScript']))&&(is_array($this->multi_attrs['gotoLogonScript']))){ + unset($this->multi_attrs['gotoLogonScript']['count']); + foreach($this->multi_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]; + $tmp2['UsedByAllUsers'] = TRUE; + $this->gotoLogonScripts[$tmp[0]]=$tmp2; + } + } + + /* Prepare hotplugs */ + if(isset($this->multi_attrs_all['gotoHotplugDeviceDN']) && is_array($this->multi_attrs_all['gotoHotplugDeviceDN'])){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + for($i = 0 ; $i < $this->multi_attrs_all['gotoHotplugDeviceDN']['count'] ; $i ++){ + $ldap->cat($this->multi_attrs_all['gotoHotplugDeviceDN'][$i]); + if($ldap->count()){ + $multi_attrs_all = $ldap->fetch(); + + if(isset($multi_attrs_all['gotoHotplugDevice'][0])){ + $tmp = preg_split("/\|/",$multi_attrs_all['gotoHotplugDevice'][0]); + $tmp2 = array(); + $tmp2['name'] = $multi_attrs_all['cn'][0]; + $tmp2['description'] = $tmp[0]; + $tmp2['id'] = $tmp[1]; + $tmp2['produkt'] = $tmp[2]; + $tmp2['vendor'] = $tmp[3]; + $tmp2['dn'] = $multi_attrs_all['dn']; + $tmp2['UsedByAllUsers'] = FALSE; + $this->gotoHotplugDevices[$tmp2['dn']] = $tmp2; + } + } + } + } + + /* Prepare hotplugs */ + if(isset($this->multi_attrs['gotoHotplugDeviceDN']) && is_array($this->multi_attrs['gotoHotplugDeviceDN'])){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + for($i = 0 ; $i < $this->multi_attrs['gotoHotplugDeviceDN']['count'] ; $i ++){ + $ldap->cat($this->multi_attrs['gotoHotplugDeviceDN'][$i]); + if($ldap->count()){ + $multi_attrs = $ldap->fetch(); + + if(isset($multi_attrs['gotoHotplugDevice'][0])){ + $tmp = preg_split("/\|/",$multi_attrs['gotoHotplugDevice'][0]); + $tmp2 = array(); + $tmp2['name'] = $multi_attrs['cn'][0]; + $tmp2['description'] = $tmp[0]; + $tmp2['id'] = $tmp[1]; + $tmp2['produkt'] = $tmp[2]; + $tmp2['vendor'] = $tmp[3]; + $tmp2['dn'] = $multi_attrs['dn']; + $tmp2['UsedByAllUsers'] = TRUE; + $this->gotoHotplugDevices[$tmp2['dn']] = $tmp2; + } + } + } + } + $this->gotoHotplugDevices = array_values($this->gotoHotplugDevices); + for($i = 0 ; $i < strlen($this->gotoProfileFlags) ; $i ++){ + $chr = $this->gotoProfileFlags[$i]; + $name = "gotoProfileFlag".$chr; + $this->$name=$chr; + } + $this->update_kiosk_profiles(); + $this->gotoKioskProfile= preg_replace("/^.*\//i","",$this->gotoKioskProfile); + + if((!empty($this->gotoProfileServer))||($this->gotoProfileFlagC=="C")){ + $this->useProfile = true; + }else{ + $this->useProfile = false; + } + + } + + + function set_multi_edit_values($attrs) + { + $shares = $this->gotoShares; + $scripts= $this->gotoLogonScripts; + $plugs= $this->gotoHotplugDevices; + plugin::set_multi_edit_values($attrs); + + $this->gotoShares = $shares; + $this->gotoLogonScripts = $scripts; + $this->gotoHotplugDevices = $plugs; + + foreach($attrs['gotoShares'] as $name => $share){ + if($share['UsedByAllUsers'] == TRUE){ + $this->gotoShares[$name] = $share; + } + } + foreach($this->gotoShares as $name => $share){ + if(!isset($attrs['gotoShares'][$name])){ + unset($this->gotoShares[$name]); + } + } + foreach($attrs['gotoLogonScripts'] as $name => $script){ + if($script['UsedByAllUsers'] == TRUE){ + $this->gotoLogonScripts[$name] = $script; + } + } + foreach($this->gotoLogonScripts as $name => $script){ + if(!isset($attrs['gotoLogonScripts'][$name])){ + unset($this->gotoLogonScripts[$name]); + } + } + $tmp = array(); + foreach($this->gotoHotplugDevices as $entry){ + $tmp[$entry['dn']] = $entry; + } + + foreach($attrs['gotoHotplugDevices'] as $name => $plug){ + if($plug['UsedByAllUsers'] == TRUE){ + $tmp[$plug['dn']] = $plug; + } + } + foreach($tmp as $name => $plug){ + $found = false; + foreach($attrs['gotoHotplugDevices'] as $test){ + if($test['dn'] == $name){ + $found = true; + } + } + if(!$found){ + unset($tmp[$name]); + } + } + } + + + /* Return selected values for multiple edit */ + function get_multi_edit_values() + { + $ret = plugin::get_multi_edit_values(); + $ret['gotoShares'] = $this->gotoShares; + $ret['gotoLogonScripts'] = $this->gotoLogonScripts; + $ret['gotoHotplugDevices'] = $this->gotoHotplugDevices; + + if(in_array("gotoPrinter",$this->multi_boxes)){ + $ret['gotoPrinter'] = $this->gotoPrinter; + $ret['gotoPrinterSel'] = $this->gotoPrinterSel; + $ret['gosaDefaultPrinter'] = $this->gosaDefaultPrinter; + + /* Force printer reset */ + $ret['add_del_printer_member_was_called'] = TRUE; + } + + if(in_array("gotoProfileFlagL",$this->multi_boxes)){ + $ret['gotoProfileFlagL'] = $this->gotoProfileFlagL; + } + + if(in_array("useProfile",$this->multi_boxes)){ + $ret['useProfile']=$this->useProfile; + if(in_array("gotoProfileServer",$this->multi_boxes)){ + $ret['gotoProfileServer']=$this->gotoProfileServer; + } + if(in_array("gotoProfileQuota",$this->multi_boxes)){ + $ret['gotoProfileQuota']=$this->gotoProfileQuota; + } + if(in_array("gotoProfileFlagC",$this->multi_boxes)){ + $ret['gotoProfileFlagC'] = $this->gotoProfileFlagC; + } + } + if(in_array("gotoXResolution",$this->multi_boxes)){ + $ret['gotoXResolution'] = $this->gotoXResolution; + } + if(in_array("kiosk_server",$this->multi_boxes)){ + $ret['gotoKioskProfile_Server'] = $this->gotoKioskProfile_Server; + $ret['gotoKioskProfile_Profile'] = $this->gotoKioskProfile_Profile; + } + return($ret); + } + + + function multiple_check() + { + $message = plugin::multiple_check(); + $this->detect_grouptype(); + + if(preg_match("/[^0-9]/",$this->gotoProfileQuota) && in_array("gotoProfileQuota",$this->multi_boxes)) { + $message[]=_("Please set a valid profile quota size."); + } + return($message); + } + + + function multiple_save_object() + { + if(isset($_POST['environment_multiple_posted'])){ + plugin::multiple_save_object(); + + if(isset($_POST['useProfile'])){ + $this->useProfile = true; + }else{ + $this->useProfile = false; + } + if(isset($_POST['gotoProfileFlagC'])){ + $this->gotoProfileFlagC = $_POST['gotoProfileFlagC']; + }else{ + $this->gotoProfileFlagC = false; + } + + if(isset($_POST['gotoProfileFlagL'])){ + $this->gotoProfileFlagL = $_POST['gotoProfileFlagL']; + }else{ + $this->gotoProfileFlagL = false; + } + + foreach(array("gotoProfileFlagL","gotoPrinter","kiosk_server","gotoXResolution", + "useProfile","gotoProfileServer","gotoProfileQuota","gotoProfileFlagC") as $attr){ + $uattr = "use_".$attr; + if(isset($_POST[$uattr])){ + $this->multi_boxes[] = $attr; + } + } + 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']; + } + } + + } + } + + /* 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-plugins/goto/personal/environment/class_hotplugDialog.inc b/gosa-plugins/goto/personal/environment/class_hotplugDialog.inc new file mode 100644 index 000000000..b3a20f894 --- /dev/null +++ b/gosa-plugins/goto/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::get('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(get_ou('deviceou').$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-plugins/goto/personal/environment/class_logonManagementDialog.inc b/gosa-plugins/goto/personal/environment/class_logonManagementDialog.inc new file mode 100644 index 000000000..f125ad096 --- /dev/null +++ b/gosa-plugins/goto/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-plugins/goto/personal/environment/class_selectPrinterDialog.inc b/gosa-plugins/goto/personal/environment/class_selectPrinterDialog.inc new file mode 100644 index 000000000..b1ebc4960 --- /dev/null +++ b/gosa-plugins/goto/personal/environment/class_selectPrinterDialog.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(); + 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= get_ou('printerou').$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-plugins/goto/personal/environment/environment.tpl b/gosa-plugins/goto/personal/environment/environment.tpl new file mode 100644 index 000000000..d1370f6d1 --- /dev/null +++ b/gosa-plugins/goto/personal/environment/environment.tpl @@ -0,0 +1,405 @@ +{if $is_account ne 'true'} + + {t}The environment extension is currently disabled.{/t} +{else} + + + + +

+ + {t}Profiles{/t} +

+ + + + + + +
+ + +{if $multiple_support} + + {render acl=$gotoProfileACL checkbox=$multiple_support checked=$use_useProfile} + {t}Use profile managment{/t} + {/render} +
+ {render acl=$gotoProfileServerACL checkbox=$multiple_support checked=$use_gotoProfileServer} + {t}Profil path{/t} + + {/render} +
+ {render acl=$gotoProfileQuotaACL checkbox=$multiple_support checked=$use_gotoProfileQuota} + {t}MB{/t} + {/render} +
+ {render acl=$gotoProfileFlagCACL checkbox=$multiple_support checked=$use_gotoProfileFlagC} +   + {t}Cache profile localy{/t} + {/render} + +{else} + + + + + + + + + + + +
+{render acl=$gotoProfileACL} + +{/render} + + +
  + + + + + + + + + + + + + +
+ + +{render acl=$gotoProfileServerACL} + +{if $gotoProfileServerWriteable} + +{else} + +{/if} +{/render} +
+ +
+
+
+{render acl=$gotoProfileQuotaACL} + {t}MB{/t} +{/render} +
+
+
+{render acl=$gotoProfileFlagCACL} +   +{/render} + +
+
+ +{/if} + +
+ + +{if $kiosk_enabled } + + + + + + + + {else} + + + + +{/if} + + + + + + + +
+ +
+{if $multiple_support} + +{/if} + {t}Server{/t} + + + {if $kiosk_server != "none"} + {t}Profile{/t} + + {else} +   + {/if} +
+ + + + +
+
+{render acl=$gotoProfileFlagLACL checkbox=$multiple_support checked=$use_gotoProfileFlagL} + +{/render} + +
+{if $multiple_support} + +{/if} + + +{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} +
+
+ + +{if $multiple_support} + +

+ +   + +

+ + + +{else} + +

+   + +

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

 {t}Add hotplug devices{/t}

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

+ +

+
+
+

+
+

+
+
+
+

[F]{t}Filters{/t}

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

 

+ +

+ + +

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

 {t}Logon script management{/t}

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

 

+ + + + +
+

 {t}Script{/t}

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

 

+

+ + +

+ + + diff --git a/gosa-plugins/goto/personal/environment/main.inc b/gosa-plugins/goto/personal/environment/main.inc new file mode 100644 index 000000000..4a31aef58 --- /dev/null +++ b/gosa-plugins/goto/personal/environment/main.inc @@ -0,0 +1,126 @@ +dn); + session::un_set ('edit'); + session::un_set ('environment'); + } + + /* Create mail object on demand */ + if (!session::is_set('environment') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $environment= new environment ($config, $ui->dn); + $environment->enable_CSN_check(); + $environment->set_acl_category('users'); + $environment->set_acl_base($ui->dn); + session::set('environment',$environment); + } + $environment = session::get('environment'); + + /* save changes back to object */ + if (session::is_set('edit')){ + $environment->save_object (); + } + + /* Enter edit mode? */ + if (isset($_POST['edit'])){ + + /* Check locking */ + if (($username= get_lock($ui->dn)) != ""){ + session::set('back_plugin',$plug); + session::set('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::set('dn',$ui->dn); + session::set('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); + session::un_set ('edit'); + + /* Remove object */ + session::un_set ('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 (session::is_set('edit')){ + session::set('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 ((session::is_set('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-plugins/goto/personal/environment/selectPrinterDialog.tpl b/gosa-plugins/goto/personal/environment/selectPrinterDialog.tpl new file mode 100644 index 000000000..f07674d39 --- /dev/null +++ b/gosa-plugins/goto/personal/environment/selectPrinterDialog.tpl @@ -0,0 +1,72 @@ +

 {t}Add printer devcies{/t}

+ + + + + + + + +
+
+

+ +

+
+
+

+
+

+
+
+
+

[F]{t}Filters{/t}

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

 

+

+ + +

+