/** * Sets the creator of this comment. * * @param kyUser|kyStaff|string $creator Creator (staff object, user object or user fullname) of this comment. * @return $this */ public function setCreator($creator) { if ($creator instanceof kyStaff) { $this->creator_staff = $creator; $this->creator_id = $this->creator_staff->getId(); $this->creator_type = self::CREATOR_TYPE_STAFF; $this->creator_user = null; } elseif ($creator instanceof kyUser) { $this->creator_user = $creator; $this->creator_id = $this->creator_user->getId(); $this->creator_type = self::CREATOR_TYPE_USER; $this->creator_staff = null; } elseif (is_string($creator) && strlen($creator) > 0) { $this->setCreatorFullname($creator); } else { $this->creator_id = null; $this->creator_type = null; $this->creator_staff = null; $this->creator_user = null; } return $this; }
/** * Sets user, the creator of this post. * * @param kyUser $user User. * @return kyTicketPost */ public function setUser($user) { $this->user = ky_assure_object($user, 'kyUser'); $this->user_id = $this->user !== null ? $this->user->getId() : null; $this->creator = $this->user !== null ? self::CREATOR_USER : null; if ($this->user !== null) { $this->full_name = $this->user->getFullName(); $this->email = $this->user->getEmail(); } $this->staff_id = null; $this->staff = null; return $this; }
/** * Creates new user. * WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result. * * @param string $full_name Full name of new user. * @param string $email E-mail address of new user. * @param kyUserGroup $user_group User group of new user. * @param string $password Password of new user. * @return kyUser */ public static function createNew($full_name, $email, kyUserGroup $user_group, $password) { $new_user = new kyUser(); $new_user->setFullName($full_name); $new_user->addEmail($email); $new_user->setUserGroup($user_group); $new_user->setPassword($password); return $new_user; }
/** * Returns User from email * * @param string $userEmail */ public function getUser($userEmail) { $_user = kyUser::search($userEmail); return $_user[0]; }
/** * Creates new user in this user group. * WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result. * * @param string $full_name Full name of new user. * @param string $email E-mail address of new user. * @param string $password Password of new user. * @return kyUser */ public function newUser($full_name, $email, $password) { return kyUser::createNew($full_name, $email, $this, $password); }
/** * Sets the user, the creator of this post. * * @param kyUser $user User. * @return kyTicketPost */ public function setUser($user) { $this->user = ky_assure_object($user, 'kyUser'); $this->user_id = $this->user !== null ? $this->user->getId() : null; $this->creator = $this->user !== null ? self::CREATOR_USER : null; $this->staff_id = null; $this->staff = null; return $this; }
/** * Return the user that this note is connected to. * * Applicable only for notes of type kyTicketNote::TYPE_USER. * Result is cached until the end of script. * * @param bool $reload True to reload data from server. False to use the cached value (if present). * @return kyUser */ public function getUser($reload = false) { if ($this->getType() !== self::TYPE_USER) { return null; } if ($this->user !== null && !$reload) { return $this->user; } if ($this->user_id === null || $this->user_id <= 0) { return null; } $this->user = kyUser::get($this->user_id); return $this->user; }
echo !$form_valid && $fields_valid['enable_dst'] !== true ? ' error' : ''; ?> ">Enable Daylight Saving Time.</span> </label> </fieldset> <input type="submit" name="submit_user" value="Submit"> </form> <?php } //we are creating the user if ($render === 'submit') { //load default user group $user_group = kyUserGroup::getAll()->filterByTitle(USER_GROUP_TITLE)->first(); //create the user $user = kyUser::createNew($full_name, $email, $user_group, $password)->setEnableDST($enable_dst)->setSendWelcomeEmail(SEND_WELCOME_EMAIL); if (is_numeric($user_organization_id)) { $user->setUserOrganizationId($user_organization_id); } if (strlen($salutation)) { $user->setSalutation($salutation); } if (strlen($salutation)) { $user->setDesignation($designation); } if (strlen($salutation)) { $user->setPhone($phone); } if (strlen($salutation)) { $user->setTimezone($timezone); }
/** * Post a message to the user * * @return bool */ public function postReply() { require_once 'modules/mod_kayako/includes/kayako-php-api/kyIncludes.php'; $confObject = JFactory::getApplication(); $tmp_path = $confObject->getCfg('tmp_path'); JTickets::init(); //Fetch Post data $input = JFactory::getApplication()->input; $form_value = $input->getArray(array('content' => null, 'id' => null, 'replyattachments' => null)); $img = $_FILES['replyattachments']['name']; //Fetch the email of login User $email = JFactory::getUser()->email; $user = kyUser::search($email)->getRawArray(); $ticket_object = kyTicket::get($form_value['id']); $user_reply_post = $ticket_object->newPost($user[0], $form_value['content'])->create(); foreach ($img as $key => $value) { $name = time() . $_FILES["replyattachments"]["name"][$key]; $temp_name = $_FILES["replyattachments"]["tmp_name"][$key]; $size = $_FILES["replyattachments"]["size"][$key]; if ($size < 1024 * 1024) { move_uploaded_file($temp_name, $tmp_path . "/" . $name); $user_reply_post->newAttachmentFromFile(JURI::Root() . "tmp/" . $name)->create(); } } return true; }
* Search for tickets with "power cable" text in contents of posts or notes. */ $tickets = kyTicket::search("power cable", array(kyTicket::SEARCH_CONTENTS, kyTicket::SEARCH_NOTES)); //print them print "Searching tickets:\n" . $tickets; /** * Search for open and assigned tickets with no replies in all departments. * WARNING: Can be time consuming. */ $tickets = kyTicket::getAll(kyDepartment::getAll())->filterByStatusId(kyTicketStatus::getAll()->filterByTitle(array("!=", "Closed"))->collectId())->filterByReplies(array('<=', 1))->filterByOwnerStaffId(array("!=", null)); //print them print "Searching tickets:\n" . $tickets; /** * Filtering, sorting and paging results. */ //print available filter methods for User objects print "User available filter methods:\n"; print_r(kyUser::getAvailableFilterMethods()); //print available order methods for Staff objects print "Staff available order methods:\n"; print_r(kyStaff::getAvailableOrderMethods()); //find the user with email someuser@example.com $user = kyUser::getAll()->filterByEmail("*****@*****.**")->first(); //find ticket time tracks with billable time greater than 10 minutes and sort them ascending using time worked $time_tracks = $ticket->getTimeTracks()->filterByTimeBillable(array(">", 10 * 60))->orderByTimeWorked(); //find department with title "General" $general_department = kyDepartment::getAll()->filterByTitle("General")->first(); //find tickets in "General" department with word "help" in subject $tickets = kyTicket::getAll($general_department->getId())->filterBySubject(array("~", "/help/i")); //assuming 10 items per page, get second page from list of staff users ordered by fullname $staff_page_2 = kyStaff::getAll()->orderByFullName()->getPage(2, 10);
$_ticketPriority['priorityid'] = $_ticketPriorityObject->getId(); $_ticketPriority['title'] = $_ticketPriorityObject->getTitle(); $_ticketPriority['displayorder'] = $_ticketPriorityObject->getDisplayOrder(); $_ticketPriority['type'] = $_ticketPriorityObject->getType(); $_ticketPriority['frcolorcode'] = $_ticketPriorityObject->getForegroundColor(); $_ticketPriority['bgcolorcode'] = $_ticketPriorityObject->getBackgroundColor(); $_ticketPriority['displayicon'] = $_ticketPriorityObject->getDisplayIcon(); $_ticketPriority['uservisibilitycustom'] = $_ticketPriorityObject->getUserVisibilityCustom(); $_ticketPriorityContainer[$_ticketPriorityObject->getId()] = $_ticketPriority; } if (isset($_GET['aid'])) { $_ticketAttachment = kyTicketAttachment::get($_GET['tid'], $_GET['aid']); Download($_ticketAttachment->getFileName(), $_ticketAttachment->getContents()); } else { if ($_GET['action'] == 'reply') { $_user = kyUser::search($clientsdetails['email']); $_user = $_user[0]; $_ticketObject = kyTicket::get($_GET['ticketid']); $_ticketPost = kyTicketPost::createNew($_ticketObject, $_user, $_POST['replycontents'])->create(); //Save ticket post attachments foreach ($_FILES['ticketattachments']['tmp_name'] as $_key => $_ticketAttachment) { kyTicketAttachment::createNewFromFile($_ticketPost, $_ticketAttachment, $_FILES['ticketattachments']['name'][$_key])->create(); } header('Location: ' . WHMCS_URL . 'viewticket.php?ticketid=' . $_GET['ticketid']); } else { if ($_REQUEST['action'] == 'update') { require_once 'updateticket.php'; header('Location: ' . WHMCS_URL . 'viewticket.php?ticketid=' . $_GET['ticketid']); } else { require_once 'ticketview.php'; }