diff --git a/gosa-core/include/class_MultiSelectWindow.inc b/gosa-core/include/class_MultiSelectWindow.inc
index 41ec46c67d564715649e86b79d06d1c80cf25593..9c9bd5071763836acd638b6201d0f0a983b95fd5 100644 (file)
$divlist->SetEntriesPerPage(0); // 0 for scrollable list
/* Display list footer with summary of all listed entries */
- if(isset($this->config->data['MAIN']['LIST_SUMMARY']) && preg_match("/true/i",$this->config->data['MAIN']['LIST_SUMMARY'])){
+ if ($this->config->get_cfg_value("listSummary") == "true"){
$divlist->SetFooter($this->get_List_Bottom_Info());
}
}
}
- /* Save base selection from headpage selectbox*/
+ /* Save base selection from headpage selectbox */
if(isset($_POST['CurrentMainBase'])){
- $this->selectedBase = $_POST['CurrentMainBase'];
+ $this->selectedBase = get_post('CurrentMainBase');
+ session::global_set("CurrentMainBase", $this->selectedBase);
+ } else {
+ $this->selectedBase= session::global_get("CurrentMainBase");
}
/* Homebutton is posted */
}
}
}
+
+ /* Save currenlty selected base in session */
+ session::global_set("CurrentMainBase",$this->selectedBase);
}
{
$this->DepartmentsAdded = true;
$this->Added_Departments = array();
+ $this->departments = array();
+
+ if(isset($this->Regex)){
+ $this->base_selection_regex = $this->Regex;
+ }
+
+ $linkopen = "<a href='?plug=".$_GET['plug']."&post_id=".$this->post_id."&act=dep_open&dep_id=%s'>%s</a>";
+ $types = departmentManagement::get_support_departments();
+ $ui = get_userinfo();
+ $module_deps = $ui->get_module_departments($this->module);
+ $found_deps = array();
/* check for a valid base */
if(!$base){
$ldap = $this->config->get_ldap_link();
$ldap->cd($base);
- /* reset current deps */
- $this->departments = array();
-
/* Get all departments within this subtree */
- $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
- array("ou", "description","objectClass"), GL_SIZELIMIT );
-
- /* Edit delete link for system types
- */
- $linkopen = "<a href='?plug=".$_GET['plug']."&post_id=".$this->post_id."&act=dep_open&dep_id=%s'>%s</a>";
-
- /* Create an array with all visible (in the list) departments */
- $types = departmentManagement::get_support_departments();
-
-
- /* Create search filter
- */
- $this->departments = array();
+ $s_filter = "";
+ $s_attrs = array("description","objectClass");
+ $s_acls = $this->module;
foreach($types as $name => $data){
- $filter = "(&(objectClass=gosaDepartment)(objectClass=".$data['OC'].")
- (".$data['ATTR']."=".$this->base_selection_regex."))";
- $tmp = get_list($filter,"department/".$data['ACL'],$this->selectedBase,array($data['ATTR'],"description"),GL_NONE);
- foreach($tmp as $attrs){
- $attrs['NAME'] = $attrs[$data['ATTR']][0];
- $attrs['TYPE'] = $data;
- $name = $attrs['NAME']." -".$attrs['dn'];
- $this->departments[$name] = $attrs;
- }
+ $s_filter.= "(&(objectClass=gosaDepartment)(objectClass=".$data['OC'].")(".$data['ATTR']."=".$this->base_selection_regex."))";
+ $s_attrs[]= $data['ATTR'];
}
- uksort($this->departments, 'strnatcasecmp');
-
- $ui = get_userinfo();
- $module_deps = $ui->get_module_departments($this->module);
-
- /* Add deps to this dialog object list */
- $this->departments = array_values($this->departments);
- foreach($this->departments as $key=> $val){
-
- if(!in_array($val['dn'],$module_deps)) continue;
-
- /* Check if this department contains sub-departments
- Display different image in this case
- */
- $img = $val['TYPE']['IMG'];
- foreach($this->config->departments as $keyd){
- if(preg_match("/,".normalizePreg($val['dn'])."$/",$keyd)){
- $img = $val['TYPE']['IMG_FULL'];
+ $tmp = get_list("(|".$s_filter.")",$s_acls,$this->selectedBase,$s_attrs,GL_NONE);
+ foreach($tmp as $attrs){
+ foreach($types as $name => $data){
+ if(in_array($data['OC'],$attrs['objectClass']) && isset($attrs[$data['ATTR']][0])){
+ $attrs['NAME'] = $attrs[$data['ATTR']][0];
+ $attrs['TYPE'] = $data;
+ $name = $attrs['NAME']." ".$attrs['dn'];
+ $departments[$name] = $attrs;
+ $found_deps[$name] = $attrs['dn'];
+ break;
}
}
+ }
- $img = "<image src='".$img."' class='center'>";
+ /* Detect allowed departments
+ */
+ $deps = array_intersect($found_deps,$module_deps);
+ uksort($deps, 'strnatcasecmp');
+ $key = 0;
+ foreach($deps as $name => $dn){
+ $key ++;
+ $val = $departments[$name];
+ $this->departments[$key] = $val;
+ $img = "<image src='".$val['TYPE']['IMG']."' class='center'>";
/* Add spacer cols to divlist
*/
/* Add departments
*/
- $row[]=$field1=array("string"=> $img,"attach"=>"style='text-align:center;width:20px;'");
- $row[]=$field2=array("string"=>sprintf($linkopen,$key,$name), "attach" => "style=''");
+ $row[]=array("string"=> $img,"attach"=>"style='text-align:center;width:20px;'");
+ $row[]=array("string"=>sprintf($linkopen,$key,$name), "attach" => "style=''");
/* Add spacer tabs
*/
function create_department_list($modules)
{
- /* Load possible departments */
+ $departments = array();
$ui= get_userinfo();
$first = "";
$found = FALSE;
+ $options ="";
- if(!is_array($modules)){
- $modules = array($modules);
- }
-
- $department = $departments = array();
$ids = $this->config->idepartments;
- foreach($modules as $module){
- $d = $ui->get_module_departments($module);
-
- foreach($ids as $department => $desc){
- if(in_array($department,$d)){
- $departments[$department] = $department;
- }
- }
+ $d = $ui->get_module_departments($modules);
+ $k_ids = array_keys($ids);
+ $deps = array_intersect($d,$k_ids);
+ foreach($k_ids as $department){
+ $departments[$department] = $ids[$department];
}
- $first = "";
- $found = FALSE;
- $options ="";
- foreach($departments as $dep => $name){
+ foreach($departments as $value => $name){
/* Keep first base dn in mind, we could need this
* info if no valid base was found
*/
if(empty($first)) {
- $first = $dep['dn'];
+ $first = $value;
}
- $value = $ids[$dep];
- if ($this->selectedBase == $dep){
+
+ $v_value = htmlentities($value,ENT_QUOTES);
+ if ($this->selectedBase == $value){
$found = TRUE;
- $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+ $options.= "<option selected='selected' value=\"".$v_value."\">$name</option>";
} else {
- $options.= "<option value='".$dep."'>$value</option>";
+ $options.= "<option value=\"".$v_value."\">$name</option>";
}
}