From 9ea9a9b52d28d8829440e5e92c30195096cd81a0 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 13:08:24 -0500 Subject: [PATCH 01/16] Order by department --- include/class.dept.php | 86 +++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/include/class.dept.php b/include/class.dept.php index 8e34e2ba..daaf6e36 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -1,7 +1,7 @@ @@ -18,23 +18,23 @@ class Dept { var $email; var $sla; - var $manager; + var $manager; var $members; var $groups; var $ht; - + function Dept($id) { $this->id=0; $this->load($id); } - + function load($id=0) { global $cfg; if(!$id && !($id=$this->getId())) return false; - + $sql='SELECT dept.*,dept.dept_id as id,dept.dept_name as name, dept.dept_signature as signature, count(staff.staff_id) as users ' .' FROM '.DEPT_TABLE.' dept ' .' LEFT JOIN '.STAFF_TABLE.' staff ON (dept.dept_id=staff.dept_id) ' @@ -66,21 +66,21 @@ function asVar() { function getId() { return $this->id; } - + function getName() { return $this->ht['name']; } - + function getEmailId() { return $this->ht['email_id']; } function getEmail() { - + if(!$this->email && $this->getEmailId()) $this->email=Email::lookup($this->getEmailId()); - + return $this->email; } @@ -88,7 +88,7 @@ function getNumStaff() { return $this->ht['users']; } - + function getNumUsers() { return $this->getNumStaff(); } @@ -103,14 +103,14 @@ function getMembers() { $this->members = array(); $sql='SELECT DISTINCT s.staff_id FROM '.STAFF_TABLE.' s ' .' LEFT JOIN '.GROUP_DEPT_TABLE.' g ON(s.group_id=g.group_id) ' - .' INNER JOIN '.DEPT_TABLE.' d - ON(d.dept_id=s.dept_id - OR d.manager_id=s.staff_id + .' INNER JOIN '.DEPT_TABLE.' d + ON(d.dept_id=s.dept_id + OR d.manager_id=s.staff_id OR (d.dept_id=g.dept_id AND d.group_membership=1) ) ' .' WHERE d.dept_id='.db_input($this->getId()) .' ORDER BY s.lastname, s.firstname'; - + if(($res=db_query($sql)) && db_num_rows($res)) { while(list($id)=db_fetch_row($res)) $this->members[] = Staff::lookup($id); @@ -140,11 +140,11 @@ function getTemplateId() { function getTemplate() { if(!$this->template && $this->getTemplateId()) - $this->template = EmailTemplateGroup::lookup($this->getTemplateId()); + $this->template = Template::lookup($this->getTemplateId()); return $this->template; } - + function getAutoRespEmail() { if(!$this->autorespEmail && $this->ht['autoresp_email_id'] && ($email=Email::lookup($this->ht['autoresp_email_id']))) @@ -154,12 +154,12 @@ function getAutoRespEmail() { return $this->autorespEmail; } - + function getEmailAddress() { if(($email=$this->getEmail())) return $email->getAddress(); } - + function getSignature() { return $this->ht['signature']; } @@ -167,13 +167,13 @@ function getSignature() { function canAppendSignature() { return ($this->getSignature() && $this->isPublic()); } - + function getManagerId() { return $this->ht['manager_id']; } function getManager() { - + if(!$this->manager && $this->getManagerId()) $this->manager=Staff::lookup($this->getManagerId()); @@ -191,11 +191,11 @@ function isManager($staff) { function isPublic() { return ($this->ht['ispublic']); } - + function autoRespONNewTicket() { return ($this->ht['ticket_auto_response']); } - + function autoRespONNewMessage() { return ($this->ht['message_auto_response']); } @@ -208,7 +208,7 @@ function noreplyAutoResp() { function isGroupMembershipEnabled() { return ($this->ht['group_membership']); } - + function getHashtable() { return $this->ht; } @@ -218,7 +218,7 @@ function getInfo() { } - + function getAllowedGroups() { if($this->groups) return $this->groups; @@ -244,9 +244,9 @@ function updateAllowedGroups($groups) { } } - + $sql='DELETE FROM '.GROUP_DEPT_TABLE.' WHERE dept_id='.db_input($this->getId()); - if($groups && is_array($groups)) + if($groups && is_array($groups)) $sql.=' AND group_id NOT IN('.implode(',', db_input($groups)).')'; db_query($sql); @@ -262,13 +262,13 @@ function update($vars, &$errors) { $this->updateAllowedGroups($vars['groups']); $this->reload(); - + return true; } function delete() { global $cfg; - + if(!$cfg || $this->getId()==$cfg->getDefaultDeptId() || $this->getNumUsers()) return 0; @@ -317,7 +317,7 @@ function getDefaultDeptName() { } function getDepartments( $criteria=null) { - + $depts=array(); $sql='SELECT dept_id, dept_name FROM '.DEPT_TABLE.' WHERE 1'; if($criteria['publiconly']) @@ -326,6 +326,8 @@ function getDepartments( $criteria=null) { if(($manager=$criteria['manager'])) $sql.=' AND manager_id='.db_input(is_object($manager)?$manager->getId():$manager); + $sql.=' ORDER BY dept_name'; + if(($res=db_query($sql)) && db_num_rows($res)) { while(list($id, $name)=db_fetch_row($res)) $depts[$id] = $name; @@ -347,13 +349,13 @@ function create($vars, &$errors) { function save($id, $vars, &$errors) { global $cfg; - + if($id && $id!=$vars['id']) $errors['err']='Missing or invalid Dept ID (internal error).'; - + if(!$vars['email_id'] || !is_numeric($vars['email_id'])) $errors['email_id']='Email selection required'; - + if(!is_numeric($vars['tpl_id'])) $errors['tpl_id']='Template selection required'; @@ -362,15 +364,15 @@ function save($id, $vars, &$errors) { } elseif(strlen($vars['name'])<4) { $errors['name']='Name is too short.'; } elseif(($did=Dept::getIdByName($vars['name'])) && $did!=$id) { - $errors['name']='Department already exists'; + $errors['name']='Department already exist'; } - + if(!$vars['ispublic'] && ($vars['id']==$cfg->getDefaultDeptId())) - $errors['ispublic']='System default department cannot be private'; + $errors['ispublic']='System default department can not be private'; if($errors) return false; - + $sql='SET updated=NOW() ' .' ,ispublic='.db_input($vars['ispublic']) .' ,email_id='.db_input($vars['email_id']) @@ -384,25 +386,25 @@ function save($id, $vars, &$errors) { .' ,ticket_auto_response='.db_input(isset($vars['ticket_auto_response'])?$vars['ticket_auto_response']:1) .' ,message_auto_response='.db_input(isset($vars['message_auto_response'])?$vars['message_auto_response']:1); - + if($id) { $sql='UPDATE '.DEPT_TABLE.' '.$sql.' WHERE dept_id='.db_input($id); if(db_query($sql) && db_affected_rows()) return true; - + $errors['err']='Unable to update '.Format::htmlchars($vars['name']).' Dept. Error occurred'; - + } else { $sql='INSERT INTO '.DEPT_TABLE.' '.$sql.',created=NOW()'; if(db_query($sql) && ($id=db_insert_id())) return $id; - + $errors['err']='Unable to create department. Internal error'; - + } - + return false; } From 656c2ed704378a5af03a9076ee0e16ca42862518 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 13:22:31 -0500 Subject: [PATCH 02/16] Department selection with Help Topic lookup --- include/client/open.inc.php | 95 ++++++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 7 deletions(-) diff --git a/include/client/open.inc.php b/include/client/open.inc.php index 275e856d..80c7d357 100644 --- a/include/client/open.inc.php +++ b/include/client/open.inc.php @@ -11,7 +11,14 @@ $info=($_POST && $errors)?Format::htmlchars($_POST):$info; ?>

Open a New Ticket

-

Please fill in the form below to open a new ticket.

+isKnowledgebaseEnabled()){ + //FIXME: provide ability to feature or select random FAQs ?? +?> +

Be sure to browse our Frequently Asked Questions (FAQs), before opening a ticket.

+ +

Please fill in the form below to open a new ticket

@@ -54,21 +61,49 @@   - Help Topic: + Department: - + $name) { + if($depts=Dept::getPublicDepartments()) { + foreach($depts as $id =>$name) { echo sprintf('', - $id, ($info['topicId']==$id)?'selected="selected"':'', $name); + $id, ($info['deptId']==$id)?'selected="selected"':'', $name); } } else { ?> + + + + + Help Topic: + + @@ -146,3 +181,49 @@

+ From 943261b0a9b73b682c372c1d993718822e445c0b Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 13:24:01 -0500 Subject: [PATCH 03/16] Department selection with Help Topic lookup --- findtopic.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 findtopic.php diff --git a/findtopic.php b/findtopic.php new file mode 100644 index 00000000..0954aaaa --- /dev/null +++ b/findtopic.php @@ -0,0 +1,39 @@ + + + From a016f7415dfd4f466dbc33e2532ac66fa4ff7108 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 13:53:20 -0500 Subject: [PATCH 04/16] Pending Ticket Status --- include/client/tickets.inc.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/client/tickets.inc.php b/include/client/tickets.inc.php index 8eda7eca..f4c135b5 100644 --- a/include/client/tickets.inc.php +++ b/include/client/tickets.inc.php @@ -8,6 +8,9 @@ //Status we are actually going to use on the query...making sure it is clean! switch(strtolower($_REQUEST['status'])) { case 'open': + case 'pending': + $status=strtolower($_REQUEST['status']); + break; case 'closed': $status=strtolower($_REQUEST['status']); break; @@ -98,12 +101,14 @@ + getNumClosedTickets()) { ?> - - >Closed (getNumClosedTickets(); ?>) + From 19989a727001f0ef587080eab1b9cb073d660a2d Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 13:54:38 -0500 Subject: [PATCH 05/16] Added order by name --- include/staff/faq.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/staff/faq.inc.php b/include/staff/faq.inc.php index 99f40176..a21affff 100644 --- a/include/staff/faq.inc.php +++ b/include/staff/faq.inc.php @@ -54,7 +54,7 @@ + + (Days to Auto Close a ticket - enter 0 to disable auto close) + + Web Tickets Priority: > - (Allow user to override/set priority) + (Allow user to overwrite/set priority) @@ -247,4 +255,3 @@

- From 799d2f99c50e4ff70594f13fc3cb05992f47d33c Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 13:57:31 -0500 Subject: [PATCH 07/16] More Source Options --- include/staff/ticket-edit.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index 93fc68ba..66c3c999 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -50,7 +50,7 @@ - Ticket Information: Due date overrides SLA's grace period. + Ticket Information: Due date overwrites SLA's grace period. @@ -63,6 +63,9 @@ + + + @@ -146,7 +149,7 @@ $min=$hr=null; if($info['time']) list($hr, $min)=explode(':', $info['time']); - + echo Misc::timeDropdown($hr, $min, 'time'); ?>     From d18f3f12eb0b414c5ef6a3d4d9cf811341e0b8c0 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 14:26:14 -0500 Subject: [PATCH 08/16] Department selection and Pending Ticket Department selection with Help Topic lookup along with Pending ticket option --- include/staff/ticket-open.inc.php | 111 +++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 24 deletions(-) diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index ed29b873..c1b8d6af 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -69,6 +69,9 @@ + + +  *  @@ -79,17 +82,19 @@ Department: - + + $name) { + echo sprintf('', + $id, ($info['deptId']==$id)?'selected="selected"':'', $name); } - ?> - + } else { ?> + + +  *  @@ -98,18 +103,29 @@ Help Topic: - - + + $name) { + echo sprintf('', + $id, ($info['topicId']==$id)?'selected="selected"':'', $name); } - ?> - + } + else { ?> + + +  *  @@ -270,7 +286,7 @@
- +
@@ -282,8 +298,9 @@ Ticket Status: - > - Close On Response (Only applicable if response is entered) +      +  (Only applicable if response is entered)

+ From 43bea6c66a7ab72bb70ed1ea417634b627a820ae Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 14:46:48 -0500 Subject: [PATCH 09/16] Pending ticket options --- include/staff/ticket-view.inc.php | 90 ++++++++++++++++++------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 3d119fb8..4fb0037b 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -54,27 +54,27 @@ canDeleteTickets()) { ?> Delete - canCloseTickets()) { - if($ticket->isOpen()) {?> - Close + if($ticket->isClosed()) {?> + Reopen - Reopen + Close - - canEditTickets()) { ?> Edit - isOpen() && !$ticket->isAssigned() && $thisstaff->canAssignTickets()) {?> Claim - + @@ -82,19 +82,19 @@
    - isOpen() && ($dept && $dept->isManager($thisstaff))) { - + if($ticket->isAssigned()) { ?>
  • Release (unassign) Ticket
  • isOverdue()) { ?>
  • Mark as Overdue
  • isAnswered()) { ?>
  • Mark as Unanswered
  • canBanEmails()) { + + if($thisstaff->canBanEmails()) { if(!$emailBanned) {?>
  • Ban Email (getEmail(); ?>)
  • -
  • Unban Email (getEmail(); ?>)
  • getNumOpenTickets())) echo sprintf('
  • %d Open Tickets
  • ', $ticket->getEmail(), $open); + if(($pending=$client->getNumPendingTickets())) + echo sprintf('
  • %d Pending Tickets
  • ', + $ticket->getEmail(), $pending); if(($closed=$client->getNumClosedTickets())) echo sprintf('
  • %d Closed Tickets
  • ', $ticket->getEmail(), $closed); @@ -179,13 +182,13 @@ Source: - getSource()); if($ticket->getIP()) echo '   ('.$ticket->getIP().')'; - + ?> @@ -294,7 +297,7 @@ posted by %s', - $note['title'], + Format::htmlchars($note['title']), Format::htmlchars($note['poster'])); ?> @@ -306,8 +309,8 @@ getThreadEntry($note['id'])) + if($note['attachments'] + && ($tentry=$ticket->getThreadEntry($note['id'])) && ($links=$tentry->getAttachmentsLinks())) { ?> @@ -332,18 +335,16 @@ $types[] = 'N'; if(($thread=$ticket->getThreadEntries($types))) { foreach($thread as $entry) { - if ($entry['body'] == '-') - $entry['body'] = '(EMPTY)'; ?> - + getThreadEntry($entry['id'])) && ($links=$tentry->getAttachmentsLinks())) {?> @@ -453,7 +454,7 @@
    - +
    @@ -483,13 +484,22 @@ } ?> - isClosed() || $thisstaff->canCloseTickets()) { ?> + -
    + isOpen()) { ?> + + isPending()) { ?> + + isClosed()) { ?> @@ -501,10 +511,8 @@ > Close on Reply -

    @@ -520,7 +528,7 @@ - @@ -537,7 +545,7 @@
    - Note title - summary of the note (optional)  + Note title - summarry of the note (optional) 
    @@ -553,7 +561,7 @@
    - +
    @@ -571,7 +579,7 @@ isClosed()){ + if($ticket->isClosed()){ echo sprintf('', ($state=='reopen')?'selected="selelected"':''); } else { @@ -581,12 +589,20 @@ /* Ticket open - states */ echo ''; + + //Pending - state + if($ticket->isPending()) + echo sprintf('', + ($state=='open')?'selected="selelected"':''); + else + echo sprintf('', + ($state=='pending')?'selected="selelected"':''); //Answer - state if($ticket->isAnswered()) echo sprintf('', ($state=='unanswered')?'selected="selelected"':''); - else + else echo sprintf('', ($state=='answered')?'selected="selelected"':''); @@ -683,7 +699,7 @@
     
    - + @@ -839,7 +855,7 @@

    +

    From ac03202fa2c1b6b72f4ddc9adbadcc412037e4c1 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 14:48:59 -0500 Subject: [PATCH 10/16] Pending Ticket Status --- include/staff/tickets.inc.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index ac38d5ff..86d94eb3 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -29,6 +29,9 @@ case 'open': $status='open'; break; + case 'pending': + $status='pending'; + break; case 'closed': $status='closed'; $showassigned=true; //closed by. @@ -119,12 +122,21 @@ //This sucks..mass scan! search anything that moves! $deep_search=true; - $qwhere.=" AND ( ticket.email LIKE '%$queryterm%'". - " OR ticket.name LIKE '%$queryterm%'". - " OR ticket.subject LIKE '%$queryterm%'". - " OR thread.body LIKE '%$queryterm%'". - " OR thread.title LIKE '%$queryterm%'". - ' ) '; + if($_REQUEST['stype'] && $_REQUEST['stype']=='FT') { //Using full text on big fields. + $qwhere.=" AND ( ticket.email LIKE '%$queryterm%'". + " OR ticket.name LIKE '%$queryterm%'". + " OR ticket.subject LIKE '%$queryterm%'". + " OR thread.title LIKE '%$queryterm%'". + " OR MATCH(thread.body) AGAINST('$queryterm')". + ' ) '; + }else{ + $qwhere.=" AND ( ticket.email LIKE '%$queryterm%'". + " OR ticket.name LIKE '%$queryterm%'". + " OR ticket.subject LIKE '%$queryterm%'". + " OR thread.body LIKE '%$queryterm%'". + " OR thread.title LIKE '%$queryterm%'". + ' ) '; + } } } //department @@ -407,7 +419,7 @@ $subject = Format::truncate($row['subject'],40); $threadcount=$row['thread_count']; if(!strcasecmp($row['status'],'open') && !$row['isanswered'] && !$row['lock_id']) { - $tid=sprintf('%s',$tid); + $tid=sprintf('%s',$tid); } ?> From d2902ed882b6930a431df1fef3d2a9664ac8682a Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 14:51:06 -0500 Subject: [PATCH 11/16] Pending Ticket Status --- include/class.client.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/class.client.php b/include/class.client.php index 5ff5911c..2c67aa5c 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -107,13 +107,17 @@ function getTicketStats() { } function getNumTickets() { - return ($stats=$this->getTicketStats())?($stats['open']+$stats['closed']):0; + return ($stats=$this->getTicketStats())?($stats['open']+$stats['pending']+$stats['closed']):0; } function getNumOpenTickets() { return ($stats=$this->getTicketStats())?$stats['open']:0; } + function getNumPendingTickets() { + return ($stats=$this->getTicketStats())?$stats['pending']:0; + } + function getNumClosedTickets() { return ($stats=$this->getTicketStats())?$stats['closed']:0; } @@ -168,7 +172,7 @@ function lookupByEmail($email) { $errors['login'] = 'Invalid method'; elseif(!$ticketID || !Validator::is_email($email)) $errors['login'] = 'Valid email and ticket number required'; - + //Bail out on error. if($errors) return false; From f2c1d28fdbe5ffa4c953c3170c086ca7d99c67d7 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 14:56:59 -0500 Subject: [PATCH 12/16] Pending Ticket Status --- include/class.config.php | 783 +++++++++++++++------------------------ 1 file changed, 307 insertions(+), 476 deletions(-) diff --git a/include/class.config.php b/include/class.config.php index 76fec8e7..ad3121d9 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -17,154 +17,50 @@ class.config.php require_once(INCLUDE_DIR.'class.email.php'); class Config { - var $config = array(); - - var $section = null; # Default namespace ('core') - var $table = CONFIG_TABLE; # Table name (with prefix) - var $section_column = 'namespace'; # namespace column name - - var $session = null; # Session-backed configuration - - # Defaults for this configuration. If settings don't exist in the - # database yet, the ->getInfo() method will not include the (default) - # values in the returned array. $defaults allows developers to define - # new settings and the corresponding default values. - var $defaults = array(); # List of default values - - function Config($section=null) { - if ($section) - $this->section = $section; - - if ($this->section === null) - return false; - - if (!isset($_SESSION['cfg:'.$this->section])) - $_SESSION['cfg:'.$this->section] = array(); - $this->session = &$_SESSION['cfg:'.$this->section]; - $sql='SELECT id, `key`, value, `updated` FROM '.$this->table - .' WHERE `'.$this->section_column.'` = '.db_input($this->section); + var $id = 0; + var $config = array(); - if(($res=db_query($sql)) && db_num_rows($res)) - while ($row = db_fetch_array($res)) - $this->config[$row['key']] = $row; - } + var $defaultDept; //Default Department + var $defaultSLA; //Default SLA + var $defaultEmail; //Default Email + var $alertEmail; //Alert Email + var $defaultSMTPEmail; //Default SMTP Email - function getNamespace() { - return $this->section; + function Config($id) { + $this->load($id); } - function getInfo() { - $info = $this->defaults; - foreach ($this->config as $key=>$setting) - $info[$key] = $setting['value']; - return $info; - } + function load($id=0) { - function get($key, $default=null) { - if (isset($this->session[$key])) - return $this->session[$key]; - elseif (isset($this->config[$key])) - return $this->config[$key]['value']; - elseif (isset($this->defaults[$key])) - return $this->defaults[$key]; + if(!$id && !($id=$this->getId())) + return false; - return $default; - } + $sql='SELECT *, (TIME_TO_SEC(TIMEDIFF(NOW(), UTC_TIMESTAMP()))/3600) as db_tz_offset ' + .' FROM '.CONFIG_TABLE + .' WHERE id='.db_input($id); - function exists($key) { - return $this->get($key, null) ? true : false; - } + if(!($res=db_query($sql)) || !db_num_rows($res)) + return false; - function set($key, $value) { - return ($this->update($key, $value)) ? $value : null; - } - function persist($key, $value) { - $this->session[$key] = $value; - return true; - } + $this->config = db_fetch_array($res); + $this->id = $this->config['id']; - function lastModified($key) { - if (isset($this->config[$key])) - return $this->config[$key]['updated']; + //Get the default time zone + // We can't JOIN timezone table above due to upgrade support. + if($this->config['default_timezone_id']) + $this->config['tz_offset'] = Timezone::getOffsetById($this->config['default_timezone_id']); else - return false; - } + $this->config['tz_offset'] = 0; - function create($key, $value) { - $sql = 'INSERT INTO '.$this->table - .' SET `'.$this->section_column.'`='.db_input($this->section) - .', `key`='.db_input($key) - .', value='.db_input($value); - if (!db_query($sql) || !($id=db_insert_id())) - return false; - - $this->config[$key] = array('key'=>$key, 'value'=>$value, 'id'=>$id); return true; } - function update($key, $value) { - if (!isset($this->config[$key])) - return $this->create($key, $value); - - $setting = &$this->config[$key]; - if ($setting['value'] == $value) - return true; - - if (!db_query('UPDATE '.$this->table.' SET updated=NOW(), value=' - .db_input($value).' WHERE id='.db_input($setting['id']))) + function reload() { + if(!$this->load($this->getId())) return false; - $setting['value'] = $value; - return true; - } - - function updateAll($updates) { - foreach ($updates as $key=>$value) - if (!$this->update($key, $value)) - return false; - return true; - } -} - -class OsticketConfig extends Config { - var $table = CONFIG_TABLE; - var $section = 'core'; - - var $defaultDept; //Default Department - var $defaultSLA; //Default SLA - var $defaultEmail; //Default Email - var $alertEmail; //Alert Email - var $defaultSMTPEmail; //Default SMTP Email - - var $defaults = array( - 'allow_pw_reset' => true, - 'pw_reset_window' => 30, - ); - - function OsticketConfig($section=null) { - parent::Config($section); - - if (count($this->config) == 0) { - // Fallback for osticket < 1.7@852ca89e - $sql='SELECT * FROM '.$this->table.' WHERE id = 1'; - if (($res=db_query($sql)) && db_num_rows($res)) - foreach (db_fetch_array($res) as $key=>$value) - $this->config[$key] = array('value'=>$value); - } - - //Get the default time zone - // We can't JOIN timezone table above due to upgrade support. - if ($this->get('default_timezone_id')) { - if (!$this->exists('tz_offset')) - $this->persist('tz_offset', - Timezone::getOffsetById($this->get('default_timezone_id'))); - } else - // Previous osTicket versions saved the offset value instead of - // a timezone instance. This is compatibility for the upgrader - $this->persist('tz_offset', 0); - return true; } @@ -177,80 +73,75 @@ function isHelpDeskOnline() { } function isOnline() { - return ($this->get('isonline')); + return ($this->config['isonline']); } function isKnowledgebaseEnabled() { require_once(INCLUDE_DIR.'class.faq.php'); - return ($this->get('enable_kb') && FAQ::countPublishedFAQs()); + return ($this->config['enable_kb'] && FAQ::countPublishedFAQs()); } function getVersion() { return THIS_VERSION; } - function getSchemaSignature($section=null) { + //Used to detect version prior to 1.7 (useful during upgrade) + function getDBVersion() { + return $this->config['ostversion']; + } - if ((!$section || $section == $this->section) - && ($v=$this->get('schema_signature'))) - return $v; + function getSchemaSignature() { - // 1.7 after namespaced configuration, other namespace - if ($section) { - $sql='SELECT value FROM '.$this->table - .' WHERE `key` = "schema_signature" and namespace='.db_input($section); - if (($res=db_query($sql, false)) && db_num_rows($res)) - return db_result($res); - } + if($this->config['schema_signature']) + return $this->config['schema_signature']; - // 1.7 before namespaced configuration - $sql='SELECT `schema_signature` FROM '.$this->table - .' WHERE id=1'; - if (($res=db_query($sql, false)) && db_num_rows($res)) - return db_result($res); + if($this->config['ostversion']) //old version 1.6 RC[1-5]-ST + return md5(strtoupper(trim($this->config['ostversion']))); - // old version 1.6 - return md5(self::getDBVersion()); + return null; } function getDBTZoffset() { - if (!$this->exists('db_tz_offset')) { - $sql='SELECT (TIME_TO_SEC(TIMEDIFF(NOW(), UTC_TIMESTAMP()))/3600) as db_tz_offset'; - if(($res=db_query($sql)) && db_num_rows($res)) - $this->persist('db_tz_offset', db_result($res)); - } - return $this->get('db_tz_offset'); + return $this->config['db_tz_offset']; } /* Date & Time Formats */ function observeDaylightSaving() { - return ($this->get('enable_daylight_saving')); + return ($this->config['enable_daylight_saving']); } function getTimeFormat() { - return $this->get('time_format'); + return $this->config['time_format']; } function getDateFormat() { - return $this->get('date_format'); + return $this->config['date_format']; } function getDateTimeFormat() { - return $this->get('datetime_format'); + return $this->config['datetime_format']; } function getDayDateTimeFormat() { - return $this->get('daydatetime_format'); + return $this->config['daydatetime_format']; + } + + function getId() { + return $this->id; + } + + function getConfigId() { + return $this->getId(); } function getConfigInfo() { - return $this->getInfo(); + return $this->config; } function getTitle() { - return $this->get('helpdesk_title'); + return $this->config['helpdesk_title']; } function getUrl() { - return $this->get('helpdesk_url'); + return $this->config['helpdesk_url']; } function getBaseUrl() { //Same as above with no trailing slash. @@ -258,27 +149,27 @@ function getBaseUrl() { //Same as above with no trailing slash. } function getTZOffset() { - return $this->get('tz_offset'); + return $this->config['tz_offset']; } function getPageSize() { - return $this->get('max_page_size'); + return $this->config['max_page_size']; } function getGracePeriod() { - return $this->get('overdue_grace_period'); + return $this->config['overdue_grace_period']; } function getPasswdResetPeriod() { - return $this->get('passwd_reset_period'); + return $this->config['passwd_reset_period']; } function showRelatedTickets() { - return $this->get('show_related_tickets'); + return $this->config['show_related_tickets']; } function showNotesInline(){ - return $this->get('show_notes_inline'); + return $this->config['show_notes_inline']; } function getClientTimeout() { @@ -286,15 +177,15 @@ function getClientTimeout() { } function getClientSessionTimeout() { - return $this->get('client_session_timeout')*60; + return $this->config['client_session_timeout']*60; } function getClientLoginTimeout() { - return $this->get('client_login_timeout')*60; + return $this->config['client_login_timeout']*60; } function getClientMaxLogins() { - return $this->get('client_max_logins'); + return $this->config['client_max_logins']; } function getStaffTimeout() { @@ -302,23 +193,23 @@ function getStaffTimeout() { } function getStaffSessionTimeout() { - return $this->get('staff_session_timeout')*60; + return $this->config['staff_session_timeout']*60; } function getStaffLoginTimeout() { - return $this->get('staff_login_timeout')*60; + return $this->config['staff_login_timeout']*60; } function getStaffMaxLogins() { - return $this->get('staff_max_logins'); + return $this->config['staff_max_logins']; } function getLockTime() { - return $this->get('autolock_minutes'); + return $this->config['autolock_minutes']; } function getDefaultDeptId() { - return $this->get('default_dept_id'); + return $this->config['default_dept_id']; } function getDefaultDept() { @@ -330,7 +221,7 @@ function getDefaultDept() { } function getDefaultEmailId() { - return $this->get('default_email_id'); + return $this->config['default_email_id']; } function getDefaultEmail() { @@ -347,7 +238,7 @@ function getDefaultEmailAddress() { } function getDefaultSLAId() { - return $this->get('default_sla_id'); + return $this->config['default_sla_id']; } function getDefaultSLA() { @@ -358,177 +249,116 @@ function getDefaultSLA() { return $this->defaultSLA; } + function getAutoCloseGrace() { + return $this->config['autoclose_grace_period']; + } + function getAlertEmailId() { - return $this->get('alert_email_id'); + return $this->config['alert_email_id']; } function getAlertEmail() { - if(!$this->alertEmail && $this->get('alert_email_id')) - $this->alertEmail= new Email($this->get('alert_email_id')); + if(!$this->alertEmail && $this->config['alert_email_id']) + $this->alertEmail= new Email($this->config['alert_email_id']); return $this->alertEmail; } function getDefaultSMTPEmail() { - if(!$this->defaultSMTPEmail && $this->get('default_smtp_id')) - $this->defaultSMTPEmail= new Email($this->get('default_smtp_id')); + if(!$this->defaultSMTPEmail && $this->config['default_smtp_id']) + $this->defaultSMTPEmail= new Email($this->config['default_smtp_id']); return $this->defaultSMTPEmail; } + function allowSMTPSpoofing() { + return $this->config['spoof_default_smtp']; + } + function getDefaultPriorityId() { - return $this->get('default_priority_id'); + return $this->config['default_priority_id']; } function getDefaultTemplateId() { - return $this->get('default_template_id'); + return $this->config['default_template_id']; } function getDefaultTemplate() { if(!$this->defaultTemplate && $this->getDefaultTemplateId()) - $this->defaultTemplate = EmailTemplateGroup::lookup($this->getDefaultTemplateId()); + $this->defaultTemplate = Template::lookup($this->getDefaultTemplateId()); return $this->defaultTemplate; } - function getLandingPageId() { - return $this->get('landing_page_id'); - } - - function getLandingPage() { - - if(!$this->landing_page && $this->getLandingPageId()) - $this->landing_page = Page::lookup($this->getLandingPageId()); - - return $this->landing_page; - } - - function getOfflinePageId() { - return $this->get('offline_page_id'); - } - - function getOfflinePage() { - - if(!$this->offline_page && $this->getOfflinePageId()) - $this->offline_page = Page::lookup($this->getOfflinePageId()); - - return $this->offline_page; - } - - function getThankYouPageId() { - return $this->get('thank-you_page_id'); - } - - function getThankYouPage() { - - if(!$this->thankyou_page && $this->getThankYouPageId()) - $this->thankyou_page = Page::lookup($this->getThankYouPageId()); - - return $this->thankyou_page; - } - - function getDefaultPages() { - /* Array of ids...as opposed to objects */ - return array( - $this->getLandingPageId(), - $this->getOfflinePageId(), - $this->getThankYouPageId(), - ); - } - function getMaxOpenTickets() { - return $this->get('max_open_tickets'); + return $this->config['max_open_tickets']; } function getMaxFileSize() { - return $this->get('max_file_size'); + return $this->config['max_file_size']; } function getStaffMaxFileUploads() { - return $this->get('max_staff_file_uploads'); + return $this->config['max_staff_file_uploads']; } function getClientMaxFileUploads() { //TODO: change max_user_file_uploads to max_client_file_uploads - return $this->get('max_user_file_uploads'); + return $this->config['max_user_file_uploads']; } function getLogLevel() { - return $this->get('log_level'); + return $this->config['log_level']; } function getLogGracePeriod() { - return $this->get('log_graceperiod'); + return $this->config['log_graceperiod']; } function logTicketActivity() { - return $this->get('log_ticket_activity'); + return $this->config['log_ticket_activity']; } function clickableURLS() { - return ($this->get('clickable_urls')); + return ($this->config['clickable_urls']); } function enableStaffIPBinding() { - return ($this->get('staff_ip_binding')); - } - - /** - * Configuration: allow_pw_reset - * - * TRUE if the Forgot my password link and system should be - * enabled, and FALSE otherwise. - */ - function allowPasswordReset() { - return $this->get('allow_pw_reset'); - } - - /** - * Configuration: pw_reset_window - * - * Number of minutes for which the password reset token is valid. - * - * Returns: Number of seconds the password reset token is valid. The - * number of minutes from the database is automatically converted - * to seconds here. - */ - function getPwResetWindow() { - // pw_reset_window is stored in minutes. Return value in seconds - return $this->get('pw_reset_window') * 60; + return ($this->config['staff_ip_binding']); } function isCaptchaEnabled() { - return (extension_loaded('gd') && function_exists('gd_info') && $this->get('enable_captcha')); + return (extension_loaded('gd') && function_exists('gd_info') && $this->config['enable_captcha']); } function isAutoCronEnabled() { - return ($this->get('enable_auto_cron')); + return ($this->config['enable_auto_cron']); } function isEmailPollingEnabled() { - return ($this->get('enable_mail_polling')); + return ($this->config['enable_mail_polling']); } function allowPriorityChange() { - return ($this->get('allow_priority_change')); + return ($this->config['allow_priority_change']); } function useEmailPriority() { - return ($this->get('use_email_priority')); + return ($this->config['use_email_priority']); } function getAdminEmail() { - return $this->get('admin_email'); + return $this->config['admin_email']; } function getReplySeparator() { - return $this->get('reply_separator'); + return $this->config['reply_separator']; } function stripQuotedReply() { - return ($this->get('strip_quoted_reply')); + return ($this->config['strip_quoted_reply']); } function saveEmailHeaders() { @@ -536,176 +366,176 @@ function saveEmailHeaders() { } function useRandomIds() { - return ($this->get('random_ticket_ids')); + return ($this->config['random_ticket_ids']); } /* autoresponders & Alerts */ function autoRespONNewTicket() { - return ($this->get('ticket_autoresponder')); + return ($this->config['ticket_autoresponder']); } function autoRespONNewMessage() { - return ($this->get('message_autoresponder')); + return ($this->config['message_autoresponder']); } function notifyONNewStaffTicket() { - return ($this->get('ticket_notice_active')); + return ($this->config['ticket_notice_active']); } function alertONNewMessage() { - return ($this->get('message_alert_active')); + return ($this->config['message_alert_active']); } function alertLastRespondentONNewMessage() { - return ($this->get('message_alert_laststaff')); + return ($this->config['message_alert_laststaff']); } function alertAssignedONNewMessage() { - return ($this->get('message_alert_assigned')); + return ($this->config['message_alert_assigned']); } function alertDeptManagerONNewMessage() { - return ($this->get('message_alert_dept_manager')); + return ($this->config['message_alert_dept_manager']); } function alertONNewNote() { - return ($this->get('note_alert_active')); + return ($this->config['note_alert_active']); } function alertLastRespondentONNewNote() { - return ($this->get('note_alert_laststaff')); + return ($this->config['note_alert_laststaff']); } function alertAssignedONNewNote() { - return ($this->get('note_alert_assigned')); + return ($this->config['note_alert_assigned']); } function alertDeptManagerONNewNote() { - return ($this->get('note_alert_dept_manager')); + return ($this->config['note_alert_dept_manager']); } function alertONNewTicket() { - return ($this->get('ticket_alert_active')); + return ($this->config['ticket_alert_active']); } function alertAdminONNewTicket() { - return ($this->get('ticket_alert_admin')); + return ($this->config['ticket_alert_admin']); } function alertDeptManagerONNewTicket() { - return ($this->get('ticket_alert_dept_manager')); + return ($this->config['ticket_alert_dept_manager']); } function alertDeptMembersONNewTicket() { - return ($this->get('ticket_alert_dept_members')); + return ($this->config['ticket_alert_dept_members']); } function alertONTransfer() { - return ($this->get('transfer_alert_active')); + return ($this->config['transfer_alert_active']); } function alertAssignedONTransfer() { - return ($this->get('transfer_alert_assigned')); + return ($this->config['transfer_alert_assigned']); } function alertDeptManagerONTransfer() { - return ($this->get('transfer_alert_dept_manager')); + return ($this->config['transfer_alert_dept_manager']); } function alertDeptMembersONTransfer() { - return ($this->get('transfer_alert_dept_members')); + return ($this->config['transfer_alert_dept_members']); } function alertONAssignment() { - return ($this->get('assigned_alert_active')); + return ($this->config['assigned_alert_active']); } function alertStaffONAssignment() { - return ($this->get('assigned_alert_staff')); + return ($this->config['assigned_alert_staff']); } function alertTeamLeadONAssignment() { - return ($this->get('assigned_alert_team_lead')); + return ($this->config['assigned_alert_team_lead']); } function alertTeamMembersONAssignment() { - return ($this->get('assigned_alert_team_members')); + return ($this->config['assigned_alert_team_members']); } function alertONOverdueTicket() { - return ($this->get('overdue_alert_active')); + return ($this->config['overdue_alert_active']); } function alertAssignedONOverdueTicket() { - return ($this->get('overdue_alert_assigned')); + return ($this->config['overdue_alert_assigned']); } function alertDeptManagerONOverdueTicket() { - return ($this->get('overdue_alert_dept_manager')); + return ($this->config['overdue_alert_dept_manager']); } function alertDeptMembersONOverdueTicket() { - return ($this->get('overdue_alert_dept_members')); + return ($this->config['overdue_alert_dept_members']); } function autoAssignReopenedTickets() { - return ($this->get('auto_assign_reopened_tickets')); + return ($this->config['auto_assign_reopened_tickets']); } function showAssignedTickets() { - return ($this->get('show_assigned_tickets')); + return ($this->config['show_assigned_tickets']); } function showAnsweredTickets() { - return ($this->get('show_answered_tickets')); + return ($this->config['show_answered_tickets']); } function hideStaffName() { - return ($this->get('hide_staff_name')); + return ($this->config['hide_staff_name']); } function sendOverLimitNotice() { - return ($this->get('overlimit_notice_active')); + return ($this->config['overlimit_notice_active']); } /* Error alerts sent to admin email when enabled */ function alertONSQLError() { - return ($this->get('send_sql_errors')); + return ($this->config['send_sql_errors']); } function alertONLoginError() { - return ($this->get('send_login_errors')); + return ($this->config['send_login_errors']); } function alertONMailParseError() { - return ($this->get('send_mailparse_errors')); + return ($this->config['send_mailparse_errors']); } /* Attachments */ function getAllowedFileTypes() { - return trim($this->get('allowed_filetypes')); + return trim($this->config['allowed_filetypes']); } function emailAttachments() { - return ($this->get('email_attachments')); + return ($this->config['email_attachments']); } function allowAttachments() { - return ($this->get('allow_attachments')); + return ($this->config['allow_attachments']); } function allowOnlineAttachments() { - return ($this->allowAttachments() && $this->get('allow_online_attachments')); + return ($this->allowAttachments() && $this->config['allow_online_attachments']); } function allowAttachmentsOnlogin() { - return ($this->allowOnlineAttachments() && $this->get('allow_online_attachments_onlogin')); + return ($this->allowOnlineAttachments() && $this->config['allow_online_attachments_onlogin']); } function allowEmailAttachments() { - return ($this->allowAttachments() && $this->get('allow_email_attachments')); + return ($this->allowAttachments() && $this->config['allow_email_attachments']); } //TODO: change db field to allow_api_attachments - which will include email/json/xml attachments @@ -716,10 +546,9 @@ function allowAPIAttachments() { /* Needed by upgrader on 1.6 and older releases upgrade - not not remove */ function getUploadDir() { - return $this->get('upload_dir'); + return $this->config['upload_dir']; } - - function updateSettings($vars, &$errors) { + function updateSettings($vars, &$errors) { if(!$vars || $errors) return false; @@ -734,8 +563,8 @@ function updateSettings($vars, &$errors) { case 'emails': return $this->updateEmailsSettings($vars, $errors); break; - case 'pages': - return $this->updatePagesSettings($vars, $errors); + case 'attachments': + return $this->updateAttachmentsSetting($vars,$errors); break; case 'autoresp': return $this->updateAutoresponderSettings($vars, $errors); @@ -768,39 +597,37 @@ function updateSystemSettings($vars, &$errors) { $f['datetime_format']=array('type'=>'string', 'required'=>1, 'error'=>'Datetime format required'); $f['daydatetime_format']=array('type'=>'string', 'required'=>1, 'error'=>'Day, Datetime format required'); $f['default_timezone_id']=array('type'=>'int', 'required'=>1, 'error'=>'Default Timezone required'); - $f['pw_reset_window']=array('type'=>'int', 'required'=>1, 'min'=>1, - 'error'=>'Valid password reset window required'); if(!Validator::process($f, $vars, $errors) || $errors) return false; - return $this->updateAll(array( - 'isonline'=>$vars['isonline'], - 'helpdesk_title'=>$vars['helpdesk_title'], - 'helpdesk_url'=>$vars['helpdesk_url'], - 'default_dept_id'=>$vars['default_dept_id'], - 'default_template_id'=>$vars['default_template_id'], - 'max_page_size'=>$vars['max_page_size'], - 'log_level'=>$vars['log_level'], - 'log_graceperiod'=>$vars['log_graceperiod'], - 'passwd_reset_period'=>$vars['passwd_reset_period'], - 'staff_max_logins'=>$vars['staff_max_logins'], - 'staff_login_timeout'=>$vars['staff_login_timeout'], - 'staff_session_timeout'=>$vars['staff_session_timeout'], - 'staff_ip_binding'=>isset($vars['staff_ip_binding'])?1:0, - 'client_max_logins'=>$vars['client_max_logins'], - 'client_login_timeout'=>$vars['client_login_timeout'], - 'client_session_timeout'=>$vars['client_session_timeout'], - 'allow_pw_reset'=>isset($vars['allow_pw_reset'])?1:0, - 'pw_reset_window'=>$vars['pw_reset_window'], - 'time_format'=>$vars['time_format'], - 'date_format'=>$vars['date_format'], - 'datetime_format'=>$vars['datetime_format'], - 'daydatetime_format'=>$vars['daydatetime_format'], - 'default_timezone_id'=>$vars['default_timezone_id'], - 'enable_daylight_saving'=>isset($vars['enable_daylight_saving'])?1:0, - )); + $sql='UPDATE '.CONFIG_TABLE.' SET updated=NOW() ' + .',isonline='.db_input($vars['isonline']) + .',helpdesk_title='.db_input($vars['helpdesk_title']) + .',helpdesk_url='.db_input($vars['helpdesk_url']) + .',default_dept_id='.db_input($vars['default_dept_id']) + .',default_template_id='.db_input($vars['default_template_id']) + .',max_page_size='.db_input($vars['max_page_size']) + .',log_level='.db_input($vars['log_level']) + .',log_graceperiod='.db_input($vars['log_graceperiod']) + .',passwd_reset_period='.db_input($vars['passwd_reset_period']) + .',staff_max_logins='.db_input($vars['staff_max_logins']) + .',staff_login_timeout='.db_input($vars['staff_login_timeout']) + .',staff_session_timeout='.db_input($vars['staff_session_timeout']) + .',staff_ip_binding='.db_input(isset($vars['staff_ip_binding'])?1:0) + .',client_max_logins='.db_input($vars['client_max_logins']) + .',client_login_timeout='.db_input($vars['client_login_timeout']) + .',client_session_timeout='.db_input($vars['client_session_timeout']) + .',time_format='.db_input($vars['time_format']) + .',date_format='.db_input($vars['date_format']) + .',datetime_format='.db_input($vars['datetime_format']) + .',daydatetime_format='.db_input($vars['daydatetime_format']) + .',default_timezone_id='.db_input($vars['default_timezone_id']) + .',enable_daylight_saving='.db_input(isset($vars['enable_daylight_saving'])?1:0) + .' WHERE id='.db_input($this->getId()); + + return (db_query($sql)); } function updateTicketsSettings($vars, &$errors) { @@ -811,6 +638,7 @@ function updateTicketsSettings($vars, &$errors) { $f['default_priority_id']=array('type'=>'int', 'required'=>1, 'error'=>'Selection required'); $f['max_open_tickets']=array('type'=>'int', 'required'=>1, 'error'=>'Enter valid numeric value'); $f['autolock_minutes']=array('type'=>'int', 'required'=>1, 'error'=>'Enter lock time in minutes'); + $f['autoclose_grace_period']=array('type'=>'int', 'required'=>1, 'error'=>'Enter time in days'); if($vars['enable_captcha']) { @@ -846,33 +674,36 @@ function updateTicketsSettings($vars, &$errors) { if(!Validator::process($f, $vars, $errors) || $errors) return false; - return $this->updateAll(array( - 'random_ticket_ids'=>$vars['random_ticket_ids'], - 'default_priority_id'=>$vars['default_priority_id'], - 'default_sla_id'=>$vars['default_sla_id'], - 'max_open_tickets'=>$vars['max_open_tickets'], - 'autolock_minutes'=>$vars['autolock_minutes'], - 'allow_priority_change'=>isset($vars['allow_priority_change'])?1:0, - 'use_email_priority'=>isset($vars['use_email_priority'])?1:0, - 'enable_captcha'=>isset($vars['enable_captcha'])?1:0, - 'log_ticket_activity'=>isset($vars['log_ticket_activity'])?1:0, - 'auto_assign_reopened_tickets'=>isset($vars['auto_assign_reopened_tickets'])?1:0, - 'show_assigned_tickets'=>isset($vars['show_assigned_tickets'])?1:0, - 'show_answered_tickets'=>isset($vars['show_answered_tickets'])?1:0, - 'show_related_tickets'=>isset($vars['show_related_tickets'])?1:0, - 'show_notes_inline'=>isset($vars['show_notes_inline'])?1:0, - 'clickable_urls'=>isset($vars['clickable_urls'])?1:0, - 'hide_staff_name'=>isset($vars['hide_staff_name'])?1:0, - 'allow_attachments'=>isset($vars['allow_attachments'])?1:0, - 'allowed_filetypes'=>strtolower(preg_replace("/\n\r|\r\n|\n|\r/", '',trim($vars['allowed_filetypes']))), - 'max_file_size'=>$vars['max_file_size'], - 'max_user_file_uploads'=>$vars['max_user_file_uploads'], - 'max_staff_file_uploads'=>$vars['max_staff_file_uploads'], - 'email_attachments'=>isset($vars['email_attachments'])?1:0, - 'allow_email_attachments'=>isset($vars['allow_email_attachments'])?1:0, - 'allow_online_attachments'=>isset($vars['allow_online_attachments'])?1:0, - 'allow_online_attachments_onlogin'=>isset($vars['allow_online_attachments_onlogin'])?1:0, - )); + $sql='UPDATE '.CONFIG_TABLE.' SET updated=NOW() ' + .',random_ticket_ids='.db_input($vars['random_ticket_ids']) + .',default_priority_id='.db_input($vars['default_priority_id']) + .',default_sla_id='.db_input($vars['default_sla_id']) + .',max_open_tickets='.db_input($vars['max_open_tickets']) + .',autolock_minutes='.db_input($vars['autolock_minutes']) + .',autoclose_grace_period='.db_input($vars['autoclose_grace_period']) + .',allow_priority_change='.db_input(isset($vars['allow_priority_change'])?1:0) + .',use_email_priority='.db_input(isset($vars['use_email_priority'])?1:0) + .',enable_captcha='.db_input(isset($vars['enable_captcha'])?1:0) + .',log_ticket_activity='.db_input(isset($vars['log_ticket_activity'])?1:0) + .',auto_assign_reopened_tickets='.db_input(isset($vars['auto_assign_reopened_tickets'])?1:0) + .',show_assigned_tickets='.db_input(isset($vars['show_assigned_tickets'])?1:0) + .',show_answered_tickets='.db_input(isset($vars['show_answered_tickets'])?1:0) + .',show_related_tickets='.db_input(isset($vars['show_related_tickets'])?1:0) + .',show_notes_inline='.db_input(isset($vars['show_notes_inline'])?1:0) + .',clickable_urls='.db_input(isset($vars['clickable_urls'])?1:0) + .',hide_staff_name='.db_input(isset($vars['hide_staff_name'])?1:0) + .',allow_attachments='.db_input(isset($vars['allow_attachments'])?1:0) + .',allowed_filetypes='.db_input(strtolower(preg_replace("/\n\r|\r\n|\n|\r/", '',trim($vars['allowed_filetypes'])))) + .',max_file_size='.db_input($vars['max_file_size']) + .',max_user_file_uploads='.db_input($vars['max_user_file_uploads']) + .',max_staff_file_uploads='.db_input($vars['max_staff_file_uploads']) + .',email_attachments='.db_input(isset($vars['email_attachments'])?1:0) + .',allow_email_attachments='.db_input(isset($vars['allow_email_attachments'])?1:0) + .',allow_online_attachments='.db_input(isset($vars['allow_online_attachments'])?1:0) + .',allow_online_attachments_onlogin='.db_input(isset($vars['allow_online_attachments_onlogin'])?1:0) + .' WHERE id='.db_input($this->getId()); + + return (db_query($sql)); } @@ -883,7 +714,7 @@ function updateEmailsSettings($vars, &$errors) { $f['alert_email_id']=array('type'=>'int', 'required'=>1, 'error'=>'Selection required'); $f['admin_email']=array('type'=>'email', 'required'=>1, 'error'=>'System admin email required'); - if($vars['strip_quoted_reply'] && !trim($vars['reply_separator'])) + if($vars['strip_quoted_reply'] && !$vars['reply_separator']) $errors['reply_separator']='Reply separator required to strip quoted reply.'; if($vars['admin_email'] && Email::getIdByEmail($vars['admin_email'])) //Make sure admin email is not also a system email. @@ -892,79 +723,76 @@ function updateEmailsSettings($vars, &$errors) { if(!Validator::process($f,$vars,$errors) || $errors) return false; - return $this->updateAll(array( - 'default_email_id'=>$vars['default_email_id'], - 'alert_email_id'=>$vars['alert_email_id'], - 'default_smtp_id'=>$vars['default_smtp_id'], - 'admin_email'=>$vars['admin_email'], - 'enable_auto_cron'=>isset($vars['enable_auto_cron'])?1:0, - 'enable_mail_polling'=>isset($vars['enable_mail_polling'])?1:0, - 'strip_quoted_reply'=>isset($vars['strip_quoted_reply'])?1:0, - 'reply_separator'=>$vars['reply_separator'], - )); - } + $sql='UPDATE '.CONFIG_TABLE.' SET updated=NOW() ' + .',default_email_id='.db_input($vars['default_email_id']) + .',alert_email_id='.db_input($vars['alert_email_id']) + .',default_smtp_id='.db_input($vars['default_smtp_id']) + .',admin_email='.db_input($vars['admin_email']) + .',enable_auto_cron='.db_input(isset($vars['enable_auto_cron'])?1:0) + .',enable_mail_polling='.db_input(isset($vars['enable_mail_polling'])?1:0) + .',strip_quoted_reply='.db_input(isset($vars['strip_quoted_reply'])?1:0) + .',reply_separator='.db_input($vars['reply_separator']) + .' WHERE id='.db_input($this->getId()); + - function getLogo($site) { - $id = $this->get("{$site}_logo_id", false); - return ($id) ? AttachmentFile::lookup($id) : null; - } - function getClientLogo() { - return $this->getLogo('client'); - } - function getLogoId($site) { - return $this->get("{$site}_logo_id", false); - } - function getClientLogoId() { - return $this->getLogoId('client'); + + + return (db_query($sql)); } - function updatePagesSettings($vars, &$errors) { + function updateAttachmentsSetting($vars,&$errors) { - $f=array(); - $f['landing_page_id'] = array('type'=>'int', 'required'=>1, 'error'=>'required'); - $f['offline_page_id'] = array('type'=>'int', 'required'=>1, 'error'=>'required'); - $f['thank-you_page_id'] = array('type'=>'int', 'required'=>1, 'error'=>'required'); - - if ($_FILES['logo']) { - $error = false; - list($logo) = AttachmentFile::format($_FILES['logo']); - if (!$logo) - ; // Pass - elseif ($logo['error']) - $errors['logo'] = $logo['error']; - elseif (!($id = AttachmentFile::uploadLogo($logo, $error))) - $errors['logo'] = 'Unable to upload logo image. '.$error; + + if($vars['allow_attachments']) { + + if(!ini_get('file_uploads')) + $errors['err']='The \'file_uploads\' directive is disabled in php.ini'; + + if(!is_numeric($vars['max_file_size'])) + $errors['max_file_size']='Maximum file size required'; + + if(!$vars['allowed_filetypes']) + $errors['allowed_filetypes']='Allowed file extentions required'; + + if(!($maxfileuploads=ini_get('max_file_uploads'))) + $maxfileuploads=DEFAULT_MAX_FILE_UPLOADS; + + if(!$vars['max_user_file_uploads'] || $vars['max_user_file_uploads']>$maxfileuploads) + $errors['max_user_file_uploads']='Invalid selection. Must be less than '.$maxfileuploads; + + if(!$vars['max_staff_file_uploads'] || $vars['max_staff_file_uploads']>$maxfileuploads) + $errors['max_staff_file_uploads']='Invalid selection. Must be less than '.$maxfileuploads; } - if(!Validator::process($f, $vars, $errors) || $errors) - return false; + if($errors) return false; - if (isset($vars['delete-logo'])) - foreach ($vars['delete-logo'] as $id) - if (($vars['selected-logo'] != $id) - && ($f = AttachmentFile::lookup($id))) - $f->delete(); + $sql= 'UPDATE '.CONFIG_TABLE.' SET updated=NOW() ' + .',allow_attachments='.db_input(isset($vars['allow_attachments'])?1:0) + .',allowed_filetypes='.db_input(strtolower(preg_replace("/\n\r|\r\n|\n|\r/", '',trim($vars['allowed_filetypes'])))) + .',max_file_size='.db_input($vars['max_file_size']) + .',max_user_file_uploads='.db_input($vars['max_user_file_uploads']) + .',max_staff_file_uploads='.db_input($vars['max_staff_file_uploads']) + .',email_attachments='.db_input(isset($vars['email_attachments'])?1:0) + .',allow_email_attachments='.db_input(isset($vars['allow_email_attachments'])?1:0) + .',allow_online_attachments='.db_input(isset($vars['allow_online_attachments'])?1:0) + .',allow_online_attachments_onlogin='.db_input(isset($vars['allow_online_attachments_onlogin'])?1:0) + .' WHERE id='.db_input($this->getId()); - return $this->updateAll(array( - 'landing_page_id' => $vars['landing_page_id'], - 'offline_page_id' => $vars['offline_page_id'], - 'thank-you_page_id' => $vars['thank-you_page_id'], - 'client_logo_id' => ( - (is_numeric($vars['selected-logo']) && $vars['selected-logo']) - ? $vars['selected-logo'] : false), - )); + return (db_query($sql)); } function updateAutoresponderSettings($vars, &$errors) { if($errors) return false; - return $this->updateAll(array( - 'ticket_autoresponder'=>$vars['ticket_autoresponder'], - 'message_autoresponder'=>$vars['message_autoresponder'], - 'ticket_notice_active'=>$vars['ticket_notice_active'], - 'overlimit_notice_active'=>$vars['overlimit_notice_active'], - )); + $sql ='UPDATE '.CONFIG_TABLE.' SET updated=NOW() ' + .',ticket_autoresponder='.db_input($vars['ticket_autoresponder']) + .',message_autoresponder='.db_input($vars['message_autoresponder']) + .',ticket_notice_active='.db_input($vars['ticket_notice_active']) + .',overlimit_notice_active='.db_input($vars['overlimit_notice_active']) + .' WHERE id='.db_input($this->getId()); + + return (db_query($sql)); } @@ -972,10 +800,12 @@ function updateKBSettings($vars, &$errors) { if($errors) return false; - return $this->updateAll(array( - 'enable_kb'=>isset($vars['enable_kb'])?1:0, - 'enable_premade'=>isset($vars['enable_premade'])?1:0, - )); + $sql = 'UPDATE '.CONFIG_TABLE.' SET updated=NOW() ' + .',enable_kb='.db_input(isset($vars['enable_kb'])?1:0) + .',enable_premade='.db_input(isset($vars['enable_premade'])?1:0) + .' WHERE id='.db_input($this->getId()); + + return (db_query($sql)); } @@ -1025,42 +855,43 @@ function updateAlertsSettings($vars, &$errors) { if($errors) return false; - return $this->updateAll(array( - 'ticket_alert_active'=>$vars['ticket_alert_active'], - 'ticket_alert_admin'=>isset($vars['ticket_alert_admin'])?1:0, - 'ticket_alert_dept_manager'=>isset($vars['ticket_alert_dept_manager'])?1:0, - 'ticket_alert_dept_members'=>isset($vars['ticket_alert_dept_members'])?1:0, - 'message_alert_active'=>$vars['message_alert_active'], - 'message_alert_laststaff'=>isset($vars['message_alert_laststaff'])?1:0, - 'message_alert_assigned'=>isset($vars['message_alert_assigned'])?1:0, - 'message_alert_dept_manager'=>isset($vars['message_alert_dept_manager'])?1:0, - 'note_alert_active'=>$vars['note_alert_active'], - 'note_alert_laststaff'=>isset($vars['note_alert_laststaff'])?1:0, - 'note_alert_assigned'=>isset($vars['note_alert_assigned'])?1:0, - 'note_alert_dept_manager'=>isset($vars['note_alert_dept_manager'])?1:0, - 'assigned_alert_active'=>$vars['assigned_alert_active'], - 'assigned_alert_staff'=>isset($vars['assigned_alert_staff'])?1:0, - 'assigned_alert_team_lead'=>isset($vars['assigned_alert_team_lead'])?1:0, - 'assigned_alert_team_members'=>isset($vars['assigned_alert_team_members'])?1:0, - 'transfer_alert_active'=>$vars['transfer_alert_active'], - 'transfer_alert_assigned'=>isset($vars['transfer_alert_assigned'])?1:0, - 'transfer_alert_dept_manager'=>isset($vars['transfer_alert_dept_manager'])?1:0, - 'transfer_alert_dept_members'=>isset($vars['transfer_alert_dept_members'])?1:0, - 'overdue_alert_active'=>$vars['overdue_alert_active'], - 'overdue_alert_assigned'=>isset($vars['overdue_alert_assigned'])?1:0, - 'overdue_alert_dept_manager'=>isset($vars['overdue_alert_dept_manager'])?1:0, - 'overdue_alert_dept_members'=>isset($vars['overdue_alert_dept_members'])?1:0, - 'send_sys_errors'=>isset($vars['send_sys_errors'])?1:0, - 'send_sql_errors'=>isset($vars['send_sql_errors'])?1:0, - 'send_login_errors'=>isset($vars['send_login_errors'])?1:0, - )); - } - - //Used to detect version prior to 1.7 (useful during upgrade) - /* static */ function getDBVersion() { - $sql='SELECT `ostversion` FROM '.TABLE_PREFIX.'config ' - .'WHERE id=1'; - return db_result(db_query($sql)); + $sql= 'UPDATE '.CONFIG_TABLE.' SET updated=NOW() ' + .',ticket_alert_active='.db_input($vars['ticket_alert_active']) + .',ticket_alert_admin='.db_input(isset($vars['ticket_alert_admin'])?1:0) + .',ticket_alert_dept_manager='.db_input(isset($vars['ticket_alert_dept_manager'])?1:0) + .',ticket_alert_dept_members='.db_input(isset($vars['ticket_alert_dept_members'])?1:0) + .',message_alert_active='.db_input($vars['message_alert_active']) + .',message_alert_laststaff='.db_input(isset($vars['message_alert_laststaff'])?1:0) + .',message_alert_assigned='.db_input(isset($vars['message_alert_assigned'])?1:0) + .',message_alert_dept_manager='.db_input(isset($vars['message_alert_dept_manager'])?1:0) + .',note_alert_active='.db_input($vars['note_alert_active']) + .',note_alert_laststaff='.db_input(isset($vars['note_alert_laststaff'])?1:0) + .',note_alert_assigned='.db_input(isset($vars['note_alert_assigned'])?1:0) + .',note_alert_dept_manager='.db_input(isset($vars['note_alert_dept_manager'])?1:0) + .',assigned_alert_active='.db_input($vars['assigned_alert_active']) + .',assigned_alert_staff='.db_input(isset($vars['assigned_alert_staff'])?1:0) + .',assigned_alert_team_lead='.db_input(isset($vars['assigned_alert_team_lead'])?1:0) + .',assigned_alert_team_members='.db_input(isset($vars['assigned_alert_team_members'])?1:0) + .',transfer_alert_active='.db_input($vars['transfer_alert_active']) + .',transfer_alert_assigned='.db_input(isset($vars['transfer_alert_assigned'])?1:0) + .',transfer_alert_dept_manager='.db_input(isset($vars['transfer_alert_dept_manager'])?1:0) + .',transfer_alert_dept_members='.db_input(isset($vars['transfer_alert_dept_members'])?1:0) + .',overdue_alert_active='.db_input($vars['overdue_alert_active']) + .',overdue_alert_assigned='.db_input(isset($vars['overdue_alert_assigned'])?1:0) + .',overdue_alert_dept_manager='.db_input(isset($vars['overdue_alert_dept_manager'])?1:0) + .',overdue_alert_dept_members='.db_input(isset($vars['overdue_alert_dept_members'])?1:0) + .',send_sys_errors='.db_input(isset($vars['send_sys_errors'])?1:0) + .',send_sql_errors='.db_input(isset($vars['send_sql_errors'])?1:0) + .',send_login_errors='.db_input(isset($vars['send_login_errors'])?1:0) + .' WHERE id='.db_input($this->getId()); + + return (db_query($sql)); + + } + + /** static **/ + function lookup($id) { + return ($id && ($cfg = new Config($id)) && $cfg->getId()==$id)?$cfg:null; } } ?> From 66938cfcdbde3ac62ba482a5d3c69ef214a68b45 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 14:57:47 -0500 Subject: [PATCH 13/16] Pending Ticket Status --- include/class.cron.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/class.cron.php b/include/class.cron.php index 257926e2..012727d5 100644 --- a/include/class.cron.php +++ b/include/class.cron.php @@ -27,6 +27,7 @@ function TicketMonitor() { require_once(INCLUDE_DIR.'class.ticket.php'); require_once(INCLUDE_DIR.'class.lock.php'); Ticket::checkOverdue(); //Make stale tickets overdue + Ticket::autoClose(); //Close pending tickets TicketLock::cleanup(); //Remove expired locks } @@ -41,10 +42,6 @@ function CleanOrphanedFiles() { } function run(){ //called by outside cron NOT autocron - global $ost; - if (!$ost || $ost->isUpgradePending()) - return; - self::MailFetcher(); self::TicketMonitor(); self::PurgeLogs(); From 3c4bccdf30606fe724690710b25a0a5b77ef0907 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 14:59:26 -0500 Subject: [PATCH 14/16] Pending Ticket Status --- include/class.ticket.php | 245 ++++++++++++++++++--------------------- 1 file changed, 113 insertions(+), 132 deletions(-) diff --git a/include/class.ticket.php b/include/class.ticket.php index c3eb29d8..bfc20f7d 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -114,6 +114,10 @@ function isReopened() { return ($this->getReopenDate()); } + function isPending(){ + return (strcasecmp($this->getStatus(),'Pending')==0); + } + function isClosed() { return (strcasecmp($this->getStatus(),'Closed')==0); } @@ -471,11 +475,7 @@ function getLastMsgId() { } function getLastMessage() { - - if($this->getLastMsgId()) - return Message::lookup($this->getLastMsgId(), $this->getId()); - - return Message::lastByTicketId($this->getId()); + return Message::lookup($this->getLastMsgId(), $this->getId()); } function getThread() { @@ -588,7 +588,7 @@ function setSLAId($slaId) { /** * Selects the appropriate service-level-agreement plan for this ticket. * When tickets are transfered between departments, the SLA of the new - * department should be applied to the ticket. This would be useful, + * department should be applied to the ticket. This would be usefule, * for instance, if the ticket is transferred to a different department * which has a shorter grace period, the ticket should be considered * overdue in the shorter window now that it is owned by the new @@ -601,7 +601,7 @@ function setSLAId($slaId) { */ function selectSLAId($trump=null) { global $cfg; - # XXX Should the SLA be overridden if it was originally set via an + # XXX Should the SLA be overwritten if it was originally set via an # email filter? This method doesn't consider such a case if ($trump && is_numeric($trump)) { $slaId = $trump; @@ -629,28 +629,30 @@ function setTeamId($teamId) { //Status helper. function setStatus($status) { - if(strcasecmp($this->getStatus(), $status)==0) return true; //No changes needed. - switch(strtolower($status)) { case 'open': return $this->reopen(); break; + case 'pending': + return $this->pending(); + break; case 'closed': return $this->close(); break; } - return false; - } + } function setState($state, $alerts=false) { - switch(strtolower($state)) { case 'open': return $this->setStatus('open'); break; + case 'pending': + return $this->setStatus('pending'); + break; case 'closed': return $this->setStatus('closed'); break; @@ -669,9 +671,8 @@ function setState($state, $alerts=false) { case 'unassined': return $this->unassign(); } - return false; - } + } @@ -684,6 +685,20 @@ function setAnsweredState($isanswered) { return (db_query($sql) && db_affected_rows()); } + //Mark Ticket as Pending + function pending() { + global $thisstaff; + $sql='UPDATE '.TICKET_TABLE.' SET isoverdue=0, duedate=NULL, updated=NOW(), status='.db_input('pending'); + if($thisstaff) //Give the closing staff credit. + $sql.=', staff_id='.db_input($thisstaff->getId()); + $sql.=' WHERE ticket_id='.db_input($this->getId()); + if(!db_query($sql) || !db_affected_rows()) + return false; + $this->reload(); + $this->logEvent('pending'); + return true; + } + //Close the ticket function close() { global $thisstaff; @@ -737,14 +752,12 @@ function onNewTicket($message, $autorespond=true, $alertstaff=true) { if(!$dept || !($email=$dept->getAutoRespEmail())) $email =$cfg->getDefaultEmail(); - $options = array('references'=>$message->getEmailMessageId()); - //Send auto response - if enabled. if($autorespond && $email && $cfg->autoRespONNewTicket() && $dept->autoRespONNewTicket() && ($msg=$tpl->getAutoRespMsgTemplate())) { - $msg = $this->replaceVars($msg->asArray(), + $msg = $this->replaceVars($msg, array('message' => $message, 'signature' => ($dept && $dept->isPublic())?$dept->getSignature():'') ); @@ -752,8 +765,7 @@ function onNewTicket($message, $autorespond=true, $alertstaff=true) { if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator())) $msg['body'] ="\n$tag\n\n".$msg['body']; - $email->sendAutoReply($this->getEmail(), $msg['subj'], - $msg['body'], null, $options); + $email->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body']); } if(!($email=$cfg->getAlertEmail())) @@ -764,14 +776,13 @@ function onNewTicket($message, $autorespond=true, $alertstaff=true) { && $cfg->alertONNewTicket() && ($msg=$tpl->getNewTicketAlertMsgTemplate())) { - $msg = $this->replaceVars($msg->asArray(), array('message' => $message)); + $msg = $this->replaceVars($msg, array('message' => $message)); $recipients=$sentlist=array(); //Alert admin?? if($cfg->alertAdminONNewTicket()) { $alert = str_replace('%{recipient}', 'Admin', $msg['body']); - $email->sendAlert($cfg->getAdminEmail(), $msg['subj'], - $alert, null, $options); + $email->sendAlert($cfg->getAdminEmail(), $msg['subj'], $alert); $sentlist[]=$cfg->getAdminEmail(); } @@ -787,8 +798,7 @@ function onNewTicket($message, $autorespond=true, $alertstaff=true) { foreach( $recipients as $k=>$staff) { if(!is_object($staff) || !$staff->isAvailable() || in_array($staff->getEmail(), $sentlist)) continue; $alert = str_replace('%{recipient}', $staff->getFirstName(), $msg['body']); - $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, - null, $options); + $email->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } @@ -818,7 +828,7 @@ function onOpenLimit($sendNotice=true) { if($tpl && ($msg=$tpl->getOverlimitMsgTemplate()) && $email) { - $msg = $this->replaceVars($msg->asArray(), + $msg = $this->replaceVars($msg, array('signature' => ($dept && $dept->isPublic())?$dept->getSignature():'')); $email->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body']); @@ -837,13 +847,13 @@ function onOpenLimit($sendNotice=true) { } function onResponse() { - db_query('UPDATE '.TICKET_TABLE.' SET isanswered=1,lastresponse=NOW(), updated=NOW() WHERE ticket_id='.db_input($this->getId())); + db_query('UPDATE '.TICKET_TABLE.' SET isoverdue=0,isanswered=1,lastresponse=NOW(), updated=NOW() WHERE ticket_id='.db_input($this->getId())); } - function onMessage($autorespond=true, $message=null) { + function onMessage($autorespond=true, $alert=true) { global $cfg; - db_query('UPDATE '.TICKET_TABLE.' SET isanswered=0,lastmessage=NOW() WHERE ticket_id='.db_input($this->getId())); + db_query('UPDATE '.TICKET_TABLE.' SET status="open",isoverdue=0,isanswered=0,lastmessage=NOW() WHERE ticket_id='.db_input($this->getId())); //auto-assign to closing staff or last respondent if(!($staff=$this->getStaff()) || !$staff->isAvailable()) { @@ -877,18 +887,14 @@ function onMessage($autorespond=true, $message=null) { //If enabled...send confirmation to user. ( New Message AutoResponse) if($email && $tpl && ($msg=$tpl->getNewMessageAutorepMsgTemplate())) { - $msg = $this->replaceVars($msg->asArray(), + $msg = $this->replaceVars($msg, array('signature' => ($dept && $dept->isPublic())?$dept->getSignature():'')); //Reply separator tag. if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator())) $msg['body'] ="\n$tag\n\n".$msg['body']; - if (!$message) - $message = $this->getLastMessage(); - $options = array('references' => $message->getEmailMessageId()); - $email->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body'], - null, $options); + $email->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body']); } } @@ -906,8 +912,7 @@ function onAssign($assignee, $comments, $alert=true) { $assigner = $thisstaff?$thisstaff:'SYSTEM (Auto Assignment)'; //Log an internal note - no alerts on the internal note. - $note = $this->logNote('Ticket Assigned to '.$assignee->getName(), - $comments, $assigner, false); + $this->logNote('Ticket Assigned to '.$assignee->getName(), $comments, $assigner, false); //See if we need to send alerts if(!$alert || !$cfg->alertONAssignment()) return true; //No alerts! @@ -937,7 +942,7 @@ function onAssign($assignee, $comments, $alert=true) { //Get the message template if($email && $recipients && $tpl && ($msg=$tpl->getAssignedAlertMsgTemplate())) { - $msg = $this->replaceVars($msg->asArray(), + $msg = $this->replaceVars($msg, array('comments' => $comments, 'assignee' => $assignee, 'assigner' => $assigner @@ -945,12 +950,10 @@ function onAssign($assignee, $comments, $alert=true) { //Send the alerts. $sentlist=array(); - $options = array('references' => $note->getEmailMessageId()); foreach( $recipients as $k=>$staff) { if(!is_object($staff) || !$staff->isAvailable() || in_array($staff->getEmail(), $sentlist)) continue; $alert = str_replace('%{recipient}', $staff->getFirstName(), $msg['body']); - $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, - null, $options); + $email->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } } @@ -980,8 +983,7 @@ function onOverdue($whine=true, $comments="") { //Get the message template if($tpl && ($msg=$tpl->getOverdueAlertMsgTemplate()) && $email) { - $msg = $this->replaceVars($msg->asArray(), - array('comments' => $comments)); + $msg = $this->replaceVars($msg, array('comments' => $comments)); //recipients $recipients=array(); @@ -1150,13 +1152,13 @@ function transfer($deptId, $comments, $alert = true) { $this->reload(); // Set SLA of the new department - if(!$this->getSLAId() || $this->getSLA()->isTransient()) + if(!$this->getSLAId()) $this->selectSLAId(); /*** log the transfer comments as internal note - with alerts disabled - ***/ $title='Ticket transfered from '.$currentDept.' to '.$this->getDeptName(); $comments=$comments?$comments:$title; - $note = $this->logNote($title, $comments, $thisstaff, false); + $this->logNote($title, $comments, $thisstaff, false); $this->logEvent('transferred'); @@ -1175,8 +1177,7 @@ function transfer($deptId, $comments, $alert = true) { //Get the message template if($tpl && ($msg=$tpl->getTransferAlertMsgTemplate()) && $email) { - $msg = $this->replaceVars($msg->asArray(), - array('comments' => $comments, 'staff' => $thisstaff)); + $msg = $this->replaceVars($msg, array('comments' => $comments, 'staff' => $thisstaff)); //recipients $recipients=array(); //Assigned staff or team... if any @@ -1196,12 +1197,10 @@ function transfer($deptId, $comments, $alert = true) { $recipients[]= $manager; $sentlist=array(); - $options = array('references' => $note->getEmailMessageId()); foreach( $recipients as $k=>$staff) { if(!is_object($staff) || !$staff->isAvailable() || in_array($staff->getEmail(), $sentlist)) continue; $alert = str_replace('%{recipient}', $staff->getFirstName(), $msg['body']); - $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, - null, $options); + $email->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } } @@ -1293,12 +1292,11 @@ function postMessage($vars, $origin='', $alerts=true) { //Strip quoted reply...on emailed replies if(!strcasecmp($origin, 'Email') && $cfg->stripQuotedReply() - && ($tag=$cfg->getReplySeparator()) - && strpos($vars['message'], $tag)) - if((list($msg) = explode($tag, $vars['message'], 2)) && trim($msg)) + && ($tag=$cfg->getReplySeparator()) && strpos($vars['message'], $tag)) + if(list($msg) = split($tag, $vars['message'])) $vars['message'] = $msg; - if(isset($vars['ip'])) + if($vars['ip']) $vars['ip_address'] = $vars['ip']; elseif(!$vars['ip_address'] && $_SERVER['REMOTE_ADDR']) $vars['ip_address'] = $_SERVER['REMOTE_ADDR']; @@ -1309,13 +1307,16 @@ function postMessage($vars, $origin='', $alerts=true) { $this->setLastMsgId($message->getId()); + if (isset($vars['mid'])) + $message->saveEmailInfo($vars); + if(!$alerts) return $message; //Our work is done... $autorespond = true; if ($autorespond && $message->isAutoResponse()) $autorespond=false; - $this->onMessage($autorespond, $message); //must be called b4 sending alerts to staff. + $this->onMessage($autorespond); //must be called b4 sending alerts to staff. $dept = $this->getDept(); @@ -1328,7 +1329,7 @@ function postMessage($vars, $origin='', $alerts=true) { //If enabled...send alert to staff (New Message Alert) if($cfg->alertONNewMessage() && $tpl && $email && ($msg=$tpl->getNewMessageAlertMsgTemplate())) { - $msg = $this->replaceVars($msg->asArray(), array('message' => $message)); + $msg = $this->replaceVars($msg, array('message' => $message)); //Build list of recipients and fire the alerts. $recipients=array(); @@ -1346,12 +1347,10 @@ function postMessage($vars, $origin='', $alerts=true) { $recipients[]=$manager; $sentlist=array(); //I know it sucks...but..it works. - $options = array('references'=>$message->getEmailMessageId()); foreach( $recipients as $k=>$staff) { if(!$staff || !$staff->getEmail() || !$staff->isAvailable() || in_array($staff->getEmail(), $sentlist)) continue; $alert = str_replace('%{recipient}', $staff->getFirstName(), $msg['body']); - $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, - null, $options); + $email->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } } @@ -1397,16 +1396,13 @@ function postCannedReply($canned, $msgId, $alert=true) { else $signature=''; - $msg = $this->replaceVars($msg->asArray(), - array('response' => $response, 'signature' => $signature)); + $msg = $this->replaceVars($msg, array('response' => $response, 'signature' => $signature)); if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator())) $msg['body'] ="\n$tag\n\n".$msg['body']; $attachments =($cfg->emailAttachments() && $files)?$response->getAttachments():array(); - $options = array('references' => $response->getEmailMessageId()); - $email->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body'], $attachments, - $options); + $email->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body'], $attachments); } return $response; @@ -1453,7 +1449,7 @@ function postReply($vars, &$errors, $alert = true) { else $signature=''; - $msg = $this->replaceVars($msg->asArray(), + $msg = $this->replaceVars($msg, array('response' => $response, 'signature' => $signature, 'staff' => $thisstaff)); if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator())) @@ -1461,10 +1457,8 @@ function postReply($vars, &$errors, $alert = true) { //Set attachments if emailing. $attachments = $cfg->emailAttachments()?$response->getAttachments():array(); - $options = array('references' => $response->getEmailMessageId()); //TODO: setup 5 param (options... e.g mid trackable on replies) - $email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments, - $options); + $email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments); } return $response; @@ -1554,8 +1548,7 @@ function postNote($vars, &$errors, $poster, $alert=true) { if($tpl && ($msg=$tpl->getNoteAlertMsgTemplate()) && $email) { - $msg = $this->replaceVars($msg->asArray(), - array('note' => $note)); + $msg = $this->replaceVars($msg, array('note' => $note)); // Alert recipients $recipients=array(); @@ -1573,17 +1566,12 @@ function postNote($vars, &$errors, $poster, $alert=true) { $recipients[]=$dept->getManager(); $attachments = $note->getAttachments(); - $options = array('references' => $note->getEmailMessageId()); $sentlist=array(); foreach( $recipients as $k=>$staff) { - if(!is_object($staff) - || !$staff->isAvailable() //Don't bother vacationing staff. - || in_array($staff->getEmail(), $sentlist) //No duplicates. - || $note->getStaffId() == $staff->getId()) //No need to alert the poster! - continue; + if(!$staff || !is_object($staff) || !$staff->getEmail() || !$staff->isAvailable()) continue; + if(in_array($staff->getEmail(), $sentlist) || ($staffId && $staffId==$staff->getId())) continue; $alert = str_replace('%{recipient}', $staff->getFirstName(), $msg['body']); - $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, $attachments, - $options); + $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, $attachments); $sentlist[] = $staff->getEmail(); } } @@ -1637,11 +1625,11 @@ function update($vars, &$errors) { if($vars['duedate']) { if($this->isClosed()) - $errors['duedate']='Due date can NOT be set on a closed ticket'; + $errors['duedate']='Duedate can NOT be set on a closed ticket'; elseif(!$vars['time'] || strpos($vars['time'],':')===false) $errors['time']='Select time'; elseif(strtotime($vars['duedate'].' '.$vars['time'])===false) - $errors['duedate']='Invalid due date'; + $errors['duedate']='Invalid duedate'; elseif(strtotime($vars['duedate'].' '.$vars['time'])<=time()) $errors['duedate']='Due date must be in the future'; } @@ -1665,7 +1653,6 @@ function update($vars, &$errors) { .' ,priority_id='.db_input($vars['priorityId']) .' ,topic_id='.db_input($vars['topicId']) .' ,sla_id='.db_input($vars['slaId']) - .' ,source='.db_input($vars['source']) .' ,duedate='.($vars['duedate']?db_input(date('Y-m-d G:i',Misc::dbtime($vars['duedate'].' '.$vars['time']))):'NULL'); if($vars['duedate']) { //We are setting new duedate... @@ -1683,10 +1670,6 @@ function update($vars, &$errors) { $this->logNote('Ticket Updated', $vars['note'], $thisstaff); $this->reload(); - // Reselect SLA if transient - if(!$this->getSLAId() || $this->getSLA()->isTransient()) - $this->selectSLAId(); - //Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue. if($this->isOverdue() && (!$this->getEstDueDate() //Duedate + SLA cleared @@ -1699,7 +1682,7 @@ function update($vars, &$errors) { } - /*============== Static functions. Use Ticket::function(params); =============nolint*/ + /*============== Static functions. Use Ticket::function(params); ==================*/ function getIdByExtId($extId, $email=null) { if(!$extId || !is_numeric($extId)) @@ -1774,34 +1757,19 @@ function getStaffStats($staff) { global $cfg; /* Unknown or invalid staff */ - if(!$staff || (!is_object($staff) && !($staff=Staff::lookup($staff))) || !$staff->isStaff()) + if(!$staff || (!is_object($staff) && !($staff=Staff::lookup($staff))) || !$staff->isStaff() || $cfg->getDBVersion()) return null; $sql='SELECT count(open.ticket_id) as open, count(answered.ticket_id) as answered ' - .' ,count(overdue.ticket_id) as overdue, count(assigned.ticket_id) as assigned, count(closed.ticket_id) as closed ' + .' ,count(overdue.ticket_id) as overdue, count(assigned.ticket_id) as assigned, count(pending.ticket_id) as pending, count(closed.ticket_id) as closed ' .' FROM '.TICKET_TABLE.' ticket ' - .' LEFT JOIN '.TICKET_TABLE.' open - ON (open.ticket_id=ticket.ticket_id - AND open.status=\'open\' - AND open.isanswered=0 - '.((!($cfg->showAssignedTickets() || $staff->showAssignedTickets()))? - ' AND open.staff_id=0 ':'').') ' - .' LEFT JOIN '.TICKET_TABLE.' answered - ON (answered.ticket_id=ticket.ticket_id - AND answered.status=\'open\' - AND answered.isanswered=1) ' - .' LEFT JOIN '.TICKET_TABLE.' overdue - ON (overdue.ticket_id=ticket.ticket_id - AND overdue.status=\'open\' - AND overdue.isoverdue=1) ' - .' LEFT JOIN '.TICKET_TABLE.' assigned - ON (assigned.ticket_id=ticket.ticket_id - AND assigned.status=\'open\' - AND assigned.staff_id='.db_input($staff->getId()).')' - .' LEFT JOIN '.TICKET_TABLE.' closed - ON (closed.ticket_id=ticket.ticket_id - AND closed.status=\'closed\' )' - .' WHERE (ticket.staff_id='.db_input($staff->getId()); + .' LEFT JOIN '.TICKET_TABLE.' open ON (open.ticket_id=ticket.ticket_id AND open.status=\'open\' AND open.isanswered=0 '.((!($cfg->showAssignedTickets() || $staff->showAssignedTickets()))? ' AND open.staff_id=0 ':'').') ' + .' LEFT JOIN '.TICKET_TABLE.' answered ON (answered.ticket_id=ticket.ticket_id AND answered.status=\'open\' AND answered.isanswered=1) ' + .' LEFT JOIN '.TICKET_TABLE.' pending ON (pending.ticket_id=ticket.ticket_id AND pending.status=\'pending\' )' + .' LEFT JOIN '.TICKET_TABLE.' overdue ON (overdue.ticket_id=ticket.ticket_id AND overdue.status=\'open\' AND overdue.isoverdue=1) ' + .' LEFT JOIN '.TICKET_TABLE.' assigned ON (assigned.ticket_id=ticket.ticket_id AND assigned.status=\'open\' AND assigned.staff_id='.db_input($staff->getId()).')' + .' LEFT JOIN '.TICKET_TABLE.' closed ON (closed.ticket_id=ticket.ticket_id AND closed.status=\'closed\' )' + .' WHERE (ticket.staff_id='.db_input($staff->getId()); if(($teams=$staff->getTeams())) $sql.=' OR ticket.team_id IN('.implode(',', db_input(array_filter($teams))).')'; @@ -1826,13 +1794,15 @@ function getClientStats($email) { if(!$email || !Validator::is_email($email)) return null; - $sql='SELECT count(open.ticket_id) as open, count(closed.ticket_id) as closed ' + $sql='SELECT count(open.ticket_id) as open, count(pending.ticket_id) as pending, count(closed.ticket_id) as closed ' .' FROM '.TICKET_TABLE.' ticket ' .' LEFT JOIN '.TICKET_TABLE.' open ON (open.ticket_id=ticket.ticket_id AND open.status=\'open\') ' + .' LEFT JOIN '.TICKET_TABLE.' pending + ON (pending.ticket_id=ticket.ticket_id AND pending.status=\'pending\') ' .' LEFT JOIN '.TICKET_TABLE.' closed ON (closed.ticket_id=ticket.ticket_id AND closed.status=\'closed\')' - .' WHERE ticket.email='.db_input($email); + .' WHERE ticket.email='.db_input($email); return db_fetch_array(db_query($sql)); } @@ -1840,16 +1810,11 @@ function getClientStats($email) { /* * The mother of all functions...You break it you fix it! * - * $autorespond and $alertstaff overrides config settings... + * $autorespond and $alertstaff overwrites config settings... */ function create($vars, &$errors, $origin, $autorespond=true, $alertstaff=true) { global $ost, $cfg, $thisclient, $_FILES; - // Drop extra whitespace - foreach (array('email', 'phone', 'subject', 'name') as $f) - if (isset($vars[$f])) - $vars[$f] = trim($vars[$f]); - //Check for 403 if ($vars['email'] && Validator::is_email($vars['email'])) { @@ -1898,7 +1863,8 @@ function create($vars, &$errors, $origin, $autorespond=true, $alertstaff=true) { $fields['message'] = array('type'=>'text', 'required'=>1, 'error'=>'Message required'); switch (strtolower($origin)) { case 'web': - $fields['topicId'] = array('type'=>'int', 'required'=>1, 'error'=>'Select help topic'); + $fields['deptId'] = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required'); +$fields['topicId'] = array('type'=>'int', 'required'=>1, 'error'=>'Select help topic'); break; case 'staff': $fields['deptId'] = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required'); @@ -1912,7 +1878,8 @@ function create($vars, &$errors, $origin, $autorespond=true, $alertstaff=true) { break; default: # TODO: Return error message - $errors['err']=$errors['origin'] = 'Invalid origin given'; + $errors['err']=$errors['origin'] = 'Invalid +origin given'; } $fields['priorityId'] = array('type'=>'int', 'required'=>0, 'error'=>'Invalid Priority'); $fields['phone'] = array('type'=>'phone', 'required'=>0, 'error'=>'Valid phone # required'); @@ -1933,7 +1900,7 @@ function create($vars, &$errors, $origin, $autorespond=true, $alertstaff=true) { if(!$vars['time'] || strpos($vars['time'],':')===false) $errors['time']='Select time'; elseif(strtotime($vars['duedate'].' '.$vars['time'])===false) - $errors['duedate']='Invalid due date'; + $errors['duedate']='Invalid duedate'; elseif(strtotime($vars['duedate'].' '.$vars['time'])<=time()) $errors['duedate']='Due date must be in the future'; } @@ -1953,7 +1920,7 @@ function create($vars, &$errors, $origin, $autorespond=true, $alertstaff=true) { $priorityId=$vars['priorityId']; $source=ucfirst($vars['source']); $topic=NULL; - // Intenal mapping magic...see if we need to override anything + // Intenal mapping magic...see if we need to overwrite anything if(isset($vars['topicId']) && ($topic=Topic::lookup($vars['topicId']))) { //Ticket created via web by user/or staff $deptId=$deptId?$deptId:$topic->getDeptId(); $priorityId=$priorityId?$priorityId:$topic->getPriorityId(); @@ -2035,7 +2002,7 @@ function create($vars, &$errors, $origin, $autorespond=true, $alertstaff=true) { $ticket->assignToTeam($vars['teamId'], 'Auto Assignment'); /********** double check auto-response ************/ - //Override auto responder if the FROM email is one of the internal emails...loop control. + //Overwrite auto responder if the FROM email is one of the internal emails...loop control. if($autorespond && (Email::getIdByEmail($ticket->getEmail()))) $autorespond=false; @@ -2086,7 +2053,7 @@ function open($vars, &$errors) { if(!$thisstaff || !$thisstaff->canCreateTickets()) return false; - if($vars['source'] && !in_array(strtolower($vars['source']),array('email','phone','other'))) + if($vars['source'] && !in_array(strtolower($vars['source']),array('email','phone','other','verbal','self','online'))) $errors['source']='Invalid source - '.Format::htmlchars($vars['source']); if(!$vars['issue']) @@ -2146,19 +2113,14 @@ function open($vars, &$errors) { else $signature=''; - $msg = $ticket->replaceVars($msg->asArray(), + $msg = $ticket->replaceVars($msg, array('message' => $message, 'signature' => $signature)); if($cfg->stripQuotedReply() && ($tag=trim($cfg->getReplySeparator()))) $msg['body'] ="\n$tag\n\n".$msg['body']; $attachments =($cfg->emailAttachments() && $response)?$response->getAttachments():array(); - $references = $ticket->getLastMessage()->getEmailMessageId(); - if (isset($response)) - $references = array($response->getEmailMessageId(), $references); - $options = array('references' => $references); - $email->send($ticket->getEmail(), $msg['subj'], $msg['body'], $attachments, - $options); + $email->send($ticket->getEmail(), $msg['subj'], $msg['body'], $attachments); } return $ticket; @@ -2168,9 +2130,9 @@ function open($vars, &$errors) { function checkOverdue() { $sql='SELECT ticket_id FROM '.TICKET_TABLE.' T1 ' - .' LEFT JOIN '.SLA_TABLE.' T2 ON (T1.sla_id=T2.id AND T2.isactive=1) ' + .' INNER JOIN '.SLA_TABLE.' T2 ON (T1.sla_id=T2.id AND T2.isactive=1) ' .' WHERE status=\'open\' AND isoverdue=0 ' - .' AND ((reopened is NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),T1.created))>=T2.grace_period*3600) ' + .' AND ((reopened is NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),T1.lastresponse))>=T2.grace_period*3600) ' .' OR (reopened is NOT NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),reopened))>=T2.grace_period*3600) ' .' OR (duedate is NOT NULL AND duedategetAutoCloseGrace(); + + if($days != 0){ + + // select all tickets marked as 'pending' where updated is older than ($days) days ago + $sql = "SELECT ticket_id FROM " . TICKET_TABLE; + $sql .= " WHERE status = 'pending'"; + $sql .= " AND TIME_TO_SEC(TIMEDIFF(NOW(),updated))>=$days*86400"; + + if(($res=db_query($sql)) && db_num_rows($res)) { + while(list($id)=db_fetch_row($res)) { + if(($ticket=Ticket::lookup($id)) && $ticket->close()) + $ticket->logActivity('Ticket Closed', 'Ticket closed by the system after '.$days.' days of no activity.'); + }}} + + } } ?> From f0428d1d83dded1c6372d501443f10776f105ea8 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 15:02:46 -0500 Subject: [PATCH 15/16] Department selection with Help Topic lookup --- scp/findtopicscp.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scp/findtopicscp.php diff --git a/scp/findtopicscp.php b/scp/findtopicscp.php new file mode 100644 index 00000000..a985adee --- /dev/null +++ b/scp/findtopicscp.php @@ -0,0 +1,36 @@ + + + From cd5039039482b4529fee095e5bf2a087b2b47111 Mon Sep 17 00:00:00 2001 From: jdelhome3578 Date: Fri, 15 Nov 2013 15:04:23 -0500 Subject: [PATCH 16/16] Create display_open_topics --- include/client/display_open_topics | 94 ++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 include/client/display_open_topics diff --git a/include/client/display_open_topics b/include/client/display_open_topics new file mode 100644 index 00000000..a9c9f076 --- /dev/null +++ b/include/client/display_open_topics @@ -0,0 +1,94 @@ + + Copyright (c) 2010-2013 + For use with osTicket version 1.7ST (http://www.osticket.com) + + Released under the GNU General Public License WITHOUT ANY WARRANTY. + See osTickets's LICENSE.TXT for details. +**********************************************************************/ + +// The columns that you want to collect data for from the db +$columns = "ticket.name, ticket.subject, ticket.created, ticket.updated, ticket.priority_id, priority.priority_desc, priority.priority_color, department.dept_name"; + +// The maximum amount of open tickets that you want to display. +$limit ='30'; + +// mysql query. The columns tha +$query = "SELECT $columns + FROM ost_ticket ticket + LEFT JOIN (ost_help_topic help_topic, ost_ticket_priority priority, ost_department department) ON (ticket.topic_id = help_topic.topic_id AND ticket.priority_id = priority.priority_id AND ticket.dept_id = department.dept_id) + WHERE ticket.status != 'closed' AND help_topic.ispublic = 1 AND department.ispublic = 1 + ORDER BY ticket.priority_id DESC,ticket.updated DESC + LIMIT 0,$limit"; + +if($result=mysql_query($query)) { + $num = mysql_numrows($result); +} +?> + +
    + +> 0) { + +// table headers, if you add or remove columns edit this +echo "
    "; +echo ""; + +$i=0; +while ($i < $num) { + + // You will need one line below for each column name that you collect and want to display. + // If you are unfamiliar with php its essentially $uniqueVariable = mysql junk ( columnName ); + // Just copy one of the lines below and change the $uniqueVariable and columnName + $name = mysql_result($result,$i,"ticket.name"); + $subject = mysql_result($result,$i,"ticket.subject"); + $created = mysql_result($result,$i,"ticket.created"); + $updated = mysql_result($result,$i,"ticket.updated"); +// $agency = mysql_result($result,$i,"agency"); + $priority = mysql_result($result,$i,"priority.priority_desc"); + $prioritycolor = mysql_result($result,$i,"priority.priority_color"); + $deptname = mysql_result($result,$i,"department.dept_name"); + + // if no update say so + if ($updated == '0000-00-00 00:00:00') { + $updated = 'no update yet'; + } + + // look up priority and display proper name + // mysql query. +// $getprioritydesc = "SELECT priority_desc FROM ost_ticket_priority WHERE priority_id = $priority_id"; +// $prioritydescresult=mysql_query($getprioritydesc); +// $priority = mysql_result($prioritydescresult,0,"priority_desc"); + mysql_close(); + + // change row back ground color to make more readable + if(($i % 2) == 1) //odd + {$bgcolour = '#F6F6F6';} + else //even + {$bgcolour = '#FEFEFE';} + + //populate the table with data + echo "" + ."" + ."" + ."" + .""; + + ++$i; +} +echo "
    NameIssue (Priority)Dept.Opened onLast Update
    $name$subject ($priority)$deptname$created$updated
    "; +} + +else { + echo "

    There are no tickets open at this time.

    "; +} +?> + +