summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 895d7a8)
raw | patch | inline | side by side (parent: 895d7a8)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 29 Jun 2007 13:45:19 +0000 (13:45 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 29 Jun 2007 13:45:19 +0000 (13:45 +0000) |
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
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6747 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/mimetypes/class_divListMimeTypes.inc | [new file with mode: 0755] | patch | blob |
plugins/admin/mimetypes/class_mimetypeGeneric.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/mimetypes/class_mimetypeManagement.inc | [new file with mode: 0755] | patch | blob |
plugins/admin/mimetypes/generic.tpl | [new file with mode: 0644] | patch | blob |
plugins/admin/mimetypes/main.inc | [new file with mode: 0755] | patch | blob |
plugins/admin/mimetypes/paste_generic.tpl | [new file with mode: 0644] | patch | blob |
plugins/admin/mimetypes/release_select.tpl | [new file with mode: 0755] | patch | blob |
plugins/admin/mimetypes/remove.tpl | [new file with mode: 0755] | patch | blob |
plugins/admin/mimetypes/tabs_mimetypes.inc | [new file with mode: 0755] | patch | blob |
diff --git a/plugins/admin/mimetypes/class_divListMimeTypes.inc b/plugins/admin/mimetypes/class_divListMimeTypes.inc
--- /dev/null
@@ -0,0 +1,191 @@
+<?php
+
+class divListMimeTypes extends MultiSelectWindow
+{
+ /* Current base */
+ var $selectedBase = "";
+ var $selectedRelease = "main";
+ var $AvailableReleases = array();
+ var $departments = array();
+ var $parent ;
+ var $ui ;
+
+ /* Regex */
+ var $Regex = "*";
+
+ /* Subsearch checkbox */
+ var $SubSearch;
+
+ /* These vars should be saved too */
+ var $SaveAdditionalVars = array("selectedRelease");
+
+
+ function divListMimeTypes ($config,$parent)
+ {
+ /* Create divlist and setup */
+ MultiSelectWindow::MultiSelectWindow($config, "Mimetypes", "mimetypes");
+
+ /* initialize required attributes */
+ $this->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 = "<input type='checkbox' id='select_all' name='select_all'
+ onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+
+ /* 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.= "<option selected='selected' value='$key'>$value</option>";
+ } else {
+ $options.= "<option value='$key'>$value</option>";
+ }
+ }
+
+ $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_mime.png' alt='"._("new").
+ "' title='"._("Create new mime type")."' name='mime_new'> ";
+ $add_sep = true;
+
+ /* And at least add a department selection box */
+ $listhead .= _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+ " <input class='center' type='image' src='images/list_submit.png' align='middle'
+ title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ";
+
+ $listhead .="</div>";;
+
+ $this->SetListHeader($listhead);
+ }
+
+
+ /* Some basic settings */
+ function execute()
+ {
+ $this->ClearElementsList();
+ $this->GenHeader();
+ }
+
+
+ function setEntries($list)
+ {
+ /********************
+ Variable init
+ ********************/
+
+ /* Create links */
+ $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
+ $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
+ $userimg = "<img class='center' src='images/select_groups.png' alt='User' title='%s'>";
+ $mimeimg = "<img class='center' src='images/select_mimetype.png' alt='A' title='"._("Mime type")."'>";
+ $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
+
+ /* set Page header */
+ $action_col_size = 80;
+
+ /********************
+ Attach objects
+ ********************/
+
+ foreach($list as $key => $val){
+
+ /* Create action icons */
+ $actions = "";
+
+ $actions.= "<input class='center' type='image'
+ src='images/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>";
+
+ $actions.= "<input class='center' type='image'
+ src='images/edittrash.png' alt='"._("delete")."' name='mime_del_%KEY%' title='"._("Delete this entry")."'>";
+
+ $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" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+ "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
--- /dev/null
@@ -0,0 +1,722 @@
+<?php
+class mimetype extends plugin
+{
+ /* CLI vars */
+ var $cli_summary = "This tab allows you to modify, add or remove mime types in the selected department.";
+ var $cli_description = "Management dialog to handle mime types";
+ var $ignore_account = true; // This is always a valid account
+ var $cli_parameters = array("eins" => "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= " <input type='image' src='images/sort_up.png' class='center' name='Pattern_SortUp_%s' >
+ <input type='image' src='images/sort_down.png' class='center' name='Pattern_SortDown_%s'>
+ <input type='image' src='images/edittrash.png' class='center' name='Pattern_Remove_%s'>";
+ }else{
+ $Pattern_Actions= "";
+ }
+
+ if(chkacl($this->acl,"gotoMimeApplication") == ""){
+ $Apps_Actions = " <input type='image' src='images/sort_up.png' class='center' name='Apps_SortUp_%s' >
+ <input type='image' src='images/sort_down.png' class='center' name='Apps_SortDown_%s'>
+ <input type='image' src='images/edittrash.png' class='center' name='Apps_Remove_%s'>";
+ }else{
+ $Apps_Actions= "";
+ }
+
+ if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){
+ $EApps_Actions = " <input type='image' src='images/sort_up.png' class='center' name='EApps_SortUp_%s' >
+ <input type='image' src='images/sort_down.png' class='center' name='EApps_SortDown_%s'>
+ <input type='image' src='images/edittrash.png' class='center' name='EApps_Remove_%s'>";
+ }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
--- /dev/null
@@ -0,0 +1,584 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+require "tabs_mimetypes.inc";
+
+class mimetypeManagement extends plugin
+{
+ /* Definitions */
+ var $plHeadline = "Mime types";
+ var $plDescription = "Manage mime types";
+
+ /* Dialog attributes */
+ var $ui = NULL;
+ var $DivListMimeTypes = NULL;
+ var $enableReleaseManagement = false;
+ var $mimetabs = NULL;
+ var $snapDialog = NULL;
+ var $CopyPasteHandler = NULL;
+ var $start_pasting_copied_objects = FALSE;
+
+
+ function mimetypeManagement ($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->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 = "<br><pre>";
+ foreach($this->dns as $dn){
+ add_lock ($dn, $this->ui->dn);
+ $dns_names .= $dn."\n";
+ }
+ $dns_names .="</pre>";
+
+ /* 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.= "<p style=\"text-align:right\">\n";
+ $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+ $display.= " \n";
+ if ($this->dn != "new"){
+ $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+ $display.= " \n";
+ }
+ $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $display.= "</p>";
+ }
+ 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
--- /dev/null
@@ -0,0 +1,186 @@
+<table style="width:100%">
+ <tr>
+ <td colspan="2">
+ <h2><img src='images/list_mime.png' class='center' alt='[M]'> {t}Generic{/t}</h2>
+ </td>
+ </tr>
+ <tr>
+ <td style='width:50%; vertical-align:top;' >
+ <table>
+ <tr>
+ <td>
+ {t}Mime type{/t}{$must}
+ </td>
+ <td>
+{render acl=$gotoMimeGroupACL}
+ <input type="text" name='cn' value="{$cn}" title='{t}Please enter a name for the mime type here{/t}'>
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {t}Mime group{/t}
+ </td>
+ <td>
+{render acl=$gotoMimeGroupACL}
+ <select name='gotoMimeGroup' title='{t}Categorize this mime type{/t}'>
+ {html_options output=$gotoMimeGroups values=$gotoMimeGroups selected=$gotoMimeGroup}
+ </select>
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {t}Description{/t}
+ </td>
+ <td>
+{render acl=$descriptionACL}
+ <input type="text" name='description' value="{$description}" title='{t}Please specify a description{/t}'>
+{/render}
+ </td>
+ </tr>
+{if !$isReleaseMimeType}
+ <tr>
+ <td><LABEL for="base">{t}Base{/t}{$must}</LABEL></td>
+ <td>
+ {render acl=$baseACL}
+ <select size="1" id="base" name="base" title="{t}Choose subtree to place application in{/t}">
+ {html_options options=$bases selected=$base_select}
+ </select>
+ {/render}
+ {if !$isReleaseMimeType}
+ {render acl=$baseACL disable_picture='images/folder_gray.png'}
+ <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+ {/render}
+ {/if}
+ </td>
+ </tr>
+
+{/if}
+ </table>
+
+ </td>
+ <td style="border-left:1px solid #A0A0A0;vertical-align:top;">
+ <table summary="">
+ <tr>
+ <td>
+ <LABEL for="picture_file">{t}Icon{/t}</LABEL><br>
+ <img src="{$gotoMimeIcon}" border=1 alt='{t}Mime icon{/t}'
+ style="width:48px; height:48; background-color:white; vertical-align:bottom;">
+ </td>
+ <td style="vertical-align:top">
+ <br>
+ <input type="hidden" name="MAX_FILE_SIZE" value="100000">
+{render acl=$gotoMimeIconACL}
+ <input name="picture_file" type="file" size="20" maxlength="255"
+ accept="image/*.png" id="picture_file">
+{/render}
+{render acl=$gotoMimeIconACL}
+ <input type="submit" name="update_icon" value="{t}Update{/t}"
+ title="{t}Update mime type icon{/t}">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <p class='seperator'> </p>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <h2><img src='images/mime_leftclick.png' class='center' alt='{t}Left click{/t}'> {t}Left click{/t}</h2>
+ </td>
+ </tr>
+ <tr>
+ <td style='width:50%; vertical-align:top;' >
+ {t}File patterns{/t}{$must}
+{render acl=$gotoMimeFilePatternACL}
+ {$gotoMimeFilePatterns}
+{/render}
+
+{render acl=$gotoMimeFilePatternACL}
+ <input type='text' name='NewFilePattern' value='' title='{t}Please specify a new file pattern{/t}'>
+{/render}
+{render acl=$gotoMimeFilePatternACL}
+ <input type='submit' name='AddNewFilePattern' value='{t}Add{/t}' title='{t}Add a new file pattern{/t}'>
+{/render}
+ </td>
+ <td style="border-left:1px solid #A0A0A0;vertical-align:top;">
+ {t}Applications{/t}
+{render acl=$gotoMimeApplicationACL}
+ {$gotoMimeApplications}
+{/render}
+{render acl=$gotoMimeApplicationACL}
+ <input type='text' name='NewApplication' value='' title='{t}Enter an application name here{/t}'>
+{/render}
+{render acl=$gotoMimeApplicationACL}
+ <input type='submit' name='AddNewApplication' value='{t}Add{/t}' title='{t}Add application{/t}'>
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <p class='seperator'> </p>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <h2><img src='images/mime_embedding.png' class='center' alt='{t}Embedding{/t}'> {t}Embedding{/t}</h2>
+ </td>
+ </tr>
+ <tr>
+ <td style='width:50%; vertical-align:top;' >
+
+ <table>
+ <tr>
+ <td style='vertical-align:top; '>
+{render acl=$gotoMimeLeftClickActionACL}
+ <input type='radio' name='gotoMimeLeftClickAction_IE' value='I'
+ {if $gotoMimeLeftClickAction_I} checked {/if}>
+{/render}
+ {t}Show file in embedded viewer{/t}
+ <br>
+
+{render acl=$gotoMimeLeftClickActionACL}
+ <input type='radio' name='gotoMimeLeftClickAction_IE' value='E'
+ {if $gotoMimeLeftClickAction_E} checked {/if}>
+{/render}
+ {t}Show file in external viewer{/t}
+ <br>
+
+{render acl=$gotoMimeLeftClickActionACL}
+ <input type='checkbox' name='gotoMimeLeftClickAction_Q' value='1'
+ {if $gotoMimeLeftClickAction_Q} checked {/if}>
+{/render}
+ {t}Ask whether to save to local disk{/t}
+ </td>
+ </tr>
+ </table>
+
+ </td>
+ <td style="border-left:1px solid #A0A0A0;vertical-align:top;">
+ {t}Applications{/t}
+{render acl=$gotoMimeEmbeddedApplicationACL}
+ {$gotoMimeEmbeddedApplications}
+{/render}
+{render acl=$gotoMimeEmbeddedApplicationACL}
+ <input type='text' name='NewEmbeddedApplication' value=''
+ title='{t}Enter an application name here{/t}'>
+{/render}
+{render acl=$gotoMimeEmbeddedApplicationACL}
+ <input type='submit' name='AddNewEmbeddedApplication' value='{t}Add{/t}'
+ title='{t}Add application{/t}'>
+{/render}
+ </td>
+ </tr>
+</table>
+<input type="hidden" name="MimeGeneric" value="1">
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ document.mainform.cn.focus();
+ -->
+</script>
diff --git a/plugins/admin/mimetypes/main.inc b/plugins/admin/mimetypes/main.inc
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+if ($remove_lock){
+ if(isset($_SESSION['MimeTypeManagement'])){
+ $MimeTypeManagement= $_SESSION['MimeTypeManagement'];
+ $MimeTypeManagement->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"), "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".@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
--- /dev/null
@@ -0,0 +1,31 @@
+<table style="width:100%">
+ <tr>
+ <td colspan="2">
+ <h2><img src='images/head.png' class='center'> {t}Generic{/t}</h2>
+ </td>
+ </tr>
+ <tr>
+ <td style='width:50%; vertical-align:top;' >
+
+ <table>
+ <tr>
+ <td>
+ {t}Mime type{/t}
+ </td>
+ <td>
+ <input type="text" name='cn' value="{$cn}" title='{t}Please enter a name for the mime type here{/t}'>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {t}Description{/t}
+ </td>
+ <td>
+ <input type="text" name='description' value="{$description}" title='{t}Please specify a description for this mime type here{/t}'>
+ </td>
+ </tr>
+ </table>
+
+ </td>
+ </tr>
+</table>
diff --git a/plugins/admin/mimetypes/release_select.tpl b/plugins/admin/mimetypes/release_select.tpl
--- /dev/null
@@ -0,0 +1,16 @@
+<br>
+<div class="contentboxh" style="border-bottom:1px solid #B0B0B0;">
+ <p class="contentboxh"><img src="{$branchimage}" align="right" alt="[F]">{t}Branches{/t}</p>
+</div>
+<div class="contentboxb">
+ <table summary="" style="width:100%;">
+ <tr>
+ <td>
+ {t}Current release{/t}
+ <select name="selectedRelease" onChange="document.mainform.submit();">
+ {html_options options=$releases selected=$selectedRelease}
+ </select>
+ </td>
+ </tr>
+ </table>
+</div>
diff --git a/plugins/admin/mimetypes/remove.tpl b/plugins/admin/mimetypes/remove.tpl
--- /dev/null
@@ -0,0 +1,23 @@
+<div style="font-size:18px;">
+ <img alt="" src="images/button_cancel.png" align=top> {t}Warning{/t}
+</div>
+<p>
+ {$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}
+</p>
+<p>
+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t}
+</p>
+
+<p class="plugbottom">
+ {if $multiple}
+ <input type=submit name="delete_multiple_mimetype_confirm" value="{t}Delete{/t}">
+
+ <input type=submit name="delete_multiple_mimetype_cancel" value="{t}Cancel{/t}">
+ {else}
+ <input type=submit name="delete_mime_confirm" value="{t}Delete{/t}">
+
+ <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+ {/if}
+</p>
+
diff --git a/plugins/admin/mimetypes/tabs_mimetypes.inc b/plugins/admin/mimetypes/tabs_mimetypes.inc
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+class mimetabs extends tabs
+{
+ var $Release= "";
+
+ function mimetabs($config, $data, $dn)
+ {
+ tabs::tabs($config, $data, $dn);
+ }
+
+ function set_release($newRelease)
+ {
+ $this->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:
+?>