<?php /** * @copyright 2001-2015 Kayako * @license https://www.freebsd.org/copyright/freebsd-license.html * @link https://github.com/kayako/whmcs-integration */ //Include config file require_once __DIR__ . '/config.php'; //Include all necessary classes and helper methods require_once 'API/kyIncludes.php'; //Include common functions require_once 'functions.php'; //Initialize the client kyConfig::set(new kyConfig(API_URL, API_KEY, SECRET_KEY)); $_ticketObject = kyTicket::get($_GET['tid']); $_customField = $_ticketObject->getCustomField($_GET['field']); $_customFieldValue = $_customField->getValue(); Download($_customFieldValue[0], $_customFieldValue[1]);
<?php /** * @copyright 2001-2015 Kayako * @license https://www.freebsd.org/copyright/freebsd-license.html * @link https://github.com/kayako/whmcs-integration */ $_ticket = kyTicket::get($_GET['ticketid']); $_ticket->setStatusId($_POST['ticketstatusid']); $_ticket->setPriorityId($_POST['ticketpriorityid']); $_ticket->update(); $_ticket->setCustomFieldValuesFromPOST(); $_ticket->updateCustomFields();
/** * Returns the ticket that this post is connected with. * * 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 kyTicket */ public function getTicket($reload = false) { if ($this->ticket !== null && !$reload) { return $this->ticket; } if ($this->ticket_id === null) { return null; } $this->ticket = kyTicket::get($this->ticket_id); return $this->ticket; }
/** * Returns the ticket that this note is connected with. * * Applicable only for notes of type kyTicketNote::TYPE_TICKET. * 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 kyTicket */ public function getTicket($reload = false) { if ($this->getType() !== self::TYPE_TICKET) { return null; } if ($this->ticket !== null && !$reload) { return $this->ticket; } if ($this->ticket_id === null || $this->ticket_id <= 0) { return null; } $this->ticket = kyTicket::get($this->ticket_id); return $this->ticket; }
//we are submitting General Information form $department_id = get_post_value('department_id', $form_valid, $fields_valid); $creator_full_name = get_post_value('creator_full_name', $form_valid, $fields_valid); $creator_email = get_post_value('creator_email', $form_valid, $fields_valid); $type_id = get_post_value('type_id', $form_valid, $fields_valid); $priority_id = get_post_value('priority_id', $form_valid, $fields_valid); $subject = get_post_value('subject', $form_valid, $fields_valid); $contents = get_post_value('contents', $form_valid, $fields_valid); //if valid, submit the ticket, re-render General Information form if it's invalid $render = $form_valid ? 'submit' : 'general'; break; case 'custom_fields': //we are submitting Custom Fields form $ticket_id = get_post_value('ticket_id', $form_valid, $fields_valid); /** @var $ticket kyTicket */ $ticket = kyTicket::get($ticket_id); //load ticket custom fields; check if there is a file custom field (for proper form encoding) $file_custom_field_present = false; $ticket_custom_fields = get_ticket_custom_fields($ticket, $file_custom_field_present); //render summary if there is no ticket custom fields if (count($ticket_custom_fields) === 0) { $render = 'summary'; break; } //load custom field values $custom_field_values = array(); foreach ($ticket_custom_fields as $custom_fields) { foreach ($custom_fields as $custom_field) { /* @var $custom_field kyCustomField */ $custom_field_definition = $custom_field->getDefinition(); //process file custom field
$email = JFactory::getUser()->email; if (empty($email) || !isset($email)) { throw new kyException(); } //Retrieve the get value $input = JFactory::getApplication()->input; //$edit_id = $input->get('id', null); $edit_id = $_REQUEST['ticketid']; JTickets::init(); $all_departments = kyDepartment::getAll()->filterByModule(kyDepartment::MODULE_TICKETS)->filterByType(kyDepartment::TYPE_PUBLIC); $department_titles = kyDepartment::getAll()->collectTitle(); $department_id = kyDepartment::getAll()->collectId(); $priority_list = kyTicketPriority::getAll(); $status_list = kyTicketStatus::getAll(); $ticket_type = kyTicketType::getAll(); $ticket_details = kyTicket::get($edit_id); $document =& JFactory::getDocument(); $document->addScript('/media/jui/js/jquery.min.js'); ?> <link rel="stylesheet" type="text/css" href="modules/mod_kayako/resources/css/style.css"> <script> jQuery(document).ready(function() { jQuery('#Reply').click(function() { jQuery('#div_reply').slideToggle("fast"); }); }); function AddTicketFile(_namePrefix) { jQuery('#' + _namePrefix + 'attachmentcontainer').append('<div class="ticketattachmentitem"><div class="ticketattachmentitemdelete" onclick="javascript: jQuery(this).parent().remove();"> </div><input name="' + _namePrefix + 'attachments[]" type="file" size="20" class="swifttextlarge swifttextfile" /></div>');
<?php /** * @copyright 2001-2015 Kayako * @license https://www.freebsd.org/copyright/freebsd-license.html * @link https://github.com/kayako/whmcs-integration */ if (!empty($_GET['tid'])) { $_ticketID = $_GET['tid']; } else { $_ticketID = $_GET['ticketid']; } //Get ticket properties $_ticketObject = kyTicket::get($_ticketID); if ($_ticketObject->getEmail() != $clientsdetails['email']) { $smarty->assign('_noPermissions', true); } else { $_ticketContainer = array(); $_ticketContainer['ticketid'] = $_ticketObject->getId(); $_ticketContainer['displayticketid'] = $_ticketObject->getDisplayId(); $_ticketContainer['departmentid'] = $_ticketObject->getDepartmentId(); $_ticketContainer['departmenttitle'] = $_ticketObject->getDepartment()->getTitle(); $_ticketContainer['departmenttype'] = $_ticketObject->getDepartment()->getType(); if ($_ticketContainer['departmenttype'] == kyDepartment::TYPE_PRIVATE) { $_ticketContainer['department'] = 'Private'; } else { $_ticketContainer['department'] = $_ticketContainer['departmenttitle']; } $_ticketContainer['ticketstatusid'] = $_ticketObject->getStatusId(); $_ticketContainer['status'] = $_ticketObject->getStatus()->getTitle(); $_ticketContainer['statusbgcolor'] = $_ticketObject->getStatus()->getStatusBackgroundColor();
/** * 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; }
function get_ticket($ticket_number) { $ticket = kyTicket::get($ticket_number); return $ticket; }
/** * Returns Ticket details * * @param int $_ticketID * * @return kyTicket */ public function getTicketDetails($_ticketID) { $_ticketObjectContainer = kyTicket::get($_ticketID); return $_ticketObjectContainer; }