/** * Return organization the user who created the ticket belongs to. * * 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 kyUserOrganization */ public function getUserOrganization($reload = false) { if ($this->user_organization !== null && !$reload) { return $this->user_organization; } if ($this->user_organization_id === null) { return null; } $this->user_organization = kyUserOrganization::get($this->user_organization_id); return $this->user_organization; }
/** * Sets user organization assigned to the user. * * @param kyUserOrganization $user_organization User organization. * @return kyUser */ public function setUserOrganization(kyUserOrganization $user_organization) { $this->user_organization = ky_assure_object($user_organization, 'kyUserOrganization'); $this->user_organization_id = $this->user_organization !== null ? $this->user_organization->getId() : null; return $this; }
<?php ini_set('html_errors', 0); ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); require_once dirname(__FILE__) . "/ressources/kayaco/kyIncludes.php"; define('DEBUG', true); kyConfig::set(new kyConfig("http://www.articatech.net/support/api/index.php", "bea5b97c-a838-8ca4-9dda-aec5043cccae", "MmUxYzRmMDMtM2RjNC1iY2Y0LTRkOGEtNjYzN2Q3N2U3MWE2N2FiZjk2NzEtMzQxZS0yMTA0LTUxN2YtOWZiY2VkOTQyNTMy")); $registered_user_group = kyUserGroup::getAll()->filterByTitle("30 days free")->first(); echo "registered_user_group: {$registered_user_group}\n"; //load some user organization $org = new kyUserOrganization(); $org->setName("MyCompany"); $data = $org->buildData(true); $org->create(); print_r($data); $user_organizations = kyUserOrganization::getAll(); foreach ($user_organizations as $user_organization) { $id = $user_organization->getId(); $company = $user_organization->getName(); echo "Company: {$company} -> {$id}\n"; } return; /** * Create new user in Registered group: * fullname: Anno Ying * email: anno.ying@example.com * password: qwerty123 */ $user = $registered_user_group->newUser("Daniel touzeau", "*****@*****.**", "qwerty123")->setUserOrganization($user_organization)->setSalutation(kyUser::SALUTATION_MR)->setSendWelcomeEmail(true)->create();
/** * Returns the user organization that this note is connecte with. * * Applicable only for notes of type kyTicketNote::TYPE_USER_ORGANIZATION. * 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 kyUserOrganization */ public function getUserOrganization($reload = false) { if ($this->getType() !== self::TYPE_USER_ORGANIZATION) { return null; } if ($this->user_organization !== null && !$reload) { return $this->user_organization; } if ($this->user_organization_id === null || $this->user_organization_id <= 0) { return null; } $this->user_organization = kyUserOrganization::get($this->user_organization_id); return $this->user_organization; }
$full_name = null; $password = null; $password_repeat = null; $email = null; $user_organization_id = null; $designation = null; $phone = null; $timezone = null; $enable_dst = false; //render User form as the first page $render = 'user'; break; } //we are rendering User form if ($render === 'user') { $user_organizations = kyUserOrganization::getAll()->filterByType(kyUserOrganization::TYPE_SHARED); $salutations = array('Mr.', 'Ms.', 'Mrs.', 'Dr.'); $timezones = get_timezones(); ?> <form method="POST"> <input type="hidden" name="page" id="page" value="user"> <fieldset> <legend>General Information</legend> <div class="label"><span class="name">Full Name</span> <select id="salutation" name="salutation" style="width: 60px;"> <option value=""></option> <?php foreach ($salutations as $salutation_option) { $selected = false;
$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(); print 'Updated: ' . $staff_user; /** * Load Registered user group. */ $registered_user_group = kyUserGroup::getAll()->filterByTitle("Registered")->first(); print 'Fetched: ' . $registered_user_group; /** * Load some user organization. */ $user_organization = kyUserOrganization::getAll()->first(); print 'Fetched: ' . $user_organization; /** * Create new user in Registered group: * fullname: Anno Ying * email: anno.ying@example.com * password: qwerty123 */ $user = $registered_user_group->newUser("Anno Ying", "*****@*****.**", "qwerty123")->setUserOrganization($user_organization)->setSalutation(kyUser::SALUTATION_MR)->setSendWelcomeEmail(false)->create(); print 'Created: ' . $user; /** * Load urgent priority. */ $priority_urgent = kyTicketPriority::getAll()->filterByTitle("Urgent")->first(); print 'Fetched: ' . $priority_urgent; /**