本文整理汇总了PHP中AlphaUserPointsHelper::checkRuleEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP AlphaUserPointsHelper::checkRuleEnabled方法的具体用法?PHP AlphaUserPointsHelper::checkRuleEnabled怎么用?PHP AlphaUserPointsHelper::checkRuleEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AlphaUserPointsHelper
的用法示例。
在下文中一共展示了AlphaUserPointsHelper::checkRuleEnabled方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getPointsOnThankyou
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;
}
示例2: _display
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);
}
示例3: onAfterProcess
/**
* 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);
}
}
示例4: _getPointsOnThankyou
private function _getPointsOnThankyou($ruleName)
{
$ruleEnabled = AlphaUserPointsHelper::checkRuleEnabled($ruleName);
if (!empty($ruleEnabled[0]->published)) {
return $ruleEnabled[0]->points2;
}
return null;
}
示例5: _get_inactive_members
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);
}
示例6: onAfterThankyou
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 );
}
}
}
示例7: checkChangeLevel
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) {
//.........这里部分代码省略.........
示例8: _save_profile
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);
}
}
}
示例9: onUserLogin
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;
}
}
示例10: sendinvite
//.........这里部分代码省略.........
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();
}