/** * 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 staff user, owner of this ticket. * * @param kyStaff $owner_staff Staff user. * @return kyTicket */ public function setOwnerStaff($owner_staff) { $this->owner_staff = ky_assure_object($owner_staff, 'kyStaff'); $this->owner_staff_id = $this->owner_staff !== null ? $this->owner_staff->getId() : null; return $this; }
/** * Creates new staff user. * WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result. * * @param string $first_name First name of new staff user. * @param string $last_name Last name of new staff user. * @param string $user_name Login username of new staff user. * @param string $email E-mail address of new staff user. * @param kyStaffGroup $staff_group Staff group of new staff user. * @param string $password Password for new staff user. * @return kyStaff */ public static function createNew($first_name, $last_name, $user_name, $email, kyStaffGroup $staff_group, $password) { $new_staff = new kyStaff(); $new_staff->setFirstName($first_name); $new_staff->setLastName($last_name); $new_staff->setUserName($user_name); $new_staff->setEmail($email); $new_staff->setStaffGroup($staff_group); $new_staff->setPassword($password); return $new_staff; }
/** * Sets staff user, the editor of this news item update. * * @param kyStaff $staff Staff user. * @return kyNewsItem */ public function setEditedStaff($staff) { $this->edited_staff = ky_assure_object($staff, 'kyStaff'); $this->edited_staff_id = $this->edited_staff !== null ? $this->edited_staff->getId() : null; return $this; }
/** * Creates new staff user in this staff group. * WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result. * * @param string $first_name First name of new staff user. * @param string $last_name Last name of new staff user. * @param string $user_name Login username of new staff user. * @param string $email E-mail address of new staff user. * @param string $password Password for new staff user. * @return kyStaff */ public function newStaff($first_name, $last_name, $user_name, $email, $password) { return kyStaff::createNew($first_name, $last_name, $user_name, $email, $this, $password); }
/** * Sets staff user, the creator of this post. * * @param kyStaff $staff Staff user. * @return kyTicketPost */ public function setStaff($staff) { $this->staff = ky_assure_object($staff, 'kyStaff'); $this->staff_id = $this->staff !== null ? $this->staff->getId() : null; $this->creator = $this->staff !== null ? self::CREATOR_STAFF : null; $this->user_id = null; $this->user = null; return $this; }
/** * Sets staff user, the creator of this knowledgebase article. * * @param kyStaff $staff Staff user. * @return kyKnowledgebaseArticle */ public function setStaff($creator) { $this->creator = ky_assure_object($creator, 'kyStaff'); $this->creator_id = $this->creator !== null ? $this->creator->getId() : null; return $this; }
/** * Sets staff user that creates the time track. * * @param kyStaff $creator_staff Staff user that creates the time track. * @return kyTicketTimeTrack */ public function setCreatorStaff($creator_staff) { $this->creator_staff = ky_assure_object($creator_staff, 'kyStaff'); $this->creator_staff_id = $this->creator_staff !== null ? $this->creator_staff->getId() : null; $this->creator_staff_name = $this->creator_staff !== null ? $this->creator_staff->getFullName() : null; return $this; }
/** * Sets the staff who this note is for. * * @param kyStaff $for_staff * @return kyTicketNote */ public function setForStaff($for_staff) { $this->for_staff = $for_staff instanceof kyStaff ? $for_staff : null; $this->for_staff_id = $this->for_staff !== null ? $this->for_staff->getId() : null; return $this; }
function get_staff_member_by_user($username) { $config = json_decode(file_get_contents("config/config.json"), true); $staff = kyStaff::getAll()->filterByEmail($config["slack"][$username]); return $staff; }
*/ $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);
/** * Gets the staff user, the creator of this TroubleshooterCategory. * * @param bool $reload True to reload data from server. False to use the cached value (if present). * @return kyStaff */ public function getStaff($reload = false) { if ($this->staff !== null && !$reload) { return $this->staff; } if ($this->staff_id === null) { return null; } $this->staff = kyStaff::get($this->staff_id); return $this->staff; }