grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access this file directly");
}
/**
* CommonITILActor Class
**/
abstract class CommonITILActor extends CommonDBRelation {
// items_id_1, items_id_2, itemtype_1 and itemtype_2 are defined inside the inherited classes
static public $checkItem_2_Rights = self::DONT_CHECK_ITEM_RIGHTS;
static public $logs_for_item_2 = false;
public $auto_message_on_action = false;
// Requester
const REQUESTER = 1;
// Assign
const ASSIGN = 2;
// Observer
const OBSERVER = 3;
function getActorForeignKey() {
return static::$items_id_2;
}
static function getItilObjectForeignKey() {
return static::$items_id_1;
}
/**
* @since version 0.84
*
* @param $input array of data to be added
*
* @see CommonDBRelation::isAttach2Valid()
**/
function isAttach2Valid(Array &$input) {
// Anonymous user (only email) as requester or observer
if (isset($input['users_id']) && ($input['users_id'] == 0)
&& isset($input['alternative_email']) && !empty($input['alternative_email'])
&& isset($input['type']) && ($input['type'] != CommonITILActor::ASSIGN)) {
return true;
}
return false;
}
/**
* @param $items_id
**/
function getActors($items_id) {
global $DB;
$users = array();
$query = "SELECT `".$this->getTable()."`.*
FROM `".$this->getTable()."`
WHERE `".static::getItilObjectForeignKey()."` = '$items_id'";
foreach ($DB->request($query) as $data) {
$users[$data['type']][] = $data;
}
return $users;
}
/**
* @param $items_id
* @param $email
**/
function isAlternateEmailForITILObject($items_id, $email) {
global $DB;
$query = "SELECT `".$this->getTable()."`.*
FROM `".$this->getTable()."`
WHERE `".static::getItilObjectForeignKey()."` = '$items_id'
AND `alternative_email` = '$email'";
foreach ($DB->request($query) as $data) {
return true;
}
return false;
}
function canUpdateItem() {
return (parent::canUpdateItem()
|| (isset($this->fields['users_id'])
&& ($this->fields['users_id'] == Session::getLoginUserID())));
}
/**
* @since version 0.84
**/
function canDeleteItem() {
return (parent::canDeleteItem()
|| (isset($this->fields['users_id'])
&& ($this->fields['users_id'] == Session::getLoginUserID())));
}
/**
* Print the object user form for notification
*
* @param $ID integer ID of the item
* @param $options array
*
* @return Nothing (display)
**/
function showUserNotificationForm($ID, $options=array()) {
global $CFG_GLPI;
$this->check($ID, UPDATE);
if (!isset($this->fields['users_id'])) {
return false;
}
$item = new static::$itemtype_1();
echo "