function _notifyTicket() { if (!$this->is_staff) { return; } if (!RSTicketsProHelper::getConfig('autoclose_enabled')) { return; } if ($this->_ticket->last_reply_customer) { return; } if ($this->_ticket->autoclose_sent) { return; } $date = JFactory::getDate(); $date = $date->toUnix(); $date = RSTicketsProHelper::getCurrentDate($date); $this->_db->setQuery("UPDATE #__rsticketspro_tickets SET autoclose_sent='" . $date . "' WHERE id='" . $this->_ticket->id . "' LIMIT 1"); $this->_db->query(); $interval = RSTicketsProHelper::getConfig('autoclose_email_interval') * 86400; if ($interval < 86400) { $interval = 86400; } $last_reply_interval = RSTicketsProHelper::getCurrentDate($this->_ticket->last_reply) + $interval; if ($last_reply_interval > $date) { return; } $overdue = floor(($date - $last_reply_interval) / 86400); $closed = RSTicketsProHelper::getConfig('autoclose_interval'); // get email sending settings $from = RSTicketsProHelper::getConfig('email_address'); $fromname = RSTicketsProHelper::getConfig('email_address_fullname'); // are we using global ? if (RSTicketsProHelper::getConfig('email_use_global')) { $config = new JConfig(); $from = $config->mailfrom; $fromname = $config->fromname; } $department =& JTable::getInstance('RSTicketsPro_Departments', 'Table'); $department->load($this->_ticket->department_id); if (!$department->get('email_use_global')) { $from = $department->email_address; $fromname = $department->email_address_fullname; } $email = RSTicketsProHelper::getEmail('notification_email'); $customer = JFactory::getUser($this->_ticket->customer_id); $staff = JFactory::getUser($this->_ticket->staff_id); $code = $this->_ticket->code; $replace = array('{live_site}', '{ticket}', '{customer_name}', '{customer_username}', '{customer_email}', '{staff_name}', '{staff_username}', '{staff_email}', '{code}', '{subject}', '{inactive_interval}', '{close_interval}'); $with = array(JURI::root(), RSTicketsProHelper::route(JURI::root() . 'index.php?option=com_rsticketspro&view=ticket&cid=' . $this->_ticket->id . ':' . JFilterOutput::stringURLSafe($this->_ticket->subject)), $customer->get('name'), $customer->get('username'), $customer->get('email'), $staff->get('name'), $staff->get('username'), $staff->get('email'), $code, $this->_ticket->subject, $overdue, $closed); $email_subject = str_replace($replace, $with, $email->subject); $email_message = str_replace($replace, $with, $email->message); JUtility::sendMail($from, $fromname, $customer->get('email'), $email_subject, $email_message, 1); }
function sendUserEmail(&$user, $password) { $mainframe =& JFactory::getApplication(); $lang = JFactory::getLanguage(); $lang->load('com_rsticketspro', JPATH_SITE); // get email sending settings $from = RSTicketsProHelper::getConfig('email_address'); $fromname = RSTicketsProHelper::getConfig('email_address_fullname'); // are we using global ? if (RSTicketsProHelper::getConfig('email_use_global')) { $config = new JConfig(); $from = $config->mailfrom; $fromname = $config->fromname; } $email = RSTicketsProHelper::getEmail('new_user_email'); $replace = array('{live_site}', '{username}', '{password}', '{email}'); $with = array(JURI::root(), $user->get('username'), $password, $user->get('email')); $email_subject = $email->subject; $email_message = str_replace($replace, $with, $email->message); JUtility::sendMail($from, $fromname, $user->get('email'), $email_subject, $email_message, 1); }