private function _getAllEvents() { $mainframe = JFactory::getApplication(); $rows = $this->model->getEvents(); $items = array(); foreach ($rows as $row) { $item = new stdClass(); $table =& JTable::getInstance('Event', 'CTable'); $table->bind($row); $table->thumbnail = $table->getThumbAvatar(); $table->avatar = $table->getAvatar(); $author = CFactory::getUser($table->creator); $item->id = $row->id; $item->created = $row->created; $item->creator = CStringHelper::escape($author->getDisplayname()); $item->title = $row->title; $item->description = CStringHelper::escape($row->description); $item->location = CStringHelper::escape($row->location); $tiem->startdate = $row->startdate; $item->enddate = $row->enddate; $item->thumbnail = $table->thumbnail; $tiem->avatar = $table->avatar; $item->ticket = $row->ticket; $item->invited = $row->invitedcount; $item->confirmed = $row->confirmedcount; $item->declined = $row->declinedcount; $item->maybe = $row->maybecount; $item->latitude = $row->latitude; $item->longitude = $row->longitude; $items[] = $item; } return $items; }
static function getActivityContentHTML($act) { // Ok, the activity could be an upload OR a wall comment. In the future, the content should // indicate which is which $html = ''; $param = new CParameter($act->params); $action = $param->get('action', false); $count = $param->get('count', false); $config = CFactory::getConfig(); switch ($action) { case CAdminstreamsAction::TOP_USERS: $model = CFactory::getModel('user'); $members = $model->getPopularMember($count); $html = ''; //Get Template Page $tmpl = new CTemplate(); $html = $tmpl->set('members', $members)->fetch('activity.members.popular'); return $html; break; case CAdminstreamsAction::TOP_PHOTOS: $model = CFactory::getModel('photos'); $photos = $model->getPopularPhotos($count, 0); $tmpl = new CTemplate(); $html = $tmpl->set('photos', $photos)->fetch('activity.photos.popular'); return $html; break; case CAdminstreamsAction::TOP_VIDEOS: $model = CFactory::getModel('videos'); $videos = $model->getPopularVideos($count); $tmpl = new CTemplate(); $html = $tmpl->set('videos', $videos)->fetch('activity.videos.popular'); return $html; break; } }
public function getThumbnail($obj) { $config = CFactory::getConfig(); $file = $obj->thumb; // Site origin if (JString::substr($file, 0, 4) == 'http') { $uri = $file; return $uri; } // Remote storage if ($obj->storage != 'file') { $storage = CStorage::getStorage($obj->storage); $uri = $storage->getURI($file); return $uri; } // Default thumbnail if (empty($file) || !JFile::exists(JPATH_ROOT . '/' . $file)) { $template = new CTemplateHelper(); $asset = $template->getTemplateAsset('video_thumb.png', 'images'); $uri = $asset->url; return $uri; } // Strip cdn path if exists. // Note: At one point, cdn path was stored along with the thumbnail path // in the db which is the mistake we are trying to rectify here. $file = str_ireplace($config->get('videocdnpath'), '', $file); // CDN or local $baseUrl = $config->get('videobaseurl') or $baseUrl = JURI::root(); $uri = str_replace('\\', '/', rtrim($baseUrl, '/') . '/' . ltrim($file, '/')); return $uri; }
static function addPoints_jomsocial($action, $username, $course_id, $course_name) { if (file_exists(JPATH_ADMINISTRATOR . '/components/com_community/tables/cache.php')) { require_once JPATH_ADMINISTRATOR . 'components/com_community/tables/cache.php'; } require_once JPATH_SITE . '/components/com_community/libraries/core.php'; require_once JPATH_SITE . '/components/com_community/libraries/userpoints.php'; if (class_exists('CFactory')) { $userPoint = CFactory::getModel('userpoints'); } else { $userPoint = new CommunityModelUserPoints(); } $upObj = $userPoint->getPointData($action); $published = $upObj->published; if ($published) { $points = $upObj->points; } else { $points = 0; } if ($points == 0) { return 0; } $user = CFactory::getUser($username); $points += $user->getKarmaPoint(); $user->_points = $points; $user->save(); return $points; }
/** * Ajax function to save a new wall entry * * @param message A message that is submitted by the user * @param uniqueId The unique id for this group * * */ function onProfileDisplay() { //Load language file. JPlugin::loadLanguage('plg_community_myarticles', JPATH_ADMINISTRATOR); // Attach CSS $document = JFactory::getDocument(); $css = JURI::base() . 'plugins/community/myarticles/myarticles/style.css'; $document->addStyleSheet($css); if (JRequest::getVar('task', '', 'REQUEST') == 'app') { $app = 1; } else { $app = 0; } $user = CFactory::getRequestUser(); $userid = $user->id; $def_limit = $this->params->get('count', 10); $limit = JRequest::getVar('limit', $def_limit, 'REQUEST'); $limitstart = JRequest::getVar('limitstart', 0, 'REQUEST'); $row = $this->getArticle($userid, $limitstart, $limit, $this->section); $cat = $this->getCatAlias(); $total = $this->countArticle($userid, $this->section); if ($this->params->get('hide_empty', 0) && !$total) { return ''; } $mainframe = JFactory::getApplication(); $caching = $this->params->get('cache', 1); if ($caching) { $caching = $mainframe->getCfg('caching'); } $cache = JFactory::getCache('plgCommunityMyArticles'); $cache->setCaching($caching); $callback = array('plgCommunityMyArticles', '_getArticleHTML'); $content = $cache->call($callback, $userid, $limit, $limitstart, $row, $app, $total, $cat, $this->params); return $content; }
public static function getAccessLevel($actorId, $targetId) { $actor = CFactory::getUser($actorId); $target = CFactory::getUser($targetId); //CFactory::load( 'helpers' , 'owner' ); //CFactory::load( 'helpers' , 'friends' ); // public guest $access = 0; // site members if ($actor->id > 0) { $access = 20; } // they are friends if ($target->id > 0 && CFriendsHelper::isConnected($actor->id, $target->id)) { $access = 30; } // mine, target and actor is the same person if ($target->id > 0 && COwnerHelper::isMine($actor->id, $target->id)) { $access = 40; } if (COwnerHelper::isCommunityAdmin()) { $access = 40; } return $access; }
public static function _getMutualFriendsHTML($userid = null) { $my = CFactory::getUser(); if ($my->id == $userid) { return; } $friendsModel = CFactory::getModel('Friends'); $friends = $friendsModel->getFriends($userid, 'latest', false, 'mutual'); $html = "<ul class='joms-list--friend single-column'>"; if (sizeof($friends)) { foreach ($friends as $friend) { $html .= "<li class='joms-list__item'>"; $html .= "<div class='joms-list__avatar'>"; $html .= '<div class="joms-avatar ' . CUserHelper::onlineIndicator($friend) . '"><a href="' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $friend->id) . '">'; $html .= '<img src="' . $friend->getThumbAvatar() . '" data-author="' . $friend->id . '" />'; $html .= "</a></div></div>"; $html .= "<div class='joms-list__body'>"; $html .= CFriendsHelper::getUserCog($friend->id, null, null, true); $html .= CFriendsHelper::getUserFriendDropdown($friend->id); $html .= '<a href="' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $friend->id) . '">'; $html .= '<h4 class="joms-text--username">' . $friend->getDisplayName() . '</h4></a>'; $html .= '<span class="joms-text--title">' . JText::sprintf('COM_COMMUNITY_TOTAL_MUTUAL_FRIENDS', CFriendsHelper::getTotalMutualFriends($friend->id)) . '</span>'; $html .= "</div></li>"; } $html .= "</ul>"; } else { $html .= JText::_('COM_COMMUNITY_NO_MUTUAL_FRIENDS'); } return $html; }
public function getFieldHTML($field, $required) { $class = $field->required == 1 ? ' required' : ''; $class .= !empty($field->tips) ? ' jomNameTips tipRight' : ''; $lists = explode(',', $field->value); CFactory::load('helpers', 'string'); $html = '<select id="field' . $field->id . '" name="field' . $field->id . '[]" type="select-multiple" multiple="multiple" class="jomNameTips tipRight select' . $class . '" title="' . CStringHelper::escape(JText::_($field->tips)) . '">'; $elementSelected = 0; foreach ($field->options as $option) { $selected = in_array($option, $lists) ? ' selected="selected"' : ''; if (empty($selected)) { $elementSelected++; } $html .= '<option value="' . $option . '"' . $selected . '>' . JText::_($option) . '</option>'; } if ($elementSelected == 0) { //if nothing is selected, we default the 1st option to be selected. $elementName = 'field' . $field->id; $html .= <<<HTML \t\t\t\t \t\t\t\t <script type='text/javascript'> \t\t\t\t\t var slt = document.getElementById('{$elementName}'); \t\t\t\t\t if(slt != null){ \t\t\t\t\t slt.options[0].selected = true;\t\t\t\t\t \t\t\t\t\t } \t\t\t\t </script> HTML; } $html .= '</select>'; $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;"> </span>'; return $html; }
function onSystemStart() { if (!self::kunenaInstalled()) { return; } //initialize the toolbar object $toolbar = CFactory::getToolbar(); // Kunena online check if (!Kunena::enabled()) { $toolbar->addGroup('KUNENAMENU', JText::_('PLG_COMMUNITY_KUNENAMENU_KUNENA_OFFLINE'), JRoute::_('index.php?option=com_kunena')); return; } //adding new 'tab' 'Forum Settings' to JomSocial toolbar $toolbar->addGroup('KUNENAMENU', JText::_('PLG_COMMUNITY_KUNENANENU_FORUM'), KunenaRoute::_('index.php?option=com_kunena&func=myprofile')); if ($this->params->get('sh_editprofile')) { $toolbar->addItem('KUNENAMENU', 'KUNENAMENU_EDITPROFILE', JText::_('PLG_COMMUNITY_KUNENAMENU_EDITPROFILE'), KunenaRoute::_('index.php?option=com_kunena&func=myprofile&task=edit')); } if ($this->params->get('sh_myprofile')) { $toolbar->addItem('KUNENAMENU', 'KUNENAMENU_PROFILE', JText::_('PLG_COMMUNITY_KUNENAMENU_PROFILE'), KunenaRoute::_('index.php?option=com_kunena&func=myprofile')); } if ($this->params->get('sh_myposts')) { $toolbar->addItem('KUNENAMENU', 'KUNENAMENU_POSTS', JText::_('PLG_COMMUNITY_KUNENAMENU_POSTS'), KunenaRoute::_('index.php?option=com_kunena&func=latest&do=userposts')); } if ($this->params->get('sh_mysubscriptions')) { $toolbar->addItem('KUNENAMENU', 'KUNENAMENU_SUBSCRIBES', JText::_('PLG_COMMUNITY_KUNENAMENU_SUBSCRIBTIONS'), KunenaRoute::_('index.php?option=com_kunena&func=latest&do=subscriptions')); } if ($this->params->get('sh_myfavorites')) { $toolbar->addItem('KUNENAMENU', 'KUNENAMENU_FAVORITES', JText::_('PLG_COMMUNITY_KUNENAMENU_FAVORITES'), KunenaRoute::_('index.php?option=com_kunena&func=latest&do=favorites')); } }
public function getProfileLink($user_id, &$object, &$attribs = array()) { $user = CFactory::getUser($user_id); //parameters $params = $this->params; if (!$user || $params->get('view_individual_link', '1') == 0) { return true; } JHTML::_('behavior.tooltip'); $name = $user->getDisplayName(); $url = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user_id); switch ($params->get('view_individual_link', '1')) { case 2: $avatar = $user->getThumbAvatar(); $text = '<img class="hasTip" src="' . $avatar . '" title="' . $name . '"/>'; break; case 1: default: $text = JText::_('PLG_TRACKS_JOMSOCIAL_VIEW_USER_PROFILE'); break; } $attribs = array_merge($attribs, array('alt' => $user->get('username'))); $object->text = JHTML::link($url, $text, $attribs); return true; }
/** * Return true if actor have access to target's item * @param type where the privacy setting should be extracted, {user, group, global, custom} * Site super admin waill always have access to all area */ static function isAccessAllowed($actorId, $targetId, $type, $userPrivacyParam) { $actor = CFactory::getUser($actorId); $target = CFactory::getUser($targetId); CFactory::load('helpers', 'owner'); CFactory::load('helpers', 'friends'); // Load User params $params =& $target->getParams(); // guest $relation = 10; // site members if ($actor->id != 0) { $relation = 20; } // friends if (CFriendsHelper::isConnected($actorId, $targetId)) { $relation = 30; } // mine, target and actor is the same person if (COwnerHelper::isMine($actor->id, $target->id)) { $relation = 40; } // @todo: respect privacy settings // If type is 'custom', then $userPrivacyParam will contain the exact // permission level $permissionLevel = $type == 'custom' ? $userPrivacyParam : $params->get($userPrivacyParam); if ($relation < $permissionLevel && !COwnerHelper::isCommunityAdmin($actorId)) { return false; } return true; }
function display($data = null) { $mainframe = JFactory::getApplication(); $config = CFactory::getConfig(); $document =& JFactory::getDocument(); $document->setTitle(JText::sprintf('CC FRONTPAGE TITLE', $config->get('sitename'))); $document->setLink(CRoute::_('index.php?option=com_community')); $my = CFactory::getUser(); CFactory::load('libraries', 'activities'); CFactory::load('helpers', 'string'); $act = new CActivityStream(); $rows = $act->getFEED('', '', null, $mainframe->getCfg('feed_limit')); if ($config->get('showactivitystream') == COMMUNITY_SHOW || $config->get('showactivitystream') == COMMUNITY_MEMBERS_ONLY && $my->id != 0) { foreach ($rows->data as $row) { if ($row->type != 'title') { // load individual item creator class $item = new JFeedItem(); // cannot escape the title. it's already formated. we should // escape it during CActivityStream::add //$item->title = CStringHelper::escape($row->title); $item->title = $row->title; $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->actor); $item->description = "<img src=\"{$row->favicon}\" alt=\"\"/> " . $row->title; $item->date = $row->createdDate; $item->category = ''; //$row->category; // Make sure url is absolute $item->description = JString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description); // loads item info into rss array $document->addItem($item); } } } }
function _displayEditLayout($tpl) { // Load frontend language file. $lang =& JFactory::getLanguage(); $lang->load('com_community', JPATH_ROOT); $userId = JRequest::getVar('id', '', 'REQUEST'); $user = CFactory::getUser($userId); // Set the titlebar text JToolBarHelper::title($user->username, 'users'); // Add the necessary buttons JToolBarHelper::back('Back', 'index.php?option=com_community&view=users'); JToolBarHelper::divider(); JToolBarHelper::cancel('removeavatar', JText::_('CC REMOVE AVATAR')); JToolBarHelper::save(); $model = CFactory::getModel('Profile'); $profile = $model->getEditableProfile($user->id, $user->getProfileType()); $config =& CFactory::getConfig(); $params = $user->getParams(); $userDST = $params->get('daylightsavingoffset'); $offset = !empty($userDST) ? $userDST : $config->get('daylightsavingoffset'); $counter = -4; $options = array(); for ($i = 0; $i <= 8; $i++, $counter++) { $options[] = JHTML::_('select.option', $counter, $counter); } $offsetList = JHTML::_('select.genericlist', $options, 'daylightsavingoffset', 'class="inputbox" size="1"', 'value', 'text', $offset); $user->profile =& $profile; $this->assignRef('user', $user); $this->assignRef('params', $user->getParameters(true)); $this->assignRef('offsetList', $offsetList); parent::display($tpl); }
public function onGroupJoin($group, $userId) { //@rule: Clear existing invites fromt he invitation table once the user joined the group $groupInvite = JTable::getInstance('GroupInvite', 'CTable'); $keys = array('groupid' => $group->id, 'userid' => $userId); if ($groupInvite->load($keys)) { $groupInvite->delete(); } $member = JTable::getInstance('GroupMembers', 'CTable'); $keys = array('memberId' => $userId, 'groupId' => $group->id); $member->load($keys); $groupModel = CFactory::getModel('groups'); $admins = $groupModel->getAdmins($group->id, null); $params = $group->getParams(); //@rule: Send notification when necessary if ($params->get('joinrequestnotification') || $params->get('newmembernotification')) { $user = CFactory::getUser($userId); $subject = JText::sprintf('COM_COMMUNITY_GROUPS_EMAIL_NEW_MEMBER_JOINED_SUBJECT', '{user}', '{group}'); if (!$member->approved) { $subject = JText::sprintf('COM_COMMUNITY_NEW_MEMBER_REQUESTED_TO_JOIN_GROUP_EMAIL_SUBJECT', '{user}', '{group}'); } $params = new CParameter(''); $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $params->set('group', $group->name); $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $params->set('user', $user->getDisplayName()); $params->set('user_url', 'index.php?option=com_community&view=profile&userid=' . $user->id); $params->set('approved', $member->approved); foreach ($admins as $admin) { CNotificationLibrary::add('groups_member_join', $user->id, $admin->id, $subject, '', 'groups.memberjoin', $params); } } }
public function populateUserData($obj, $user_id) { // joomla fills the info $obj = parent::populateUserData($obj, $user_id); //populate jomsocial require_once JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php'; $pModel = CFactory::getModel('profile'); $profile = $pModel->getEditableProfile($this->activationUserID); $fields = $profile['fields']; //$obj->jomsocial = array(); foreach ($fields as $name => $fieldGroup) { foreach ($fieldGroup as $field) { $name = $field['name']; if ($field['fieldcode'] == 'XIPT_PROFILETYPE') { require_once JPATH_BASE . DS . 'components' . DS . 'com_xipt' . DS . 'api.xipt.php'; $profiletypeName = XiptAPI::getUserProfiletype($user_id, 'name'); $obj['profile'][$name] = $profiletypeName; continue; } $fieldId = $pModel->getFieldId($field['fieldcode']); $query = 'SELECT value FROM #__community_fields_values' . ' ' . 'WHERE `field_id`=' . $this->db->Quote($fieldId) . ' ' . 'AND `user_id`=' . $this->db->Quote($user_id); $result = $this->db->setQuery($query)->loadresult(); if (!empty($result)) { $obj['profile'][$name] = $result; } } } return $obj; }
/** * The default method that will display the output of this view which is called by * Joomla * * @param string template Template file name **/ public function display($tpl = null) { $mainframe = JFactory::getApplication(); $filter_order = $mainframe->getUserStateFromRequest("com_community.eventcategories.filter_order", 'filter_order', 'name', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest("com_community.eventcategories.filter_order_Dir", 'filter_order_Dir', '', 'word'); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; $categories = $this->get('Categories'); $pagination = $this->get('Pagination'); $catCount = $this->get('CategoriesCount'); // Escape the output CFactory::load('helpers', 'string'); foreach ($categories as $row) { $row->name = CStringHelper::escape($row->name); $row->description = CStringHelper::escape($row->description); if ($row->parent == 0) { $row->pname = JText::_("COM_COMMUNITY_NO_PARENT"); } else { $parent =& JTable::getInstance('eventcategories', 'CommunityTable'); $parent->load($row->parent); $row->pname = CStringHelper::escape($parent->name); } } $this->assignRef('lists', $lists); $this->assignRef('categories', $categories); $this->assignRef('catCount', $catCount); $this->assignRef('pagination', $pagination); parent::display($tpl); }
public static function getStream(&$params) { //since @2.6 $db = JFactory::getDBO(); $query = ''; //if user is logged in, depends on the settings, either to display updates from participated group or all public groups if ($params->get('afterlogin_setting') && JFactory::getUser()->id) { //first lets get the user participated group //CFactory::load( 'models' , 'groups' ); $groupsModel = CFactory::getModel('groups'); $groupIds = $groupsModel->getGroupIds(JFactory::getUser()->id); $groupIds = implode(',', $groupIds); if (empty($groupIds)) { return array(); } $query = 'SELECT a.*, b.' . $db->quoteName('name') . ' AS groupname, b.' . $db->quoteName('thumb') . ' AS thumbnail FROM ' . $db->quoteName('#__community_activities') . ' AS a ' . 'INNER JOIN ' . $db->quoteName('#__community_groups') . ' AS b ' . ' ON b.' . $db->quoteName('id') . '=a.' . $db->quoteName('groupid') . ' WHERE a.' . $db->quoteName('app') . '=' . $db->Quote('groups.wall') . ' AND a.' . $db->quoteName('groupid') . ' IN (' . $groupIds . ')' . ' ORDER BY a.' . $db->quoteName('created') . ' DESC ' . ' LIMIT ' . $params->get('count'); } else { $query = 'SELECT a.*, b.' . $db->quoteName('name') . ' AS groupname, b.' . $db->quoteName('thumb') . ' AS thumbnail FROM ' . $db->quoteName('#__community_activities') . ' AS a ' . 'INNER JOIN ' . $db->quoteName('#__community_groups') . ' AS b ' . ' ON b.' . $db->quoteName('id') . '=a.' . $db->quoteName('groupid') . ' AND b.' . $db->quoteName('approvals') . '=' . $db->Quote(0) . ' WHERE a.' . $db->quoteName('app') . '=' . $db->Quote('groups.wall') . ' ORDER BY a.' . $db->quoteName('created') . ' DESC ' . ' LIMIT ' . $params->get('count'); } $db->setQuery($query); $rows = $db->loadObjectList(); // if exist, group the results based on groups $results = array(); if (count($rows)) { foreach ($rows as $row) { $results[$row->groupid][] = $row; } } //reverse the results so that latest will be shown on top array_reverse($results); return $results; }
public function onFriendApprove($obj) { // Update friends count $friendsModel = CFactory::getModel('friends'); $friendsModel->updateFriendCount($obj->profileOwnerId); $friendsModel->updateFriendCount($obj->friendId); }
function onProfileDisplay() { JPlugin::loadLanguage('plg_community_mygoogleads', JPATH_ADMINISTRATOR); $config = CFactory::getConfig(); $config = CFactory::getConfig(); $this->loadUserParams(); $uri = JURI::base(); $user = CFactory::getRequestUser(); $document = JFactory::getDocument(); $css = $uri . 'plugins/community/mygoogleads/mygoogleads/style.css'; $document->addStyleSheet($css); $googleCode = $this->userparams->get('googleCode'); $content = ''; if (!empty($googleCode)) { $mainframe = JFactory::getApplication(); $caching = $this->params->get('cache', 1); if ($caching) { $caching = $mainframe->getCfg('caching'); } $cache = JFactory::getCache('plgCommunityMyGoogleAds'); $cache->setCaching($caching); $callback = array('plgCommunityMyGoogleAds', '_getGoogleAdsHTML'); $content = $cache->call($callback, $googleCode, $user->id); } else { // $content = "<div class=\"icon-nopost\"><img src=\"".JURI::base()."components/com_community/assets/error.gif\" alt=\"\" /></div>"; $content .= "<div class=\"content-nopost\">" . JText::_('PLG_GOOGLE_ADS_NOT_SET') . "</div>"; } return $content; }
public static function exceedDaily($view, $userId = null, $returnRemaining = false) { $my = CFactory::getUser($userId); // Guests shouldn't be even allowed here. if ($my->id == 0) { return true; } $view = JString::strtolower($view); // We need to include the model first before using ReflectionClass so that the model file is included. $model = CFactory::getModel($view); // Since the model will always return a CCachingModel which is a proxy, // for the real model, we can't really test what type of object it is. $modelClass = 'CommunityModel' . ucfirst($view); $reflection = new ReflectionClass($modelClass); if (!$reflection->implementsInterface('CLimitsInterface')) { return false; } $config = CFactory::getConfig(); $total = $model->getTotalToday($my->id); $max = $config->getInt('limit_' . $view . '_perday'); if ($returnRemaining) { return $max - $total; } return $total >= $max && $max != 0; }
/** * Load up all published moods on startup */ public function __construct() { $this->enabled = CFactory::getConfig()->get("enablemood"); $db = JFactory::getDBO(); $sql = 'SELECT * FROM ' . $db->quoteName('#__community_moods') . ' ORDER BY ' . $db->quoteName('ordering') . ' ASC'; $db->setQuery($sql); $result = $db->loadObjectList(); // build and pre-parse assoc result array foreach ($result as $mood) { // legacy - predefined (non-custom) moods use untraslated mood strings as identifiers if (!$mood->custom) { $mood->id = $mood->title; $mood->title = JText::_('COM_COMMUNITY_MOOD_SHORT_' . strtoupper($mood->title)); } // apply description translations for frontend $mood->description = JText::_($mood->description); if ($mood->custom) { $mood->title = JText::_($mood->title); $filename = "mood_" . $mood->id . "." . $mood->image; if (file_exists(COMMUNITY_PATH_ASSETS . $filename)) { $mood->image = JUri::root() . str_replace(JPATH_ROOT, '', COMMUNITY_PATH_ASSETS) . $filename; } else { $mood->image = ''; } } $this->moods[$mood->id] = $mood; } unset($result); }
function onProfileDisplay() { if (!self::kunenaOnline()) { return; } //Load Language file. JPlugin::loadLanguage('plg_community_mykunena', JPATH_ADMINISTRATOR); $document = JFactory::getDocument(); $document->addStyleSheet(JURI::base() . 'plugins/community/mykunena/style.css'); $items = array(); $user = CFactory::getRequestUser(); if ($user->id) { require_once KPATH_SITE . '/funcs/latestx.php'; $obj = new CKunenaLatestX('userposts', 0); $obj->user = JFactory::getUser($user->id); $obj->threads_per_page = $this->params->get('count', 5); $obj->embedded = 1; $obj->getUserPosts(); $items = $obj->customreply; } $caching = $this->params->get('cache', 1); if ($caching) { $app = JFactory::getApplication(); $caching = $app->getCfg('caching'); } $cache = JFactory::getCache('plgCommunityMyKunena'); $cache->setCaching($caching); $callback = array('plgCommunityMyKunena', '_getMyKunenaHTML'); $content = $cache->call($callback, $user, $items); return $content; }
public function fetchElement($name, $value, &$node, $control_name) { $lang =& JFactory::getLanguage(); $lang->load('com_community', JPATH_ROOT); $model = CFactory::getModel('Groups'); $groups = $model->getAllGroups(); $fieldName = $control_name . '[' . $name . ']'; ob_start(); ?> <select name="<?php echo $fieldName; ?> "> <?php foreach ($groups as $group) { ?> <option value="<?php echo $group->id; ?> "<?php echo $value == $group->id ? ' selected="selected"' : ''; ?> ><?php echo $group->name; ?> </option> <?php } ?> </select> <?php $html = ob_get_contents(); ob_end_clean(); return $html; }
public function getFieldHTML($field, $required) { $class = $field->required == 1 ? ' required validate-custom-checkbox' : ''; $lists = is_array($field->value) ? $field->value : explode(',', $field->value); $html = ''; $elementSelected = 0; $elementCnt = 0; $style = ' style="margin: 0 5px 5px 0;' . $this->getStyle() . '" '; $cnt = 0; CFactory::load('helpers', 'string'); $class .= !empty($field->tips) ? ' jomNameTips tipRight' : ''; $html .= '<div class="' . $class . '" style="display: inline-block;" title="' . CStringHelper::escape(JText::_($field->tips)) . '">'; if (is_array($field->options)) { foreach ($field->options as $option) { $selected = in_array(JString::trim($option), $lists) ? ' checked="checked"' : ''; if (empty($selected)) { $elementSelected++; } $html .= '<label class="lblradio-block">'; $html .= '<input type="checkbox" name="field' . $field->id . '[]" value="' . $option . '"' . $selected . ' class="checkbox ' . $class . $style . ' />'; $html .= JText::_($option) . '</label>'; $elementCnt++; } } $html .= '<span id="errfield' . $field->id . 'msg" style="display: none;"> </span>'; $html .= '</div>'; return $html; }
$model = CFactory::getModel('Photos'); $photos = $model->getAllPhotos($albumId); $content .= '<div class="photoList">'; foreach ($photos as $rows) { $img = '<img src=\\"' . $rows->image . '\\" border=\\"0\\" alt=\\"Tree\\" />'; $content .= '<div class="picture">'; $content .= '<a href=\'#\' onClick=\'window.parent.jInsertEditorText("' . $img . '", "' . $e_name . '");window.parent.document.getElementById("sbox-window").close();return;\'>'; $content .= '<img src="' . $rows->thumbnail . '" alt="' . $rows->caption . '" border="0">'; $content .= '</a>'; $content .= '</div>'; } $content .= '<div style="clear:both;"></div></div>'; $response->addAssign('iFrameContent', 'innerHTML', $backButton . $content); return $response; } function ajaxGetAlbum($response, $e_name) { $response->addAssign('iFrameContent', 'innerHTML', $this->_getAlbumHTML($e_name)); return $response; } function _getAlbumHTML($e_name) { //Include language file JPlugin::loadLanguage('plg_editormyphotos', JPATH_ADMINISTRATOR); $user = JFactory::getUser(); $model = CFactory::getModel('photos'); $albums = $model->getAlbums($user->id, true, true); $content = '<div class="title">' . JText::_('ALBUM LIST') . '</div>'; if (count($albums) > 0) {
/** * Update the user status * * @param int user id * @param string the message. Should be < 140 char (controller check) */ function update($id, $status) { $db =& $this->getDBO(); $my = CFactory::getUser(); // @todo: posted_on should be constructed to make sure we take into account // of Joomla server offset // Current user and update id should always be the same CError::assert($my->id, $id, 'eq', __FILE__, __LINE__); // Trigger onStatusUpdate require_once COMMUNITY_COM_PATH . DS . 'libraries' . DS . 'apps.php'; $appsLib =& CAppPlugins::getInstance(); $appsLib->loadApplications(); $args = array(); $args[] = $my->id; // userid $args[] = $my->getStatus(); // old status $args[] = $status; // new status $appsLib->triggerEvent('onProfileStatusUpdate', $args); $today =& JFactory::getDate(); $data = new stdClass(); $data->userid = $id; $data->status = $status; $data->posted_on = $today->toMySQL(); $db->updateObject('#__community_users', $data, 'userid'); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } }
public function getavatar($filter) { // Get CUser object $user = CFactory::getUser($filter); $avatarUrl = $user->getThumbAvatar(); return $avatarUrl; }
/** * take an object with the send data * $recipient, $body, $subject, */ public function add($recipient, $subject, $body, $templateFile = '', $params = '', $status = 0, $email_type = '') { $my = CFactory::getUser(); // A user should not be getting a notification email of his own action $bookmarkStr = explode('.', $templateFile); if ($my->id == $recipient && $bookmarkStr[1] != 'bookmarks') { return $this; } $db =& $this->getDBO(); $date =& JFactory::getDate(); $obj = new stdClass(); $obj->recipient = $recipient; // This part does a url search in the email body for URL and automatically makes it a linked URL // pattern search must starts with www or protocal such as http or https $matchUrl = preg_match_all('/\\b(([\\w-]+:\\/\\/?|www[.])[^\\s()<>]+(?:\\([\\w\\d]+\\)|([^[:punct:]\\s]|\\/)))/', $body, $matching); if ($matchUrl !== false && $matchUrl > 0) { for ($i = 0; $i < $matchUrl; $i++) { $body = str_replace($matching[0][$i], '<a href="' . $matching[0][$i] . '">' . $matching[0][$i] . '</a>', $body); } } $obj->body = $body; $obj->subject = $subject; $obj->template = $templateFile; $obj->params = is_object($params) && method_exists($params, 'toString') ? $params->toString() : ''; $obj->created = $date->toMySQL(); $obj->status = $status; $obj->email_type = $email_type; $db->insertObject('#__community_mailq', $obj); return $this; }
/** * Check if 2 friends is connected or not * @param int userid1 * @param int userid2 * @return bool */ public static function isConnected($id1, $id2) { // Static caching for this session static $isFriend = array(); if (!empty($isFriend[$id1 . '-' . $id2])) { return $isFriend[$id1 . '-' . $id2]; } if ($id1 == $id2 && $id1 != 0) { return true; } if ($id1 == 0 || $id2 == 0) { return false; } /* $db =& JFactory::getDBO(); $sql = 'SELECT count(*) FROM ' . $db->nameQuote('#__community_connection') .' WHERE ' . $db->nameQuote('connect_from') .'=' . $db->Quote($id1) .' AND ' . $db->nameQuote('connect_to') .'=' . $db->Quote($id2) .' AND ' . $db->nameQuote('status') .' = ' . $db->Quote(1); $db->setQuery($sql); $result = $db->loadResult(); if($db->getErrorNum()) { JError::raiseError( 500, $db->stderr()); } $isFriend[$id1.'-'.$id2] = $result; */ // change method to get connection since list friends stored in community_users as well $user = CFactory::getUser($id1); $isConnected = $user->isFriendWith($id2); return $isConnected; }
public function insertFeaturedStream($activityId, $streamType, $targetId) { $my = CFactory::getUser(); // current user $featuredTable = JTable::getInstance('Featured', 'CTable'); //set the featured stream type $featuredType = ''; switch ($streamType) { case 'profile': case 'profiles': $featuredType = 'stream.profile'; break; case 'frontpage': $featuredType = 'stream.frontpage'; break; case 'event': case 'events': $featuredType = 'stream.event'; break; case 'group': case 'groups': $featuredType = 'stream.group'; break; default: return false; } $featuredTable->cid = $activityId; $featuredTable->type = $featuredType; $featuredTable->target_id = $targetId; $featuredTable->created_by = $my->id; $featuredTable->created = JFactory::getDate()->toSql(); return $featuredTable->store(); }