/** * Returns staff group of the staff 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 kyStaffGroup */ public function getStaffGroup($reload = false) { if ($this->staff_group !== null && !$reload) { return $this->staff_group; } if ($this->staff_group_id === null || $this->staff_group_id <= 0) { return null; } $this->staff_group = kyStaffGroup::get($this->staff_group_id); return $this->staff_group; }
/** * Add staff group to the list of groups that this news item will be visible to. * Automatically sets custom staff visibility flag to True. * * @param kyStaffGroup $staff_group Staff group that this news item will be visible to. * @param bool $clear Clear the list before adding. * @return kyNewsItem */ public function addStaffGroup(kyStaffGroup $staff_group, $clear = false) { if ($clear) { $this->staff_groups = array(); $this->staff_group_ids = array(); } if (!in_array($staff_group->getId(), $this->staff_group_ids)) { $this->staff_group_ids[] = $staff_group->getId(); $this->staff_visibility_custom = true; } return $this; }
/** * Returns whether this ticket status can be set by specified staff group. * * @param kyStaffGroup|int $staff_group Staff group or its identifier. * @return bool * @filterBy */ public function isVisibleToStaffGroup($staff_group) { if ($this->staff_visibility_custom === false) { return true; } if ($staff_group instanceof kyStaffGroup) { $staff_group_id = $staff_group->getId(); } else { $staff_group_id = intval($staff_group); } return in_array($staff_group_id, $this->staff_group_ids); }
/** * Creates new staff group. * WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result. * * @param string $title Title of new staff group. * @param bool $is_admin True, if you want staff members assigned to this group to be Administrators. False (default), otherwise. * @return kyStaffGroup */ public static function createNew($title, $is_admin = false) { $new_staff_group = new kyStaffGroup(); $new_staff_group->setTitle($title); $new_staff_group->setIsAdmin($is_admin); return $new_staff_group; }
$printers_department = $general_department->newSubdepartment("Printers (example)")->create(); print 'Created: ' . $printers_department; /** * Create some livechat department: * title: Urgent problems (example) * type: public * module: livechat */ $livechat_department = kyDepartment::createNew("Urgent problems (example)", kyDepartment::TYPE_PUBLIC, kyDepartment::MODULE_LIVECHAT)->create(); print 'Created: ' . $livechat_department; /** * Create a staff group: * title: Lazy guys (example) * isadmin: false (default) */ $lazy_staff_group = kyStaffGroup::createNew("Lazy guys (example)")->create(); print 'Created: ' . $lazy_staff_group; /** * Create a staff user in just created staff group: * firstname: John * lastname: Doe * username: lazyguy * email: john.doe@lazycorp.com * password: veryhardpassword */ $staff_user = $lazy_staff_group->newStaff("John", "Doe", "lazyguy", "*****@*****.**", "veryhardpassword")->setDesignation("useless specialist")->setSignature("Sorry I couldn't help you")->create(); print 'Created: ' . $staff_user; /** * Update staff user mobile number. */ $staff_user->setMobileNumber("427 078 528")->update();