Ejemplo n.º 1
0
 function doOpenTicket()
 {
     if (!FSS_Permission::auth("fss.ticket.open", "com_fss.support_user")) {
         return FSS_Helper::NoPerm();
     }
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $userid = $user->get('id');
     $this->userid = $userid;
     $this->email = '';
     $this->admin_create = 0;
     $session = JFactory::getSession();
     if (FSS_Input::getInt('admincreate') > 0) {
         $session->Set("admin_create", FSS_Input::getInt('admincreate'));
         if ($session->Get("admin_create") == 1 && FSS_Input::getInt('user_id') > 0) {
             $session->Set('admin_create_user_id', FSS_Input::getInt('user_id'));
         } else {
             if ($session->Get("admin_create") == 2 && (FSS_Input::getString('admin_create_email') || FSS_Input::getString('admin_create_name'))) {
                 $session->Set('ticket_email', FSS_Input::getEMail('admin_create_email'));
                 $session->Set('ticket_name', FSS_Input::getString('admin_create_name'));
             }
         }
     }
     if ($session->Get("admin_create") == 1) {
         $this->admin_create = 1;
         $model = $this->getModel();
         $this->user = $model->getUser($session->Get('admin_create_user_id'));
     } else {
         if ($session->Get("admin_create") == 2) {
             $this->unreg_email = $session->Get('ticket_email');
             $this->unreg_name = $session->Get('ticket_name');
             $this->admin_create = 2;
         }
     }
     if (FSS_Settings::Get('support_only_admin_open') && $this->admin_create < 1) {
         return $this->noPermission("Access Denied", "CREATING_NEW_TICKETS_BY_USERS_IS_CURRENTLY_DISABLED");
     }
     // store in session and data for an unregistered ticket
     $type = FSS_Input::getCmd('type');
     if ($type == "without") {
         $email = FSS_Input::getEMail('email');
         $name = FSS_Input::getString('name');
         if ($name == "") {
             $name = $email;
         }
         if ($email != "") {
             $session->Set('ticket_email', $email);
             $session->Set('ticket_name', $name);
         }
     }
     if (!$this->ValidateUser('open')) {
         return;
     }
     // defaults for blank ticket
     $ticket['priid'] = FSS_Input::getInt('priid', FSS_Settings::get('support_default_priority'));
     $ticket['body'] = FSS_Input::GetString('body');
     $ticket['subject'] = FSS_Input::GetString('subject');
     $ticket['handler'] = FSS_Input::getInt('handler', 0);
     $this->ticket = $ticket;
     $errors['subject'] = '';
     $errors['body'] = '';
     $errors['cat'] = '';
     $errors['captcha'] = '';
     $this->errors = $errors;
     $prodid = FSS_Input::getInt('prodid');
     // prod id not set, should we display product list???
     if ($prodid < 1) {
         $this->products = $this->get('Products');
         if (count($this->products) > 1) {
             $this->search = "";
             $pagination = $this->get('ProdPagination');
             $this->pagination = $pagination;
             $this->limit = $this->get("ProdLimit");
             parent::display("product");
             return;
         } else {
             if (count($this->products) == 1) {
                 $prodid = $this->products[0]['id'];
                 JRequest::setVar('prodid', $prodid);
                 //echo "Setting prodid to $prodid<br>";
             }
         }
     }
     $this->assign('prodid', $prodid);
     $deptid = FSS_Input::getInt('deptid');
     // dept id not set, should we display department list?
     if ($deptid < 1) {
         $this->search = "";
         $this->depts = $this->get('Departments');
         $this->limit = $this->get("ProdLimit");
         if (count($this->depts) > 1) {
             $this->pagination = $this->get('DeptPagination');
             $this->product = $this->get('Product');
             parent::display("department");
             return;
         } else {
             if (count($this->depts) == 1) {
                 $deptid = $this->depts[0]['id'];
                 JRequest::setVar('deptid', $deptid);
                 //echo "Setting deptid to $deptid<br>";
             }
         }
     }
     $what = FSS_Input::getCmd('what');
     // done with ticket, try and save, if not, display any errors
     if ($what == "add") {
         if ($this->saveTicket()) {
             $message = FSS_Helper::HelpText("support_open_thanks", true);
             if ($message != "") {
                 FSS_Helper::enqueueMessage($message, "success");
             }
             //exit;
             if ($this->admin_create > 0) {
                 $link = 'index.php?option=com_fss&view=admin_support&Itemid=' . FSS_Input::getInt('Itemid', '') . '&ticketid=' . $this->ticketid;
                 $mainframe->redirect(FSSRoute::_($link, false));
             } else {
                 // need to set the session info that will display the ticket to the user here!
                 $link = 'index.php?option=com_fss&view=ticket&layout=view&Itemid=' . FSS_Input::getInt('Itemid', '') . '&ticketid=' . $this->ticketid;
                 $mainframe->redirect(FSSRoute::_($link, false));
             }
             return;
         } else {
             //echo "Error saving ticket<br>";
         }
     }
     // load handlers if required. This depends on what product and department have been selected
     if (FSS_Settings::get('support_choose_handler') != "none") {
         $allow_no_auto = 0;
         if ($this->admin_create > 0) {
             $allow_no_auto = 1;
             $this->autohandlers = SupportUsers::getHandlersTicket($prodid, $deptid, 0);
         }
         $handlers = SupportUsers::getHandlersTicket($prodid, $deptid, 0, $allow_no_auto);
         /**
          * I DONT KNOW IF THIS IS A GOOD CHANGE OR NOT, BUT IT MAKES IT CONSISTANT EVERYWHERE I THINK 
          **/
         // if the hide super users checkbox is tickets, hide them all from the dropdown
         if (FSS_Settings::get('support_hide_super_users')) {
             foreach ($handlers as $offset => $handler) {
                 $fssuser = SupportUsers::getUser($handler);
                 $juser = JFactory::getUser($handler);
                 if ($juser->get('isRoot') && $userid != $juser->id) {
                     unset($handlers[$offset]);
                 }
             }
         }
         if (count($handlers) == 0) {
             $handlers[] = 0;
         }
         $qry = "SELECT * FROM #__users WHERE id IN (" . implode(", ", $handlers) . ")";
         $db = JFactory::getDBO();
         $db->setQuery($qry);
         $handlers = $db->loadAssocList();
         $this->handlers = array();
         $h = array();
         $h['id'] = 0;
         $h['name'] = JText::_('AUTO_ASSIGN');
         $this->handlers[] = $h;
         if (is_array($handlers)) {
             foreach ($handlers as $handler) {
                 $this->handlers[] = $handler;
             }
         }
     }
     $this->assign('deptid', $deptid);
     $this->product = $this->get('Product');
     $this->dept = $this->get('Department');
     $this->cats = $this->get('Cats');
     $this->pris = $this->get('Priorities');
     $this->support_user_attach = FSS_Settings::get('support_user_attach');
     $this->fields = FSSCF::GetCustomFields(0, $prodid, $deptid);
     // load in captch and display if needed
     $this->sortCaptchaType();
     $captcha = new FSS_Captcha();
     $this->captcha = $captcha->GetCaptcha('support_captcha_type');
     parent::display();
 }
