示例#1
0
 function SaveLog()
 {
     $db = JFactory::getDBO();
     $class = get_class($this);
     $class = str_ireplace("FSSCron", "", $class);
     $now = FSS_Helper::CurDate();
     $qry = "INSERT INTO #__fss_cron_log (cron, `when`, log) VALUES ('" . FSSJ3Helper::getEscaped($db, $class) . "', '{$now}', '" . FSSJ3Helper::getEscaped($db, $this->_log) . "')";
     $db->SetQuery($qry);
     $db->Query();
     //echo $qry."<br>";
     $qry = "DELETE FROM #__fss_cron_log WHERE `when` < DATE_SUB('{$now}', INTERVAL " . (int) FSS_Settings::get('support_cronlog_keep') . " DAY)";
     $db->SetQuery($qry);
     $db->Query();
 }
示例#2
0
 function Save()
 {
     $db = JFactory::getDBO();
     $this->item = array();
     $this->item['id'] = FSS_Input::getInt('id', 0);
     $user = JFactory::getUser();
     $userid = $user->get('id');
     $this->errors = array();
     $ok = true;
     foreach ($this->edit as $edit) {
         $field = $this->GetField($edit);
         $this->item[$field->field] = FSS_Input::getString($field->input_name, '');
         if ($field->type == "text") {
             $this->item[$field->field] = FSS_Input::getHTML($field->input_name, '');
         }
         if ($field->more) {
             if (strpos($this->item[$field->field], "system-readmore") > 0) {
                 $pos = strpos($this->item[$field->field], "system-readmore");
                 $top = substr($this->item[$field->field], 0, $pos);
                 $top = substr($top, 0, strrpos($top, "<"));
                 $bottom = substr($this->item[$field->field], $pos);
                 $bottom = substr($bottom, strpos($bottom, ">") + 1);
                 $this->item[$field->field] = $top;
                 $this->item[$field->more] = $bottom;
             } else {
                 $this->item[$field->more] = '';
             }
         }
         if ($field->required) {
             if ($this->item[$field->field] == "") {
                 $ok = false;
                 $this->errors[$field->field] = $field->required;
             }
         }
     }
     $now = FSS_Helper::CurDate();
     // if errors
     if ($ok) {
         if ($this->item['id']) {
             $qry = "UPDATE " . $this->table . " SET ";
             $sets = array();
             foreach ($this->edit as $edit) {
                 $field = $this->GetField($edit);
                 if ($field->type != "related" && $field->type != "tags") {
                     $sets[] = $field->field . " = '" . FSSJ3Helper::getEscaped($db, $this->item[$field->field]) . "'";
                 }
                 if ($field->more) {
                     $sets[] = "`" . $field->more . "` = '" . FSSJ3Helper::getEscaped($db, $this->item[$field->more]) . "'";
                 }
             }
             if (FSS_Permission::auth("core.edit.state", $this->getAsset())) {
                 $sets[] = "published = " . FSS_Input::getInt('published', 0);
                 if ($this->has_author) {
                     $sets[] = "author = " . FSS_Input::getInt('author', 0);
                 }
             }
             if ($this->has_modified) {
                 $sets[] = "modified = '{$now}'";
             }
             $qry .= implode(", ", $sets);
             $qry .= " WHERE id = '" . FSSJ3Helper::getEscaped($db, $this->item['id']) . "'";
         } else {
             $fieldlist = array();
             if ($this->has_author) {
                 $fieldlist[] = "author";
             }
             if ($this->has_added) {
                 $fieldlist[] = "added";
             }
             $setlist = array();
             foreach ($this->edit as $edit) {
                 $field = $this->GetField($edit);
                 if ($field->type == "related" || $field->type == "tags") {
                     continue;
                 }
                 $fieldlist[] = $field->field;
                 $setlist[] = "'" . FSSJ3Helper::getEscaped($db, $this->item[$field->field]) . "'";
                 if ($field->more) {
                     $fieldlist[] = "`" . $field->more . "`";
                     $setlist[] = "'" . FSSJ3Helper::getEscaped($db, $this->item[$field->more]) . "'";
                 }
             }
             if ($this->has_modified) {
                 $fieldlist[] = "modified";
                 $setlist[] = "'{$now}'";
                 $fieldlist[] = "created";
                 $setlist[] = "'{$now}'";
             }
             $fieldlist[] = "published";
             if (FSS_Permission::auth("core.edit.state", $this->getAsset())) {
                 $setlist[] = FSS_Input::getInt('published', 0);
             } else {
                 $setlist[] = "0";
             }
             if ($this->has_ordering) {
                 // need to get ordering value
                 $order = $this->GetOrderValue();
                 if ($order < 1) {
                     $order = 1;
                 }
                 $fieldlist[] = "ordering";
                 $setlist[] = $order;
             }
             $qry = "INSERT INTO " . $this->table . " (" . implode(", ", $fieldlist) . ") VALUES (";
             if ($this->has_author) {
                 $qry .= "'{$userid}', ";
             }
             if ($this->has_added) {
                 $qry .= "'{$now}', ";
             }
             $qry .= implode(", ", $setlist) . ")";
         }
         $db->setQuery($qry);
         $db->query($qry);
         if (!$this->item['id']) {
             $this->item['id'] = $db->insertid();
         }
         $this->articleid = $this->item['id'];
         foreach ($this->edit as $edit) {
             $field = $this->GetField($edit);
             // save any products fields
             if ($field->type == "products") {
                 $this->GetProducts();
                 $qry = "DELETE FROM {$field->prod_table} WHERE {$field->prod_artid} = '" . FSSJ3Helper::getEscaped($db, $this->item['id']) . "'";
                 $db->setQuery($qry);
                 //echo $qry."<br>";
                 $db->query($qry);
                 if (!$this->item[$field->field]) {
                     foreach ($this->products as &$product) {
                         $pid = $product->id;
                         $name = $field->field . "_prod_" . $pid;
                         $val = FSS_Input::getString($name);
                         if ($val == "on") {
                             $qry = "INSERT INTO {$field->prod_table} ({$field->prod_prodid}, {$field->prod_artid}) VALUES\n\t\t\t\t\t\t\t\t\t({$pid}, '" . FSSJ3Helper::getEscaped($db, $this->item['id']) . "')";
                             $db->setQuery($qry);
                             //echo $qry."<br>";
                             $db->query($qry);
                         }
                     }
                     //echo "Saving products<br>";
                 }
                 //echo "Prod Field";
             } elseif ($field->type == "related") {
                 // save related field
                 $relids = explode(":", $this->item[$field->field]);
                 $qry1 = "DELETE FROM {$field->rel_table} WHERE {$field->rel_id} = '" . FSSJ3Helper::getEscaped($db, $this->item['id']) . "'";
                 $db->setQuery($qry1);
                 //echo $qry1."<br>";
                 $db->query();
                 foreach ($relids as $id) {
                     $id = FSSJ3Helper::getEscaped($db, $id);
                     $qry1 = "REPLACE INTO {$field->rel_table} ({$field->rel_id}, {$field->rel_relid}) VALUES ('" . FSSJ3Helper::getEscaped($db, $this->item['id']) . "', '{$id}')";
                     $db->setQuery($qry1);
                     //echo $qry1."<br>";
                     $db->query();
                 }
             } else {
                 if ($field->type == "tags") {
                     //print_p($field);
                     //print_p($this->item);
                     $qry1 = "DELETE FROM {$field->tags_table} WHERE {$field->tags_key} = '" . FSSJ3Helper::getEscaped($db, $this->item['id']) . "'";
                     //echo $qry1 . "<br>";
                     $db->setQuery($qry1);
                     $db->query();
                     $tags = explode("\n", $this->item[$field->field]);
                     foreach ($tags as $tag) {
                         $tag = trim($tag);
                         if (!$tag) {
                             continue;
                         }
                         $qry1 = "REPLACE INTO {$field->tags_table} ({$field->tags_key}, tag, language) VALUES (\t'" . FSSJ3Helper::getEscaped($db, $this->item['id']) . "', ";
                         $qry1 .= "'" . FSSJ3Helper::getEscaped($db, $tag) . "', '" . FSSJ3Helper::getEscaped($db, $this->item['language']) . "')";
                         //echo $qry1 . "<br>";
                         $db->setQuery($qry1);
                         $db->query();
                     }
                     //exit;
                 }
             }
         }
         // need to check for a redirect field here
         $mainframe = JFactory::getApplication();
         if ($this->what == "apply") {
             $link = FSSRoute::_("index.php?option=com_fss&view=admin_content&type={$this->id}&what=edit&id={$this->articleid}", false);
         } elseif ($this->what == "savenew") {
             $link = FSSRoute::_("index.php?option=com_fss&view=admin_content&type={$this->id}&what=new", false);
         } else {
             $link = FSSRoute::_('index.php?option=com_fss&view=admin_content&type=' . $this->id, false);
             $return = FSS_Input::getString('return', '');
             if ($return && $return != 1) {
                 $link = $return;
             }
         }
         $mainframe->redirect($link, JText::_('ARTICLE_SAVED'));
         return;
     } else {
         // need to put onto the form the field stuff for related and products fields
         foreach ($this->edit as $edit) {
             $field = $this->GetField($edit);
             if ($field->type == "related") {
                 $field->rel_ids = array();
                 $relids = FSS_Input::getString($field->field);
                 $relateds = explode(":", $relids);
                 foreach ($relateds as $related) {
                     if ($related == 0) {
                         continue;
                     }
                     $field->rel_ids[$related] = $related;
                 }
                 $field->rel_id_list = implode(":", $field->rel_ids);
                 if (count($field->rel_ids) > 0) {
                     $ids = array();
                     foreach ($field->rel_ids as $id) {
                         $ids[] = FSSJ3Helper::getEscaped($db, $id);
                     }
                     $qry = "SELECT {$field->rel_lookup_id}, {$field->rel_display} FROM {$field->rel_lookup_table} WHERE {$field->rel_lookup_id} IN (" . implode(", ", $ids) . ")";
                     ///					$qry = "SELECT {$field->rel_lookup_id}, {$field->rel_lookup_display} FROM {$field->rel_lookup_table} WHERE {$field->rel_lookup_id} IN (" . implode(", ", $field->rel_ids) . ")";
                     $db->setQuery($qry);
                     $relateds = $db->loadAssocList($field->rel_lookup_id);
                     foreach ($relateds as $id => &$related) {
                         $field->rel_ids[$id] = $related[$field->rel_lookup_display];
                     }
                 }
                 if (!$this->added_related_js) {
                     $this->AddRelatedJS();
                 }
             } else {
                 if ($field->type == "products") {
                     $this->GetProducts();
                     $field->products = array();
                     $prodcheck = "";
                     foreach ($this->products as $product) {
                         $prodform = FSS_Input::getString($field->field . "_prod_" . $product->id);
                         if ($prodform == "on") {
                             $prodcheck .= '<label class="checkbox">';
                             $prodcheck .= "<input type='checkbox' name='{$field->field}_prod_" . $product->id . "' checked />" . $product->title;
                             $prodcheck .= '</label>';
                         } else {
                             $prodcheck .= '<label class="checkbox">';
                             $prodcheck .= "<input type='checkbox' name='{$field->field}_prod_" . $product->id . "' />" . $product->title;
                             $prodcheck .= '</label>';
                         }
                     }
                     $field->products_check = $prodcheck;
                     $field->products_yesno = JHTML::_('select.booleanlist', $field->field, array('class' => "inputbox", 'size' => "1", 'onclick' => "DoAllProdChange('{$field->field}');"), $this->item[$field->field]);
                 }
             }
         }
         if (FSS_Permission::auth("core.edit.state", $this->getAsset())) {
             $this->item['published'] = FSS_Input::getInt('published', 0);
             $this->item['author'] = FSS_Input::getInt('author', 0);
         }
         if (FSS_Permission::auth("core.edit", $this->getAsset())) {
             $this->authorselect = $this->AuthorSelect($this->item);
         }
         $this->Output("form");
     }
     // if no errors, forward to list
     return;
 }
