From: hickert Date: Fri, 29 Jun 2007 13:45:19 +0000 (+0000) Subject: Added mimetype plugin. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9ed0e907299af67f2890a1522c7a080d1e578ec3;p=gosa.git Added mimetype plugin. Port not finished, yet, plugin not useable. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6747 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/mimetypes/class_divListMimeTypes.inc b/plugins/admin/mimetypes/class_divListMimeTypes.inc new file mode 100755 index 000000000..98c1ab0c4 --- /dev/null +++ b/plugins/admin/mimetypes/class_divListMimeTypes.inc @@ -0,0 +1,191 @@ +selectedRelease = "ou=mime,".$_SESSION['CurrentMainBase']; + $this->parent = $parent; + $this->ui = get_userinfo(); + $this->AvailableReleases= $this->parent->getReleases($this->selectedBase); + + /* Set list strings */ + $this->SetTitle (_("List of defined mime types")); + $this->SetSummary (_("List of defined mime types")); + $this->SetInformation (_("This menu allows you to add, edit and remove selected mime types. You may want to use the range selector on top of the mime type listbox, when working with a large number of mime types.")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->EnableAplhabet(true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* set Page header */ + $action_col_size = 80; + + /* 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"), _("Ignore 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= ""; + foreach ($this->config->idepartments as $key => $value){ + if ($this->selectedBase == $key){ + $options.= ""; + } else { + $options.= ""; + } + } + + $listhead .= "  "; + $add_sep = true; + + /* And at least add a department selection box */ + $listhead .= _("Base")." ". + "  "; + + $listhead .="";; + + $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; + + /******************** + Attach objects + ********************/ + + foreach($list as $key => $val){ + + /* Create action icons */ + $actions = ""; + + $actions.= ""; + + $actions.= ""; + + $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; + + if(!isset($val['description'][0])){ + $desc = ""; + }else{ + $desc = " - [ ".$val['description'][0]." ]"; + } + + /* 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,($val['cn']['0'].$desc)), "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)); + } + } + + function Save() + { + MultiSelectWindow::Save(); + } + + function save_object() + { + /* Save automatic created POSTs like regex, checkboxes */ + MultiSelectWindow::save_object(); + + /* check if returned selectedRelease is a valid release. + If it isn't set to a valid release */ + $this->AvailableReleases = $this->parent->getReleases($this->selectedBase); + if(!isset($this->AvailableReleases[$this->selectedRelease])){ + $this->selectedRelease =key($this->AvailableReleases); + } + $_SESSION['mimefilter']['release'] = $this->selectedRelease; + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/mimetypes/class_mimetypeGeneric.inc b/plugins/admin/mimetypes/class_mimetypeGeneric.inc new file mode 100644 index 000000000..6efbb480b --- /dev/null +++ b/plugins/admin/mimetypes/class_mimetypeGeneric.inc @@ -0,0 +1,722 @@ + "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 = ""; + + /* 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; + var $dialog = NULL; + + /* 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 = ""; + var $acl =""; + + function mimetype($config,$dn= NULL) + { + plugin::plugin ($config, $dn); + + /* Save original dn */ + $this->orig_dn = $dn; + + $this->ui = get_userinfo(); + $acl= get_permissions ($dn, $this->ui->subtreeACL); + $this->acl= get_module_permission($acl, "mimetypes", $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; + } + } + } + + /* 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 = search_config($this->config->data,"faiManagement","CLASS"); + if(!empty($tmp)) { + $this->isReleaseMimeType= true; + } + + /* Set base */ + if ($this->dn == "new"){ + if(isset($_SESSION['CurrentMainBase'])){ + $this->base= $_SESSION['CurrentMainBase']; + }else{ + $ui= get_userinfo(); + $this->base= dn2base($ui->dn); + } + } else { + $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn); + } + + /* Get icon data */ + if(isset($this->attrs['gotoMimeIcon'])){ + $ldap = $this->config->get_ldap_link(); + $this->iconData = $ldap->get_attribute($this->dn,"gotoMimeIcon"); + $this->saved_attributes['gotoMimeIcon'] = $this->iconData; + } + if ($this->iconData == ""){ + $this->set_new_picture(""); + } + $_SESSION['binary'] = $this->iconData; + $_SESSION['binarytype'] = "image/jpeg"; + } + + + function execute() + { + $smarty = get_smarty(); + + if(!$this->view_logged){ + $this->view_logged =TRUE; + } + + $tmp = $this->plInfo(); + foreach($this->attributes as $name){ + $smarty->assign($name."ACL", chkacl($this->acl,$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->config->idepartments); + $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->config->idepartments; + 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(chkacl($this->acl,$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(chkacl($this->acl,"gotoMimeFilePattern") == ""){ + $str = $_POST['NewFilePattern']; + if(!empty($str)){ + $this->use_gotoMimeFilePattern[] = $str; + } + } + } + + /* Add gotoMimeFilePattern */ + if(isset($_POST['AddNewApplication']) && isset($_POST['NewApplication'])){ + if(chkacl($this->acl,"gotoMimeApplication") == ""){ + $str = $_POST['NewApplication']; + if(!empty($str)){ + $this->use_gotoMimeApplication[] = $str; + } + } + } + + /* Add gotoMimeFilePattern */ + if(isset($_POST['AddNewEmbeddedApplication']) && isset($_POST['NewEmbeddedApplication'])){ + if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){ + $str = $_POST['NewEmbeddedApplication']; + if(!empty($str)){ + $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(chkacl($this->acl,"gotoMimeFilePattern") == ""){ + $Pattern_Actions= "   +   + "; + }else{ + $Pattern_Actions= ""; + } + + if(chkacl($this->acl,"gotoMimeApplication") == ""){ + $Apps_Actions = "   +   + "; + }else{ + $Apps_Actions= ""; + } + + if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){ + $EApps_Actions = "   +   + "; + }else{ + $EApps_Actions= ""; + } + + /* Before adding some entries check acls */ + 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); + } + + 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); + } + 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->config->idepartments); + $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()); + + /* 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->config->idepartments; + if(isset($_POST['base'])){ + if(isset($tmp[$_POST['base']])){ + $this->base= $_POST['base']; + } + } + + } + + /* Save radio buttons */ + if(chkacl($this->acl,"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); + }else{ + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + 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)); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove"); + + /* Delete references to object groups */ + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn")); + while ($ldap->fetch()){ + $og= new ogroup($this->config, $ldap->getDN()); + unset($og->member[$this->dn]); + $og->save (); + show_ldap_error($ldap->get_error(), sprintf(_("Removing mime type from objectgroup '%s' failed"), $og->dn)); + } + } + + + /* Check given values */ + function check() + { + $message = plugin::check(); + if(empty($this->cn)){ + $message[] = _("Please specify a valid name for this mime type."); + } + if(!count($this->use_gotoMimeFilePattern)){ + $message[] = _("Please specify at least one file pattern.") ; + } + + /* Check if there is already a mime type with this cn */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current["BASE"]); + if($this->isReleaseMimeType && (isset($_SESSION['mimefilter']['release']))){ + $baseDn = str_replace($this->config->current['BASE'],$this->base,$_SESSION['mimefilter']['release']); + $baseDn = preg_replace("/ou=mime,.*/","ou=mime,".$this->base,$_SESSION['mimefilter']['release']); + $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$baseDn,array("cn")); + if($ldap->count()){ + $attrs = $ldap->fetch(); + if($this->dn != $attrs['dn']) { + $message[]= _("There's already a mime type with this 'Name'."); + } + } + }else{ + $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))","ou=mime,".$this->base,array("cn")); + if ($ldap->count()){ + $attrs = $ldap->fetch(); + if($this->dn != $attrs['dn']) { + $message[]= _("There's already an mime with this 'Name'."); + } + } + } + + return($message); + } + + /** Helper functions **/ + + /* Set a new picture */ + function set_new_picture($filename) + { + if (empty($filename)){ + $filename= "./images/default_icon.png"; + $this->use_gotoMimeIcon= "*removed*"; + }else{ + $this->use_gotoMimeIcon= $filename; + } + + if (file_exists($filename)){ + $fd = fopen ($filename, "rb"); + $this->iconData= fread ($fd, filesize ($filename)); + $_SESSION['binary']= $this->iconData; + $_SESSION['binarytype']= "image/jpeg"; + fclose ($fd); + } + } + + /* Get picture link */ + function get_picture() + { + $_SESSION['binary']= $this->iconData; + $_SESSION['binarytype']= "image/jpeg"; + return("getbin.php"); + } + + /* Transports the given Arraykey one position up*/ + function ArrayUp($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == 1))){ + $before = array_slice($attrs,0,($pos-2)); + $mitte = array_reverse(array_slice($attrs,($pos-2),2)); + $unten = array_slice($attrs,$pos); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* Transports the given Arraykey one position down*/ + function ArrayDown($atr,$attrs) + { + $ret = $attrs; + $pos = $this->getpos($atr,$attrs) ; + $cn = count($attrs); + if(!(($pos == -1)||($pos == $cn))){ + $before = array_slice($attrs,0,($pos-1)); + $mitte = array_reverse(array_slice($attrs,($pos-1),2)); + $unten = array_slice($attrs,($pos+1)); + $ret = array(); + $ret = $this->combineArrays($before,$mitte,$unten); + } + return($ret); + } + + + /* return the position of the element in the array */ + function getpos($atr,$attrs) + { + $i = 0; + foreach($attrs as $attr => $name) { + $i++; + if($attr == $atr){ + return($i); + } + } + return(-1); + } + + + /* Remove this element from array */ + function ArrayRemove($key,$array,$reorder = false) + { + if(isset($array[$key])){ + unset($array[$key]); + if($reorder){ + $tmp = array(); + foreach($array as $entry){ + $tmp[] = $entry; + } + $array = $tmp; + } + } + return($array); + } + + + /* Combine new array */ + function combineArrays($ar0,$ar1,$ar2) + { + $ret = array(); + if(is_array($ar0)) + foreach($ar0 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar1)) + foreach($ar1 as $ar => $a){ + $ret[]=$a; + } + if(is_array($ar2)) + foreach($ar2 as $ar => $a){ + $ret[]=$a; + } + return($ret); + } + + + /* Return a dialog with all fields that must be changed, + if we want to copy this entry */ + function getCopyDialog() + { + $str = ""; + + $smarty = get_smarty(); + $smarty->assign("cn", $this->cn); + $smarty->assign("description", $this->description); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + + /* Save all */ + function saveCopyDialog() + { + $attrs = array("cn","description"); + foreach($attrs as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + /* Return plugin informations for acl handling */ + function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Mime type generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("mimetypes" => array("description" => _("Mime types"), + "objectClass" => "gotoMimeType")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "gotoMimeGroup" => _("Mime group"), + "description" => _("Description"), + "base" => _("Base"), + "gotoMimeApplication" => _("Application"), + "gotoMimeLeftClickAction" => _("Left click action"), + "gotoMimeIcon" => _("Icon"), + "gotoMimeFilePattern" => _("File patterns"), + "gotoMimeEmbeddedApplication" => _("Embedded applications")) + )); + + } + + function PrepareForCopyPaste($source) + { + plugin::PrepareForCopyPaste($source); + + $source_o = new mimetype($this->config,$source['dn'],$this->parent); + + foreach(array("gotoMimeLeftClickAction_Q","gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern","gotoMimeIcon","iconData") as $name){ + $use_attr = "use_".$name; + if(isset($this->$use_attr)){ + $this->$use_attr= $source_o->$use_attr; + } + $this->$name = $source_o->$name; + } + foreach($this->attributes as $name){ + $this->$name = $source_o->$name; + } + + if($this->iconData){ + $this->use_gotoMimeIcon ="Not emtpy, causes icon to be written."; + } + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/mimetypes/class_mimetypeManagement.inc b/plugins/admin/mimetypes/class_mimetypeManagement.inc new file mode 100755 index 000000000..0dd9bff76 --- /dev/null +++ b/plugins/admin/mimetypes/class_mimetypeManagement.inc @@ -0,0 +1,584 @@ +config = $config; + $this->ui = $ui; + + /* Check if copy & paste is activated */ + if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } + + /* Creat dialog object */ + $this->DivListMimeTypes = new divListMimeTypes($this->config,$this); + + if($this->IsReleaseManagementActivated()){ + + /* Check if we should enable the release selection */ + $this->enableReleaseManagement = true; + + /* Hide SubSearch checkbox */ + $this->DivListMimeTypes->DisableCheckBox("SubSearch"); + } + + } + + + /* Get all releases */ + function getReleases($base) + { + $ldap = $this->config->get_ldap_link(); + $dn = "ou=mime,".$base; + $ret = array(); + $ret ["ou=mime,".$base] = "/"; + + $ldap->cd($dn); + $ldap->search("objectClass=organizationalUnit",array("ou")); + + while($attrs = $ldap->fetch()){ + $str = str_replace($dn,"",$attrs['dn']); + $tmp = array_reverse( split("ou=",$str)); + $str = ""; + foreach($tmp as $val){ + $val = trim(preg_replace("/,/","",$val)); + if(empty($val)) break; + $str .= "/".$val; + } + if(!empty($str)){ + $ret[$attrs['dn']]= preg_replace("/^\//","",$str); + } + } + asort($ret); + return($ret); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + + /**************** + Variable init + ****************/ + + /* These vars will be stored if you try to open a locked mime, + to be able to perform your last requests after showing a warning message */ + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^mime_edit_/","/^mime_del_/","/^item_selected/","/^remove_multiple_mimetypes/"); + + $smarty = get_smarty(); // Smarty instance + $s_action = ""; // Contains the action to proceed + $s_entry = ""; // The value for s_action + $base_back = ""; // The Link for Backbutton + + /* Test Posts */ + foreach($_POST as $key => $val){ + // Post for delete + if(preg_match("/mime_del.*/",$key)){ + $s_action = "del"; + $s_entry = preg_replace("/mime_".$s_action."_/i","",$key); + // Post for edit + }elseif(preg_match("/mime_edit_.*/",$key)){ + $s_action="edit"; + $s_entry = preg_replace("/mime_".$s_action."_/i","",$key); + // Post for new + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); + // Post for new + }elseif(preg_match("/^mime_new.*/",$key)){ + $s_action="new"; + }elseif(preg_match("/^remove_multiple_mimetypes/",$key)){ + $s_action="del_multiple"; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^multiple_copy_mimetypes/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_mimetypes/",$key)){ + $s_action = "cut_multiple"; + } + } + + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + + $s_entry = preg_replace("/_.$/","",$s_entry); + + + /**************** + 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(); + 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->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn); + } + + + /**************** + Edit entry canceled + ****************/ + + /* Cancel dialogs */ + if (isset($_POST['edit_cancel'])){ + del_lock ($this->mimetabs->dn); + unset ($this->mimetabs); + $this->mimetabs= NULL; + unset ($_SESSION['objectinfo']); + } + + + /**************** + Edit entry finished + ****************/ + + /* Finish mime edit is triggered by the tabulator dialog, so + the user wants to save edited data. Check and save at this point. */ + if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->mimetabs->config))){ + + /* Check tabs, will feed message array */ + $this->mimetabs->save_object(); + $message= $this->mimetabs->check(); + + /* Save, or display error message? */ + if (count($message) == 0){ + + /* Save data data to ldap */ + $this->mimetabs->set_release($this->DivListMimeTypes->selectedRelease); + $this->mimetabs->save(); + + if (!isset($_POST['edit_apply'])){ + /* Mime type has been saved successfully, remove lock from LDAP. */ + if ($this->dn != "new"){ + del_lock ($this->dn); + } + unset ($this->mimetabs); + $this->mimetabs= NULL; + unset ($_SESSION['objectinfo']); + } + } else { + /* Ok. There seem to be errors regarding to the tab data, + show message and continue as usual. */ + show_errors($message); + } + } + + + /**************** + Edit entry + ****************/ + + /* User wants to edit data? */ + if (($s_action=="edit") && (!isset($this->mimetabs->config))){ + + /* Get 'dn' from posted 'mimelist', must be unique */ + $this->dn= $this->mimetypes[$s_entry]['dn']; + + /* Check locking, save current plugin in 'back_plugin', so + the dialog knows where to return. */ + if (($user= get_lock($this->dn)) != ""){ + return(gen_locked_message ($user, $this->dn)); + } + + /* Lock the current entry, so everyone will get the + above dialog */ + add_lock ($this->dn, $this->ui->dn); + + + /* Register mimetabs to trigger edit dialog */ + $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn); + $_SESSION['objectinfo']= $this->dn; + } + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + + foreach($ids as $id){ + $dn = $this->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 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' */ + $acl= get_permissions ($dn, $this->ui->subtreeACL); + $acl= get_module_permission($acl, "mimetypes", $dn); + + if (chkacl($acl,"remove") == ""){ + + /* 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'])){ + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl= get_permissions ($dn, $this->ui->subtreeACL); + $acl= get_module_permission($acl, "mimetypes", $dn); + + if (chkacl($acl,"remove") == ""){ + + /* Delete request is permitted, perform LDAP action */ + $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); + $this->mimetabs->set_acl_base($this->dn); + $this->mimetabs->delete (); + unset ($this->mimetabs); + $this->mimetabs= NULL; + + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this mime type!")); + new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + + /**************** + Delete mime canceled + ****************/ + + /* Delete mime type canceled? */ + if (isset($_POST['delete_cancel'])){ + del_lock ($this->dn); + unset($_SESSION['objectinfo']); + } + + /* Show tab dialog if object is present */ + if (($this->mimetabs) && (isset($this->mimetabs->config))){ + $display= $this->mimetabs->execute(); + + /* Don't show buttons if tab dialog requests this */ + if (!$this->mimetabs->by_object[$this->mimetabs->current]->dialog){ + $display.= "

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

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