Ejemplo n.º 2
0
 function DoPost()
 {
     $this->post['name'] = FSS_Input::getString('name', '');
     $this->post['email'] = FSS_Input::getEMail('email', '');
     $this->post['website'] = FSS_Input::getURL('website', '');
     $this->post['body'] = FSS_Input::getString('body', '');
     $this->post['itemid'] = FSS_Input::getInt('itemid', 0);
     $this->post['ident'] = FSS_Input::getInt('ident', 0);
     $published = 1;
     if ($this->moderate) {
         $published = 0;
     }
     $captcha = new FSS_Captcha();
     $this->valid = 1;
     if ($this->post['name'] == "") {
         $this->errors['name'] = JText::_("YOU_MUST_ENTER_A_NAME");
         $this->valid = 0;
     }
     if ($this->use_email && $this->post['email'] != "" && !JMailHelper::isEmailAddress($this->post['email'])) {
         $this->errors['email'] = JText::_("INVALID_EMAIL_ADDRESS_ENTERED");
         $this->valid = 0;
     }
     if ($this->use_website && $this->post['website'] != "" && 0) {
         $this->errors['website'] = JText::_("INVALID_WEBSITE_ADDRESS_ENTERED");
         $this->valid = 0;
     }
     if ($this->post['body'] == "") {
         $this->errors['body'] = JText::_("YOU_MUST_ENTER_A_COMMENT_TO_POST");
         $this->valid = 0;
     }
     if ($this->handler->item_select_must_have) {
         if ($this->post['itemid'] == 0) {
             $this->errors['itemid'] = JText::_("YOU_MUST_SELECT_A") . $this->handler->email_article_type;
             $this->valid = 0;
         }
     }
     if (!$captcha->ValidateCaptcha()) {
         $this->errors['captcha'] = JText::_("INVALID_SECURITY_CODE");
         $this->valid = 0;
     }
     if (!FSSCF::ValidateFields($this->customfields, $this->errors)) {
         $this->valid = 0;
     }
     $output['valid'] = $this->valid;
     if ($this->valid == 1) {
         $db = JFactory::getDBO();
         $user = JFactory::getUser();
         $userid = $user->id;
         $custom = FSSCF::Comm_StoreFields($this->customfields);
         $custom = serialize($custom);
         $now = FSS_Helper::CurDate();
         $qry = "INSERT INTO " . $this->table . " (ident, itemid, name, email, website, body, published, created, userid, custom) VALUES (";
         $qry .= $this->post['ident'];
         $qry .= " , " . $this->post['itemid'];
         $qry .= " , '" . FSSJ3Helper::getEscaped($db, $this->post['name']);
         $qry .= "' , '" . FSSJ3Helper::getEscaped($db, $this->post['email']);
         $qry .= "' , '" . FSSJ3Helper::getEscaped($db, $this->post['website']);
         $qry .= "' , '" . FSSJ3Helper::getEscaped($db, $this->post['body']);
         $qry .= "' , {$published}, '{$now}', '" . FSSJ3Helper::getEscaped($db, $userid) . "', '" . FSSJ3Helper::getEscaped($db, $custom) . "' )";
         $db->SetQuery($qry);
         $db->Query();
         $this->comment = $this->post;
         $this->comment['id'] = $db->insertid();
         $this->comment['ident'] = $this->post['ident'];
         foreach ($this->customfields as $id => $field) {
             $this->comment["custom_{$id}"] = FSS_Input::getString("custom_{$id}", "");
             JRequest::setVar("custom_{$id}", '');
         }
         FSS_EMail::Send_Comment($this);
         //print_r($output);
         //exit();
         //ob_clean();
         //print_p($this);
         if ($this->moderate) {
             $this->comment['published'] = 0;
             include $this->tmplpath . DS . 'moderate.php';
         } else {
             if ($this->opt_show_posted_message_only) {
                 $this->comment['published'] = 0;
                 include $this->tmplpath . DS . 'thanks.php';
             } else {
                 $this->comment['published'] = 1;
                 include $this->tmplpath . DS . 'thanks.php';
                 include $this->tmplpath . DS . 'comment.php';
             }
         }
         $output['comment'] = ob_get_contents();
         if ($this->opt_display) {
             if ($this->opt_order == 0) {
                 $output['display'] = 'before';
             } else {
                 $output['display'] = 'after';
             }
         } else {
             $output['display'] = 'none';
         }
         if ($this->opt_show_posted_message_only) {
             $output['display'] = "replace";
         }
         $this->post['name'] = $this->GetName();
         $this->post['email'] = '';
         $this->post['website'] = '';
         $this->post['body'] = '';
         $this->post['created'] = 'now';
         if ($this->opt_show_form_after_post) {
             ob_clean();
             $this->captcha = $captcha->GetCaptcha();
             include $this->tmplpath . DS . 'addcomment.php';
             $output['form'] = ob_get_contents();
             $output['form_display'] = "replace";
         } else {
             $output['form'] = '';
             $output['form_display'] = "";
             if ($this->opt_form_clear_comment) {
                 $output['form_display'] = "clear_comment";
             }
         }
         ob_clean();
         echo json_encode($output);
         exit;
     } else {
         $output['display'] = 'none';
         $output['form_display'] = "replace";
         ob_clean();
         $this->comment = $this->post;
         include $this->tmplpath . DS . 'comment.php';
         $output['comment'] = ob_get_contents();
         ob_clean();
         $this->captcha = $captcha->GetCaptcha();
         include $this->tmplpath . DS . 'addcomment.php';
         $output['form'] = ob_get_contents();
         ob_clean();
         echo json_encode($output);
         exit;
     }
     return true;
 }