parent = $parent;
$this->ui = get_userinfo();
/* Set default base */
if(!isset($_SESSION['CurrentMainBase'])){
$_SESSION['CurrentMainBase'] = $this->config->current['BASE'];
}
$this->selectedBase = $_SESSION['CurrentMainBase'];
/* Set list strings */
$this->SetTitle(_("List of FAI classes"));
$this->SetSummary(_("This table displays all FAI classes in the selected tree."));
/* Result page will look like a headpage */
$this->SetHeadpageMode();
$this->SetInformation(_("This menu allows you to create, delete and edit FAI classes."));
$this->EnableAplhabet (true);
/* Disable buttonsm */
$this->EnableCloseButton(false);
$this->EnableSaveButton (false);
/* Dynamic action col, depending on snapshot icons */
$action_col_size = 50;
if($this->parent->snapshotEnabled()){
$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='text-align:center;width:20px;'"));
$this->AddHeader(array("string" => _("Name of FAI class"), "attach" => "style=''"));
$this->AddHeader(array("string" => _("Class type"), "attach" => "style='width:200px;'"));
$this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
$this->AddCheckBox("ShowProfiles" , _("Display FAI profile objects") ,_("Show profiles") ,true);
$this->AddCheckBox("ShowTemplates" , _("Display FAI template objects") ,_("Show templates") ,true);
$this->AddCheckBox("ShowScripts" , _("Display FAI scripts") ,_("Show scripts") ,true);
$this->AddCheckBox("ShowHooks" , _("Display FAI hooks") ,_("Show hooks") ,true);
$this->AddCheckBox("ShowVariables" , _("Display FAI variables") ,_("Show variables") ,true);
$this->AddCheckBox("ShowPackages" , _("Display FAI packages") ,_("Show packages") ,true);
$this->AddCheckBox("ShowPartitions" , _("Display FAI partitions") ,_("Show partitions") ,true);
/* Add SubSearch checkbox */
//$this->AddCheckBox(SEPERATOR);
//$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 AddUserBoxToFilter($position)
{
$str = "";
if($position == 2){
/* Check if there are post commands available for fai management.
* If not, grey out freeze/branch and release remove buttons.
*/
$r = $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'));
$c = $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'));
$smarty = get_smarty();
$smarty->assign("allow_create", $c);
$smarty->assign("allow_remove", $r);
$smarty->assign("selectedBranch",$this->selectedBranch);
$smarty->assign("branchimage","images/branch.png");
$smarty->assign("branches",$this->AvailableBranches);
$str = $smarty->fetch(get_template_path('branch_selector.tpl', TRUE));
}
return($str);
}
function GenHeader()
{
/* Prepare departments,
which are shown in the listbox on top of the listbox
*/
$options= "";
/* Get all departments within this subtree */
$ui= get_userinfo();
$first = "";
$found = FALSE;
$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("fai");
$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;
}
/* Add seperator */
$add_sep = false;
/* Get complete fai acls, to be able to check if we must show or hide the snapshot abilities */
$acl_all = $ui->has_complete_category_acls($this->selectedBase,$this->module);
/* Add default header */
$listhead = MultiSelectWindow::get_default_header();
$acl = $ui->get_permissions($this->selectedBase,"fai/faiProfile");
if(preg_match("/c/",$acl)){
$listhead .=" ";
$listhead .="
";
}
/* Add snapshot icons, if we are allowed to write and create the complete fai module ($ui->has_complete_category_acls) */
if(preg_match("/(c.*w|w.*c)/",$acl_all)){
$listhead .= $this->get_snapshot_header($this->selectedBase);
}
/* Add copy & paste icons, currently disabled, this ability is not implemeneted yet */
if(preg_match("/(c.*w|w.*c)/",$acl_all) && isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler){
$Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
}
/* Append create icons for each fai component */
$arr = array(
array("images/fai_new_partitionTable.png" , _("New partition table") ,"Create_partition" , _("PT") , "faiPartitionTable"),
array("images/fai_new_script.png" , _("New scripts") ,"Create_script" , _("S") , "faiScript"),
array("images/fai_new_hook.png" , _("New hooks") ,"Create_hook" , _("H") , "faiHook"),
array("images/fai_new_variable.png" , _("New variables") ,"Create_variable" , _("V") , "faiVariable"),
array("images/fai_new_template.png" , _("New templates ") ,"Create_template" , _("I") , "faiTemplate"),
array("images/fai_new_packages.png" , _("New package list") ,"Create_package" , _("PK") , "faiPackage"));
foreach($arr as $ar){
$acl = $ui->get_permissions($this->selectedBase,"fai/".$ar[4]);
if(preg_match("/c/",$acl)){
$add_sep = true;
$listhead .=" ";
}
}
/* Add additional seperator */
if($add_sep){
$listhead .="
";
}
$listhead .= _("Base")." ".
" ";
/* Multiple options */
$listhead .= " ";
/* Add multiple copy & cut icons */
if(is_object($this->parent->CopyPasteHandler)){
$listhead .= " ";
$listhead .= " ";
$listhead .= "";
}
$listhead .="";;
$this->SetListHeader($listhead);
}
/* so some basic settings */
function execute()
{
$this->ClearElementsList();
$this->GenHeader();
$this->AvailableBranches = $this->parent->getBranches();
}
function setEntries($list)
{
/********************
Variable init
********************/
$objects = array(
"FAIpartitionTable" => array("IMG"=> "images/fai_partitionTable.png", "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"),
"FAIpackageList" => array("IMG"=> "images/fai_packages.png", "NAME"=>_("Package list") , "KZL"=> "PL", "VAR"=>"ShowPackages"),
"FAIscript" => array("IMG"=> "images/fai_script.png", "NAME"=>_("Scripts") , "KZL"=> "S", "VAR"=>"ShowScripts"),
"FAIvariable" => array("IMG"=> "images/fai_variable.png", "NAME"=>_("Variables") , "KZL"=> "V", "VAR"=>"ShowVariables"),
"FAIhook" => array("IMG"=> "images/fai_hook.png", "NAME"=>_("Hooks"), "KZL"=> "H", "VAR"=>"ShowHooks"),
"FAIprofile" => array("IMG"=> "images/fai_profile.png", "NAME"=>_("Profile") , "KZL"=> "P", "VAR"=>"ShowProfiles"),
"FAItemplate" => array("IMG"=> "images/fai_template.png", "NAME"=>_("Templates") , "KZL"=> "T", "VAR"=>"ShowTemplates"));
$editlink ="%NAME%";
/* Dynamic action col, depending on snapshot icons */
$action_col_size = 50;
if($this->parent->snapshotEnabled()){
$action_col_size += 20;
}
/********************
Attach objects
********************/
$cnts = array();
foreach($objects as $key => $data){
$cnts[$key] = 0;
}
foreach($list as $key => $value){
$info = "";
$img = "";
$type = $value['type'];
$abort =false;
$cnts[$type] ++;
if(isset($objects[$type])){
$img = "
";
$info = $objects[$type]['NAME'];
$var = $objects[$type]['VAR'];
}else{
$img = "
";
$info = "";
$var = "";
}
if((isset($value['description']))&&(!empty($value['description']))){
$desc= " [".$value['description']."]";
}else{
$desc= "";
}
if($value['FAIstate'] == "freeze"){
$action= "![F](images/closedlock.png)
";
$action.= "";
}else{
$action= "";
if(preg_match("/(c&w)/",$value['acl'])){
$action.= $this->GetSnapShotActions($value['dn']);;
}
if(preg_match("/d/",$value['acl'])){
$action.= "";
}
}
$edi = $editlink;
$acti = $action;
/* Cutted objects should be displayed in light grey */
$display = $value['cn'].$desc;
if($this->parent->CopyPasteHandler){
foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
if($queue_data['dn'] == $value['dn']) {
$display = "".$display."";
break;
}
}
}
/* Create each field */
$field0 = array("string" => "" ,
"attach" => "style='width:20px;'");
$field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'");
$field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/","/%TITLE%/"),array($key,$display,preg_replace('/ /', ' ', @LDAP::fix($value['dn']))),$edi) , "attach" => "style=''");
$field3 = array("string" => $info, "attach" => "style='width:200px;'");
$field4 = array("string" => preg_replace("/%KEY%/",$key,$acti) , "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
$this->AddElement(array($field0,$field1,$field2,$field3,$field4));
}
/* Create summary string for list footer */
$num_deps=0;
if(!$this->SubSearch){
$num_deps = count($this->Added_Departments);
}
$profile_str = _("Number of listed profiles");
$partition_str = _("Number of listed partitions");
$script_str = _("Number of listed scripts");
$hook_str = _("Number of listed hooks");
$variable_str = _("Number of listed variables");
$template_str = _("Number of listed templates");
$package_str = _("Number of listed packages");
$dep_str = _("Number of listed departments");
$str = "
".$cnts['FAIprofile']." ";
$str.= "
".$cnts['FAIpartitionTable']." ";
$str.= "
".$cnts['FAIscript']." ";
$str.= "
".$cnts['FAIhook']." ";
$str.= "
".$cnts['FAIvariable']." ";
$str.= "
".$cnts['FAItemplate']." ";
$str.= "
".$cnts['FAIpackageList']." ";
$str.= "
".$num_deps." ";
$this->set_List_Bottom_Info($str);
}
function Save()
{
MultiSelectWindow::Save();
}
function save_object()
{
/* Save automatic created POSTs like regex, checkboxes */
MultiSelectWindow::save_object();
$_SESSION['faifilter']['branch'] = $this->selectedBranch;
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>