[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} +
+

 

+
+

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

 {t}Generic{/t}

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

[F]{t}Branches{/t}

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

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

+

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

+ +

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

+ diff --git a/plugins/admin/mimetypes/tabs_mimetypes.inc b/plugins/admin/mimetypes/tabs_mimetypes.inc new file mode 100755 index 000000000..eb4368ce9 --- /dev/null +++ b/plugins/admin/mimetypes/tabs_mimetypes.inc @@ -0,0 +1,61 @@ +Release= preg_replace('/,ou=mime,.*$/', '', $newRelease); + if ($this->Release != ""){ + $this->Release= ",".$this->Release; + } + } + + function save() + { + $baseobject= $this->by_object['mimetype']; + + /* Check for new 'dn', in order to propagate the + 'dn' to all plugins */ + $tmp = search_config($this->config->data,"faiManagement","CLASS"); + + if((!empty($tmp)) && (isset($_SESSION['mimefilter']['release']))){ + if(!$baseobject->isReleaseMimeType){ + $new_dn= "cn=".$baseobject->cn.",ou=mime,".$baseobject->base; + }else{ + $new_dn ="cn=".$baseobject->cn.",".$_SESSION['mimefilter']['release']; + } + }else{ + $new_dn= "cn=".$baseobject->cn.",ou=mime,".$baseobject->base; + } + + /* Move group? */ + if ($this->dn != $new_dn){ + + /* Write entry on new 'dn' */ + if ($this->dn != "new"){ + $baseobject->move($this->dn, $new_dn); + $this->by_object['mimetype']= $baseobject; + } + + /* Happen to use the new one */ + $this->dn= $new_dn; + } + + tabs::save(); + + /* Fix tagging if needed */ + $baseobject->dn= $this->dn; + $baseobject->handle_object_tagging(); + $this->by_object['mimetype'] = $baseobject; + } + +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?>