本文整理汇总了PHP中TicketValidation::canValidate方法的典型用法代码示例。如果您正苦于以下问题:PHP TicketValidation::canValidate方法的具体用法?PHP TicketValidation::canValidate怎么用?PHP TicketValidation::canValidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TicketValidation
的用法示例。
在下文中一共展示了TicketValidation::canValidate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareInputForUpdate
function prepareInputForUpdate($input)
{
global $CFG_GLPI;
// Get ticket : need for comparison
$this->getFromDB($input['id']);
// automatic recalculate if user changes urgence or technician change impact
if (isset($input['urgency']) && isset($input['impact']) && ($input['urgency'] != $this->fields['urgency'] || $input['impact'] != $this->fields['impact']) && !isset($input['priority'])) {
$input['priority'] = self::computePriority($input['urgency'], $input['impact']);
}
// Security checks
if (!Session::isCron() && !Session::haveRight("assign_ticket", "1")) {
if (isset($input["_itil_assign"]) && isset($input['_itil_assign']['_type']) && $input['_itil_assign']['_type'] == 'user') {
// must own_ticket to grab a non assign ticket
if ($this->countUsers(CommonITILActor::ASSIGN) == 0) {
if (!Session::haveRight("steal_ticket", "1") && !Session::haveRight("own_ticket", "1") || !isset($input["_itil_assign"]['users_id']) || $input["_itil_assign"]['users_id'] != Session::getLoginUserID()) {
unset($input["_itil_assign"]);
}
} else {
// Can not steal or can steal and not assign to me
if (!Session::haveRight("steal_ticket", "1") || !isset($input["_itil_assign"]['users_id']) || $input["_itil_assign"]['users_id'] != Session::getLoginUserID()) {
unset($input["_itil_assign"]);
}
}
}
// No supplier assign
if (isset($input["_itil_assign"]) && isset($input['_itil_assign']['_type']) && $input['_itil_assign']['_type'] == 'supplier') {
unset($input["_itil_assign"]);
}
// No group
if (isset($input["_itil_assign"]) && isset($input['_itil_assign']['_type']) && $input['_itil_assign']['_type'] == 'group') {
unset($input["_itil_assign"]);
}
}
$check_allowed_fields_for_template = false;
if (!Session::isCron() && !Session::haveRight("update_ticket", "1")) {
$allowed_fields = array('id');
$check_allowed_fields_for_template = true;
if ($this->canApprove() && isset($input["status"])) {
$allowed_fields[] = 'status';
}
// for post-only with validate right or validation created by rules
if (TicketValidation::canValidate($this->fields['id']) || TicketValidation::canCreate() || isset($input["_rule_process"])) {
$allowed_fields[] = 'global_validation';
}
// Manage assign and steal right
if (Session::haveRight('assign_ticket', 1) || Session::haveRight('steal_ticket', 1)) {
$allowed_fields[] = '_itil_assign';
}
// Can only update initial fields if no followup or task already added
if ($this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0 && $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID())) {
$allowed_fields[] = 'content';
$allowed_fields[] = 'urgency';
$allowed_fields[] = 'priority';
// automatic recalculate if user changes urgence
$allowed_fields[] = 'itilcategories_id';
$allowed_fields[] = 'itemtype';
$allowed_fields[] = 'items_id';
$allowed_fields[] = 'name';
}
if ($this->canSolve()) {
$allowed_fields[] = 'solutiontypes_id';
$allowed_fields[] = 'solution';
}
foreach ($allowed_fields as $field) {
if (isset($input[$field])) {
$ret[$field] = $input[$field];
}
}
$input = $ret;
}
//// check mandatory fields
// First get ticket template associated : entity and type/category
if (isset($input['entities_id'])) {
$entid = $input['entities_id'];
} else {
$entid = $this->fields['entities_id'];
}
if (isset($input['type'])) {
$type = $input['type'];
} else {
$type = $this->fields['type'];
}
if (isset($input['itilcategories_id'])) {
$categid = $input['itilcategories_id'];
} else {
$categid = $this->fields['itilcategories_id'];
}
$tt = $this->getTicketTemplateToUse(0, $type, $categid, $entid);
if (count($tt->mandatory)) {
$mandatory_missing = array();
$fieldsname = $tt->getAllowedFieldsNames(true);
foreach ($tt->mandatory as $key => $val) {
if ((!$check_allowed_fields_for_template || in_array($key, $allowed_fields)) && (isset($input[$key]) && (empty($input[$key]) || $input[$key] == 'NULL') && !empty($this->fields[$key]))) {
$mandatory_missing[$key] = $fieldsname[$val];
}
}
if (count($mandatory_missing)) {
//TRANS: %s are the fields concerned
$message = sprintf(__('Mandatory fields are not filled. Please correct: %s'), implode(", ", $mandatory_missing));
Session::addMessageAfterRedirect($message, false, ERROR);
//.........这里部分代码省略.........
示例2: prepareInputForUpdate
function prepareInputForUpdate($input)
{
global $CFG_GLPI, $DB;
// Get ticket : need for comparison
$this->getFromDB($input['id']);
// Clean new lines before passing to rules
if ($CFG_GLPI["use_rich_text"] && isset($input["content"])) {
$input["content"] = preg_replace('/\\\\r\\\\n/', "\n", $input['content']);
$input["content"] = preg_replace('/\\\\n/', "\n", $input['content']);
}
// automatic recalculate if user changes urgence or technician change impact
if (isset($input['urgency']) && isset($input['impact']) && ($input['urgency'] != $this->fields['urgency'] || $input['impact'] != $this->fields['impact']) && !isset($input['priority'])) {
$input['priority'] = self::computePriority($input['urgency'], $input['impact']);
}
// Security checks
if (!Session::isCron() && !Session::haveRight(self::$rightname, self::ASSIGN)) {
if (isset($input["_itil_assign"]) && isset($input['_itil_assign']['_type']) && $input['_itil_assign']['_type'] == 'user') {
// must own_ticket to grab a non assign ticket
if ($this->countUsers(CommonITILActor::ASSIGN) == 0) {
if (!Session::haveRightsOr(self::$rightname, array(self::STEAL, self::OWN)) || !isset($input["_itil_assign"]['users_id']) || $input["_itil_assign"]['users_id'] != Session::getLoginUserID()) {
unset($input["_itil_assign"]);
}
} else {
// Can not steal or can steal and not assign to me
if (!Session::haveRight(self::$rightname, self::STEAL) || !isset($input["_itil_assign"]['users_id']) || $input["_itil_assign"]['users_id'] != Session::getLoginUserID()) {
unset($input["_itil_assign"]);
}
}
}
// No supplier assign
if (isset($input["_itil_assign"]) && isset($input['_itil_assign']['_type']) && $input['_itil_assign']['_type'] == 'supplier') {
unset($input["_itil_assign"]);
}
// No group
if (isset($input["_itil_assign"]) && isset($input['_itil_assign']['_type']) && $input['_itil_assign']['_type'] == 'group') {
unset($input["_itil_assign"]);
}
}
$check_allowed_fields_for_template = false;
$allowed_fields = array();
if (!Session::isCron() && (!Session::haveRight(self::$rightname, UPDATE) || in_array($this->fields['status'], $this->getClosedStatusArray()))) {
$allowed_fields = array('id');
$check_allowed_fields_for_template = true;
if (in_array($this->fields['status'], $this->getClosedStatusArray())) {
$allowed_fields[] = 'status';
// probably transfer
$allowed_fields[] = 'entities_id';
} else {
if ($this->canApprove() && isset($input["status"])) {
$allowed_fields[] = 'status';
}
// for post-only with validate right or validation created by rules
if (TicketValidation::canValidate($this->fields['id']) || TicketValidation::canCreate() || isset($input["_rule_process"])) {
$allowed_fields[] = 'global_validation';
}
// Manage assign and steal right
if (Session::haveRightsOr(self::$rightname, array(self::ASSIGN, self::STEAL))) {
$allowed_fields[] = '_itil_assign';
}
// Can only update initial fields if no followup or task already added
if ($this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0 && $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID())) {
$allowed_fields[] = 'content';
$allowed_fields[] = 'urgency';
$allowed_fields[] = 'priority';
// automatic recalculate if user changes urgence
$allowed_fields[] = 'itilcategories_id';
$allowed_fields[] = 'name';
}
if ($this->canSolve()) {
$allowed_fields[] = 'solutiontypes_id';
$allowed_fields[] = 'solution';
}
}
foreach ($allowed_fields as $field) {
if (isset($input[$field])) {
$ret[$field] = $input[$field];
}
}
$input = $ret;
// Only ID return false
if (count($input) == 1) {
return false;
}
}
//// check mandatory fields
// First get ticket template associated : entity and type/category
if (isset($input['entities_id'])) {
$entid = $input['entities_id'];
} else {
$entid = $this->fields['entities_id'];
}
if (isset($input['type'])) {
$type = $input['type'];
} else {
$type = $this->fields['type'];
}
if (isset($input['itilcategories_id'])) {
$categid = $input['itilcategories_id'];
} else {
$categid = $this->fields['itilcategories_id'];
//.........这里部分代码省略.........
示例3: prepareInputForUpdate
function prepareInputForUpdate($input)
{
global $LANG, $CFG_GLPI;
// Get ticket : need for comparison
$this->getFromDB($input['id']);
if (isset($input["date"]) && empty($input["date"])) {
unset($input["date"]);
}
if (isset($input["closedate"]) && empty($input["closedate"])) {
unset($input["closedate"]);
}
if (isset($input["solvedate"]) && empty($input["solvedate"])) {
unset($input["solvedate"]);
}
// check mandatory fields
if ($CFG_GLPI["is_ticket_title_mandatory"] && isset($input['name'])) {
$title = trim($input['name']);
if (empty($title)) {
addMessageAfterRedirect($LANG['tracking'][6], false, ERROR);
unset($input['name']);
}
}
if ($CFG_GLPI["is_ticket_content_mandatory"] && isset($input['content'])) {
$content = trim($input['content']);
if (empty($content)) {
addMessageAfterRedirect($LANG['tracking'][7], false, ERROR);
unset($input['content']);
}
}
// Security checks
if (is_numeric(getLoginUserID(false)) && !haveRight("assign_ticket", "1")) {
if (isset($input["_ticket_assign"]) && isset($input['_ticket_assign']['_type']) && $input['_ticket_assign']['_type'] == 'user') {
// must own_ticket to grab a non assign ticket
if ($this->countUsers(self::ASSIGN) == 0) {
if (!haveRight("steal_ticket", "1") && !haveRight("own_ticket", "1") || !isset($input["_ticket_assign"]['users_id']) || $input["_ticket_assign"]['users_id'] != getLoginUserID()) {
unset($input["_ticket_assign"]);
}
} else {
// Can not steal or can steal and not assign to me
if (!haveRight("steal_ticket", "1") || !isset($input["_ticket_assign"]['users_id']) || $input["_ticket_assign"]['users_id'] != getLoginUserID()) {
unset($input["_ticket_assign"]);
}
}
}
// No supplier assign
if (isset($input["suppliers_id_assign"])) {
unset($input["suppliers_id_assign"]);
}
// No group
if (isset($input["_ticket_assign"]) && isset($input['_ticket_assign']['_type']) && $input['_ticket_assign']['_type'] == 'group') {
unset($input["_ticket_assign"]);
}
}
if (is_numeric(getLoginUserID(false)) && !haveRight("update_ticket", "1")) {
$allowed_fields = array('id');
if ($this->canApprove() && isset($input["status"])) {
$allowed_fields[] = 'status';
}
// for post-only with validate right
$ticketval = new TicketValidation();
if (TicketValidation::canValidate($this->fields['id']) || $ticketval->canCreate()) {
$allowed_fields[] = 'global_validation';
}
// Manage assign and steal right
if (haveRight('assign_ticket', 1) || haveRight('steal_ticket', 1)) {
$allowed_fields[] = '_ticket_assign';
}
if (haveRight('assign_ticket', 1)) {
$allowed_fields[] = 'suppliers_id_assign';
}
// Can only update initial fields if no followup or task already added
if ($this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0 && $this->isUser(self::REQUESTER, getLoginUserID())) {
$allowed_fields[] = 'content';
$allowed_fields[] = 'urgency';
$allowed_fields[] = 'ticketcategories_id';
$allowed_fields[] = 'itemtype';
$allowed_fields[] = 'items_id';
$allowed_fields[] = 'name';
}
if ($this->canSolve()) {
$allowed_fields[] = 'ticketsolutiontypes_id';
$allowed_fields[] = 'solution';
}
foreach ($allowed_fields as $field) {
if (isset($input[$field])) {
$ret[$field] = $input[$field];
}
}
$input = $ret;
}
// Manage fields from auto update : map rule actions to standard ones
if (isset($input['_auto_update'])) {
if (isset($input['_users_id_assign'])) {
$input['_ticket_assign']['_type'] = 'user';
$input['_ticket_assign']['users_id'] = $input['_users_id_assign'];
}
if (isset($input['_groups_id_assign'])) {
$input['_ticket_assign']['_type'] = 'group';
$input['_ticket_assign']['groups_id'] = $input['_groups_id_assign'];
}
//.........这里部分代码省略.........