summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5cf4478)
raw | patch | inline | side by side (parent: 5cf4478)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 26 Jun 2006 09:24:25 +0000 (09:24 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 26 Jun 2006 09:24:25 +0000 (09:24 +0000) |
This is an initial commit, there possibly follow some fixes
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3897 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3897 594d385d-05f5-0310-b6e9-bd551577e9d8
index c71b0704183e7bc48c60dd01874a99f1606ae28a..677bc17ec5f0d25c7c2a21369079dc62146d8d49 100755 (executable)
</tr>
<tr>
<td>
- <select name="SnapShot" {if $CountSnapShots==0} disabled {/if}>
- {if $CountSnapShots==0} disabled
- <option value=""> {t}none{/t} </option>
- {else}
- <option value=""> </option>
- {html_options options=$SnapShots}
- {/if}
- </select>
+ {$SnapShotDivlist}
</td>
</tr>
</table>
index 8481095f07e457aaf426bc5402a57d0a5ff075e6..59aa9eb22419221c4a7cb1e217bd294fdcc42ead 100644 (file)
if($this->parent->snapshotEnabled()){
$str .="<input class='center' type='image' src='images/snapshot.png'
- alt='"._("Create snapshot")."' name='CreateSnapShot_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'> ";
+ alt='"._("Create snapshot")."' name='CreateSnapShotDialog_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'> ";
if(count($this->parent->Available_SnapsShots($dn))){
$str .="<input class='center' type='image' src='images/restore.png'
- alt='"._("Restore snapshot")."' name='RestoreSnapShot_".base64_encode($dn)."' title='"._("Restore snapshot")."'> ";
+ alt='"._("Restore snapshot")."' name='RestoreSnapShotDialog_".base64_encode($dn)."' title='"._("Restore snapshot")."'> ";
}else{
$str.= "<img src='images/empty.png' style='width:16px;' class='center'> ";
}
index 9e42c81a6a733d5c27516016bcd87c1c0c0beee6..9391c1370493078d02ab910b7c10d2ec6ba108dc 100755 (executable)
var $display_all_removed_objects= false; /* Specifies which objects will be listed, all snapshots for a single entry
or all snapshots of already deleted objects */
var $dialog = true;
+ var $del_dn = "";
+ var $ui;
+ var $acl;
function SnapShotDialog($config,$dn,$parent)
{
plugin::plugin($config,$dn);
- $this->parent = $parent;
+ $this->parent = $parent;
+ $this->ui = get_userinfo();
}
{
plugin::execute();
$smarty = get_smarty();
+
+ $once = true;
+ foreach($_POST as $name => $value){
+ if((preg_match("/^RemoveSnapShot_/",$name)) && ($once)){
+ $once = false;
+
+ $entry = preg_replace("/^RemoveSnapShot_/","",$name);
+ $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
+
+ $acl = get_permissions ($entry, $this->ui->subtreeACL);
+ $this->acl = get_module_permission($acl, "snapshot", $entry );
+
+ if (chkacl($this->acl, "delete") == ""){
+ $this->del_dn = $entry;
+ $smarty= get_smarty();
+ $smarty->assign("intro", sprintf(_("You're about to delete the snapshot '%s'."), @LDAP::fix($this->del_dn)));
+ return($smarty->fetch (get_template_path('remove.tpl')));
+ } else {
+
+ /* Obviously the user isn't allowed to delete. Show message and
+ clean session. */
+ print_red (_("You are not allowed to delete this snap shot!"));
+ }
+ }
+ }
+
+ /* Remove snapshot */
+ if(isset($_POST['delete_confirm']) && !empty($this->del_dn)){
+ $acl = get_permissions ($this->del_dn, $this->ui->subtreeACL);
+ $this->acl = get_module_permission($acl, "snapshot", $this->del_dn);
+ if (chkacl($this->acl, "delete") == ""){
+ $this->remove_snapshot($this->del_dn);
+ $this->del_dn = "";
+ }
+ }
/* We must restore a snapshot */
if($this->display_restore_dialog){
}else{
$tmp = $this->Available_SnapsShots($this->dn,true);
}
-
+
+ $DivListSnapShots = new DivSelectBox("SnapShotRestore");
+ $DivListSnapShots->SetHeight(180);
+
+ $list_of_elements = array();
+
/* Walk through all entries and setup the display text */
foreach($tmp as $key => $entry){
-
- $data = $entry['description'][0];
- $date = date("d.m.Y H.i.s",preg_replace("/\-.*$/","",$entry['gosaSnapshotTimestamp'][0]));
- if($this->display_all_removed_objects){
- $data.= " - ".$entry['gosaSnapshotDN'][0];
- }
+ $TimeStamp = $entry['gosaSnapshotTimestamp'][0];
+ $list_of_elements[$TimeStamp] = $entry;
+ }
+
+ /* Sort generated list */
+ krsort($list_of_elements);
- if(strlen($data) > 83){
- $data= substr($data,0,80)." ...";
+ /* Add Elements to divlist */
+ foreach($list_of_elements as $entry){
+
+ $actions = "<input type='image' src='images/edittrash.png' name='RemoveSnapShot_%KEY' title='"._("Remove snapshot")."'> ";
+ $actions.= "<input type='image' src='images/restore.png' name='RestoreSnapShot_%KEY' title='"._("Restore snapshot")."'> ";
+
+ $time_stamp = date("d.m.Y H.i.s",preg_replace("/\-.*$/","",$entry['gosaSnapshotTimestamp'][0]));
+ $display_data = $entry['description'][0];
+
+ if($this->display_all_removed_objects){
+ $display_data.= " - ".$entry['gosaSnapshotDN'][0];
}
-
- $res[base64_encode($entry['dn'])] = $date." - ".$data;
- }
- natcasesort($res);
- $smarty->assign("SnapShots",array_reverse($res));
- $smarty->assign("CountSnapShots",count($res));
+
+ $field0 = array("string"=> $time_stamp , "attach"=> "style='vertical-align:top;width:120px;'");
+ $field1 = array("string"=> $display_data , "attach"=> "");
+ $field2 = array("string"=> preg_replace("/%KEY/",base64_encode($entry['dn']),$actions) ,
+ "attach"=> "style='border-right:0px;vertical-align:top;width:40px;text-align:right;'");
+ $DivListSnapShots->AddEntry(array($field0,$field1,$field2));
+ }
+
+ $smarty->assign("SnapShotDivlist",$DivListSnapShots->DrawList());
+ $smarty->assign("CountSnapShots",count($list_of_elements));
}
$smarty->assign("RestoreMode",$this->display_restore_dialog);
index 323fbeddfe0f7ae6aa49bc964e70fec496fa73a1..c56cfae687e9f38d8e8b144314cc3a8ec8e38842 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
/* Get configuration from gosa.conf */
$tmp = $this->config->current;
- /* Check if the undo level is specified */
- if(isset($tmp['SNAPSHOT_UNDO_LEVEL'])){
- $UndoLvl = $tmp['SNAPSHOT_UNDO_LEVEL'];
- }else{
- $UndoLvl = 5;
- }
/* Create lokal ldap connection */
$ldap= $this->config->get_ldap_link();
show_ldap_error($ldap_to->get_error(), _("Snapshot failed."));
}
-
/* check if the dn exists */
if ($ldap->dn_exists($this->dn)){
show_ldap_error($ldap_to->get_error(), _("Create snapshot failed."));
show_ldap_error($ldap->get_error(), _("Create snapshot failed."));
+ }
+ }
- /* Check amount of used snapshots, and remove old ones if necessary */
- $test = $this->Available_SnapsShots($this->dn,true);
- if(count($test) > $UndoLvl){
- $toDel = array();
- foreach($test as $entry){
- $toDel[preg_replace("/-/","",$entry['gosaSnapshotTimestamp'][0])] = $entry['dn'];
- }
- krsort($toDel);
- $i = 0 ;
- foreach($toDel as $entryID => $entry){
- $i ++ ;
- if($i > $UndoLvl){
- $ldap_to->rmdir_recursive($entry);
- }
- }
- }
+ function remove_snapshot($dn)
+ {
+ $ui = get_userinfo();
+ $acl = get_permissions ($dn, $ui->subtreeACL);
+ $acl = get_module_permission($acl, "snapshot", $dn);
+
+ if (chkacl($this->acl, "delete") == ""){
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->rmdir_recursive($dn);
+ }else{
+ print_red (_("You are not allowed to delete this snap shot!"));
}
}
foreach($_POST as $name => $value){
/* Create a new snapshot, display a dialog */
- if(preg_match("/^CreateSnapShot_/",$name) && $once){
+ if(preg_match("/^CreateSnapShotDialog_/",$name) && $once){
$once = false;
- $entry = preg_replace("/^CreateSnapShot_/","",$name);
+ $entry = preg_replace("/^CreateSnapShotDialog_/","",$name);
$entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
$this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
}
/* Restore a snapshot, display a dialog with all snapshots of the current object */
- if(preg_match("/^RestoreSnapShot_/",$name) && $once){
+ if(preg_match("/^RestoreSnapShotDialog_/",$name) && $once){
$once = false;
- $entry = preg_replace("/^RestoreSnapShot_/","",$name);
+ $entry = preg_replace("/^RestoreSnapShotDialog_/","",$name);
$entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
$this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
$this->snapDialog->display_restore_dialog = true;
$this->snapDialog->display_restore_dialog = true;
$this->snapDialog->display_all_removed_objects = true;
}
+
+ /* Restore selected snapshot */
+ if(preg_match("/^RestoreSnapShot_/",$name) && $once){
+ $once = false;
+ $entry = preg_replace("/^RestoreSnapShot_/","",$name);
+ $entry = base64_decode(trim(preg_replace("/_[xy]$/","",$entry)));
+ if(!empty($entry)){
+ $this->restore_snapshot($entry);
+ $this->snapDialog = NULL;
+ }
+ }
}
/* Create a new snapshot requested, check
/* Restore is requested, restore the object with the posted dn .*/
if((isset($_POST['RestoreSnapshot'])) && (isset($_POST['SnapShot']))){
- $entry =trim($_POST['SnapShot']);
- if(!empty($entry)){
- $entry = base64_decode($entry);
- $this->restore_snapshot($entry);
- $this->snapDialog = NULL;
- }
}
if(isset($_POST['CancelSnapshot'])){