diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc
index 0dec827bd6320b24f2bcda89404b1421d1db2674..b1d5d201ee34d74f7f76b6531be681bc1999395e 100644 (file)
$action_col_size += 38;
}
+ /* Toggle all selected / deselected */
+ $chk = "<input type='checkbox' id='select_all' name='select_all'
+ onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+
/* set Page header */
- $this->AddHeader(array("string"=>" ", "attach"=>"style='width:20px;'"));
+ $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
+ $this->AddHeader(array("string"=> " ", "attach"=>"style='width:20px;'"));
$this->AddHeader(array("string"=>_("Username")." / "._("Department")));
- $this->AddHeader(array("string"=>_("Properties"), "attach" => "style='width:152px;'"));
+ $this->AddHeader(array("string"=>_("Properties"), "attach" => "style='width:166px;'"));
$this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
$this->AddCheckBox("ShowTemplates" ,_("Select to see template pseudo users") ,_("Show templates") , false);
/* Add SubSearch checkbox */
$this->AddCheckBox(SEPERATOR);
- $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
+ $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false);
/* Name ,Text ,Default , Connect with alphabet */
$this->AddRegex ("Regex", _("Display users matching"),"*" , true);
/* Get all departments within this subtree */
$base = $this->config->current['BASE'];
- $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
- array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+
+ /* 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("users");
-
$ids = $this->config->idepartments;
-
- foreach($deps as $dep){
- if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+ $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['dn']];
- if ($this->selectedBase == $dep['dn']){
- $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
+ $value = $ids[$dep];
+ if ($this->selectedBase == $dep){
+ $found = TRUE;
+ $options.= "<option selected='selected' value='".$dep."'>$value</option>";
} else {
- $options.= "<option value='".$dep['dn']."'>$value</option>";
+ $options.= "<option value='".$dep."'>$value</option>";
}
}
}
- /* Get copy & paste icon */
- $acl = $ui->get_permissions($this->selectedBase,"users/user");
- if(preg_match("/(c.*w|w.*c)/",$acl) && $this->parent->CopyPasteHandler){
+ /* The currently used base is not visible with your acl setup.
+ * Set base to first useable base.
+ */
+ if(!$found){
+ $this->selectedBase = $first;
+ }
+
+ /* Get copy & paste icon */
+ $acl_all = $ui->has_complete_category_acls($this->selectedBase,"users") ;
+ $acl = $ui->get_permissions($this->selectedBase,"users/user");
+ if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){
$Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
}else{
$Copy_Paste ="";
}
- /* Create header with selected base */
- $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input class='center' type='image' src='images/list_root.png' align='middle'
- title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
- " <input class='center' type='image' align='middle' src='images/list_back.png'
- title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
- " <input class='center' type='image' align='middle' src='images/list_home.png'
- title='"._("Go to users department")."' alt='"._("Home")."' name='dep_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'> ";
-
+ /* Add default header */
+ $listhead = MultiSelectWindow::get_default_header();
- if(preg_match("/(c.*w|w.*c)/",$acl)){
+ if(preg_match("/(c.*w|w.*c)/",$acl_all)){
$listhead .= $this->get_snapshot_header($this->selectedBase);
}
$listhead .=
_("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>";
+ 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 user")."' alt='"._("Remove user")."' name='remove_multiple_users'> ";
+
+ /* Add multiple copy & cut icons */
+ if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+ $listhead .= " <input class='center' type='image' align='middle' src='images/editcopy.png'
+ title='"._("Copy selected user")."' alt='"._("Copy users")."' name='multiple_copy_users'> ";
+ $listhead .= " <input class='center' type='image' align='middle' src='images/editcut.png'
+ title='"._("cut selected user")."' alt='"._("Cut users")."' name='multiple_cut_users'> ";
+ }
+ $listhead .="</div>";;
$this->SetListHeader($listhead);
}
/********************
Variable init
********************/
+
+ $num_users = 0;
+ $num_templates = 0;
/* Variable initialation */
$enviro = $posix = $maila = $faxac = $samba = $netatalk = "";
END :: Variable init
********************/
- /* Get Configuration for goFon DB (if it is set), to connect to the asterisk tables.
- * Read Sip Table for specified account (for each user with phoneAccount).
- * Check the attributes ip port and regseconds.
- * If regseconds is set and >0 , the phone is logged in.
- * Else the phone is currently not logged.
- * If we can't read any Data from the DB or there is no goFon DB specified
- * show old style without status icons.
- */
- $r_db =false;
- $r_con =false;
- if (isset($_SESSION['config']->data['SERVERS']['FON'])){
- $a_SETUP= $_SESSION['config']->data['SERVERS']['FON'];
- $r_con = false;
- $r_db = false;
- if(is_callable("mysql_pconnect")){
- $r_con= @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
- // Check if we are connected correctly
- if($r_con){
- $r_db = @mysql_select_db($a_SETUP['DB'],$r_con);
- }
- }
- }
-
/********************
Append entries to divlist
$action= "";
/* Add copy & cut icons */
-
- $acl = $ui->get_permissions($val['dn'],"users/user");
- if(preg_match("/(c.*w|w.*c)/",$acl) && $this->parent->CopyPasteHandler){
+ $acl_all = $ui->has_complete_category_acls($this->selectedBase,"users") ;
+ $acl = $ui->get_permissions($val['dn'],"users/user");
+ if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){
$action .= "<input class='center' type='image'
src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
$action.= "<input class='center' type='image'
}
/* Add snapshot icon */
- if(preg_match("/(c.*w|w.*c)/",$acl)){
+ if(preg_match("/(c.*w|w.*c)/",$acl_all)){
$action.= $this->GetSnapShotActions($val['dn']);
}
}
/* Create phonaccopunt informationm, if conencted && is phoneAccount */
- $connected = ""; // This string represents timestamp or offline status
- $ip_port = ""; // String that will represent ip : port of the connected phone
if((in_array("goFonAccount" ,$val['objectClass']))){
/* Set defaults */
$fonac = preg_replace("/%KEY%/", "$key", $fonac);
$fonac = preg_replace("/%title%/", "", $fonac);
- /* Database connection is ok ?*/
- if(($r_db)&&(is_callable("mysql_query"))){
- $res= @mysql_query("SELECT regseconds,name,port,ipaddr FROM ".$a_SETUP['SIP_TABLE']." WHERE (name='".$val['uid'][0]."')");
- $mysql_entry = @mysql_fetch_row($res);
- if(is_array($mysql_entry)){
- if((isset($mysql_entry[0]))&&($mysql_entry[0]>1)){
- $connected = " | "._("Online")." : ".gmdate("d.m.Y H:i:s",($mysql_entry[0]+(60*60)));
- $fonac = preg_replace("/%image%/", "select_phone_connected.png", $fonimg);
- $fonac = preg_replace("/%KEY%/", "$key", $fonac);
- $fonac = preg_replace("/%title%/", $connected, $fonac);
- $ip_port= " - ".$mysql_entry[3].":".$mysql_entry[2];
- }
- if((isset($mysql_entry[0]))&&($mysql_entry[0]==0)){
- $connected = " | "._("Offline");
- $fonac = preg_replace("/%image%/", "select_phone.png", $fonimg);
- $fonac = preg_replace("/%KEY%/", "$key", $fonac);
- $fonac = preg_replace("/%title%/", $connected, $fonac);
- }
- }
- }
}else{
$fonac=$empty;
}
if(in_array("gosaUserTemplate",$val['objectClass'])){
$tpl = preg_replace("/%KEY%/", "$key", $tplimg);
$s_img_create_from_template = preg_replace("/%KEY%/", "$key", $tplcreateuserimg);
+ $num_templates ++;
}else{
$s_img_create_from_template = "";
$tpl = $userimg;
+ $num_users ++;
}
/* Insert key into userimg */
/* Connect all images */
$UseImg = $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$netatalk;
+ /* Cutted objects should be displayed in light grey */
+ if($this->parent->CopyPasteHandler){
+ foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
+ if($queue_data['dn'] == $val['dn']) {
+ $display = "<font color='#999999'>".$display."</font>";
+ break;
+ }
+ }
+ }
+
/* Create each field */
+ $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+ "attach" => "style='width:20px;'");
$field1 = array("string" => sprintf($tpl,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port, "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
- $field3 = array("string" => $UseImg, "attach" => "style='width:152px;'");
+ $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
+ $field3 = array("string" => $UseImg, "attach" => "style='width:166px;'");
$field4 = array("string" => $s_img_create_from_template.preg_replace("/%KEY%/", "$key", $action),
"attach" => "style='width:".$action_col_size."px;border-right:0px; text-align:right;'");
/* Add to list */
- $add = array($field1,$field2,$field3,$field4);
+ $add = array($field0,$field1,$field2,$field3,$field4);
$this->AddElement($add);
// Template or User
$users[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
}
}
-
- /* close database connection, if it was opened */
- if(isset($r_con)){
- if((is_callable("mysql_close"))&&($r_con)){
- @mysql_close($r_con);
- }
+
+
+ /* Create summary string for list footer */
+ $num_deps=0;
+ if(!$this->SubSearch){
+ $num_deps = count($this->Added_Departments);
}
+ $num_users = count($list);
+
+ $num_user_str = _("Number of listed users");
+ $num_dep_str = _("Number of listed departments");
+
+ $str = "<img class='center' src='images/select_user.png'
+ title='".$num_user_str."' alt='".$num_user_str."'> ".$num_users." ";
+ $str.= "<img class='center' src='images/folder.png'
+ title='".$num_dep_str."' alt='".$num_dep_str."'> ".$num_deps." ";
+ $this->set_List_Bottom_Info($str);
}
function Save()