本文整理汇总了PHP中AlphaUserPointsHelper::getPointsRule方法的典型用法代码示例。如果您正苦于以下问题:PHP AlphaUserPointsHelper::getPointsRule方法的具体用法?PHP AlphaUserPointsHelper::getPointsRule怎么用?PHP AlphaUserPointsHelper::getPointsRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AlphaUserPointsHelper
的用法示例。
在下文中一共展示了AlphaUserPointsHelper::getPointsRule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUserPoints
public static function updateUserPoints($result, $referrerid, $assignpoints, $now, $referraluserpoints, $autoapproved, $rule_plugin = '', $rule_id = '', $rule_name = '', $datareference = '', $frontmessage = '')
{
$app = JFactory::getApplication();
$lang = JFactory::getLanguage();
$lang->load('com_alphauserpoints', JPATH_SITE);
$user = JFactory::getUser();
$username = $user->id ? $user->username : '';
$displaymsg = $result->displaymsg;
$msg = str_replace('{username}', $username, $result->msg);
$method = $result->method;
$db = JFactory::getDBO();
// get params definitions
$params = JComponentHelper::getParams('com_alphauserpoints');
$query = "SELECT id FROM #__alpha_userpoints WHERE `referreid`='{$referrerid}'";
$db->setQuery($query);
$referrerUser = $db->loadResult();
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'tables');
$row = JTable::getInstance('userspoints');
// update points into alpha_userpoints table
$row->load(intval($referrerUser));
$referraluser = $row->referraluser;
$newtotal = !$referraluserpoints ? $row->points + $assignpoints : $row->points + $referraluserpoints;
$row->last_update = $now;
$checkWinner = 0;
if ($row->max_points >= 1 && $newtotal > $row->max_points) {
// Max total was reached !
//$newtotal = $row->max_points;
if (AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_winnernotification', 0, $referrerid)) {
// get email admins in rule
$query = "SELECT `content_items` FROM #__alpha_userpoints_rules WHERE `plugin_function`='sysplgaup_winnernotification'";
$db->setQuery($query);
$emailadmins = $db->loadResult();
if ($autoapproved || $referraluserpoints) {
AlphaUserPointsHelper::sendwinnernotification($referrerid, $assignpoints, $newtotal, $emailadmins);
// Uddeim notification integration
if ($params->get('sendMsgUddeim', 0)) {
AlphaUserPointsHelper::sendUddeimWinnerNotification($referrerid, $assignpoints, $newtotal);
}
$checkWinner = 1;
}
}
}
if ($autoapproved) {
if ($rule_plugin == 'sysplgaup_invitewithsuccess') {
$row->referrees = $row->referrees + 1;
}
$row->points = $newtotal;
$db->updateObject('#__alpha_userpoints', $row, 'id');
}
if ($displaymsg && !$referraluserpoints) {
$realcurrentreferrerid = AlphaUserPointsHelper::getAnyUserReferreID($user->id);
switch ($rule_plugin) {
case 'sysplgaup_bonuspoints':
case 'sysplgaup_recommend':
case 'sysplgaup_reader2author':
case 'sysplgaup_buypointswithpaypal':
case 'sysplgaup_invite':
// No need congratulation...
break;
case 'sysplgaup_invitewithsuccess':
// number points in message = assign points to new user
$numpoints = AlphaUserPointsHelper::getPointsRule('sysplgaup_newregistered');
if ($numpoints && $user->id) {
if ($msg != '') {
$msg = str_replace('{points}', AlphaUserPointsHelper::getFPoints($numpoints), JText::_($msg));
$msg = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $msg);
$app->enqueueMessage($msg);
} else {
$app->enqueueMessage(sprintf(JText::_('AUP_CONGRATULATION'), AlphaUserPointsHelper::getFPoints($numpoints)));
}
}
break;
default:
if ($referrerid == $realcurrentreferrerid && $user->id) {
if ($assignpoints > 0) {
if ($msg != '') {
$msg = str_replace('{points}', AlphaUserPointsHelper::getFPoints($assignpoints), JText::_($msg));
$msg = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $msg);
$app->enqueueMessage($msg);
} else {
$app->enqueueMessage(sprintf(JText::_('AUP_CONGRATULATION'), AlphaUserPointsHelper::getFPoints($assignpoints)));
if ($rule_plugin == 'sysplgaup_happybirthday') {
$frontmessage = JText::_('AUP_HAPPYBIRTHDAY');
}
}
} elseif ($assignpoints < 0) {
if ($msg != '') {
$msg = str_replace('{points}', AlphaUserPointsHelper::getFPoints(abs($assignpoints)), JText::_($msg));
$msg = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $msg);
$app->enqueueMessage($msg);
} else {
$app->enqueueMessage(sprintf(JText::_('AUP_X_POINTS_HAS_BEEN_DEDUCTED_FROM_YOUR_ACCOUNT'), AlphaUserPointsHelper::getFPoints(abs($assignpoints))));
}
}
}
}
}
if ($rule_plugin == 'sysplgaup_custom' && $datareference) {
$rule_name = JText::_($datareference);
}
//.........这里部分代码省略.........
示例2: sendinvite
//.........这里部分代码省略.........
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);
}
}