function out()
 {
     $current_user = JFactory::getUser()->id;
     $manager = FSS_Permission::auth("fss.ticket_admin.ooo", "com_fss.support_admin", JFactory::getUser()->id);
     $user_id = FSS_Input::getInt('user_id');
     if (!$manager && $current_user != $user_id) {
         return $this->cancel();
     }
     // update the current users setting
     $values = SupportUsers::getAllSettings($user_id);
     $values->out_of_office = 1;
     SupportUsers::updateUserSettings($values, $user_id);
     $assign = FSS_Input::getCmd('assign');
     $handler = FSS_Input::getInt('handler');
     $body = FSS_Input::getHTML('body');
     if ($assign == "auto" || $assign == "handler") {
         $this->loadTicketList($user_id);
         foreach ($this->tickets->tickets as $ticket) {
             if ($assign == "auto") {
                 $handler = FSS_Ticket_Helper::AssignHandler($ticket->prod_id, $ticket->ticket_dept_id, $ticket->ticket_cat_id, true);
             }
             if ($assign == "unassigned") {
                 $handler = 0;
             }
             $ticket->assignHandler($handler);
             if ($body) {
                 $ticket->addMessage($body, "", $user_id, TICKET_MESSAGE_PRIVATE);
                 FSS_EMail::Admin_Forward($ticket, $ticket->title, $body);
             }
         }
     }
     JFactory::getApplication()->redirect(FSSRoute::_("index.php?option=com_fss&view=admin_support&layout=listhandlers", false));
 }
Exemple #2
0
 function resend_all_passwords()
 {
     $this->loadTicket();
     $email = $this->ticket->email;
     $tickets = new SupportTickets();
     $tickets->limitstart = 0;
     $tickets->limit = 500;
     $tickets->loadTicketsByQuery(array("t.email = '{$email}'"), "lastupdate DESC");
     FSS_EMail::User_Unreg_Passwords($tickets->tickets);
     $link = FSSRoute::_("index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=" . $this->ticket->id, false);
     JFactory::getApplication()->redirect($link, JText::_("PASSWORDS_FOR_ALL_THIS_USERS_TICKETS_HAVE_BEEN_SENT"));
     return false;
 }
Exemple #3
0
 function Unreg_Passlist()
 {
     $email = FSS_Input::getEMail('email');
     if ($email == "") {
         $email = FSS_Input::getEMail('reference');
     }
     $tickets = new SupportTickets();
     $tickets->limitstart = 0;
     $tickets->limit = 500;
     $tickets->loadTicketsByQuery(array("t.email = '{$email}'"), "lastupdate DESC");
     if ($tickets->ticket_count > 0) {
         FSS_EMail::User_Unreg_Passwords($tickets->tickets);
         $link = FSSRoute::_("index.php?option=com_fss&view=ticket", false);
         JFactory::getApplication()->redirect($link, JText::sprintf("A_LIST_OF_YOUR_TICKETS_AND_PASSWORDS_HAS_BEEN_SENT_TO_YOU", $email));
     } else {
         $link = FSSRoute::_("index.php?option=com_fss&view=ticket", false);
         JFactory::getApplication()->redirect($link, JText::sprintf("UNABLE_TO_FIND_ANY_TICKETS_FOR_EMAIL", $email));
     }
 }
