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 = 54; if($this->parent->snapshotEnabled()){ $action_col_size += 32; } if($this->parent->CopyPasteHandler){ $action_col_size += 20; } /* 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"); } /*! \brief Generate the list header. */ 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"; $s.= "...| "._("Default")."|new_default|\n"; } /* Append multiple remove */ if(preg_match("/d/",$acl)){ $s.= "..|---|\n"; $s.= "..|". " "._("Remove")."|"."del_role|\n"; } /* Add multiple copy & cut icons */ if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl)){ $s.= "..|---|\n"; $s.= "..|". " "._("Copy")."|"."multiple_copy_sudo|\n"; # $s.= "..|". # " "._("Cut")."|"."multiple_cut_sudo|\n"; if($this->parent->CopyPasteHandler->entries_queued()){ $img = ""; $s.="..|".$img." "._("Paste")."|editPaste|\n"; }else{ $img = ""; $s.="..|".$img." "._("Paste")."\n"; } } /* Add snapshot icons */ if(preg_match("/(c.*w|w.*c)/",$acl)){ $s .= "..|---|\n"; $s .= $this->get_snapshot_header(TRUE); } $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); } /*! \brief Prepare the plguin to list a set of objects */ function execute() { $this->ClearElementsList(); $this->GenHeader(); } /*! \brief Create a list of all objects that should be displayed @param Array $list The list of sudo roles, passed from the sudoManagement class. */ function setEntries($list) { /* Prepare links */ $editlink = "%s"; $userimg = "Sudo"; $ui = get_userinfo(); $action_col_size = 54; if($this->parent->snapshotEnabled()){ $action_col_size += 32; } if($this->parent->CopyPasteHandler){ $action_col_size += 20; } // 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(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl)){ # $actions.= " "; $actions.= " "; } $actions.= ""; if(preg_match("/(c.*w|w.*c)/",$acl)){ $actions.= $this->GetSnapShotActions($val['dn']); } 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; /* Highlight defaults entry */ if(preg_match("/^defaults$/i",$val['cn'][0])){ $display = "$display"; } /* 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 = "".$display.""; break; } } } $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); } /*! \brief Save this plugin. In this case nothing will be saved */ function Save() { MultiSelectWindow :: Save(); } /*! \brief Save all relevant HTML inputs for this plugin. */ function save_object() { /* Save automatic created POSTs like regex, checkboxes */ MultiSelectWindow::save_object(); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>