parent = &$parent; $this->ui = get_userinfo(); /* Set list strings */ $this->SetTitle( _("List of sudo roles")); $this->SetSummary(_("List of sudo roles")); $this->EnableAplhabet(true); /* Result page will look like a headpage */ $this->SetHeadpageMode(); /* Disable buttonsm */ $this->EnableCloseButton(false); $this->EnableSaveButton (false); /* Dynamic action col, depending on snapshot icons */ $action_col_size = 80; /* 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"=>_("Name")." / "._("Department"))); $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'")); /* Add SubSearch checkbox */ $this->AddCheckBox("SubSearch", msgPool::selectToView("","subsearch"),msgPool::selectToView("","subsearch_small"), false); $this->AddRegex ("Regex" , _("Regular expression for matching role names") , "*" , true); $this->AddRegex ("UserRegex", _("Regular expression for matching role member names"), "*" , FALSE,"images/search_user.png"); } function GenHeader() { /* Prepare departments, which are shown in the listbox on top of the listbox */ $base = sudo::get_sudoers_ou($this->config); $acl = $this->ui->get_category_permissions($base,"sudo"); /* Add default header */ $listhead = MultiSelectWindow::get_default_header(); /* Create Layers menu */ $s = ".|"._("Actions")."|\n"; $s .= "..|". " "._("Create")."|\n"; /* Append create options */ if(preg_match("/c/",$acl)) { $s.= "...| "._("Role")."|new_role|\n"; } /* Append multiple remove */ if(preg_match("/d/",$acl)){ $s.= "..|---|\n"; $s.= "..|". " "._("Remove")."|"."del_role|\n"; } $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); } function execute() { $this->ClearElementsList(); $this->GenHeader(); } function setEntries($list) { /* Prepare links */ $editlink = "%s"; $userimg = "Sudo"; $ui = get_userinfo(); $action_col_size = 80; // Test Every Entry and generate divlist Array foreach($list as $key => $val){ /* Create action icons - copy & paste icons */ $acl = $ui->get_permissions($val['dn'],"sudo/sudo"); /* Add edit icon */ $actions = ""; $actions.= ""; if(preg_match("/d/",$acl)){ $actions.= ""; } $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; if(!isset($val['description'][0])){ $desc = ""; }else{ $desc = " - [ ".$val['description'][0]." ]"; } $display = $val['cn'][0].$desc; $field1 = array("string" => "" , "attach" => "style='width:20px;'"); $field2 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); $field3 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title); $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); $this->AddElement(array($field1,$field2,$field3,$field4)); } /* Create summary string for list footer */ $num = count($list); $num_str = _("Number of listed roles"); $str = "".$num_str." ".$num." "; $this->set_List_Bottom_Info($str); } 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: ?>