コード例 #1
0
 function onAfterRoute()
 {
     $mainframe = JFactory::getApplication();
     if ($mainframe->isAdmin()) {
         return;
     }
     if (!file_exists(JPATH_ROOT . '/components/com_helpdeskpro/helper/helper.php')) {
         return;
     }
     $option = JRequest::getCmd('option', '');
     $task = JRequest::getCmd('task', '');
     if ($option == 'com_contact' && $task == 'contact.submit') {
         require_once JPATH_ROOT . '/components/com_helpdeskpro/helper/helper.php';
         $config = HelpdeskProHelper::getConfig();
         $contactData = JRequest::getVar('jform');
         $data = array();
         $data['name'] = $contactData['contact_name'];
         $data['email'] = $contactData['contact_email'];
         $data['subject'] = $contactData['contact_subject'];
         $data['message'] = nl2br($contactData['contact_message']);
         $data['category_id'] = $this->params->get('category_id');
         $data['priority_id'] = $config->default_ticket_priority_id;
         HelpdeskProHelper::storeTicket($data);
     }
 }
コード例 #2
0
ファイル: tickets.php プロジェクト: AxelFG/ckbran-inf
 function _buildContentWhereArray()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $config = HelpdeskProHelper::getConfig();
     $managedCategoryIds = HelpdeskProHelper::getTicketCategoryIds($user->get('username'));
     $where = parent::_buildContentWhereArray();
     $state = $this->getState();
     if ($state->category_id) {
         $where[] = ' a.category_id = ' . $state->category_id;
     }
     if ($state->status_id) {
         if ($state->status_id == -1) {
             if (!$user->authorise('core.admin')) {
                 if (count($managedCategoryIds)) {
                     //Show open and pending tickets to managers by default
                     $where[] = ' (a.status_id=' . $config->new_ticket_status_id . ' OR a.status_id=' . $config->ticket_status_when_customer_add_comment . ') ';
                 } else {
                     //Show open tickets and require feedback tickets to customers
                     //$where[] = ' (a.status_id='.$config->new_ticket_status_id.' OR a.status_id='.$config->ticket_status_when_admin_add_comment.') ';
                     $where[] = " a.status_id != {$config->closed_ticket_status} ";
                 }
             } else {
                 //Show open and pending tickets to managers by default
                 $where[] = ' (a.status_id=' . $config->new_ticket_status_id . ' OR a.status_id=' . $config->ticket_status_when_customer_add_comment . ') ';
             }
         } else {
             $where[] = ' a.status_id = ' . $state->status_id;
         }
     }
     if ($state->priority_id) {
         $where[] = ' a.priority_id = ' . $state->priority_id;
     }
     if (!$user->authorise('core.admin')) {
         //Super administrator can view all tickets
         if ($managedCategoryIds) {
             //He is ticket managers, so all tickets belong to him
             $where[] = ' a.category_id IN (' . implode(',', $managedCategoryIds) . ')';
         } else {
             //Registered user, only show tickets submitted by himself
             $userId = $user->get('id');
             $email = $user->get('email');
             //				$where[] = "(a.user_id=$userId OR a.email='$email') " ;
             $where[] = ' a.status_id = 4';
         }
     }
     return $where;
 }
