diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc
index 7b2b9cceb6bdedd0ab4fb10a256383842a3ccb43..b1d5d201ee34d74f7f76b6531be681bc1999395e 100644 (file)
function divListUsers ($config,$parent)
{
- MultiSelectWindow::MultiSelectWindow($config,"Users");
+ MultiSelectWindow::MultiSelectWindow($config, "Users", "users");
$this->parent = $parent;
$this->ui = get_userinfo();
$this->EnableCloseButton(false);
$this->EnableSaveButton (false);
+ /* Dynamic action col, depending on snapshot icons */
+ $action_col_size = 104;
+ if($this->parent->snapshotEnabled()){
+ $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"=>_("Actions"), "attach" => "style='width:102px;border-right:0px;text-align:right;'"));
+ $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);
$this->AddCheckBox("ShowFunctionalUsers",_("Select to see users that have only a GOsa object"),_("Show functional users") , true);
/* 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);
}
+
function GenHeader()
{
/* 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 */
+ $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("users");
+ $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>";
+ }
}
}
- /* Get copy & paste icon */
- if($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'> ".
- " <input class='center' type='image' align='middle' src='images/list_new_user.png'
- title='"._("Create new user")."' alt='"._("New user")."' name='user_new'> ".
- " <input class='center' type='image' align='middle' src='images/list_new.png'
- title='"._("Create new template")."' alt='"._("New template")."' name='user_tplnew'> ".
- $Copy_Paste.
- " <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_all)){
+ $listhead .= $this->get_snapshot_header($this->selectedBase);
+ }
+
+ if(preg_match("/c/",$acl)) {
+ $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_user.png'
+ title='"._("Create new user")."' alt='"._("New user")."' name='user_new'> ";
+ $listhead .= " <input class='center' type='image' align='middle' src='images/list_new.png'
+ title='"._("Create new template")."' alt='"._("New template")."' name='user_tplnew'> ";
+ }
+
+ $listhead .= $Copy_Paste;
+
+ $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 = "";
- $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
+ $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt='-'>";
$userimg = "<img class='center' src='images/select_user.png' alt='User' title='%s'>";
$tplimg = "<img class='center' src='images/select_template.png' alt='Template' title='%s'>";
$editlink = "<a href='?plug=".validate($_GET['plug'])."&id=%s&act=edit_entry'>%s</a>";
- /* Create action icons */
- $action = "";
- if($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'
- src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
+ /* Dynamic action col, depending on snapshot icons */
+ $action_col_size = 104;
+ if($this->parent->snapshotEnabled()){
+ $action_col_size += 38;
}
- $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
- name='user_edit_%KEY%' title='"._("Edit user")."'>";
- $action.= "<input class='center' type='image' src='images/list_password.png' alt='"._("password")."'
- name='user_chgpw_%KEY%' title='"._("Change password")."'>";
- $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
- name='user_del_%KEY%' title='"._("Delete user")."'>";
-
+
/* Possilbe objectClass image combinations */
$possibleAccounts = array(
"posixAccount" => array("VAR"=>"posix" ,"IMG"=>"posiximg"),
"apple-user" => array("VAR"=>"netatalk" ,"IMG"=>"netatalkimg"));
/* Pictures for Extensions */
- $usrimg ="<input class='center' type='image' src='images/penguin.png' alt='"._("GOsa")."'
+ $usrimg ="<input class='center' type='image' src='images/select_user.png' alt='"._("GOsa")."'
name='user_edit_%KEY%-user' title='"._("Edit generic properties")."'>";
- $posiximg = "<input class='center' type='image' src='images/select_user.png' alt='"._("Posix")."'
+ $posiximg = "<input class='center' type='image' src='images/penguin.png' alt='"._("Posix")."'
name='user_edit_%KEY%-posixAccount' title='"._("Edit UNIX properties")."'>";
$eviroimg = "<input class='center' type='image' src='images/smallenv.png' alt='"._("Environment")."'
name='user_edit_%KEY%-environment' title='"._("Edit environment properties")."'>";
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
********************/
+ $ui = get_userinfo();
+
// Test Every Entry and generate divlist Array
foreach($list as $key => $val){
+ /* Create action icons */
+ $action= "";
+
+ /* Add copy & cut icons */
+ $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'
+ src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
+ }
+
+ /* Generate edit icon */
+ $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
+ name='user_edit_%KEY%' title='"._("Edit user")."'>";
+
+ /* Add Password change icon, if we are able to write users/password */
+ if(!in_array_ics("gosaUserTemplate",$val['objectClass']) && preg_match("/w/",$ui->get_permissions($val['dn'],"users/password"))) {
+ $action.= "<input class='center' type='image' src='images/list_password.png' alt='"._("password")."'
+ name='user_chgpw_%KEY%' title='"._("Change password")."'>";
+ }else{
+ $action.= "<img class='center' src='images/empty.png' alt=' '
+ title='"._("You are not allowed to change the password for this user.")."'>";
+ }
+
+ /* Add snapshot icon */
+ if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+ $action.= $this->GetSnapShotActions($val['dn']);
+ }
+
+ /* Add remove icon, if we are allowed to remove the current user */
+ if(preg_match("/d/",$ui->get_permissions($val['dn'],"users/user"))) {
+ $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
+ name='user_del_%KEY%' title='"._("Delete user")."'>";
+ }else{
+ $action.= "<img class='center' src='images/empty.png' alt=' '
+ title='"._("You are not allowed to remove this user.")."'>";
+ }
+
/* 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;
+ $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:102px;border-right:0px; text-align:right;'");
+ "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()