示例#3
0
 function doLog()
 {
     $output = "";
     if (array_key_exists("Ticket", $this->debug_data)) {
         $ticket = $this->debug_data['Ticket'];
         $output .= "Ticket: ";
         $output .= "<a href='" . FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticket['id']) . "'>";
         $output .= "{$ticket['id']} / {$ticket['reference']} / {$ticket['title']}</a><br>";
     }
     $output .= "Subject: " . $this->subject . "<br />";
     if (count($this->getAllTo()) > 1) {
         $output .= "Send config: " . FSS_Settings::Get('email_send_multiple') . "<br />";
     }
     foreach ($this->getAllTo() as $email => $name) {
         $output .= "To: {$name} ({$email})<br />";
     }
     $output .= "<hr />";
     $output .= str_replace("\n", "<br />", $this->body);
     if (count($this->files) || count($this->skipped_files)) {
         $output .= "<hr />";
         if (count($this->files)) {
             $output .= "Files: <br />";
             foreach ($this->files as $file => $display) {
                 $output .= "{$display}<br />";
             }
         }
         if (count($this->skipped_files)) {
             $output .= "Skipped Files (due to size restrictions): <br />";
             foreach ($this->skipped_files as $file => $display) {
                 $output .= "{$display}<br />";
             }
         }
     }
     $output .= "<hr />";
     $output .= "To address reasons: <br />";
     foreach ($this->source as $address => $source) {
         $output .= "{$address} =&gt; " . implode(", ", $source) . "<br />";
     }
     $now = FSS_Helper::CurDate();
     $db = JFactory::getDBO();
     $qry = "INSERT INTO #__fss_cron_log (cron, log, `when`) VALUES ('" . $db->escape("EMail Sent") . "', '" . $db->escape($output) . "', '{$now}')";
     $db->setQuery($qry);
     $db->Query();
 }
