summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 15d26cd)
raw | patch | inline | side by side (parent: 15d26cd)
author | dradon <dradon@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 20 Apr 2011 10:19:29 +0000 (10:19 +0000) | ||
committer | dradon <dradon@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 20 Apr 2011 10:19:29 +0000 (10:19 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20754 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/ihtml/themes/default/acl.tpl | patch | blob | history | |
gosa-core/include/class_acl.inc | patch | blob | history | |
gosa-core/include/class_sortableListing.inc | patch | blob | history |
index 15ad1983b333b545da67ae69647bb28a8f6ce3c0..f5ed778a9799740844dfbe0c57f08c9b54d7b437 100644 (file)
</table>
<hr>
- <h3>{t}Members{/t}</h3>
- <table style="width:100%" summary='{t}Member selection{/t}'>
- <tr>
- <td style="width:48%">
- {t}Use members from{/t}
- <select name="target" onChange="document.mainform.submit()" size=1>
- {html_options options=$targets selected=$target}
- <option disabled> </option>
- </select>
- {if $javascript eq 'false'}<button type='submit' name='refresh'>{t}Apply{/t}</button>{/if}
- </td>
- <td> </td>
- <td>{t}Members{/t}</td>
- <tr>
- <td style="width:48%">
- {if !$acl_writeable}
- <select style="width:100%;height:180px;" disabled name="dummy_s[]" size="20" multiple title="{t}List message possible targets{/t}">
- {html_options options=$sources}
- <option disabled> </option>
- </select>
- {else}
- <select style="width:100%;height:180px;" name="source[]" size="20" multiple title="{t}List message possible targets{/t}">
- {html_options options=$sources}
- <option disabled> </option>
- </select>
- {/if}
- </td>
- <td>
-
- {if $acl_writeable}
- <button type='submit' name='add'>></button>
-
- <br><br>
- <button type='submit' name='del'><</button>
-
- {/if}
- </td>
- <td style="width:48%">
- {if !$acl_writeable}
- <select style="width:100%;height:180px;" disabled name="dummy_r[]" size="20" multiple title="{t}List message recipients{/t}">
- {html_options options=$recipients}
- <option disabled> </option>
- </select>
-
- {else}
- <select style="width:100%;height:180px;" name="recipient[]" size="20" multiple title="{t}List message recipients{/t}">
- {html_options options=$recipients}
- <option disabled> </option>
- </select>
- {/if}
- </td>
- </tr>
- </table>
+ <h3>{t}Members{/t}</h3>
+ {$aclMemberList}
+ <button type='submit'
+ {if !$acl_writeable} disabled="disabled" {/if}
+ name='add_user_or_group'>{msgPool type=addButton}</button>
+
+ <button type='submit'
+ {if !$acl_writeable} disabled="disabled" {/if}
+ name='add_all_users'>Add all users</button>
{if $aclType ne 'reset'}
{if $aclType ne 'role'}
index 60a4e65beb7f406ae4c0176f84346a9bd6c5da9b..4d24dbda657ef81a7f221cf53194515c6fdb216e 100644 (file)
var $sectionList = NULL;
var $roleList = NULL;
+ var $aclMemberList = NULL;
function acl (&$config, $parent, $dn= NULL)
{
$this->roleList->setHeader(array(_("Used"),_("Name"),_("Description")));
$this->roleList->setDefaultSortColumn(1);
$this->roleList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
+
+ $this->aclMemberList = new sortableListing(array(), array(), false);
+ $this->aclMemberList->setEditable(false);
+ $this->aclMemberList->setDeleteable(true);
+ $this->aclMemberList->setInstantDelete(false);
+ $this->aclMemberList->sortingEnabled(true);
+ $this->aclMemberList->setWidth("100%");
+ $this->aclMemberList->setHeight("150px");
+ //$this->aclMemberList->setColspecs(array('20px','*','*'));
+ $this->aclMemberList->setHeader(array(_("~"),_("Name"),_("Description")));
+ $this->aclMemberList->setDefaultSortColumn(1);
+ $this->aclMemberList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
}
$this->dialog= TRUE;
$this->loadAclEntry();
}
-
+
foreach($_POST as $name => $post){
$post =get_post($name);
}
/* Remove from list? */
- if (isset($_POST['del']) && isset($_POST['recipient'])){
- foreach ($_POST['recipient'] as $key){
+ if (isset($_POST['del']) && isset($_POST['recipient'])) {
+ foreach ($_POST['recipient'] as $key) {
unset($this->recipients[$key]);
}
}
+ $this->aclMemberList->save_object();
+ $actionL = $this->aclMemberList->getAction();
+ if($actionL['action'] == "delete") {
+ $key = $this->aclMemberList->getData($actionL['targets'][0]);
+ unset($this->recipients[$key]);
+ $this->aclMemberList->deleteEntry($actionL['targets'][0]);
+ }
+
+ /* Adds the 'all-users' peudo-group to the acl */
+ if(isset($_POST['add_all_users'])) {
+ if(!isset($this->recipients['G:*'])) {
+ $this->recipients['G:*'] = _("All users");
+
+ $key = "G:*";
+ $vData = array("data" => array(image("plugins/groups/images/select_group.png"),
+ _("All users"),
+ _("Pseudo-group for all users.")));
+
+ $this->aclMemberList->addEntry($key, $vData, $key);
+ }
+ }
+
+ /* Show User/Group-Add-Dialog */
+ if(isset($_POST['add_user_or_group'])) {
+ $this->dialog = new userGroupSelect($this->config, get_userinfo());
+ }
+
+ /* If dialog is confirmed */
+ if(isset($_POST['userGroupSelect_save']) &&
+ $this->dialog instanceof userGroupSelect) {
+
+ $groupIcon = image("plugins/groups/images/select_group.png");
+ $userIcon = image("plugins/users/images/select_user.png");
+
+ if($this->acl_is_writeable("")) {
+ foreach($this->dialog->save() as $entry) {
+ if(in_array("posixGroup", $entry['objectClass'])) {
+ $key = "G:" . $entry['dn'];
+ $vData = array("data" => array($groupIcon, $entry['cn'][0], $entry['description'][0]));
+
+ $this->recipients[$key] = $entry['cn'][0];
+ }
+ else if(isset($entry['uid'])) {
+ $key = "U:" . $entry['dn'];
+ $vData = array("data" => array($userIcon, $entry['uid'][0], $entry['cn'][0]));
+
+ $lData = array($key => $key);
+ $this->recipients["U:" . $entry['dn']] = $entry['uid'][0];
+ }
+ else {
+ // Error
+ break;
+ }
+
+ $this->aclMemberList->addEntry($key, $vData, $key);
+ }
+ }
+
+ unset($this->dialog);
+ $this->dialog = true;
+ }
+
+ /* If dialog is canceled */
+ if(isset($_POST['userGroupSelect_cancel']) &&
+ $this->dialog instanceof userGroupSelect) {
+ unset($this->dialog);
+ $this->dialog = true;
+ }
+
+ if($this->dialog instanceof userGroupSelect) {
+ // filter current members out
+ $used = array();
+ foreach(array_keys($this->recipients) as $key) {
+ $used['dn'][] = substr($key, 2);
+ }
+
+ session::set('filterBlacklist', $used);
+ return $this->dialog->execute();
+ }
+
/* Create templating instance */
$smarty= get_smarty();
$smarty->assign('sources', set_post($tmp));
$smarty->assign('recipients', set_post($this->recipients));
+ /* Generate ACL member list */
+ if($this->acl_is_writeable("")) {
+ $this->aclMemberList->setDeleteable(true);
+ } else {
+ $this->aclMemberList->setDeleteable(false);
+ }
+
+ $this->aclMemberList->update();
+ $smarty->assign("aclMemberList", $this->aclMemberList->render());
+
/* Acl selector if scope is base */
if ($this->aclType == 'base'){
$smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
$this->recipients= $acl['members'];
$this->aclContents= (isset($acl['acl'])) ? $acl['acl'] :"";
$this->aclFilter= $acl['filter'];
+
+ /* Add members to aclMemberList */
+ $vData = array();
+ $lData = array();
+ foreach($this->recipients as $key => $val) {
+ // split name and description
+ $match = NULL;
+ preg_match_all("/^([^\[]+)( \[(.*)\])?$/", $val, $match);
+
+ $name = "";
+ $desc = "";
+ $icon = NULL;
+ if($key == "G:*") {
+ $name = _("All users");
+ $desc = _("Pseudo-group for all users.");
+ $icon = image("plugins/groups/images/select_group.png");
+ }
+ else if($key[0] == 'U') { // is user?
+ $name = $match[3][0];
+ $desc = $match[1][0];
+ $icon = image("plugins/users/images/select_user.png");
+ }
+ else { // or group?
+ $name = $match[1][0];
+ $desc = $match[3][0];
+ $icon = image("plugins/groups/images/select_group.png");
+ }
+
+ $lData[$key] = $key;
+ $vData[$key] = array("data" => array($icon, $name, $desc));
+ }
+
+ $this->aclMemberList->setListData($lData, $vData);
}
$this->wasNewEntry= $new;
diff --git a/gosa-core/include/class_sortableListing.inc b/gosa-core/include/class_sortableListing.inc
index 8e03f08b1841922311b6e90ace97f82a6863e228..a8b627c8965dc49b6c2ab45bfcd6ff1f5286b2b7 100644 (file)
define ('LIST_DISABLED', 2);
class sortableListing {
- private $header= null;
- private $colspecs= null;
- private $reorderable= true;
- private $width= "400px";
- private $height= "100px";
- private $cssclass= "";
- private $id;
-
- private $sortingEnabled= true;
- private $data= array();
- private $keys= array();
- private $modes= array();
- private $displayData= array();
- private $columns= 0;
- private $deleteable= false;
- private $editable= false;
- private $colorAlternate= false;
- private $instantDelete= true;
- private $action;
- private $mapping;
- private $current_mapping;
- private $active_index;
- private $scrollPosition= 0;
- private $sortColumn= 0;
- private $sortDirection= array();
-
- private $acl= "";
- private $modified= false;
-
-
+ public $header= null;
+ public $colspecs= null;
+ public $reorderable= true;
+ public $width= "400px";
+ public $height= "100px";
+ public $cssclass= "";
+ public $id;
+
+ public $sortingEnabled= true;
+ public $data= array();
+ public $keys= array();
+ public $modes= array();
+ public $displayData= array();
+ public $columns= 0;
+ public $deleteable= false;
+ public $editable= false;
+ public $colorAlternate= false;
+ public $instantDelete= true;
+ public $action;
+ public $mapping;
+ public $current_mapping;
+ public $active_index;
+ public $scrollPosition= 0;
+ public $sortColumn= 0;
+ public $sortDirection= array();
+
+ public $acl= "";
+ public $modified= false;
+
+
public function sortableListing($data= array(), $displayData= null, $reorderable= false)
{
global $config;
$this->sortColumn = $id;
}
- /*
- *
- * Examples
- * DatenARray ($data)
- * @param: array( arbitrary object, arbitrary object)
- * Datenarray will be manipulated by add, del and sort operations. According to this it will be returned from this widget.
- * The index of a data entry must correspond to the entry of the "display array" following.
- * DisplayArray ($displyData)
- * @param: array("eins" array( "data"=> array("Uno", "2", "x" ) , "zwei" array( "data"=> array("Due", "3", "y" ))) ;
- * label pointing on a list of columns that will be shown in the list.
- */
+ /*
+ *
+ * Examples
+ * DatenARray ($data)
+ * @param: array( arbitrary object, arbitrary object)
+ * Datenarray will be manipulated by add, del and sort operations. According to this it will be returned from this widget.
+ * The index of a data entry must correspond to the entry of the "display array" following.
+ * DisplayArray ($displyData)
+ * @param: array("eins" array( "data"=> array("Uno", "2", "x" ) , "zwei" array( "data"=> array("Due", "3", "y" ))) ;
+ * label pointing on a list of columns that will be shown in the list.
+ */
public function setListData($data, $displayData= null)
{
// Save data to display
$this->setDisplayData($displayData);
}
- //setting flat data
+ //setting flat data
private function setData($data)
{
$this->data= $data;
}
- // collecting the display data -
+ // collecting the display data -
private function setDisplayData($data)
{
if (!is_array($data)) {
public function render()
- {
+ {
$result= "<div class='sortableListContainer' id='scroll_".$this->id."' style='min-width:".$this->width.";height: ".$this->height."'>\n";
$result.= "<table summary='"._("Sortable list")."' border='0' cellpadding='0' cellspacing='0' width='100%' style='width:100%' ".(!empty($this->cssclass)?" class='".$this->cssclass."'":"").">\n";
$action_width= 0;
foreach ($_POST as $key => $value) {
$value = get_post($key);
if (preg_match('/^del_'.$this->id.'_([0-9]+)$/', $key, $matches)) {
+
+
+ if(!isset($this->mapping[$matches[1]])) return;
+
$this->active_index= $this->mapping[$matches[1]];
// Ignore request if mode requests it
foreach ($_POST as $key => $value) {
$value = get_post($key);
if (preg_match('/^edit_'.$this->id.'_([0-9]+)$/', $key, $matches)) {
+
+ if(!isset($this->mapping[$matches[1]])) return;
+
$this->active_index= $this->mapping[$matches[1]];
// Ignore request if mode requests it
}
- private function deleteEntry($id)
+ public function deleteEntry($id)
{
// Remove mapping
$index= array_search($id, $this->mapping);
if ($index !== false) {
$target = $this->mapping[$index];
+ $key = $this->keys[$target];
+
unset($this->mapping[$index]);
if(isset($this->displayData[$target])){
unset($this->displayData[$target]);
- unset($this->data[$target]);
+ unset($this->data[$key]);
unset($this->keys[$target]);
}
$this->mapping= array_values($this->mapping);