Commit f74277f0 authored by moyooo's avatar moyooo

prepare for #3767 : move Actor types to correct class : CommonITILObject -> CommonITILActor

parent 21c51107
......@@ -60,5 +60,5 @@ if (isset($_POST['_users_id_requester_notif']) && !empty($_POST['_users_id_reque
}
$ticket = new Ticket();
$ticket->showActorAddFormOnCreate(Ticket::REQUESTER, $_POST);
$ticket->showActorAddFormOnCreate(Ticket_User::REQUESTER, $_POST);
?>
\ No newline at end of file
......@@ -84,9 +84,9 @@ class Change extends CommonITILObject {
return (self::isAllowedStatus($this->fields['status'], 'solved')
&& (Session::haveRight("edit_all_change", "1")
|| (Session::haveRight('show_my_change', 1)
&& ($this->isUser(parent::ASSIGN, Session::getLoginUserID())
&& ($this->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parent::ASSIGN, $_SESSION["glpigroups"]))))));
&& $this->haveAGroup(CommonITILActor::ASSIGN, $_SESSION["glpigroups"]))))));
}
......@@ -113,14 +113,14 @@ class Change extends CommonITILObject {
}
return (Session::haveRight('edit_all_change', 1)
|| (Session::haveRight('show_my_change', 1)
&& ($this->isUser(parent::REQUESTER, Session::getLoginUserID())
|| $this->isUser(parent::OBSERVER, Session::getLoginUserID())
&& ($this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID())
|| $this->isUser(CommonITILActor::OBSERVER, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& ($this->haveAGroup(parent::REQUESTER, $_SESSION["glpigroups"])
|| $this->haveAGroup(parent::OBSERVER, $_SESSION["glpigroups"])))
|| ($this->isUser(parent::ASSIGN, Session::getLoginUserID())
&& ($this->haveAGroup(CommonITILActor::REQUESTER, $_SESSION["glpigroups"])
|| $this->haveAGroup(CommonITILActor::OBSERVER, $_SESSION["glpigroups"])))
|| ($this->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parent::ASSIGN, $_SESSION["glpigroups"]))))));
&& $this->haveAGroup(CommonITILActor::ASSIGN, $_SESSION["glpigroups"]))))));
}
......@@ -132,9 +132,9 @@ class Change extends CommonITILObject {
function canApprove() {
return (($this->fields["users_id_recipient"] === Session::getLoginUserID())
|| $this->isUser(parent::REQUESTER, Session::getLoginUserID())
|| $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parent::REQUESTER, $_SESSION["glpigroups"])));
&& $this->haveAGroup(CommonITILActor::REQUESTER, $_SESSION["glpigroups"])));
}
......
......@@ -104,9 +104,9 @@ class ChangeTask extends CommonITILTask {
if ($change->getFromDB($this->fields['changes_id'])) {
return (Session::haveRight("edit_all_change", "1")
|| (Session::haveRight("show_my_change", "1")
&& ($change->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
&& ($change->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $change->haveAGroup(CommonITILObject::ASSIGN,
&& $change->haveAGroup(CommonITILActor::ASSIGN,
$_SESSION['glpigroups'])))));
}
return false;
......
......@@ -44,6 +44,12 @@ abstract class CommonITILActor extends CommonDBRelation {
var $no_form_page = true;
// Requester
const REQUESTER = 1;
// Assign
const ASSIGN = 2;
// Observer
const OBSERVER = 3;
function getActorForeignKey() {
return static::$items_id_2;
......@@ -70,7 +76,7 @@ abstract class CommonITILActor extends CommonDBRelation {
&& isset($input['alternative_email'])
&& !empty($input['alternative_email'])
&& isset($input['type'])
&& ($input['type'] != CommonITILObject::ASSIGN)) {
&& ($input['type'] != CommonITILActor::ASSIGN)) {
return false;
}
return true;
......@@ -236,9 +242,9 @@ abstract class CommonITILActor extends CommonDBRelation {
$item = new static::$itemtype_1();
if ($item->getFromDB($this->fields[static::getItilObjectForeignKey()])) {
if (($item->countSuppliers(CommonITILObject::ASSIGN) == 0)
&& ($item->countUsers(CommonITILObject::ASSIGN) == 0)
&& ($item->countGroups(CommonITILObject::ASSIGN) == 0)
if (($item->countSuppliers(CommonITILActor::ASSIGN) == 0)
&& ($item->countUsers(CommonITILActor::ASSIGN) == 0)
&& ($item->countGroups(CommonITILActor::ASSIGN) == 0)
&& ($item->fields['status'] != 'closed')
&& ($item->fields['status'] != 'solved')) {
......@@ -266,7 +272,7 @@ abstract class CommonITILActor extends CommonDBRelation {
$item = new static::$itemtype_1();
$no_stat_computation = true;
if ($this->input['type']==CommonITILObject::ASSIGN) {
if ($this->input['type']==CommonITILActor::ASSIGN) {
$no_stat_computation = false;
}
$item->updateDateMod($this->fields[static::getItilObjectForeignKey()], $no_stat_computation);
......
This diff is collapsed.
......@@ -166,7 +166,7 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
* Get the email of the item's user : Overloaded manual address used
**/
function getItemAuthorAddress() {
$this->getLinkedUserByType(CommonITILObject::REQUESTER);
$this->getLinkedUserByType(CommonITILActor::REQUESTER);
}
......@@ -174,7 +174,7 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
global $CFG_GLPI;
if (isset($this->options['_old_user'])
&& ($this->options['_old_user']['type'] == CommonITILObject::ASSIGN)
&& ($this->options['_old_user']['type'] == CommonITILActor::ASSIGN)
&& $this->options['_old_user']['use_notification']) {
$user = new User();
......@@ -219,7 +219,7 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
global $DB;
if (!$sendprivate
&& $this->countSuppliers(CommonITILObject::ASSIGN)) {
&& $this->countSuppliers(CommonITILActor::ASSIGN)) {
$supplierlinktable = getTableForItemType($this->obj->supplierlinkclass);
$fkfield = $this->obj->getForeignKeyField();
......@@ -431,12 +431,12 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
switch ($data['items_id']) {
case Notification::ASSIGN_TECH :
$this->getLinkedUserByType(CommonITILObject::ASSIGN);
$this->getLinkedUserByType(CommonITILActor::ASSIGN);
break;
//Send to the supervisor of group in charge of the ITIL object
case Notification::SUPERVISOR_ASSIGN_GROUP :
$this->getLinkedGroupSupervisorByType(CommonITILObject::ASSIGN);
$this->getLinkedGroupSupervisorByType(CommonITILActor::ASSIGN);
break;
//Send to the user who's got the issue
......@@ -446,7 +446,7 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
//Send to the supervisor of the requester's group
case Notification::SUPERVISOR_REQUESTER_GROUP :
$this->getLinkedGroupSupervisorByType(CommonITILObject::REQUESTER);
$this->getLinkedGroupSupervisorByType(CommonITILActor::REQUESTER);
break;
//Send to the technician previously in charge of the ITIL object (before reassignation)
......@@ -460,11 +460,11 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
break;
case Notification::REQUESTER_GROUP :
$this->getLinkedGroupByType(CommonITILObject::REQUESTER);
$this->getLinkedGroupByType(CommonITILActor::REQUESTER);
break;
case Notification::ASSIGN_GROUP :
$this->getLinkedGroupByType(CommonITILObject::ASSIGN);
$this->getLinkedGroupByType(CommonITILActor::ASSIGN);
break;
//Send to the ITIL object validation approver
......@@ -494,17 +494,17 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
//Notification to the ITIL object's observer group
case Notification::OBSERVER_GROUP :
$this->getLinkedGroupByType(CommonITILObject::OBSERVER);
$this->getLinkedGroupByType(CommonITILActor::OBSERVER);
break;
//Notification to the ITIL object's observer user
case Notification::OBSERVER :
$this->getLinkedUserByType(CommonITILObject::OBSERVER);
$this->getLinkedUserByType(CommonITILActor::OBSERVER);
break;
//Notification to the supervisor of the ITIL object's observer group
case Notification::SUPERVISOR_OBSERVER_GROUP :
$this->getLinkedGroupSupervisorByType(CommonITILObject::OBSERVER);
$this->getLinkedGroupSupervisorByType(CommonITILActor::OBSERVER);
break;
}
}
......@@ -619,9 +619,9 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
}
$datas["##$objettype.authors##"] = '';
if ($item->countUsers(CommonITILObject::REQUESTER)) {
if ($item->countUsers(CommonITILActor::REQUESTER)) {
$users = array();
foreach ($item->getUsers(CommonITILObject::REQUESTER) as $tmpusr) {
foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
$uid = $tmpusr['users_id'];
$user_tmp = new User();
if ($uid
......@@ -666,9 +666,9 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
}
$datas["##$objettype.assigntousers##"] = '';
if ($item->countUsers(CommonITILObject::ASSIGN)) {
if ($item->countUsers(CommonITILActor::ASSIGN)) {
$users = array();
foreach ($item->getUsers(CommonITILObject::ASSIGN) as $tmp) {
foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
$uid = $tmp['users_id'];
$user_tmp = new User();
if ($user_tmp->getFromDB($uid)) {
......@@ -680,9 +680,9 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
$datas["##$objettype.assigntosupplier##"] = '';
if ($item->countSuppliers(CommonITILObject::ASSIGN)) {
if ($item->countSuppliers(CommonITILActor::ASSIGN)) {
$suppliers = array();
foreach ($item->getSuppliers(CommonITILObject::ASSIGN) as $tmp) {
foreach ($item->getSuppliers(CommonITILActor::ASSIGN) as $tmp) {
$uid = $tmp['suppliers_id'];
$supplier_tmp = new Supplier();
if ($supplier_tmp->getFromDB($uid)) {
......@@ -693,9 +693,9 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
}
$datas["##$objettype.groups##"] = '';
if ($item->countGroups(CommonITILObject::REQUESTER)) {
if ($item->countGroups(CommonITILActor::REQUESTER)) {
$groups = array();
foreach ($item->getGroups(CommonITILObject::REQUESTER) as $tmp) {
foreach ($item->getGroups(CommonITILActor::REQUESTER) as $tmp) {
$gid = $tmp['groups_id'];
$groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
}
......@@ -703,9 +703,9 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
}
$datas["##$objettype.observergroups##"] = '';
if ($item->countGroups(CommonITILObject::OBSERVER)) {
if ($item->countGroups(CommonITILActor::OBSERVER)) {
$groups = array();
foreach ($item->getGroups(CommonITILObject::OBSERVER) as $tmp) {
foreach ($item->getGroups(CommonITILActor::OBSERVER) as $tmp) {
$gid = $tmp['groups_id'];
$groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
}
......@@ -713,9 +713,9 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
}
$datas["##$objettype.observerusers##"] = '';
if ($item->countUsers(CommonITILObject::OBSERVER)) {
if ($item->countUsers(CommonITILActor::OBSERVER)) {
$users = array();
foreach ($item->getUsers(CommonITILObject::OBSERVER) as $tmp) {
foreach ($item->getUsers(CommonITILActor::OBSERVER) as $tmp) {
$uid = $tmp['users_id'];
$user_tmp = new User();
if ($uid
......@@ -729,9 +729,9 @@ abstract class NotificationTargetCommonITILObject extends NotificationTarget {
}
$datas["##$objettype.assigntogroups##"] = '';
if ($item->countGroups(CommonITILObject::ASSIGN)) {
if ($item->countGroups(CommonITILActor::ASSIGN)) {
$groups = array();
foreach ($item->getGroups(CommonITILObject::ASSIGN) as $tmp) {
foreach ($item->getGroups(CommonITILActor::ASSIGN) as $tmp) {
$gid = $tmp['groups_id'];
$groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
}
......
This diff is collapsed.
......@@ -100,9 +100,9 @@ class ProblemTask extends CommonITILTask {
return (Session::haveRight("edit_all_problem","1")
|| (Session::haveRight("show_my_problem","1")
&& ($ticket->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
&& ($ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $ticket->haveAGroup(CommonITILObject::ASSIGN,
&& $ticket->haveAGroup(CommonITILActor::ASSIGN,
$_SESSION['glpigroups'])))));
}
......
......@@ -737,7 +737,7 @@ class Stat {
case "technicien" :
$LEFTJOIN = $LEFTJOINUSER;
$WHERE .= " AND (`$userlinktable`.`users_id` = '$value'
AND `$userlinktable`.`type`='".CommonITILObject::ASSIGN."')";
AND `$userlinktable`.`type`='".CommonITILActor::ASSIGN."')";
break;
case "technicien_followup" :
......@@ -749,7 +749,7 @@ class Stat {
case "user" :
$LEFTJOIN = $LEFTJOINUSER;
$WHERE .= " AND (`$userlinktable`.`users_id` = '$value'
AND `$userlinktable`.`type` ='".CommonITILObject::REQUESTER."')";
AND `$userlinktable`.`type` ='".CommonITILActor::REQUESTER."')";
break;
case "usertitles_id" :
......@@ -757,7 +757,7 @@ class Stat {
$LEFTJOIN .= " LEFT JOIN `glpi_users`
ON (`glpi_users`.`id` = `$userlinktable`.`users_id`)";
$WHERE .= " AND (`glpi_users`.`usertitles_id` = '$value'
AND `$userlinktable`.`type` = '".CommonITILObject::REQUESTER."')";
AND `$userlinktable`.`type` = '".CommonITILActor::REQUESTER."')";
break;
case "usercategories_id" :
......@@ -765,7 +765,7 @@ class Stat {
$LEFTJOIN .= " LEFT JOIN `glpi_users`
ON (`glpi_users`.`id` = `$userlinktable`.`users_id`)";
$WHERE .= " AND (`glpi_users`.`usercategories_id` = '$value'
AND `$userlinktable`.`type` = '".CommonITILObject::REQUESTER."')";
AND `$userlinktable`.`type` = '".CommonITILActor::REQUESTER."')";
break;
case "itilcategories_tree" :
......@@ -790,8 +790,8 @@ class Stat {
case 'group_tree' :
case 'groups_tree_assign' :
$grptype = (($param == 'group_tree') ? CommonITILObject::REQUESTER
: CommonITILObject::ASSIGN);
$grptype = (($param == 'group_tree') ? CommonITILActor::REQUESTER
: CommonITILActor::ASSIGN);
if ($value == $value2) {
$groups = array($value);
} else {
......@@ -807,19 +807,19 @@ class Stat {
case "group" :
$LEFTJOIN = $LEFTJOINGROUP;
$WHERE .= " AND (`$grouplinktable`.`groups_id` = '$value'
AND `$grouplinktable`.`type` = '".CommonITILObject::REQUESTER."')";
AND `$grouplinktable`.`type` = '".CommonITILActor::REQUESTER."')";
break;
case "groups_id_assign" :
$LEFTJOIN = $LEFTJOINGROUP;
$WHERE .= " AND (`$grouplinktable`.`groups_id` = '$value'
AND `$grouplinktable`.`type` = '".CommonITILObject::ASSIGN."')";
AND `$grouplinktable`.`type` = '".CommonITILActor::ASSIGN."')";
break;
case "suppliers_id_assign" :
$LEFTJOIN = $LEFTJOINSUPPLIER;
$WHERE .= " AND (`$supplierlinktable`.`suppliers_id` = '$value'
AND `$supplierlinktable`.`type` = '".CommonITILObject::ASSIGN."')";
AND `$supplierlinktable`.`type` = '".CommonITILActor::ASSIGN."')";
break;
case "requesttypes_id" :
......
This diff is collapsed.
......@@ -159,9 +159,9 @@ class TicketFollowup extends CommonDBTM {
}
// Only the technician
return (Session::haveRight("update_followups","1")
|| $ticket->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
|| $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $ticket->haveAGroup(CommonITILObject::ASSIGN, $_SESSION['glpigroups'])));
&& $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups'])));
}
......@@ -355,9 +355,9 @@ class TicketFollowup extends CommonDBTM {
&& $this->input["_reopen"]
&& in_array($this->input["_job"]->fields["status"], array('solved', 'waiting'))) {
if (($this->input["_job"]->countUsers(CommonITILObject::ASSIGN) > 0)
|| ($this->input["_job"]->countGroups(CommonITILObject::ASSIGN) > 0)
|| ($this->input["_job"]->countSuppliers(CommonITILObject::ASSIGN) > 0)) {
if (($this->input["_job"]->countUsers(CommonITILActor::ASSIGN) > 0)
|| ($this->input["_job"]->countGroups(CommonITILActor::ASSIGN) > 0)
|| ($this->input["_job"]->countSuppliers(CommonITILActor::ASSIGN) > 0)) {
$update['status'] = 'assign';
} else {
$update['status'] = 'new';
......@@ -510,9 +510,9 @@ class TicketFollowup extends CommonDBTM {
}
$tech = (Session::haveRight("global_add_followups", "1")
|| $ticket->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
|| $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $ticket->haveAGroup(CommonITILObject::ASSIGN, $_SESSION['glpigroups'])));
&& $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups'])));
if ($tech) {
$this->showFormHeader($options);
......
......@@ -83,10 +83,10 @@ class TicketSatisfaction extends CommonDBTM {
return false;
}
if ($ticket->isUser(CommonITILObject::REQUESTER,Session::getLoginUserID())
if ($ticket->isUser(CommonITILActor::REQUESTER,Session::getLoginUserID())
|| ($ticket->fields["users_id_recipient"] === Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $ticket->haveAGroup(CommonITILObject::REQUESTER, $_SESSION["glpigroups"]))) {
&& $ticket->haveAGroup(CommonITILActor::REQUESTER, $_SESSION["glpigroups"]))) {
return true;
}
return false;
......
......@@ -122,9 +122,9 @@ class TicketTask extends CommonITILTask {
if ($ticket->getFromDB($this->fields['tickets_id'])) {
return (Session::haveRight("global_add_tasks","1")
|| $ticket->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
|| $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $ticket->haveAGroup(CommonITILObject::ASSIGN, $_SESSION['glpigroups'])));
&& $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups'])));
}
return false;
}
......
......@@ -807,7 +807,7 @@ function update0782to080() {
(`tickets_id`, `groups_id`,
`type`)
VALUES ('".$data['id']."', '".$data['groups_id']."',
'".Ticket::REQUESTER."')";
'".CommonITILActor::REQUESTER."')";
$DB->queryOrDie($query, "0.80 migrate data to glpi_groups_tickets table");
}
if ($data['groups_id_assign']>0) {
......@@ -815,7 +815,7 @@ function update0782to080() {
(`tickets_id`, `groups_id`,
`type`)
VALUES ('".$data['id']."', '".$data['groups_id_assign']."',
'".Ticket::ASSIGN."')";
'".CommonITILActor::ASSIGN."')";
$DB->queryOrDie($query, "0.80 migrate data to glpi_groups_tickets table");
}
}
......@@ -886,7 +886,7 @@ function update0782to080() {
(`tickets_id`, `users_id`,
`type`, `use_notification`)
VALUES ('".$data['id']."', '".$data['users_id_assign']."',
'".Ticket::ASSIGN."', '1')";
'".CommonITILActor::ASSIGN."', '1')";
$DB->queryOrDie($query, "0.80 migrate data to glpi_tickets_users table");
}
if ($data['users_id']>0
......@@ -903,7 +903,7 @@ function update0782to080() {
$query = "INSERT INTO `glpi_tickets_users`
(`tickets_id`, `users_id`,`type`,
`use_notification`, `alternative_email`)
VALUES ('".$data['id']."', '$user_id', '".Ticket::REQUESTER."',
VALUES ('".$data['id']."', '$user_id', '".CommonITILActor::REQUESTER."',
'".$data['use_email_notification']."', '$user_email')";
$DB->queryOrDie($query, "0.80 migrate data to glpi_tickets_users table");
}
......
......@@ -1845,7 +1845,7 @@ function update0831to084() {
foreach($DB->request('glpi_problems',"`suppliers_id_assign` > 0") as $data) {
$query = "INSERT INTO `glpi_problems_suppliers`
(`suppliers_id`, `type`, `problems_id`)
VALUES ('".$data['suppliers_id_assign']."', '".CommonITILObject::ASSIGN."',
VALUES ('".$data['suppliers_id_assign']."', '".CommonITILActor::ASSIGN."',
'".$data['id']."')";
$DB->query($query);
}
......@@ -1868,7 +1868,7 @@ function update0831to084() {
foreach($DB->request('glpi_tickets',"`suppliers_id_assign` > 0") as $data) {
$query = "INSERT INTO `glpi_suppliers_tickets`
(`suppliers_id`, `type`, `tickets_id`)
VALUES ('".$data['suppliers_id_assign']."', '".CommonITILObject::ASSIGN."',
VALUES ('".$data['suppliers_id_assign']."', '".CommonITILActor::ASSIGN."',
'".$data['id']."')";
$DB->query($query);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment