function getPoint($user_id) { require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; $profile = AlphaUserPointsHelper::getUserInfo('', $user_id); $point = $profile->points; return $point; }
public function awardPoints($userId, $name, $args) { require_once $this->_componentFile; $key = $args->get('key', ''); $name = str_replace(".", "_", $name); $name = 'plgaup_jfbconnect_' . $name; $keyreference = AlphaUserPointsHelper::buildKeyreference($name, $key); // get the current user's Referrerid always, for now. $profile = AlphaUserPointsHelper::getUserInfo('', $userId); $referrerId = $profile->referreid; $return = AlphaUserPointsHelper::newpoints($name, $referrerId, $keyreference); }
public function getPoints($userId) { $config = EasyBlogHelper::getConfig(); if (!$config->get('main_alpha_userpoint_points')) { return false; } if (!$this->loadHelper()) { return false; } $info = AlphaUserPointsHelper::getUserInfo('', $userId); if (!$info) { return ''; } return JText::sprintf('COM_EASYBLOG_AUP_POINTS_EARNED', $info->points); }
function _get_referrees($referrerid) { $db = JFactory::getDBO(); $query = "SELECT * FROM #__alpha_userpoints WHERE referraluser='******'"; $db->setQuery($query); $rowsreferrees = $db->loadObjectList(); if ($rowsreferrees) { require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; for ($i = 0, $n = count($rowsreferrees); $i < $n; $i++) { $UserInfo = AlphaUserPointsHelper::getUserInfo($rowsreferrees[$i]->referreid); $username = $UserInfo->username; $name = $UserInfo->name; $rowsreferrees[$i]->username = $username; $rowsreferrees[$i]->name = $name; } } return $rowsreferrees; }
function validerRadio($db) { $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP)) { require_once $api_AUP; $query = "SELECT id_user FROM #__mzpromoradio where valide='0' GROUP BY id_user"; $db->setQuery($query); $users = $db->loadResultArray(); foreach ($users as $u) { $u = (int) $u; //$referreid = AlphaUserPointsHelper::getAnyUserReferreID( $u ); $profil = AlphaUserPointsHelper::getUserInfo('', $u); if ($profil->points > 299) { $query = "UPDATE #__mzpromoradio SET valide='1' WHERE id_user='******'"; $db->setQuery($query); $test = $db->query(); } } } }
} echo $linktoprofil; ?> </td> <?php } ?> <?php if ($this->params->get('show_username_cols', 1) || !$this->params->get('show_name_cols') && !$this->params->get('show_username_cols')) { ?> <td headers="categorylist_header_title" class="list-title"> <?php if ($this->params->get('show_links_to_users', 1)) { $_user_info = AlphaUserPointsHelper::getUserInfo($row->referreid); $linktoprofil = getProfileLink($_profilelink, $_user_info); $linktoprofil = "<a href=\"" . JRoute::_($linktoprofil) . "\">" . $row->username . "</a>"; } else { $linktoprofil = $row->username; } echo $linktoprofil; ?> </td> <?php } ?> <td headers="categorylist_header_title" class="list-title"> <div class="progress progress-striped active"> <div class="bar" style="width: <?php
function getAvatar($userId,$wallversion) { $path=JURI::base(); $temp='plugins/content/loadjomwall/'; $path=str_replace($temp,'',$path); $db =& JFactory::getDBO(); $app = JFactory::getApplication('site'); $config = & $app->getParams('com_awdwall'); $template = $config->get('temp', 'blue'); $avatarintergration = $config->get('avatarintergration', '0'); $query = "SELECT facebook_id FROM #__jconnector_ids WHERE user_id = " . (int)$userId; $db->setQuery($query); $facebook_id = $db->loadResult(); if($facebook_id) { $avatar='https://graph.facebook.com/'.$facebook_id.'/picture?type=square'; } else { $query = 'SELECT avatar FROM #__awd_wall_users WHERE user_id = ' . (int)$userId; $db = & JFactory::getDBO(); $db->setQuery($query); $img = $db->loadResult(); if($img == NULL){ $avatar = $path . "components/com_awdwall/images/".$template."/".$template."32.png"; }else{ $avatar = $path. "images/wallavatar/" . $userId . "/thumb/tn32" . $img; } } if($avatarintergration==1) // k2 { if(file_exists(JPATH_SITE . '/components/com_k2/k2.php')) { require_once (JPATH_SITE . '/components/com_k2/helpers/utilities.php'); $avatar=K2HelperUtilities::getAvatar($userId); } } else if($avatarintergration==2) // easyblog { if(file_exists(JPATH_SITE . '/components/com_easyblog/easyblog.php')) { require_once (JPATH_SITE . '/components/com_easyblog/helpers/helper.php'); $blogger = EasyBlogHelper::getTable( 'Profile', 'Table'); $blogger->load( $userId ); $avatar=$blogger->getAvatar(); } } else if($avatarintergration==3) // alphauserpoint { if(file_exists(JPATH_SITE . '/components/com_alphauserpoints/alphauserpoints.php')) { require_once (JPATH_SITE . '/components/com_alphauserpoints/helper.php'); require_once (JPATH_SITE . '/components/com_alphauserpoints/helpers/helpers.php'); $_user_info = AlphaUserPointsHelper::getUserInfo ( $referrerid='', $userId ); $com_params = &JComponentHelper::getParams( 'com_alphauserpoints' ); $useAvatarFrom = $com_params->get('useAvatarFrom'); $height = 32; $width=32; $avatar = getAvatar( $useAvatarFrom, $_user_info, $height,$width); $doc = new DOMDocument(); $doc->loadHTML($avatar); $imageTags = $doc->getElementsByTagName('img'); foreach($imageTags as $tag) { $avatar=$tag->getAttribute('src'); } } } return $avatar; }
$com_params = JComponentHelper::getParams('com_alphauserpoints'); $user = JFactory::getUser(); if ($list) { if (!class_exists('AlphaUserPointsHelper')) { require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; } $com_params = JComponentHelper::getParams('com_alphauserpoints'); $useAvatarFrom = $com_params->get('useAvatarFrom'); ?> <div> <ul style="padding:0;margin:0;list-style: none;"> <?php $i = 1; foreach ($list as $item) { $usrname = htmlspecialchars($item->usrname, ENT_QUOTES, 'UTF-8'); $userinfo = AlphaUserPointsHelper::getUserInfo($item->referreid); $profil = getProfileLink($com_params->get('linkToProfile', ''), $item); ?> <li style="background:none;padding:5px 0;border-bottom:solid 1px #ccc;list-style: none;"> <?php if ($params->get('showavatar', 0)) { ?> <div style="float:left;width:38px;"> <div style="padding:2px;border:solid 1px #ccc;"> <?php echo getAvatar($useAvatarFrom, $userinfo, 32); ?> </div> </div> <?php $margin = 42;
/** * Check whether a user may download the file, when AlphaUserPoints are used * * @param integer $sum_aup_price_points the sum of points from price field, for the requested files * array $marked_files_id * * @return array */ public static function checkUserPoints($sum_aup_price_points, $marked_files_id) { global $jlistConfig; $user = JFactory::getUser(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $sum_aup_points = 0; $aup_result = array(); $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP)) { require_once $api_AUP; // get current user points - stored in $profil->points $aup = new AlphaUserPointsHelper(); $profil = $aup->getUserInfo('', $user->id); // get standard points value from AUP jDownloads rule $db->setQuery("SELECT points FROM #__alpha_userpoints_rules WHERE published = 1 AND plugin_function = 'plgaup_jdownloads_user_download'"); $aup_fix_points = floatval($db->loadResult()); //$aup_fix_points = strToNumber($aup_fix_points); if ($jlistConfig['use.alphauserpoints.with.price.field']) { $sum_aup_points = $sum_aup_price_points; } else { // fis points for every download are used $sum_aup_points = $aup_fix_points * count($marked_files_id); // we need a positive value if ($sum_aup_points < 0) { $sum_aup_points = -$sum_aup_points; } } if ($profil) { // we have a member if ($jlistConfig['user.can.download.file.when.zero.points']) { // he can download it after all $aup_result['points_info'] = sprintf(str_replace('%d', '%s', JText::_('COM_JDOWNLOADS_FE_VIEW_AUP_SUM_POINTS')), self::strToNumber($sum_aup_points), self::strToNumber($profil->points)); $aup_result['may_download'] = true; } elseif ($sum_aup_points > 0 && $sum_aup_points <= $profil->points) { // view it only when we have a result and user may download it $aup_result['points_info'] = sprintf(str_replace('%d', '%s', JText::_('COM_JDOWNLOADS_FE_VIEW_AUP_SUM_POINTS')), self::strToNumber($sum_aup_points), self::strToNumber($profil->points)); $aup_result['may_download'] = true; } elseif ($sum_aup_points > 0 && $sum_aup_points > $profil->points) { // user may not download $aup_result['points_info'] = '<div style="text-align:center" class="jd_div_aup_message">' . stripslashes(self::getOnlyLanguageSubstring($jlistConfig['user.message.when.zero.points'])) . '</div>' . '<div style="text-align:center" class="jd_div_aup_message">' . JText::_('COM_JDOWNLOADS_FE_SUMMARY_YOUR_POINTS') . ' ' . self::strToNumber($profil->points) . '<br />' . JText::_('COM_JDOWNLOADS_FE_SUMMARY_NEEDED_POINTS') . ' ' . self::strToNumber($sum_aup_points) . '</div>'; $aup_result['may_download'] = false; } else { // this download is free but we create still the user info, so the user can read that he costs nothing! $aup_result['points_info'] = sprintf(str_replace('%d', '%s', JText::_('COM_JDOWNLOADS_FE_VIEW_AUP_SUM_POINTS')), abs($aup_fix_points * count($marked_files_id)), self::strToNumber($profil->points)); $aup_result['may_download'] = true; } } else { if ($sum_aup_points > 0) { // view it only when we have a result // but we have here an unregistered visitor - he can not have aup points! if ($jlistConfig['user.can.download.file.when.zero.points']) { // he can download it after all $aup_result['points_info'] = sprintf(str_replace('%d', '%s', JText::_('COM_JDOWNLOADS_FE_VIEW_AUP_SUM_POINTS')), self::strToNumber($sum_aup_points), 0); $aup_result['may_download'] = true; } else { // now way to doenload it $aup_result['points_info'] = sprintf(str_replace('%d', '%s', JText::_('COM_JDOWNLOADS_FE_VIEW_AUP_SUM_POINTS_FOR_VISITOR')), self::strToNumber($sum_aup_points), 0); $aup_result['may_download'] = false; } } else { // remove placeholder $aup_result['points_info'] = ''; $aup_result['may_download'] = true; } } } else { $aup_result['points_info'] = ''; $aup_result['may_download'] = true; } return $aup_result; }
function check_user_credits($userid = 0) { $app = JFactory::getApplication(); if (!$userid) { $user = JFactory::getUser(); $userid = $user->id; } $params = JComponentHelper::getParams(S_APP_NAME); $points_per_credit = (int) $params->get('points_per_credit', 0); if (!$points_per_credit) { return -1; } switch ($params->get('points_system', 'none')) { case 'cjblog': $api = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_cjblog' . DIRECTORY_SEPARATOR . 'api.php'; if (file_exists($api)) { include_once $api; $profile = CjBlogApi::get_user_profile($userid); if (!empty($profile)) { return floor($profile['points'] / $points_per_credit); } } break; case 'aup': $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP)) { require_once $api_AUP; $profile = AlphaUserPointsHelper::getUserInfo('', $userid); if (!empty($profile)) { return floor($profile->points / $points_per_credit); } } break; case 'jomsocial': $query = 'select points from #__community_users where userid=' . $userid; $this->_db->setQuery($query); $points = (int) $this->_db->loadResult(); return floor($points / $points_per_credit); case 'easysocial': $query = 'select sum(points) from #__social_points_history where user_id = ' . $userid . ' and state = 1'; $this->_db->setQuery($query); $points = (int) $this->_db->loadResult(); return floor($points / $points_per_credit); } return -1; }
public function display($cachable = false, $urlparams = false) { $app = JFactory::getApplication(); require_once JPATH_ROOT . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; $com_params = JComponentHelper::getParams('com_alphauserpoints'); $model = $this->getModel('alphauserpoints'); $view = $this->getView('account', 'html'); // current user $user = JFactory::getUser(); // profil request $userid = JFactory::getApplication()->input->get('userid', '', 'string'); if (!$user->id && !$com_params->get('allowGuestUserViewProfil', 1)) { $msg = JText::_('ALERTNOTAUTH'); $this->setRedirect('index.php', $msg); $this->redirect(); } // check referre ID if (!$userid) { $referrerid = $model->_checkUser(); } else { $referrerid = $userid; } // Rule Profile View if ($referrerid != @$_SESSION['referrerid']) { $keyreference = AlphaUserPointsHelper::buildKeyreference('sysplgaup_profile_view', $user->id); $username = $user->username ? $user->username : JText::_('AUP_GUEST'); $datareference = JText::_('AUP_PROFILE_VIEW_REFERENCE') . ' ' . $username; AlphaUserPointsHelper::userpoints('sysplgaup_profile_view', $referrerid, 0, $keyreference, $datareference); } // End rule Profile View // Get the parameters of the active menu item $params = $model->_getParamsAUP(); $num_item_activities = $params->get('num_item_activities', 10); $_get_last_points = $model->_get_last_points($referrerid, $num_item_activities); $_listing_last_points = $_get_last_points[0]; $_listing_total = $_get_last_points[1]; $_listing_limit = $_get_last_points[2]; $_listing_limitstart = $_get_last_points[3]; $rowsreferrees = $model->_get_referrees($referrerid); $pointsearned = $model->_pointsearned(); // users points earned TOP 10 $totalpoints = $model->_totalpoints(); // entire community $mypointsearned = $model->_mypointsearned($referrerid); $mypointsspent = $model->_mypointsspent($referrerid); $mypointsearnedthismonth = $model->_mypointsearnedthismonth($referrerid); $mypointsspentthismonth = $model->_mypointsspentthismonth($referrerid); $mypointsearnedthisday = $model->_mypointsearnedthisday($referrerid); $mypointsspentthisday = $model->_mypointsspentthisday($referrerid); $_average_age = _get_average_age_community(); $_user_info = AlphaUserPointsHelper::getUserInfo($referrerid); $currenttotalpoints = $_user_info->points; $lastupdate = $_user_info->last_update; $referraluser = $_user_info->referraluser; $myname = $_user_info->name; $myusername = $_user_info->username; $mybirthday = $_user_info->birthdate; $referralname = ""; if ($referraluser) { $referralinfo = AlphaUserPointsHelper::getUserInfo($referraluser); $referralname = $referralinfo->username; } // get level/rank if exist $userrankinfo = AlphaUserPointsHelper::getUserRank($referrerid); // get medals if exist $medalslistuser = AlphaUserPointsHelper::getUserMedals($referrerid); // load avatar $useAvatarFrom = $com_params->get('useAvatarFrom'); $height = 100; if ($useAvatarFrom == 'alphauserpoints') { $lang = JFactory::getLanguage(); $lang->load('com_media', JPATH_ADMINISTRATOR); } $avatar = getAvatar($useAvatarFrom, $_user_info, $height, $height, 'class="thumbnail"'); // Get coupons code $resultCoupons = $model->_getMyCouponCode($referrerid); $view->assign('params', $params); $view->assign('cparams', $com_params); $view->assign('referreid', $referrerid); $view->assign('currenttotalpoints', $currenttotalpoints); $view->assign('rowslastpoints', $_listing_last_points); $view->assign('total', $_listing_total); $view->assign('limit', $_listing_limit); $view->assign('limitstart', $_listing_limitstart); $view->assign('lastupdate', $lastupdate); $view->assign('referraluser', $referraluser); $view->assign('referralname', $referralname); $view->assign('rowsreferrees', $rowsreferrees); $view->assign('userid', $user->id); $view->assign('userrankinfo', $userrankinfo); $view->assign('medalslistuser', $medalslistuser); $view->assign('pointsearned', $pointsearned); $view->assign('totalpoints', $totalpoints); $view->assign('mypointsearned', $mypointsearned); $view->assign('mypointsspent', $mypointsspent); $view->assign('mypointsearnedthismonth', $mypointsearnedthismonth); $view->assign('mypointsspentthismonth', $mypointsspentthismonth); $view->assign('mypointsearnedthisday', $mypointsearnedthisday); $view->assign('mypointsspentthisday', $mypointsspentthisday); $view->assign('myname', $myname); $view->assign('myusername', $myusername); $view->assign('avatar', $avatar); $view->assign('birthday', $mybirthday); $view->assign('user_info', $_user_info); $view->assign('useAvatarFrom', $useAvatarFrom); $view->assign('mycouponscode', $resultCoupons); $view->assign('userinfo', $_user_info); $view->assign('average_age', $_average_age); // Display $view->_display(); }
function getAvatar($useAvatarFrom, $userinfo, $height = '', $width = '', $class = '') { $db = JFactory::getDBO(); $avatar = ''; $setheight = $height != '' ? 'height="' . $height . '"' : ''; $setwidth = $width != '' ? 'width="' . $width . '"' : 'width="' . $height . '"'; if ($width == '') { $width = $height; } $defaultAvatarAUP = JURI::root() . 'components/com_alphauserpoints/assets/images/avatars/generic_gravatar_grey.png'; switch ($useAvatarFrom) { case 'gravatar': $email = $userinfo->email; $gravatar_url = 'http://www.gravatar.com/avatar/'; $gravatar_url .= md5(strtolower(trim($email))); $gravatar_url .= '?d=' . urlencode($defaultAvatarAUP); if ($height) { $gravatar_url .= '&s=$height'; } else { $gravatar_url .= '&s=80'; } $avatar = '<img src="' . $gravatar_url . '" alt=""/>'; break; case 'kunena': if (!defined("_AUP_KUNENA_PATH")) { define('_AUP_KUNENA_PATH', JPATH_ROOT . '/media/kunena'); } if (!defined("_AUP_KUNENA_LIVE_PATH")) { define('_AUP_KUNENA_LIVE_PATH', JURI::base(true) . '/media/kunena'); } $Avatarname = $userinfo->avatar; $query = "SELECT a.*, b.* FROM #__kunena_users as a" . "\n LEFT JOIN #__users as b on b.id=a.userid" . "\n where a.userid=" . $userinfo->id; $db->setQuery($query); $userProfilKunena = $db->loadObject(); $fb_avatar = @$userProfilKunena->avatar; if ($fb_avatar != '') { if (!file_exists(_AUP_KUNENA_PATH . '/avatars/' . $fb_avatar)) { $avatar = _AUP_KUNENA_LIVE_PATH . '/avatars/' . $fb_avatar; } else { $avatar = _AUP_KUNENA_LIVE_PATH . '/avatars/' . $fb_avatar; } } else { $avatar = _AUP_KUNENA_LIVE_PATH . '/avatars/nophoto.jpg'; } break; case 'cb': $query = "SELECT avatar FROM #__comprofiler WHERE user_id = '" . $userinfo->id . "'"; $db->setQuery($query); $result = $db->loadResult(); if (!empty($result)) { $avatar = JURI::base(true) . "/images/comprofiler/" . $result; } else { $avatar = JURI::base(true) . "/components/com_comprofiler/plugin/templates/default/images/avatar/nophoto_n.png"; } break; case 'cbe': global $mosConfig_lang; $query = "SELECT avatar, avatarapproved FROM #__cbe WHERE user_id ='" . $userinfo->id . "'"; $db->setQuery($query); $result = $db->loadObject(); $avatar = $result->avatar; if (file_exists(JPATH_ROOT . DS . "components" . DS . "com_cbe" . DS . "images" . DS . $mosConfig_lang)) { $uimagepath = JURI::base(true) . "/components/com_cbe/images/" . $mosConfig_lang . "/"; } else { $uimagepath = JURI::base(true) . "/components/com_cbe/images/english/"; } if ($result->avatarapproved == 0) { $avatar = $uimagepath . "pendphoto.jpg"; } elseif ($result->avatar == '' || $result->avatar == null) { $avatar = $uimagepath . "nophoto.jpg"; } else { $avatar = JURI::base(true) . "/images/cbe/" . $avatar; } break; case 'jomsocial': $query = "SELECT avatar FROM #__community_users WHERE userid = '" . $userinfo->id . "'"; $db->setQuery($query); $result = $db->loadResult(); if (!empty($result)) { $avatar = JURI::base(false) . $result; } else { $avatar = JURI::base(true) . "/components/com_community/assets/default_thumb.jpg"; } break; case 'clexus': $query = "SELECT picture FROM #__mypms_profiles WHERE `name`='" . $userinfo->username . "'"; $db->setQuery($query); $result = $db->loadResult(); if (!empty($result)) { $avatar = $result; } else { $avatar = ''; } break; case 'K2': $query = "SELECT image FROM #__k2_users WHERE userID='" . $userinfo->id . "'"; $db->setQuery($query); $result = $db->loadResult(); if (!empty($result)) { $avatar = JURI::base(true) . "/media/k2/users/" . $result; } else { $avatar = ''; } break; case 'alphauserpoints': if (!defined("_AUP_AVATAR_LIVE_PATH")) { define('_AUP_AVATAR_LIVE_PATH', JURI::base(true) . '/components/com_alphauserpoints/assets/images/avatars/'); } $usr_avatar = $userinfo->avatar != '' ? JPATH_COMPONENT . DS . 'assets/images/avatars/' . $userinfo->avatar : JPATH_COMPONENT . DS . 'assets/images/avatars/generic_gravatar_grey.gif'; if (file_exists($usr_avatar)) { $image = new JImage($usr_avatar); $avatar = $image->createThumbs(array($width . 'x' . $height), JImage::CROP_RESIZE, JPATH_COMPONENT . DS . 'assets' . DS . 'images' . DS . 'avatars' . DS . 'thumbs'); $avatar = myImage::getLivePathImage($avatar); } else { $avatar = $defaultAvatarAUP; } break; case 'jomWALL': // for version 2.5 $config = JComponentHelper::getParams('com_awdwall'); $template = $config->get('temp', 'blue'); $avatarintergration = $config->get('avatarintergration', '0'); $query = "SELECT facebook_id FROM #__jconnector_ids WHERE user_id = " . (int) $userId; $db->setQuery($query); $facebook_id = $db->loadResult(); if ($facebook_id) { $avatar = 'https://graph.facebook.com/' . $facebook_id . '/picture?type=large'; } else { $query = 'SELECT avatar FROM #__awd_wall_users WHERE user_id = ' . (int) $userId; $db = JFactory::getDBO(); $db->setQuery($query); $img = $db->loadResult(); if ($img == NULL) { $avatar = JURI::root() . "components/com_awdwall/images/" . $template . "/" . $template . "51.png"; } else { $avatar = JURI::root() . "images/wallavatar/" . $userId . "/thumb/tn51" . $img; } } if ($avatarintergration == 1) { if (file_exists(JPATH_SITE . '/components/com_k2/k2.php')) { require_once JPATH_SITE . '/components/com_k2/helpers/utilities.php'; $avatar = K2HelperUtilities::getAvatar($userId); } } else { if ($avatarintergration == 2) { if (file_exists(JPATH_SITE . '/components/com_easyblog/easyblog.php')) { require_once JPATH_SITE . '/components/com_easyblog/helpers/helper.php'; $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($userId); $avatar = $blogger->getAvatar(); } } else { if ($avatarintergration == 3) { if (file_exists(JPATH_SITE . '/components/com_alphauserpoints/alphauserpoints.php')) { require_once JPATH_SITE . '/components/com_alphauserpoints/helper.php'; require_once JPATH_SITE . '/components/com_alphauserpoints/helpers/helpers.php'; $_user_info = AlphaUserPointsHelper::getUserInfo($referrerid = '', $userId); $com_params = JComponentHelper::getParams('com_alphauserpoints'); $useAvatarFrom = $com_params->get('useAvatarFrom'); $height = 50; $width = 50; $avatar = getAvatar($useAvatarFrom, $_user_info, $height, $width); $doc = new DOMDocument(); $doc->loadHTML($avatar); $imageTags = $doc->getElementsByTagName('img'); foreach ($imageTags as $tag) { $avatar = $tag->getAttribute('src'); } } } } } default: $avatar = ''; } if ($avatar && $useAvatarFrom != 'gravatar' && $useAvatarFrom != 'jomsocial') { $avatar = '<img src="' . $avatar . '" border="0" alt="" ' . $setheight . $setwidth . ' ' . $class . ' />'; } elseif ($useAvatarFrom == 'jomsocial') { $avatar = '<img src="' . $avatar . '" border="0" alt="" ' . $setheight . $setwidth . ' />'; } return $avatar; }
function sendnotification($referrerid, $assignpoints, $newtotal, $result, $force = 0, $username = '') { $app = JFactory::getApplication(); if (!$referrerid || $referrerid == 'GUEST') { return; } $db = JFactory::getDBO(); $user = JFactory::getUser($username); jimport('joomla.mail.helper'); // get params definitions $params = JComponentHelper::getParams('com_alphauserpoints'); $SiteName = $app->getCfg('sitename'); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $sef = $app->getCfg('sef'); $userinfo = AlphaUserPointsHelper::getUserInfo($referrerid); $email = $userinfo->email; $rule_name = $result->rule_name; $subject = $result->emailsubject; $body = $result->emailbody; $formatMail = $result->emailformat; $bcc2admin = $result->bcc2admin; if (!$userinfo->block || $force) { if ($subject != '' && $body != '') { $subject = str_replace('{username}', $user->username, $subject); $subject = str_replace('{points}', abs($assignpoints), $subject); $subject = str_replace('{newtotal}', $newtotal, $subject); $body = str_replace('{username}', $user->username, $body); $body = str_replace('{points}', abs($assignpoints), $body); $body = str_replace('{newtotal}', $newtotal, $body); } else { if ($assignpoints > 0) { $subject = JText::_('AUP_EMAILNOTIFICATION_SUBJECT'); $body = sprintf(JText::_('AUP_EMAILNOTIFICATION_MSG'), $SiteName, $assignpoints, $newtotal, JText::_($rule_name)); } elseif ($assignpoints < 0) { $subject = JText::_('AUP_EMAILNOTIFICATION_SUBJECT_ACCOUNT_UPDATED'); $body = sprintf(JText::_('AUP_EMAILNOTIFICATION_MSG_REMOVE_POINTS'), $SiteName, abs($assignpoints), $newtotal, JText::_($rule_name)); } } $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $mailer = JFactory::getMailer(); $mailer->setSender(array($MailFrom, $FromName)); $mailer->setSubject($subject); $mailer->isHTML((bool) $formatMail); $mailer->CharSet = "utf-8"; $mailer->setBody($body); $mailer->addRecipient($email); if ($bcc2admin) { // get all users allowed to receive e-mail system $query = "SELECT email" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'"; $db->setQuery($query); $rowsAdmins = $db->loadObjectList(); foreach ($rowsAdmins as $rowsAdmin) { $mailer->addBCC($rowsAdmin->email); } } $send =& $mailer->Send(); } }
public static function getAupAvatar($userid, $linktoprofil = 0, $width = '', $height = '', $class = '', $otherprofileurl = '') { if (!$userid) { return; } if (!defined("_AUP_AVATAR_PATH")) { // prevent call in administrator backend $juriroot = str_replace(DS . 'administrator', '', JURI::root()); define('_AUP_AVATAR_PATH', JURI::root() . 'components/com_alphauserpoints/assets/images/avatars/'); } else { $juriroot = $juriroot = str_replace(DS . 'administrator', '', JURI::root()); } if (!defined("_AUP_AVATAR_LIVE_PATH")) { // prevent call in administrator backend $juribase = str_replace('/administrator', '', JURI::base()); define('_AUP_AVATAR_LIVE_PATH', $juribase . 'components/com_alphauserpoints/assets/images/avatars/'); } else { $juribase = str_replace('/administrator', '', JURI::base()); } $startprofil = ""; $endprofil = ""; $setwidth = $width != '' ? ' width="' . $width . '"' : ''; $setheight = $height != '' ? ' height="' . $height . '"' : ''; $setclass = $class != '' ? ' class="' . $class . '"' : ''; $profile = AlphaUserPointsHelper::getUserInfo('', $userid); $avatar = $profile->avatar != '' ? _AUP_AVATAR_LIVE_PATH . $profile->avatar : _AUP_AVATAR_PATH . 'generic_gravatar_grey.png'; //$avatar = JURI::root() . "components/com_alphauserpoints/assets/phpThumb/phpThumb.php?src=".$avatar."&w=" . $width ."&h=" . $height; $avatar = '<img src="' . $avatar . '" border="0" alt=""' . $setwidth . $setheight . $setclass . ' />'; $profileitemid = ''; if ($linktoprofil) { $profileitemid = '&Itemid=' . AlphaUserPointsHelper::getItemidAupProfil(); $profil = $otherprofileurl ? $otherprofileurl : "index.php?option=com_alphauserpoints&view=account&userid=" . $profile->referreid . $profileitemid; $startprofil = "<a href=\"" . JRoute::_($profil) . "\">"; $endprofil = "</a>"; $avatar = $startprofil . $avatar . $endprofil; } return $avatar; // USAGE // $avatar = AlphaUserPointsHelper::getAupAvatar($userid, [int $linktoprofil], [int $width], [int $height], [string $class], [string $otherprofileurl]); // if $linktoprofil set to 1, display avatar with the link to the AUP profil of this user // Think to call and include this API helper.php in your script }
/** * Method to submit the downloads file to the browser. * * * @return null */ public function send() { global $jlistConfig; jimport('joomla.environment.uri'); $jinput = JFactory::getApplication()->input; $app = JFactory::getApplication(); $params = $app->getParams(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $db = JFactory::getDBO(); $config = array('ignore_request' => true); $model = $this->getModel('send', 'jdownloadsModel', $config); $user_rules = JDHelper::getUserRules(); clearstatcache(); $active = $app->getMenu()->getActive(); if ($active) { $current_link = $active->link; } else { $current_link = JRoute::_(JUri::current() . '?option=com_jdownloads'); } // abort when downloads are offline if ($jlistConfig['offline']) { $msg = JDHelper::getOnlyLanguageSubstring($jlistConfig['offline.text']); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } $allow = false; $extern = false; $extern_site = false; $can_download = false; $aup_exist = false; $profile = ''; // Which file types shall be viewed in browser $view_types = array(); $view_types = explode(',', $jlistConfig['file.types.view']); // get request data $cat_id = $db->escape($jinput->get('catid', 0, 'int')); $file_id = $db->escape($jinput->get('id', 0, 'int')); $mirror = $db->escape($jinput->get('m', 0, 'int')); $files_list = $db->escape($jinput->get('list', '', 'string')); $zip_file = $db->escape($jinput->get('user', 0, 'cmd')); // get session data $stored_random_id = (int) JDHelper::getSessionDecoded('jd_random_id'); $stored_file_id = (int) JDHelper::getSessionDecoded('jd_fileid'); $stored_cat_id = (int) JDHelper::getSessionDecoded('jd_catid'); $stored_files_list = JDHelper::getSessionDecoded('jd_list'); // compare and check it if ($cat_id > 0 && $cat_id != $stored_cat_id || $file_id > 0 && $file_id != $stored_file_id || $zip_file > 0 && $zip_file != $stored_random_id || $files_list != '' && $files_list != $stored_files_list) { // perhaps use it a direct download option $this->items = $model->getItems($file_id); if ($this->items) { $this->state = $model->getState(); $sum_selected_files = $this->state->get('sum_selected_files'); $sum_selected_volume = $this->state->get('sum_selected_volume'); $sum_files_prices = $this->state->get('sum_files_prices'); $must_confirm_license = $this->state->get('must_confirm_license'); $directlink = $this->state->get('directlink_used'); $marked_files_id = $this->state->get('download.marked_files.id'); // check the permission access for direct download option $within_the_user_limits = JDHelper::checkDirectDownloadLimits($cat_id, $file_id, $files_list, $user_rules, $sum_selected_files, $sum_selected_volume); if ($within_the_user_limits !== true) { // user has his limits reached or not enough points $msg = JText::_($within_the_user_limits); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } } else { // invalid data found / url manipulations? $msg = JText::_('COM_JDOWNLOADS_INVALID_DOWNLOAD_DATA_MSG'); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } } // check leeching if ($is_leeching = JDHelper::useAntiLeeching()) { // download stopped - view hint $msg = JText::_('COM_JDOWNLOADS_ANTILEECH_MSG') . ' ' . JText::_('COM_JDOWNLOADS_ANTILEECH_MSG2'); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } if ($zip_file) { // user has selected more as a single file $zip_file = $jlistConfig['zipfile.prefix'] . $zip_file . '.zip'; $filename = $jlistConfig['files.uploaddir'] . '/' . $jlistConfig['tempzipfiles.folder.name'] . '/' . $zip_file; if (!file_exists($filename)) { // download stopped - zip file not found $msg = JText::_('COM_JDOWNLOADS_FILE_NOT_FOUND') . ': ' . basename($zip_file); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } } // download action check (not for uncategorized) if ($cat_id > 1) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('download', 'com_jdownloads.category.' . $cat_id); if ($file_id && $allow) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('download', 'com_jdownloads.download.' . $file_id); } } else { if ($file_id) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('download', 'com_jdownloads.download.' . $file_id); } } if (!$allow) { // download stopped - user has not the right to download it $msg = JText::_('COM_JDOWNLOADS_DOWNLOAD_NOT_ALLOWED_MSG'); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } $transfer_speed = (int) $user_rules->transfer_speed_limit_kb; if ($jlistConfig['use.alphauserpoints']) { // get AUP user info $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP) && !$user->guest) { require_once $api_AUP; $aup_exist = true; // get user profile data from AUP $profile = AlphaUserPointsHelper::getUserInfo('', $user->id); // get standard points value from AUP $db->setQuery("SELECT points FROM #__alpha_userpoints_rules WHERE published = 1 AND plugin_function = 'plgaup_jdownloads_user_download'"); $aup_fix_points = floatval($db->loadResult()); //$aup_fix_points = JDHelper::strToNumber($aup_fix_points); } } // build a array with IDs $files_arr = explode(',', $files_list); // get the files data for multi or single download $query = $db->getQuery(true); $query->select('a.*'); $query->from('#__jdownloads_files AS a'); // Join on category table. $query->select('c.title AS category_title, c.id AS category_id, c.cat_dir AS category_cat_dir, c.cat_dir_parent AS category_cat_dir_parent'); $query->join('LEFT', '#__jdownloads_categories AS c on c.id = a.cat_id'); // Join on license table. $query->select('l.title AS license_title'); $query->join('LEFT', '#__jdownloads_licenses AS l on l.id = a.license'); $query->where('(a.published = ' . $db->Quote('1') . ')'); if ($files_list) { $query->where('a.file_id IN (' . $files_list . ')'); } else { $query->where('a.file_id = ' . $db->Quote($file_id)); } // Filter by access level so when we get not a result this user has not the access to view it $query->where('a.access IN (' . $groups . ')'); $query->where('c.access IN (' . $groups . ')'); $db->setQuery($query); $files = $db->loadObjectList(); if (!$files) { // invalid data or user has not really the access $msg = JText::_('COM_JDOWNLOADS_DATA_NOT_FOUND'); $app->redirect(JRoute::_($current_link), $msg, 'error'); } // When we have a regged user, we must check whether he downloads the file in parts. // If so, we may only once write the download data in log and compute the AUP etc. $download_in_parts = JDHelper::getLastDownloadActivity($user->id, $files_list, $file_id, $user_rules->download_limit_after_this_time); if (count($files) > 1) { // mass download if (!$download_in_parts) { // add AUP points if ($jlistConfig['use.alphauserpoints'] && $aup_exist) { if ($jlistConfig['use.alphauserpoints.with.price.field']) { $db->setQuery("SELECT SUM(price) FROM #__jdownloads_files WHERE file_id IN ({$files_list})"); $sum_points = (int) $db->loadResult(); if ($profile->points >= $sum_points) { foreach ($files as $aup_data) { $db->setQuery("SELECT price FROM #__jdownloads_files WHERE file_id = '{$aup_data->file_id}'"); if ($price = floatval($db->loadResult())) { $can_download = JDHelper::setAUPPointsDownloads($user->id, $aup_data->file_title, $aup_data->file_id, $price, $profile); } } } } else { // use fix points $sum_points = $aup_fix_points * count($files_arr); if ($profile->points >= $sum_points) { foreach ($files as $aup_data) { $can_download = JDHelper::setAUPPointsDownloads($user->id, $aup_data->file_title, $aup_data->file_id, 0, $profile); } } else { $can_download = false; } } } else { // no AUP active $can_download = true; } if ($jlistConfig['user.can.download.file.when.zero.points'] && !$user->guest) { $can_download = true; } } else { $can_download = true; } } else { // single download // we must be ensure that the user cannot skiped special options or settings // check at first the password option if ($files[0]->password_md5 != '') { // captcha is activated for this user $session_result = (int) JDHelper::getSessionDecoded('jd_password_run'); if ($session_result < 2) { // Abort !!! $msg = JText::_('COM_JDOWNLOADS_ANTILEECH_MSG'); $app->redirect(JRoute::_($current_link), $msg, 'error'); } else { JDHelper::writeSessionEncoded('0', 'jd_password_run'); } } else { // when is not use a password, we must check captcha if ($user_rules->view_captcha) { // captcha is activated for this user $session_result = (int) JDHelper::getSessionDecoded('jd_captcha_run'); if ($session_result < 2) { // Abort !!! $msg = JText::_('COM_JDOWNLOADS_ANTILEECH_MSG'); $app->redirect(JRoute::_($current_link), $msg, 'error'); } else { JDHelper::writeSessionEncoded('0', 'jd_captcha_run'); } } } if (!$mirror) { if ($files[0]->url_download) { // build the complete category path if ($files[0]->cat_id > 1) { // Download has a category if ($files[0]->category_cat_dir_parent != '') { $cat_dir = $files[0]->category_cat_dir_parent . '/' . $files[0]->category_cat_dir; } else { $cat_dir = $files[0]->category_cat_dir; } $filename = $jlistConfig['files.uploaddir'] . '/' . $cat_dir . '/' . $files[0]->url_download; $filename_direct = $jlistConfig['files.uploaddir'] . '/' . $cat_dir . '/' . $files[0]->url_download; } else { // Download is 'uncategorized' $filename = $jlistConfig['files.uploaddir'] . '/' . $jlistConfig['uncategorised.files.folder.name'] . '/' . $files[0]->url_download; } } elseif ($files[0]->other_file_id) { // A file from another Download was assigned $query = $db->getQuery(true); $query->select('a.*'); $query->from('#__jdownloads_files AS a'); // Join on category table. $query->select('c.id AS category_id, c.cat_dir AS category_cat_dir, c.cat_dir_parent AS category_cat_dir_parent'); $query->join('LEFT', '#__jdownloads_categories AS c on c.id = a.cat_id'); $query->where('a.published = ' . $db->Quote('1')); $query->where('a.file_id = ' . $db->Quote($files[0]->other_file_id)); $query->where('a.access IN (' . $groups . ')'); $db->setQuery($query); $other_file_data = $db->loadObject(); if ($other_file_data->cat_id > 1) { // the assigned Download has a category if ($other_file_data->category_cat_dir_parent != '') { $cat_dir = $other_file_data->category_cat_dir_parent . '/' . $other_file_data->category_cat_dir; } else { $cat_dir = $other_file_data->category_cat_dir; } $filename = $jlistConfig['files.uploaddir'] . '/' . $cat_dir . '/' . $other_file_data->url_download; $filename_direct = $jlistConfig['files.uploaddir'] . '/' . $cat_dir . '/' . $other_file_data->url_download; } else { // Download is 'uncategorized' $filename = $jlistConfig['files.uploaddir'] . '/' . $jlistConfig['uncategorised.files.folder.name'] . '/' . $other_file_data->url_download; } } else { $filename = $files[0]->extern_file; if ($files[0]->extern_site) { $extern_site = true; } $extern = true; } } else { // is mirror if ($mirror == 1) { $filename = $files[0]->mirror_1; if ($files[0]->extern_site_mirror_1) { $extern_site = true; } } else { $filename = $files[0]->mirror_2; if ($files[0]->extern_site_mirror_2) { $extern_site = true; } } $extern = true; } $price = ''; // Is AUP rule or price option used - we need the price for it if ($aup_exist) { if ($jlistConfig['use.alphauserpoints.with.price.field']) { $price = floatval($files[0]->price); } else { $price = $aup_fix_points; } } if (!$download_in_parts) { $can_download = JDHelper::setAUPPointsDownload($user->id, $files[0]->file_title, $files[0]->file_id, $price, $profile); if ($jlistConfig['user.can.download.file.when.zero.points'] && $user->id) { $can_download = true; } } else { $can_download = true; } } // plugin support // load external plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('jdownloads'); $results = $dispatcher->trigger('onBeforeDownloadIsSendJD', array(&$files, &$can_download, $user_rules, $download_in_parts)); if (!$can_download) { $msg = JText::_('COM_JDOWNLOADS_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD'); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } else { // run download if (!$download_in_parts) { // send at first e-mail if ($jlistConfig['send.mailto.option'] == '1' && $files) { JDHelper::sendMailDownload($files); } // give uploader AUP points when is set on if ($jlistConfig['use.alphauserpoints']) { if ($jlistConfig['use.alphauserpoints.with.price.field']) { JDHelper::setAUPPointsDownloaderToUploaderPrice($files); } else { JDHelper::setAUPPointsDownloaderToUploader($files); } } // write data in log if ($jlistConfig['activate.download.log']) { JDHelper::updateLog($type = 1, $files, ''); } // update downloads hits if (count($files) > 1) { $db->setQuery('UPDATE #__jdownloads_files SET downloads=downloads+1 WHERE file_id IN (' . $files_list . ')'); $db->execute(); } else { $db->setQuery("UPDATE #__jdownloads_files SET downloads=downloads+1 WHERE file_id = '" . $files[0]->file_id . "'"); $db->execute(); } } // get filesize if (!$extern) { if (!file_exists($filename)) { $msg = JText::_('COM_JDOWNLOADS_FILE_NOT_FOUND') . ': ' . basename($filename); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } else { $size = filesize($filename); } } else { $size = JDHelper::getUrlFilesize($filename); } // if url go to other website - open it in a new browser window if ($extern_site) { echo "<script>document.location.href='{$filename}';</script>\n"; exit; } // if set the option for direct link to the file if (!$jlistConfig['use.php.script.for.download']) { $root = str_replace('\\', '/', $_SERVER["DOCUMENT_ROOT"]); $root = rtrim($root, "/"); $host = $_SERVER["HTTP_HOST"] . '/'; $filename_direct = str_replace($root, $host, $filename_direct); $filename_direct = str_replace('//', '/', $filename_direct); if (strpos('http://', $filename_direct) === false && strpos('https://', $filename_direct) === false && strpos('ftp://', $filename_direct) === false) { $filename_direct = 'http://' . $filename_direct; } $app->redirect($filename_direct); } else { $only_filename = basename($filename); $extension = JDHelper::getFileExtension($only_filename); if ($extern) { $mime_type = JDHelper::getMimeTypeRemote($filename); } else { $mime_type = JDHelper::getMimeTyp($extension); } // Check for protocol and set the appropriate headers $use_ssl = false; $uri = JUri::getInstance(JUri::current()); $protocol = $uri->getScheme(); if ($protocol == 'https') { $use_ssl = true; } $open_in_browser = false; if (in_array($extension, $view_types)) { // view file in browser $open_in_browser = true; } clearstatcache(); if ($extern) { ob_end_clean(); // needed for MS IE - otherwise content disposition is not used? if (ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); } header("Cache-Control: public, must-revalidate"); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // header("Pragma: no-cache"); // Problems with MS IE header("Expires: 0"); header("Content-Description: File Transfer"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); header("Content-Type: " . $mime_type); header("Content-Length: " . (string) $size); if (!$open_in_browser) { header('Content-Disposition: attachment; filename="' . $only_filename . '"'); } else { // view file in browser header('Content-Disposition: inline; filename="' . $only_filename . '"'); } header("Content-Transfer-Encoding: binary\n"); // redirect to category when it is set the time if (intval($jlistConfig['redirect.after.download']) > 0) { header("refresh:" . $jlistConfig['redirect.after.download'] . "; url=" . $current_link); } // set_time_limit doesn't work in safe mode if (!ini_get('safe_mode')) { @set_time_limit(0); } @readfile($filename); flush(); exit; } else { $download_class_file = JPATH_SITE . DS . 'components' . DS . 'com_jdownloads' . DS . 'helpers' . DS . 'downloader.php'; if (file_exists($download_class_file)) { require_once $download_class_file; $object = new downloader(); $object->set_byfile($filename); // Type: Download from a file $object->set_filename($only_filename); // Set the file basename $object->set_filesize($size); // Set the file basename $object->set_mime($mime_type); // Set the mime type $object->set_speed($transfer_speed); // Set download speed $object->set_refresh($current_link, (int) $jlistConfig['redirect.after.download']); // // redirect to category when it is set the time in configuration $object->use_resume = true; // Set the value for using Resume Mode $object->use_ssl = $use_ssl; // Set support for SSL $object->open_in_browser = $open_in_browser; // Set whether the file shall be opened in browser window $object->use_autoexit = true; // Set the value for auto exit ('false' worked not really with extern file?) $object->download(); // Run the download flush(); exit; } else { $msg = JText::_('COM_JDOWNLOADS_FILE_NOT_FOUND') . ': ' . $filename; $app->redirect(JRoute::_($current_link), $msg, 'notice'); } } } } }
public static function get_user_points($system, $userid = 0) { if (!$userid) { return 0; } $app = JFactory::getApplication(); switch ($system) { case 'cjblog': $api = JPATH_ROOT . '/components/com_cjblog/api.php'; if (file_exists($api)) { include_once $api; $profile = CjBlogApi::get_user_profile($userid); if (!empty($profile)) { return $profile['points']; } } break; case 'aup': $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP)) { require_once $api_AUP; $profile = AlphaUserPointsHelper::getUserInfo('', $userid); if (!empty($profile)) { return $profile->points; } } break; case 'jomsocial': $db = JFactory::getDbo(); $query = 'select points from #__community_users where userid=' . (int) $userid; $db->setQuery($query); return (int) $db->loadResult(); case 'easysocial': require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; $my = Foundry::user($userid); $points = $my->getPoints(); return $points; default: return 0; } return -1; }
function getUserPoints($cms_user_id = null, $mode = 'all') { $ret = 0; if ($mode == 'all') { $ret = array(); } if ($mode == 'aup' || $mode == 'all' && $this->getAUP()) { if ($mode == 'aup' && !$this->getAUP(true)) { return false; } if ($cms_user_id === null) { $user = Jfactory::getUser(); $cms_user_id = $user->id; } $userInfo = AlphaUserPointsHelper::getUserInfo('', $cms_user_id); if ($mode == 'aup') { return (int) $userInfo->points; } $ret['aup'] = (int) $userInfo->points; } if ($cms_user_id === null) { $user = hikashop_loadUser(true); } else { $userClass = hikashop_get('class.user'); $user = $userClass->get($cms_user_id, 'cms'); } if ($mode == 'hk') { if (isset($user->user_points) || $user != null && in_array('user_points', array_keys(get_object_vars($user)))) { return (int) @$user->user_points; } return false; } if (isset($user->user_points) || $user != null && in_array('user_points', array_keys(get_object_vars($user)))) { if ($mode == 'all') { $ret['hk'] = (int) @$user->user_points; } else { $ret = (int) @$user->user_points; } } return $ret; }
function _save_medaluser() { $app = JFactory::getApplication(); require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; // initialize variables $db = JFactory::getDBO(); $post = JRequest::get('post'); $row = JTable::getInstance('medals'); // last update $jnow = JFactory::getDate(); $now = $jnow->toSql(); $row->medaldate = $now; if ($post['reason'] == '') { $queryDescMedals = "SELECT description FROM #__alpha_userpoints_levelrank WHERE typerank='1' AND id='" . $post['medal'] . "'"; $db->setQuery($queryDescMedals); $medaldescription = $db->loadResult(); $post['reason'] = $medaldescription; } if (!$row->bind($post)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $query = "SELECT * FROM #__alpha_userpoints_levelrank WHERE typerank='1' AND id='" . $post['medal'] . "'"; $db->setQuery($query); $medal = $db->loadObject(); $userinfo = AlphaUserPointsHelper::getUserInfo($post['referreid']); // load external plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('alphauserpoints'); // load external plugins $results = $dispatcher->trigger('onUnlockMedalAlphaUserPoints', array(&$userinfo, &$medal)); $msg = JText::_('AUP_GENERALSTATSSAVED'); JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=edituser&cid[]=' . $post['rid'], $msg); JControllerLegacy::redirect(); }
<h1><?php echo $this->escape($this->params->get('page_heading')); ?> </h1> </div> <?php } if ($this->latestactivity) { require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; ?> <table class="category table table-striped table-bordered table-hover"> <tbody> <?php $i = 0; foreach ($this->latestactivity as $activity) { $_user_info = AlphaUserPointsHelper::getUserInfo($activity->referreid); $linktoprofil = getProfileLink($this->linkToProfile, $_user_info); ?> <tr class="cat-list-row<?php echo $i % 2; ?> "> <?php if ($this->useAvatarFrom && $this->params->get('showAvatar')) { $avatar = getAvatar($this->useAvatarFrom, $_user_info, $this->params->get('heightAvatar', '48')); // add link to profil if need $startprofil = '<a href="#" class="thumbnail">'; $endprofil = '</a>'; if ($this->params->get('show_links_to_users', 1) && $user->id || $this->params->get('show_links_to_users', 1) && !$user->id && $this->allowGuestUserViewProfil) { $startprofil = '<a href="' . $linktoprofil . '" class="thumbnail">'; $endprofil = '</a>';