diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index 0cf8e3872808342bfdf21011d3e8f8b691363b47..24fe12cf057acbee5ddc243475a043dc437aba20 100644 (file)
$this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
}
+ if(isset($this->gotoPrinterPPD)){
+ $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
+ }
/* In case of gotoWorkstation this tab is calles from workstation plugin
* in case of gotoTerminal it is called from a terminal tab
}else{
$this->type = "terminal";
$this->is_terminal = "true";
- $this->dn = preg_replace("/ou=terminal/","ou=printers",$this->dn);
+ $this->dn = preg_replace("/ou=terminals/","ou=printers",$this->dn);
}
}else{
/* Save dn for later references */
/* $this->members contains all members */
$this->member[$type]=array();
- unset($this->attrs[$attr]['count']);
+ if (isset($this->attrs[$attr]['count'])) {
+ unset($this->attrs[$attr]['count']);
+ }
if(isset($this->attrs[$attr])){
foreach($this->attrs[$attr] as $mem){
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
+ if(isset($this->parent->by_name['workgeneric'])){
+// echo "workstation";
+ if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+ $display= $this->show_header(_("Add printer extension"),
+ _("This is a workstation template, printer tab is disabled."),TRUE,TRUE);
+ $this->is_account= false;
+ return $display;
+ }
+ }elseif(isset($this->parent->by_name['termgeneric'])){
+ if($this->parent->by_object['termgeneric']->cn == "default"){
+ $display= $this->show_header(_("Add printer extension"),
+ _("This is a terminal template, printer tab is disabled."),TRUE,TRUE);
+ $this->is_account= false;
+ return $display;
+ }
+ }elseif(isset($this->parent->by_name['printgeneric'])){
+// echo "printer";
+ }
+
+
$smarty= get_smarty();
$display="";
/* Template management.
$this->dialog=NULL;
}
+
+
if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
if(isset($this->member['AddUser'][$_POST['UserMember']])){
unset($this->member['AddUser'][$_POST['UserMember']]);
}
if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
- if(isset($this->member['AddAdmingroup'][$_POST['AdminMember']])){
+ if(isset($this->member['AddAdminGroup'][$_POST['AdminMember']])){
unset($this->member['AddAdminGroup'][$_POST['AdminMember']]);
}
}
require_once ("class_ppdManager.inc");
- $ppdManager= new ppdManager('/var/spool/ppd/');
- if(!empty($this->gotoPrinterPPD)){
- $smarty->assign("driverInfo", $ppdManager->loadDescription($this->gotoPrinterPPD));
+
+ if((isset($_SESSION['config']->data['MAIN']['PPD_PATH']))&&(is_dir($_SESSION['config']->data['MAIN']['PPD_PATH']))){
+
+ $path = $_SESSION['config']->data['MAIN']['PPD_PATH'];
+ if(!preg_match("/\/$/",$path)){
+ $path = $path."/";
+ }
+
+ $ppdManager= new ppdManager($path);
+ if(!empty($this->gotoPrinterPPD)){
+ if((!file_exists($path.$this->gotoPrinterPPD))){
+ $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$this->gotoPrinterPPD))."</b>";
+ }else{
+ $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
+ }
+ }else{
+ $smarty->assign("driverInfo", _("not defined"));
+ }
}else{
- $smarty->assign("driverInfo", _("not defined"));
+ $smarty->assign("driverInfo",_("can't get ppd informations."));
}
+
$list=$this->generateList();
$userlist = array_merge($list['AddUser'],$list['AddGroup']);
$adminlist = array_merge($list['AddAdminUser'],$list['AddAdminGroup']);
function remove_from_parent()
{
- $this->dn= preg_replace('/ou=workstations,/', 'ou=printers,', $this->dn);
- $ldap= $this->config->get_ldap_link();
- $ldap->rmdir($this->dn);
- show_ldap_error($ldap->get_error());
- $this->handle_post_events("remove");
-
- /* Delete references to object groups */
- $ldap->cd ($this->config->current['BASE']);
- $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
- while ($ldap->fetch()){
- $og= new ogroup($this->config, $ldap->getDN());
- unset($og->member[$this->dn]);
- $og->save ();
+ if($this->initially_was_account){
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cat($this->dn);
+ if(count($ldap->fetch()) ){
+
+ $ldap->rmdir($this->dn);
+ show_ldap_error($ldap->get_error());
+ $this->handle_post_events("remove");
+
+ /* Delete references to object groups */
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
+ while ($ldap->fetch()){
+ $og= new ogroup($this->config, $ldap->getDN());
+ unset($og->member[$this->dn]);
+ $og->save ();
+ }
+ }
}
}
-
- /* Save data to object */
- function save_object()
+ /* Save data to object */
+ function save_object()
{
plugin::save_object();
function check()
{
$message= array();
+
+ if(isset($this->parent->by_name['workgeneric'])){
+ if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+ return $message;
+ }
+ }elseif(isset($this->parent->by_name['termgeneric'])){
+ if($this->parent->by_object['termgeneric']->cn == "default"){
+ return $message;
+ }
+ }
+
$this->dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base;
/* must: cn */
if (!$this->is_account){
return;
}
-
+ if(isset($this->parent->by_name['workgeneric'])){
+ if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+ return;
+ }
+ }elseif(isset($this->parent->by_name['termgeneric'])){
+ if($this->parent->by_object['termgeneric']->cn == "default"){
+ return;
+ }
+ }
+
if($this->PPDdialogToSave){
$this->PPDdialogToSave->save_ppd();
}
-
$dn= $this->dn;
plugin::save();
$ldap= $this->config->get_ldap_link();
$this->attrs= $attrs;
}
+ if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
+ $method="https://";
+ }else{
+ $method="http://";
+ }
+
+ if(!is_array($this->attrs['gotoPrinterPPD'])) {
+ $this->attrs['gotoPrinterPPD'] = $this->attrs['gotoPrinterPPD'];
+ $this->attrs['gotoPrinterPPD'] = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->attrs['gotoPrinterPPD']);
+ }
/* Append printer user
*/