コード例 #3
0
ファイル: view.html.php プロジェクト: AxelFG/ckbran-inf
 /**
  * Generate form allows admin creating new ticket
  * @param array $lists
  * @param object $item
  */
 function _buildListArrayForm(&$lists, $item)
 {
     $db =& JFactory::getDbo();
     $config = HelpdeskProHelper::getConfig();
     $db =& JFactory::getDBO();
     $sql = "SELECT id, parent_id, title FROM #__helpdeskpro_categories";
     $db->setQuery($sql);
     $rows = $db->loadObjectList();
     $children = array();
     if ($rows) {
         // first pass - collect children
         foreach ($rows as $v) {
             $pt = $v->parent_id;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('HDP_CHOOSE_CATEGORY'));
     foreach ($list as $listItem) {
         $options[] = JHTML::_('select.option', $listItem->id, '   ' . $listItem->treename);
     }
     $lists['category_id'] = JHTML::_('select.genericlist', $options, 'category_id', array('option.text.toHtml' => false, 'option.text' => 'text', 'option.value' => 'value', 'list.attr' => 'class="inputbox" onchange="showFields(this.form);" ', 'list.select' => $item->category_id));
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('HDP_CHOOSE_PRIORITY'), 'id', 'title');
     $sql = 'SELECT id, title FROM #__helpdeskpro_priorities WHERE published=1 ORDER BY ordering';
     $db->setQuery($sql);
     $rowPriorities = $db->loadObjectList();
     $options = array_merge($options, $rowPriorities);
     $lists['priority_id'] = JHTML::_('select.genericlist', $options, 'priority_id', array('option.text.toHtml' => false, 'option.text' => 'title', 'option.key' => 'id', 'list.attr' => 'class="inputbox" ', 'list.select' => $config->default_ticket_priority_id));
     $categoryId = 0;
     $jcFields = new JCFields();
     if ($jcFields->getTotal()) {
         $customField = true;
         $fieldArray = JCFields::getAssoc();
         $fieldJs = "fields = new Array();\n";
         foreach ($fieldArray as $catId => $fieldList) {
             $fieldJs .= ' fields[' . $catId . '] = new Array("' . implode('","', $fieldList) . '");' . "\n";
         }
         $this->assign('fieldJs', $fieldJs);
         $fields = $jcFields->renderCustomFields($categoryId, $fieldArray);
         $validations = $jcFields->renderJSValidation();
         $this->assign('fields', $fields);
         $this->assign('validations', $validations);
     } else {
         $customField = false;
     }
     $this->assign('customField', $customField);
     $user = JFactory::getUser();
     $this->item = $item;
     $this->config = $config;
 }
コード例 #4
0
ファイル: view.html.php プロジェクト: AxelFG/ckbran-inf
 function _displayForm($tpl)
 {
     $db =& JFactory::getDbo();
     $user = JFactory::getUser();
     $config = HelpdeskProHelper::getConfig();
     $userId = $user->get('id');
     $Itemid = JRequest::getInt('Itemid', 0);
     if (!$userId && !$config->allow_public_user_submit_ticket) {
         //Redirect user to login page
         $return = JRoute::_('index.php?option=com_helpdeskpro&task=ticket.add&Itemid=' . $Itemid);
         JFactory::getApplication()->redirect('index.php?option=com_users&view=login&return=' . base64_encode($return), JText::_('HDP_LOGIN_TO_SUBMIT_TICKET'));
     }
     $db =& JFactory::getDBO();
     $sql = "SELECT id, parent_id, title FROM #__helpdeskpro_categories WHERE published=1 AND access IN (" . implode(',', $user->getAuthorisedViewLevels()) . ')';
     $db->setQuery($sql);
     $rows = $db->loadObjectList();
     $children = array();
     if ($rows) {
         // first pass - collect children
         foreach ($rows as $v) {
             $pt = $v->parent_id;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('HDP_CHOOSE_CATEGORY'));
     foreach ($list as $listItem) {
         $options[] = JHTML::_('select.option', $listItem->id, '   ' . $listItem->treename);
     }
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('HDP_CHOOSE_PRIORITY'), 'id', 'title');
     $sql = 'SELECT id, title FROM #__helpdeskpro_priorities WHERE published=1 ORDER BY ordering';
     $db->setQuery($sql);
     $rowPriorities = $db->loadObjectList();
     $options = array_merge($options, $rowPriorities);
     $lists['category_id'] = JHTML::_('select.genericlist', $options, 'category_id', array('option.text.toHtml' => false, 'option.text' => 'text', 'option.value' => 'value', 'list.attr' => 'class="inputbox" onchange="showFields(this.form);" ', 'list.select' => 0));
     $lists['priority_id'] = JHTML::_('select.genericlist', $options, 'priority_id', array('option.text.toHtml' => false, 'option.text' => 'title', 'option.key' => 'id', 'list.attr' => 'class="inputbox" ', 'list.select' => $config->default_ticket_priority_id));
     $categoryId = 0;
     $jcFields = new JCFields();
     if ($jcFields->getTotal()) {
         $customField = true;
         $fieldArray = JCFields::getAssoc();
         $fieldJs = "fields = new Array();\n";
         foreach ($fieldArray as $catId => $fieldList) {
             $fieldJs .= ' fields[' . $catId . '] = new Array("' . implode('","', $fieldList) . '");' . "\n";
         }
         $this->assign('fieldJs', $fieldJs);
         $fields = $jcFields->renderCustomFields($categoryId, $fieldArray);
         $validations = $jcFields->renderJSValidation();
         $this->assign('fields', $fields);
         $this->assign('validations', $validations);
     } else {
         $customField = false;
     }
     $this->assign('customField', $customField);
     $this->lists = $lists;
     $this->Itemid = $Itemid;
     $this->config = $config;
     $this->userId = $userId;
     $this->lists['category_id'] = $lists['category_id'];
     parent::display($tpl);
 }
