parent = $parent;
$this->ui = get_userinfo();
/* Set list strings */
$this->SetTitle(_("List of users"));
$this->SetSummary(_("List of users"));
/* Result page will look like a headpage */
$this->SetHeadpageMode();
$this->SetInformation(_("This menu allows you to create, edit and delete selected users. Having a great number of users, you may want to use the range selectors on top of the user list."));
$this->EnableAplhabet (true);
/* Disable buttonsm */
$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 = "";
/* set Page header */
$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: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);
$this->AddCheckBox("ShowUnixUsers" ,_("Select to see users that have posix settings") ,_("Show unix users") , true);
$this->AddCheckBox("ShowMailUsers" ,_("Select to see users that have mail settings") ,_("Show mail users") , true);
$this->AddCheckBox("ShowSambaUsers" ,_("Select to see users that have samba settings") ,_("Show samba users") , true);
$this->AddCheckBox("ShowProxyUsers" ,_("Select to see users that have proxy settings") ,_("Show proxy users") , true);
/* Add SubSearch checkbox */
$this->AddCheckBox(SEPERATOR);
$this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore 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= "";
/* 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.= "";
} else {
$options.= "";
}
}
}
/* 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 ="";
}
/* 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 .= " ";
$listhead .= " ";
}
$listhead .= $Copy_Paste;
$listhead .=
_("Base")." ".
" ";
/* Multiple options */
$listhead .= " ";
$listhead .="";;
$this->SetListHeader($listhead);
}
/* so some basic settings */
function execute()
{
$this->ClearElementsList();
$this->GenHeader();
}
function setEntries($list)
{
/********************
Variable init
********************/
/* Variable initialation */
$enviro = $posix = $maila = $faxac = $samba = $netatalk = "";
$empty = "";
$userimg = "";
$tplimg = "";
$editlink = "%s";
/* Dynamic action col, depending on snapshot icons */
$action_col_size = 104;
if($this->parent->snapshotEnabled()){
$action_col_size += 38;
}
/* Possilbe objectClass image combinations */
$possibleAccounts = array(
"posixAccount" => array("VAR"=>"posix" ,"IMG"=>"posiximg"),
"gotoEnvironment" => array("VAR"=>"enviro" ,"IMG"=>"eviroimg"),
"gosaMailAccount" => array("VAR"=>"maila" ,"IMG"=>"mailimg"),
"goFaxAccount" => array("VAR"=>"faxac" ,"IMG"=>"faximg"),
"sambaSamAccount" => array("VAR"=>"samba" ,"IMG"=>"sambaimg"),
"apple-user" => array("VAR"=>"netatalk" ,"IMG"=>"netatalkimg"));
/* Pictures for Extensions */
$usrimg ="";
$posiximg = "";
$eviroimg = "";
$mailimg = "";
$fonimg = "";
$faximg = "";
$sambaimg = "";
$netatalkimg = "";
$tplcreateuserimg = "";
/********************
END :: Variable init
********************/
/********************
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 .= " ";
$action.= " ";
}
/* Generate edit icon */
$action.= "";
/* 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.= "";
}else{
$action.= "";
}
/* 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.= "";
}else{
$action.= "";
}
/* Create phonaccopunt informationm, if conencted && is phoneAccount */
if((in_array("goFonAccount" ,$val['objectClass']))){
/* Set defaults */
$fonac = preg_replace("/%image%/", "select_phone.png", $fonimg);
$fonac = preg_replace("/%KEY%/", "$key", $fonac);
$fonac = preg_replace("/%title%/", "", $fonac);
}else{
$fonac=$empty;
}
/* Set images for different types of objectClasses */
foreach($possibleAccounts as $objectClass => $Settigns){
if(in_array($objectClass ,$val['objectClass'])){
$$Settigns['VAR'] = preg_replace("/%KEY%/", "$key", $$Settigns['IMG']);
}else{
$$Settigns['VAR'] = $empty;
}
}
/* Create userimg */
if(in_array("gosaUserTemplate",$val['objectClass'])){
$tpl = preg_replace("/%KEY%/", "$key", $tplimg);
$s_img_create_from_template = preg_replace("/%KEY%/", "$key", $tplcreateuserimg);
}else{
$s_img_create_from_template = "";
$tpl = $userimg;
}
/* Insert key into userimg */
$usrimg2 = preg_replace("/%KEY%/", "$key", $usrimg);
// Generate caption for rows
if (isset($val["sn"]) && isset($val["givenName"])){
$display= $val["sn"][0].", ".$val["givenName"][0]." [".$val["uid"][0]."]";
} else {
$display= "[".$val["uid"][0]."]";
}
/* Connect all images */
$UseImg = $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$netatalk;
/* Create each field */
$field0 = array("string" => "" ,
"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), "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($field0,$field1,$field2,$field3,$field4);
$this->AddElement($add);
// Template or User
if(in_array("gosaUserTemplate",$val['objectClass'])){
$tpls[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
}else{
$users[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
}
}
}
function Save()
{
MultiSelectWindow :: Save();
}
function save_object()
{
/* Save automatic created POSTs like regex, checkboxes */
MultiSelectWindow::save_object();
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>