コード例 #1
0
 /**
  * Searches for tickets based on provided data. You must provide at least one department identifier.
  *
  * @param kyDepartment|kyResultSet $departments Non-empty list of department identifiers.
  * @param array|kyResultSet|kyTicketStatus $ticket_statuses List of ticket status identifiers.
  * @param array|kyResultSet|kyStaff $owner_staffs List of staff (ticket owners) identifiers.
  * @param array|kyResultSet|kyUser $users List of user (ticket creators) identifiers.
  * @param $rowsPerPage (OPTIONAL)
  * @param $rowOffset (OPTIONAL)
  * @throws InvalidArgumentException
  * @return kyResultSet
  */
 public static function getAll($departments, $ticket_statuses = array(), $owner_staffs = array(), $users = array(), $max_items = null, $starting_ticket_id = null)
 {
     $search_parameters = array('ListAll');
     $department_ids = array();
     if ($departments instanceof kyDepartment) {
         $department_ids = array($departments->getId());
     } elseif ($departments instanceof kyResultSet) {
         $department_ids = $departments->collectId();
     }
     //department
     if (count($department_ids) === 0) {
         throw new InvalidArgumentException('You must provide at least one department to search for tickets.');
     }
     $ticket_status_ids = array();
     if ($ticket_statuses instanceof kyTicketStatus) {
         $ticket_status_ids = array($ticket_statuses->getId());
     } elseif ($ticket_statuses instanceof kyResultSet) {
         $ticket_status_ids = $ticket_statuses->collectId();
     } elseif (is_array($ticket_statuses)) {
         $ticket_status_ids = $ticket_statuses;
     }
     $owner_staff_ids = array();
     if ($owner_staffs instanceof kyStaff) {
         $owner_staff_ids = array($owner_staffs->getId());
     } elseif ($owner_staffs instanceof kyResultSet) {
         $owner_staff_ids = $owner_staffs->collectId();
     }
     $user_ids = array();
     if ($users instanceof kyUser) {
         $user_ids = array($users->getId());
     } elseif ($users instanceof kyResultSet) {
         $user_ids = $users->collectId();
     }
     $search_parameters[] = implode(',', $department_ids);
     //ticket status
     if (count($ticket_status_ids) > 0) {
         $search_parameters[] = implode(',', $ticket_status_ids);
     } else {
         $search_parameters[] = '-1';
     }
     //owner staff
     if (count($owner_staff_ids) > 0) {
         $search_parameters[] = implode(',', $owner_staff_ids);
     } else {
         $search_parameters[] = '-1';
     }
     //user
     if (count($user_ids) > 0) {
         $search_parameters[] = implode(',', $user_ids);
     } else {
         $search_parameters[] = '-1';
     }
     if (is_numeric($starting_ticket_id) && $starting_ticket_id > 0) {
         if (!is_numeric($max_items) || $max_items <= 0) {
             $max_items = 1000;
         }
         $search_parameters[] = $max_items;
         $search_parameters[] = $starting_ticket_id;
     }
     return parent::getAll($search_parameters);
 }
コード例 #2
0
 /**
  * Process tickets related data. You must provide at least one department identifier.
  *
  * @param string                           $method
  * @param kyDepartment|kyResultSet         $departments     Non-empty list of department identifiers.
  * @param array|kyResultSet|kyTicketStatus $ticket_statuses List of ticket status identifiers.
  * @param array|kyResultSet|kyStaff        $owner_staffs    List of staff (ticket owners) identifiers.
  * @param array|kyResultSet|kyUser         $users           List of user (ticket creators) identifiers.
  *
  * @throws InvalidArgumentException
  * @return array $search_parameters
  */
 public static function processData($method, $departments, $ticket_statuses = array(), $owner_staffs = array(), $users = array())
 {
     $search_parameters = array($method);
     $department_ids = array();
     if ($departments instanceof kyDepartment) {
         $department_ids = array($departments->getId());
     } elseif ($departments instanceof kyResultSet) {
         $department_ids = $departments->collectId();
     }
     //department
     if (count($department_ids) === 0) {
         throw new InvalidArgumentException('You must provide at least one department to search for tickets.');
     }
     $ticket_status_ids = array();
     if ($ticket_statuses instanceof kyTicketStatus) {
         $ticket_status_ids = array($ticket_statuses->getId());
     } elseif ($ticket_statuses instanceof kyResultSet) {
         $ticket_status_ids = $ticket_statuses->collectId();
     }
     $owner_staff_ids = array();
     if ($owner_staffs instanceof kyStaff) {
         $owner_staff_ids = array($owner_staffs->getId());
     } elseif ($owner_staffs instanceof kyResultSet) {
         $owner_staff_ids = $owner_staffs->collectId();
     }
     $user_ids = array();
     if ($users instanceof kyUser) {
         $user_ids = array($users->getId());
     } elseif ($users instanceof kyResultSet) {
         $user_ids = $users->collectId();
     }
     $search_parameters[] = implode(',', $department_ids);
     //ticket status
     if (count($ticket_status_ids) > 0) {
         $search_parameters[] = implode(',', $ticket_status_ids);
     } else {
         $search_parameters[] = '-1';
     }
     //owner staff
     if (count($owner_staff_ids) > 0) {
         $search_parameters[] = implode(',', $owner_staff_ids);
     } else {
         $search_parameters[] = '-1';
     }
     //user
     if (count($user_ids) > 0) {
         $search_parameters[] = implode(',', $user_ids);
     } else {
         $search_parameters[] = '-1';
     }
     return $search_parameters;
 }