}); } $columns['ticket_contact'] = array('title' => 'Contact', 'callback' => function ($ticket) { echo module_user::link_open($ticket['user_id'], true, array(), true); }); if (class_exists('module_faq', false) && module_config::c('ticket_show_product_list', 1)) { $columns['ticket_product'] = array('title' => 'Product', 'callback' => function ($ticket) { if ($ticket['faq_product_id']) { $faq_product = module_faq::get_faq_product($ticket['faq_product_id']); echo $faq_product && isset($faq_product['name']) ? htmlspecialchars($faq_product['name']) : ''; } }); } if (class_exists('module_envato', false)) { $columns['ticket_envato'] = array('title' => _l('Envato%s', module_config::c('envato_show_ticket_earning', 0) ? ' (' . dollar($envato_count * 0.7) . ')' : ''), 'callback' => function ($ticket) { $items = module_envato::get_items_by_ticket($ticket['ticket_id']); foreach ($items as $item) { echo '<a href="' . $item['url'] . '">' . htmlspecialchars($item['name']) . '</a> '; } }); } if (class_exists('module_group', false) && module_config::c('ticket_enable_groups', 1) && module_group::groups_enabled()) { $columns['ticket_group'] = array('title' => 'Group', 'callback' => function ($ticket) { // find the groups for this customer. $groups = module_group::get_groups_search(array('owner_table' => 'ticket', 'owner_id' => $ticket['ticket_id'])); $g = array(); foreach ($groups as $group) { $g[] = $group['name']; } echo implode(', ', $g); });
/** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!module_config::can_i('view', 'Settings') || !module_faq::can_i('edit', 'FAQ')) { redirect_browser(_BASE_HREF); } $faq_products = module_faq::get_faq_products(); $types = module_ticket::get_types(); if (class_exists('module_envato', false)) { $all_items_rel = module_envato::get_envato_items_rel(); } if (isset($_REQUEST['faq_product_id']) && $_REQUEST['faq_product_id']) { $show_other_settings = false; $faq_product_id = (int) $_REQUEST['faq_product_id']; if ($faq_product_id > 0) { $faq_product = module_faq::get_faq_product($faq_product_id); } else { $faq_product = array(); } if (!$faq_product) { $faq_product = array('name' => '', 'envato_item_ids' => '', 'default_type_id' => ''); } ?>
public static function api_filter_faq($hook, $response, $endpoint, $method) { $response['faq'] = true; switch ($method) { case 'list_products': $faq_products = module_faq::get_faq_products(); $types = module_ticket::get_types(); if (class_exists('module_envato', false)) { $all_items = module_envato::get_envato_items(); $all_items_rel = array(); foreach ($all_items as $all_item) { $all_items_rel[$all_item['item_id']] = $all_item; } } foreach ($faq_products as $faq_product_id => $faq_product) { $faq_products[$faq_product_id]['default_type'] = isset($types[$faq_product['default_type_id']]) ? $types[$faq_product['default_type_id']] : false; if (class_exists('module_envato', false)) { $linked_items = explode('|', $faq_product['envato_item_ids']); foreach ($linked_items as $id => $linked_item) { if (!strlen(trim($linked_item))) { unset($linked_items[$id]); } if (isset($all_items_rel[$linked_item])) { $linked_items[$id] = $all_items_rel[$linked_item]; } } $faq_products[$faq_product_id]['envato_items'] = $linked_items; } } $response['faq_products'] = $faq_products; break; } return $response; }
?> </td> <?php if (class_exists('module_envato', false)) { ?> <td width="27"> <?php echo _l('Envato:'); ?> </td> <td> <?php echo print_select_box(module_envato::get_envato_items_rel(), 'search[envato_item_id]', isset($search['envato_item_id']) ? $search['envato_item_id'] : ''); ?> </td> <?php } ?> <td class="search_action"> <?php echo create_link("Reset", "reset", module_ticket::link_open(false)); ?> <?php echo create_link("Search", "submit"); ?>
public static function get_ticket($ticket_id, $full = true) { $cache_key_args = func_get_args(); $cache_key = self::_ticket_cache_key($ticket_id, $cache_key_args); $cache_timeout = module_config::c('cache_objects', 60); if ($cached_item = module_cache::get('ticket', $cache_key)) { return $cached_item; } $ticket_access = self::get_ticket_data_access(); $ticket_id = (int) $ticket_id; $ticket = false; if ($ticket_id > 0) { //$ticket = get_single("ticket","ticket_id",$ticket_id); $sql = "SELECT * FROM `" . _DB_PREFIX . "ticket` t WHERE t.ticket_id = {$ticket_id} "; switch ($ticket_access) { case _TICKET_ACCESS_ALL: break; case _TICKET_ACCESS_ASSIGNED: // we only want tickets assigned to me. //$sql .= " AND t.assigned_user_id = '".(int)module_security::get_loggedin_id()."'"; $sql .= " AND (t.assigned_user_id = '" . (int) module_security::get_loggedin_id() . "' OR t.assigned_user_id = 0)"; break; case _TICKET_ACCESS_CREATED: // we only want tickets I created. $sql .= " AND t.user_id = '" . (int) module_security::get_loggedin_id() . "'"; break; case _TICKET_ACCESS_CUSTOMER: $valid_customer_ids = module_security::get_customer_restrictions(); if (is_array($valid_customer_ids) && count($valid_customer_ids)) { $sql .= " AND ( "; foreach ($valid_customer_ids as $valid_customer_id) { $sql .= " t.customer_id = '" . (int) $valid_customer_id . "' OR "; } $sql = rtrim($sql, 'OR '); $sql .= " )"; } break; } $ticket = qa1($sql, false); } if ($full === 2) { module_cache::put('ticket', $cache_key, $ticket, $cache_timeout); return $ticket; } if (!$ticket) { $customer_id = $website_id = 0; $user_id = module_security::get_loggedin_id(); if (isset($_REQUEST['customer_id']) && $_REQUEST['customer_id']) { // $customer_id = (int) $_REQUEST['customer_id']; $customer = module_customer::get_customer($customer_id); if (!$customer || $customer['customer_id'] != $customer_id) { $customer_id = 0; } else { $user_id = $customer['primary_user_id']; } // find default website id to use. if (isset($_REQUEST['website_id'])) { $website_id = (int) $_REQUEST['website_id']; $website = module_website::get_website($website_id); if (!$website || $website['website_id'] != $website_id || $website['customer_id'] != $customer_id) { $website_id = 0; } } else { $website_id = 0; } } $position = self::ticket_position(); $ticket = array('ticket_id' => 'new', 'customer_id' => $customer_id, 'website_id' => $website_id, 'subject' => '', 'date_completed' => '', 'status_id' => _TICKET_STATUS_NEW_ID, 'user_id' => $user_id, 'assigned_user_id' => module_config::c('ticket_default_user_id', 1), 'ticket_account_id' => module_config::c('ticket_default_account_id', 0), 'last_message_timestamp' => 0, 'last_ticket_message_id' => 0, 'message_count' => 0, 'position' => $position['current'] + 1, 'priority' => 0, 'ticket_type_id' => module_config::c('ticket_type_id_default', 0), 'total_pending' => $position['total'] + 1, 'extra_data' => array(), 'invoice_id' => false, 'faq_product_id' => false); } else { // find the position of this ticket // the position is determined by the number of pending tickets // that have a last_message_timestamp earlier than this ticket. $position = self::ticket_position($ticket_id); $ticket['position'] = $position['current']; $ticket['total_pending'] = $position['total']; /*if($ticket['priority'] == _TICKET_PRIORITY_STATUS_ID){ $ticket['position'] = self::ticket_count('priority',$ticket['last_message_timestamp'],$ticket['ticket_id'],$ticket['priority']); }else{ $ticket['position'] = self::ticket_count('pending',$ticket['last_message_timestamp'],$ticket['ticket_id'],$ticket['priority']); } $ticket['total_pending'] = self::ticket_count('pending');*/ $messages = self::get_ticket_messages($ticket_id, true); //$ticket['message_count'] = count($messages); $ticket['message_count'] = mysql_num_rows($messages); //end($messages); if ($ticket['message_count'] > 0) { mysql_data_seek($messages, $ticket['message_count'] - 1); } //$last_message = current($messages); $last_message = mysql_fetch_assoc($messages); $ticket['last_ticket_message_id'] = $last_message['ticket_message_id']; $ticket['last_message_was_private'] = isset($last_message['private_message']) && $last_message['private_message']; // for passwords and website addresses.. $ticket['extra_data'] = self::get_ticket_extras($ticket_id); // hook into the envato module. // link any missing envato/faqproduct items together. if (class_exists('module_envato', false) && isset($_REQUEST['faq_product_envato_hack']) && (!$ticket['faq_product_id'] || $ticket['faq_product_id'] == $_REQUEST['faq_product_envato_hack'])) { $items = module_envato::get_items_by_ticket($ticket['ticket_id']); foreach ($items as $envato_item_id => $item) { // see if this item is linked to a product. if ($item['envato_item_id']) { $sql = "SELECT * FROM `" . _DB_PREFIX . "faq_product` WHERE envato_item_ids REGEXP '[|]*" . $envato_item_id . "[|]*'"; $res = qa1($sql); if ($res && $res['faq_product_id']) { // found a product matching this one. link her up. update_insert('ticket_id', $ticket_id, 'ticket', array('faq_product_id' => $res['faq_product_id'])); break; } } } } } module_cache::put('ticket', $cache_key, $ticket, $cache_timeout); return $ticket; }