private function _getPointsOnThankyou($ruleName) { $ruleEnabled = AlphaUserPointsHelper::checkRuleEnabled($ruleName); if ($ruleEnabled[0]->published) { if ($this->_getAUPversion() < '1.6.0') { return $ruleEnabled[0]->content_items; } elseif ($this->_getAUPversion() >= '1.6.0') { return $ruleEnabled[0]->points2; } } return; }
function _display($tpl = null) { $document = JFactory::getDocument(); $lang = $document->getLanguage(); $displ = "view"; $points = 0; JHtml::_('behavior.framework', true); $document->addStyleSheet(JURI::base(true) . '/components/com_alphauserpoints/assets/css/alphauserpoints.css'); require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; $result = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_invite'); if ($result) { $points = $result[0]->points; } JHTML::_('behavior.formvalidation'); // reCaptcha script if ($this->params->get('userecaptcha', 1)) { if ($this->params->get('recaptchaajax ', 0)) { $document->addScript("http://api.recaptcha.net/js/recaptcha_ajax.js"); $paramsReCaptcha = "\r\n\t\t\t\t\twindow.onload = function () {\r\n\t\t\t\t\tRecaptcha.create('" . $this->params->get('pubkey') . "',\r\n\t\t\t\t\t'recaptcha_div', {\r\n\t\t\t\t\t theme: '" . $this->params->get('themerecaptcha', 'red') . "',\r\n\t\t\t\t\t callback: Recaptcha.focus_response_field\r\n\t\t\t\t\t});\r\n\t\t\t\t\t}"; } else { $paramsReCaptcha = "\r\n\t\t\t\tvar RecaptchaOptions = {\r\n\t\t\t\t theme : '" . $this->params->get('themerecaptcha', 'red') . "',\r\n\t\t\t\t lang : '" . substr($lang, 0, 2) . "'\r\n\t\t\t\t};\r\n\t\t\t\t"; } $document->addScriptDeclaration($paramsReCaptcha, ''); } /* $document->addScript(JURI::base(true).'/media/system/js/mootools-core.js'); $document->addStyleSheet(JURI::base(true).'/media/system/css/modal.css'); $document->addScript(JURI::base(true).'/media/system/js/modal.js'); */ JHTML::_('behavior.modal'); $setModal = "window.addEvent('domready', function() {\r\n\t\t\tSqueezeBox.initialize({});\r\n\r\n\t\t\t\$\$('a.modal').each(function(el) {\r\n\t\t\t\tel.addEvent('click', function(e) {\r\n\t\t\t\t\tnew Event(e).stop();\r\n\t\t\t\t\tSqueezeBox.fromElement(el);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t});\r\n\t\t"; $document->addScriptDeclaration($setModal); $this->assignRef('params', $this->params); $this->assignRef('referreid', $this->referreid); $this->assignRef('user_name', $this->user_name); $this->assignRef('points', $points); $this->assignRef('displ', $displ); $this->assignRef('referrer_link', $this->referrer_link); parent::display($tpl); }
/** * Run right at the end of the form processing * form needs to be set to record in database for this to hook to be called * * @throws Exception * * @return bool */ public function onAfterProcess() { $params = $this->getParams(); $api_AUP = JPATH_SITE . '/components/com_alphauserpoints/helper.php'; if (JFile::exists($api_AUP)) { $w = new FabrikWorker(); $this->data = $this->getProcessData(); require_once $api_AUP; $aup = new AlphaUserPointsHelper(); // Define which user will receive the points. $userId = $params->get('user_id', ''); $userId = (int) $w->parseMessageForPlaceholder($userId, $this->data, false); $aupId = $aup->getAnyUserReferreID($userId); // Replace these if you want to show a specific reference for the attributed points - doesn't seem to effect anything $keyReference = ''; // Shown in the user details page - description of what the point is for $dataReference = $params->get('data_reference', ''); $dataReference = $w->parseMessageForPlaceholder($dataReference, $this->data, false); // Override the plugin default points $randomPoints = $params->get('random_points', 0); if ($params->get('random_points_eval', '0') == '1') { if (!empty($randomPoints)) { $randomPoints = $w->parseMessageForPlaceholder($randomPoints, $this->data, false); $randomPoints = @eval($randomPoints); FabrikWorker::logEval($randomPoints, 'Caught exception on eval in aup plugin : %s'); } $randomPoints = (double) $randomPoints; } else { $randomPoints = (double) $w->parseMessageForPlaceholder($randomPoints, $this->data, false); } // If set to be greater than $randompoints then this is the # of points assigned (not sure when this would be used - commenting out for now) $referralUserPoints = 0; $aupPlugin = $params->get('aup_plugin', 'plgaup_fabrik'); $aupPlugin = $w->parseMessageForPlaceholder($aupPlugin, $this->data, false); if (!$aup->checkRuleEnabled($aupPlugin, 0, $aupId)) { throw new Exception('Alpha User Points plugin not published'); } $aup->userpoints($aupPlugin, $aupId, $referralUserPoints, $keyReference, $dataReference, $randomPoints); } }
private function _getPointsOnThankyou($ruleName) { $ruleEnabled = AlphaUserPointsHelper::checkRuleEnabled($ruleName); if (!empty($ruleEnabled[0]->published)) { return $ruleEnabled[0]->points2; } return null; }
function _get_inactive_members() { $inactive_members = 0; $num_days = 0; require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; $inactive_user_rule = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_inactiveuser'); if ($inactive_user_rule && $inactive_user_rule[0]->published) { $num_days = intval($inactive_user_rule[0]->content_items); $db = JFactory::getDBO(); $query = "SELECT COUNT(id) FROM #__alpha_userpoints WHERE userid > 0 AND published='1' AND referreid!='GUEST' AND (TO_DAYS(NOW()) - TO_DAYS(last_update)) > " . intval($inactive_user_rule[0]->content_items); $db->setQuery($query); $inactive_members = $db->loadResult(); } return array($inactive_members, $num_days); }
public function onAfterThankyou($target, $actor, $message) { $infoTargetUser = (JText::_ ( 'COM_KUNENA_THANKYOU_GOT' ).': ' . KunenaFactory::getUser($target)->username ); $infoRootUser = ( JText::_ ( 'COM_KUNENA_THANKYOU_SAID' ).': ' . KunenaFactory::getUser($actor)->username ); $category = $message->getCategory(); if ($category->pub_access == 0 || $category->pub_access == - 1) { $auptarget = AlphaUserPointsHelper::getAnyUserReferreID( $target ); $aupactor = AlphaUserPointsHelper::getAnyUserReferreID( $actor ); if ( $this->_getAUPversion() < '1.5.12' ) { $ruleName = 'plgaup_thankyou_kunena'; $ruleEnabled = AlphaUserPointsHelper::checkRuleEnabled( $ruleName ); $usertargetpoints = intval($ruleEnabled[0]->content_items); } elseif ( $this->_getAUPversion() >= '1.5.12' ) { $ruleName = 'plgaup_kunena_message_thankyou'; $ruleEnabled = AlphaUserPointsHelper::checkRuleEnabled( $ruleName ); $usertargetpoints = intval($ruleEnabled[0]->content_items); } else { return; } if ( $usertargetpoints && $ruleEnabled ) { // for target user if ($auptarget) AlphaUserPointsHelper::newpoints($ruleName , $auptarget, '', $infoTargetUser, $usertargetpoints); // for who has gived the thank you if ($aupactor) AlphaUserPointsHelper::newpoints($ruleName , $aupactor, '', $infoRootUser ); } } }
public static function checkChangeLevel($referrerid, $newtotal) { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $ok = 0; $lang = JFactory::getLanguage(); $lang->load('com_alphauserpoints', JPATH_SITE); JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'tables'); $resultChangeLevel1 = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_changelevel1', 0, $referrerid); $resultChangeLevel2 = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_changelevel2', 0, $referrerid); $resultChangeLevel3 = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_changelevel3', 0, $referrerid); if ($resultChangeLevel1) { $checkAlreadyDone1 = explode(',', $resultChangeLevel1[0]->exclude_items); } if ($resultChangeLevel2) { $checkAlreadyDone2 = explode(',', $resultChangeLevel2[0]->exclude_items); } if ($resultChangeLevel3) { $checkAlreadyDone3 = explode(',', $resultChangeLevel3[0]->exclude_items); } $userid = AlphaUserPointsHelper::getUserID($referrerid); // get actual group fot this user jimport('joomla.user.helper'); $authorizedLevels = JAccess::getAuthorisedViewLevels($userid); $result = array_keys(JUserHelper::getUserGroups($userid)); $actualgroup = end($result); if ($resultChangeLevel1 && $newtotal >= $resultChangeLevel1[0]->points2 && !in_array(intval($resultChangeLevel1[0]->content_items), $authorizedLevels) && !in_array($userid, $checkAlreadyDone1)) { // delete old group $query = "DELETE FROM `#__user_usergroup_map` WHERE `user_id`='{$userid}'"; $db->setQuery($query); $db->query(); JUserHelper::addUserToGroup($userid, intval($resultChangeLevel1[0]->content_items)); $user = JUser::getInstance((int) $userid); $ok = 1; $resultChangeLevel = $resultChangeLevel1; $result = JUserHelper::getUserGroups($userid); $actualnamegroup = end($result); // insert done for this user in this rule if ($resultChangeLevel1[0]->exclude_items != '') { $insertUserId = $resultChangeLevel1[0]->exclude_items . ',' . $userid; } else { $insertUserId = $userid; } $row = JTable::getInstance('rules'); $row->load(intval($resultChangeLevel1[0]->id)); $row->exclude_items = $insertUserId; $db->updateObject('#__alpha_userpoints_rules', $row, 'id'); } if ($resultChangeLevel2 && $newtotal >= $resultChangeLevel2[0]->points2 && !in_array(intval($resultChangeLevel2[0]->content_items), $authorizedLevels) && !in_array($userid, $checkAlreadyDone2)) { $query = "DELETE FROM `#__user_usergroup_map` WHERE `user_id`='{$userid}'"; $db->setQuery($query); $db->query(); JUserHelper::addUserToGroup($userid, intval($resultChangeLevel2[0]->content_items)); $user = JUser::getInstance((int) $userid); $ok = 1; $resultChangeLevel = $resultChangeLevel2; $result = JUserHelper::getUserGroups($userid); $actualnamegroup = end($result); $row = JTable::getInstance('rules'); $row->load(intval($resultChangeLevel2[0]->id)); $row->exclude_items = $insertUserId; $db->updateObject('#__alpha_userpoints_rules', $row, 'id'); } if ($resultChangeLevel3 && $newtotal >= $resultChangeLevel3[0]->points2 && !in_array(intval($resultChangeLevel3[0]->content_items), $authorizedLevels) && !in_array($userid, $checkAlreadyDone3)) { $query = "DELETE FROM `#__user_usergroup_map` WHERE `user_id`='{$userid}'"; $db->setQuery($query); $db->query(); JUserHelper::addUserToGroup($userid, intval($resultChangeLevel3[0]->content_items)); $user = JUser::getInstance((int) $userid); $ok = 1; $resultChangeLevel = $resultChangeLevel3; $result = JUserHelper::getUserGroups($userid); $actualnamegroup = end($result); $row = JTable::getInstance('rules'); $row->load(intval($resultChangeLevel3[0]->id)); $row->exclude_items = $insertUserId; $db->updateObject('#__alpha_userpoints_rules', $row, 'id'); } if ($ok) { // refresh session if user online $temp = JFactory::getUser((int) $userid); $temp->groups = $user->groups; $temp = JFactory::getUser((int) $userid); if ($temp->id == $userid) { $temp->groups = $user->groups; } } // show message only for current user and if frontend site if ($referrerid == @$_SESSION['referrerid'] && $app->isSite() && $ok) { // display message for the current user if ($resultChangeLevel[0]->displaymsg && $resultChangeLevel[0]->msg != '') { $msg = str_replace('{username}', $user->username, $resultChangeLevel[0]->msg); $msg = str_replace('{points}', AlphaUserPointsHelper::getFPoints($resultChangeLevel[0]->points), $msg); $msg = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $msg); AlphaUserPointsHelper::displayMessageSystem($msg); } elseif ($resultChangeLevel[0]->displaymsg && $resultChangeLevel[0]->msg == '') { AlphaUserPointsHelper::displayMessageSystem(sprintf(JText::_('AUP_MSG_YOUHAVENEWUSERRIGHTS'), AlphaUserPointsHelper::getFPoints($resultChangeLevel[0]->points2), $actualnamegroup)); } } if ($ok) { // insert this new activity in database $datareference = sprintf(JText::_('AUP_DESCRIPTIONACTIVITYONCHANGELEVEL'), AlphaUserPointsHelper::getFPoints($resultChangeLevel[0]->points2), $actualnamegroup); //AlphaUserPointsHelper::insertUserPoints( $referrerid, $resultChangeLevel[0], 0, '', $datareference ); //Send notification if ($resultChangeLevel[0]->notification) { AlphaUserPointsHelper::sendnotification($referrerid, $resultChangeLevel[0]->points2, $newtotal, $resultChangeLevel[0]); // load external plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('alphauserpoints'); $rule_name = JText::_($resultChangeLevel[0]->rule_name); $results = $dispatcher->trigger('onSendNotificationAlphaUserPoints', array(&$resultChangeLevel[0], $rule_name, $resultChangeLevel[0]->points2, $newtotal, $referrerid, $userid)); } // load external plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('alphauserpoints'); $results = $dispatcher->trigger('onChangeLevelAlphaUserPoints', array(&$resultChangeLevel[0], $actualnamegroup, $userid, $referrerid)); } }
function _save_profile() { $app = JFactory::getApplication(); // initialize variables $db = JFactory::getDBO(); $post = JRequest::get('post'); $profilecomplete = 0; if ($post['referreid'] == '') { echo "<script>window.history.go(-1);</script>\n"; exit; } JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'tables'); $row = JTable::getInstance('userspoints'); if (!isset($post['gender'])) { $post['gender'] = 0; } if ($post['birthdate'] == '') { $post['birthdate'] = '0000-00-00'; } elseif ($post['birthdate'] != '') { // Check format date to save $valdat = $post['birthdate']; $format = substr($valdat, -5, 1); if ($format == '-' || $format == '/') { // french format $cday = substr($valdat, -10, 2); $cmonth = substr($valdat, -7, 2); $cyear = substr($valdat, -4, 4); $post['birthdate'] = $cyear . '-' . $cmonth . '-' . $cday; } } $curdate = date("Y-m-d"); if ($post['birthdate'] >= $curdate) { $post['birthdate'] = '0000-00-00'; } if (!$row->bind($post)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $app->enqueueMessage(JText::_('AUP_CHANGE_SAVED')); // check if all field are complete for the profile complete rule if ($post['gender'] > 0 && $post['birthdate'] != '' && $post['birthdate'] != '0000-00-00' && $post['aboutme'] != '' && $post['city'] != '' && $post['avatar'] != '' && $post['job'] != '' && $post['education'] != '' && $post['graduationyear'] != '') { $profilecomplete = 1; } // rules for Profile require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if ($profilecomplete) { // assigns points when the user upload his avatar: this rule can be assigned only once per user AlphaUserPointsHelper::userpoints('sysplgaup_profilecomplete', '', 0, $post['referreid']); } else { // remove points if profile has been complete and now remove required fields for profile complete -> return state incomplete $rule = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_profilecomplete'); if ($rule) { // rule published // get ID of rule named 'sysplgaup_profilecomplete' $rule_id = $rule[0]->id; $query = "DELETE FROM #__alpha_userpoints_details WHERE rule='" . $rule_id . "' AND referreid='" . $post['referreid'] . "' AND keyreference='" . $post['referreid'] . "'"; $db->setQuery($query); $db->query(); // recount for this user $this->checkNewTotal($post['referreid'], $rule_id); } } }
public function onUserLogin($user, $options = array()) { $app = JFactory::getApplication(); $db = JFactory::getDBO(); jimport('joomla.user.helper'); $instance = new JUser(); if ($id = intval(JUserHelper::getUserId($user['username']))) { $instance->load($id); } if ($instance->get('block') == 0) { require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; // start the user session for AlphaUserpoints AlphaUserPointsHelper::getReferreid(intval($instance->get('id'))); if ($app->isSite()) { // load language component $lang = JFactory::getLanguage(); $lang->load('com_alphauserpoints', JPATH_SITE); // check raffle subscription to showing a reminder message // check first if rule for raffle is enabled $result = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_raffle', 1); if ($result) { $resultCurrentRaffle = $this->checkIfCurrentRaffleSubscription(intval($instance->get('id'))); if ($resultCurrentRaffle == 'stillRegistered') { $messageAvailable = JText::_('AUP_YOU_ARE_STILL_NOT_REGISTERED_FOR_RAFFLE'); if ($messageAvailable != '') { $messageRaffle = sprintf(JText::_('AUP_YOU_ARE_STILL_NOT_REGISTERED_FOR_RAFFLE'), $user['username']); $app->enqueueMessage($messageRaffle); } } } } //return true; } }
public function sendinvite() { $app = JFactory::getApplication(); JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // active user $user = JFactory::getUser(); $db = JFactory::getDBO(); jimport('joomla.mail.helper'); $model = $this->getModel('alphauserpoints'); $view = $this->getView('invite', 'html'); $SiteName = $app->getCfg('sitename'); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $jnow = JFactory::getDate(); $now = $jnow->toSql(); $uri = JURI::getInstance(); $base = $uri->toString(array('scheme', 'host', 'port')); $params = $model->_getParamsAUP(); $cparams = JComponentHelper::getParams('com_alphauserpoints'); $referrerid = $model->_getReferreid(); if ($referrerid) { $link = getLinkToInvite($referrerid, $cparams->get('systemregistration')); } else { $link = $base . JRoute::_(''); } if ($params->get('userecaptcha') == 1 || $params->get('userecaptcha') == 2 && !$user->id) { require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'assets' . DS . 'recaptcha' . DS . 'recaptchalib.php'; $privatekey = $params->get('privkey'); // the response from reCAPTCHA $resp = null; // the error code from reCAPTCHA, if any $error = null; // was there a reCAPTCHA response? $recaptcha_response_field = JFactory::getApplication()->input->get('recaptcha_response_field', '', 'string'); //if ($_POST["recaptcha_response_field"]) { if ($recaptcha_response_field) { $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $recaptcha_response_field); if (!$resp->is_valid) { // set the error code so that we can display it $error = $resp->error; JError::raiseWarning(0, $error); return $this->display(); } } else { JError::raiseWarning(0, 'Captcha'); return $this->display(); } } // An array of e-mail headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender', 'from', 'subject'); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we fine one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos(@$_POST[$field], $header) !== false) { JError::raiseError(403, ''); } } } /* * Free up memory */ unset($headers, $fields); $imported_emails = $_POST['importedemails']; $other_emails = JRequest::getString('other_recipients', '', 'post'); $sender = JRequest::getString('sender', '', 'post'); // Check for a valid to address $errorMail = false; // build list emails if ($imported_emails == '' && $other_emails != '') { $emails = $other_emails; } elseif ($other_emails == '' && $imported_emails != '') { $emails = $imported_emails; } elseif ($imported_emails != '' && $other_emails != '') { $emails = $imported_emails . "," . $other_emails; } else { $emails = ""; $errorMail = JText::_('AUP_EMAIL_INVALID'); JError::raiseWarning(0, $errorMail); } $emails = @explode(',', $emails); // Check for a valid from address if (!$MailFrom || !JMailHelper::isEmailAddress($MailFrom)) { $errorMail = JText::sprintf('AUP_EMAIL_INVALID', $MailFrom); JError::raiseWarning(0, $errorMail); } if ($errorMail) { return $this->display(); } // Build the message to send $msg = JText::_('AUP_EMAIL_MSG_INVITE'); $custommessage = JRequest::getString('custommessage', '', 'post'); $formatMail = '0'; $bcc2admin = '0'; if ($params->get('templateinvite', 0)) { JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'tables'); $row = JTable::getInstance('template_invite'); $row->load(intval($params->get('templateinvite'))); $subject = $row->emailsubject; $body = $row->emailbody; $body = str_replace('{name}', $sender, $body); $body = str_replace('{custom}', $custommessage, $body); $body = str_replace('{link}', $link, $body); $bcc2admin = $row->bcc2admin; $formatMail = $row->emailformat; } else { $subject = JText::_('AUP_YOUAREINVITEDTOREGISTERON') . " " . $SiteName; $body = sprintf($msg, $SiteName, $sender, $link) . " \n" . $custommessage; } // Clean the email data $subject = JMailHelper::cleanSubject($subject); //$body = JMailHelper::cleanBody($body); require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; // Limit $max = $params->get('maxemailperinvite'); $maxperday = $params->get('maxinvitesperday'); $delay = intval($params->get('delaybetweeninvites')); $counter = 0; $rule_ID = $model->_getRuleID('sysplgaup_invite'); $refer_ID = AlphaUserPointsHelper::getAnyUserReferreID($user->id); $numpoints4invite = AlphaUserPointsHelper::getPointsRule('sysplgaup_invite'); $totalpointsearned = 0; $currentmaxperday = $model->_checkCurrentMaxPerDay($rule_ID, $user->id, $referrerid, $_SERVER["REMOTE_ADDR"]); $checkdelay = 1; if ($delay) { $checkdelay = $model->_checkLastInviteForDelay($rule_ID, $user->id, $referrerid, $_SERVER["REMOTE_ADDR"], $delay); } if (!$checkdelay) { $errorTime = JText::_('AUP_DELAY_BETWEEN_INVITES_INVALID'); JError::raiseWarning(0, $errorTime); return $this->display(); } if ($currentmaxperday < $maxperday) { $mailer = JFactory::getMailer(); foreach ($emails as $email) { $aEmails[0] = $model->_extractEmailsFromString($email); $email = $aEmails[0][0]; if (JMailHelper::isEmailAddress($email)) { $mailer->setSender(array($MailFrom, $FromName)); $mailer->setSubject($subject); $mailer->isHTML((bool) $formatMail); $mailer->CharSet = "utf-8"; $mailer->setBody($body); $mailer->addRecipient($email); if ($bcc2admin) { // get all users allowed to receive e-mail system $query = "SELECT email" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'"; $db->setQuery($query); $rowsAdmins = $db->loadObjectList(); foreach ($rowsAdmins as $rowsAdmin) { $mailer->addBCC($rowsAdmin->email); } } if ($mailer->Send() === true) { if ($user->id) { if (AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_invite')) { // insert email for tracking $email2 = str_replace("@", " [at] ", $email); // change @ because can be display on frontend in latest activity $keyreference = AlphaUserPointsHelper::buildKeyreference('sysplgaup_invite', $email); AlphaUserPointsHelper::userpoints('sysplgaup_invite', $refer_ID, 0, $keyreference, $email2); $totalpointsearned = $totalpointsearned + $numpoints4invite; } } else { // guest user : Insert IP and email fortracking JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'tables'); $row = JTable::getInstance('userspointsdetails'); $row->id = NULL; $row->referreid = 'GUEST'; $row->points = 0; $row->insert_date = $now; $row->expire_date = ''; $row->rule = $rule_ID; $row->approved = 1; $row->status = 1; $row->keyreference = $_SERVER["REMOTE_ADDR"]; $row->datareference = $email; if (!$row->store()) { JError::raiseError(500, $row->getError()); } } $counter++; $currentmaxperday++; } if ($counter == $max || $currentmaxperday == $maxperday) { break; } } } if ($totalpointsearned) { $app->enqueueMessage(sprintf(JText::_('AUP_CONGRATULATION'), $totalpointsearned)); } } else { $maxperdaylimit = JText::_('AUP_MAXINVITESPERDAY') . " " . $maxperday; $app->enqueueMessage($maxperdaylimit); } switch ($counter) { case '0': $message = JText::_('AUP_NO_EMAIL_HAS_BEEN_SENT'); break; case '1': $message = JText::_('AUP_EMAIL_SENT'); break; default: $message = JText::_('AUP_EMAILS_SENT'); $message = sprintf($message, $counter); break; } $app->enqueueMessage($message); $this->setRedirect('index.php?option=com_alphauserpoints&view=invite&Itemid=' . JFactory::getApplication()->input->get('Itemid', '')); $this->redirect(); }