diff --git a/plugins/admin/mimetypes/class_mimetypeGeneric.inc b/plugins/admin/mimetypes/class_mimetypeGeneric.inc
index cfdfde0da0410cbd0829a29a162bd9a5110511b1..e7585c90b44a1c5551795b8774f10673367c4637 100644 (file)
"gotoMimeGroup");
/* Class vars */
- var $acl;
var $ui;
var $cn = "";
var $gotoMimeLeftClickAction = "I";
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");
+ 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",
/* Orig_Dn is used to verify if this object is new or only edited */
var $orig_dn = "";
-
function mimetype($config,$dn= NULL)
{
plugin::plugin ($config, $dn);
{
$smarty = get_smarty();
+ if(!$this->view_logged){
+ $this->view_logged =TRUE;
+ new log("view","mimetypes/".get_class($this),$this->dn);
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
/* Base select dialog */
$once = true;
foreach($_POST as $name => $value){
if(preg_match("/^chooseBase/",$name) && $once){
$once = false;
- $this->dialog = new baseSelectDialog($this->config,$this);
- echo $this->base;
+ $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
$this->dialog->setCurrentBase($this->base);
}
}
if($this->dialog->isClosed()){
$this->dialog = false;
}elseif($this->dialog->isSelected()){
- $this->base = $this->dialog->isSelected();
+
+ /* A new base was selected, check if it is a valid one */
+ $tmp = $this->get_allowed_bases();
+ if(isset($tmp[$this->dialog->isSelected()])){
+ $this->base = $this->dialog->isSelected();
+ }
+
$this->dialog= false;
}else{
return($this->dialog->execute());
/* Execute a command with the given attribute and entry
e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */
- if(chkacl($this->acl,$attr) == ""){
+ if($this->acl_is_writeable($attr)){
$this->$attr= $this->$func($s_entry,$this->$attr,true);
}
}
/* Add gotoMimeFilePattern */
if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){
- if(chkacl($this->acl,"gotoMimeFilePattern") == ""){
+ if($this->acl_is_writeable("gotoMimeFilePattern")){
$str = $_POST['NewFilePattern'];
if(!empty($str)){
$this->use_gotoMimeFilePattern[] = $str;
/* Add gotoMimeFilePattern */
if(isset($_POST['AddNewApplication']) && isset($_POST['NewApplication'])){
- if(chkacl($this->acl,"gotoMimeApplication") == ""){
+ if($this->acl_is_writeable("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") == ""){
+ if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
$str = $_POST['NewEmbeddedApplication'];
if(!empty($str)){
$this->use_gotoMimeEmbeddedApplication[] = $str;
$DivEApps -> SetHeight(100);
- if(chkacl($this->acl,"gotoMimeFilePattern") == ""){
+ if($this->acl_is_writeable("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'>";
$Pattern_Actions= "";
}
- if(chkacl($this->acl,"gotoMimeApplication") == ""){
+ if($this->acl_is_writeable("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'>";
$Apps_Actions= "";
}
- if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){
+ if($this->acl_is_writeable("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'>";
$EApps_Actions= "";
}
- 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);
+ /* Before adding some entries check acls */
+ if($this->acl_is_readable("gotoMimeFilePattern")){
+ foreach($this->use_gotoMimeFilePattern as $key => $pattern){
+ $field1 = array("string" => $pattern);
+ $field2 = array("string" => preg_replace("/%s/",$key,$Pattern_Actions),"attach"=>"style='border-right:0px;width:50px;'");
+ $fields = array($field1,$field2);
+ $DivPatterns -> AddEntry($fields);
+ }
+ }
+
+ if($this->acl_is_readable("gotoMimeApplication")){
+ foreach($this->use_gotoMimeApplication as $key => $pattern){
+ $field1 = array("string" => $pattern);
+ $field2 = array("string" => preg_replace("/%s/",$key,$Apps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
+ $fields = array($field1,$field2);
+ $DivApps -> AddEntry($fields);
+ }
}
- foreach($this->use_gotoMimeApplication as $key => $pattern){
- $field1 = array("string" => $pattern);
- $field2 = array("string" => preg_replace("/%s/",$key,$Apps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
- $fields = array($field1,$field2);
- $DivApps -> AddEntry($fields);
+ if($this->acl_is_readable("gotoMimeEmbeddedApplication")){
+ foreach($this->use_gotoMimeEmbeddedApplication as $key => $pattern){
+ $field1 = array("string" => $pattern);
+ $field2 = array("string" => preg_replace("/%s/",$key,$EApps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
+ $fields = array($field1,$field2);
+ $DivEApps -> AddEntry($fields);
+ }
}
- 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("baseACL", chkacl($this->acl,"base"));
- $smarty->assign("bases", $this->config->idepartments);
+ $smarty->assign("bases", $this->get_allowed_bases());
$smarty->assign("base_select", $this->base);
$smarty->assign("isReleaseMimeType", $this->isReleaseMimeType);
$smarty->assign("gotoMimeFilePatterns", $DivPatterns->DrawList());
/* Assign class vars to smarty */
foreach($this->attributes as $attr){
$smarty->assign($attr,$this->$attr);
- $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
}
/* Assign additional vars that are not included in attributes*/
function save_object()
{
if(isset($_POST['MimeGeneric'])){
- plugin::save_object();
+ /* Create a base backup and reset the
+ base directly after calling plugin::save_object();
+ Base will be set seperatly a few lines below */
+ $base_tmp = $this->base;
+ plugin::save_object();
+ $this->base = $base_tmp;
+
/* Only save base if we are not in release mode */
if(!$this->isReleaseMimeType){
+
+ /* Set new base if allowed */
+ $tmp = $this->get_allowed_bases();
if(isset($_POST['base'])){
- $this->base = $_POST['base'];
+ if(isset($tmp[$_POST['base']])){
+ $this->base= $_POST['base'];
+ }
}
+
}
/* Save radio buttons */
- if(chkacl($this->acl,"gotoMimeLeftClickAction")== ""){
+ if($this->acl_is_writeable("gotoMimeLeftClickAction")){
if(isset($_POST['gotoMimeLeftClickAction_IE'])){
$chr = $_POST['gotoMimeLeftClickAction_IE'];
if($chr == "E"){
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify($this->attrs);
+ new log("modify","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
}else{
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
$ldap->cd($this->dn);
$ldap->add($this->attrs);
+ new log("create","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
}
show_ldap_error($ldap->get_error(), sprintf(_("Saving of mime type/generic with dn '%s' failed."),$this->dn));
}
/* Remove current mime type */
function remove_from_parent()
{
+ plugin::remove_from_parent();
$ldap = $this->config->get_ldap_link();
$ldap->rmDir($this->dn);
show_ldap_error($ldap->get_error(), sprintf(_("Removing of mime type/generic with dn '%s' failed."),$this->dn));
+ new log("remove","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
/* Optionally execute a command after we're done */
$this->handle_post_events("remove");
}
}
- /* Check permissions for that base? */
- if ($this->base != ""){
- $new_dn= "cn=".$this->cn.",ou=mime,".$this->base;
- } else {
- $new_dn= $this->dn;
- }
- if (chkacl($this->acl, "create") != ""){
- $message[]= _("You have no permissions to create a mime type on this 'Base'.");
- }
-
return($message);
}
if (empty($filename)){
$filename= "./images/default_icon.png";
$this->use_gotoMimeIcon= "*removed*";
+ }else{
+ $this->use_gotoMimeIcon= $filename;
}
if (file_exists($filename)){
}
}
}
+
+ /* 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:
?>