示例#4
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;
 }
示例#5
0
 function getDBTime()
 {
     $this->db_time = strtotime(FSS_Helper::CurDate());
 }
示例#6
0
 /**
  * Adds an audit note to this ticket
  **/
 function addAuditNote($note)
 {
     if (!$this->audit_changes) {
         return;
     }
     $db = JFactory::getDBO();
     $now = FSS_Helper::CurDate();
     if ($this->is_batch) {
         $note = "Batch: " . $note;
     }
     $qry = "INSERT INTO #__fss_ticket_messages (ticket_ticket_id, subject, body, user_id, admin, posted) VALUES ('";
     $qry .= FSSJ3Helper::getEscaped($db, $this->id) . "','Audit Message','" . FSSJ3Helper::getEscaped($db, $note) . "','" . FSSJ3Helper::getEscaped($db, $this->current_user) . "',3, '{$now}')";
     $db->SetQuery($qry);
     $db->Query();
 }
示例#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>";*/
 }
示例#8
0
    function merge()
    {
        $source_id = FSS_Input::getInt('source_id');
        $dest_id = FSS_Input::getInt('dest_id');
        if ($source_id < 1) {
            return $this->cancel();
        }
        if ($dest_id < 1) {
            return $this->cancel();
        }
        $source = new SupportTicket();
        if (!$source->load($source_id)) {
            return $this->cancel();
        }
        $dest = new SupportTicket();
        if (!$dest->load($dest_id)) {
            return $this->cancel();
        }
        //print_p($source);
        // need to copy messages
        $db = JFactory::getDBO();
        $sql = "SELECT * FROM #__fss_ticket_messages WHERE ticket_ticket_id = " . $db->escape($source_id);
        $db->setQuery($sql);
        $messages = $db->loadObjectList();
        $msg_map = array();
        foreach ($messages as $message) {
            $old_id = $message->id;
            unset($message->id);
            $message->ticket_ticket_id = $dest_id;
            $new_id = $this->Insert("#__fss_ticket_messages", $message);
            $msg_map[$old_id] = $new_id;
        }
        // add time
        $qry = "UPDATE #__fss_ticket_ticket SET timetaken = timetaken + " . (int) $source->timetaken . " WHERE id = " . $dest_id;
        $db->setQuery($qry);
        $db->Query();
        if ($source->timetaken > 0) {
            $qry = "UPDATE #__fss_ticket_ticket SET timetaken = 0 WHERE id = " . $source_id;
            $db->setQuery($qry);
            $db->Query();
            $source->addAuditNote("Time taken cleared as merged with another ticket");
        }
        // copy files
        $sql = "SELECT * FROM #__fss_ticket_attach WHERE ticket_ticket_id = " . $db->escape($source_id);
        $db->setQuery($sql);
        $attachments = $db->loadObjectList();
        foreach ($attachments as $attachment) {
            unset($attachment->id);
            $attachment->ticket_ticket_id = $dest_id;
            // change id to that of new message
            if (array_key_exists($attachment->message_id, $msg_map)) {
                $attachment->message_id = $msg_map[$attachment->message_id];
            }
            $new_id = $this->Insert("#__fss_ticket_attach", $attachment);
        }
        // add audit messages to both
        $source->addAuditNote("Ticket merged into another ticket then closed. Dest Ticket: " . $dest->reference . " - " . $dest->title);
        $dest->addAuditNote("Ticket merged into this one. Merged Ticket: " . $source->reference . " - " . $source->title);
        // close source ticket
        $closed = FSS_Ticket_Helper::GetStatusID('def_closed');
        // add merge tag to source ticket
        $now = FSS_Helper::CurDate();
        $qry = "UPDATE #__fss_ticket_ticket SET merged = " . (int) $dest_id . ", ticket_status_id = " . (int) $closed . ", lastupdate = '{$now}', closed = '{$now}' WHERE id = " . (int) $source_id;
        $db->setQuery($qry);
        $db->Query();
        // redirect to new ticket
        // TODO:
        /*
        Need to copy cc information on the ticket
        */
        $session = JFactory::getSession();
        $session->clear('merge');
        $session->clear('merge_ticket_id');
        ?>
<script>
window.location = '<?php 
        echo FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $dest_id, false);
        ?>