コード例 #5
0
ファイル: helpdeskpro.php プロジェクト: AxelFG/ckbran-inf
 /**
  * Replace callback function
  * 
  * @param array $matches
  */
 function _displayForm($matches)
 {
     $document = JFactory::getDocument();
     require_once JPATH_ROOT . '/components/com_helpdeskpro/helper/helper.php';
     require_once JPATH_ROOT . '/components/com_helpdeskpro/helper/fields.php';
     $db =& JFactory::getDbo();
     $user = JFactory::getUser();
     HelpdeskProHelper::loadLanguage();
     $document->addStyleSheet(JURI::base(true) . '/components/com_helpdeskpro/assets/css/style.css');
     if (version_compare(JVERSION, '3.0', 'lt')) {
         HelpdeskProHelper::loadBootstrap();
     }
     $config = HelpdeskProHelper::getConfig();
     $userId = $user->get('id');
     $Itemid = JRequest::getInt('Itemid', 0);
     if (!$userId && !$config->allow_public_user_submit_ticket) {
         //Redirect user to login page
         $return = JRoute::_('index.php?option=com_helpdeskpro&task=ticket.add&Itemid=' . $Itemid);
         JFactory::getApplication()->redirect('index.php?option=com_users&view=login&return=' . base64_encode($return), JText::_('HDP_LOGIN_TO_SUBMIT_TICKET'));
     }
     //Initialize the view object
     $viewConfig = array();
     $viewConfig['name'] = 'form';
     $viewConfig['base_path'] = JPATH_ROOT . '/plugins/content/helpdeskpro';
     $viewConfig['template_path'] = JPATH_ROOT . '/plugins/content/helpdeskpro/tmpl';
     $viewConfig['layout'] = 'form';
     require_once JPATH_ROOT . '/administrator/components/com_helpdeskpro/legacy/view.php';
     $jView = new LegacyView($viewConfig);
     $db =& JFactory::getDBO();
     $sql = "SELECT id, parent_id, title FROM #__helpdeskpro_categories WHERE published=1 AND access IN (" . implode(',', $user->getAuthorisedViewLevels()) . ')';
     $db->setQuery($sql);
     $rows = $db->loadObjectList();
     $children = array();
     if ($rows) {
         // first pass - collect children
         foreach ($rows as $v) {
             $pt = $v->parent_id;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('HDP_CHOOSE_CATEGORY'));
     foreach ($list as $listItem) {
         $options[] = JHTML::_('select.option', $listItem->id, '   ' . $listItem->treename);
     }
     $lists['category_id'] = JHTML::_('select.genericlist', $options, 'category_id', array('option.text.toHtml' => false, 'option.text' => 'text', 'option.value' => 'value', 'list.attr' => 'class="inputbox" onchange="showFields(this.form);" ', 'list.select' => 0));
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('HDP_CHOOSE_PRIORITY'), 'id', 'title');
     $sql = 'SELECT id, title FROM #__helpdeskpro_priorities WHERE published=1 ORDER BY ordering';
     $db->setQuery($sql);
     $rowPriorities = $db->loadObjectList();
     $options = array_merge($options, $rowPriorities);
     $lists['priority_id'] = JHTML::_('select.genericlist', $options, 'priority_id', array('option.text.toHtml' => false, 'option.text' => 'title', 'option.key' => 'id', 'list.attr' => 'class="inputbox" ', 'list.select' => $config->default_ticket_priority_id));
     $categoryId = 0;
     $jcFields = new JCFields();
     if ($jcFields->getTotal()) {
         $customField = true;
         $fieldArray = JCFields::getAssoc();
         $fieldJs = "fields = new Array();\n";
         foreach ($fieldArray as $catId => $fieldList) {
             $fieldJs .= ' fields[' . $catId . '] = new Array("' . implode('","', $fieldList) . '");' . "\n";
         }
         $jView->fieldJs = $fieldJs;
         $fields = $jcFields->renderCustomFields($categoryId, $fieldArray);
         $validations = $jcFields->renderJSValidation();
         $jView->fields = $fields;
         $jView->validations = $validations;
     } else {
         $customField = false;
     }
     $jView->assign('customField', $customField);
     $jView->lists = $lists;
     $jView->Itemid = $Itemid;
     $jView->config = $config;
     $jView->userId = $userId;
     ob_start();
     $jView->display();
     $text = ob_get_contents();
     ob_end_clean();
     return $text;
 }
