diff --git a/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc
index 0b89ef20e84cd1b69bd5e2763d4488cdbdff5026..46aa1f1f8b472dda1934e45113d3b409b57a2fcb 100644 (file)
var $gotoPrinterPPD = "";
var $initial_PPD = "";
var $orig_dn = "";
+ var $orig_cn = "";
+ var $orig_base = "";
var $UserMember ="";
var $UserMembers =array();
/* attribute list for save action */
var $attributes = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress",
- "gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter","gotoGroupPrinter");
+ "gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter","gotoGroupPrinter","gosaUnitTag");
var $objectclasses = array("top", "gotoPrinter");
var $view_logged = FALSE;
var $parent;
}
if(!isset($this->config->idepartments[$this->base])){
- print_red(_("Can't extract a valid base out of object dn, setting base to '%s'."),session::get('CurrentMainBase'));
+ msg_dialog::display(_("Internal error"), sprintf(_("Cannot determine a valid department for this object. Setting base to '%s'!"), session::get('CurrentMainBase')) , WARNING_DIALOG);
$this->base = session::get('CurrentMainBase');
}
}
/* $this->members contains all members */
$this->member[$type]=array();
- if (isset($this->attrs[$attr]['count'])) {
- unset($this->attrs[$attr]['count']);
- }
-
if(isset($this->attrs[$attr])){
- foreach($this->attrs[$attr] as $mem){
+ $ldap->cd($this->config->current['BASE']) ;
+ for($i = 0 ; $i < $this->attrs[$attr]['count']; $i++){
+
+ $mem = $this->attrs[$attr][$i];
if(preg_match("/Group/",$type)){
- $ldap->search("(&(objectClass=posixGroup)(cn=".$mem."))",array("cn","description"));
+ $ldap->search("(&(|(objectClass=posixGroup)(objectClass=gosaGroupOfNames))(cn=".$mem."))",array("cn","description"));
if($ldap->count()){
$entry = $ldap->fetch();
$this->member[$type][$entry['cn'][0]]=$entry;
}
}
}
+ $this->orig_cn = $this->cn;
+ $this->orig_base = $this->base;
}
function set_acl_base($base)
/* Do we represent a valid printer? */
if (!$this->is_account && $this->parent === NULL){
- $display= "<img alt=\"\" src=\"images/stop.png\" align=middle> <b>".
- _("This 'dn' has no printer features.")."</b>";
+ $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle> <b>".
+ msgPool::noValidExtension(_("printer"))."</b>";
return($display);
}
/* If this is a WS / Terminal depending printer, display account state button */
if(!preg_match("/^Printer$/i",$this->BelongsTo)){
- if((empty($this->cn)) && ($this->dn != "new")){
+ if($this->cn == "" && ($this->dn != "new")){
$display= $this->show_enable_header(_("Add printer extension"),
- _("This object has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE);
+ msgPool::featuresDisabled(_("printer"))._("You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template."),TRUE,TRUE);
$this->is_account= false;
return $display;
}
if (($this->is_account)){
if(preg_match("/^Workstation$/i",$this->BelongsTo)){
$display= $this->show_disable_header(_("Remove printer extension"),
- _("This workstation has printer extension enabled.You can disable it by clicking below."));
+ msgPool::featuresEnabled(_("printer")));
}elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){
$display= $this->show_disable_header(_("Remove printer extension"),
- _("This terminal has printer extension enabled. You can disable it by clicking below."));
+ msgPool::featuresDisabled(_("printer")));
}
}else{
if(preg_match("/^Workstation$/i",$this->BelongsTo)){
$display= $this->show_disable_header(_("Add printer extension"),
- _("This workstation has printer extension disabled. You can enable it by clicking below."));
+ msgPool::featuresEnabled(_("printer")));
}elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){
$display= $this->show_enable_header(_("Add printer extension"),
- _("This terminal has printer extension disabled. You can enable it by clicking below."));
+ msgPool::featuresDisabled(_("printer")));
}
return ($display);
}
$this->dialog->save_object();
if(count($this->dialog->check())){
foreach($this->dialog->check() as $msg){
- print_red($msg);
+ msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
}
}else{
$this->gotoPrinterPPD = array();
$this->dialog->save_object();
if(count($this->dialog->check())){
foreach($this->dialog->check() as $msg){
- print_red($msg);
+ msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
}
}else{
$data= $new = $this->dialog->save();
/* Parse selected ppd file */
$config = session::get('config');
- if((isset($config->data['MAIN']['PPD_PATH']))&&(is_dir($config->data['MAIN']['PPD_PATH']))){
-
- $path = $config->data['MAIN']['PPD_PATH'];
+ if ($config->get_cfg_value("ppdPath") != ""){
+ $path = $config->get_cfg_value("ppdPath");
if(!preg_match("/\/$/",$path)){
$path = $path."/";
}
if(!preg_match("/Printer/i",$this->BelongsTo)){
if(preg_match("/Terminal/i",$this->BelongsTo)){
- $smarty->assign("desc" ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
+ $smarty->assign("desc" ,sprintf(_("This printer belongs to %s. You can't rename this printer."),_("terminal"),"<b>".$this->cn."</b>"));
}else{
- $smarty->assign("desc" ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
+ $smarty->assign("desc" ,sprintf(_("This printer belongs to %s. You can't rename this printer."),_("workstation"),"<b>".$this->cn."</b>"));
}
$smarty->assign("cnACL" , $this->getacl("cn",true));
}else{
$ldap= $this->config->get_ldap_link();
$ldap->cat($this->dn, array('dn',"objectClass"));
if(!$ldap->count()){
- print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss.");
+ msg_dialog::display(_("Error"), _("Object is no printer!"), ERROR_DIALOG);
return;
}
/* Check if obejct is a printer */
$CheckPrinter = $ldap->fetch();
if(!in_array("gotoPrinter",$CheckPrinter['objectClass'])){
- print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss.");
+ msg_dialog::display(_("Error"), _("Object is no printer!"), ERROR_DIALOG);
return;
}
$dn= "cn=".$this->cn.get_ou('printerou').",".$this->base;
/* must: cn */
- if(($this->BelongsTo == "Printer") && (empty($this->cn))){
- $message[]= _("The required field 'Printer name' is not set.");
+ if(($this->BelongsTo == "Printer") && $this->cn == ""){
+ $message[]= msgPool::required(_("Name"));
}
/* must: cn */
if(($this->BelongsTo == "Printer") && !tests::is_dns_name($this->cn)){
- $message[]= _("Invalid character in printer name.");
+ $message[]= msgPool::invalid(_("Name"));
}
/* must: labeledURI */
if(empty($this->labeledURI)){
- $message[]= "The required field 'Printer URL' is not set.";
+ $message[]= msgPool::required(_("Printer URL"));
}
/* Check if there is already an entry with this cn*/
continue;
}
if ($attrs['dn'] != $this->orig_dn){
- $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
+ $message[]= msgPool::duplicated(_("Name"));
break;
}
}
}
}
+ /* Check if we are allowed to create or move this object
+ */
+ if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+ $message[] = msgPool::permCreate();
+ }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+ $message[] = msgPool::permMove();
+ }
+
return ($message);
}
if($this->parent->by_object['workgeneric']->cn == "wdefault"){
return;
}
+
+ /* Adapt IP & mac from parent object */
+ $this->netConfigDNS->ipHostNumber = $this->parent->by_object['workgeneric']->netConfigDNS->ipHostNumber;
+ $this->netConfigDNS->macAddress = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
+
}elseif(isset($this->parent->by_object['termgeneric'])){
if($this->parent->by_object['termgeneric']->cn == "default"){
return;
}
+
+ /* Adapt IP & mac from parent object */
+ $this->netConfigDNS->ipHostNumber = $this->parent->by_object['termgeneric']->netConfigDNS->ipHostNumber;
+ $this->netConfigDNS->macAddress = $this->parent->by_object['termgeneric']->netConfigDNS->macAddress;
}
/* If type is still unknown, the initialisation of this printer failed, abort. */
}else{
$method="http://";
}
+
+ /* Get servername */
+ $server = $_SERVER['SERVER_NAME'];
+ if(tests::is_ip($server)){
+ $server_name = gethostbyaddr($server);
+ }else{
+ $server_name = gethostbyaddr(gethostbyname($server));
+ }
/* If no ppd is selected, remove this attribute */
if(!empty($this->gotoPrinterPPD) && $this->initially_was_account) {
- $this->gotoPrinterPPD = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD);
+ $this->gotoPrinterPPD = $method.str_replace("//","/",$server_name."/ppd/".$this->gotoPrinterPPD);
}else{
$this->gotoPrinterPPD = array();
}
$dn= $this->dn;
- plugin::save();
- $ldap= $this->config->get_ldap_link();
/* reduce objectClasses to minimun */
$this->attrs['objectClass']= $this->objectclasses;
+ plugin::save();
+ $ldap= $this->config->get_ldap_link();
+
/* Remove all empty values */
if ($this->orig_dn == 'new'){
$attrs= array();
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
}
- if(preg_match("/printer/i",$this->BelongsTo)){
+ #if(preg_match("/printer/i",$this->BelongsTo)){
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->dn = $this->dn;
$this->netConfigDNS->save();
- }
+ #}
}
function generateList(){
}
if(!$this->acl_is_writeable("gotoUserPrinter")){
- print_red(sprintf(_("You are not allowed to remove the given object '%s' from the list of members of printer '%s'."),$id,$this->dn));
+ msg_dialog::display(_("Permission error"), msgPool::permDelete(_("printer user"), $id), INFO_DIALOG);
return(FALSE);
}
{
$types = array("AddUser","AddGroup","AddAdminUser","AddAdminGroup");
if(!in_array_ics($type, $types)){
- print_red(sprintf(_("Illegal printer type while adding '%s' to the list of '%s' printers,"),$dn,$type));
+ msg_dialog::display(_("Internal error"), sprintf(_("Illegal member type '%s'!"), $type), ERROR_DIALOG);
return(FALSE);
}
if(!$this->acl_is_writeable("gotoUserPrinter")){
- print_red(sprintf(_("You are not allowed to add the given object '%s' to the list of members of '%s'."),$dn,$this->dn));
+ msg_dialog::display(_("Permission error"), msgPool::permModify(_("printer user"), $this->dn), INFO_DIALOG);
return(FALSE);
}
}
if(isset( $this->member[$ctype][$name])){
- print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0]));
+ msg_dialog::display(_("Error"), sprintf(_("'%s' is already used!"), $attrs[$var][0]), ERROR_DIALOG);
return(FALSE);
}
}
print_a($attrs);
}
}else{
- print_red(sprintf(_("Can't add '%s' to list of members, it is not reachable."),$dn));
+ msg_dialog::display(_("Error"), sprintf(_("'%s' does not exist!"), $dn), ERROR_DIALOG);
return(FALSE);
}
return(TRUE);