Exemple #4
0
 static function &ParseTemplate($template, &$ticket, $subject, $body, $ishtml, $foruser = false)
 {
     $handler = self::GetHandler($ticket['admin_id'], $template['tmpl']);
     $custrec = self::GetUser($ticket['user_id']);
     $subject = trim(str_ireplace("re:", "", $subject));
     $vars[] = self::BuildVar('subject', $subject);
     $body = FSS_Helper::ParseBBCode($body, null, false, false, $foruser);
     $body = str_replace("<", "XXXLTXXX", $body);
     $body = str_replace(">", "XXXGTXXX", $body);
     $vars[] = self::BuildVar('body', $body);
     $vars[] = self::BuildVar('reference', $ticket['reference']);
     $vars[] = self::BuildVar('password', $ticket['password']);
     foreach (self::$extra_vars as $key => $value) {
         $vars[] = self::BuildVar($key, $value);
     }
     if ($ticket['user_id'] == 0) {
         $vars[] = self::BuildVar('user_name', $ticket['unregname']);
         $vars[] = self::BuildVar('user_username', JText::_("UNREGISTERED"));
         $vars[] = self::BuildVar('user_email', $ticket['email']);
     } else {
         $vars[] = self::BuildVar('user_name', $custrec['name']);
         $vars[] = self::BuildVar('user_username', $custrec['username']);
         $vars[] = self::BuildVar('user_email', $custrec['email']);
     }
     $vars[] = self::BuildVar('handler_name', $handler['name']);
     $vars[] = self::BuildVar('handler_username', $handler['username']);
     $vars[] = self::BuildVar('handler_email', $handler['email']);
     $vars[] = self::BuildVar('ticket_id', $ticket['id']);
     if ($foruser) {
         $statuss = SupportHelper::getStatuss(false);
         $status = $statuss[$ticket['ticket_status_id']];
         if ($status->combine_with > 0) {
             $status = $statuss[$status->combine_with];
         }
         FSS_Translate_Helper::TrO($status);
         $text = $status->title;
         if ($status->userdisp) {
             $text = $status->userdisp;
         }
         $vars[] = self::BuildVar('status', $text);
     } else {
         $vars[] = self::BuildVar('status', self::GetStatus($ticket['ticket_status_id']));
     }
     $vars[] = self::BuildVar('priority', self::GetPriority($ticket['ticket_pri_id']));
     $vars[] = self::BuildVar('category', self::GetCategory($ticket['ticket_cat_id']));
     $vars[] = self::BuildVar('department', self::GetDepartment($ticket['ticket_dept_id']));
     $vars[] = self::BuildVar('department_desc', strip_tags(self::GetDepartment($ticket['ticket_dept_id'], 'description')));
     $vars[] = self::BuildVar('department_desc_html', self::GetDepartment($ticket['ticket_dept_id'], 'description'));
     $vars[] = self::BuildVar('product', self::GetProduct($ticket['prod_id']));
     $vars[] = self::BuildVar('product_desc', strip_tags(self::GetProduct($ticket['prod_id'], 'description')));
     $vars[] = self::BuildVar('product_desc_html', self::GetProduct($ticket['prod_id'], 'description'));
     if (strpos($template['body'], "{messagehistory}") > 0) {
         $messages = self::GetMessageHist($ticket['id']);
         $text = self::ParseMessageRows($messages, $ishtml, $foruser);
         $vars[] = self::BuildVar('messagehistory', $text);
     }
     $uri = JURI::getInstance();
     $baseUrl = FSS_Settings::get('support_email_no_domain') ? "" : $uri->toString(array('scheme', 'host', 'port'));
     if (in_array(FSS_Settings::get('support_unreg_type'), array(0, 1))) {
         $vars[] = self::BuildVar('haspassword', 1);
     } else {
         $vars[] = self::BuildVar('haspassword', 0);
     }
     // choose which user link to generate
     if ($ticket['user_id'] < 1) {
         // unregistered user
         $url = 'index.php?option=com_fss&t=' . $ticket['id'] . "&p=" . $ticket['password'];
         if (FSS_Settings::get('support_email_link_unreg') > 0) {
             // add fixed item id if needed
             $url .= "&Itemid=" . FSS_Settings::get('support_email_link_unreg');
         }
         $vars[] = self::BuildVar('ticket_link', $baseUrl . JRoute::_($url, false));
     } else {
         // registered user
         $url = 'index.php?option=com_fss&view=ticket&layout=view&ticketid=' . $ticket['id'];
         if (FSS_Settings::get('support_email_include_autologin')) {
             $url .= "&login={login_code}";
         }
         if (FSS_Settings::get('support_email_link_reg') > 0) {
             // add fixed item id if needed
             $url .= "&Itemid=" . FSS_Settings::get('support_email_link_reg');
         }
         $vars[] = self::BuildVar('ticket_link', $baseUrl . JRoute::_($url, false));
     }
     // ticket admin link
     $url = 'index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticket['id'];
     if (FSS_Settings::get('support_email_link_admin') > 0) {
         // add fixed item id if needed
         $url .= "&Itemid=" . FSS_Settings::get('support_email_link_admin');
     }
     $vars[] = self::BuildVar('admin_link', $baseUrl . JRoute::_($url, false));
     // email pending link
     $url = 'index.php?option=com_fss&view=admin_support&layout=emails';
     if (FSS_Settings::get('support_email_link_pending') > 0) {
         // add fixed item id if needed
         $url .= "&Itemid=" . FSS_Settings::get('support_email_link_pending');
     }
     $vars[] = self::BuildVar('email_pending_link', $baseUrl . JRoute::_($url, false));
     $vars[] = self::BuildVar('websitetitle', FSS_Helper::getSiteName());
     // need to add the tickets custom fields to the output here
     $fields = FSSCF::GetAllCustomFields(true);
     $values = FSSCF::GetTicketValues($ticket['id'], $ticket);
     foreach ($fields as $fid => &$field) {
         $name = "custom_" . $fid;
         $value = "";
         if (array_key_exists($fid, $values)) {
             $value = (string) $values[$fid]['value'];
         }
         $fieldvalues = array();
         $fieldvalues[0]['field_id'] = $fid;
         $fieldvalues[0]['value'] = $value;
         // only do area output processing if we are in html mode
         if ($field['type'] != "area" || $ishtml) {
             $newvalue = FSSCF::FieldOutput($field, $fieldvalues, '');
             if ($newvalue) {
                 $value = $newvalue;
             }
         }
         $vars[] = self::BuildVar($name, $value);
         $vars[] = self::BuildVar("custom_" . $field['alias'], $value);
     }
     $email['subject'] = self::ParseText($template['subject'], $vars);
     $email['body'] = self::ParseText($template['body'], $vars);
     self::$last_vars = $vars;
     if ($template['ishtml']) {
         $email['body'] = FSS_Helper::MaxLineLength($email['body']);
     } else {
         $email['body'] = str_replace("<br />", "\n", $email['body']);
         $email['body'] = html_entity_decode($email['body']);
         $email['body'] = preg_replace_callback("/(&#[0-9]+;)/", array("FSS_Helper", "email_decode_utf8"), $email['body']);
         $email['body'] = strip_tags($email['body']);
     }
     $email['body'] = str_replace("XXXLTXXX", "<", $email['body']);
     $email['body'] = str_replace("XXXGTXXX", ">", $email['body']);
     return $email;
 }
