本文整理汇总了PHP中Foundry::points方法的典型用法代码示例。如果您正苦于以下问题:PHP Foundry::points方法的具体用法?PHP Foundry::points怎么用?PHP Foundry::points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundry
的用法示例。
在下文中一共展示了Foundry::points方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate
/**
* Allows user to activate their account.
*
* @since 1.0
* @access public
*/
public function activate()
{
$my = FD::user();
// Get current view.
$view = $this->getCurrentView();
// Get the id from the request
$id = JRequest::getInt('userid');
$currentUser = FD::user($id);
// If user is already logged in, redirect to the dashboard.
if ($my->isLoggedIn()) {
return $view->call(__FUNCTION__, $currentUser);
}
$token = JRequest::getVar('token', '');
// If token is empty, warn the user.
if (empty($token) || strlen($token) !== 32) {
$view->setMessage(JText::_('COM_EASYSOCIAL_REGISTRATION_ACTIVATION_TOKEN_INVALID'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $currentUser);
}
// Retrieve registration model
$model = FD::model('Registration');
// Activate the token.
$user = $model->activate($token);
if ($user === false) {
$view->setMessage($model->getError(), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $currentUser);
}
// @points: user.register
// Assign points when user registers on the site.
$points = Foundry::points();
$points->assign('user.registration', 'com_easysocial', $this->id);
// @badge: registration.create
// Assign badge for the person that initiated the friend request.
$badge = FD::badges();
$badge->log('com_easysocial', 'registration.create', $user->id, JText::_('COM_EASYSOCIAL_REGISTRATION_BADGE_REGISTERED'));
// Get configuration object.
$config = FD::config();
// Add activity logging when a uer registers on the site.
// Get the application params
$app = FD::table('App');
$app->load(array('element' => 'profiles', 'group' => SOCIAL_TYPE_USER));
$params = $app->getParams();
// If not allowed, we will not want to proceed here.
if ($params->get('stream_register', true)) {
$stream = FD::stream();
$streamTemplate = $stream->getTemplate();
// Set the actor
$streamTemplate->setActor($user->id, SOCIAL_TYPE_USER);
// Set the context
$streamTemplate->setContext($user->id, SOCIAL_TYPE_PROFILES);
// Set the verb
$streamTemplate->setVerb('register');
// set sitewide
$streamTemplate->setSiteWide();
$streamTemplate->setAccess('core.view');
// Add stream template.
$stream->add($streamTemplate);
}
$view->setMessage(JText::_('COM_EASYSOCIAL_REGISTRATION_ACTIVATION_COMPLETED_SUCCESS'), SOCIAL_MSG_SUCCESS);
return $view->call(__FUNCTION__, $user);
}
示例2: assignPoints
/**
* Assign points
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function assignPoints($rule, $creatorId = null)
{
if (!$this->exists()) {
return false;
}
$creator = Foundry::user($creatorId);
$points = Foundry::points();
$state = $points->assign($rule, 'com_easyblog', $creator->id);
return $state;
}
示例3: addpoints
public function addpoints(JUser $receiver, $options = array())
{
if (empty($options['command']) or empty($options['extension'])) {
$return['success'] = 0;
$return['message'] = 'Command or extension not passed to ';
return $return;
}
$return['success'] = Foundry::points()->assign($options['command'], $options['extension'], $receiver->id);
}
示例4: use_credits
function use_credits($userid, $credits, $info)
{
$params = JComponentHelper::getParams(S_APP_NAME);
$points_per_credit = (int) $params->get('points_per_credit', 0);
$points = -($credits * $points_per_credit);
$function = '';
switch ($params->get('points_system', 'none')) {
case 'cjblog':
case 'jomsocial':
$function = 'com_communitysurveys.credits';
break;
case 'aup':
$function = 'sysplgaup_survey_credits';
break;
case 'easysocial':
$api = JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php';
if (file_exists($api)) {
require_once $api;
Foundry::points()->assignCustom($userid, $points, $info);
}
// now return from here as the points are already added.
return true;
default:
return false;
}
CJFunctions::award_points($params->get('points_system', 'none'), $userid, array('points' => $points, 'reference' => '', 'info' => $info, 'function' => $function));
}
示例5: award_points
/**
* Award points to the user using selected points system. The user id and required parameters should be passed based on points system selected.
*
* Parameters array should be an associative array which can include
* <ul>
* <li>function: the function name used to award points.</li>
* <li>points: points awarded to the user. For jomsocial this has no effect as the points are taken from xml rule.</li>
* <li>reference: the reference string for AUP rule</li>
* <li>info: Brief information about this point.</li>
* </ul>
*
* @param string $system
* @param int $userid
* @param array $params
*/
public static function award_points($system, $userid, $params = array())
{
switch ($system) {
case 'cjblog':
$api = JPATH_ROOT . DS . 'components' . DS . 'com_cjblog' . DS . 'api.php';
if (file_exists($api)) {
include_once $api;
$points = !empty($params['points']) ? $params['points'] : 0;
$reference = !empty($params['reference']) ? $params['reference'] : null;
$description = !empty($params['info']) ? $params['info'] : null;
CjBlogApi::award_points($params['function'], $userid, $points, $reference, $description);
}
break;
case 'jomsocial':
$api = JPATH_SITE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php';
if (file_exists($api) && !empty($params['function'])) {
include_once $api;
CuserPoints::assignPoint($params['function'], $userid);
}
break;
case 'aup':
$api = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
if (file_exists($api) && !empty($params['function']) && isset($params['info'])) {
require_once $api;
$reference = !empty($params['reference']) ? $params['reference'] : null;
$aupid = AlphaUserPointsHelper::getAnyUserReferreID($userid);
AlphaUserPointsHelper::newpoints($params['function'], $aupid, $reference, $params['info'], $params['points']);
}
break;
case 'touch':
$api = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'api.php';
if (file_exists($api) && !empty($params['points'])) {
require_once $api;
JSCommunityApi::increaseKarma($userid, $params['points']);
}
break;
case 'easysocial':
$api = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_easysocial' . DS . 'includes' . DS . 'foundry.php';
if (file_exists($api)) {
require_once $api;
Foundry::points()->assign($params['function'], $params['component'], $userid);
}
break;
}
}
示例6: approve
/**
* Approves a user's registration application
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function approve($sendEmail = true)
{
// check if the user already approved or not.
if ($this->block == 0 && $this->state == SOCIAL_USER_STATE_ENABLED) {
//already approved.
return true;
}
// Update the JUser object.
$this->block = 0;
// Update the current state property.
$this->state = SOCIAL_USER_STATE_ENABLED;
// If set to admin approve, user should be activated regardless of whether user activates or not.
$this->activation = 0;
// Store the block status
$this->save();
// Activity logging.
// Announce to the world when a new user registered on the site.
$config = FD::config();
// Get the application params
$app = FD::table('App');
$app->load(array('element' => 'profiles', 'group' => SOCIAL_TYPE_USER));
$params = $app->getParams();
// If not allowed, we will not want to proceed here.
if ($params->get('stream_register', true)) {
// Get the stream library.
$stream = FD::stream();
// Get stream template
$streamTemplate = $stream->getTemplate();
// Set the actors.
$streamTemplate->setActor($this->id, SOCIAL_TYPE_USER);
// Set the context for the stream.
$streamTemplate->setContext($this->id, SOCIAL_TYPE_PROFILES);
// Set the verb for this action as this is some sort of identifier.
$streamTemplate->setVerb('register');
$streamTemplate->setSiteWide();
$streamTemplate->setAccess('core.view');
// Add the stream item.
$stream->add($streamTemplate);
}
// add user into com_finder index
$this->syncIndex();
// @points: user.register
// Assign points when user registers on the site.
$points = Foundry::points();
$points->assign('user.registration', 'com_easysocial', $this->id);
// @badge: registration.create
// Assign badge for the person that initiated the friend request.
$badge = FD::badges();
$badge->log('com_easysocial', 'registration.create', $this->id, JText::_('COM_EASYSOCIAL_REGISTRATION_BADGE_REGISTERED'));
// If we need to send email to the user, we need to process this here.
if ($sendEmail) {
// Get the application data.
$jConfig = FD::jConfig();
// Get the current profile this user has registered on.
$profile = $this->getProfile();
// Push arguments to template variables so users can use these arguments
$params = array('site' => $jConfig->getValue('sitename'), 'username' => $this->username, 'name' => $this->getName(), 'avatar' => $this->getAvatar(SOCIAL_AVATAR_LARGE), 'email' => $this->email, 'profileType' => $profile->get('title'));
JFactory::getLanguage()->load('com_easysocial', JPATH_ROOT);
// Get the email title.
$title = JText::_('COM_EASYSOCIAL_EMAILS_REGISTRATION_APPLICATION_APPROVED');
// Immediately send out emails
$mailer = FD::mailer();
// Get the email template.
$mailTemplate = $mailer->getTemplate();
// Set recipient
$mailTemplate->setRecipient($this->getName(), $this->email);
// Set title
$mailTemplate->setTitle($title);
// Set the contents
$mailTemplate->setTemplate('site/registration/approved', $params);
// Set the priority. We need it to be sent out immediately since this is user registrations.
$mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
// Try to send out email now.
$mailer->create($mailTemplate);
}
return true;
}
示例7: activate
/**
* Activates a user account.
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function activate($sendEmail = true)
{
// Load Joomla users plugin for triggers.
JPluginHelper::importPlugin('user');
// Set joomla parameters
$this->activation = '';
$this->block = 0;
// Update the current state property.
$this->state = SOCIAL_USER_STATE_ENABLED;
// Try to save the user.
$state = $this->save();
// Save the user.
if (!$state) {
$this->setError($this->getError());
return false;
}
//index user into com_finder
$this->syncIndex();
// @points: user.register
// Assign points when user registers on the site.
$points = Foundry::points();
$points->assign('user.registration', 'com_easysocial', $this->id);
return true;
}
示例8: awardPoints
public function awardPoints($app, $userId, $options)
{
$points = !empty($options['points']) ? $options['points'] : 0;
$reference = !empty($options['reference']) ? $options['reference'] : null;
$title = !empty($options['title']) ? $options['title'] : null;
$description = !empty($options['info']) ? $options['info'] : null;
switch ($app) {
case 'cjforum':
$api = JPATH_ROOT . '/components/com_cjforum/lib/api.php';
if (file_exists($api)) {
require_once $api;
$pointsApi = CjForumApi::getPointsApi();
$pointsApi->awardPoints($options['function'], $userId, $points, $reference, $title, $description);
}
break;
case 'cjblog':
$api = JPATH_ROOT . '/components/com_cjblog/api.php';
if (file_exists($api)) {
include_once $api;
CjBlogApi::award_points($options['function'], $userId, $points, $reference, $description);
}
break;
case 'jomsocial':
$api = JPATH_SITE . '/components/com_community/libraries/userpoints.php';
if (file_exists($api) && !empty($options['function'])) {
include_once $api;
CuserPoints::assignPoint($options['function'], $userId);
}
break;
case 'aup':
$api = JPATH_SITE . '/components/com_alphauserpoints/helper.php';
if (file_exists($api) && !empty($options['function'])) {
require_once $api;
$aupid = AlphaUserPointsHelper::getAnyUserReferreID($userId);
AlphaUserPointsHelper::newpoints($options['function'], $aupid, $reference, $description, $points);
}
break;
case 'easysocial':
$api = JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php';
if (file_exists($api)) {
require_once $api;
Foundry::points()->assign($options['function'], $options['component'], $userId);
}
break;
}
}
示例9: assignPoints
/**
* Assign points
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function assignPoints($rule, $creatorId = null, $post = null)
{
if (!$this->exists() || !$this->config->get('integration_easysocial_points')) {
return false;
}
// Since all the "rule" in EasyDiscuss is prepended with discuss. , we need to remove it
$rule = str_ireplace('easydiscuss.', '', $rule);
$creator = Foundry::user($creatorId);
$points = Foundry::points();
if ($rule == 'new.comment') {
$params = $points->getParams('new.comment', 'com_easydiscuss');
$length = JString::strlen($post->comment);
$state = false;
if (!$params) {
// For earlier versions of EasySocial
// This could be older version of EasySocial
$points->assign($rule, 'com_easydiscuss', $creator->id);
} else {
$min = isset($params->get('min')->value) ? $params->get('min')->value : $params->get('min')->default;
// Get the content length
if ($length > $min || $min == 0) {
$state = $points->assign($rule, 'com_easydiscuss', $creator->id);
}
}
return $state;
}
if ($rule == 'new.reply') {
$params = false;
if (method_exists($points, 'getParams')) {
$params = $points->getParams('new.reply', 'com_easydiscuss');
}
$length = JString::strlen($post->content);
$state = false;
if (!$params) {
// For earlier versions of EasySocial
// This could be older version of EasySocial
$points->assign($rule, 'com_easydiscuss', $creator->id);
} else {
// Get the content length
if ($length > $params->get('min')->value || $params->get('min')->value == 0) {
$state = $points->assign($rule, 'com_easydiscuss', $creator->id);
}
}
return $state;
}
$state = $points->assign($rule, 'com_easydiscuss', $creator->id);
return $state;
}
示例10: assignPoints
/**
* Assign points
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function assignPoints( $rule , $creatorId = null, $comment = null)
{
if( !$this->exists() )
{
return false;
}
$creator = Foundry::user( $creatorId );
$points = Foundry::points();
if ($rule == 'komento.add.comment' || $rule == 'komento.reply.comment') {
if (method_exists($points, 'getParams')) {
$params = $points->getParams($rule, 'com_komento');
$length = JString::strlen($comment->comment);
$state = false;
if ($params) {
// Get the content length
if ($length > $params->get('min')->value || $params->get('min')->value == 0) {
$state = $points->assign($rule, 'com_komento', $creator->id);
}
} else {
$state = $points->assign($rule, 'com_komento', $creator->id);
}
} else {
$state = $points->assign($rule, 'com_komento', $creator->id);
}
return $state;
}
$state = $points->assign( $rule , 'com_komento' , $creator->id );
return $state;
}