';
</script>
<?php 
        exit;
    }
示例#9
0
 function AddTicketAuditNote($ticketid, $note, $userid)
 {
     if ($ticketid < 1) {
         echo "ERROR: AddTicketAuditNote called with no ticket id ({$note})<br>";
         exit;
     }
     $db = JFactory::getDBO();
     $now = FSS_Helper::CurDate();
     $qry = "INSERT INTO #__fss_ticket_messages (ticket_ticket_id, subject, body, user_id, admin, posted) VALUES ('";
     $qry .= FSSJ3Helper::getEscaped($db, $ticketid) . "','Audit Message','" . FSSJ3Helper::getEscaped($db, $note) . "','" . FSSJ3Helper::getEscaped($db, $userid) . "',3, '{$now}')";
     $db->SetQuery($qry);
     //echo $qry. "<br>";
     $db->Query();
     //echo "Audit: $ticketid - $note<br>";
 }
示例#10
0
 function saveTicket()
 {
     $name = "";
     $db = JFactory::getDBO();
     $ok = true;
     $this->errors['subject'] = '';
     $this->errors['body'] = '';
     $this->errors['cat'] = '';
     if (FSS_Settings::get('support_subject_message_hide') == "subject") {
         $ticket->subject = substr(strip_tags($ticket->body), 0, 40);
     } else {
         if ($ticket->subject == "") {
             $this->errors['subject'] = JText::_("YOU_MUST_ENTER_A_SUBJECT_FOR_YOUR_SUPPORT_TICKET");
             $ok = false;
         }
     }
     if (FSS_Settings::get('support_altcat')) {
         $cats = $this->get('Cats');
         if (count($cats) > 0 && $catid == 0) {
             $this->errors['cat'] = JText::_("YOU_MUST_SELECT_A_CATEGORY");
             $ok = false;
         }
     }
     if ($body == "" && FSS_Settings::get('support_subject_message_hide') != "message") {
         $this->errors['body'] = JText::_("YOU_MUST_ENTER_A_MESSAGE_FOR_YOUR_SUPPORT_TICKET");
         $ok = false;
     }
     $fields = FSSCF::GetCustomFields(0, $prodid, $deptid);
     if (!FSSCF::ValidateFields($fields, $this->errors)) {
         $ok = false;
     }
     $email = "";
     $password = "";
     $now = FSS_Helper::CurDate();
     if ($ok) {
         /*$admin_id = FSS_Ticket_Helper::AssignHandler($prodid, $deptid, $catid);
         			
         			$now = FSS_Helper::CurDate();
         			
         			$def_open = FSS_Ticket_Helper::GetStatusID('def_open');
         			
         			$qry = "INSERT INTO #__fss_ticket_ticket (reference, ticket_status_id, ticket_pri_id, ticket_cat_id, ticket_dept_id, prod_id, title, opened, lastupdate, user_id, admin_id, email, password, unregname, lang) VALUES ";
         			$qry .= "('', $def_open, '".FSSJ3Helper::getEscaped($db, $priid)."', '".FSSJ3Helper::getEscaped($db, $catid)."', '".FSSJ3Helper::getEscaped($db, $deptid)."', '".FSSJ3Helper::getEscaped($db, $prodid)."', '".FSSJ3Helper::getEscaped($db, $subject)."', '{$now}', '{$now}', '".FSSJ3Helper::getEscaped($db, $userid)."', '".FSSJ3Helper::getEscaped($db, $admin_id)."', '{$email}', '".FSSJ3Helper::getEscaped($db, $password)."', '{$name}', '".JFactory::getLanguage()->getTag()."')";
         			
         
         			$db->setQuery($qry);$db->Query();
         			$this->ticketid = $db->insertid();
         			
         			$ref = FSS_Ticket_Helper::createRef($this->ticketid);
         
         			$qry = "UPDATE #__fss_ticket_ticket SET reference = '".FSSJ3Helper::getEscaped($db, $ref)."' WHERE id = '" . FSSJ3Helper::getEscaped($db, $this->ticketid) . "'";  
         			$db->setQuery($qry);$db->Query();
         
         
         			$qry = "INSERT INTO #__fss_ticket_messages (ticket_ticket_id, subject, body, user_id, posted) VALUES ('";
         			$qry .= FSSJ3Helper::getEscaped($db, $this->ticketid) . "','".FSSJ3Helper::getEscaped($db, $subject)."','".FSSJ3Helper::getEscaped($db, $body)."','".FSSJ3Helper::getEscaped($db, $userid)."','{$now}')";
         			
         			$db->setQuery($qry);$db->Query();
         			$messageid = $db->insertid();
         			
         			FSSCF::StoreFields($fields,$this->ticketid);
         			
         			
         			$files = array();
         			// save any uploaded file
         			
         			for ($i = 1; $i < 10; $i++)
         			{
         				$file = JRequest::getVar('filedata_' . $i, '', 'FILES', 'array');
         				if (array_key_exists('error',$file) && $file['error'] == 0 && $file['name'] != '')
         				{
         					$destpath = JPATH_COMPONENT_SITE.DS.'files'.DS.'support'.DS;					
         					$destname = md5(mt_rand(0,999999).'-'.$file['name']); 
         					
         					while (JFile::exists($destpath . $destname))
         					{
         						$destname = md5(mt_rand(0,999999).'-'.$file['name']);               
         					}
         					
         					if (JFile::upload($file['tmp_name'], $destpath . $destname))
         					{
         						$qry = "INSERT INTO #__fss_ticket_attach (ticket_ticket_id, filename, diskfile, size, user_id, added, message_id) VALUES ('";
         						$qry .= FSSJ3Helper::getEscaped($db, $this->ticketid) . "',";
         						$qry .= "'" . FSSJ3Helper::getEscaped($db, $file['name']) . "',";
         						$qry .= "'" . FSSJ3Helper::getEscaped($db, $destname) . "',";
         						$qry .= "'" . $file['size'] . "',";
         						$qry .= "'" . FSSJ3Helper::getEscaped($db, $userid) . "',";
         						$qry .= "'{$now}', $messageid )";
         						
         						
         						$file_obj = new stdClass();
         						$file_obj->filename = $file['name'];
         						$file_obj->diskfile = $destname;
         						$file_obj->size = $file['size'];
         						$files[] = $file_obj;
         						
         						
         						$db->setQuery($qry);$db->Query();     
         					} else {
         						// ERROR : File cannot be uploaded! try permissions	
         					}
         				}
         			}
         			
         			$t = new SupportTicket();
         			$t->load($this->ticketid, true);
         			
         			$subject = JRequest::getVar('subject','','','string');
         			$body = JRequest::getVar('body','','','string', JREQUEST_ALLOWRAW);
         			
         			$action_name = "User_Open";
         			$action_params = array('subject' => $subject, 'user_message' => $body, 'files' => $files);
         			SupportActions::DoAction($action_name, $t, $action_params);*/
     }
     $this->errors = $errors;
     $this->ticket = $ticket;
     return $ok;
 }