コード例 #6
0
ファイル: ticket.php プロジェクト: AxelFG/ckbran-inf
 function addComment($data)
 {
     $user = JFactory::getUser();
     $config = HelpdeskProHelper::getConfig();
     if (isset($data['message_id'])) {
         $row = JTable::getInstance('helpdeskpro', 'message');
         if ($data['comment' . $data['message_id']] == '') {
             $row->delete($data['message_id']);
             return true;
         }
         $row->load($data['message_id']);
         $row->message = $data['comment' . $data['message_id']];
         $row->store();
         return true;
     }
     $ticket = JTable::getInstance('helpdeskpro', 'ticket');
     $row = JTable::getInstance('helpdeskpro', 'message');
     $allowedFileTypes = explode('|', $config->allowed_file_types);
     for ($i = 0, $n = count($allowedFileTypes); $i < $n; $i++) {
         $allowedFileTypes[$i] = trim(strtoupper($allowedFileTypes[$i]));
     }
     $row->bind($data);
     $row->message = $data['comment'];
     $ticket->load($row->ticket_id);
     if ($user->id) {
         $row->user_id = $user->get('id');
     } else {
         if (isset($data['ticket_code'])) {
             $row->user_id = $ticket->user_id;
         }
     }
     $row->date_added = gmdate('Y-m-d H:i:s');
     $uploadedFiles = $this->_storeAttachment($allowedFileTypes);
     if (count($uploadedFiles['names'])) {
         $row->attachments = implode('|', $uploadedFiles['names']);
         $row->original_filenames = implode('|', $uploadedFiles['original_names']);
     }
     $row->store();
     if ($row->user_id == $ticket->user_id || isset($data['ticket_code'])) {
         $isCustomerAddComment = true;
     } else {
         $isCustomerAddComment = false;
     }
     //Update ticket status
     if ($isCustomerAddComment) {
         if ($config->ticket_status_when_customer_add_comment) {
             $ticket->status_id = $config->ticket_status_when_customer_add_comment;
         }
     } else {
         if ($config->ticket_status_when_admin_add_comment) {
             $ticket->status_id = $config->ticket_status_when_admin_add_comment;
         }
     }
     $ticket->modified_date = gmdate('Y-m-d H:i:s');
     $ticket->store();
     //Need to send email to users
     if ($isCustomerAddComment) {
         HelpdeskProHelper::sendTicketUpdatedEmailToManagers($row, $ticket, $config);
     } else {
         HelpdeskProHelper::sendTicketUpdatedEmailToCustomer($row, $ticket, $config);
     }
     return true;
 }
コード例 #7
0
ファイル: helper.php プロジェクト: AxelFG/ckbran-inf
 /**
  * Store ticket from input data
  * @param array $data
  */
 public static function storeTicket($data)
 {
     $db = JFactory::getDbo();
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_helpdeskpro/tables');
     jimport('joomla.user.helper');
     $config = HelpdeskProHelper::getConfig();
     $user = JFactory::getUser();
     $row = JTable::getInstance('helpdeskpro', 'ticket');
     $row->bind($data);
     if ($user->get('id')) {
         $row->user_id = $user->get('id');
     } else {
         $sql = 'SELECT id FROM #__users WHERE email="' . $data['email'] . '"';
         $db->setQuery($sql);
         $row->user_id = $db->loadResult();
     }
     $row->status_id = $config->new_ticket_status_id;
     while (true) {
         $ticketCode = strtolower(JUserHelper::genRandomPassword(10));
         $sql = 'SELECT COUNT(*) FROM #__helpdeskpro_tickets WHERE ticket_code="' . $ticketCode . '"';
         $db->setQuery($sql);
         $total = $db->loadResult();
         if (!$total) {
             break;
         }
     }
     $row->ticket_code = $ticketCode;
     $row->created_date = $row->modified_date = gmdate('Y-m-d H:i:s');
     $row->store();
     //Store custom fields information for this ticket
     HelpdeskProHelper::sendNewTicketNotificationEmails($row, $config);
     return true;
 }