/** * Saves changes to an order * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); $statusmsg = ''; $data = array_map('trim', $_POST); $action = isset($data['action']) ? $data['action'] : ''; $id = $data['id'] ? $data['id'] : 0; $cost = intval($data['total']); if ($id) { // initiate extended database class $row = new Order($this->database); $row->load($id); $row->notes = \Hubzero\Utility\Sanitize::clean($data['notes']); $hold = $row->total; $row->total = $cost; // get user bank account $xprofile = User::getInstance($row->uid); $BTL_Q = new Teller($this->database, $xprofile->get('id')); switch ($action) { case 'complete_order': // adjust credit $credit = $BTL_Q->credit_summary(); $adjusted = $credit - $hold; $BTL_Q->credit_adjustment($adjusted); // remove hold $sql = "DELETE FROM `#__users_transactions` WHERE category='store' AND type='hold' AND referenceid='" . $id . "' AND uid=" . intval($row->uid); $this->database->setQuery($sql); if (!$this->database->query()) { throw new Exception($this->database->getErrorMsg(), 500); } // debit account if ($cost > 0) { $BTL_Q->withdraw($cost, Lang::txt('COM_STORE_BANKING_PURCHASE') . ' #' . $id, 'store', $id); } // update order information $row->status_changed = Date::toSql(); $row->status = 1; $statusmsg = Lang::txt('COM_STORE_ORDER') . ' #' . $id . ' ' . Lang::txt('COM_STORE_HAS_BEEN') . ' ' . strtolower(Lang::txt('COM_STORE_COMPLETED')) . '.'; break; case 'cancel_order': // adjust credit $credit = $BTL_Q->credit_summary(); $adjusted = $credit - $hold; $BTL_Q->credit_adjustment($adjusted); // remove hold $sql = "DELETE FROM `#__users_transactions` WHERE category='store' AND type='hold' AND referenceid='" . $id . "' AND uid=" . intval($row->uid); $this->database->setQuery($sql); if (!$this->database->query()) { throw new Exception($this->database->getErrorMsg(), 500); } // update order information $row->status_changed = Date::toSql(); $row->status = 2; $statusmsg = Lang::txt('COM_STORE_ORDER') . ' #' . $id . ' ' . Lang::txt('COM_STORE_HAS_BEEN') . ' ' . strtolower(Lang::txt('COM_STORE_CANCELLED')) . '.'; break; case 'message': $statusmsg = Lang::txt('COM_STORE_MSG_SENT') . '.'; break; default: $statusmsg = Lang::txt('COM_STORE_ORDER_DETAILS_UPDATED') . '.'; break; } // check content if (!$row->check()) { throw new Exception($row->getError(), 500); return; } // store new content if (!$row->store()) { throw new Exception($row->getError(), 500); } // send email if ($action || $data['message']) { if (\Hubzero\Utility\Validate::email($row->email)) { $message = new \Hubzero\Mail\Message(); $message->setSubject(Config::get('sitename') . ' ' . Lang::txt('COM_STORE_EMAIL_UPDATE_SHORT', $id)); $message->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' ' . Lang::txt('COM_STORE_STORE')); // Plain text email $eview = new \Hubzero\Mail\View(array('name' => 'emails', 'layout' => '_plain')); $eview->option = $this->_option; $eview->controller = $this->_controller; $eview->orderid = $id; $eview->cost = $cost; $eview->row = $row; $eview->action = $action; $eview->message = \Hubzero\Utility\Sanitize::stripAll($data['message']); $plain = $eview->loadTemplate(false); $plain = str_replace("\n", "\r\n", $plain); $message->addPart($plain, 'text/plain'); // HTML email $eview->setLayout('_html'); $html = $eview->loadTemplate(); $html = str_replace("\n", "\r\n", $html); $message->addPart($html, 'text/html'); // Send e-mail $message->setTo(array($row->email)); $message->send(); } } } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $statusmsg); }
/** * Saves changes to a ticket, adds a new comment/changelog, * notifies any relevant parties * * @return void */ public function saveTask($redirect = 1) { // Check for request forgeries Request::checkToken(); // Incoming $isNew = true; $id = Request::getInt('id', 0); if ($id) { $isNew = false; } // Load the old ticket so we can compare for the changelog $old = new Ticket($id); $old->set('tags', $old->tags('string')); // Initiate class and bind posted items to database fields $row = new Ticket($id); if (!$row->bind($_POST)) { throw new Exception($row->getError(), 500); } if ($row->get('target_date') && $row->get('target_date') != '0000-00-00 00:00:00') { $row->set('target_date', Date::of($row->get('target_date'), Config::get('offset'))->toSql()); } else { $row->set('target_date', '0000-00-00 00:00:00'); } $comment = Request::getVar('comment', '', 'post', 'none', 2); $rowc = new Comment(); $rowc->set('ticket', $id); // Check if changes were made inbetween the time the comment was started and posted if ($id) { $started = Request::getVar('started', Date::toSql(), 'post'); $lastcomment = $row->comments('list', array('sort' => 'created', 'sort_Dir' => 'DESC', 'limit' => 1, 'start' => 0, 'ticket' => $id))->first(); if (isset($lastcomment) && $lastcomment->created() >= $started) { $rowc->set('comment', $comment); \Notify::error(Lang::txt('Changes were made to this ticket in the time since you began commenting/making changes. Please review your changes before submitting.')); return $this->editTask($rowc); } } if ($id && isset($_POST['status']) && $_POST['status'] == 0) { $row->set('open', 0); $row->set('resolved', Lang::txt('COM_SUPPORT_TICKET_COMMENT_OPT_CLOSED')); } $row->set('open', $row->status('open')); // If an existing ticket AND closed AND previously open if ($id && !$row->get('open') && $row->get('open') != $old->get('open')) { // Record the closing time $row->set('closed', Date::toSql()); } // Check content if (!$row->check()) { throw new Exception($row->getError(), 500); } // Store new content if (!$row->store()) { throw new Exception($row->getError(), 500); } // Save the tags $row->tag(Request::getVar('tags', '', 'post'), User::get('id'), 1); $row->set('tags', $row->tags('string')); $base = Request::base(); if (substr($base, -14) == 'administrator/') { $base = substr($base, 0, strlen($base) - 14); } $webpath = trim($this->config->get('webpath'), '/'); $allowEmailResponses = $this->config->get('email_processing'); $this->config->set('email_terse', Request::getInt('email_terse', 0)); if ($this->config->get('email_terse')) { $allowEmailResponses = false; } if ($allowEmailResponses) { try { $encryptor = new \Hubzero\Mail\Token(); } catch (Exception $e) { $allowEmailResponses = false; } } // If a new ticket... if ($isNew) { // Get any set emails that should be notified of ticket submission $defs = explode(',', $this->config->get('emails', '{config.mailfrom}')); if ($defs) { // Get some email settings $msg = new \Hubzero\Mail\Message(); $msg->setSubject(Config::get('sitename') . ' ' . Lang::txt('COM_SUPPORT') . ', ' . Lang::txt('COM_SUPPORT_TICKET_NUMBER', $row->get('id'))); $msg->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_option))); // Plain text email $eview = new \Hubzero\Mail\View(array('base_path' => PATH_CORE . DS . 'components' . DS . $this->_option . DS . 'site', 'name' => 'emails', 'layout' => 'ticket_plain')); $eview->option = $this->_option; $eview->controller = $this->_controller; $eview->ticket = $row; $eview->config = $this->config; $eview->delimiter = ''; $plain = $eview->loadTemplate(false); $plain = str_replace("\n", "\r\n", $plain); $msg->addPart($plain, 'text/plain'); // HTML email $eview->setLayout('ticket_html'); $html = $eview->loadTemplate(); $html = str_replace("\n", "\r\n", $html); if (!$this->config->get('email_terse')) { foreach ($row->attachments() as $attachment) { if ($attachment->size() < 2097152) { if ($attachment->isImage()) { $file = basename($attachment->link('filepath')); $html = preg_replace('/<a class="img" data\\-filename="' . str_replace('.', '\\.', $file) . '" href="(.*?)"\\>(.*?)<\\/a>/i', '<img src="' . $message->getEmbed($attachment->link('filepath')) . '" alt="" />', $html); } else { $message->addAttachment($attachment->link('filepath')); } } } } $msg->addPart($html, 'text/html'); // Loop through the addresses foreach ($defs as $def) { $def = trim($def); // Check if the address should come from Joomla config if ($def == '{config.mailfrom}') { $def = Config::get('mailfrom'); } // Check for a valid address if (Validate::email($def)) { // Send e-mail $msg->setTo(array($def)); $msg->send(); } } } } // Incoming comment if ($comment) { // If a comment was posted by the ticket submitter to a "waiting user response" ticket, change status. if ($row->isWaiting() && User::get('username') == $row->get('login')) { $row->open(); } } // Create a new support comment object and populate it $access = Request::getInt('access', 0); //$rowc = new Comment(); $rowc->set('ticket', $row->get('id')); $rowc->set('comment', nl2br($comment)); $rowc->set('created', Date::toSql()); $rowc->set('created_by', User::get('id')); $rowc->set('access', $access); // Compare fields to find out what has changed for this ticket and build a changelog $rowc->changelog()->diff($old, $row); $rowc->changelog()->cced(Request::getVar('cc', '')); // Save the data if (!$rowc->store()) { throw new Exception($rowc->getError(), 500); } Event::trigger('support.onTicketUpdate', array($row, $rowc)); if ($tmp = Request::getInt('tmp_dir')) { $attach = new Tables\Attachment($this->database); $attach->updateCommentId($tmp, $rowc->get('id')); } if (!$isNew) { $attachment = $this->uploadTask($row->get('id'), $rowc->get('id')); } // Only do the following if a comment was posted or ticket was reassigned // otherwise, we're only recording a changelog if ($rowc->get('comment') || $row->get('owner') != $old->get('owner') || $row->get('group') != $old->get('group') || $rowc->attachments()->total() > 0) { // Send e-mail to ticket submitter? if (Request::getInt('email_submitter', 0) == 1) { // Is the comment private? If so, we do NOT send e-mail to the // submitter regardless of the above setting if (!$rowc->isPrivate()) { $rowc->addTo(array('role' => Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_SUBMITTER'), 'name' => $row->submitter('name'), 'email' => $row->submitter('email'), 'id' => $row->submitter('id'))); } } // Send e-mail to ticket owner? if (Request::getInt('email_owner', 0) == 1) { if ($old->get('owner') && $row->get('owner') != $old->get('owner')) { $rowc->addTo(array('role' => Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_PRIOR_OWNER'), 'name' => $old->owner('name'), 'email' => $old->owner('email'), 'id' => $old->owner('id'))); } if ($row->get('owner')) { $rowc->addTo(array('role' => Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_OWNER'), 'name' => $row->owner('name'), 'email' => $row->owner('email'), 'id' => $row->owner('id'))); } elseif ($row->get('group')) { $group = \Hubzero\User\Group::getInstance($row->get('group')); if ($group) { foreach ($group->get('managers') as $manager) { $manager = User::getInstance($manager); if (!$manager || !$manager->get('id')) { continue; } $rowc->addTo(array('role' => Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_GROUPMANAGER'), 'name' => $manager->get('name'), 'email' => $manager->get('email'), 'id' => $manager->get('id'))); } } } } // Add any CCs to the e-mail list foreach ($rowc->changelog()->get('cc') as $cc) { $rowc->addTo($cc, Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_CC')); } // Message people watching this ticket, // but ONLY if the comment was NOT marked private $this->acl = ACL::getACL(); foreach ($row->watchers() as $watcher) { $this->acl->setUser($watcher->user_id); if (!$rowc->isPrivate() || $rowc->isPrivate() && $this->acl->check('read', 'private_comments')) { $rowc->addTo($watcher->user_id, 'watcher'); } } $this->acl->setUser(User::get('id')); if (count($rowc->to())) { // Build e-mail components $subject = Lang::txt('COM_SUPPORT_EMAIL_SUBJECT_TICKET_COMMENT', $row->get('id')); $from = array('name' => Lang::txt('COM_SUPPORT_EMAIL_FROM', Config::get('sitename')), 'email' => Config::get('mailfrom'), 'multipart' => md5(date('U'))); // Plain text email $eview = new \Hubzero\Mail\View(array('base_path' => PATH_CORE . DS . 'components' . DS . $this->_option . DS . 'site', 'name' => 'emails', 'layout' => 'comment_plain')); $eview->option = $this->_option; $eview->controller = $this->_controller; $eview->comment = $rowc; $eview->ticket = $row; $eview->config = $this->config; $eview->delimiter = $allowEmailResponses ? '~!~!~!~!~!~!~!~!~!~!' : ''; $message['plaintext'] = $eview->loadTemplate(false); $message['plaintext'] = str_replace("\n", "\r\n", $message['plaintext']); // HTML email $eview->setLayout('comment_html'); $message['multipart'] = $eview->loadTemplate(); $message['multipart'] = str_replace("\n", "\r\n", $message['multipart']); $message['attachments'] = array(); if (!$this->config->get('email_terse')) { foreach ($rowc->attachments() as $attachment) { if ($attachment->size() < 2097152) { $message['attachments'][] = $attachment->link('filepath'); } } } // Send e-mail to admin? foreach ($rowc->to('ids') as $to) { if ($allowEmailResponses) { // The reply-to address contains the token $token = $encryptor->buildEmailToken(1, 1, $to['id'], $id); $from['replytoemail'] = 'htc-' . $token . strstr(Config::get('mailfrom'), '@'); } // Get the user's email address if (!Event::trigger('xmessage.onSendMessage', array('support_reply_submitted', $subject, $message, $from, array($to['id']), $this->_option))) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_FAILED_TO_MESSAGE', $to['name'] . '(' . $to['role'] . ')')); } // Watching should be anonymous if ($to['role'] == 'watcher') { continue; } $rowc->changelog()->notified($to['role'], $to['name'], $to['email']); } foreach ($rowc->to('emails') as $to) { if ($allowEmailResponses) { $token = $encryptor->buildEmailToken(1, 1, -9999, $id); $email = array($to['email'], 'htc-' . $token . strstr(Config::get('mailfrom'), '@')); // In this case each item in email in an array, 1- To, 2:reply to address Utilities::sendEmail($email[0], $subject, $message, $from, $email[1]); } else { // Email is just a plain 'ol string Utilities::sendEmail($to['email'], $subject, $message, $from); } // Watching should be anonymous if ($to['role'] == 'watcher') { continue; } $rowc->changelog()->notified($to['role'], $to['name'], $to['email']); } } else { // Force entry to private if no comment or attachment was made if (!$rowc->get('comment') && $rowc->attachments()->total() <= 0) { $rowc->set('access', 1); } } // Were there any changes? if (count($rowc->changelog()->get('notifications')) > 0 || $access != $rowc->get('access')) { // Save the data if (!$rowc->store()) { throw new Exception($rowc->getError(), 500); } } } // output messsage and redirect if ($redirect) { $filters = Request::getVar('filters', ''); $filters = str_replace('&', '&', $filters); // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . ($filters ? '&' . $filters : ''), false), Lang::txt('COM_SUPPORT_TICKET_SUCCESSFULLY_SAVED', $row->get('id'))); return; } $this->view->setLayout('edit'); $this->editTask(); }
/** * Saves a trouble report as a ticket * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); $live_site = rtrim(Request::base(), '/'); // Trigger any events that need to be called before session stop Event::trigger('support.onPreTicketSubmission', array()); // Incoming $no_html = Request::getInt('no_html', 0); $verified = Request::getInt('verified', 0); if (!isset($_POST['reporter']) || !isset($_POST['problem'])) { // This really, REALLY shouldn't happen. throw new Exception(Lang::txt('COM_SUPPORT_ERROR_MISSING_DATA'), 400); } $reporter = Request::getVar('reporter', array(), 'post', 'none', 2); $problem = Request::getVar('problem', array(), 'post', 'none', 2); //$reporter = array_map('trim', $_POST['reporter']); //$problem = array_map('trim', $_POST['problem']); // Normally calling Request::getVar calls _cleanVar, but b/c of the way this page processes the posts // (with array square brackets in the html names) against the $_POST collection, we explicitly // call the clean_var function on these arrays after fetching them //$reporter = array_map(array('Request', '_cleanVar'), $reporter); //$problem = array_map(array('Request', '_cleanVar'), $problem); // [!] zooley - Who added this? Why? // Reporter login can only be for authenticated users -- ignore any form submitted login names //$reporterLogin = $this->_getUser(); //$reporter['login'] = $reporterLogin['login']; // Probably redundant after the change to call Request::_cleanVar change above, It is a bit hard to // tell if the Joomla _cleanvar function does enough to allow us to remove the purifyText call $reporter = array_map(array('\\Hubzero\\Utility\\Sanitize', 'stripAll'), $reporter); //$problem = array_map(array('\\Hubzero\\Utility\\Sanitize', 'stripAll'), $problem); $reporter['name'] = trim($reporter['name']); $reporter['email'] = trim($reporter['email']); $problem['long'] = trim($problem['long']); // Make sure email address is valid $validemail = Validate::email($reporter['email']); // Set page title $this->_buildTitle(); $this->view->title = $this->_title; // Set the pathway $this->_buildPathway(); // Trigger any events that need to be called $customValidation = true; $result = Event::trigger('support.onValidateTicketSubmission', array($reporter, $problem)); $customValidation = is_array($result) && !empty($result) ? $result[0] : $customValidation; // Check for some required fields if (!$reporter['name'] || !$reporter['email'] || !$validemail || !$problem['long'] || !$customValidation) { Request::setVar('task', 'new'); // Output form with error messages if (!$reporter['name'] || !$reporter['email'] || !$problem['long']) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_MISSING_DATA')); } if (!$validemail) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_INVALID_EMAIL')); } if (!$customValidation) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_INVALID_DATA')); } foreach ($this->getErrors() as $error) { $this->view->setError($error); } return $this->newTask(); } // Get the user's IP $ip = Request::ip(); $hostname = gethostbyaddr(Request::getVar('REMOTE_ADDR', '', 'server')); if (!$verified) { // Check CAPTCHA $validcaptchas = Event::trigger('support.onValidateCaptcha'); if (count($validcaptchas) > 0) { foreach ($validcaptchas as $validcaptcha) { if (!$validcaptcha) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_INVALID_CAPTCHA')); } } } } // Are they verified? if (!$verified) { // Quick spam filter $spam = $this->_detectSpam($problem['long'], $ip); if ($spam) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_FLAGGED_AS_SPAM')); return; } // Quick bot check $botcheck = Request::getVar('botcheck', ''); if ($botcheck) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_INVALID_BOTCHECK')); return; } } // Check for errors // If any found, push back into the submission form view if ($this->getError()) { if ($no_html) { // Output error messages (AJAX) $this->view->setLayout('error'); if ($this->getError()) { $this->view->setError($this->getError()); } $this->view->display(); return; } else { Request::setVar('task', 'new'); $this->view->setError($this->getError()); return $this->newTask(); } } // Cut suggestion at 70 characters if (!$problem['short'] && $problem['long']) { $problem['short'] = substr($problem['long'], 0, 70); if (strlen($problem['short']) >= 70) { $problem['short'] .= '...'; } } $group = isset($problem['group']) ? $problem['group'] : ''; // Initiate class and bind data to database fields $row = new Ticket(); $row->set('open', 1); $row->set('status', 0); $row->set('created', Date::toSql()); $row->set('login', $reporter['login']); $row->set('severity', isset($problem['severity']) ? $problem['severity'] : 'normal'); $row->set('owner', isset($problem['owner']) ? $problem['owner'] : null); $row->set('category', isset($problem['category']) ? $problem['category'] : ''); $row->set('summary', $problem['short']); $row->set('report', $problem['long']); $row->set('resolved', isset($problem['resolved']) ? $problem['resolved'] : null); $row->set('email', $reporter['email']); $row->set('name', $reporter['name']); $row->set('os', $problem['os'] . ' ' . $problem['osver']); $row->set('browser', $problem['browser'] . ' ' . $problem['browserver']); $row->set('ip', $ip); $row->set('hostname', $hostname); $row->set('uas', Request::getVar('HTTP_USER_AGENT', '', 'server')); $row->set('referrer', base64_decode($problem['referer'])); $row->set('cookies', Request::getVar('sessioncookie', '', 'cookie') ? 1 : 0); $row->set('instances', 1); $row->set('section', 1); $row->set('group', $group); if (isset($incoming['target_date'])) { if (!$incoming['target_date']) { $row->set('target_date', '0000-00-00 00:00:00'); } else { $row->set('target_date', Date::of($incoming['target_date'], Config::get('offset'))->toSql()); } } // check if previous ticket submitted is the same as this one. $ticket = new Tables\Ticket($this->database); $filters = array('status' => 'new', 'sort' => 'id', 'sortdir' => 'DESC', 'limit' => '1', 'start' => 0); $prevSubmission = $ticket->getTickets($filters, false); // for the first ticket ever if (isset($prevSubmission[0]) && $prevSubmission[0]->report == $row->get('report') && time() - strtotime($prevSubmission[0]->created) <= 15) { $this->setError(Lang::txt('COM_SUPPORT_TICKET_DUPLICATE_DETECTION')); return $this->newTask($row); } // Save the data if (!$row->store()) { $this->setError($row->getError()); } $attachment = $this->uploadTask($row->get('id')); // Save tags $row->set('tags', Request::getVar('tags', '', 'post')); $row->tag($row->get('tags'), User::get('id'), 1); // Get any set emails that should be notified of ticket submission $defs = explode(',', $this->config->get('emails', '{config.mailfrom}')); if ($defs) { $message = new \Hubzero\Mail\Message(); $message->setSubject(Config::get('sitename') . ' ' . Lang::txt('COM_SUPPORT_EMAIL_SUBJECT_NEW_TICKET', $row->get('id'))); $message->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_option))); // Plain text email $eview = new \Hubzero\Mail\View(array('name' => 'emails', 'layout' => 'ticket_plain')); $eview->option = $this->_option; $eview->controller = $this->_controller; $eview->ticket = $row; $eview->config = $this->config; $eview->delimiter = ''; $plain = $eview->loadTemplate(false); $plain = str_replace("\n", "\r\n", $plain); $message->addPart($plain, 'text/plain'); // HTML email $eview->setLayout('ticket_html'); $html = $eview->loadTemplate(); $html = str_replace("\n", "\r\n", $html); if (!$this->config->get('email_terse')) { foreach ($row->attachments() as $attachment) { if ($attachment->size() < 2097152) { if ($attachment->isImage()) { $file = basename($attachment->link('filepath')); $html = preg_replace('/<a class="img" data\\-filename="' . str_replace('.', '\\.', $file) . '" href="(.*?)"\\>(.*?)<\\/a>/i', '<img src="' . $message->getEmbed($attachment->link('filepath')) . '" alt="" />', $html); } else { $message->addAttachment($attachment->link('filepath')); } } } } $message->addPart($html, 'text/html'); // Loop through the addresses foreach ($defs as $def) { $def = trim($def); // Check if the address should come from Joomla config if ($def == '{config.mailfrom}') { $def = Config::get('mailfrom'); } // Check for a valid address if (Validate::email($def)) { // Send e-mail $message->setTo(array($def)); $message->send(); } } } // Log activity $creator = User::getInstance($row->get('login')); if ($creator && $creator->get('id')) { Event::trigger('system.logActivity', ['activity' => ['action' => 'created', 'scope' => 'support.ticket', 'scope_id' => $row->get('id'), 'description' => Lang::txt('COM_SUPPORT_ACTIVITY_TICKET_CREATED', '<a href="' . Route::url($row->link()) . '">#' . $row->get('id') . ' - ' . $row->get('summary') . '</a>'), 'details' => array('id' => $row->get('id'), 'summary' => $row->get('summary'), 'url' => Route::url($row->link()))], 'recipients' => [['support.tickets', 1], ['user', $creator->get('id')]]]); } if (!User::isGuest() && $this->acl->check('update', 'tickets') > 0) { // Only do the following if a comment was posted // otherwise, we're only recording a changelog $old = new Ticket(); $old->set('open', 1); $old->set('owner', 0); $old->set('status', 0); $old->set('tags', ''); $old->set('severity', 'normal'); $rowc = new Comment(); $rowc->set('ticket', $row->get('id')); $rowc->set('created', Date::toSql()); $rowc->set('created_by', User::get('id')); $rowc->set('access', 1); $rowc->set('comment', Lang::txt('COM_SUPPORT_TICKET_SUBMITTED')); // Compare fields to find out what has changed for this ticket and build a changelog $rowc->changelog()->diff($old, $row); $rowc->changelog()->cced(Request::getVar('cc', '')); // Were there any changes, CCs, or comments to record? if (count($rowc->changelog()->get('changes')) > 0 || count($rowc->changelog()->get('cc')) > 0) { // Save the data if (!$rowc->store()) { throw new Exception($rowc->getError(), 500); } if ($row->get('owner')) { $rowc->addTo(array('role' => Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_OWNER'), 'name' => $row->owner('name'), 'email' => $row->owner('email'), 'id' => $row->owner('id'))); } elseif ($row->get('group')) { $group = \Hubzero\User\Group::getInstance($row->get('group')); if ($group) { foreach ($group->get('managers') as $manager) { $manager = User::getInstance($manager); if (!$manager || !$manager->get('id')) { continue; } $rowc->addTo(array('role' => Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_GROUPMANAGER'), 'name' => $manager->get('name'), 'email' => $manager->get('email'), 'id' => $manager->get('id'))); } } } // Add any CCs to the e-mail list foreach ($rowc->changelog()->get('cc') as $cc) { $rowc->addTo($cc, Lang::txt('COM_SUPPORT_COMMENT_SEND_EMAIL_CC')); } $recipients = array(['support.tickets', 1]); // Check if the notify list has eny entries if (count($rowc->to())) { $allowEmailResponses = $this->config->get('email_processing'); if ($this->config->get('email_terse')) { $allowEmailResponses = false; } if ($allowEmailResponses) { try { $encryptor = new \Hubzero\Mail\Token(); } catch (Exception $e) { $allowEmailResponses = false; } } $subject = Lang::txt('COM_SUPPORT_EMAIL_SUBJECT_TICKET_COMMENT', $row->get('id')); $from = array('name' => Lang::txt('COM_SUPPORT_EMAIL_FROM', Config::get('sitename')), 'email' => Config::get('mailfrom'), 'multipart' => md5(date('U'))); $message = array(); // Plain text email $eview = new \Hubzero\Mail\View(array('name' => 'emails', 'layout' => 'comment_plain')); $eview->option = $this->_option; $eview->controller = $this->_controller; $eview->comment = $rowc; $eview->ticket = $row; $eview->config = $this->config; $eview->delimiter = $allowEmailResponses ? '~!~!~!~!~!~!~!~!~!~!' : ''; $message['plaintext'] = $eview->loadTemplate(false); $message['plaintext'] = str_replace("\n", "\r\n", $message['plaintext']); // HTML email $eview->setLayout('comment_html'); $message['multipart'] = $eview->loadTemplate(); $message['multipart'] = str_replace("\n", "\r\n", $message['multipart']); // Send e-mail to admin? foreach ($rowc->to('ids') as $to) { $recipients[] = ['user', $to['id']]; if ($allowEmailResponses) { // The reply-to address contains the token $token = $encryptor->buildEmailToken(1, 1, $to['id'], $row->get('id')); $from['replytoemail'] = 'htc-' . $token . strstr(Config::get('mailfrom'), '@'); } // Get the user's email address if (!Event::trigger('xmessage.onSendMessage', array('support_reply_submitted', $subject, $message, $from, array($to['id']), $this->_option))) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_FAILED_TO_MESSAGE', $to['name'] . '(' . $to['role'] . ')')); } $rowc->changelog()->notified($to['role'], $to['name'], $to['email']); } foreach ($rowc->to('emails') as $to) { if ($allowEmailResponses) { $token = $encryptor->buildEmailToken(1, 1, -9999, $row->get('id')); $email = array($to['email'], 'htc-' . $token . strstr(Config::get('mailfrom'), '@')); // In this case each item in email in an array, 1- To, 2:reply to address Utilities::sendEmail($email[0], $subject, $message, $from, $email[1]); } else { // email is just a plain 'ol string Utilities::sendEmail($to['email'], $subject, $message, $from); } $rowc->changelog()->notified($to['role'], $to['name'], $to['email']); } } // Were there any changes? if (count($rowc->changelog()->get('notifications')) > 0 || count($rowc->changelog()->get('cc')) > 0 || count($rowc->changelog()->get('changes')) > 0) { // Save the data if (!$rowc->store()) { $this->setError($rowc->getError()); } } // Record the activity if (!$rowc->isPrivate() && $creator->get('id')) { $recipients[] = ['user', $creator->get('id')]; } $desc = Lang::txt('COM_SUPPORT_ACTIVITY_TICKET_UPDATED', '<a href="' . Route::url($row->link()) . '">#' . $row->get('id') . ' - ' . $row->get('summary') . '</a>'); if ($rowc->get('comment')) { $desc = Lang::txt('COM_SUPPORT_ACTIVITY_COMMENT_CREATED', $rowc->get('id'), '<a href="' . Route::url($row->link()) . '">#' . $row->get('id') . ' - ' . $row->get('summary') . '</a>'); } Event::trigger('system.logActivity', ['activity' => ['action' => 'created', 'scope' => 'support.ticket.comment', 'scope_id' => $rowc->get('id'), 'description' => $desc, 'details' => array('id' => $row->get('id'), 'summary' => $row->get('summary'), 'url' => Route::url($row->link()), 'comment' => $rowc->get('id'))], 'recipients' => $recipients]); } } // Trigger any events that need to be called Event::trigger('support.onTicketSubmission', array($row)); // Output Thank You message $this->view->ticket = $row->get('id'); $this->view->no_html = $no_html; foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }
/** * Final submission * * @return void */ public function submitTask() { // Incoming $id = Request::getInt('id', 0); // Ensure we have an ID to work with if (!$id) { App::abort(404, Lang::txt('COM_CONTRIBUTE_NO_ID')); } // Load resource info $resource = Resource::oneOrFail($id); // Set a flag for if the resource was already published or not $published = 0; if ($resource->get('published') != 2) { $published = 1; } // Check if a newly submitted resource was authorized to be published $authorized = Request::getInt('authorization', 0); if (!$authorized && !$published) { $this->setError(Lang::txt('COM_CONTRIBUTE_CONTRIBUTION_NOT_AUTHORIZED')); $this->_checkProgress($id); return $this->step_review(); } // Allow for any other validation $results = Event::trigger('resources.onResourceBeforeSubmit', array($resource)); foreach ($results as $result) { if ($result) { $this->setError($result); $this->_checkProgress($id); return $this->step_review(); } } // Is this a newly submitted resource? if (!$published) { $activity = 'submitted'; // 0 = unpublished, 1 = published, 2 = composing, 3 = pending (submitted), 4 = deleted // Are submissions auto-approved? if ($this->config->get('autoapprove') == 1) { //checks if autoapproved content has children (configurable in options on backend) if ($this->config->get('autoapprove_content_check') == 1) { if ($resource->children()->total() < 1) { $this->setError(Lang::txt('COM_CONTRIBUTE_NO_CONTENT')); return $this->step_review(); } } // Set status to published $resource->set('published', 1); $resource->set('publish_up', Date::toSql()); $activity = 'published'; } else { $apu = $this->config->get('autoapproved_users'); $apu = explode(',', $apu); $apu = array_map('trim', $apu); if (in_array(User::get('username'), $apu)) { // Set status to published $resource->set('published', 1); $resource->set('publish_up', Date::toSql()); } else { // Set status to pending review (submitted) $resource->set('published', 3); } } // Get the resource's contributors $authors = $resource->authors()->rows(); if ($authors->count() <= 0) { $this->setError(Lang::txt('COM_CONTRIBUTE_CONTRIBUTION_HAS_NO_AUTHORS')); $this->_checkProgress($id); return $this->step_review(); } // Get any set emails that should be notified of ticket submission $defs = explode(',', $this->config->get('email_when_submitted', '{config.mailfrom}')); if (!empty($defs)) { $message = new \Hubzero\Mail\Message(); $message->setSubject(Config::get('sitename') . ' ' . Lang::txt('COM_RESOURCES_EMAIL_SUBJECT_NEW_SUBMISSION', $resource->id)); $message->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_option))); // Plain text email $eview = new \Hubzero\Mail\View(array('name' => 'emails', 'layout' => 'submitted_plain')); $eview->option = $this->_option; $eview->controller = $this->_controller; $eview->resource = $resource; $eview->delimiter = ''; $plain = $eview->loadTemplate(false); $plain = str_replace("\n", "\r\n", $plain); $message->addPart($plain, 'text/plain'); // HTML email $eview->setLayout('submitted_html'); $html = $eview->loadTemplate(); $html = str_replace("\n", "\r\n", $html); $message->addPart($html, 'text/html'); // Loop through the addresses foreach ($defs as $def) { $def = trim($def); // Check if the address should come from config if ($def == '{config.mailfrom}') { $def = Config::get('mailfrom'); } // Check for a valid address if (\Hubzero\Utility\Validate::email($def)) { // Send e-mail $message->setTo(array($def)); $message->send(); } } } // Log activity $recipients = array(['resource', $resource->get('id')], ['user', $resource->get('created_by')]); foreach ($authors as $author) { if ($author->get('authorid') > 0) { $recipients[] = ['user', $author->get('authorid')]; } } Event::trigger('system.logActivity', ['activity' => ['action' => $activity, 'scope' => 'resource', 'scope_id' => $resource->get('title'), 'description' => Lang::txt('COM_RESOURCES_ACTIVITY_ENTRY_' . strtoupper($activity), '<a href="' . Route::url($resource->link()) . '">' . $resource->get('title') . '</a>'), 'details' => array('title' => $resource->get('title'), 'url' => Route::url($resource->link()))], 'recipients' => $recipients]); } // Is this resource licensed under Creative Commons? if ($this->config->get('cc_license')) { $license = Request::getVar('license', ''); if ($license == 'custom') { $license .= $resource->get('id'); $licenseText = Request::getVar('license-text', ''); if ($licenseText == '[ENTER LICENSE HERE]') { $this->setError(Lang::txt('Please enter a license.')); $this->_checkProgress($id); return $this->step_review(); } $rl = License::oneOrNew($license); $rl->set('name', $license); $rl->set('text', $licenseText); $rl->set('info', $resource->get('id')); $rl->save(); } // set license $params = new \Hubzero\Config\Registry($resource->get('params')); $params->set('license', $license); $resource->set('params', $params->toString()); } // Save the resource $resource->save(); Event::trigger('resources.onResourceAfterSubmit', array($resource)); // If a previously published resource, redirect to the resource page if ($published == 1) { App::redirect(Route::url($resource->link())); return; } // Output HTML $this->setView($this->_controller, 'thanks'); $this->view->set('title', $this->_title)->set('config', $this->config)->set('resource', $resource)->setErrors($this->getErrors())->display(); }
/** * Finalize the purchase process * * @return void */ public function finalizeTask() { // Check for request forgeries Request::checkToken(); // Set page title $this->_buildTitle(); // Set the pathway $this->_buildPathway(); // Check authorization if (User::isGuest()) { $this->loginTask(); return; } $now = \Date::toSql(); // Get cart object $item = new Cart($this->database); // Calculate total $cost = $item->getCartItems(User::get('id'), 'cost'); // Check available user funds $BTL = new Teller(User::get('id')); $balance = $BTL->summary(); $credit = $BTL->credit_summary(); $funds = $balance - $credit; $funds = $funds > 0 ? $funds : '0'; // Get cart items $items = $item->getCartItems(User::get('id')); if (!$items or $cost > $funds) { $this->cartTask(); return; } // Get shipping info $shipping = array_map('trim', $_POST); // make sure email address is valid $email = \Hubzero\Utility\Validate::email($shipping['email']) ? $shipping['email'] : User::get('email'); // Format posted info $details = Lang::txt('COM_STORE_SHIP_TO') . ':' . "\r\n"; $details .= $shipping['name'] . "\r\n"; $details .= Sanitize::stripAll($shipping['address']) . "\r\n"; $details .= Lang::txt('COM_STORE_COUNTRY') . ': ' . $shipping['country'] . "\r\n"; $details .= '----------------------------------------------------------' . "\r\n"; $details .= Lang::txt('COM_STORE_CONTACT') . ': ' . "\r\n"; if ($shipping['phone']) { $details .= $shipping['phone'] . "\r\n"; } $details .= $email . "\r\n"; $details .= '----------------------------------------------------------' . "\r\n"; $details .= Lang::txt('COM_STORE_DETAILS') . ': '; $details .= $shipping['comments'] ? "\r\n" . Sanitize::stripAll($shipping['comments']) : 'N/A'; // Register a new order $order = new Order($this->database); $order->uid = User::get('id'); $order->total = $cost; $order->status = '0'; // order placed $order->ordered = $now; $order->email = $email; $order->details = $details; // Store new content if (!$order->store()) { throw new Exception($order->getError(), 500); } // Get order ID $objO = new Order($this->database); $orderid = $objO->getOrderID(User::get('id'), $now); if ($orderid) { // Transfer cart items to order foreach ($items as $itm) { $orderitem = new OrderItem($this->database); $orderitem->uid = User::get('id'); $orderitem->oid = $orderid; $orderitem->itemid = $itm->itemid; $orderitem->price = $itm->price; $orderitem->quantity = $itm->quantity; $orderitem->selections = $itm->selections; // Save order item if (!$orderitem->store()) { throw new Exception($orderitem->getError(), 500); } } // Put the purchase amount on hold $BTL = new Teller(User::get('id')); $BTL->hold($order->total, Lang::txt('COM_STORE_BANKING_HOLD'), 'store', $orderid); $message = new \Hubzero\Mail\Message(); $message->setSubject(Config::get('sitename') . ' ' . Lang::txt('COM_STORE_EMAIL_SUBJECT_NEW_ORDER', $orderid)); $message->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_option))); // Plain text email $eview = new \Hubzero\Mail\View(array('name' => 'emails', 'layout' => 'confirmation_plain')); $eview->option = $this->_option; $eview->controller = $this->_controller; $eview->orderid = $orderid; $eview->cost = $cost; $eview->shipping = $shipping; $eview->details = $details; $eview->items = $items; $plain = $eview->loadTemplate(false); $plain = str_replace("\n", "\r\n", $plain); $message->addPart($plain, 'text/plain'); // HTML email $eview->setLayout('confirmation_html'); $html = $eview->loadTemplate(); $html = str_replace("\n", "\r\n", $html); $message->addPart($html, 'text/html'); // Send e-mail $message->setTo(array(User::get('email'))); $message->send(); } // Empty cart $item->deleteCartItem('', User::get('id'), 'all'); if ($this->getError()) { \Notify::message($this->getError(), 'error'); } else { \Notify::message(Lang::txt('COM_STORE_SUCCESS_MESSAGE', $orderid), 'success'); } App::redirect(Route::url('index.php?option=' . $this->_option)); return; }
/** * Final submission * * @return void */ public function submitTask() { // Incoming $id = Request::getInt('id', 0); // Ensure we have an ID to work with if (!$id) { throw new Exception(Lang::txt('COM_CONTRIBUTE_NO_ID'), 500); } // Load resource info $resource = new Resource($this->database); $resource->load($id); // Set a flag for if the resource was already published or not $published = 0; if ($resource->published != 2) { $published = 1; } // Check if a newly submitted resource was authorized to be published $authorized = Request::getInt('authorization', 0); if (!$authorized && !$published) { $this->setError(Lang::txt('COM_CONTRIBUTE_CONTRIBUTION_NOT_AUTHORIZED')); $this->_checkProgress($id); $this->step_review(); return; } // Is this a newly submitted resource? if (!$published) { // 0 = unpublished, 1 = published, 2 = composing, 3 = pending (submitted), 4 = deleted // Are submissions auto-approved? if ($this->config->get('autoapprove') == 1) { //checks if autoapproved content has children (configurable in options on backend) if ($this->config->get('autoapprove_content_check') == 1) { require_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'resource.php'; $item = new \Components\Resources\Models\Resource($id); if (count($item->children()) < 1) { $this->setError(Lang::txt('COM_CONTRIBUTE_NO_CONTENT')); $this->step_review(); return; } } // Set status to published $resource->published = 1; $resource->publish_up = Date::toSql(); } else { $apu = $this->config->get('autoapproved_users'); $apu = explode(',', $apu); $apu = array_map('trim', $apu); if (in_array(User::get('username'), $apu)) { // Set status to published $resource->published = 1; $resource->publish_up = Date::toSql(); } else { // Set status to pending review (submitted) $resource->published = 3; } } // Get the resource's contributors $helper = new Helper($id, $this->database); $helper->getCons(); $contributors = $helper->_contributors; if (!$contributors || count($contributors) <= 0) { $this->setError(Lang::txt('COM_CONTRIBUTE_CONTRIBUTION_HAS_NO_AUTHORS')); $this->_checkProgress($id); $this->step_review(); return; } // Get any set emails that should be notified of ticket submission $defs = explode(',', $this->config->get('email_when_submitted', '{config.mailfrom}')); if (!empty($defs)) { $message = new \Hubzero\Mail\Message(); $message->setSubject(Config::get('sitename') . ' ' . Lang::txt('COM_RESOURCES_EMAIL_SUBJECT_NEW_SUBMISSION', $resource->id)); $message->addFrom(Config::get('mailfrom'), Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_option))); // Plain text email $eview = new \Hubzero\Mail\View(array('name' => 'emails', 'layout' => 'submitted_plain')); $eview->option = $this->_option; $eview->controller = $this->_controller; $eview->resource = $resource; $eview->delimiter = ''; $plain = $eview->loadTemplate(); $plain = str_replace("\n", "\r\n", $plain); $message->addPart($plain, 'text/plain'); // HTML email $eview->setLayout('submitted_html'); $html = $eview->loadTemplate(); $html = str_replace("\n", "\r\n", $html); $message->addPart($html, 'text/html'); // Loop through the addresses foreach ($defs as $def) { $def = trim($def); // Check if the address should come from config if ($def == '{config.mailfrom}') { $def = Config::get('mailfrom'); } // Check for a valid address if (\Hubzero\Utility\Validate::email($def)) { // Send e-mail $message->setTo(array($def)); $message->send(); } } } } // Is this resource licensed under Creative Commons? if ($this->config->get('cc_license')) { $license = Request::getVar('license', ''); if ($license == 'custom') { $license .= $resource->id; $licenseText = Request::getVar('license-text', ''); if ($licenseText == '[ENTER LICENSE HERE]') { $this->setError(Lang::txt('Please enter a license.')); $this->_checkProgress($id); $this->step_review(); return; } include_once dirname(dirname(__DIR__)) . DS . 'tables' . DS . 'license.php'; $rl = new License($this->database); $rl->load($license); $rl->name = $license; $rl->text = $licenseText; $rl->info = $resource->id; $rl->check(); $rl->store(); } // set license $params = new \Hubzero\Config\Registry($resource->params); $params->set('license', $license); $resource->params = $params->toString(); } // Save and checkin the resource $resource->store(); $resource->checkin(); // If a previously published resource, redirect to the resource page if ($published == 1) { if ($resource->alias) { $url = Route::url('index.php?option=com_resources&alias=' . $resource->alias); } else { $url = Route::url('index.php?option=com_resources&id=' . $resource->id); } App::redirect($url); return; } // Output HTML $this->setView($this->_controller, 'thanks'); $this->view->title = $this->_title; $this->view->config = $this->config; $this->view->resource = $resource; foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }
/** * Send a message * * @return mixed */ protected function _send() { // Ensure the user is logged in if (User::isGuest()) { return false; } //message $message = Lang::txt('PLG_GROUPS_MESSAGES_FROM_GROUP', $this->group->get('cn')); // Incoming array of users to message $mbrs = Request::getVar('users', array(0), 'post'); switch ($mbrs[0]) { case 'invitees': $mbrs = $this->group->get('invitees'); $action = 'group_invitees_message'; $group_id = $this->group->get('gidNumber'); break; case 'applicants': $mbrs = $this->group->get('applicants'); $action = 'group_pending_message'; $group_id = $this->group->get('gidNumber'); break; case 'managers': $mbrs = $this->group->get('managers'); $action = 'group_managers_message'; $group_id = $this->group->get('gidNumber'); break; case 'all': $mbrs = $this->group->get('members'); $action = 'group_members_message'; $group_id = $this->group->get('gidNumber'); break; default: $message = Lang::txt('PLG_GROUPS_MESSAGES_FOR_GROUP_MEMBER', $this->group->get('cn')); foreach ($mbrs as $mbr) { if (strstr($mbr, '_')) { $role = explode('_', $mbr); $db = App::get('db'); $sql = "SELECT uidNumber FROM `#__xgroups_member_roles` WHERE roleid=" . $db->Quote($role[1]); $db->setQuery($sql); $member_roles = $db->loadAssocList(); foreach ($member_roles as $member) { $members[] = $member['uidNumber']; } $mbrs = $members; $action = 'group_role_message'; $group_id = $this->group->get('gidNumber'); } else { $action = ''; $group_id = 0; break; } } break; } // Incoming message and subject $s = Request::getVar('subject', Lang::txt('PLG_GROUPS_MESSAGES_SUBJECT')); $m = Request::getVar('message', ''); // Ensure we have a message if (!$s || !$m) { $html = '<p class="error">You must enter all required fields</p>'; $html .= $this->_create(); return $html; } // get all group members $recipients = array(); foreach ($mbrs as $mbr) { if ($profile = User::getInstance($mbr)) { $recipients[$profile->get('email')] = $profile->get('name'); } } // add invite emails if sending to invitees if ($action == 'group_invitees_message') { // Get invite emails $db = App::get('db'); $group_inviteemails = new \Hubzero\User\Group\InviteEmail(); $current_inviteemails = $group_inviteemails->getInviteEmails($this->group->get('gidNumber'), true); foreach ($current_inviteemails as $current_inviteemail) { $recipients[$current_inviteemail] = $current_inviteemail; } } // define from details $from = array('name' => $this->group->get('description') . " Group on " . Config::get("fromname"), 'email' => Config::get("mailfrom")); // create url $sef = Route::url('index.php?option=' . $this->_option . '&cn=' . $this->group->get('cn')); $sef = ltrim($sef, '/'); // create subject $subject = $s . " [Email sent on Behalf of " . User::get('name') . "]"; //message $plain = Lang::txt('PLG_GROUPS_MESSAGES_FROM_GROUP', $this->group->get('cn')); $plain .= "\r\n------------------------------------------------\r\n\r\n"; $plain .= $m; // create message $plain .= "\r\n\r\n------------------------------------------------\r\n" . Request::base() . $sef . "\r\n"; // create message object $message = new \Hubzero\Mail\Message(); // set message details and send $message->setSubject($subject)->setFrom(array($from['email'] => $from['name']))->addPart($plain, 'text/plain'); foreach ($recipients as $email => $name) { $message->setTo(array($email => $name))->send(); } // add invite emails if sending to invitees /*if ($action == 'group_invitees_message') { // Get invite emails $db = App::get('db'); $group_inviteemails = new \Hubzero\User\Group\InviteEmail(); $current_inviteemails = $group_inviteemails->getInviteEmails($this->group->get('gidNumber'), true); $headers = 'From: ' . $from['name'] . ' <' . $from['email'] . '>' . "\r\n"; $headers .= 'Reply-To: ' . $from['replytoname'] . ' <' . $from['replytoemail'] . '>' . "\r\n"; foreach ($current_inviteemails as $current_inviteemail) { mail($current_inviteemail, $subject, $message, $headers); } }*/ // Log the action if ($action) { // log invites \Components\Groups\Models\Log::log(array('gidNumber' => $this->group->get('gidNumber'), 'action' => $action, 'comments' => array(User::get('id')))); } // Determine if we're returning HTML or not // (if no - this is an AJAX call) $no_html = Request::getInt('no_html', 0); if (!$no_html) { $html = ''; if ($this->getError()) { $html .= '<p class="error">' . $this->getError() . '</p>'; } $html .= $this->_sent(); return $html; } }