Exemplo n.º 1
0
 function onAfterVote($poll, $option_id)
 {
     $user =& JFactory::getUser();
     $api = JPATH_ROOT . '/components/com_community/api.php';
     if ($this->params->get('points', '0') == '1' && file_exists($api)) {
         require_once $api;
         JSCommunityApi::increaseKarma($user->id, $this->params->get('points_value', '0'));
     }
     if ($this->params->get('activity', '0') == '1' && file_exists($api)) {
         require_once $api;
         $icon = 'media/acepolls/images/acepolls.png';
         $link = JRoute::_('index.php?option=com_acepolls&view=poll&id=' . $poll->id . ":" . $poll->alias . self::getItemid($poll->id));
         $text = JText::_('COM_ACEPOLLS_ACTIVITY_TEXT') . ' <a href="' . $link . '">' . $poll->title . '</a>';
         $capi = new JSCommunityApi();
         $capi->registerActivity(0, $text, $user->id, $icon, 'user', null, 'com_acepolls', '', 'Polls');
     }
 }
Exemplo n.º 2
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;
     }
 }
Exemplo n.º 3
0
 function streamActivity($action, $obj)
 {
     global $option;
     $app =& JFactory::getApplication();
     $cwConfig = $app->getUserState(SESSION_CONFIG);
     $user =& JFactory::getUser();
     $menu =& JSite::getMenu();
     $mnuitems = $menu->getItems('link', 'index.php?option=' . $option . '&view=crosswords');
     $itemid = isset($mnuitems[0]) ? '&amp;Itemid=' . $mnuitems[0]->id : '';
     if (strcasecmp($cwConfig[ACTIVITY_STREAM_TYPE], COMPONENT_JOMSOCIAL) == 0) {
         $API = JPATH_SITE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php';
         if (file_exists($API)) {
             include_once $API;
             $act = new stdClass();
             $act->cmd = 'wall.write';
             $act->actor = $user->id;
             $act->target = 0;
             // no target
             $act->content = '';
             $act->app = 'wall';
             $act->cid = 0;
             switch ($action) {
                 case 1:
                     // New question
                     $act->title = JText::_('{actor} ' . JText::_('TXT_SUBMITTED_CROSSWORD_QUESTION'));
                     break;
                 case 2:
                     // Solved crossword
                     $text = JText::_('TXT_SOLVED_CROSSWORD');
                     $link = JRoute::_('index.php?option=' . $option . '&view=crosswords&task=view&id=' . $obj->id . ':' . $obj->alias . $itemid);
                     $act->title = JText::_('{actor} ' . $text . ' <a href="' . $link . '">' . $obj->title . '</a>');
                     break;
             }
             CFactory::load('libraries', 'activities');
             CActivityStream::add($act);
         }
     } else {
         if (strcasecmp($cwConfig[ACTIVITY_STREAM_TYPE], 'touch') == 0) {
             $API = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'api.php';
             if (file_exists($API)) {
                 require_once $API;
                 $capi = new JSCommunityApi();
                 if ($user->id) {
                     $link = JRoute::_('index.php?option=' . $option . '&view=crosswords&task=view&id=' . $obj->id . ":" . $obj->alias . $itemid);
                     $icon = JURI::base() . 'components/' . $option . '/assets/images/logo.png';
                     $text = '';
                     switch ($action) {
                         case 1:
                             // New question
                             $text = $user->{$cwConfig}[USER_NAME] . ' ' . JText::_('TXT_SUBMITTED_CROSSWORD_QUESTION');
                             break;
                         case 2:
                             // solved crossword
                             $text = $user->{$cwConfig}[USER_NAME] . ' ' . JText::_('TXT_SOLVED_CROSSWORD') . ' <a href="' . $link . '">' . $obj->title . '</a>';
                             break;
                     }
                     $capi->registerActivity(0, $text, $user->get('id'), $icon, 'user', null, $option, '', 'Crosswords');
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public function addActivity($blog, $new = false)
 {
     $config = EasyBlogHelper::getConfig();
     // We do not want to add activities if new blog activity is disabled.
     if ($new && !$config->get('integrations_mighty_activity_new_blog')) {
         return false;
     }
     // We do not want to add activities if update blog activity is disabled.
     if (!$new && !$config->get('integrations_mighty_activity_update_blog')) {
         return false;
     }
     $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'api.php';
     if (!JFile::exists($file)) {
         return false;
     }
     require_once $file;
     $date = EasyBlogHelper::getDate();
     $priority = 0;
     $title = $blog->title;
     $content = '';
     if ($config->get('integrations_mighty_submit_content')) {
         $requireVerification = false;
         if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
             $row->title = JText::sprintf('COM_EASYBLOG_PASSWORD_PROTECTED_BLOG_TITLE', $blog->title);
             $requireVerification = true;
         }
         if ($requireVerification && !EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) {
             $theme = new CodeThemes();
             $theme->set('id', $blog->id);
             $theme->set('return', base64_encode($this->getBlogLink($blog)));
             $output = $theme->fetch('blog.protected.php');
         } else {
             $content = $blog->intro . $blog->content;
             $content = EasyBlogHelper::getHelper('Videos')->strip($content);
             $pattern = '#<img[^>]*>#i';
             preg_match($pattern, $content, $matches);
             // Remove all html tags from the content as we want to chop it down.
             $content = strip_tags($content);
             $content = JString::substr($content, 0, $config->get('integrations_mighty_blogs_length', 250)) . ' ...';
             $output = '<div style="background: #f4f4f4;border: 1px solid #eeee;border-radius: 5px;padding: 5px;margin-top:5px;">';
             if ($matches) {
                 $matches[0] = JString::str_ireplace('img ', 'img style="margin: 0 5px 5px 0;float: left; height: auto; width: 120px !important;"', $matches[0]);
                 $output .= $matches[0] . $content . '<div style="clear: both;"></div>';
             } else {
                 $output .= $content;
             }
             $output .= '<div style="text-align: right;"><a href="' . $this->getBlogLink($blog) . '">' . JText::_('COM_EASYBLOG_CONTINUE_READING') . '</a></div>';
             $output .= '</div>';
         }
     }
     if ($new) {
         $title = JText::sprintf('COM_EASYBLOG_MIGHTY_ACTIVITY_BLOG', $this->getBlogLink($blog), $this->getBlogTitle($blog));
     } else {
         $title = JText::sprintf('COM_EASYBLOG_MIGHTY_ACTIVITY_BLOG_UPDATE', $this->getBlogLink($blog), $this->getBlogTitle($blog));
     }
     if ($config->get('integrations_mighty_show_category')) {
         $title .= JText::sprintf('COM_EASYBLOG_MIGHTY_ACTIVITY_IN_CATEGORY', $this->getCategoryLink($blog), $this->getCategoryTitle($blog));
     }
     JSCommunityApi::registerActivity(0, $title . $output, $blog->created_by, null, 'user', null, 'com_easyblog', null, JText::_('COM_EASYBLOG_MIGHTYTOUCH_FILTER_BLOGS'));
     return true;
 }
Exemplo n.º 5
0
 function awardPoints($userid, $function, $referrence, $info)
 {
     $app =& JFactory::getApplication();
     $cwConfig =& CrosswordsHelper::get_configuration();
     if (strcasecmp($cwConfig[POINTS_SYSTEM], COMPONENT_AUP) == 0) {
         $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
         if (file_exists($api_AUP)) {
             require_once $api_AUP;
             $aupid = AlphaUserPointsHelper::getAnyUserReferreID($userid);
             if ($aupid) {
                 switch ($function) {
                     case 1:
                         //New Question
                         AlphaUserPointsHelper::newpoints(AUP_NEW_QUESTION, $aupid, $referrence, $info);
                         break;
                     case 2:
                         // Solved crossword
                         AlphaUserPointsHelper::newpoints(AUP_SOLVE_CROSSWORD, $aupid, $referrence, $info);
                         break;
                 }
             }
         }
     } else {
         if (strcasecmp($cwConfig[POINTS_SYSTEM], COMPONENT_JOMSOCIAL) == 0) {
             include_once JPATH_SITE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php';
             switch ($function) {
                 case 1:
                     //New Question
                     CuserPoints::assignPoint(JSP_NEW_QUESTION, $userid);
                     break;
                 case 2:
                     // New Answer
                     CuserPoints::assignPoint(JSP_SOLVED_CROSSWORD, $userid);
                     break;
             }
         } else {
             if (strcasecmp($cwConfig[POINTS_SYSTEM], COMPONENT_TOUCH) == 0) {
                 $API = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'api.php';
                 if (file_exists($API)) {
                     require_once $API;
                     switch ($function) {
                         case 1:
                             //New Question
                             JSCommunityApi::increaseKarma($userid, $cwConfig[TOUCH_POINTS_NEW_QUESTION]);
                             break;
                         case 2:
                             // New Answer
                             JSCommunityApi::increaseKarma($userid, $cwConfig[TOUCH_POINTS_SOLVED_CROSSWORD]);
                             break;
                     }
                 }
             }
         }
     }
 }