示例#1
0
 /**
  * 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;
     }
 }
示例#2
0
文件: points.php 项目: Ruud68/cjblog
 function save_custom_points()
 {
     $app = JFactory::getApplication();
     $ids = $app->input->getArray(array('cid' => 'array', 'points' => 'int', 'description' => 'string'));
     JArrayHelper::toInteger($ids['cid']);
     if (!empty($ids['cid']) && !empty($ids['description']) && $ids['points'] != 0) {
         foreach ($ids['cid'] as $userid) {
             CjBlogApi::award_points('com_system.custom', $userid, $ids['points'], null, $ids['description']);
         }
         $this->setRedirect(JRoute::_('index.php?option=' . CJBLOG . '&view=points', false), JText::_('COM_CJBLOG_SUCCESS'));
     } else {
         $this->setRedirect(JRoute::_('index.php?option=' . CJBLOG . '&view=points', false), JText::_('COM_CJBLOG_FAILED'));
     }
 }
示例#3
0
 public function onContentBeforeDelete($context, $article)
 {
     if ($context != 'com_content.article') {
         return true;
     }
     $api = JPATH_ROOT . '/components/com_cjblog/api.php';
     if (file_exists($api)) {
         if (!empty($article->created_by) && !empty($article->id)) {
             $db = JFactory::getDbo();
             $query = 'select count(*) from #__content where created_by = ' . $article->created_by . ' and state = 1';
             $db->setQuery($query);
             $count = $db->loadResult();
             require_once $api;
             CjBlogApi::trigger_badge_rule('com_content.delete_article', array('num_articles' => $count), $article->created_by);
             CjBlogApi::award_points('com_content.deletearticle', $article->created_by, 0, $article->id, $article->title);
         }
     } else {
         die('CjBlog component is not installed.');
     }
 }
示例#4
0
文件: api.php 项目: pguilford/vcomcc
 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;
     }
 }