From: hickert Date: Thu, 29 May 2008 07:49:53 +0000 (+0000) Subject: Updated snapshot handling X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8ba3fd05fa73f30ca338ea91c9914437d411d6b6;p=gosa.git Updated snapshot handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11092 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_MultiSelectWindow.inc b/gosa-core/include/class_MultiSelectWindow.inc index e76ee82ff..8946d061e 100644 --- a/gosa-core/include/class_MultiSelectWindow.inc +++ b/gosa-core/include/class_MultiSelectWindow.inc @@ -635,55 +635,6 @@ class MultiSelectWindow{ } - /* Create header snapshot value */ - function get_snapshot_header($layer_menu = FALSE) - { - $str = ""; - if($this->parent->snapshotEnabled()){ - $ok = false; - foreach($this->parent->get_used_snapshot_bases() as $base){ - $ok |= count($this->parent->getAllDeletedSnapshots($base)) >= 1 ; - } - if($ok){ - if($layer_menu){ - $str = "..|"._("Restore")." "._("Restore")."|RestoreDeletedSnapShot|\n"; - }else{ - $str = " "; - } - }else{ - if($layer_menu){ - $str = "..| "._("Restore")."||\n"; - }else{ - $str = " "; - } - } - } - return($str); - } - - - function GetSnapShotActions($dn) - { - $str= ""; - if($this->parent->snapshotEnabled()){ - - if(count($this->parent->Available_SnapsShots($dn))){ - $str.= " "; - } else { - $str = " "; - } - - $str.= " "; - } - - return($str); - } - - /* this function adds the sub-departments of the current tree to the list */ function AddDepartments($base = false,$numtabs = 3,$empty_tabs_in_front = 0) { diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 51d372862..6f6a6e52b 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -1925,6 +1925,58 @@ class plugin $message = plugin::check(); return($message); } + + + /*! \brief Returns the snapshot header part for "Actions" menu in management dialogs + @param $layer_menu + */ + function get_snapshot_header($base,$category) + { + $str = ""; + $ui = get_userinfo(); + if($this->snapshotEnabled() && $ui->allow_snapshot_restore($base,$category)){ + + $ok = false; + foreach($this->get_used_snapshot_bases() as $base){ + $ok |= count($this->getAllDeletedSnapshots($base)) >= 1 ; + } + + if($ok){ + $str = "..| "._("Restore"). "|RestoreDeletedSnapShot|\n"; + }else{ + $str = "..| "._("Restore")."||\n"; + } + } + return($str); + } + + + function get_snapshot_action($base,$category) + { + $str= ""; + $ui = get_userinfo(); + if($this->snapshotEnabled() && $ui->allow_snapshot_create($base,$category)){ + + if(count($this->Available_SnapsShots($base))){ + $str.= " "; + } else { + $str = " "; + } + + $str.= " "; + } + + return($str); + } + + + function get_used_snapshot_bases() + { + return(array()); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/gosa-core/include/class_userinfo.inc b/gosa-core/include/class_userinfo.inc index 45f6a1324..86f1bbada 100644 --- a/gosa-core/include/class_userinfo.inc +++ b/gosa-core/include/class_userinfo.inc @@ -197,12 +197,25 @@ class userinfo return ($acl); } - + + /*! \brief Check if the given object (dn) is copyable + @param String The object dn + @param String The acl category (e.g. users) + @param String The acl class (e.g. user) + @return Boolean TRUE if the given object is copyable else FALSE + */ function is_copyable($dn, $object, $class) { return(preg_match("/r/",$this->has_complete_category_acls($dn, $object))); } + + /*! \brief Check if the given object (dn) is cutable + @param String The object dn + @param String The acl category (e.g. users) + @param String The acl class (e.g. user) + @return Boolean TRUE if the given object is cutable else FALSE + */ function is_cutable($dn, $object, $class) { $remove = preg_match("/d/",$this->get_permissions($dn,$object."/".$class)); @@ -210,11 +223,55 @@ class userinfo return($remove && $read); } + + /*! \brief Checks if we are allowed to paste an object to the given destination ($dn) + @param String The destination dn + @param String The acl category (e.g. users) + @param String The acl class (e.g. user) + @return Boolean TRUE if we are allowed to paste an object. + */ function is_pasteable($dn, $object, $class) { return(preg_match("/w/",$this->has_complete_category_acls($dn, $object))); } + + /*! \brief Checks if we are allowed to restore a snapshot for the given dn. + @param String The destination dn + @param String The acl category (e.g. users) + @return Boolean TRUE if we are allowed to restore a snapshot. + */ + function allow_snapshot_restore($dn, $object) + { + if(!is_array($object)){ + $object = array($object); + } + $r = $w = $c = TRUE; + foreach($object as $category){ + $w |= preg_match("/w/",$this->has_complete_category_acls($dn, $category)); + $c |= preg_match("/c/",$this->has_complete_category_acls($dn, $category)); + $r |= preg_match("/r/",$this->has_complete_category_acls($dn, $category)); +# print_a(array($category => $w.$c.$r)); + } + return($r); + } + + + /*! \brief Checks if we are allowed to create a snapshot of the given dn. + @param String The source dn + @param String The acl category (e.g. users) + @return Boolean TRUE if we are allowed to restore a snapshot. + */ + function allow_snapshot_create($dn, $object) + { + $w = preg_match("/w/",$this->has_complete_category_acls($dn, $object)); + $c = preg_match("/c/",$this->has_complete_category_acls($dn, $object)); + $r = preg_match("/r/",$this->has_complete_category_acls($dn, $object)); +# print_a(array($object => $w.$c.$r)); + return($r && $w && $c) ; + } + + function get_permissions($dn, $object, $attribute= "", $skip_write= FALSE) { /* If we are forced to skip ACLs checks for the current user diff --git a/gosa-core/plugins/admin/acl/class_divListACL.inc b/gosa-core/plugins/admin/acl/class_divListACL.inc index 0da6caed1..5838c7615 100644 --- a/gosa-core/plugins/admin/acl/class_divListACL.inc +++ b/gosa-core/plugins/admin/acl/class_divListACL.inc @@ -42,7 +42,7 @@ class divListACL extends MultiSelectWindow function divListACL (&$config, &$parent) { - MultiSelectWindow::MultiSelectWindow($config, "ACL", "acl"); + MultiSelectWindow::MultiSelectWindow($config, "ACL", array("acl","aclroles")); $this->parent = &$parent; $this->ui = get_userinfo(); @@ -185,11 +185,7 @@ class divListACL extends MultiSelectWindow $s.="..|".$img." "._("Paste")."\n"; } - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -224,14 +220,14 @@ class divListACL extends MultiSelectWindow } /* Add copy & paste handler */ - if($ui->is_cutable($acl_entry['dn'],"acl","aclRole") && $this->parent->CopyPasteHandler){ + if($ui->is_cutable($acl_entry['dn'],"aclroles","aclRole") && $this->parent->CopyPasteHandler){ $action .= " "; }else{ $action.="  "; } - if($ui->is_copyable($acl_entry['dn'],"acl","aclRole") && $this->parent->CopyPasteHandler){ + if($ui->is_copyable($acl_entry['dn'],"aclroles","aclRole") && $this->parent->CopyPasteHandler){ $action.= " "; }else{ @@ -246,9 +242,7 @@ class divListACL extends MultiSelectWindow } /* Add snapshot functionality */ - if(preg_match("/(c.*w|w.*c)/", $acl_all)){ - $action.= $this->GetSnapShotActions($acl_entry['dn']); - } + $action.= $this->parent->get_snapshot_action($acl_entry['dn'],"aclroles"); if(preg_match("/d/", $acl)){ $action.= "get_snapshot_header(TRUE); - } + /* Add snapshot functionality */ + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); @@ -317,13 +314,8 @@ class divListGroup extends MultiSelectWindow src='images/lists/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>"; /* Add snapshot functionality */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $actions.= $this->GetSnapShotActions($val['dn']); - }else{ - $actions.="  "; - $actions.="  "; - } - + $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module); + if(preg_match("/d/",$acl)){ $actions.= ""; diff --git a/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc b/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc index cd60dead1..4894f9b13 100644 --- a/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc @@ -237,10 +237,7 @@ class divListOGroup extends MultiSelectWindow } /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -298,12 +295,7 @@ class divListOGroup extends MultiSelectWindow $actions.= ""; - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $actions.= $this->GetSnapShotActions($val['dn']); - }else{ - $actions.="  "; - $actions.="  "; - } + $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module); if(preg_match("/d/",$acl)){ $actions.= "get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -354,13 +350,8 @@ class divListUsers extends MultiSelectWindow title='"._("Not allowed")."'>"; } - /* Add snapshot icon */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $action.= $this->GetSnapShotActions($val['dn']); - }else{ - $action.="  "; - $action.="  "; - } + /* Add snapshot functionality */ + $action.= $this->parent->get_snapshot_action($val['dn'],$this->module); /* Add remove icon, if we are allowed to remove the current user */ if(preg_match("/d/",$acl)) { diff --git a/gosa-plugins/fai/admin/fai/class_divListFai.inc b/gosa-plugins/fai/admin/fai/class_divListFai.inc index 9f0362e4d..8820af5f8 100644 --- a/gosa-plugins/fai/admin/fai/class_divListFai.inc +++ b/gosa-plugins/fai/admin/fai/class_divListFai.inc @@ -177,12 +177,7 @@ class divListFai extends MultiSelectWindow } # /* Add snapshot icons, if we are allowed to write and create the complete fai module ($ui->has_complete_category_acls) */ -# if(preg_match("/(c.*w|w.*c)/",$acl_all)){ -# if($this->parent->snapshotEnabled()){ -# $s .= "..|---|\n"; -# $s .= $this->get_snapshot_header(TRUE); -# } -# } +# $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -275,6 +270,8 @@ class divListFai extends MultiSelectWindow } } +# $action.= $this->parent->get_snapshot_action($val['dn'],$this->module); + /* Cutted objects should be displayed in light grey */ $display = $value['cn'].$desc; if($this->parent->CopyPasteHandler){ diff --git a/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc b/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc index 54dec3889..234625466 100644 --- a/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc +++ b/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc @@ -169,11 +169,7 @@ class divListBlocklist extends MultiSelectWindow } /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -227,12 +223,7 @@ class divListBlocklist extends MultiSelectWindow $action.= ""; /* Add snapshot icon */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $action.= $this->GetSnapShotActions($val['dn']); - }else{ - $action.="  "; - $action.="  "; - } + $action.= $this->parent->get_snapshot_action($val['dn'],$this->module); /* Delete entry ; requires remove access */ if(preg_match("/d/",$acl)){ diff --git a/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc b/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc index c50340950..b116eacdf 100644 --- a/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc +++ b/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc @@ -165,11 +165,7 @@ class divListConference extends MultiSelectWindow $s.="..|".$img." "._("Paste")."\n"; } - /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -228,12 +224,7 @@ class divListConference extends MultiSelectWindow alt='"._("edit")."' name='conference_edit_%KEY%' title='"._("Edit this entry")."'>"; /* Add snapshot icon */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $actions.= $this->GetSnapShotActions($conference['dn']); - }else{ - $actions.="  "; - $actions.="  "; - } + $actions.= $this->parent->get_snapshot_action($conference['dn'],$this->module); /* Create delete link - Only if we are allowed to delete this entry */ if(preg_match("/d/",$acl)){ diff --git a/gosa-plugins/gofon/gofon/macro/class_divListMacros.inc b/gosa-plugins/gofon/gofon/macro/class_divListMacros.inc index 22b1f499f..8420ead27 100644 --- a/gosa-plugins/gofon/gofon/macro/class_divListMacros.inc +++ b/gosa-plugins/gofon/gofon/macro/class_divListMacros.inc @@ -164,10 +164,7 @@ class divListMacro extends MultiSelectWindow } /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -224,13 +221,7 @@ class divListMacro extends MultiSelectWindow name='goFonMacro_edit_%KEY%' title='"._("Edit macro")."'>"; /* Add snapshot icon */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $action.= $this->GetSnapShotActions($val['dn']); - }else{ - $action.="  "; - $action.="  "; - } - + $action.= $this->parent->get_snapshot_action($val['dn'],$this->module); if(preg_match("/d/",$acl)){ $action.= "get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -250,12 +247,7 @@ class divListApplication extends MultiSelectWindow src='images/lists/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>"; /* Add snapshot icon */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $actions.= $this->GetSnapShotActions($val['dn']); - }else{ - $actions.="  "; - $actions.="  "; - } + $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module); /* If we are allowed to remove the application account, display remove icon */ if(preg_match("/d/",$acl)){ diff --git a/gosa-plugins/goto/admin/devices/class_divListDevices.inc b/gosa-plugins/goto/admin/devices/class_divListDevices.inc index b43c492fc..7c4b39e2f 100644 --- a/gosa-plugins/goto/admin/devices/class_divListDevices.inc +++ b/gosa-plugins/goto/admin/devices/class_divListDevices.inc @@ -165,10 +165,7 @@ class divListDevices extends MultiSelectWindow } /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); @@ -231,13 +228,7 @@ class divListDevices extends MultiSelectWindow $actions.= ""; -# /* Add snapshot icon */ -# if(preg_match("/(r.*w|w.*r)/",$acl_all)){ -# $actions.= $this->GetSnapShotActions($val['dn']); -# }else{ -# $actions.="  "; -# $actions.="  "; -# } + $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module); /* Add delete button */ if(preg_match("/d/",$acl)){ diff --git a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc index dbc60c501..53b9a1bd7 100644 --- a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc +++ b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc @@ -189,10 +189,7 @@ class divListMimeTypes extends MultiSelectWindow } /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -255,12 +252,7 @@ class divListMimeTypes extends MultiSelectWindow src='images/lists/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>"; /* Add snapshot icon */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $action.= $this->GetSnapShotActions($val['dn']); - }else{ - $action.="  "; - $action.="  "; - } + $action.= $this->parent->get_snapshot_action($val['dn'],$this->module); /* Add delete button */ if(preg_match("/d/",$acl)){ diff --git a/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc b/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc index f16ddd90c..98259d9fd 100644 --- a/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc +++ b/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc @@ -139,11 +139,8 @@ class divListSudo extends MultiSelectWindow } /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } - + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); + $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); } @@ -196,13 +193,7 @@ class divListSudo extends MultiSelectWindow src='images/lists/edit.png' alt='".msgPool::editButton()."' name='sudo_edit_%KEY%' title='"._("Edit this entry")."'>"; /* Add snapshot icon */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $actions.= $this->GetSnapShotActions($val['dn']); - }else{ - $actions.="  "; - $actions.="  "; - } - + $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module); if(preg_match("/d/",$acl)){ $actions.= "dns,$this->ui->dn); /* Lock the current entry, so nobody will edit it during deletion */ - $smarty->assign("info", msgPool::deleteInfo($dns_names,_("Sudo role"))); + $smarty->assign("info", msgPool::deleteInfo($this->dns,_("Sudo role"))); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } } diff --git a/gosa-plugins/systems/admin/systems/class_divListSystem.inc b/gosa-plugins/systems/admin/systems/class_divListSystem.inc index b49d1bd9c..8f549172f 100644 --- a/gosa-plugins/systems/admin/systems/class_divListSystem.inc +++ b/gosa-plugins/systems/admin/systems/class_divListSystem.inc @@ -155,6 +155,7 @@ class divListSystem extends MultiSelectWindow $d = $ui->get_module_departments($module); foreach($d as $department){ $departments[$department] = $department; + } } @@ -277,10 +278,7 @@ class divListSystem extends MultiSelectWindow } /* Add snapshot icons */ - if(preg_match("/(c.*w|w.*c)/",$all_module_acls)){ - $s .= "..|---|\n"; - $s .= $this->get_snapshot_header(TRUE); - } + $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); @@ -401,20 +399,7 @@ class divListSystem extends MultiSelectWindow $action.= ""; - /* Add snapshot icon */ - if(preg_match("/(r.*w|w.*r)/",$acl_all)){ - $action.= $this->GetSnapShotActions($val['dn']); - }else{ - $action.="  "; - $action.="  "; - } - - if(preg_match("/d/",$acl)){ - $action.= ""; - }else{ - $action.= $empty; - } + $action.= $this->parent->get_snapshot_action($val['dn'],$acl_type); /* Generate picture list, which is currently disabled */ if(in_array("goCupsServer" ,$val['objectClass'])) $cups = $img1; else $cups =$empty;