summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 777dcc2)
raw | patch | inline | side by side (parent: 777dcc2)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 17 Apr 2007 06:37:58 +0000 (06:37 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 17 Apr 2007 06:37:58 +0000 (06:37 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6059 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/addons/gotomasses/class_gotomasses.inc | patch | blob | history | |
plugins/addons/gotomasses/contents.tpl | patch | blob | history | |
plugins/addons/gotomasses/main.inc | patch | blob | history |
diff --git a/plugins/addons/gotomasses/class_gotomasses.inc b/plugins/addons/gotomasses/class_gotomasses.inc
index 83a10850b73d5cb9c8774b0ef5e1fe47cf2ac431..a8230776f8aad1208e5f1a077a762390f0128261 100644 (file)
var $file_to_read = "Undefined"; #Set in constructor
/* Parsed csv content */
- var $contents = array();
+ var $contents = array();
+
+ /* Used to detect changes made on the csv content.
+ * Buttons will be disabled and js warnings will be
+ * shown if the content wasn't saved or discarded
+ */
+ var $contents_backup = array();
function gotomasses($config, $dn= NULL)
/* Call parent execute */
plugin::execute();
$smarty= get_smarty();
+ $smarty->assign("contents_modified",$this->contents_modified());
$smarty->assign("ogs", $this->get_object_groups());
$smarty->assign("contents", $this->contents);
$smarty->assign("launchimage","images/launch.png");
return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
}
+
+ /* Check if something is modified */
+ function contents_modified($display = FALSE)
+ {
+ $a = $this->contents;
+ $b = $this->contents_backup;
+ if(count($a) != count($b)){
+ if($display){
+ print_a(array_diff_assoc($a,$b));
+ }
+ return(TRUE);
+ }else{
+ foreach($a as $a_key => $a_val){
+ if(count(array_diff($a_val, $b[$a_key]))){
+
+ if($display){
+ print_a(array_diff($a_val, $b[$a_key]));
+ }
+ return(TRUE);
+ }
+ }
+ }
+ return(FALSE);
+ }
+
function load_csv_data($data = NULL)
{
}
}
}
+ $this->contents_backup = $this->contents;
}
/* Write back all changes */
if(isset($_POST['save_gotomass_changes'])){
$this->save_csv_data();
+
+ /* Call load again, so we will see if everything is fine.
+ * And load_csv_data causes the contents_backup to be updated
+ */
+ $this->load_csv_data();
}
/* Reload data from csv file ? */
index 59bfa56a07f77172b5467e74f68b902fea3733c9..f2d108f58839f293092818d36354909bc7a5fcc1 100644 (file)
<p> </p>
<div class="contentboxb" style="border-top: 1px solid #B0B0B0; padding:0px;">
<p class="contentboxb" style='text-align:right'>
+{if $contents_modified}
<input type='submit' name='reload_gotomass_data' value='{t}Discard changes{/t}'>
<input type='submit' name='save_gotomass_changes' value='{t}Apply changes{/t}'>
+{else}
+ <input type='submit' name='reload_gotomass_data' value='{t}Discard changes{/t}' disabled>
+ <input type='submit' name='save_gotomass_changes' value='{t}Apply changes{/t}' disabled>
+{/if}
</p>
</div>
<input type='hidden' name='gotomasses' value='1'>
+
+<!-- Display a warning if the content was modified, but not saved yet -->
+{if !$contents_modified}
+ <input type='hidden' name='ignore' value='1'>
+{/if}
+
+
+
+
+
+
+
index 89dea8fb88847b9cce561291b7ce5dcd78ee69eb..07877f190d4889232d6efd9cb5482f6f3f69d35f 100644 (file)
/* Execute formular */
$display= $gotomasses->save_object();
$display= $gotomasses->execute ();
- $display.= "<input type=\"hidden\" name=\"ignore\">\n";
+
+/* Ignore plugin changes is handled by the gotomasses class itself */
+# $display.= "<input type=\"hidden\" name=\"ignore\">\n";
/* Page header*/
$display= print_header(get_template_path('images/system.png'), _("Mass machine deployment")).$display;