summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 98c0483)
raw | patch | inline | side by side (parent: 98c0483)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 7 Dec 2007 13:02:05 +0000 (13:02 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 7 Dec 2007 13:02:05 +0000 (13:02 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8058 594d385d-05f5-0310-b6e9-bd551577e9d8
index 9e944fe641cf3a9cd35e37072513853cd38333d0..066d830286b211f9c45dd72af60d69d56e7d3b22 100644 (file)
/*
-Data structure :
-
+Data structure :
+================
|->o_tab <-- dummy object, collects HTML posts, displays ui
|->a_handles <-- tab object for each given dn
|->tab object for dn 1
...
|->tab object for dn n
+Using this class:
+=================
+ Simple Example:
+
+ $dn = array(dn1,dn2,dn3);
+ $tmp = new multi_plug($config,"usertabs",$config->data['TABS']['USERTABS'],$dn);
+ echo $tmp->execute();
+
+ $tmp can now be used like the normal tab class, execute, save_object ...
+
+ To enable multipe edit for a specific plugin,
+ just set the plugin variable 'multiple_support' to true:
+
+ var $multiple_support = TRUE;
+
+ If plugin::multiple_support is true, the member function
+ multiple_execute() will be called and displayed, NOT execute().
+
+ (I will put this in the wiki, later. This are just notes for me.)
+
*/
@param array $dns The object dns we want to edit.
@return object multi_plug
*/
- public function __construct($config,$class,$tab,$dns)
+ public function __construct($config,$class,$tab,$dns,$acl_base,$acl_category)
{
$this->dn = $dns;
$this->config = $config;
/* Initialize collector object
* Used to display the ui and to collect the user input.
*/
- $this->o_tab = new $class($config,$tab,"new");
+ $this->o_tab = new $class($config,$tab,"new",$acl_category);
+ $this->o_tab->set_acl_base($acl_base);
/* Check if the specified tab object supports multiple edits
*/
/* Initialize the objects we want to edit at once
*/
foreach($dns as $dn){
- $this->a_handles[] = new $class($config,$tab,$dn);
+ $obj = new $class($config,$tab,$dn,$acl_category);
+ $obj->set_acl_base($acl_base);
+ $this->a_handles[] = $obj;
}
}
}
{
$this->populate_values();
$messages = $this->o_tab->check();
- foreach($this->a_handles as $key => $obj){
- $msgs = $obj->check();
- foreach($msgs as $msg){
- $messages[] = $msg;
- }
- }
return($messages);
}
*/
public function password_change_needed()
{
+ foreach($this->a_handles as $i_id => $o_handle){
+ if($o_handle->password_change_needed() && isset($o_handle->by_object['user'])){
+ new msg_dialog(_("Password reset"),_("The user password was resetted, please set a new password value!"),WARNING_DIALOG);
+ change_password ($o_handle->dn, "",0, $o_handle->by_object['user']->pw_storage);
+ }
+ }
return(FALSE);
}
if($this->multiple_available() && is_array($this->a_handles)){
foreach($this->o_tab->by_object as $name => $obj){
+
$values = $this->o_tab->by_object[$name]->get_multi_edit_values();
foreach($values as $a_name => $a_value){
foreach($this->a_handles as $i_id => $o_handle){
- $o_handle->by_object[$name]->$a_name = $a_value;
+ $this->a_handles[$i_id]->by_object[$name]->$a_name = $a_value;
+ echo $name."->".$a_name." = ".$a_value."<br>";
}
}
}
if($this->multiple_available() && is_array($this->a_handles)){
$this->populate_values();
foreach($this->a_handles as $i_id => $o_handle){
- $o_handle->save();
+ $o_handle->save(TRUE);
}
}
}
index db615d67b0beefa36a89acb26678bc3b188da206..51547403d0f4864ca433508f29e500c5f1e8162a 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
}
- /*! \brief execute plugin
-
- Generates the html output for this node
- */
- function execute_multiple()
- {
- /* This one is empty currently. Fabian - please fill in the docu code */
- $_SESSION['current_class_for_help'] = get_class($this);
-
- /* Reset Lock message POST/GET check array, to prevent perg_match errors*/
- $_SESSION['LOCK_VARS_TO_USE'] = $_SESSION['LOCK_VARS_USED'] =array();
-
- return("Multiple edit is currently not implemented for this plugin.");
- }
-
-
-
/*! \brief execute plugin
Generates the html output for this node
$this->entryCSN = getEntryCSN($this->dn);
}
- /* MULTIPLE_EDIT
- Ensures that only selected values will be used.
- Should be rewritten.
- */
- if($this->multiple_support_active){
- foreach($this->attributes as $attr){
- if(isset($_POST["use_".$attr])){
- $this->selected_edit_values[$attr] = TRUE;
- }else{
- $this->selected_edit_values[$attr] = FALSE;
- }
- }
- }
-
/* Save values to object */
foreach ($this->attributes as $val){
if ($this->acl_is_writeable($val) && isset ($_POST["$val"])){
}
- function get_multi_edit_values()
- {
- $ret = array();
- foreach($this->selected_edit_values as $attr => $active){
- if($active){
- $ret[$attr] = $this->$attr;
- }
- }
- return($ret);
- }
-
/* This function enables the entry Serial ID check.
* If an entry was edited while we have edited the entry too,
}
+
+
function set_multi_edit_value()
{
}
+
+ /*! \brief Prepares the plugin to be used for multiple edit
+ */
+ function init_multiple_support()
+ {
+ foreach($this->attributes as $attr){
+ if(isset($this->$attr) && is_string($this->$attr)){
+ $this->$attr = "{default}";
+ }
+ }
+ }
+
+
+ /*! \brief Returns all values that have been modfied in multiple edit mode.
+ @return array Cotaining all mdofied values.
+ */
+ function get_multi_edit_values()
+ {
+ $ret = array();
+ foreach($this->attributes as $attr){
+ if($this->$attr != "{default}"){
+ $ret[$attr] = $this->$attr;
+ }
+ }
+ return($ret);
+ }
+
+
+ /*! \brief execute plugin
+
+ Generates the html output for this node
+ */
+ function multiple_execute()
+ {
+ /* This one is empty currently. Fabian - please fill in the docu code */
+ $_SESSION['current_class_for_help'] = get_class($this);
+
+ /* Reset Lock message POST/GET check array, to prevent perg_match errors*/
+ $_SESSION['LOCK_VARS_TO_USE'] = $_SESSION['LOCK_VARS_USED'] =array();
+
+ return("Multiple edit is currently not implemented for this plugin.");
+ }
+
+
+ /*! \brief Save HTML posted data to object for multiple edit
+ */
+ function multiple_save_object()
+ {
+ if(empty($this->entryCSN) && $this->CSN_check_active){
+ $this->entryCSN = getEntryCSN($this->dn);
+ }
+
+ /* Save values to object */
+ foreach ($this->attributes as $val){
+ if ($this->acl_is_writeable($val) && isset ($_POST["$val"])){
+
+ /* Check for modifications */
+ if (get_magic_quotes_gpc()) {
+ $data= stripcslashes($_POST["$val"]);
+ } else {
+ $data= $this->$val = $_POST["$val"];
+ }
+ if ($this->$val != $data && $data != "{default}"){
+ $this->is_modified= TRUE;
+ }
+
+ /* IE post fix */
+ if(isset($data[0]) && $data[0] == chr(194)) {
+ $data = "";
+ }
+ if($data != "{default}"){
+ $this->$val= $data;
+ }
+ }
+ }
+ }
+
+
+ /*! \brief Check given values in multiple edit
+ @return array Error messages
+ */
+ function multiple_check()
+ {
+ $message = plugin::check();
+ return($message);
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/include/class_tabs.inc b/include/class_tabs.inc
index 9d4a3cedbe9675a65be5490cd59c6663a74ec73d..b6060399a900df6941ec959b1088591ac4f9494a 100644 (file)
--- a/include/class_tabs.inc
+++ b/include/class_tabs.inc
var $by_object= array();
var $SubDialog = false;
- var $multiple_support = FALSE;
+ var $multiple_support_active = FALSE;
function tabs(&$config, $data, $dn, $acl_category= "")
{
/* If multiple edit is enabled for this tab,
we have tho display different templates */
- if(!$this->multiple_support){
+ if(!$this->multiple_support_active){
$display.= $this->by_object[$this->current]->execute();
}else{
- $display.= $this->by_object[$this->current]->execute_multiple();
+ $display.= $this->by_object[$this->current]->multiple_execute();
}
/* Footer for tabbed dialog */
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
$this->last, "Saving");
- $this->by_object[$this->last]->save_object ();
+ if(!$this->multiple_support_active){
+ $this->by_object[$this->last]->save_object ();
+ }else{
+ $this->by_object[$this->last]->multiple_save_object();
+ }
}
/* Skip if curent and last are the same object */
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
$this->current, "Saving (current)");
- $obj->save_object ();
+ if(!$this->multiple_support_active){
+ $obj->save_object();
+ }else{
+ $obj->multiple_save_object();
+ }
}
}
if ($obj->is_account || $ignore_account || $obj->ignore_account){
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$key, "Checking");
- $msg = $obj->check();
+ if(!$this->multiple_support_active){
+ $msg = $obj->check();
+ }else{
+ $msg = $obj->multiple_check();
+ }
if (count($msg)){
$obj->pl_notify= TRUE;
if(!$this->multiple_support_available()){
return(FALSE);
}else{
- $this->multiple_support = TRUE;
+ $this->multiple_support_active = TRUE;
foreach($this->by_object as $name => $obj){
if($obj->multiple_support){
$this->by_object[$name]->multiple_support_active = TRUE;
+ $this->by_object[$name]->init_multiple_support();
}else{
unset($this->by_object[$name]);
unset($this->by_name[$name]);
diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc
index 26058ead46b5b6f46463a8f62f97fa1c74d7e05c..a2f6f70a22941417edf4d8140db44073a5a662ad 100644 (file)
$_SESSION['objectinfo']= $this->dn;
}
-
/********************
Edit multiple entries
foreach($this->list_get_selected_items() as $id){
$this->dn[] = $this->list[$id]['dn'];;
}
- $tmp = new multi_plug($this->config,"usertabs",$this->config->data['TABS']['USERTABS'],$this->dn);
+ $tmp = new multi_plug($this->config,"usertabs",$this->config->data['TABS']['USERTABS'],
+ $this->dn,$this->DivListUsers->selectedBase,"user");
if ($tmp->entries_locked()){
return($tmp->display_lock_message());
}
index 157b5b8d3dac8fab42c3803efb3c041a606938d4..30178739f141ba72d599f6d102034e154e68cae9 100644 (file)
$temp= passwordMethod::get_available_methods();
$is_configurable= FALSE;
$hashes = $temp['name'];
+ $hashes["{default}"] = "{default}";
if(isset($temp[$this->pw_storage])){
$test= new $temp[$this->pw_storage]($this->config);
$is_configurable= $test->is_configurable();
} else {
$smarty->assign("has_phoneaccount", "false");
}
+ $smarty->assign("multiple_support" , $this->multiple_support_active);
return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
}
/* Save data to object */
function save_object()
{
- if (isset($_POST['multiple_user_posted'])){
- $this->save_object_multiple();
- }
if(isset($_POST['generic']) || isset($_POST['multiple_user_posted'])){
/* Make a backup of the current selected base */
*/
if($this->gender=="0") $this->gender ="";
if($this->preferredLanguage=="0") $this->preferredLanguage ="";
-
+
/* First use parents methods to do some basic fillup in $this->attrs */
plugin::save ();
}
+ function init_multiple_support()
+ {
+ plugin::init_multiple_support();
+ $this->pw_storage = "{default}";
+ }
-
-
-
-
- function get_values_to_update()
+ function get_multi_edit_values()
{
$ret = plugin::get_multi_edit_values();
+ if($this->pw_storage != "{default}"){
+ $ret['pw_storage'] = $this->pw_storage;
+ }
return($ret);
}
- function save_object_multiple()
+ function multiple_save_object()
{
- foreach(array("pw_storage","base","edit_cert") as $attr){
- if(isset($_POST["use_".$attr])){
- $this->selected_edit_values[$attr] = TRUE;
- }else{
- $this->selected_edit_values[$attr] = FALSE;
+ plugin::multiple_save_object();
+
+ /* Get pw_storage mode */
+ if (isset($_POST['pw_storage'])){
+ foreach(array("pw_storage") as $val){
+ if(isset($_POST[$val])){
+ $data= validate($_POST[$val]);
+ if ($data != $this->$val){
+ $this->is_modified= TRUE;
+ }
+ $this->$val= $data;
+ }
}
}
+
}
- function execute_multiple()
+ function multiple_execute()
{
- $smarty =get_smarty();
- $language= array_merge(array(0 => " ") ,get_languages(TRUE));
- $smarty->assign("preferredLanguage_list", $language);
- @$smarty->assign("bases", $this->allowedBasesToMoveTo());
- $smarty->assign("base_select", $this->base);
-
- /* Save government mode attributes */
- if (isset($this->config->current['GOVERNMENTMODE']) &&
- preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
- $smarty->assign("governmentmode", "true");
- $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
- "internet,ivbv", "internet,testa", "internet,ivbv,testa");
- $smarty->assign("ivbbmodes", $ivbbmodes);
- foreach ($this->govattrs as $val){
- $smarty->assign("$val", $this->$val);
- $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
- }
- } else {
- $smarty->assign("governmentmode", "false");
- }
-
- $temp= passwordMethod::get_available_methods();
- $hashes = $temp['name'];
- $test= new $temp[$this->pw_storage]($this->config);
- $is_configurable= $test->is_configurable();
- $smarty->assign("pwmode", $hashes);
- $smarty->assign("pwmode_select", $this->pw_storage);
- $smarty->assign("pw_configurable", $is_configurable);
-
- foreach($this->attributes as $attr){
- if(isset($this->selected_edit_values[$attr]) && $this->selected_edit_values[$attr] == TRUE){
- $smarty->assign("use_".$attr,TRUE);
- }else{
- $smarty->assign("use_".$attr,FALSE);
- }
- $smarty->assign($attr,$this->$attr);
- }
- foreach(array("pw_storage","base","edit_cert") as $attr){
- if(isset($this->selected_edit_values[$attr]) && $this->selected_edit_values[$attr] == TRUE){
- $smarty->assign("use_".$attr,TRUE);
- }else{
- $smarty->assign("use_".$attr,FALSE);
- }
- }
- return($smarty->fetch (get_template_path('multiple_generic.tpl', TRUE, dirname(__FILE__))));
+ return($this->execute());
}
index f96d764b25c193ac38dffde37df0ea855c03002c..d5e1fcbedd3e4abcfdd1b434923150b441ab247b 100644 (file)
<tr>
<td colspan="4">
<h2><img alt="" align="middle" src="images/head.png" class="center"> {t}Personal information{/t}</h2>
+
+{if $multiple_support}
+ <p>
+ <b>You are currently editing multiple entries at once. Some attributes may be disabled.<br>
+ All touched values will be written.
+ </b>
+ </p>
+{/if}
+
</td>
</tr>
</tr>
<tr>
<td><label for="uid">{t}Login{/t}{$must}</label></td>
- <td>{render acl=$uidACL}<input id="uid" name="uid" size=25 maxlength=60 value="{$uid}">{/render}</td>
+ <td>
+ {if !$multiple_support}
+ {render acl=$uidACL}
+ <input id="uid" name="uid" size=25 maxlength=60 value="{$uid}">
+ {/render}
+ {else}
+ <input id="uid" name="dummy1" size=25 maxlength=60 value="{t}Multiple edit{/t}" disabled>
+ {/if}
+ </td>
</tr>
{/if}