summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5f42367)
raw | patch | inline | side by side (parent: 5f42367)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 23 Feb 2010 07:44:04 +0000 (07:44 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 23 Feb 2010 07:44:04 +0000 (07:44 +0000) |
- The plugin is now able to edit loginRestriction in multi-edit mode.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15666 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15666 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/plugins/personal/generic/class_user.inc | patch | blob | history | |
gosa-core/plugins/personal/generic/generic.tpl | patch | blob | history |
diff --git a/gosa-core/plugins/personal/generic/class_user.inc b/gosa-core/plugins/personal/generic/class_user.inc
index 8214ef77c311c7f57269d94faff23db00b7d50e8..7df04a8e6659d9487d424fe83c84d02faa4711fa 100644 (file)
$smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !session::is_set('edit'))));
}
- $smarty->assign("gosaLoginRestrictionACL", $this->getacl('gosaLoginRestriction', (!is_object($this->parent) && !session::is_set('edit'))));
+ // Special ACL for gosaLoginRestrictions -
+ // In case of multiple edit, we need a readonly ACL for the list.
+ $smarty->assign('gosaLoginRestriction_ONLY_R_ACL',
+ preg_replace("/[^r]/i","", $this->getacl($val,(!is_object($this->parent) && !session::is_set('edit')))));
+
$smarty->assign("pwmode", $pwd_methods);
$smarty->assign("pwmode_select", $this->pw_storage);
$smarty->assign("pw_configurable", $is_configurable);
$ret['orig_base']="Changed_by_Multi_Plug";
$ret['base']=$this->base;
}
+
+ $ret['gosaLoginRestriction'] = $this->gosaLoginRestriction;
+ $ret['gosaLoginRestriction_some'] = $this->gosaLoginRestriction_some;
+
return($ret);
}
}
}
}
-
+
/* Refresh base */
if ($this->acl_is_moveable($this->base)){
if (!$this->baseSelector->update()) {
}
}
}
+
+ /* Sync lists */
+ $this->gosaLoginRestrictionWidget->save_object();
+ if ($this->gosaLoginRestrictionWidget->isModified()) {
+ $this->gosaLoginRestriction= array_values($this->gosaLoginRestrictionWidget->getMaintainedData());
+ }
}
}
+ /*! \brief Prepares the plugin to be used for multiple edit
+ * Update plugin attributes with given array of attribtues.
+ * \param array Array with attributes that must be updated.
+ */
+ function init_multiple_support($attrs,$all)
+ {
+ plugin::init_multiple_support($attrs,$all);
+
+ // Get login restrictions
+ if(isset($attrs['gosaLoginRestriction'])){
+ $this->gosaLoginRestriction =array();
+ for($i =0;$i < $attrs['gosaLoginRestriction']['count']; $i++){
+ $this->gosaLoginRestriction[] = $attrs['gosaLoginRestriction'][$i];
+ }
+ }
+
+ // Detect login restriction not used in all user objects.
+ $this->gosaLoginRestriction_some = array();
+ if(isset($all['gosaLoginRestriction'])){
+ for($i=0;$i<$all['gosaLoginRestriction']['count'];$i++){
+ $this->gosaLoginRestriction_some[] = $all['gosaLoginRestriction'][$i];
+ }
+ }
+
+
+ // Reinit the login restriction list.
+ $data = $this->convertLoginRestriction();
+ if(count($data)){
+ $this->gosaLoginRestrictionWidget->setListData($data['data'], $data['displayData']);
+ }
+ }
+
+
+ function set_multi_edit_values($attrs)
+ {
+ $lR = array();
+
+ // Update loginRestrictions, keep my settings while ip is optional
+ foreach($attrs['gosaLoginRestriction_some'] as $ip){
+ if(in_array($ip, $this->gosaLoginRestriction) && in_array($ip, $attrs['gosaLoginRestriction'])){
+ $lR[] = $ip;
+ }
+ }
+
+ // Add enforced loginRestrictions
+ foreach($attrs['gosaLoginRestriction'] as $ip){
+ $lR[] = $ip;
+ }
+
+ $lR = array_values(array_unique($lR));
+ $this->is_modified |= array_differs($this->gosaLoginRestriction, $lR);
+ plugin::set_multi_edit_values($attrs);
+ $this->gosaLoginRestriction = $lR;
+ }
+
+
+ function convertLoginRestriction()
+ {
+ $all = array_unique(array_merge($this->gosaLoginRestriction,$this->gosaLoginRestriction_some));
+ $data = array();
+ foreach($all as $ip){
+ $data['data'][] = $ip;
+ if(!in_array($ip, $this->gosaLoginRestriction)){
+ $data['displayData'][] = array('mode' => LIST_MARKED , 'data' => array($ip.' ('._("Entries differ").')'));
+ }else{
+ $data['displayData'][] = array('mode' => 0 , 'data' => array($ip));
+ }
+ }
+ return($data);
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/gosa-core/plugins/personal/generic/generic.tpl b/gosa-core/plugins/personal/generic/generic.tpl
index afecb253ed7443710c757e8f701d3ea1bce0a8a7..6ef9d87e444ccafcc9fdd760eb7bfb92d5793702 100644 (file)
</tr>
{/if}
- {if !$multiple_support}
<tr>
<td colspan=2>
<div style="height:10px;"></div>
<tr>
<td style='vertical-align:top'><label for="edit_perms">{t}Restrict login to{/t}</label></td>
<td>
-{render acl=$gosaLoginRestrictionACL}
- {$gosaLoginRestrictionWidget}
- <input type="text" id="res" name="res" size=22 maxlength=33 value="{t}IP or network{/t}" onFocus='document.getElementById("res").value=""'>
- <input id="add_res" type="submit" name="add_res" value="{t}Add{/t}">
-
-{/render}
+
+ {if !$multiple_support}
+ {$gosaLoginRestrictionWidget}
+ <input type="text" id="res" name="res" size=22 maxlength=33
+ value="{t}IP or network{/t}" onFocus='document.getElementById("res").value=""'>
+ <input id="add_res" type="submit" name="add_res" value="{t}Add{/t}">
+ {else}
+ <input type='checkbox' name='use_gosaLoginRestriction' {if $use_gosaLoginRestriction} checked {/if}
+ onClick='document.mainform.submit();'
+ >
+ {if !$use_gosaLoginRestriction}
+ {render acl=$gosaLoginRestriction_ONLY_R_ACL}
+ {$gosaLoginRestrictionWidget}
+ {/render}
+ {else}
+ {render acl=$gosaLoginRestrictionACL}
+ {$gosaLoginRestrictionWidget}
+ {/render}
+ {render acl=$gosaLoginRestrictionACL}
+ <input type="text" id="res" name="res" size=22 maxlength=33
+ value="{t}IP or network{/t}" onFocus='document.getElementById("res").value=""'>
+ {/render}
+ {render acl=$gosaLoginRestrictionACL}
+ <input id="add_res" type="submit" name="add_res" value="{t}Add{/t}">
+ {/render}
+ {/if}
+ {/if}
</td>
</tr>
- {/if}
</table>
</td>
</tr>