From: hickert Date: Mon, 8 Oct 2007 10:58:52 +0000 (+0000) Subject: Added Kiosk service X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4f19f48046a9ad47d473f5a71b3cc77539eef00c;p=gosa.git Added Kiosk service git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7453 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_goKioskService.inc b/plugins/admin/systems/class_goKioskService.inc new file mode 100644 index 000000000..0635192bb --- /dev/null +++ b/plugins/admin/systems/class_goKioskService.inc @@ -0,0 +1,214 @@ +DisplayName = _("Kiosk profile service"); + $this->baseDir = $this->config->search('environment', 'kioskpath',array('menu','tabs')); + + /* Load list of profiles and check if they still exists */ + if ($this->baseDir == ""){ + print_red(_("There is no KIOSKPATH defined in your gosa.conf. Can't manage kiosk profiles!")); + }else{ + $this->gotoKioskProfiles = array(); + if(isset($this->attrs['gotoKioskProfile']) && is_array($this->attrs['gotoKioskProfile'])){ + for($i = 0 ; $i < $this->attrs['gotoKioskProfile']['count']; $i ++){ + $url = $this->attrs['gotoKioskProfile'][$i]; + $name= preg_replace("/^.*\/kiosk\//","",$url); + + $this->gotoKioskProfiles[] = array('url' => $url , + 'name' => $name , + 'initial' =>TRUE, + 'exists' => file_exists($this->baseDir."/".$name)); + } + } + } + } + + + function execute() + { + /* log actions */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add new kiosk profile + * in profile directory ($this->baseDir); + */ + if((isset($_POST['profileAdd']))&&(isset($_FILES['newProfile']))){ + $file = $_FILES['newProfile']; + if(!file_exists($this->baseDir.$file['name'])){ + $tmp = array( + 'url' => "" , + 'name' => $file['name'] , + 'initial' => FALSE, + 'tmp_name'=> $file['tmp_name'], + 'content' => file_get_contents($file['tmp_name']), + 'exists' => TRUE); + $this->gotoKioskProfiles[] = $tmp; + } + } + + print_a($_POST); + + + $only_once = true; + foreach($_POST as $name => $value){ + + if((preg_match("/^delkiosk_/",$name))&&($only_once)){ + + /* Get id, name and path */ + $only_once = false; + $id = preg_replace("/^delkiosk_/","",$name); + $id = preg_replace("/_.*$/","",$id); + $name = $this->gotoKioskProfiles[$id]['name']; + $filename = $this->baseDir."/".$name; + + /* check if profile is still in use */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*".$name.")",array("cn","uid","gotoKioskProfile")); + $used_by = ""; + $cnt = 3; + while(($attrs = $ldap->fetch()) && ($cnt)){ + $cnt --; + $check = preg_replace("/^.*\//i","",$attrs['gotoKioskProfile'][0]); + if($check == $name){ + $used_by .= $attrs['cn'][0].", "; + } + } + $used_by = preg_replace("/, $/","",$used_by); + if(!empty($used_by)){ + print_red(sprintf(_("Can't remove kioks profile, it is still in use by the following objects '%s'."),$used_by)); + }else{ + if($this->gotoKioskProfiles[$id]['initial']){ + $res = @unlink($filename); + if(!$res){ + if(!is_writeable($filename)){ + print_red(sprintf(_("Can't delete '%s'. Error was: permission denied."), $filename)); + } + if(!file_exists($filename)){ + print_red(sprintf(_("Can't delete '%s'. Error was: file doesn't exist."), $filename)); + } + } + unset($this->gotoKioskProfiles[$id]); + } + } + } + } + + /* Display list of profiles */ + $divlist = new divSelectBox("KioskProfiles"); + $divlist -> SetHeight (300); + foreach($this->gotoKioskProfiles as $key => $val ){ + $divlist->AddEntry(array( + array("string"=>"".$val['name'].""), + array("string"=>"" , + "attach"=>" style='border-right: 0px;width:24px; text-align:center;' ") + )); + } + + /* Assign all existing profiles to smarty */ + $smarty->assign("divlist",$divlist->DrawList()); + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty->fetch(get_template_path("goKioskService.tpl",TRUE,dirname(__FILE__)))); + } + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Kiosk profile service"); + $fields['AllowEdit'] = TRUE; + $fields['AllowStart'] = false; + $fields['AllowStop'] = false; + $fields['AllowRestart'] = false; + return($fields); + } + + function check() + { + $message = plugin::check(); + return($message); + } + + function save() + { + goService::save(); + + /* Create server url */ + if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ + $method="https://".$this->cn."/kiosk/"; + }else{ + $method="http://".$this->cn."/kiosk/"; + } + + $this->attrs['gotoKioskProfile'] = array(); + foreach($this->gotoKioskProfiles as $profile){ + if(!$profile['initial']){ + + $contents = $profile['content']; + $path = $this->baseDir."/".$profile['name']; + $fp = @fopen($path,"w"); + if(!$fp){ + print_red(_("Can't save new kiosk profiles, possibly permission denied for folder")." : ",$path); + }else{ + fwrite($fp,$contents,strlen($contents)); + $this->attrs['gotoKioskProfile'][] = $method.$profile['name']; + } + @unlink($profile['tmp_name']); + }else{ + $this->attrs['gotoKioskProfile'][] = $method.$profile['name']; + } + } + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error(),_("Wohl kaum")); + } + + /* Return plugin informations for acl handling */ + function plInfo() + { + return (array( + "plShortName" => _("Kiosk"), + "plDescription" => _("Kiosk profile management")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 100, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array() + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/goKioskService.tpl b/plugins/admin/systems/goKioskService.tpl new file mode 100644 index 000000000..18d076d4e --- /dev/null +++ b/plugins/admin/systems/goKioskService.tpl @@ -0,0 +1,21 @@ +

 

+ + + +{$divlist} + + + +

 

+
+ +   + +
+ + +