From b56dea33ddbad0b41200c3c52e50975de186d2ac Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 17 May 2006 05:18:39 +0000 Subject: [PATCH] Added conference div list git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3371 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../gofon/conference/class_divListMacros.inc | 172 ++++++++++ .../class_phoneConferenceManagment.inc | 304 +++++------------- plugins/gofon/conference/main.inc | 1 + 3 files changed, 254 insertions(+), 223 deletions(-) create mode 100755 plugins/gofon/conference/class_divListMacros.inc diff --git a/plugins/gofon/conference/class_divListMacros.inc b/plugins/gofon/conference/class_divListMacros.inc new file mode 100755 index 000000000..b9d21b54f --- /dev/null +++ b/plugins/gofon/conference/class_divListMacros.inc @@ -0,0 +1,172 @@ +parent = $parent; + $this->ui = get_userinfo(); + + /* Set list strings */ + $this->SetTitle(_("List of conference rooms")); + $this->SetSummary(_("List of conference rooms")); + + /* Result page will look like a headpage */ + $this->SetHeadpageMode(); + $this->SetInformation(_("This menu allows you to create, delete and edit selected phone conferences. ". + "Having a large number of phone conferences, you might prefer the range ". + "selectors on top of the conferences list.")); + + $this->EnableAplhabet(true); + + /* Disable buttonsm */ + $this->EnableCloseButton(false); + $this->EnableSaveButton (false); + + /* set Page header */ + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" =>_("Name - Number"), "attach" => "style=''")); + $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'")); + $this->AddHeader(array("string" => _("PIN"), "attach" => "style='width:50px;'")); + $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")); + + /* Add Checkboxes / SubSearch checkbox */ + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false); + + /* Name ,Text ,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching conference names"),"*" , 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.= ""; + } else { + $options.= ""; + } + } + + /* NEW LIST MANAGMENT */ + $listhead = "
". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + "  ". + _("Base")." ". + "  ". + "
"; + + $this->SetListHeader($listhead); + } + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + } + + function setEntries($list) + { + $actions = ""; + $actions.= ""; + $actions2= ""; + $linkopen= "%s"; + + $userimg = "User"; + $editlink = "%s"; + + /* Insert conferneces*/ + foreach($list as $conferencekey => $conference ){ + + if((isset($conference['goFonPIN'][0]))&&(($this->parent->ui->dn==$conference['goFonConferenceOwner'][0])||($this->parent->acl=="#all#"))){ + $pin = "PIN"; + }else{ + $pin = " "; + } + + if(isset($conference['telephoneNumber'][0])){ + $number = " - ".$conference['telephoneNumber'][0]; + }else{ + $number = "  - ?"; + } + + $ldap= $this->parent->config->get_ldap_link(); + $ldap->cat($conference['goFonConferenceOwner'][0], array('cn')); + $data = $ldap->fetch(); + $cn = $data['cn'][0]; + + $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => "style='text-align:center;width:20px;'"); + + if(($this->parent->acl=="#all#")||(($this->parent->ui->dn==$conference['goFonConferenceOwner'][0])&&(chkacl($this->parent->acl,"goFonConferenceOwner")==""))){ + $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$conference['cn'][0].$number), "attach" => "style=''"); + }else{ + $a_field2 = array("string"=>$conference['cn'][0].$number, "attach" => "style=''"); + } + $a_field3 = array("string"=> $cn, "attach" => "style='width:200px;'"); + $a_field4 = array("string"=> $pin, "attach" => "style='width:50px;'"); + + if(($this->parent->ui->dn==$conference['goFonConferenceOwner'][0])&&(chkacl($this->parent->acl,"goFonConferenceOwner")=="")){ + $a_field5 = array("string"=>preg_replace("/%KEY%/",$conferencekey,$actions), "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + }elseif(chkacl($this->acl,"goFonConferenceOwner")==""){ + $a_field5 = array("string"=>preg_replace("/%KEY%/",$conferencekey,$actions2), "attach" => "style='width:52px;border-right:0px;text-align:right;'"); + }else{ + $a_field5 = array("string"=>" ", "attach" => "style='width:52px;border-right:0px;text-align:right;'"); + } + + $this->AddElement(array($a_field1,$a_field2,$a_field3,$a_field4,$a_field5)); + } + + + + } + + 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: +?> diff --git a/plugins/gofon/conference/class_phoneConferenceManagment.inc b/plugins/gofon/conference/class_phoneConferenceManagment.inc index 3dc7eb390..508af3112 100644 --- a/plugins/gofon/conference/class_phoneConferenceManagment.inc +++ b/plugins/gofon/conference/class_phoneConferenceManagment.inc @@ -30,15 +30,14 @@ class phoneConferenceManagment extends plugin var $cli_description = "Some longer text\nfor help"; var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); - /* Headpage attributes */ - var $conferences = array(); - /* attribute list for save action */ var $attributes = array(); var $objectclasses = array(); + + var $conferences = array(); var $conftab = false; - var $departments =array(); + var $DivListConference = NULL; /* Initialise Class */ function phoneConferenceManagment ($config, $ui) @@ -50,22 +49,20 @@ class phoneConferenceManagment extends plugin $acl= get_permissions ($ui->dn, $ui->subtreeACL); $this->acl= get_module_permission($acl, "conference", $ui->dn); - /* Get global filter config */ - if (!isset($_SESSION["conferencefilter"])){ - $base= get_base_from_people($ui->dn); - $conferencefilter= array( - "regex" => "*"); - $_SESSION["conferencefilter"] = $conferencefilter; - } + $this->DivListConference = new divListConference($this->config,$this); } + /* Execute class and display something */ function execute() { + /* Call parent execute */ + plugin::execute(); - /* Call parent execute */ - plugin::execute(); - + /*************** + Variable initialisation + ***************/ + /* Reload departments */ $smarty = get_smarty(); $display = ""; @@ -73,27 +70,11 @@ class phoneConferenceManagment extends plugin $s_entry = ""; // The entry name for edit delete -... $conferencefilter = $_SESSION["conferencefilter"]; - if(isset($_POST['regexit'])){ - $conferencefilter['regex']=$_POST['regexit']; - } - - if(isset($_GET['search'])){ - if($_GET['search']=="*"){ - $conferencefilter['regex']=$_GET['search']; - }else{ - $conferencefilter['regex']=$_GET['search']."*"; - } - } - - $smarty->assign("regex",$conferencefilter['regex']); - - /* Start for New List Managment */ - if(isset($_GET['act'])&&($_GET['act']=="dep_open")){ - $s_action="open"; - $s_entry = base64_decode($_GET['dep_id']); - $_SESSION['CurrentMainBase']= $this->config->departments[trim($s_entry)]; - } + /*************** + Check posts + ***************/ + foreach($_POST as $key => $post){ if(preg_match("/.*new.*/i",$key)){ $s_action = "new"; @@ -107,12 +88,6 @@ class phoneConferenceManagment extends plugin $s_action="edit"; $s_entry = preg_replace("/conf_".$s_action."_/i","",$key); $s_entry = preg_replace("/_.*$/","",$s_entry); - }elseif(preg_match("/dep_back.*/i",$key)){ - $s_action="back"; - }elseif(preg_match("/dep_home.*/i",$key)){ - $s_action="home"; - }elseif(preg_match("/dep_root.*/i",$key)){ - $s_action="root"; } } @@ -122,39 +97,13 @@ class phoneConferenceManagment extends plugin $s_entry = $_GET['id']; } - /* Department changed? */ - if(isset($_POST['CurrentMainBase']) && $_POST['CurrentMainBase']){ - $_SESSION['CurrentMainBase']= $_POST['CurrentMainBase']; - } - - /* Homebutton is posted */ - if($s_action=="home"){ - $_SESSION['CurrentMainBase'] =preg_replace("/^[^,]+,/","",$this->ui->dn); - $_SESSION['CurrentMainBase'] =preg_replace("/^[^,]+,/","",$_SESSION['CurrentMainBase']); - } - - /* back to root */ - if($s_action=="root"){ - $_SESSION['CurrentMainBase']=($this->config->current['BASE']); - } - - /* If Backbutton is Posted */ - if($s_action=="back"){ - $base_back = preg_replace("/^[^,]+,/","",$_SESSION['CurrentMainBase']); - $base_back = convert_department_dn($base_back); - - if(isset($this->config->departments[trim($base_back)])){ - $_SESSION['CurrentMainBase']= $this->config->departments[trim($base_back)]; - }else{ - $_SESSION['CurrentMainBase']= $this->config->departments["/"]; - } - } - - register_global("conferencefilter",$conferencefilter); - $this->reload(); + /*************** + Cancel dialogs + ***************/ + /* Reset requested? */ - if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ + if (isset($_POST['edit_cancel'])){ if (isset($this->conftab)){ del_lock ($this->conftab->dn); unset ($this->conftab); @@ -165,6 +114,11 @@ class phoneConferenceManagment extends plugin unset ($_SESSION['objectinfo']); } + + /*************** + Delete + ***************/ + /* Delete Entry if Posted action (s_action) == del * The entry which will be deleted is defined in $s_entry */ @@ -183,6 +137,11 @@ class phoneConferenceManagment extends plugin } } + + /*************** + Delete confirmed + ***************/ + /* If department deletion is accepted ... * Finally delete department */ @@ -190,12 +149,16 @@ class phoneConferenceManagment extends plugin if (chkacl($this->acl, "delete") == ""){ $this->remove_from_parent(); gosa_log ("Department object'".$this->dn."' has been removed"); - $this->reload (); } else { print_red (_("You have no permission to remove this department.")); } } + + /*************** + Edit + ***************/ + /* Edit Entry if Posted action (s_action) == edit * The entry which will be edited is defined in $s_entry */ @@ -215,15 +178,25 @@ class phoneConferenceManagment extends plugin $_SESSION['objectinfo']= $this->dn; } + + /*************** + Create new + ***************/ + /* Insert new entry*/ if($s_action == "new"){ - $this->dn= "new"; + /* Set up the users ACL's for this 'dn' */ $this->dn= "new"; $this->conftab= new conferencetabs($this->config,$this->config->data['TABS']['CONFERENCETABS'], $this->dn); - unset($_SESSION['objectinfo']);// + unset($_SESSION['objectinfo']); } + + /*************** + Save entry + ***************/ + /* Edit finished, check and save changes */ if ((isset($_POST['edit_finish'])) && (isset($this->conftab->config))){ /* Check tabs, will feed message array */ @@ -250,10 +223,13 @@ class phoneConferenceManagment extends plugin } else { show_errors($message); } - - $this->reload(); } + + /*************** + Display dialogs + ***************/ + /* if edit or new, show dialog */ if(($this->conftab) && (isset($this->conftab->config))){ $display= $this->conftab->execute(); @@ -269,165 +245,42 @@ class phoneConferenceManagment extends plugin return ($display); } - /* Header + Departmentlist*/ - $options= ""; - foreach ($this->config->idepartments as $key => $value){ - if ($_SESSION['CurrentMainBase'] == $key){ - $options.= ""; - } else { - $options.= ""; - } - } - $listhead = "
". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - "  ". - _("Base")." ". - "  ". - "
"; - - /* Images for delete / edit */ - $actions = ""; - $actions.= ""; - - $actions2= ""; - /* open an entry */ - $linkopen= "%s"; - - /* Set Header */ - $divlist = new divlist("conferenceTabs"); - $divlist->SetSummary(_("This table displays all available conference rooms.")); - $divlist->SetEntriesPerPage(0); - $divlist->SetHeader(array( - array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), - array("string" =>_("Name - Number"), "attach" => "style=''"), - array("string" => _("Owner"), "attach" => "style='width:200px;'"), - array("string" => _("PIN"), "attach" => "style='width:50px;'"), - array("string" =>_("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'"))); - - /* Insert departments in divlist*/ - foreach($this->departments as $key=> $val){ - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } + /*************** + display divlist + ***************/ - $non_empty=""; - $keys= str_replace("/","\/",$key); - foreach($this->config->departments as $keyd=>$vald ){ - if(preg_match("/".$keys."\/.*/",$keyd)){ - $non_empty="full"; - } - } - - /* Prepare and insert fields*/ - $a_field1 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); - $a_field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''"); - $a_field3 = array("string" => " ", "attach" => "style='width:200px;'"); - $a_field4 = array("string" => " ", "attach" => "style='width:50px;'"); - $a_field5 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + /* Return rendered main page */ + /* Display dialog with system list */ + $this->DivListConference->execute(); - /* Add entries */ - $divlist->AddEntry(array($a_field1,$a_field2,$a_field3,$a_field4,$a_field5)); + /* Add departments if subsearch is disabled */ + if(!$this->DivListConference->SubSearch){ + $this->DivListConference->AddDepartments($this->DivListConference->selectedBase,5); } - - /* Image shown in divlist */ - $userimg = "User"; - - /* Edit entry link*/ - $editlink = "%s"; - - /* Insert conferneces*/ - foreach($this->conferences as $conferencekey => $conference ){ - - if((isset($conference['goFonPIN'][0]))&&(($this->ui->dn==$conference['goFonConferenceOwner'][0])||($this->acl=="#all#"))){ - $pin = "PIN"; - }else{ - $pin = " "; - } - - if(isset($conference['telephoneNumber'][0])){ - $number = " - ".$conference['telephoneNumber'][0]; - }else{ - $number = "  - ?"; - } - - $ldap= $this->config->get_ldap_link(); - $ldap->cat($conference['goFonConferenceOwner'][0], array('cn')); - $data = $ldap->fetch(); - $cn = $data['cn'][0]; - - $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => "style='text-align:center;width:20px;'"); - - if(($this->acl=="#all#")||(($this->ui->dn==$conference['goFonConferenceOwner'][0])&&(chkacl($this->acl,"goFonConferenceOwner")==""))){ - $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$conference['cn'][0].$number), "attach" => "style=''"); - }else{ - $a_field2 = array("string"=>$conference['cn'][0].$number, "attach" => "style=''"); - } - $a_field3 = array("string"=> $cn, "attach" => "style='width:200px;'"); - $a_field4 = array("string"=> $pin, "attach" => "style='width:50px;'"); - - if(($this->ui->dn==$conference['goFonConferenceOwner'][0])&&(chkacl($this->acl,"goFonConferenceOwner")=="")){ - $a_field5 = array("string"=>preg_replace("/%KEY%/",$conferencekey,$actions), "attach" => "style='width:60px;border-right:0px;text-align:right;'"); - }elseif(chkacl($this->acl,"goFonConferenceOwner")==""){ - $a_field5 = array("string"=>preg_replace("/%KEY%/",$conferencekey,$actions2), "attach" => "style='width:52px;border-right:0px;text-align:right;'"); - }else{ - $a_field5 = array("string"=>" ", "attach" => "style='width:52px;border-right:0px;text-align:right;'"); - } - - $divlist->AddEntry(array($a_field1,$a_field2,$a_field3,$a_field4,$a_field5)); - } - - $smarty->assign("search_image", get_template_path('images/search.png')); - $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info.png')); - $smarty->assign("launchimage", get_template_path('images/launch.png')); - $smarty->assign("conferences", $divlist->DrawList()); - $smarty->assign("conferencehead", $listhead); - $smarty->assign("deplist", $this->config->idepartments); - $smarty->assign("apply", apply_filter()); - $smarty->assign("alphabet", generate_alphabet()); - $smarty->assign("hint", print_sizelimit_warning()); - - $display= $smarty->fetch(get_template_path('headpage.tpl', TRUE)); - return($display); + $this->reload(); + $this->DivListConference->setEntries($this->conferences); + return($this->DivListConference->Draw()); } /* Reload entries for divlist. - * First, reload all conferences for the current base, with the given regex - * Second, get all departments for the given base and regex - * Convert departments dn + * reload all conferences for the current base, with the given regex */ function reload() { - $conferencefilter = $_SESSION["conferencefilter"]; - $base = $_SESSION['CurrentMainBase']; - $regex = $conferencefilter['regex']; - - $this->confgerences= get_list("(&(|(cn=$regex)(description=$regex))(objectClass=goFonConference))", - $this->ui->subtreeACL, $base, array("*"), GL_SIZELIMIT); - $res3= get_list("(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))", $this->ui->subtreeACL, - $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT); - - $this->departments= array(); - - $tmp = array(); - foreach ($res3 as $value){ - $tmp[strtolower($value['dn']).$value['dn']]=$value; - } - ksort($tmp); - foreach($tmp as $value){ - if(isset($value["description"][0])){ - $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]"; - }else{ - $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0]; - } + $Base = $this->DivListConference->selectedBase; + $SubSearch = $this->DivListConference->SubSearch; + $Regex = $this->DivListConference->Regex; + $Flags = GL_SIZELIMIT ; + $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=goFonConference))"; + $Attrs = array("cn","goFonConferenceOwner","goFonPIN","telephoneNumber"); + + if($SubSearch){ + $Flags |= GL_SUBSEARCH; } + + $this->conferences= get_list($Filter, $this->ui->subtreeACL, $Base, $Attrs, $Flags); } function remove_from_parent() @@ -453,6 +306,11 @@ class phoneConferenceManagment extends plugin } + function save_object() + { + $this->DivListConference->save_object(); + } + function remove_lock() { if (isset($this->dn)){ diff --git a/plugins/gofon/conference/main.inc b/plugins/gofon/conference/main.inc index 04ab46f78..fd3ea7ef8 100644 --- a/plugins/gofon/conference/main.inc +++ b/plugins/gofon/conference/main.inc @@ -31,6 +31,7 @@ if ($remove_lock){ $_SESSION['conference']= new phoneConferenceManagment($config, $ui); } $conference= $_SESSION['conference']; + $conference->save_object(); $output= $conference->execute(); /* Page header*/ -- 2.30.2