本文整理汇总了PHP中CUserPoints::_getActionPoint方法的典型用法代码示例。如果您正苦于以下问题:PHP CUserPoints::_getActionPoint方法的具体用法?PHP CUserPoints::_getActionPoint怎么用?PHP CUserPoints::_getActionPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUserPoints
的用法示例。
在下文中一共展示了CUserPoints::_getActionPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignPoint
/**
* add points to user based on the action.
*/
function assignPoint($action, $userId = null)
{
//get the rule points
//must use the JFactory::getUser to get the aid
$juser =& JFactory::getUser($userId);
if ($juser->id != 0) {
$aid = $juser->aid;
// if the aid is null, means this is not the current logged-in user.
// so we need to manually get this aid for this user.
if (is_null($aid)) {
$aid = 0;
//defautl to 0
// Get an ACL object
$acl =& JFactory::getACL();
$grp = $acl->getAroGroup($juser->id);
$group = 'USERS';
if ($acl->is_group_child_of($grp->name, $group)) {
$aid = 1;
// Fudge Authors, Editors, Publishers and Super Administrators into the special access group
if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
$aid = 2;
}
}
}
$points = CUserPoints::_getActionPoint($action, $aid);
$user = CFactory::getUser($userId);
$points += $user->getKarmaPoint();
$user->_points = $points;
$user->save();
}
}
示例2: assignPoint
/**
* add points to user based on the action.
* @param $action
* @param null $userId
*/
public static function assignPoint($action, $userId = null)
{
//get the rule points
//must use the JFactory::getUser to get the aid
$juser = JFactory::getUser($userId);
//since 4.0, check if this action is published, else return false (boolean)
$userPointModel = CFactory::getModel('Userpoints');
$point = $userPointModel->getPointData($action);
if (!isset($point->published) || !$point->published) {
return false;
}
if ($juser->id != 0) {
if (!method_exists($juser, 'getAuthorisedViewLevels')) {
$aid = $juser->aid;
// if the aid is null, means this is not the current logged-in user.
// so we need to manually get this aid for this user.
if (is_null($aid)) {
$aid = 0;
//defautl to 0
// Get an ACL object
$acl = JFactory::getACL();
$grp = $acl->getAroGroup($juser->id);
$group = 'USERS';
if ($acl->is_group_child_of($grp->name, $group)) {
$aid = 1;
// Fudge Authors, Editors, Publishers and Super Administrators into the special access group
if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
$aid = 2;
}
}
}
} else {
//joomla 1.6
$aid = $juser->getAuthorisedViewLevels();
}
$points = CUserPoints::_getActionPoint($action, $aid);
$user = CFactory::getUser($userId);
$points += $user->getKarmaPoint();
$user->_points = $points;
$profile = JTable::getInstance('Profile', 'CTable');
$profile->load($user->id);
$user->_thumb = $profile->thumb;
$user->_avatar = $profile->avatar;
$user->save();
//Event trigger
$appsLib = CAppPlugins::getInstance();
$appsLib->loadApplications();
$params = array('action' => $action, 'points' => $points, 'userId' => $user->id);
$appsLib->triggerEvent('onAfterAssignPoint', $params);
return true;
}
}