public function store($log = true) { // @rule: Load language file from the front end. JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); $under_approval = false; if (isset($this->under_approval)) { $under_approval = true; // now we need to reset this variable from the blog object. unset($this->under_approval); } // @trigger: onBeforeSave $this->triggerBeforeSave(); // @rule: Determine if this record is new or not. if (empty($this->isnew)) { $isNew = empty($this->id) ? true : false; } else { $isNew = true; } // @rule: Get the rulesets for this user. $acl = EasyBlogACLHelper::getRuleSet(); // @rule: Process badword filters for title here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->title); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_TITLE_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Check for minimum words in the content if required. if ($config->get('main_post_min')) { $minimum = $config->get('main_post_length'); $total = JString::strlen(strip_tags($this->intro . $this->content)); if ($total < $minimum) { $this->setError(JText::sprintf('COM_EASYBLOG_CONTENT_LESS_THAN_MIN_LENGTH', $minimum)); return false; } } // @rule: Check for invalid title if (empty($this->title) || $this->title == JText::_('COM_EASYBLOG_DASHBOARD_WRITE_DEFAULT_TITLE')) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_TITLE_ERROR')); return false; } // @rule: For edited blogs, ensure that they have permissions to edit it. if (!$isNew && $this->created_by != JFactory::getUser()->id && !EasyBlogHelper::isSiteAdmin() && empty($acl->rules->moderate_entry)) { if (!class_exists('EasyBlogModelTeamBlogs')) { jimport('joomla.application.component.model'); JLoader::import('blog', EBLOG_ROOT . DIRECTORY_SEPARATOR . 'models'); } // @task: Only throw error when this blog post is not a team blog post and it's not owned by the current logged in user. JModel::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'models'); $model = JModel::getInstance('TeamBlogs', 'EasyBlogModel'); $contribution = $model->getBlogContributed($this->id); if (!$contribution || !$model->checkIsTeamAdmin(JFactory::getUser()->id, $contribution->team_id)) { $this->setError(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_BLOG')); return false; } } // @rule: Every blog post must be assigned to a category if (empty($this->category_id)) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_EMPTY_CATEGORY_ERROR')); return false; } // Filter / strip contents that are not allowed $filterTags = EasyBlogHelper::getHelper('Acl')->getFilterTags(); $filterAttributes = EasyBlogHelper::getHelper('Acl')->getFilterAttributes(); // @rule: Apply filtering on contents jimport('joomla.filter.filterinput'); $inputFilter = JFilterInput::getInstance($filterTags, $filterAttributes, 1, 1, 0); $inputFilter->tagBlacklist = $filterTags; $inputFilter->attrBlacklist = $filterAttributes; if (count($filterTags) > 0 && !empty($filterTags[0]) || count($filterAttributes) > 0 && !empty($filterAttributes[0])) { $this->intro = $inputFilter->clean($this->intro); $this->content = $inputFilter->clean($this->content); } // @rule: Process badword filters for content here. $blockedWord = EasyBlogHelper::getHelper('String')->hasBlockedWords($this->intro . $this->content); if ($blockedWord !== false) { $this->setError(JText::sprintf('COM_EASYBLOG_BLOG_POST_CONTAIN_BLOCKED_WORDS', $blockedWord)); return false; } // @rule: Test for the empty-ness if (empty($this->intro) && empty($this->content)) { $this->setError(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_CONTENT_ERROR')); } // alway set this to false no matter what! TODO: remove this column. $this->ispending = '0'; $state = parent::store(); $source = JRequest::getVar('blog_contribute_source', 'easyblog'); // @trigger: onBeforeSave $this->triggerAfterSave(); // if this is blog edit, then we should see the column isnew to determine // whether the post is really new or not. if (!$isNew) { $isNew = $this->isnew; } // @task: If auto featured is enabled, we need to feature the blog post automatically since the blogger is featured. if ($config->get('main_autofeatured', 0) && EasyBlogHelper::isFeatured('blogger', $this->created_by) && !EasyBlogHelper::isFeatured('post', $this->id)) { EasyBlogHelper::makeFeatured('post', $this->id); } // @task: This is when the blog is either created or updated. if ($source == 'easyblog' && $state && $this->published == POST_ID_PUBLISHED && $log) { // @rule: Add new stream item in jomsocial EasyBlogHelper::addJomSocialActivityBlog($this, $isNew); // @rule: Log new stream item into EasyBlog $activity = new stdClass(); $activity->actor_id = $this->created_by; $activity->target_id = '0'; $activity->context_type = 'post'; $activity->context_id = $this->id; $activity->verb = $isNew ? 'add' : 'update'; $activity->uuid = $this->title; EasyBlogHelper::activityLog($activity); } if ($source == 'easyblog' && $state && $this->published == POST_ID_PUBLISHED && $isNew && $log) { // @rule: Send email notifications out to subscribers. $author = EasyBlogHelper::getTable('Profile'); $author->load($this->created_by); // @rule: Ping pingomatic if ($config->get('main_pingomatic')) { if (!EasyBlogHelper::getHelper('Pingomatic')->ping($this->title, EasyBlogHelper::getExternalLink('index.php?option=com_easyblog&view=entry&id=' . $this->id, true))) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_SAVE_PINGOMATIC_ERROR'), 'error'); } } // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('blog.create', $this->created_by); // @rule: Add userpoints for jomsocial if ($config->get('main_jomsocial_userpoint')) { $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($path)) { require_once $path; CUserPoints::assignPoint('com_easyblog.blog.add', $this->created_by); } } $link = $this->getExternalBlogLink('index.php?option=com_easyblog&view=entry&id=' . $this->id); // @rule: Add notifications for jomsocial 2.6 if ($config->get('integrations_jomsocial_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('JomSocial')->addNotification(JText::sprintf('COM_EASYBLOG_JOMSOCIAL_NOTIFICATIONS_NEW_BLOG', $author->getName(), $link, $this->title), 'easyblog_new_blog', $target, $this->created_by, $link); } // @rule: Mighty Touch karma points EasyBlogHelper::getHelper('MightyTouch')->setKarma($this->created_by, 'new_blog'); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.blog', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_BLOG', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.blog', $this->created_by); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.blog', $this->created_by); // Assign badge for users that report blog post. // Only give points if the viewer is viewing another person's blog post. EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.create', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_CREATE_BLOG_POST')); if ($config->get('integrations_easydiscuss_notification_blog')) { // Get list of users who subscribed to this blog. $target = $this->getRegisteredSubscribers('new', array($this->created_by)); EasyBlogHelper::getHelper('EasyDiscuss')->addNotification($this, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_NOTIFICATIONS_NEW_BLOG', $author->getName(), $this->title), EBLOG_NOTIFICATIONS_TYPE_BLOG, $target, $this->created_by, $link); } $my = JFactory::getUser(); // @rule: Add points for AlphaUserPoints if ($my->id == $this->created_by && EasyBlogHelper::isAUPEnabled()) { // get blog post URL $url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $this->id); $aupid = AlphaUserPointsHelper::getAnyUserReferreID($this->created_by); AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_blog', $aupid, 'easyblog_add_blog_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_NEW_BLOG_CREATED', $url, $this->title)); } // @rule: Process trackbacks $this->processTrackbacks(); // Update the isnew column so that if user edits this entry again, it doesn't send any notifications the second time. $this->isnew = 0; $this->store(false); } return $state; }
public function reader2author($authorid = 0, $author = '', $articleid = 0, $title = '', $url = '') { $app = JFactory::getApplication(); require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (!$authorid || !$articleid) { return; } // get referrerid of author $referrerUserAuthor = AlphaUserPointsHelper::getAnyUserReferreID($authorid); if (!AlphaUserPointsHelper::checkExcludeUsers($referrerUserAuthor)) { return; } $ip = getenv('REMOTE_ADDR'); $db = JFactory::getDBO(); $keyreference = $articleid . "|" . $ip; $keyreference = AlphaUserPointsHelper::buildKeyreference('sysplgaup_reader2author', $keyreference); // check if not already view by active user $query = "SELECT `id` FROM #__alpha_userpoints_details WHERE `keyreference`='" . $keyreference . "'"; $db->setQuery($query); $alreadyView = $db->loadResult(); if (!$alreadyView) { $user = JFactory::getUser(); $jnow = JFactory::getDate(); $now = $jnow->toSql(); $authorizedLevels = JAccess::getAuthorisedViewLevels($user->id); $query = "SELECT * FROM #__alpha_userpoints_rules WHERE `plugin_function`='sysplgaup_reader2author' AND `published`='1' AND `access` IN (" . implode(",", $authorizedLevels) . ") AND (`rule_expire`>'{$now}' OR `rule_expire`='0000-00-00 00:00:00')"; $db->setQuery($query); $result = $db->loadObjectList(); if ($result && $referrerUserAuthor) { $datareference = '<a href="' . $url . '">' . $title . '</a> (' . $author . ')'; AlphaUserPointsHelper::insertUserPoints($referrerUserAuthor, $result[0], 0, $keyreference, $datareference); } } }
function remove() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('comment'); $comments = JRequest::getVar('cid', '', 'POST'); $message = ''; $type = 'message'; if (empty($comments)) { $message = JText::_('Invalid comment id'); $type = 'error'; } else { $table = EasyBlogHelper::getTable('Comment', 'Table'); foreach ($comments as $comment) { $table->load($comment); // AlphaUserPoints // since 1.2 if (!empty($table->created_by) && EasyBlogHelper::isAUPEnabled()) { $aupid = AlphaUserPointsHelper::getAnyUserReferreID($table->created_by); AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_comment', $aupid, '', JText::_('COM_EASYBLOG_AUP_COMMENT_DELETED')); } if (!$table->delete()) { $message = JText::_('COM_EASYBLOG_COMMENTS_COMMENT_REMOVE_ERROR'); $type = 'error'; $this->setRedirect('index.php?option=com_easyblog&view=comments', $message, $type); return; } $message = JText::_('COM_EASYBLOG_COMMENTS_COMMENT_REMOVED'); } } $this->setRedirect('index.php?option=com_easyblog&view=comments', $message, $type); }
function refundDeal($user_id, $point) { $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; require_once $api_AUP; $aupid = AlphaUserPointsHelper::getAnyUserReferreID($user_id); if ($aupid) { AlphaUserPointsHelper::newpoints('plgaup_com_enmasse_refund_by_point', $aupid, '', '', $point); } }
public function assignPoints($cmd, $userId, $message) { if (!$this->enabled()) { return false; } // Get the user id $userId = AlphaUserPointsHelper::getAnyUserReferreID($userId); $state = AlphaUserPointsHelper::newpoints($cmd, $userId, '', $message); return $state; }
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; } } } } } }
public function getProfileURL($user, $task = '', $xhtml = true) { if ($user == 0) return false; $user = KunenaFactory::getUser ( $user ); $my = JFactory::getUser (); if ($user === false) return false; $userid = $my->id != $user->userid ? '&userid=' . AlphaUserPointsHelper::getAnyUserReferreID ( $user->userid ) : ''; $AUP_itemid = AlphaUserPointsHelper::getItemidAupProfil (); return JRoute::_ ( 'index.php?option=com_alphauserpoints&view=account' . $userid . '&Itemid=' . $AUP_itemid, $xhtml ); }
function onAfterVote($poll, $option_id) { $user =& JFactory::getUser(); $aup = JPATH_SITE . '/components/com_alphauserpoints/helper.php'; if ($this->params->get('points', '0') == '1' && file_exists($aup)) { require_once $aup; $aup_id = AlphaUserPointsHelper::getAnyUserReferreID($user->id); if ($aup_id) { AlphaUserPointsHelper::newpoints('sysplgaup_votepoll', $aup_id, '', JText::_('COM_MIJOPOLLS_CAST_VOTE_AUP') . ' ' . $poll->id, $this->params->get('points_value', '0'), true); } } }
public function assign($rule, $userId, $title) { if (!$this->exists || !isset($this->rules[$rule])) { return false; } JFactory::getLanguage()->load('com_easydiscuss', JPATH_ROOT); // TODO: Fixed strict standard issue. $aup = new AlphaUserPointsHelper(); $id = $aup->getAnyUserReferreID($userId); //$id = AlphaUserPointsHelper::getAnyUserReferreID( $userId ); $rule = $this->rules[$rule]; $aup->newpoints('plgaup_easydiscuss_' . strtolower($rule), $id, '', JText::sprintf('COM_EASYDISCUSS_AUP_' . strtoupper($rule), $title)); }
public function getProfileURL($user, $task = '', $xhtml = true) { if ($user == 0) return false; $user = KunenaFactory::getUser ( $user ); $my = JFactory::getUser (); if ($user === false) return false; $userid = $my->id != $user->userid ? '&userid=' . AlphaUserPointsHelper::getAnyUserReferreID ( $user->userid ) : ''; if (method_exists ( 'AlphaUserPointsHelper', 'getItemidAupProfil' )) { $AUP_itemid = AlphaUserPointsHelper::getItemidAupProfil (); } else { $db = JFactory::getDBO (); $query = "SELECT id FROM #__menu WHERE link='index.php?option=com_alphauserpoints&view=account' AND type='component' AND published='1'"; $db->setQuery ( $query ); $AUP_itemid = intval ( $db->loadResult () ); } return JRoute::_ ( 'index.php?option=com_alphauserpoints&view=account' . $userid . '&Itemid=' . $AUP_itemid, $xhtml ); }
public function vote($value, $uid, $type, $elementId) { $ajax = new Ejax(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $blog = EasyBlogHelper::getTable('Blog', 'Table'); $blog->load($uid); if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) { if (!EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) { echo 'Invalid Access.'; exit; } } $rating = EasyBlogHelper::getTable('Ratings', 'Table'); // Do not allow guest to vote, or if the voter already voted. if ($rating->fill($my->id, $uid, $type, JFactory::getSession()->getId()) || $my->id < 1 && !$config->get('main_ratings_guests')) { // We wouldn't allow user to vote more than once so don't do anything here $ajax->send(); } $rating->set('created_by', $my->id); $rating->set('type', $type); $rating->set('uid', $uid); $rating->set('ip', @$_SERVER['REMOTE_ADDR']); $rating->set('value', (int) $value); $rating->set('sessionid', JFactory::getSession()->getId()); $rating->set('created', EasyBlogHelper::getDate()->toMySQL()); $rating->set('published', 1); $rating->store(); $model = EasyBlogHelper::getModel('Ratings'); $ratingValue = $model->getRatingValues($uid, $type); $total = $ratingValue->total; $rating = $ratingValue->ratings; // Assign badge for users that report blog post. // Only give points if the viewer is viewing another person's blog post. EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.rate', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_RATED_BLOG')); $ajax->script('eblog.loader.doneLoading("' . $elementId . '-command .ratings-text")'); $ajax->script('eblog.ratings.update("' . $elementId . '", "' . $type . '" , "' . $rating . '" , "' . JText::_('COM_EASYBLOG_RATINGS_RATED_THANK_YOU') . '");'); $ajax->assign($elementId . ' .ratings-value', '<i></i>' . $total . '<b>√</b>'); if (EasyBlogHelper::isAUPEnabled()) { $id = AlphaUserPointsHelper::getAnyUserReferreID($my->id); AlphaUserPointsHelper::newpoints('plgaup_easyblog_rate_blog', $id, '', JText::sprintf('COM_EASYBLOG_AUP_BLOG_RATED'), ''); } $ajax->send(); }
public function onAfterThankyou($actor, $target, $message) { $infoTargetUser = JText::_('COM_KUNENA_THANKYOU_GOT_FROM').': ' . KunenaFactory::getUser($actor)->username; $infoRootUser = JText::_('COM_KUNENA_THANKYOU_SAID_TO').': ' . KunenaFactory::getUser($target)->username; if ($this->_checkPermissions($message)) { $aupactor = AlphaUserPointsHelper::getAnyUserReferreID($actor); $auptarget = AlphaUserPointsHelper::getAnyUserReferreID($target); $ruleName = 'plgaup_kunena_message_thankyou'; $usertargetpoints = intval($this->_getPointsOnThankyou($ruleName)); if ( $usertargetpoints && $this->_checkRuleEnabled($ruleName) ) { // for target user if ($auptarget) AlphaUserPointsHelper::newpoints($ruleName , $auptarget, '', $infoTargetUser, $usertargetpoints); // for who has gived the thank you if ($aupactor) AlphaUserPointsHelper::newpoints($ruleName , $aupactor, '', $infoRootUser ); } } }
/** * Run right at the end of the form processing * form needs to be set to record in database for this to hook to be called * * @throws Exception * * @return bool */ public function onAfterProcess() { $params = $this->getParams(); $api_AUP = JPATH_SITE . '/components/com_alphauserpoints/helper.php'; if (JFile::exists($api_AUP)) { $w = new FabrikWorker(); $this->data = $this->getProcessData(); require_once $api_AUP; $aup = new AlphaUserPointsHelper(); // Define which user will receive the points. $userId = $params->get('user_id', ''); $userId = (int) $w->parseMessageForPlaceholder($userId, $this->data, false); $aupId = $aup->getAnyUserReferreID($userId); // Replace these if you want to show a specific reference for the attributed points - doesn't seem to effect anything $keyReference = ''; // Shown in the user details page - description of what the point is for $dataReference = $params->get('data_reference', ''); $dataReference = $w->parseMessageForPlaceholder($dataReference, $this->data, false); // Override the plugin default points $randomPoints = $params->get('random_points', 0); if ($params->get('random_points_eval', '0') == '1') { if (!empty($randomPoints)) { $randomPoints = $w->parseMessageForPlaceholder($randomPoints, $this->data, false); $randomPoints = @eval($randomPoints); FabrikWorker::logEval($randomPoints, 'Caught exception on eval in aup plugin : %s'); } $randomPoints = (double) $randomPoints; } else { $randomPoints = (double) $w->parseMessageForPlaceholder($randomPoints, $this->data, false); } // If set to be greater than $randompoints then this is the # of points assigned (not sure when this would be used - commenting out for now) $referralUserPoints = 0; $aupPlugin = $params->get('aup_plugin', 'plgaup_fabrik'); $aupPlugin = $w->parseMessageForPlaceholder($aupPlugin, $this->data, false); if (!$aup->checkRuleEnabled($aupPlugin, 0, $aupId)) { throw new Exception('Alpha User Points plugin not published'); } $aup->userpoints($aupPlugin, $aupId, $referralUserPoints, $keyReference, $dataReference, $randomPoints); } }
public static function addAUP($plugin_function = '', $referrerid = '', $keyreference = '', $datareference = '') { $my = JFactory::getUser(); if (!empty($referrerid)) { $my = JFactory::getUser($referrerid); } if ($my->id != 0) { $aup = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_alphauserpoints' . DIRECTORY_SEPARATOR . 'helper.php'; if (JFile::exists($aup)) { require_once $aup; AlphaUserPointsHelper::newpoints($plugin_function, AlphaUserPointsHelper::getAnyUserReferreID($referrerid), $keyreference, $datareference); } } }
/** * Assign points to the file uploader when a user download his file and use the price field * * @param mixed $files */ public static function setAUPPointsDownloaderToUploaderPrice($files) { $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP)) { require_once $api_AUP; foreach ($files as $file) { if ($file->submitted_by) { $referreid = AlphaUserPointsHelper::getAnyUserReferreID((int) $file->submitted_by); if ($referreid) { $key_reference = AlphaUserPointsHelper::buildKeyreference('plgaup_jdownloads_downloader_to_uploader_use_price', $file->file_id, (int) $file->submitted_by); $rule_id = AlphaUserPointsHelper::getRuleID('plgaup_jdownloads_downloader_to_uploader_use_price'); $check_aup_reference = AlphaUserPointsHelper::checkReference($referreid, $key_reference, $rule_id); // check the method when a prior download process is found if ($check_aup_reference > 0) { $method = (int) AlphaUserPointsHelper::getMethod('plgaup_jdownloads_downloader_to_uploader_use_price'); switch ($method) { case 1: // ONCE PER USER // has already payed return; break; case '2': // ONCE PER DAY AND PER USER' return; break; case '3': // ONCE A DAY FOR A SINGLE USER ON ALL USERS return; break; case '5': // ONCE PER USER PER WEEK return; break; case '6': // ONCE PER USER PER MONTH return; break; case '7': // ONCE PER USER PER YEAR return; break; /* case '4': // WHENEVER case '0': default: // points must be payed always */ } } $text = JText::_('COM_JDOWNLOADS_BACKEND_SET_AUP_DOWNLOAD_TEXT'); $text = sprintf($text, $file->file_title); $price = floatval($file->price); AlphaUserPointsHelper::newpoints('plgaup_jdownloads_downloader_to_uploader_use_price', $referreid, $key_reference, $text, '+' . $price, $text); } } } } }
/** * 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; } }
public function delete($cid = null) { $state = parent::delete($cid); $my = JFactory::getUser(); // @rule: Remove comment's stream $this->removeStream(); if ($this->created_by != 0 && $this->published == '1') { $blog = EasyBlogHelper::getTable('Blog'); $blog->load($this->post_id); JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.delete.comment', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_COMMENT', $blog->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.delete.comment', $this->created_by); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.delete.comment', $this->created_by); // @since 1.2 // AlphaUserPoints if (EasyBlogHelper::isAUPEnabled()) { AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_comment', AlphaUserPointsHelper::getAnyUserReferreID($this->created_by), '', JText::_('COM_EASYBLOG_AUP_COMMENT_DELETED')); // @rule: Add comment for blog author if ($blog->created_by != $this->created_by) { AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_comment_blogger', AlphaUserPointsHelper::getAnyUserReferreID($blog->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_COMMENT_DELETED_BLOGGER', $url, $blog->title)); } } // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('comments.remove', $this->created_by); // @rule: Deduct points from the comment author EasyBlogHelper::addJomsocialPoint('com_easyblog.comments.remove', $this->created_by); // @rule: Give points to the blog author if ($my->id != $blog->created_by) { // Assign EasySocial points $easysocial->assignPoints('comments.remove.author', $blog->created_by); EasyBlogHelper::addJomsocialPoint('com_easyblog.comments.removeblogger', $blog->created_by); } } return $state; }
public static function updateUserPoints($result, $referrerid, $assignpoints, $now, $referraluserpoints, $autoapproved, $rule_plugin = '', $rule_id = '', $rule_name = '', $datareference = '', $frontmessage = '') { $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); $lang->load('com_alphauserpoints', JPATH_SITE); $user = JFactory::getUser(); $username = $user->id ? $user->username : ''; $displaymsg = $result->displaymsg; $msg = str_replace('{username}', $username, $result->msg); $method = $result->method; $db = JFactory::getDBO(); // get params definitions $params = JComponentHelper::getParams('com_alphauserpoints'); $query = "SELECT id FROM #__alpha_userpoints WHERE `referreid`='{$referrerid}'"; $db->setQuery($query); $referrerUser = $db->loadResult(); JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'tables'); $row = JTable::getInstance('userspoints'); // update points into alpha_userpoints table $row->load(intval($referrerUser)); $referraluser = $row->referraluser; $newtotal = !$referraluserpoints ? $row->points + $assignpoints : $row->points + $referraluserpoints; $row->last_update = $now; $checkWinner = 0; if ($row->max_points >= 1 && $newtotal > $row->max_points) { // Max total was reached ! //$newtotal = $row->max_points; if (AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_winnernotification', 0, $referrerid)) { // get email admins in rule $query = "SELECT `content_items` FROM #__alpha_userpoints_rules WHERE `plugin_function`='sysplgaup_winnernotification'"; $db->setQuery($query); $emailadmins = $db->loadResult(); if ($autoapproved || $referraluserpoints) { AlphaUserPointsHelper::sendwinnernotification($referrerid, $assignpoints, $newtotal, $emailadmins); // Uddeim notification integration if ($params->get('sendMsgUddeim', 0)) { AlphaUserPointsHelper::sendUddeimWinnerNotification($referrerid, $assignpoints, $newtotal); } $checkWinner = 1; } } } if ($autoapproved) { if ($rule_plugin == 'sysplgaup_invitewithsuccess') { $row->referrees = $row->referrees + 1; } $row->points = $newtotal; $db->updateObject('#__alpha_userpoints', $row, 'id'); } if ($displaymsg && !$referraluserpoints) { $realcurrentreferrerid = AlphaUserPointsHelper::getAnyUserReferreID($user->id); switch ($rule_plugin) { case 'sysplgaup_bonuspoints': case 'sysplgaup_recommend': case 'sysplgaup_reader2author': case 'sysplgaup_buypointswithpaypal': case 'sysplgaup_invite': // No need congratulation... break; case 'sysplgaup_invitewithsuccess': // number points in message = assign points to new user $numpoints = AlphaUserPointsHelper::getPointsRule('sysplgaup_newregistered'); if ($numpoints && $user->id) { if ($msg != '') { $msg = str_replace('{points}', AlphaUserPointsHelper::getFPoints($numpoints), JText::_($msg)); $msg = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $msg); $app->enqueueMessage($msg); } else { $app->enqueueMessage(sprintf(JText::_('AUP_CONGRATULATION'), AlphaUserPointsHelper::getFPoints($numpoints))); } } break; default: if ($referrerid == $realcurrentreferrerid && $user->id) { if ($assignpoints > 0) { if ($msg != '') { $msg = str_replace('{points}', AlphaUserPointsHelper::getFPoints($assignpoints), JText::_($msg)); $msg = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $msg); $app->enqueueMessage($msg); } else { $app->enqueueMessage(sprintf(JText::_('AUP_CONGRATULATION'), AlphaUserPointsHelper::getFPoints($assignpoints))); if ($rule_plugin == 'sysplgaup_happybirthday') { $frontmessage = JText::_('AUP_HAPPYBIRTHDAY'); } } } elseif ($assignpoints < 0) { if ($msg != '') { $msg = str_replace('{points}', AlphaUserPointsHelper::getFPoints(abs($assignpoints)), JText::_($msg)); $msg = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $msg); $app->enqueueMessage($msg); } else { $app->enqueueMessage(sprintf(JText::_('AUP_X_POINTS_HAS_BEEN_DEDUCTED_FROM_YOUR_ACCOUNT'), AlphaUserPointsHelper::getFPoints(abs($assignpoints)))); } } } } } if ($rule_plugin == 'sysplgaup_custom' && $datareference) { $rule_name = JText::_($datareference); } // email notification if ($result->notification && !$checkWinner) { $result->datareference = JText::_($datareference); AlphaUserPointsHelper::sendnotification($referrerid, $assignpoints, $newtotal, $result); // load external plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('alphauserpoints'); $results = $dispatcher->trigger('onSendNotificationAlphaUserPoints', array(&$result, $rule_name, $assignpoints, $newtotal, $referrerid, $user->id)); } // Uddeim notification integration if ($params->get('sendMsgUddeim', 0) && !$checkWinner) { AlphaUserPointsHelper::sendUddeimNotification($referrerid, $assignpoints, $newtotal, $rule_name); } // load external plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('alphauserpoints'); $results = $dispatcher->trigger('onUpdateAlphaUserPoints', array(&$result, $rule_name, $assignpoints, $referrerid, $user->id)); // checking rank and medals and update if necessary if ($rule_id == '') { $rule_id = AlphaUserPointsHelper::getRuleID($rule_plugin); } AlphaUserPointsHelper::checkRankMedal($referrerid, $rule_id); // referral points rule if ($referraluser != '' && $rule_plugin != 'sysplgaup_buypointswithpaypal' && $rule_plugin != 'sysplgaup_raffle' && $assignpoints > 0) { // if not already assigned $query = "SELECT * FROM #__alpha_userpoints_rules WHERE `plugin_function`='sysplgaup_referralpoints' AND `published`='1' AND (`rule_expire`>'{$now}' OR `rule_expire`='0000-00-00 00:00:00')"; $db->setQuery($query); $referralpoints = $db->loadObjectList(); if ($referralpoints) { $referraluserpoints = round($assignpoints * $referralpoints[0]->points / 100, 2); if ($referraluserpoints > 0) { AlphaUserPointsHelper::userpoints('sysplgaup_referralpoints', $referraluser, $referraluserpoints); } } } // check change user group rule //if ( $rule_plugin!='sysplgaup_changelevel1' && $rule_plugin!='sysplgaup_changelevel2' && $rule_plugin!='sysplgaup_changelevel3' ) //{ AlphaUserPointsHelper::checkChangeLevel($referrerid, AlphaUserPointsHelper::getCurrentTotalPoints($referrerid)); //} if ($frontmessage != '') { AlphaUserPointsHelper::displayMessageSystem($frontmessage); } // load external plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('alphauserpoints'); $results = $dispatcher->trigger('onAfterUpdateAlphaUserPoints', array(&$result, $rule_name, $assignpoints, $referrerid, $user->id)); // link up rule if ($result->linkup) { $plugin_function_linkup = AlphaUserPointsHelper::getPluginFunction($result->linkup); AlphaUserPointsHelper::newpoints($plugin_function_linkup, $referrerid); } }
public function onAfterThankyou($target, $actor, $message) { $infoTargetUser = (JText::_ ( 'COM_KUNENA_THANKYOU_GOT' ).': ' . KunenaFactory::getUser($target)->username ); $infoRootUser = ( JText::_ ( 'COM_KUNENA_THANKYOU_SAID' ).': ' . KunenaFactory::getUser($actor)->username ); $category = $message->getCategory(); if ($category->pub_access == 0 || $category->pub_access == - 1) { $auptarget = AlphaUserPointsHelper::getAnyUserReferreID( $target ); $aupactor = AlphaUserPointsHelper::getAnyUserReferreID( $actor ); if ( $this->_getAUPversion() < '1.5.12' ) { $ruleName = 'plgaup_thankyou_kunena'; $ruleEnabled = AlphaUserPointsHelper::checkRuleEnabled( $ruleName ); $usertargetpoints = intval($ruleEnabled[0]->content_items); } elseif ( $this->_getAUPversion() >= '1.5.12' ) { $ruleName = 'plgaup_kunena_message_thankyou'; $ruleEnabled = AlphaUserPointsHelper::checkRuleEnabled( $ruleName ); $usertargetpoints = intval($ruleEnabled[0]->content_items); } else { return; } if ( $usertargetpoints && $ruleEnabled ) { // for target user if ($auptarget) AlphaUserPointsHelper::newpoints($ruleName , $auptarget, '', $infoTargetUser, $usertargetpoints); // for who has gived the thank you if ($aupactor) AlphaUserPointsHelper::newpoints($ruleName , $aupactor, '', $infoRootUser ); } } }
function addPoints($points, $order, $data = null, $forceMode = null) { if (empty($this->plugin_params) && $forceMode === null) { return false; } if ($points === 0) { return true; } $points_mode = @$this->plugin_params->points_mode; if ($forceMode !== null) { $points_mode = $forceMode; } if ($points_mode == 'aup') { if (empty($order->customer)) { $userClass = hikashop_get('class.user'); $order->customer = $userClass->get($order->order_user_id); } if ($this->getAUP(true)) { if ($data === null) { $data = $this->getDataReference($order); } $aupid = AlphaUserPointsHelper::getAnyUserReferreID($order->customer->user_cms_id); AlphaUserPointsHelper::newpoints('plgaup_orderValidation', $aupid, '', $data, $points); return true; } return false; } $ret = true; $userClass = hikashop_get('class.user'); $oldUser = $userClass->get($order->order_user_id); if (!isset($oldUser->user_points) && !in_array('user_points', array_keys(get_object_vars($oldUser)))) { return false; } if (empty($oldUser->user_points)) { $oldUser->user_points = 0; } $user = new stdClass(); $user->user_id = $oldUser->user_id; $user->user_points = (int) $oldUser->user_points + $points; if ($user->user_points < 0) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('HIKAPOINTS_USE_X_POINTS', -$points), 'error'); $points = -$oldUser->user_points; $user->user_points = 0; $ret = false; } $userClass->save($user); $app = JFactory::getApplication(); if (!$app->isAdmin() && $points !== 0) { $user = hikashop_loadUser(true); if ($user->user_id == $order->order_user_id) { if ($points < 0) { $app->enqueueMessage(JText::sprintf('HIKAPOINTS_USE_X_POINTS', -$points)); } else { $app->enqueueMessage(JText::sprintf('HIKAPOINTS_EARN_X_POINTS', $points)); } } } return $ret; }
$added = $sum == 0 ? 0 : $count + 1; // if it is an array i.e. already has entries the push in another value $useridstring = "uid" . $userid . ";"; is_array($checkIP) ? array_push($checkIP, $ip_num, $useridstring) : ($checkIP = array($ip_num, $useridstring)); $insertip = serialize($checkIP); $user_registered = $userid > 0 ? " OR used_ips LIKE '%uid" . $userid . ";%'" : ""; //IP check when voting $query = "SELECT used_ips FROM #__alpha_rating WHERE ( used_ips LIKE '%" . $ip_num . "%'" . $user_registered . " ) AND id='" . $id_sent . "' AND component='" . $component . "' AND cid='" . $cid . "' AND rid='" . $rid . "'"; $db->setQuery($query); $voted = $db->loadResult(); if (!$voted) { //if the user hasn't yet voted, then vote normally... if ($vote_sent >= 1 && $vote_sent <= $units) { // keep votes within range $query = "UPDATE #__alpha_rating SET total_votes='" . $added . "', total_value='" . $sum . "', used_ips='" . $insertip . "', component='" . $component . "' WHERE id='" . $id_sent . "' AND component='" . $component . "' AND cid='" . $cid . "' AND rid='" . $rid . "'"; $db->setQuery($query); $db->query(); } // Add rule for AlphaUserPoints component $api_AUP = JPATH_BASE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP) && $userid > 0) { require_once $api_AUP; $referreid = AlphaUserPointsHelper::getAnyUserReferreID($userid); $keyreference = $id_sent . $component . $cid . $rid; AlphaUserPointsHelper::newpoints('plgaup_voting_ac', $referreid, $keyreference); } header("Location: {$referer}"); // go back to the page we came from exit; } //end for the "if(!$voted)"
function process() { global $database, $jTips, $mosConfig_absolute_path; $this->clearHistory(); $params = array('round_id' => $this->id); $jSeason = new jSeason($database); $jSeason->load($this->season_id); $jGame = new jGame($database); $jGames = forceArray($jGame->loadByParams($params)); $params = array('season_id' => $this->season_id); $jTipsUser = new jTipsUser($database); $jTipsUsers = forceArray($jTipsUser->loadByParams($params)); $noTips = $scores = $worst_precision = array(); $played = count($jGames); foreach ($jTipsUsers as $jTipsUser) { jTipsLogger::_log("Processing scores for user " . $jTipsUser->id); $score = $matching = $precision = $allAwayScore = 0; if ($jTipsUser->hasTipped($this->id)) { jTipsLogger::_log($jTipsUser->id . " has tipped in round " . $this->id); foreach ($jGames as $jGame) { jTipsLogger::_log("Processing game " . $jGame->id); $params = array('user_id' => $jTipsUser->id, 'game_id' => $jGame->id); $jTip = new jTip($database); $jTip->loadByParams($params); // make sure this is not a bye game if (!$jGame->home_id or !$jGame->away_id or !$jGame->winner_id) { jTipsLogger::_log('attempting to process tips on a bye game, skipping', 'INFO'); continue; } /* * Feature Request 101 - Team Starts * Determine the winner when we take the starts into account * We only care about the starts for picking the winner/draw * For picking the margins and scores, use the actual winner */ if ($jSeason->team_starts) { jTipsLogger::_log('processing team starts'); $homeScore = $awayScore = 0; $homeScore = $jGame->home_score + ($jGame->home_start + 0); $awayScore = $jGame->away_score + ($jGame->away_start + 0); if ($homeScore > $awayScore) { $winnerID = $jGame->home_id; } else { if ($homeScore < $awayScore) { $winnerID = $jGame->away_id; } else { if ($homeScore == $awayScore) { $winnerID = -1; } } } jTipsLogger::_log('feature 101: With starts, the winner is ' . $winnerID . ', otherwise the winner is ' . $jGame->winner_id . " HOME {$homeScore} v AWAY {$awayScore}"); } else { $winnerID = $jGame->winner_id; } if ($jTip->tip_id == $winnerID) { //User tipped right! jTipsLogger::_log("CORRECT TIP by " . $jTipsUser->id . " in round_id " . $this->id . " in game_id " . $jGame->id); //BUG 248 - Add ToughScore if enabled if ($jSeason->tough_score and $jGame->tough_score) { $score += $jGame->tough_score; } if ($winnerID == -1) { $score += isset($jSeason->user_draw) ? $jSeason->user_draw : 0; jTipsLogger::_log("Draw correctly picked!"); } else { $score += isset($jSeason->user_correct) ? $jSeason->user_correct : 0; } $matching++; } if ($winnerID == $jGame->away_id) { $allAwayScore += $jSeason->user_correct; } //Check for correct margins and handle precision score gathering if ($jSeason->pick_margin == 1 and $jGame->has_margin == 1) { $margin = abs($jGame->home_score - $jGame->away_score); if ($jTip->margin == $margin) { $score += isset($jSeason->user_pick_margin) ? $jSeason->user_pick_margin : 0; jTipsLogger::_log("correct margin picked!"); } if ($jSeason->precision_score == 1) { if ($jGame->winner_id == $jTip->tip_id) { $margin_offset = abs($margin - $jTip->margin); } else { $margin_offset = abs($margin + $jTip->margin); } if (isset($worst_precision[$jGame->id]) && $margin_offset > $worst_precision[$jGame->id] || empty($worst_precision[$jGame->id])) { $worst_precision[$jGame->id] = $margin_offset; } $precision += $margin_offset; jTipsLogger::_log("PICK_MARGIN: Adding {$margin_offset} to precision of {$precision}"); } } //Check for correct scores and handle precision score gathering if ($jSeason->pick_score == 1 and $jGame->has_score == 1) { $margin = abs($jGame->home_score - $jGame->away_score); if ($jTip->home_score == $jGame->home_score and $jTip->away_score == $jGame->away_score) { $score += isset($jSeason->user_pick_score) ? $jSeason->user_pick_score : 0; jTipsLogger::_log("Correct scores picked!"); } if ($jSeason->precision_score == 1) { $pickedScoreMargin = abs($jTip->home_score - $jTips->away_score); if ($jGame->winner_id == $jTip->tip_id) { $score_offset = abs($margin - $pickedScoreMargin); } else { $score_offset = abs($margin + $pickedScoreMargin); } if (isset($worst_precision[$jGame->id]) and $score_offset > $worst_precision[$jGame->id] or empty($worst_precision[$jGame->id])) { $worst_precision[$jGame->id] = $score_offset; } $precision += $score_offset; jTipsLogger::_log("PICK_SCORE: Adding {$score_offset} to precision of {$precision}"); jTipsLogger::_log("PREC DEBUG: {$jTipsUser->id}-{$jTipsUser->user_id} Picked Margin: {$pickedScoreMargin}. Actual Margin: {$margin}. Applied Precision: {$score_offset}. Running Precision: {$precision}", 'INFO'); } } //Check for a bonus team selection if ($jSeason->pick_bonus >= 1 and $jGame->has_bonus == 1) { if ($jTip->bonus_id == $jGame->bonus_id && $jGame->bonus_id != -1) { $score += isset($jSeason->user_pick_bonus) ? $jSeason->user_pick_bonus : 0; } } } //was a perfect round picked? if ($matching == $played) { $score += isset($jSeason->user_bonus) ? $jSeason->user_bonus : 0; } //did the user use their 'doubleup' if ($jTipsUser->doubleup == $this->id and $jTips['DoubleUp'] == 1) { $score = $score * 2; } $scores[] = $score; //Save the data to the history object $jHistory = new jHistory($database); $jHistory->user_id = $jTipsUser->id; $jHistory->round_id = $this->id; jTipsLogger::_log("Score for user_id " . $jTipsUser->id . " in round_id " . $this->id . " is {$score}"); $jHistory->points = $score; //Update rank after all users have been saved $jHistory->outof = count($jTipsUsers); //$jHistory->comment = $jTipsUser->comment; if ($jSeason->precision_score == 1) { jTipsLogger::_log("setting precision to {$precision} for user_id " . $jTipsUser->id . " in round_id " . $this->id); $jHistory->precision = $precision; } else { $jHistory->precision = 0; } if ($jHistory->save() !== false) { $results[] = 1; } else { jTipsLogger::_log("Error saving history: " . $jHistory->_error); $results[] = 0; } //remove the current comment $jTipsUser->comment = null; $jTipsUser->save(); // Check if the AlphaUserPoints config option is set if (isJoomla15()) { $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; } else { $api_AUP = $mosConfig_absolute_path . 'components/com_alphauserpoints/helper.php'; } if (!$this->scored and $jTips['AlphaUserPoints'] and jTipsFileExists($api_AUP)) { require_once $api_AUP; jTipsLogger::_log('sending ' . $score . ' points for user ' . $jTipsUser->user_id, 'INFO'); $refID = AlphaUserPointsHelper::getAnyUserReferreID($jTipsUser->user_id); AlphaUserPointsHelper::newpoints('plgaup_jtips_total_points', $refID, '', '', $score); } if (!$this->scored and $jTips['JomSocialActivities'] and $jTips['JomSocialUserResults']) { global $mosConfig_absolute_path; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/utils/jTipsJomSocial.php'; jTipsJomSocial::writeRoundResult($jSeason, $this, $jTipsUser->user_id, $score); } } else { $noTips[] = $jTipsUser; } } if (count($noTips) > 0) { ///////////////////////////////////////////////// // Feature Request 71 // Allow users that did not to be assigned // all the away teams // /*if ($jSeason->user_none != -1) { $thisRound = $jSeason->user_none; } else if (is_array($scores) && count($scores) > 0) { $thisRound = min($scores); } else { $thisRound = 0; }*/ if ($jSeason->user_none == -2) { //handle all away teams $thisRound = $allAwayScore; jTipsLogger::_log("didn't tip? You'll be stuck with the away teams. You got {$thisRound}"); } else { if ($jSeason->user_none == -1) { //handle lowest possible score if (is_array($scores) and count($scores) > 0) { $thisRound = min($scores); jTipsLogger::_log("didn't tip? You'll be stuck with the lowest score this round, {$thisRound}"); } else { $thisRound = 0; jTipsLogger::_log("didn't tip? You'll be stuck {$thisRound}"); } } else { //handle allocated score $thisRound = $jSeason->user_none; jTipsLogger::_log("didn't tip? You're getting {$thisRound}"); } } // // END Feature Request 71 //////////////////////////////////////////////////// foreach ($noTips as $jTipsUser) { $jHistory = new jHistory($database); $jHistory->user_id = $jTipsUser->id; $jHistory->round_id = $this->id; $jHistory->points = $thisRound; $jHistory->precision = array_sum($worst_precision); //$jHistory->outof = count($jTipsUsers); //$jHistory->comment = $jTipsUser->comment; if ($jHistory->save() !== false) { $results[] = 1; } else { $results[] = 0; } $jTipsUser->save(); // Check if the AlphaUserPoints config option is set if (isJoomla15()) { $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; } else { $api_AUP = $mosConfig_absolute_path . 'components/com_alphauserpoints/helper.php'; } if (!$this->scored and $jTips['AlphaUserPoints'] and jTipsFileExists($api_AUP)) { require_once $api_AUP; jTipsLogger::_log('sending ' . $score . ' points for user ' . $jTipsUser->user_id, 'INFO'); $refID = AlphaUserPointsHelper::getAnyUserReferreID($jTipsUser->user_id); AlphaUserPointsHelper::newpoints('plgaup_jtips_total_points', $refID, '', '', $thisRound); } if (!$this->scored and $jTips['JomSocialActivities']) { global $mosConfig_absolute_path; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/utils/jTipsJomSocial.php'; if ($jTips['JomSocialUserResults']) { jTipsJomSocial::writeRoundResult($jSeason, $this, $jTipsUser->user_id, $score); } if ($jTips['JomSocialOnNoTips']) { jTipsJomSocial::writeOnNoTips($jTipsUser->user_id, $jSeason, $this); } } } } $jHistory = new jHistory($database); $jHistory->setRanks($this->id, true); if (!$this->scored and $jTips['JomSocialActivities']) { // find out who won the round and write it to the JomSocial stream $winners = $this->getRoundWinners(); jTipsJomSocial::writeRoundWinners($winners, $this, $jSeason); } $this->scored = 1; $result = $this->save(); //if ($this->scored != 1) { jTeam::updateLadder($this, $jSeason); //} //$this->scored = 1; //return $this->save(); return $result; }
public function getAnyUserReferreID(JUser $user) { return $res = AlphaUserPointsHelper::getAnyUserReferreID($user->id); }
function GetProfileURL($userid) { $fbConfig =& CKunenaConfig::getInstance(); // Only create links for valid users if ($userid > 0) { if ($fbConfig->fb_profile == 'cb') { $kunenaProfile =& CKunenaCBProfile::getInstance(); return $kunenaProfile->getProfileURL($userid); } elseif ($fbConfig->fb_profile == 'jomsocial') { return CRoute::_('index.php?option=com_community&view=profile&userid=' . $userid); } elseif ($fbConfig->fb_profile == 'aup') { $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP)) { $useridAUP = AlphaUserPointsHelper::getAnyUserReferreID($userid); return JRoute::_(KUNENA_PROFILE_LINK_SUFFIX . $useridAUP); } } else { return JRoute::_(KUNENA_PROFILE_LINK_SUFFIX . $userid); } } return ''; }
function attribPoints() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $login = JFactory::getApplication()->input->get('login', '', 'username'); $coupon = JFactory::getApplication()->input->get('couponCode', '', 'string'); $trackID = JFactory::getApplication()->input->get('trackID', '', 'string'); $query = "SELECT id FROM #__alpha_userpoints_qrcodetrack WHERE `trackid`='" . $trackID . "'"; $db->setQuery($query); $idTrack = $db->loadResult(); $query = "SELECT id FROM #__users WHERE `username`='" . $login . "' AND `block`='0'"; $db->setQuery($query); $userID = $db->loadResult(); if ($userID) { // insert API AlphaUserPoint $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; require_once $api_AUP; $referrerid = AlphaUserPointsHelper::getAnyUserReferreID($userID); $nullDate = $db->getNullDate(); $date =& JFactory::getDate(); $now = $date->toSql(); $query = "SELECT * FROM #__alpha_userpoints_coupons WHERE `couponcode`='{$coupon}' AND (`expires`>='{$now}' OR `expires`='0000-00-00 00:00:00')"; $db->setQuery($query); $result = $db->loadObjectList(); if ($result) { $resultCouponExist = 0; // check if public or private coupon if (!$result[0]->public) { // private -> usable once per one user $query = "SELECT count(*) FROM #__alpha_userpoints_details WHERE `keyreference`='{$coupon}'"; $db->setQuery($query); $resultCouponExist = $db->loadResult(); if (!$resultCouponExist) { // insert points AlphaUserPointsHelper::newpoints('sysplgaup_couponpointscodes', $referrerid, $result[0]->couponcode, $result[0]->description, $result[0]->points); //if ( AlphaUserPointsHelper::newpoints( 'sysplgaup_couponpointscodes', $referrerid, $result[0]->couponcode, $result[0]->description, $result[0]->points, true )===true ){ // insert confirmed in track table $this->updateTableQRTrack($idTrack); return $result[0]->points; //} } else { $msg = JText::_('AUP_THIS_COUPON_WAS_ALREADY_USED'); JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $coupon . '&trackID=' . $trackID, $msg); JControllerLegacy::redirect(); } } elseif ($result[0]->public) { // public -> usable once per all users $keyreference = $coupon . "##" . $userID; $query = "SELECT count(*) FROM #__alpha_userpoints_details WHERE `keyreference`='{$keyreference}'"; $db->setQuery($query); $resultCouponExist = $db->loadResult(); if (!$resultCouponExist) { // insert points AlphaUserPointsHelper::newpoints('sysplgaup_couponpointscodes', $referrerid, $keyreference, $result[0]->description, $result[0]->points); //if ( AlphaUserPointsHelper::newpoints( 'sysplgaup_couponpointscodes', $referrerid, $keyreference, $result[0]->description, $result[0]->points, true )===true ){ // insert confirmed in track table $this->updateTableQRTrack($idTrack); return $result[0]->points; //} } else { $msg = JText::_('AUP_THIS_COUPON_WAS_ALREADY_USED'); JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $coupon . '&trackID=' . $trackID, $msg); JControllerLegacy::redirect(); } } } else { $msg = JText::_('AUP_COUPON_NOT_AVAILABLE'); JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $coupon . '&trackID=' . $trackID, $msg); JControllerLegacy::redirect(); } } else { // no username $msg = JText::_('ALERTNOTAUTH'); JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $coupon . '&trackID=' . $trackID, $msg); JControllerLegacy::redirect(); } }
function _plgReviewAfterSave(&$model) { $review = $this->_getReview($model); // Treat moderated reviews as new $this->inAdmin and Sanitize::getBool($model->data, 'moderation') and $model->isNew = true; if (isset($model->isNew) && $model->isNew && $review['Review']['published'] == 1) { // Begin add points $aupid = AlphaUserPointsHelper::getAnyUserReferreID($review['User']['user_id']); if ($aupid) { AlphaUserPointsHelper::newpoints('plgaup_jreviews_review_add', $aupid); } } }
public function onPurchase($args = null, $user = null, $status = null) { // Split up the arguments $args = explode(';', $args); $rule = $args[0]; $points = $args[1]; $sku = $args[2]; $aup = JPATH_SITE . '/components/com_alphauserpoints/helper.php'; if (file_exists($aup)) { require_once $aup; $aupid = AlphaUserPointsHelper::getAnyUserReferreID($user->id); if ($aupid) { AlphaUserPointsHelper::newpoints($rule, $aupid, $sku, null, $points); } } return true; }
/** * Overrides parent's delete method to add our own logic. * * @return boolean * @param object $db */ function delete($pk = null) { $db = $this->getDBO(); $config = EasyBlogHelper::getConfig(); $query = 'SELECT COUNT(1) FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_post') . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('category_id') . '=' . $db->Quote($this->id); $db->setQuery($query); $count = $db->loadResult(); if ($count > 0) { return false; } $my = JFactory::getUser(); if ($this->created_by != 0 && $this->created_by == $my->id) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.delete.category', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_CATEGORY', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.delete.category', $my->id); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.delete.category', $my->id); // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('category.remove', $this->created_by); if ($config->get('main_jomsocial_userpoint')) { $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($path)) { require_once $path; CUserPoints::assignPoint('com_easyblog.category.remove', $this->created_by); } } // @since 1.2 // AlphaUserPoints if (EasyBlogHelper::isAUPEnabled()) { AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_category', AlphaUserPointsHelper::getAnyUserReferreID($this->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_CATEGORY_DELETED', $this->title)); } } /* TODO */ //remove avatar if previously already uploaded. $avatar = $this->avatar; if ($avatar != 'cdefault.png' && !empty($avatar)) { $avatar_config_path = $config->get('main_categoryavatarpath'); $avatar_config_path = rtrim($avatar_config_path, '/'); $avatar_config_path = JString::str_ireplace('/', DIRECTORY_SEPARATOR, $avatar_config_path); $upload_path = JPATH_ROOT . DIRECTORY_SEPARATOR . $avatar_config_path; $target_file_path = $upload_path; $target_file = JPath::clean($target_file_path . DIRECTORY_SEPARATOR . $avatar); if (JFile::exists($target_file)) { JFile::delete($target_file); } } //activity logging. $activity = new stdClass(); $activity->actor_id = $my->id; $activity->target_id = '0'; $activity->context_type = 'category'; $activity->context_id = $this->id; $activity->verb = 'delete'; $activity->uuid = $this->title; $return = parent::delete(); if ($return) { EasyBlogHelper::activityLog($activity); } return $return; }
private function givePoints($user_id, $points, $data = null, $mode = null) { if ($points === 0) { return true; } $points_mode = @$this->plugin_params->mode; if ($mode !== null) { $points_mode = $mode; } if ($points_mode == 'aup') { if ($this->getAUP(true)) { $aupid = AlphaUserPointsHelper::getAnyUserReferreID($user_id); AlphaUserPointsHelper::newpoints('plgaup_orderValidation', $aupid, '', $data, $points); return true; } return false; } if ($points_mode == 'hks') { if (hikaserial::initShop()) { $app = JFactory::getApplication(); $ret = true; $userClass = hikaserial::get('shop.class.user'); $oldUser = $userClass->get($user_id, 'cms'); if (!isset($oldUser->user_points) && !in_array('user_points', array_keys(get_object_vars($oldUser)))) { return false; } if (empty($oldUser->user_points)) { $oldUser->user_points = 0; } $user = new stdClass(); $user->user_id = $oldUser->user_id; $user->user_points = (int) $oldUser->user_points + $points; if ($user->user_points < 0) { $app->enqueueMessage(JText::_('CANT_HAVE_NEGATIVE_POINTS'), 'error'); $points = -$oldUser->user_points; $user->user_points = 0; $ret = false; } else { $app->enqueueMessage(JText::sprintf('HIKAPOINTS_EARN_X_POINTS', $points), 'success'); } $userClass->save($user); return $ret; } return false; } if ($points_mode == 'hkp') { if (hikaserial::initPoints()) { return hikapoints::trigger($user_id, 'hikaserial_points_consumer', $points); } return false; } if (substr($points_mode, 0, 4) == 'hkp.') { if (hikaserial::initPoints()) { $category_id = (int) substr($points_mode, 4); $pointsClass = hikapoints::get('class.points'); return $pointsClass->add($user_id, $category_id, $points); } return false; } return false; }
function remove() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('category'); $categories = JRequest::getVar('cid', '', 'POST'); $message = ''; $type = 'info'; if (empty($categories)) { $message = JText::_('COM_EASYBLOG_CATEGORIES_INVALID_CATEGORY'); $type = 'error'; } else { $table = EasyBlogHelper::getTable('Category', 'Table'); foreach ($categories as $category) { $table->load($category); if ($table->getPostCount()) { $message = JText::sprintf('COM_EASYBLOG_CATEGORIES_DELETE_ERROR_POST_NOT_EMPTY', $table->title); $type = 'error'; $this->setRedirect('index.php?option=com_easyblog&view=categories', $message, $type); return; } if ($table->getChildCount()) { $message = JText::sprintf('COM_EASYBLOG_CATEGORIES_DELETE_ERROR_CHILD_NOT_EMPTY', $table->title); $type = 'error'; $this->setRedirect('index.php?option=com_easyblog&view=categories', $message, $type); return; } if (!$table->delete()) { $message = JText::_('COM_EASYBLOG_CATEGORIES_DELETE_ERROR'); $type = 'error'; $this->setRedirect('index.php?option=com_easyblog&view=categories', $message, $type); return; } else { // AlphaUserPoints // since 1.2 if (EasyBlogHelper::isAUPEnabled()) { $aupid = AlphaUserPointsHelper::getAnyUserReferreID($table->created_by); AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_category', $aupid, '', JText::sprintf('AUP CATEGORY DELETED', $table->title)); } } } $message = JText::_('COM_EASYBLOG_CATEGORIES_DELETE_SUCCESS'); } $this->setRedirect('index.php?option=com_easyblog&view=categories', $message, $type); }