Exemple #5
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;
 }
Exemple #6
0
 function User_Reply($ticket, $params)
 {
     if ($params['user_message']) {
         FSS_EMail::User_Reply($ticket, $params['subject'], $params['user_message'], $params['files']);
     }
 }
Exemple #7
0
 function Execute($aparams)
 {
     $debug = 0;
     $this->Log("Auto closing tickets");
     $db = JFactory::getDBO();
     $can_close = FSS_Ticket_Helper::GetStatusIDs('can_autoclose');
     $def_close = FSS_Ticket_Helper::GetStatusID('def_closed');
     if ($debug) {
         $this->Log("Can Close : " . implode(", ", $can_close));
     }
     if ($debug) {
         $this->Log("Close To : " . $def_close);
     }
     $now = FSS_Helper::CurDate();
     // if no audit log to be created, then can just close all tickets in a single query, this is quicker!
     if (!$aparams['addaudit'] && !$aparams['emailuser']) {
         if ($debug) {
             echo "No audit required, just closing<br>";
         }
         $qry = "UPDATE #__fss_ticket_ticket SET closed = '{$now}', ticket_status_id = {$def_close} WHERE DATE_ADD(`lastupdate` ,INTERVAL " . FSSJ3Helper::getEscaped($db, $aparams['closeinterval']) . " DAY) < '{$now}' AND ticket_status_id IN (" . implode(", ", $can_close) . ")";
         $db->setQuery($qry);
         $db->Query();
         // UNCOMMENT
         $rows = $db->getAffectedRows();
         if ($debug) {
             $this->Log($qry);
         }
         // COMMENT
         $this->Log("Auto closed {$rows} tickets");
         return;
     }
     $qry = "SELECT * FROM #__fss_ticket_ticket WHERE DATE_ADD(`lastupdate` ,INTERVAL " . FSSJ3Helper::getEscaped($db, $aparams['closeinterval']) . " DAY) < '{$now}' AND ticket_status_id IN (" . implode(", ", $can_close) . ")";
     $db->setQuery($qry);
     if ($debug) {
         $this->Log($qry);
     }
     $rows = $db->loadAssocList();
     $this->Log("Found " . count($rows) . " tickets to close");
     if (count($rows) == 0) {
         return;
     }
     $ids = array();
     $auditrows = array();
     foreach ($rows as $row) {
         $ids[] = FSSJ3Helper::getEscaped($db, $row['id']);
         if ($aparams['addaudit']) {
             // add audit log to the ticket
             $auditqry[] = "(" . FSSJ3Helper::getEscaped($db, $row['id']) . ", 'Audit Message', 'Ticket auto-closed after " . FSSJ3Helper::getEscaped($db, $aparams['closeinterval']) . " days of inactivity', 0, 3, '{$now}')";
         }
         if ($aparams['emailuser']) {
             FSS_EMail::Admin_AutoClose($row);
         }
     }
     if ($aparams['addaudit']) {
         $qry = "INSERT INTO #__fss_ticket_messages (ticket_ticket_id, subject, body, user_id, admin, posted) VALUES \n";
         $qry .= implode(",\n ", $auditqry);
         if ($debug) {
             $this->Log("Saving Audit Messages");
         }
         if ($debug) {
             $this->Log($qry);
         }
         $db->setQuery($qry);
         $db->Query();
     }
     $qry = "UPDATE #__fss_ticket_ticket SET closed = '{$now}', ticket_status_id = {$def_close} WHERE id IN (" . implode(", ", $ids) . ")";
     if ($debug) {
         $this->Log("Closing Tickets");
     }
     if ($debug) {
         $this->Log($qry);
     }
     $db->setQuery($qry);
     $db->Query();
     $this->Log("Closed " . count($rows) . " tickets");
     /*echo "<pre style='background-color:white;'>";
     		echo $qry;
     		echo "</pre>";*/
 }
 function DoTicketReply($ticketid, $userid, $isadmin, &$messageid)
 {
     $db = JFactory::getDBO();
     $subject = $this->subject;
     $body = $this->plainmsg;
     $now = FSS_Helper::CurDate();
     if ($body) {
         $qry = "INSERT INTO #__fss_ticket_messages (ticket_ticket_id, subject, body, user_id, admin, posted) VALUES ('";
         $qry .= FSSJ3Helper::getEscaped($db, $ticketid) . "','" . FSSJ3Helper::getEscaped($db, $subject) . "','" . FSSJ3Helper::getEscaped($db, $body) . "','" . FSSJ3Helper::getEscaped($db, $userid) . "', '" . FSSJ3Helper::getEscaped($db, $isadmin) . "', '{$now}')";
         $db->setQuery($qry);
         $db->Query();
         $messageid = $db->insertid();
         $qry = "SELECT ticket_status_id FROM #__fss_ticket_ticket WHERE id = '" . FSSJ3Helper::getEscaped($db, $ticketid) . "'";
         $db->setQuery($qry);
         $status = $db->loadAssoc();
         if ($isadmin) {
             $newstatus = FSS_Ticket_Helper::GetStatusID('def_admin');
         } else {
             $newstatus = FSS_Ticket_Helper::GetStatusID('def_user');
         }
         if ($newstatus > 0) {
             $qry = "UPDATE #__fss_ticket_ticket SET ticket_status_id = '" . FSSJ3Helper::getEscaped($db, $newstatus) . "', closed = NULL WHERE id = '" . FSSJ3Helper::getEscaped($db, $ticketid) . "'";
         } else {
             $qry = "UPDATE #__fss_ticket_ticket SET closed = NULL WHERE id = '" . FSSJ3Helper::getEscaped($db, $ticketid) . "'";
         }
         $db->setQuery($qry);
         $db->Query();
         if ($newstatus > 0) {
             $oldstatus = $this->GetStatus($status['ticket_status_id']);
             $newstatus = $this->GetStatus($newstatus);
             $this->AddTicketAuditNote($ticketid, "Status changed from '" . $oldstatus['title'] . "' to '" . $newstatus['title'] . "'", $userid);
         }
     }
     $qry = "UPDATE #__fss_ticket_ticket SET lastupdate = '{$now}' WHERE id = '" . FSSJ3Helper::getEscaped($db, $ticketid) . "'";
     $db->setQuery($qry);
     $db->Query();
     $ticket = $this->getTicket($ticketid);
     if ($isadmin) {
         FSS_EMail::Admin_Reply($ticket, $subject, $body, array());
     } else {
         FSS_EMail::User_Reply($ticket, $subject, $body, array());
     }
 }
