diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index 9cccd381a2afd013918ff2dcada07f989a971ad6..9d3c2cfe25ef6e524d4ccaacec09d0d064271f5e 100644 (file)
class printgeneric extends plugin
{
- /* CLI vars */
- var $cli_summary = "Manage terminal base objects";
- var $cli_description = "Some longer text\nfor help";
- var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* Generic terminal attributes */
var $interfaces = array();
var $ignore_account = FALSE;
var $description = "";
var $labeledURI = "";
var $gotoPrinterPPD = "";
+ var $initial_PPD = "";
var $orig_dn = "";
var $UserMember ="";
}
/* Update dn, to ensure storing as printer instead of WS / terminal */
- if($this->BelongsTo == "Terminal"){
+ if($this->BelongsTo == "Terminal" || $this->BelongsTo == "TerminalTemplate"){
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
- if($this->BelongsTo == "Workstation"){
+ if($this->BelongsTo == "Workstation" || $this->BelongsTo == "WorkstationTemplate"){
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
/* create dns object */
$this->netConfigDNS = new termDNS($this->config, $this->dn,$this->objectclasses);
+ $this->netConfigDNS->acl = $this->acl;
/* Set base */
if ($this->dn == "new"){
$this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
}
+ $this->initial_PPD = $this->gotoPrinterPPD;
+
/* Prepare different member types */
foreach(array("AddUser" =>"gotoUserPrinter",
"AddGroup" =>"gotoGroupPrinter",
function execute()
{
+ $this->netConfigDNS->acl = $this->acl;
+
/* Call parent execute */
plugin::execute();
*/
if($this->BelongsTo == "unknown"){
$display= $this->show_header(_("Add printer extension"),
- _("Could not intialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
+ _("Could not initialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
return($display);
}
$smarty->assign("StandAlone",false);
}
- /* Do we need to flip is_account state? */
+
if (isset($_POST['modify_state'])){
- $this->is_modified = true;
- $this->is_account= !$this->is_account;
+
+ /* Only change account state if allowed */
+ if($this->is_account && $this->acl == "#all#"){
+ $this->is_account= !$this->is_account;
+ $this->is_modified = true;
+ }elseif(!$this->is_account && chkacl($this->acl,"create") == "" && !((empty($this->cn)) && ($this->dn != "new"))){
+ $this->is_account= !$this->is_account;
+ $this->is_modified = true;
+ }
}
/* Do we represent a valid printer? */
/* Base select dialog */
$once = true;
foreach($_POST as $name => $value){
- if(preg_match("/^chooseBase/",$name) && $once){
+ if(preg_match("/^chooseBase/",$name) && $once && chkacl($this->acl,"base")){
$once = false;
$this->dialog = new baseSelectDialog($this->config);
$this->dialog->setCurrentBase($this->base);
$smarty->assign("baseACL", chkacl($this->acl,"base"));
- if(isset($_POST['AddUser'])){
+ if(isset($_POST['AddUser']) && chkacl($this->acl,"gotoUserPrinter") == ""){
$this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddUser");
}
- if(isset($_POST['AddGroup'])){
+ if(isset($_POST['AddGroup']) && chkacl($this->acl,"gotoGroupPrinter") == ""){
$this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddGroup");
}
- if(isset($_POST['AddAdminUser'])){
+ if(isset($_POST['AddAdminUser']) && chkacl($this->acl,"gotoUserAdminPrinter") == ""){
$this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminUser");
}
- if(isset($_POST['AddAdminGroup'])){
+ if(isset($_POST['AddAdminGroup']) && chkacl($this->acl,"gotoGroupAdminPrinter") == ""){
$this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminGroup");
}
/* Display ppd configure/select dialog */
- if(isset($_POST['EditDriver'])){
+ if(isset($_POST['EditDriver']) && chkacl($this->acl,"gotoPrinterPPD")==""){
if($this->PPDdialogToSave){
$this->dialog = $this->PPDdialogToSave;
}else{
$this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
+ $this->dialog->cn= $this->cn;
}
}
/* remove ppd */
- if(isset($_POST['RemoveDriver'])){
+ if(isset($_POST['RemoveDriver']) && chkacl($this->acl,"gotoPrinterPPD")==""){
$this->gotoPrinterPPD = array();
$this->PPDdialogToSave = NULL;
}
}
/* Member management, delete user / group / admin ..*/
- if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
+ if((isset($_POST['DelUser']))&&(isset($_POST['UserMember'])) && chkacl($this->acl,"gotoUserPrinter")==""){
foreach($_POST['UserMember'] as $mem){
$this->DelMember('AddUser',$mem);
}
}
- if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
+ if((isset($_POST['DelUser']))&&(isset($_POST['UserMember'])) && chkacl($this->acl,"gotoGroupPrinter")==""){
foreach($_POST['UserMember'] as $mem){
$this->DelMember('AddGroup',$mem);
}
}
- if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
+ if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember'])) && chkacl($this->acl,"gotoUserAdminPrinter")==""){
foreach($_POST['AdminMember'] as $mem){
$this->DelMember('AddAdminUser',$mem);
}
}
- if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
+ if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember'])) && chkacl($this->acl,"gotoGroupAdminPrinter")==""){
foreach($_POST['AdminMember'] as $mem){
$this->DelMember('AddAdminGroup',$mem);
}
$smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
}
}else{
- $smarty->assign("driverInfo", _("not defined"));
+ $smarty->assign("driverInfo", _("Not defined"));
}
}else{
- $smarty->assign("driverInfo",_("can't get ppd informations."));
+ $smarty->assign("driverInfo",_("Can't get ppd informations."));
}
/* Create user & admin user list */
$smarty->assign("AdminMembers" ,$adminlist);
$smarty->assign("AdminMemberKeys",array_flip($adminlist));
if($this->BelongsTo == "Printer"){
+ $this->netConfigDNS->cn= $this->cn;
$smarty->assign("netconfig", $this->netConfigDNS->execute());
+
+ /* Display sub dialog from network settings */
+ if($this->netConfigDNS->dialog){
+ $this->dialog = TRUE;
+ return($this->netConfigDNS->execute());
+ }else{
+ $this->dialog = FALSE;
+ }
} else {
$smarty->assign("netconfig", "");
}
+
return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE)));
}
function remove_from_parent()
{
+ $this->netConfigDNS->acl = $this->acl;
+
/* Only remove if there was initially an account */
if($this->initially_was_account){
$this->netConfigDNS->remove_from_parent();
$ldap->rmdir($this->dn);
show_ldap_error($ldap->get_error(), _("Removing printer failed"));
- $this->handle_post_events("remove");
+ $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
/* Delete references to object groups */
$ldap->cd ($this->config->current['BASE']);
unset($og->member[$this->dn]);
$og->save ();
}
+
+ /* Remove previously selected ppd file.*/
+ if(!empty($this->initial_PPD)){
+ $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD);
+ $tmp->removeModifiedPPD();
+ }
}
}
if($this->BelongsTo == "Printer"){
$ui= get_userinfo();
$acl= get_permissions ($dn, $ui->subtreeACL);
- $acl= get_module_permission($acl, "printer", $this->dn);
+ $acl= get_module_permission($acl, "printgeneric", $dn);
if (chkacl($acl, "create") != ""){
$message[]= _("You have no permissions to create a printer on this 'Base'.");
}
$ldap->ls("(cn=".$this->cn.")","ou=printers,ou=systems,".$this->base, array("cn"));
if ($ldap->count() != 0){
while ($attrs= $ldap->fetch()){
+ if(preg_match("/cn=dhcp,/",$attrs['dn'])){
+ continue;
+ }
if ($attrs['dn'] != $this->orig_dn){
$message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
break;
/* Save to LDAP */
function save()
{
+ $this->netConfigDNS->acl = $this->acl;
+
/* Update dn, to ensure storing as printer instead of WS / terminal
*/
if($this->BelongsTo == "Terminal"){
if($this->BelongsTo == "Workstation"){
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
- $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
- $this->netConfigDNS->macAddress = $mac;
+ $this->macAddress = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
}
if(!$this->is_account) return;
if($this->PPDdialogToSave){
$this->PPDdialogToSave->save_ppd();
}
+ if($this->orig_dn != $this->dn){
+ $this->PPDdialogToSave = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
+ $this->PPDdialogToSave->cn = $this->cn;
+ $this->PPDdialogToSave->generateProperties();
+ $this->PPDdialogToSave->update_ppd_url();
+ }
+
+ /* Remove previously selected ppd file.*/
+ if($this->initial_PPD != $this->gotoPrinterPPD){
+ if(!empty($this->initial_PPD)){
+ $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD);
+ $tmp->removeModifiedPPD();
+ }
+ }
+
+ if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
+ $method="https://";
+ }else{
+ $method="http://";
+ }
+
+ /* If no ppd is selected, remove this attribute */
+ if(!empty($this->gotoPrinterPPD)) {
+ $this->gotoPrinterPPD = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD);
+ }else{
+ $this->gotoPrinterPPD = array();
+ }
$dn= $this->dn;
plugin::save();
$this->attrs= $attrs;
}
- if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
- $method="https://";
- }else{
- $method="http://";
- }
-
- /* Only save ppd path, if the path is not empty (no ppd selected )*/
- if(count($this->gotoPrinterPPD)) {
- $this->attrs['gotoPrinterPPD'] = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD);
- }else{
- $this->attrs['gotoPrinterPPD'] = array();
- }
-
/* Append printer user
*/
$this->attrs['gotoUserPrinter']=array();
if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
$this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+ $this->attrs['gosaUnitTag'] = $this->gosaUnitTag;
}
if($this->orig_dn == 'new'){
}
}
+ /* Ensure to create a new object */
+ if(preg_match("/ou=incoming,/",$this->orig_dn)){
+ $this->orig_dn = "new";
+ }
+
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
if ($this->orig_dn == 'new'){
$ldap->cd($this->config->current['BASE']);
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
$ldap->cd($this->dn);
+
+ /* Remove empty values */
+ foreach($this->attrs as $name => $value){
+ if(empty($value)){
+ unset($this->attrs[$name]);
+ }
+ }
+
$ldap->add($this->attrs);
- $this->handle_post_events("add");
+ $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
} else {
if ($this->orig_dn != $this->dn){
$this->move($this->orig_dn, $this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
- $this->handle_post_events("modify");
+ $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
}
show_ldap_error($ldap->get_error(), _("Saving printer failed"));
-
- $this->netConfigDNS->cn = $this->cn;
- $this->netConfigDNS->dn = $this->dn;
- $this->netConfigDNS->save($this->dn);
-
- /* Optionally execute a command after we're done */
- $this->postcreate();
+ /* Only save dns stuff if we are a standalone printer */
+ if($this->BelongsTo == "Printer"){
+ $this->netConfigDNS->cn = $this->cn;
+ $this->netConfigDNS->dn = $this->dn;
+ $this->netConfigDNS->save($this->dn);
+ }
/* This is a multi object. Handle tagging here... */
$this->handle_object_tagging();