static function addPoints_jomsocial($action, $username, $course_id, $course_name) { if (file_exists(JPATH_ADMINISTRATOR . '/components/com_community/tables/cache.php')) { require_once JPATH_ADMINISTRATOR . 'components/com_community/tables/cache.php'; } require_once JPATH_SITE . '/components/com_community/libraries/core.php'; require_once JPATH_SITE . '/components/com_community/libraries/userpoints.php'; if (class_exists('CFactory')) { $userPoint = CFactory::getModel('userpoints'); } else { $userPoint = new CommunityModelUserPoints(); } $upObj = $userPoint->getPointData($action); $published = $upObj->published; if ($published) { $points = $upObj->points; } else { $points = 0; } if ($points == 0) { return 0; } $user = CFactory::getUser($username); $points += $user->getKarmaPoint(); $user->_points = $points; $user->save(); return $points; }
/** * Private method. DO NOT call this method directly. * Return points for various actions. Return value should be configurable from the backend. */ public function _getActionPoint($action, $aid = 0) { include_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'userpoints.php'; $userPoint = ''; if (class_exists('CFactory')) { $userPoint = CFactory::getModel('userpoints'); } else { $userPoint = new CommunityModelUserPoints(); } $point = 0; $upObj = $userPoint->getPointData($action); if (!empty($upObj)) { $published = $upObj->published; $access = $upObj->access; if (is_array($aid)) { //joomla 1.6 if (in_array($access, $aid)) { $point = $upObj->points; } } else { //joomla 1.5 and older $userAccess = empty($aid) ? 0 : $aid; if ($access <= $userAccess) { $point = $upObj->points; } } if ($published == '0') { $point = 0; } } return $point; }
/** * Private method. DO NOT call this method directly. * Return points for various actions. Return value should be configurable from the backend. */ public static function _getActionPoint($action, $aid = 0) { $userPoint = ''; if (class_exists('CFactory')) { $userPoint = CFactory::getModel('userpoints'); } else { $userPoint = new CommunityModelUserPoints(); } $point = 0; $upObj = $userPoint->getPointData($action); if (!empty($upObj)) { $published = $upObj->published; $access = $upObj->access; $point = $upObj->points; if ($published == '0') { $point = 0; } } return $point; }
/** * Return points for various actions. Return value should be configurable from the backend * */ function getActionPoint($action, $gid = 0) { include_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'userpoints.php'; $userPoint = ''; if (class_exists('CFactory')) { $userPoint = CFactory::getModel('userpoints'); } else { $userPoint = new CommunityModelUserPoints(); } $point = 0; $upObj = $userPoint->getPointData($action); if (!empty($upObj)) { $published = $upObj->published; $point = $upObj->points; $access = $upObj->access; if ($published == '0') { $point = 0; } else { if ($access != $gid) { $point = 0; } } } return $point; }