Exemple #9
0
 function ticket_status_id()
 {
     // update status in ticket
     // redirect if the config is set to
     $ticketid = FSS_Input::getInt('ticketid');
     $ticket_status_id = FSS_Input::getInt('ticket_status_id');
     if ($ticketid < 1) {
         exit;
     }
     if ($ticket_status_id < 1) {
         exit;
     }
     $link = FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticketid, false);
     // check permission for new status
     $statuss = SupportHelper::getStatuss();
     $new_status = $statuss[$ticket_status_id];
     if ($new_status->is_closed && !$this->view->can_Close()) {
         JFactory::getApplication()->redirect($link);
         exit;
     }
     $ticket = new SupportTicket();
     if ($ticket->Load($ticketid)) {
         $old_st = $ticket->getStatus();
         $ticket->updateStatus($ticket_status_id);
         $new_st = $ticket->getStatus();
         // if we have closed the ticket, and return on close is set, then we should do a redirect dependant on the setting
         if ($new_st->is_closed && SupportUsers::getSetting("return_on_close")) {
             $link = SupportHelper::parseRedirectType($old_st->id, SupportUsers::getSetting("return_on_close"));
         }
         if ($new_st->is_closed && !$old_st->is_closed) {
             // SEND CLOSED EMAIL HERE!
             if (!FSS_Settings::get('support_email_on_close_no_dropdown')) {
                 FSS_EMail::Admin_Close($ticket, $ticket->title, '', array());
             }
         }
     }
     JFactory::getApplication()->redirect($link);
     exit;
 }