diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc
index 2c909c6906a3eed17372c221a69577e24c180957..76d45fd382c22e02e2362893cf3f5db062cb9306 100644 (file)
var $renameTypeDialog = false;
var $renameOSDialog = false;
var $select_type ;
var $renameTypeDialog = false;
var $renameOSDialog = false;
var $select_type ;
+ var $view_logged = FALSE;
/* Not necessary, cause we use mysql databse */
var $objectclasses= array("whatever");
/* Used to remember if this was an account (simply: is this an edited entry) */
/* Not necessary, cause we use mysql databse */
var $objectclasses= array("whatever");
/* Used to remember if this was an account (simply: is this an edited entry) */
- var $initialy_was_account = false;
+ var $initially_was_account = false;
/* Remember current dialog */
var $edit_type = false;
/* Remember current dialog */
var $edit_type = false;
/* Contructor
Sets default values and checks if we already have an existing glpi account
*/
/* Contructor
Sets default values and checks if we already have an existing glpi account
*/
- function glpiAccount ($config, $dn= NULL)
+ function glpiAccount (&$config, $dn= NULL, $parent= NULL)
{
{
- plugin::plugin ($config, $dn);
+ plugin::plugin ($config, $dn, $parent);
$this->ui= get_userinfo();
/* Abort class construction, if no db is defined */
$this->ui= get_userinfo();
/* Abort class construction, if no db is defined */
/* set defaults */
$this->name = $this->dn;
$this->orig_dn = $this->dn;
/* set defaults */
$this->name = $this->dn;
$this->orig_dn = $this->dn;
- $this->initialy_was_account = $this->is_account;
-
-
+ $this->initially_was_account = $this->is_account;
}
function execute()
}
function execute()
/* Call parent execute */
plugin::execute();
/* Call parent execute */
plugin::execute();
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","all/".get_class($this),$this->dn);
+ }
+
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
"OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys",
"OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
$smarty->assign($attr,array());
"OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys",
"OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
$smarty->assign($attr,array());
- $smarty->assign($attr."ACL"," disabled ");
}
foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){
$smarty->assign($attr,"");
}
foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){
$smarty->assign($attr,"");
- $smarty->assign($attr."ACL"," disabled ");
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation) {
+ $smarty->assign($name."ACL",$this->getacl($name));
}
/* Check if there is a glpi database server defined
}
/* Check if there is a glpi database server defined
/* Add Device was requested, open new dialog
*/
/* Add Device was requested, open new dialog
*/
- if(isset($_POST['AddDevice'])){
+ if((isset($_POST['AddDevice'])) && ($this->acl_is_writeable("Devices"))){
$this->dialog =true;
$this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
}
/* Attachment pool was closed with use
*/
$this->dialog =true;
$this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
}
/* Attachment pool was closed with use
*/
- if(isset($_POST['UseAttachment'])){
+ if(isset($_POST['UseAttachment']) && ($this->acl_is_writeable("Attachments"))){
if(count($this->cur_dialog->check())){
foreach($this->cur_dialog->check() as $msg){
print_red($msg);
if(count($this->cur_dialog->check())){
foreach($this->cur_dialog->check() as $msg){
print_red($msg);
/* Open Attachment pool to add/edit Attachments
*/
/* Open Attachment pool to add/edit Attachments
*/
- if(isset($_POST['AddAttachment'])){
+ if(isset($_POST['AddAttachment']) && ($this->acl_is_writeable("Attachments"))){
$this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
$this->dialog = true;
}
$this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
$this->dialog = true;
}
*/
$once = true;
foreach($_POST as $name => $value){
*/
$once = true;
foreach($_POST as $name => $value){
- if((preg_match("/^delAttachment_/",$name))&&($once)){
+ if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
$once= false;
$name = preg_replace("/^delAttachment_/","",$name);
$entry = preg_replace("/_.*$/","",$name);
$once= false;
$name = preg_replace("/^delAttachment_/","",$name);
$entry = preg_replace("/_.*$/","",$name);
}
}
}
}
}
}
- if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments']))){
+ if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && ($this->acl_is_writeable("Attachments"))){
foreach($_POST['Attachments'] as $entry){
if(isset($this->usedAttachments[$entry])){
unset($this->usedAttachments[$entry]);
foreach($_POST['Attachments'] as $entry){
if(isset($this->usedAttachments[$entry])){
unset($this->usedAttachments[$entry]);
/* We have selected some devices and pressed use button
*/
/* We have selected some devices and pressed use button
*/
- if(isset($_POST['SelectDeviceSave'])){
+ if(isset($_POST['SelectDeviceSave']) && $this->acl_is_writeable("Devices")){
$this->cur_dialog->save_object();
$this->usedDevices= ($this->cur_dialog->getSelected());
$this->cur_dialog = false;
$this->cur_dialog->save_object();
$this->usedDevices= ($this->cur_dialog->getSelected());
$this->cur_dialog = false;
/* Aborted Device selction
*/
/* Aborted Device selction
*/
- if(isset($_POST['SelectDeviceCancel'])){
+ if(isset($_POST['SelectDeviceCancel']) && ($this->acl_is_writeable("Devices"))){
$this->dialog = false;
$this->cur_dialog = false;
$this->edit_type=false;
$this->dialog = false;
$this->cur_dialog = false;
$this->edit_type=false;
/* System type management
*/
/* System type management
*/
- if(isset($_POST['edit_type'])){
+ if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){
$this->dialog = true;
$this->edit_type=true;
}
/* This closes the system type editing dialog
*/
$this->dialog = true;
$this->edit_type=true;
}
/* This closes the system type editing dialog
*/
- if(isset($_POST['close_edit_type'])){
+ if(isset($_POST['close_edit_type']) && ($this->acl_is_writeable("type"))){
$this->edit_type=false;
$this->dialog = false;
}
$this->edit_type=false;
$this->dialog = false;
}
/* This appends a new system to our sytem types
*/
/* This appends a new system to our sytem types
*/
- if((isset($_POST['add_type']))&&(!empty($_POST['type_string']))){
+ if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
$attr = $this->handle->getSystemTypes();
if(in_array(trim($_POST['type_string']),$attr)){
print_red(_("Adding new sytem type failed, this system type name is already used.")) ;
$attr = $this->handle->getSystemTypes();
if(in_array(trim($_POST['type_string']),$attr)){
print_red(_("Adding new sytem type failed, this system type name is already used.")) ;
/* Remove selected type from our system types list
*/
/* Remove selected type from our system types list
*/
- if((isset($_POST['del_type']))&&(!empty($_POST['select_type']))){
+ if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
$tmp = $this->handle->is_systemTypeUsed($_POST['select_type']);
if(count($tmp)){
$names = "";
$tmp = $this->handle->is_systemTypeUsed($_POST['select_type']);
if(count($tmp)){
$names = "";
/* System os management
*/
/* System os management
*/
- if(isset($_POST['edit_os'])){
+ if(isset($_POST['edit_os']) && $this->acl_is_writeable("os")){
$this->dialog = true;
$this->edit_os=true;
}
$this->dialog = true;
$this->edit_os=true;
}
/* Add new os to the db
*/
/* Add new os to the db
*/
- if((isset($_POST['add_os']))&&(!empty($_POST['is_string']))){
+ if((isset($_POST['add_os']))&&(!empty($_POST['is_string'])) && $this->acl_is_writeable("os")){
$attr = $this->handle->getOSTypes();
if(in_array(trim($_POST['is_string']),$attr)){
print_red(_("Adding new operating system failed, specifed name is already used.")) ;
$attr = $this->handle->getOSTypes();
if(in_array(trim($_POST['is_string']),$attr)){
print_red(_("Adding new operating system failed, specifed name is already used.")) ;
/* Delete selected os from list and db
*/
/* Delete selected os from list and db
*/
- if((isset($_POST['del_os']))&&(!empty($_POST['select_os']))){
+ if((isset($_POST['del_os']))&&(!empty($_POST['select_os'])) && $this->acl_is_writeable("os")){
$tmp = $this->handle->is_osUsed($_POST['select_os']);
if(count($tmp)){
$tmp = $this->handle->is_osUsed($_POST['select_os']);
if(count($tmp)){
/* Rename selected os to given string
*/
/* Rename selected os to given string
*/
- if(isset($_POST['Rename_os_OK'])){
+ if(isset($_POST['Rename_os_OK']) && $this->acl_is_writeable("os")){
$attr = $this->handle->getOSTypes();
if(in_array(trim($_POST['string']),$attr)){
print_red(_("Updating operating system failed, specifed name is already used.")) ;
$attr = $this->handle->getOSTypes();
if(in_array(trim($_POST['string']),$attr)){
print_red(_("Updating operating system failed, specifed name is already used.")) ;
/* Show dialog to select a new contact person
* Select a contact person
*/
/* Show dialog to select a new contact person
* Select a contact person
*/
- if(isset($_POST['SelectContactPerson'])){
+ if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
$this->addUser = "contact";
$this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
$this->addUser = "contact";
$this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
+ $this->cur_dialog->set_acl_base($this->dn);
+
}
/* Open dialog which allows to edit the manufacturers
*/
}
/* Open dialog which allows to edit the manufacturers
*/
- if(isset($_POST['edit_manufacturer'])){
+ if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
$this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
$this->dialog = true;
}
$this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
$this->dialog = true;
}
/* Selecte technical responsible person
*/
/* Selecte technical responsible person
*/
- if(isset($_POST['SelectTechPerson'])){
+ if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
$this->addUser ="tech";
$this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
$this->addUser ="tech";
$this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
+ $this->cur_dialog->set_acl_base($this->dn);
}
/* Technical responsible person selected*/
}
/* Technical responsible person selected*/
- if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")){
+ if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")&&(strlen($_GET['id']) > 100)){
+ print_red(sprintf(_("Could not add the given user, the users dn is too long, only 100 characters are allowed here.")));
+
+ }elseif(isset($_GET['act'])&&($_GET['act']=="user_tech_num") && strlen($_GET['id'])){
+
/* Get posted id */
$id = base64_decode($_GET['id']);
/* Get posted id */
$id = base64_decode($_GET['id']);
$smarty->assign($attr,array());
}
$smarty->assign($attr,array());
}
- foreach($this->attributes as $attr){
- $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
- }
-
/* Assign some vars to smarty
*/
foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){
$smarty->assign($attr,"");
/* Assign some vars to smarty
*/
foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){
$smarty->assign($attr,"");
- $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
}
/* Do we need to flip is_account state? */
}
/* Do we need to flip is_account state? */
- if (isset($_POST['modify_state'])){
- $this->is_account= !$this->is_account;
+ if(isset($_POST['modify_state'])){
+ if($this->is_account && $this->acl_is_removeable()){
+ $this->is_account= FALSE;
+ }elseif(!$this->is_account && $this->acl_is_createable()){
+ $this->is_account= TRUE;
+ }
}
/* Show tab dialog headers */
if ($this->is_account){
}
/* Show tab dialog headers */
if ($this->is_account){
- $display= $this->show_header(_("Remove inventory"),
+ $display= $this->show_disable_header(_("Remove inventory"),
_("This device has inventory informations enabled. You can disable them by clicking below."));
} else {
_("This device has inventory informations enabled. You can disable them by clicking below."));
} else {
- $display= $this->show_header(_("Add inventory"),
+ $display= $this->show_enable_header(_("Add inventory"),
_("This device has inventory informations disabled. You can enable them by clicking below."));
return ($display);
}
_("This device has inventory informations disabled. You can enable them by clicking below."));
return ($display);
}
- /* Assign ACLs to smarty*/
- foreach($this->attributes as $attr){
- $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
- }
-
/* Assign system types
*/
$smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
/* Assign system types
*/
$smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
function remove_from_parent()
{
function remove_from_parent()
{
- if(!$this->initialy_was_account){
+ /* Cancel if there's nothing to do here */
+ if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){
return;
}
if(function_exists("mysql_pconnect")){
$this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
return;
}
if(function_exists("mysql_pconnect")){
$this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
- if($this->initialy_was_account){
+ if($this->initially_was_account){
$this->handle->removeComputerInformations($this->dn);
$this->handle->removeComputerInformations($this->dn);
+ new log("remove","undefined/".get_class($this),$this->dn);
}
}else{
print_red(_("Can't remove glpi account, while mysql extension is missing."));
}
}else{
print_red(_("Can't remove glpi account, while mysql extension is missing."));
+ new log("remove","undefined/".get_class($this),$this->dn,array(),_("Can't remove glpi account, while mysql extension is missing."));
}
}
}
}
return ;
}
plugin::save_object();
return ;
}
plugin::save_object();
- foreach($this->attributes as $attrs){
- if(isset($_POST[$attrs])){
- $this->$attrs = stripslashes ($_POST[$attrs]);
- }
- }
}
}
return ($message);
}
return ($message);
}
+
/* Save to LDAP */
function save()
{
/* Save to LDAP */
function save()
{
$this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
/* check if we have to update, add */
$this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
/* check if we have to update, add */
- if($this->initialy_was_account&&$this->is_account){
+ if($this->initially_was_account&&$this->is_account){
$this->handle->updateComputerInformations($attrs,$this->orig_dn);
$this->handle->updateComputerInformations($attrs,$this->orig_dn);
+ new log("modify","undefined/".get_class($this),$this->dn);
}elseif($this->is_account){
$this->handle->addComputerInformations($attrs,$this->dn);
}elseif($this->is_account){
$this->handle->addComputerInformations($attrs,$this->dn);
+ new log("create","undefined/".get_class($this),$this->dn);
}
$tmp = $this->handle->getComputerInformations($this->dn);
$this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
}
}
}
$tmp = $this->handle->getComputerInformations($this->dn);
$this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
}
}
+
/* Return used attachments */
function getUsedAttachments($divlist = false)
{
/* Return used attachments */
function getUsedAttachments($divlist = false)
{
}
return($ret);
}
}
return($ret);
}
+
+ /* Return plugin informations for acl handling */
+ function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Glpi"),
+ "plDescription" => _("Inventory extension"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 20,
+ "plSection" => array("administration"),
+ "plCategory" => array("workstation","terminal","component","server","phone") ,
+ "plProvidedAcls"=> array(
+
+ "tech_num" => _("Technical responsible"),
+ "comments" => _("Comment"),
+ "os" => _("Operating system"),
+ "location" => _("Location"),
+ "contact_num" => _("Contact person"),
+ "model" => _("Model"),
+ "type" => _("Type"),
+ "FK_glpi_enterprise" => _("Manufacturer"),
+ "Attachments" => _("Attachments"),
+ "Devices" => _("Peripheral devices"))
+ ));
+ }
}
}