diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc
index c86f52d00c80f2884b202355ff7b5f554dea0190..36597d19b987b4efde492f321f83129c39f044f8 100644 (file)
var $uid = "";
var $is_group = false;
+ var $view_logged = FALSE;
/* Attribute definition
*/
var $gotoKioskProfile = "none"; // The selected Kiosk Profile
var $gotoKioskProfiles = array();// All available Kiosk profiles
var $newKioskProfiles = array();
+ var $kioskProfileList = array(); // Displayed List of Profiles
/* Hotplug Devices */
var $gotoHotplugDevice = array(); // Selected hotplug
var $gotoHotplugDevices = array();// Already configured hotplug devices
+ var $NewAddedPrinters = array();
+ var $NewDeletedPrinters = array();
/* general settings */
// Sets the attributes which will kept on page reload, which will be saved, ...
var $CopyPasteVars = array("gotoHotplugDevices","newKioskProfiles","gotoAvailableShares","gotoShareSelections","gotoPrinterSel","gotoProfileFlagL","gotoXResolutions","gotoProfileFlagC","gotoProfileServers","useProfile","is_group","in_dialog","OrigCn");
- var $attributes = array("uid","gotoProfileServer","gotoProfileFlags",
+ var $attributes = array("uid","gotoProfileServer","gotoProfileFlags","gotoHotplugDevice",
"gotoXResolution","gotoProfileQuota",
"gotoLogonScripts","gotoLogonScript",
"gotoPrinter", "gosaDefaultPrinter",
var $OrigCn;
var $add_del_printer_member_was_called = false;
- function environment ($config, $dn= NULL)
+ function environment (&$config, $dn= NULL)
{
plugin::plugin ($config, $dn);
+ /* Setting uid to default */
+ if(isset($this->attrs['uid'][0])){
+ $this->uid = $this->attrs['uid'][0];
+ }
+
/* Check : Are we currently editing a group or user dialog */
if((isset($this->attrs['cn'][0]))&&(!isset($this->attrs['uid'][0]))){
$suffix="Group";
$this->useProfile = false;
}
- /* Set to group environment if we editing a group */
- if(!isset($this->parent)){
- $this->is_group = true;
- }
-
/* Set resolutions */
$this->gotoXResolutions = array("auto"=>_("auto"),
"640x480" => "640x480",
$this->gotoShareSelections= $config->getShareList(true);
$this->gotoAvailableShares= $config->getShareList(false);
+ $tmp = new kioskManagementDialog($this->config,$this->dn);
+ $list = $tmp->getKioskProfiles($this->newKioskProfiles);
+ $list['none']=_("None");
+ $this->kioskProfileList = array_reverse($list);
+ }
+
+
+ /* Detect type of edited object (user|group)*/
+ function detect_grouptype()
+ {
+ if((!isset($this->parent))&&(!$this->is_account)){
+ $this->is_group = false;
+ }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){
+ $this->is_group = true;
+ }else{
+ $this->is_group = false;
+ }
}
+
function execute()
{
/* Call parent execute */
plugin::execute();
+ /* Log view */
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ if(in_array("gosaAccount",$this->attrs['objectClass'])){
+ new log("view","users/".get_class($this),$this->dn);
+ }else{
+ new log("view","groups/".get_class($this),$this->dn);
+ }
+ }
+
+ /* Are we editing from MyAccount and not editing a user */
+ $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']);
+
+ /* Check profile server */
+ if($this->acl_is_writeable("gotoProfileServer",$WriteOnly)){
+ if(!empty($this->gotoProfileServer) && !isset($this->gotoProfileServers[$this->gotoProfileServer])){
+ if(count($this->gotoProfileServers)){
+
+ /* Get First Profile */
+ $new = key($this->gotoProfileServers);
+
+ /* Another profile server found */
+ print_red(sprintf(_("Your selected profile server '%s' is no longer available. Setting profile server to '%s'."),
+ $this->gotoProfileServer,$new));
+ }else{
+
+ /* No other profile servers found */
+ print_red(sprintf(_("Your selected profile server '%s' is no longer available. Profile server configuration is resetted."),
+ $this->gotoProfileServer));
+ $this->gotoProfileServer = "";
+ }
+ }
+ }
+
+ $this->detect_grouptype();
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
- /* Are we editing from MyAccount and not editing a user */
- $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']);
+ $smarty->assign("is_group",$this->is_group);
/* Prepare all variables for smarty */
foreach($this->attributes as $s_attr){
*/
}elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){
$smarty->assign("is_account","true");
- $this->is_group = true;
$this->uid = $this->cn;
$this->attrs['uid'] = $this->cn;
*/
$smarty->assign("is_account","true");
- $this->is_group = false;
-
/* Change state if needed */
if (isset($_POST['modify_state'])){
if(($this->acl_is_createable() && !$this->is_account) ||
}else{
$smarty->assign("useProfileCHK"," checked ");
}
-
-
+
+ $smarty->assign("gotoProfileServerWriteable", $this->acl_is_writeable("gotoProfileServer",$WriteOnly));
$smarty->assign("gotoProfileACL", $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly));
/* HANDLE Profile Settings here
$this->dialog->acl = $this->acl;
$this->is_dialog = true;
}
- $tmp = new kioskManagementDialog($this->config,$this->dn);
- $list = $tmp->getKioskProfiles($this->newKioskProfiles);
- $list['none']=_("None");
- $list = array_reverse($list);
- $smarty->assign("gotoKioskProfiles",$list);
- $smarty->assign("gotoKioskProfileKeys",array_flip($list));
+ $smarty->assign("gotoKioskProfiles",$this->kioskProfileList);
+ $smarty->assign("gotoKioskProfileKeys",array_flip($this->kioskProfileList));
/* Logonscript Management
* Get available LogonScripts (possibly grey out (or mark) these script that are defined for the group)
/* We assign a share to this user, if we don't know where to mount the share */
if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
print_red(_("You must specify a valid mount point."));
+ }elseif(preg_match('/ /', $_POST['gotoShareMountPoint'])){
+ print_red(_("Spaces are not allowed in the mount path!"));
}elseif(!(
preg_match("/^\//",$_POST['gotoShareMountPoint']) ||
preg_match("/^~/",$_POST['gotoShareMountPoint']) ||
}
$divlistShares = new divSelectBox("gotoShares");
$divlistShares->SetHeight(100);
- $tmp = $this->printOutAssignedShares();
+
+ $tmp = array();
+ if($this->acl_is_readable("gotoShares")){
+ $tmp = $this->printOutAssignedShares();
+ }
+
+
foreach($tmp as $key => $value){
$img = "";
}
/* We have to delete the selected hotplug from the list*/
- if((isset($_POST['gotoHotplugDeviceDel']))&&(isset($_POST['gotoHotplugDevice'])) && $this->acl_is_writeable("gotoHotplugDevice")){
+ if((isset($_POST['gotoHotplugDeviceDel']))&&(isset($_POST['gotoHotplugDevice_post'])) && $this->acl_is_writeable("gotoHotplugDevice")){
if($this->acl_is_writeable("gotoHotplugDevice")){
- foreach($_POST['gotoHotplugDevice'] as $name){
+ foreach($_POST['gotoHotplugDevice_post'] as $name){
unset($this->gotoHotplugDevices[$name]);
}
}
$tmp2= $this->dialog->getPrinter(true);
foreach($tmp as $pname){
- $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn']);
- if($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){
+ $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn'],"printer");
+ $printerObj->set_acl_base($tmp2[$pname]['dn']);
+
+ $type = false;
+
+ if($this->is_group){
+
+ if(isset($this->NewDeletedPrinters[$pname])){
+ $type = "AddGroup";
+ }elseif($printerObj->by_object['printgeneric']->AddMember("AddGroup",$this->dn)){
+ $type = "AddGroup";
+ }
+ }else{
+ if(isset($this->NewDeletedPrinters[$pname])){
+ $type = "AddUser";
+ }elseif($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){
+ $type = "AddUser";
+ }
+ }
+
+ if($type){
$this->gotoPrinter[$pname]=$tmp2[$pname];
$this->gotoPrinter[$pname]['mode']="user";
$this->add_del_printer_member_was_called = true;
+
+ $this->NewAddedPrinters[$pname] = $pname;
+ if(isset($this->NewDeletedPrinters[$pname])){
+ unset($this->NewDeletedPrinters[$pname]);
+ }
}
}
$printer = $_POST['gotoPrinterSel'];
foreach($printer as $pname){
- $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$this->gotoPrinter[$pname]['dn']);
- if($printerObj->by_object['printgeneric']->DelMember("AddUser",$this->dn)){
- unset($this->gotoPrinter[$pname]);
+ $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$this->gotoPrinter[$pname]['dn'],"printer");
+ $printerObj->set_acl_base($this->gotoPrinter[$pname]['dn']);
+
+ $type = false;
+ if($this->is_group){
+ if(isset($this->NewAddedPrinters[$pname])){
+ $type = "Group";
+ }elseif($printerObj->by_object['printgeneric']->DelMember("AddGroup",$this->cn)){
+ $type = "Group";
+ }
+ }else{
+ if(isset($this->NewAddedPrinters[$pname])){
+ $type = "User";
+ }elseif($printerObj->by_object['printgeneric']->DelMember("AddUser",$this->uid)){
+ $type = "User";
+ }
+ }
+ if($type){
$this->add_del_printer_member_was_called = true;
+ unset($this->gotoPrinter[$pname]);
+
+ $this->NewDeletedPrinters[$pname] = $pname;
+ if(isset($this->NewAddedPrinters[$pname])){
+ UNSET($this->NewAddedPrinters[$pname]);
+ }
}
}
}
if((isset($_POST['gotoPrinterEdit']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){
-
-
$printers = $_POST['gotoPrinterSel'];
-
+ $this->add_del_printer_member_was_called = true;
foreach($printers as $printer){
if($this->gotoPrinter[$printer]['mode']=="user"){
$this->gotoPrinter[$printer]['mode']="admin";
}
if((isset($_POST['gotoPrinterDefault']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){
- if ($this->gosaDefaultPrinter == $_POST['gotoPrinterSel'][0]){
- $this->gosaDefaultPrinter= "";
- } else {
- $this->gosaDefaultPrinter= $_POST['gotoPrinterSel'][0];
+ if($this->is_group){
+ print_red(_("GOsa default printer flag is not allowed within groups."));
+ }else{
+ if ($this->gosaDefaultPrinter == $_POST['gotoPrinterSel'][0]){
+ $this->gosaDefaultPrinter= "";
+ } else {
+ $this->gosaDefaultPrinter= $_POST['gotoPrinterSel'][0];
+ }
}
}
$smarty->assign("gotoPrinterKeys",array_flip($this->printOutPrinterDevices()));
/* General behavior */
- if($this->acl_is_writeable("gotoKioskProfile")){
if((isset($this->dialog))&&($this->dialog!=NULL)&&(!empty($this->dialog))){
$this->dialog->save_object();
$disp =$this->dialog->execute();
$this->gotoKioskProfile = 'none';
}
return($disp);
- }
}
/* Als smarty vars are set. Get smarty template and generate output */
$this->cleanup();
$ldap->modify ($this->attrs);
+ if($this->is_group){
+ new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/environment account with dn '%s' failed."),$this->dn));
/* Optionally execute a command after we're done */
- $this->handle_post_events("remove");
+ $this->handle_post_events("remove",array("uid" => $this->uid));
}
/* Get all Posted vars
* Setup checkboxes
*/
-
+ $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']);
if(isset($_POST['iamposted'])){
- if(isset($_POST['useProfile'])){
- $this->useProfile = true;
- }else{
- $this->useProfile = false;
+
+ $PACL = $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly);
+
+ if(preg_match("/w/",$PACL)){
+ if(isset($_POST['useProfile'])){
+ $this->useProfile = true;
+ }else{
+ $this->useProfile = false;
+ }
}
- if(isset($_POST['gotoProfileFlagC'])){
- $this->gotoProfileFlagC = $_POST['gotoProfileFlagC'];
- }else{
- $this->gotoProfileFlagC = false;
+
+ if($this->acl_is_writeable("gotoProfileFlagC")){
+ if(isset($_POST['gotoProfileFlagC'])){
+ $this->gotoProfileFlagC = $_POST['gotoProfileFlagC'];
+ }else{
+ $this->gotoProfileFlagC = false;
+ }
}
- if(isset($_POST['gotoProfileFlagL'])){
- $this->gotoProfileFlagL = $_POST['gotoProfileFlagL'];
- }else{
- $this->gotoProfileFlagL = false;
+
+ if($this->acl_is_writeable("gotoProfileFlagL")){
+ if(isset($_POST['gotoProfileFlagL'])){
+ $this->gotoProfileFlagL = $_POST['gotoProfileFlagL'];
+ }else{
+ $this->gotoProfileFlagL = false;
+ }
}
- $tmp= $this->gosaDefaultPrinter;
plugin::save_object();
foreach($this->attributes as $s_attr){
- if(in_array($s_attr,array("gotoShares","gotoHotplugDevices","gotoPrinter","gotoLogonScripts","uid"))) continue;
- if(isset($_POST[$s_attr])){
- $this->$s_attr = $_POST[$s_attr];
- }else{
- $this->$s_attr = false;
+ if((!isset($_POST[$s_attr])) ||
+ in_array($s_attr,array("gosaDefaultPrinter","gotoShares","gotoHotplugDevices","gotoPrinter","gotoLogonScripts","uid"))) continue;
+ if(!$this->acl_is_writeable($s_attr)){
+ continue;
+ }else{
+ if(isset($_POST[$s_attr])){
+ $this->$s_attr = $_POST[$s_attr];
+ }else{
+ $this->$s_attr = false;
+ }
}
}
- $this->gosaDefaultPrinter= $tmp;
}
}
/* Call common method to give check the hook */
$message= plugin::check();
+ $this->detect_grouptype();
+
if(preg_match("/[^0-9]/",$this->gotoProfileQuota)) {
$message[]=_("Please set a valid profile quota size.");
}
* 2.2 And each type has two modes, Admin (e.g. 'gotoUserAdminPrinter') and Normal
*/
+ $this->detect_grouptype();
+
if($this->add_del_printer_member_was_called){
$types = array( "gotoUserPrinter" => "AddUser",
}
/* Remove old entries */
- $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->uid."))",array("*"));
+ $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->$useVar."))",array("*"));
while($attr = $ldap->fetch()){
$printerObj = NULL;
- $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']);
- $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->uid);
+ $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer");
+ $printerObj->set_acl_base($attr['dn']);
+ $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->$useVar);
$printerObj->by_object['printgeneric']->save();
}
- $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->uid."))",array("*"));
+ $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->$useVar."))",array("*"));
while($attr = $ldap->fetch()){
$printerObj = NULL;
- $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']);
- $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->uid);
+ $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer");
+ $printerObj->set_acl_base($attr['dn']);
+ $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->$useVar);
$printerObj->by_object['printgeneric']->save();
}
foreach($this->gotoPrinter as $printer){
$printerObj = NULL;
- $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn']);
+ $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn'],"printer");
+ $printerObj->set_acl_base($printer['dn']);
+
if($printer['mode'] == "admin") {
$attribute = "goto".$s_suffix."AdminPrinter";
/* Prepare HotPlug devices */
$this->attrs['gotoHotplugDevice'] = array();
foreach($this->gotoHotplugDevices as $name => $device){
- $this->attrs['gotoHotplugDevice'][] = $device['name']."|".$device['description']."|".$device['id'].
- "|".$device['produkt']."|".$device['vendor'];
+
+ $tmp= $device['name']."|".$device['description']."|".$device['id'];
+ if (isset($device['produkt']) && isset($device['vendor'])){
+ $tmp.= "|".$device['produkt']."|".$device['vendor'];
+ }
+ $this->attrs['gotoHotplugDevice'][]= $tmp;
}
/* Prepare LogonScripts */
$this->attrs['gotoShare']=array();
foreach($this->gotoShares as $name => $share){
$mntp= $share['mountPoint'];
- if (!preg_match('=^[a-z0-9+_/%-]+$=i', $mntp)){
+ if (!preg_match('=^[a-z0-9+\._/%-]+$=i', $mntp)){
$mntp= base64_encode($mntp);
}
$this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$mntp."|".$share['PwdHash']."|".$share['Username'];
$ldap->cd($this->dn);
$this->cleanup();
$ldap->$mode($this->attrs);
+
+ $cat = "users";
+ if($this->is_group){
+ $cat = "groups";
+ }
+
+ /* Log last action */
+ if($this->initially_was_account){
+ new log("modify",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ new log("create",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/environment account with dn '%s' failed."),$this->dn));
- $this->handle_post_events($mode);
+ $this->handle_post_events($mode,array("uid"=>$this->uid));
}
/* Generate ListBox frindly output for the defined shares
function printOutPrinterDevices()
{
$a_return = array();
- if(is_array($this->gotoPrinter)){
- foreach($this->gotoPrinter as $printer){
- if($printer['mode'] == "admin"){
- $a_return[$printer['cn'][0]]= $printer['cn'][0]." - "._("Administrator");
- }else{
- $a_return[$printer['cn'][0]]= $printer['cn'][0];
- }
- if ($printer['cn'][0] == $this->gosaDefaultPrinter){
- $a_return[$printer['cn'][0]].=" - "._("Default printer");
+
+ if($this->acl_is_readable("gotoPrinter")){
+
+ if(is_array($this->gotoPrinter)){
+ foreach($this->gotoPrinter as $printer){
+ if($printer['mode'] == "admin"){
+ $a_return[$printer['cn'][0]]= $printer['cn'][0]." - "._("Administrator");
+ }else{
+ $a_return[$printer['cn'][0]]= $printer['cn'][0];
+ }
+ if ($printer['cn'][0] == $this->gosaDefaultPrinter){
+ $a_return[$printer['cn'][0]].=" - "._("Default printer");
+ }
}
}
}
return($a_return);
}
+
+ function saveCopyDialog()
+ {
+ if(isset($_POST['cn'])){
+ $this->cn = $_POST['cn'];
+ $this->uid = $_POST['cn'];
+ }
+ }
+
+
/* Generates ListBox frienly output of used logonscripts
*/
function printOutLogonScripts()
"plDescription" => _("Environment settings"), // Description
"plSelfModify" => TRUE,
"plDepends" => array("user", "posixAccount"), // This plugin depends on
- "plPriority" => 2, // Position in tabs
- "plSection" => "personal", // This belongs to personal
- "plCategory" => array("users", "groups"), // Add to following categories
+ "plPriority" => 3, // Position in tabs
+ "plSection" => array("personal" => _("My account")),
+ "plCategory" => array("users",
+ "groups"),
"plOptions" => array("resolution_hook" => array("type" => "string",
"description" => _("Command to extend the list of possible screen resolutions"))),