diff --git a/plugins/admin/departments/class_divListDepartment.inc b/plugins/admin/departments/class_divListDepartment.inc
index ebbb7ac3f77a887250ce3879bcd7bdfb515362f1..c3a59151906c925885b8f3cc8d0416205c2cd143 100755 (executable)
function divListDepartment ($config,$parent)
{
- MultiSelectWindow::MultiSelectWindow($config,"Department");
+ MultiSelectWindow::MultiSelectWindow($config, "Department", "department");
$this->parent = $parent;
$this->ui = get_userinfo();
$this->EnableCloseButton(false);
$this->EnableSaveButton (false);
+
+
+ /* Toggle all selected / deselected */
+ $chk = "<input type='checkbox' id='select_all' name='select_all'
+ onClick='toggle_all_(\"^item_selected_[a-zA-Z0-9\=]*$\",\"select_all\");' >";
+
/* set Page header */
+ $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
$this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
$this->AddHeader(array("string"=>_("Department name"), "attach" => "style=''"));
$this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'"));
{
/* Prepare departments,
which are shown in the listbox on top of the listbox
- */
+ */
$options= "";
- foreach ($this->config->idepartments as $key => $value){
- if ($this->selectedBase == $key){
- $options.= "<option selected='selected' value='$key'>$value</option>";
- } else {
- $options.= "<option value='$key'>$value</option>";
+
+ /* Get all departments within this subtree */
+ $ui= get_userinfo();
+ $first = "";
+ $found = FALSE;
+ $base = $this->config->current['BASE'];
+
+ /* Add base */
+ $tmp = array();
+ $tmp[] = array("dn"=>$this->config->current['BASE']);
+ $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+ array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+
+ $deps = array();
+ foreach($tmp as $tm){
+ $deps[$tm['dn']] = $tm['dn'];
+ }
+
+ /* Load possible departments */
+ $ui= get_userinfo();
+ $tdeps= $ui->get_module_departments("department");
+ $ids = $this->config->idepartments;
+ $first = "";
+ $found = FALSE;
+ foreach($ids as $dep => $name){
+ if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
+
+ /* Keep first base dn in mind, we could need this
+ * info if no valid base was found
+ */
+ if(empty($first)) {
+ $first = $dep['dn'];
+ }
+
+ $value = $ids[$dep];
+ if ($this->selectedBase == $dep){
+ $found = TRUE;
+ $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+ } else {
+ $options.= "<option value='".$dep."'>$value</option>";
+ }
}
}
+ /* The currently used base is not visible with your acl setup.
+ * Set base to first useable base.
+ */
+ if(!$found){
+ $this->selectedBase = $first;
+ }
+
/* Generate list head */
- $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input type='image' class='center' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='". _("Root")."'> ".
- " <input type='image' class='center' src='images/list_up.png' align='middle' title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'> ".
- " <input type='image' class='center' src='images/list_home.png' align='middle' title='"._("Go to users home department")."' name='dep_home' alt='". _("Home")."'> ".
- " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
- " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
- " <input class='center' type='image' src='images/list_new_department.png' align='middle' alt='"._("Create new department")."' name='dep_new'> ".
- " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
- _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
- " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
- "</div>";
+ $ui = get_userinfo();
+ $acl = $ui->get_permissions("ou=dummy,".$this->selectedBase ,"department/department");
+
+ /* Add default header */
+ $listhead = MultiSelectWindow::get_default_header();
+
+ if(preg_match("/c/",$acl)){
+ $listhead .= " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
+ " <input class='center' type='image' src='images/list_new_department.png' ".
+ " align='middle' alt='"._("Create new department")."' name='dep_new'> ";
+ }
+
+
+ $listhead .= " <img class='center' src='images/list_seperator.png' align='middle' ".
+ " alt='' height='16' width='1'> ".
+ " "._("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+ " <input class='center' type='image' src='images/list_submit.png' align='middle' ".
+ " title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ";
+
+ /* Multiple options */
+ $listhead .= " <input class='center' type='image' align='middle' src='images/edittrash.png'
+ title='"._("Remove selected departments")."' alt='"._("Remove departments")."' name='remove_multiple_departments'> ";
+
+ $listhead .="</div>";;
$this->SetListHeader($listhead);
}
function setEntries($list)
{
- $actions= "<input class='center' type='image' src='images/edit.png'
- alt='"._("edit")."' name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
- $actions.= "<input class='center' type='image' src='images/edittrash.png'
- alt='"._("delete")."' name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
-
$linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
+ $ui = get_userinfo();
foreach($list as $key => $val) {
+
+ $actions= "";
+
+ $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department");
+ if(preg_match("/r/",$acl)){
+ $actions.= "<input class='center' type='image' src='images/edit.png'
+ alt='"._("edit")."' name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
+ }
+
+ if(preg_match("/c/",$acl)){
+ $actions.= "<input class='center' type='image' src='images/edittrash.png'
+ alt='"._("delete")."' name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
+ }
+
if(!isset($this->config->departments[trim($key)])){
$this->config->departments[trim($key)]="";
}
}
$title = preg_replace('/ /', ' ', @LDAP::fix($this->config->departments[$key]));
+
+ if($val == "."){
+ $field01 = array("string" => " ",
+ "attach" => "style='width:20px;'");
+ }else{
+ $field01 = array("string" => "<input type='checkbox' id='item_selected_".base64_encode($key)."'
+ name='item_selected_".base64_encode($key)."'>" ,
+ "attach" => "style='width:20px;'");
+ }
+
$field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
$field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'");
$field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align:
right;'");
- $this->AddElement( array($field0,$field1,$field2));
+ $this->AddElement( array($field01,$field0,$field1,$field2));
}
}