Bitrix Site Manager

CTicket::Set

int
CTicket::Set(
 array arFields,
 int &MESSAGE_ID,
 int TICKET_ID="",
 char(1) CHECK_RIGHTS="Y"
);

The method Set creates a new ticket or modifies the existing one if a ticket ID is passed in the second parameter. Returns the created ticket ID, or the modified ticket ID.

Parameters

ParameterDescription
arFields An array of the ticket parameters. The following keys are possible in this array:
  • *TITLE - the ticket title (required when creating a new ticket);
  • MESSAGE - message body (required when creating a new ticket);
  • IMAGE - array describing the image to be uploaded. The following keys are possible in this array:
    • name - the original name of an uploaded file;
    • type - type of the uploaded file (for example: "image/gif");
    • tmp_name - name of the temporary file on the server;
    • error - the error code ("0" - no errors);
    • size - size of the uploaded file;
    • MODULE_ID - the module ID ("support");
  • *OWNER_SID - the ticket owner symbolic code. Any value identifying the owner can be specified: e-mail, phone number, address etc.
  • *OWNER_USER_ID - the ticket owner ID (the current user ID by default);
  • *SOURCE_SID - the ticket source symbolic code ((from) "web" by default);
  • *CREATED_MODULE_NAME - the ID of the module from which the ticket originates ("support" by default);
  • **MESSAGE_AUTHOR_SID - the message author symbolic code. Any value identifying the message author can be specified: e-mail, phone number, address etc.;
  • **MESSAGE_AUTHOR_USER_ID - the ID of the user who is the message author (the current user ID by default);
  • **MESSAGE_SOURCE_SID - the message source symbolic code (from web by default);
  • **MODIFIED_MODULE_NAME - the ID of the module from which the ticket was modified ("support" by default);
  • **HIDDEN - if set to "Y", the message is added as hidden and can be viewed only by members of the techsupport user group. If "N", the message is added as visible and can be viewed both by the ticket owner and by members of the techsupport user group (by default);
  • CATEGORY_SID - the category symbolic code;
  • CRITICALITY_SID - the emergency level symbolic code;
  • STATUS_SID - the ticket status symbolic code;
  • MARK_SID - the reply mark symbolic code;
  • RESPONSIBLE_USER_ID - the ID of the user responsible for the ticket.;
  • SUPPORT_COMMENTS - comments which can be viewed only by users who are members of the techsupport user group;
  • CLOSE - "Y" specifies the ticket to be closed; "N" specifies the ticket to remain open;
  • AUTO_CLOSE_DAYS - number of days expire before the ticket is automatically closed in case the author did not respond;
* - the field can be used to create new tickets;
** - the field can be used to modify the existing tickets only.
MESSAGE_ID The ID of the added message.
TICKET_ID The ID of the modified ticket.
CHECK_RIGHTS Flag indicating that the current user permissions should be checked:
  • if "Y", the permissions of the current user who is creating or modifying a ticket should be checked; 
  • if "N", a ticket can be created and modified disregarding the current user permissions.

Example


// Example of the code adding a new e-mail ticket to the techsupport,
// or adding a new message to the ticket if $TICKET_ID is valid:

<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("support");
$arFields = array(
 "CREATED_MODULE_NAME" => "mail",
 "MODIFIED_MODULE_NAME" => "mail",
 "OWNER_SID" => "user@mail.com",
 "SOURCE_SID" => "email",
 "MESSAGE_AUTHOR_SID" => "user@mail.com",
 "MESSAGE_SOURCE_SID" => "email",
 "TITLE" => "title",
 "MESSAGE" => "message"
 );

//$TICKET_ID = 866;
$NEW_TICKET_ID = CTicket::Set($arFields, $MESSAGE_ID, $TICKET_ID, "N");
echo "MESSAGE_ID = ".$MESSAGE_ID;
?>