/** * Do a batch send */ function send($total = 100) { $mailqModel = CFactory::getModel('mailq'); $userModel = CFactory::getModel('user'); $mails = $mailqModel->get($total); $jconfig = JFactory::getConfig(); $mailer = JFactory::getMailer(); $config = CFactory::getConfig(); $senderEmail = $jconfig->getValue('mailfrom'); $senderName = $jconfig->getValue('fromname'); if (empty($mails)) { return; } CFactory::load('helpers', 'string'); foreach ($mails as $row) { // @rule: only send emails that is valid. // @rule: make sure recipient is not blocked! $userid = $userModel->getUserFromEmail($row->recipient); $user = CFactory::getUser($userid); if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) { $mailer->setSender(array($senderEmail, $senderName)); $mailer->addRecipient($row->recipient); $mailer->setSubject($row->subject); $tmpl = new CTemplate(); $raw = isset($row->params) ? $row->params : ''; $params = new JParameter($row->params); $base = $config->get('htmlemail') ? 'email.html' : 'email.text'; if ($config->get('htmlemail')) { $row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body); $mailer->IsHTML(true); } else { //@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags. $row->body = CStringHelper::escape(strip_tags($row->body)); } $tmpl->set('content', $row->body); $tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template')); $tmpl->set('sitename', $config->get('sitename')); $row->body = $tmpl->fetch($base); // Replace any occurences of custom variables within the braces scoe { } if (!empty($row->body)) { preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER); foreach ($matches as $val) { $replaceWith = $params->get($val[1], null); //if the replacement start with 'index.php', we can CRoute it if (strpos($replaceWith, 'index.php') === 0) { $replaceWith = CRoute::getExternalURL($replaceWith); } if (!is_null($replaceWith)) { $row->body = JString::str_ireplace($val[0], $replaceWith, $row->body); } } } unset($tmpl); $mailer->setBody($row->body); $mailer->send(); } $mailqModel->markSent($row->id); $mailer->ClearAllRecipients(); } }
private function jomsocialForm($external, $groupId = '0', $blogSource = '', $isPending = 0) { $my = JFactory::getUser(); $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; //extra checking incase somewhere still passing empty blogSource. $blogSource = empty($blogSource) ? 'group' : $blogSource; if (!JFile::exists($file)) { return false; } require_once $file; $model = CFactory::getModel('groups'); if (EasyBlogHelper::isSiteAdmin() && $isPending) { $rows = $model->getAllGroups(); } else { $rows = $model->getGroups($my->id, null, false); } $groups = array(); JTable::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'tables'); foreach ($rows as $row) { $group = JTable::getInstance('Group', 'CTable'); $group->load($row->id); $data = new stdClass(); $data->id = $group->id; $data->title = $group->name; $data->avatar = $group->getAvatar(); $groups[] = $data; } $theme = EB::template(); $theme->set('blogSource', $blogSource); $theme->set('external', $external); $theme->set('groups', $groups); $theme->set('groupId', $groupId); return $theme->output('site/jomsocial/groups'); }
function onProfileDisplay() { JPlugin::loadLanguage('plg_community_events', JPATH_ADMINISTRATOR); $config = CFactory::getConfig(); if (!$config->get('enableevents')) { return JText::_('PLG_EVENTS_EVENT_DISABLED'); } $document = JFactory::getDocument(); $mainframe = JFactory::getApplication(); $user = CFactory::getRequestUser(); $caching = $this->params->get('cache', 1); $model = CFactory::getModel('Events'); $my = CFactory::getUser(); $this->loadUserParams(); //CFactory::load( 'helpers' , 'event' ); $event = JTable::getInstance('Event', 'CTable'); $handler = CEventHelper::getHandler($event); $events = $model->getEvents(null, $user->id, $this->params->get('sorting', 'latest'), null, true, false, null, null, $handler->getContentTypes(), $handler->getContentId(), $this->userparams->get('count', 5)); if ($this->params->get('hide_empty', 0) && !count($events)) { return ''; } if ($caching) { $caching = $mainframe->getCfg('caching'); } $creatable = $my->canCreateEvents(); $cache = JFactory::getCache('plgCommunityEvents'); $cache->setCaching($caching); $callback = array($this, '_getEventsHTML'); $content = $cache->call($callback, true, $events, $user, $config, $model->getEventsCount($user->id), $creatable); 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 CommunityViewVideos() { //CFactory::load( 'helpers', 'videos' ); //CFactory::load( 'libraries' , 'videos' ); $this->model = CFactory::getModel('videos'); $this->videoLib = new CVideoLibrary(); }
public function __construct($event) { $this->my = CFactory::getUser(); $this->model = CFactory::getModel('events'); $this->event = $event; $this->url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $this->event->id; }
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; }
public static function getMediaPermission($groupId) { // load COwnerHelper::isCommunityAdmin() CFactory::load('helpers', 'owner'); $my = CFactory::getUser(); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); $isAdmin = false; $isMember = false; $waitingApproval = false; // Load the group table. $groupModel = CFactory::getModel('groups'); $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupId); $params = $group->getParams(); if (!$isSuperAdmin) { $isAdmin = $groupModel->isAdmin($my->id, $group->id); $isMember = $group->isMember($my->id); //check if awaiting group's approval if ($groupModel->isWaitingAuthorization($my->id, $group->id)) { $waitingApproval = true; } } $permission = new stdClass(); $permission->isMember = $isMember; $permission->waitingApproval = $waitingApproval; $permission->isAdmin = $isAdmin; $permission->isSuperAdmin = $isSuperAdmin; $permission->params = $params; $permission->privateGroup = $group->approvals; return $permission; }
function getGroupsData(&$params) { $model =& CFactory::getModel('groups'); $db =& JFactory::getDBO(); $count = $params->get('count', '5'); $sql = " SELECT\n\t\t\t\t\t\t" . $db->nameQuote('cid') . ",\n\t\t\t\t\t\tCOUNT(" . $db->nameQuote('cid') . ") AS " . $db->nameQuote('count') . " \n\t\t\t\t FROM\n\t\t\t\t\t\t" . $db->nameQuote('#__community_activities') . " a \n\t\t\t INNER JOIN\t" . $db->nameQuote('#__community_groups') . " b ON a." . $db->nameQuote('cid') . " = b." . $db->nameQuote('id') . " \n\t\t\t\t WHERE\n\t\t\t\t\t\ta." . $db->nameQuote('app') . " = " . $db->quote('groups') . " AND\n\t\t\t\t\t\tb." . $db->nameQuote('published') . " = " . $db->quote('1') . " AND\n\t\t\t\t\t\ta." . $db->nameQuote('archived') . " = " . $db->quote('0') . " AND\n\t\t\t\t\t\ta." . $db->nameQuote('cid') . " != " . $db->quote('0') . "\n\t\t\t GROUP BY a." . $db->nameQuote('cid') . "\n\t\t\t ORDER BY " . $db->nameQuote('count') . " DESC\n\t\t\t LIMIT " . $count; $query = $db->setQuery($sql); $row = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $_groups = array(); if (!empty($row)) { foreach ($row as $data) { $group = $model->getGroup($data->cid); if ($group->id) { $groupAvatar =& JTable::getInstance('group', 'CTable'); $groupAvatar->bind($group); $_obj = new stdClass(); $_obj->id = $group->id; $_obj->name = $group->name; $_obj->avatar = $groupAvatar->getThumbAvatar(); $_obj->totalMembers = $model->getMembersCount($group->id); $_groups[] = $_obj; } } } return $_groups; }
/** * Method is called during the status update triggers. **/ public function onProfileStatusUpdate($userid, $oldMessage, $newMessage) { $config = CFactory::getConfig(); $my = CFactory::getUser(); if ($config->get('fbconnectpoststatus')) { //CFactory::load( 'libraries' , 'facebook' ); $facebook = new CFacebook(); if ($facebook) { $fbuserid = $facebook->getUser(); $connectModel = CFactory::getModel('Connect'); $connectTable = JTable::getInstance('Connect', 'CTable'); $connectTable->load($fbuserid); // Make sure the FB session match the user session if ($connectTable->userid == $my->id) { /** * Check post status to facebook settings */ //echo "posting to facebook"; exit; $targetUser = CFactory::getUser($my->id); $userParams = $targetUser->getParams(); if ($userParams->get('postFacebookStatus')) { $result = $facebook->postStatus($newMessage); //print_r($result); exit; } } } } }
function deletewallpost($data) { require_once JPATH_SITE . '/components/com_community/libraries/core.php'; $error_messages = array(); $response = NULL; $validated = true; $db =& JFactory::getDBO(); if ($data['wall_id'] == "" || $data['wall_id'] == "0") { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "Wall id cannot be blank"); } //@rule: Check if user is really allowed to remove the current wall $my = CFactory::getUser(); $model =& CFactory::getModel('wall'); $wall = $model->get($data['wall_id']); $groupModel =& CFactory::getModel('groups'); $group =& JTable::getInstance('Group', 'CTable'); $group->load($wall->contentid); $query = "SELECT contentid FROM #__community_wall WHERE id ='" . $data['wall_id'] . "' AND type = 'groups'"; $db->setQuery($query); $contentid = $db->LoadResult(); CFactory::load('helpers', 'owner'); $query = "SELECT id FROM #__community_wall WHERE id ='" . $data['wall_id'] . "' AND type = 'groups'"; $db->setQuery($query); $isdiscussion = $db->LoadResult(); if (!$isdiscussion) { $error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "wall id for type groups does not exists. Modify the wall_id field"); } else { if (!$model->deletePost($data['wall_id'])) { $validated = false; //$error_messages[] = 'wall id does not exists. Modify the wall_id fields in request'; $error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "wall id does not exists. Modify the wall_id field"); } else { if ($wall->post_by != 0) { //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('wall.remove', $wall->post_by); } } //$groupModel->substractWallCount( $data['wall_id'] ); // Substract the count $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote('#__community_wall') . ' ' . 'WHERE contentid=' . $db->Quote($contentid) . ' ' . 'AND type="groups"'; $db->setQuery($query); $wall_count = $db->loadResult(); $wallcount = new stdClass(); $wallcount->id = $contentid; $wallcount->wallcount = $wall_count; $db->updateObject('#__community_groups', $wallcount, 'id'); } if (true == isset($error_messages) && 0 < sizeof($error_messages)) { $res = array(); foreach ($error_messages as $key => $error_message) { $res[] = $error_message; } $response = array("id" => 0, 'errors' => $res); } else { $response = array('id' => $wall->id); } return $response; }
function deletegroupmembers($data) { require_once JPATH_SITE . '/components/com_community/libraries/core.php'; CFactory::load('libraries', 'apps'); $error_messages = array(); $success_messages = array(); $response = NULL; $validated = true; if ("" == $data['groupid'] || 0 == $data['groupid']) { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "groupid", "message" => "Groupid cannot be blank"); } if (false == array_key_exists('memberids', $data) || 0 == sizeof($data['memberids'])) { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "memberids", "message" => "Memberids cannot be blank"); } if (true == $validated) { $model =& CFactory::getModel('groups'); $group =& JTable::getInstance('Group', 'CTable'); $group->id = $data['groupid']; $group->ownerid = $data['ownerid']; } if ($data['ownerid'] == $data['memberids']) { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "ownerid/memberid", "message" => "owner id and member id are same.please update 'ownwrid or memberid' fields in request"); } else { $groupMember =& JTable::getInstance('GroupMembers', 'CTable'); $memberId = $data['memberids']; $groupId = $data['groupid']; $groupMember->load($memberId, $groupId); $data = new stdClass(); $data->groupid = $groupId; $data->memberid = $memberId; $data = new stdClass(); $data->groupid = $groupId; $data->memberid = $memberId; $model->removeMember($data); $db =& JFactory::getDBO(); $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__community_groups_members') . ' ' . 'WHERE groupid=' . $db->Quote($groupId) . ' ' . 'AND approved=' . $db->Quote('1'); $db->setQuery($query); $membercount = $db->loadResult(); $members = new stdClass(); $members->id = $groupId; $members->membercount = $membercount; $db->updateObject('#__community_groups', $members, 'id'); //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('group.member.remove', $memberId); } if (true == isset($error_messages) && 0 < sizeof($error_messages)) { $res = array(); foreach ($error_messages as $key => $error_message) { $res[] = $error_message; } $response = array("id" => 0, 'errors' => $res); } else { $response = array('id' => $memberId); } return $response; }
public function get() { $user = $this->plugin->get('user'); $model = CFactory::getModel('Activities'); $activities = $model->getActivities($user->get('id'), '', '', 20, false); $this->plugin->setResponse($activities); }
function getGroupsData(&$params) { $model = CFactory::getModel('groups'); $db = JFactory::getDBO(); $count = $params->get('count', '5'); $query = 'SELECT *, (a.' . $db->quoteName('discusscount') . ' + a.' . $db->quoteName('wallcount') . ' ) AS count FROM ' . $db->quoteName('#__community_groups') . ' as a' . ' INNER JOIN ' . $db->quoteName('#__community_groups_members') . ' AS b ON a.' . $db->quoteName('id') . '= b.' . $db->quoteName('groupid') . ' WHERE a.' . $db->quoteName('published') . ' = ' . $db->Quote('1') . ' GROUP BY a.' . $db->quoteName('id') . ' ORDER BY ' . $db->quoteName('count') . ' DESC ' . ' LIMIT 0, ' . $count; $db->setQuery($query); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $_groups = array(); /** * @todo No need use JTable to get group JTable object again */ if (!empty($rows)) { foreach ($rows as $row) { $group = $model->getGroup($row->id); if ($group->id) { $groupAvatar = JTable::getInstance('group', 'CTable'); $groupAvatar->bind($group); $_obj = new stdClass(); $_obj->id = $group->id; $_obj->name = $group->name; $_obj->avatar = $groupAvatar->getThumbAvatar(); $_obj->totalMembers = count($model->getMembers($group->id, NULL, true, false, true)); //$_obj->totalMembers = $model->getMembersCount($group->id); $_groups[] = $_obj; } } } return $_groups; }
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; }
/** * Private method. DO NOT call this method directly. * Return points for various actions. Return value should be configurable from the backend. */ public function _getActionPoint($action, $aid = 0) { include_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'userpoints.php'; $userPoint = ''; if (class_exists('CFactory')) { $userPoint = CFactory::getModel('userpoints'); } else { $userPoint = new CommunityModelUserPoints(); } $point = 0; $upObj = $userPoint->getPointData($action); if (!empty($upObj)) { $published = $upObj->published; $access = $upObj->access; if (is_array($aid)) { //joomla 1.6 if (in_array($access, $aid)) { $point = $upObj->points; } } else { //joomla 1.5 and older $userAccess = empty($aid) ? 0 : $aid; if ($access <= $userAccess) { $point = $upObj->points; } } if ($published == '0') { $point = 0; } } return $point; }
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 onSave($user = null, $customer = null, $address = null) { // Preliminary checks if ($user == null || $customer == null) { return false; } // Get system variables $db = JFactory::getDBO(); // Get the user-fields from the database $db->setQuery('SELECT id,fieldcode FROM #__community_fields WHERE fieldcode != ""'); $fields = $db->loadObjectList(); if (empty($fields)) { return false; } // Add the customer values $field_values = array(); if (!empty($customer)) { foreach ($customer as $name => $value) { $newname = $this->convertField($name, self::CONVERT_TO_JOOMLA); foreach ($fields as $field) { if ($field->fieldcode == $newname) { $field_values[$field->id] = $value; break; } } } } // Save the user include_once JPATH_ROOT . '/components/com_community/libraries/core.php'; include_once JPATH_ROOT . '/components/com_community/models/profile.php'; $model = CFactory::getModel('profile'); $model->saveProfile($user->id, $field_values); return true; }
public function onFriendApprove($obj) { // Update friends count $friendsModel = CFactory::getModel('friends'); $friendsModel->updateFriendCount($obj->profileOwnerId); $friendsModel->updateFriendCount($obj->friendId); }
private function _getFriends($userid, $limit) { $db = JFactory::getDBO(); $query = 'SELECT ' . $db->quoteName('connect_from') . ' AS ids ' . 'FROM ' . $db->quoteName('#__community_connection') . ' ' . 'WHERE ' . $db->quoteName('connect_to') . '=' . $db->Quote($userid) . ' ' . 'AND ' . $db->quoteName('status') . '=' . $db->Quote(1); if ($limit != 0) { $query .= " LIMIT " . $limit; } $db->setQuery($query); $friends = $db->loadColumn(); $result = array(); $my = CFactory::getUser(); $model = CFactory::getModel('Friends'); $userFriends = $model->getFriendIds($userid); foreach ($friends as $friendId) { $user = CFactory::getUser($friendId); $params = $user->getParams(); $privacy = $params->get('privacyProfileView'); if ($my->id == $userid) { $result[] = $friendId; } if ($privacy == 0) { $result[] = $friendId; } else { if ($privacy == 20 && $my->id != 0) { $result[] = $friendId; } else { if ($privacy == 30 && in_array($my->id, $userFriends)) { $result[] = $friendId; } } } } return array_unique($result); }
public function onGroupJoin($group, $userId) { //@rule: Clear existing invites fromt he invitation table once the user joined the group $groupInvite =& JTable::getInstance('GroupInvite', 'CTable'); if ($groupInvite->load($group->id, $userId)) { $groupInvite->delete(); } $member =& JTable::getInstance('GroupMembers', 'CTable'); $member->load($userId, $group->id); $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->getDisplayName(), $group->name); if (!$member->approved) { $subject = JText::sprintf('COM_COMMUNITY_NEW_MEMBER_REQUESTED_TO_JOIN_GROUP_EMAIL_SUBJECT', $user->getDisplayName(), $group->name); } // Add notification CFactory::load('libraries', 'notification'); $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('user', $user->getDisplayName()); $params->set('approved', $member->approved); foreach ($admins as $admin) { CNotificationLibrary::add('etype_groups_member_join', $user->id, $admin->id, $subject, '', 'groups.memberjoin', $params); } } }
public function getInput() { // Check if JomSocial core file exists $corefile = JPATH_ROOT . '/components/com_community/libraries/core.php'; jimport('joomla.filesystem.file'); if (!JFile::exists($corefile)) { return; } require_once $corefile; /* Create the Application */ $app = JFactory::getApplication('site'); jimport('joomla.application.module.helper'); $model = CFactory::getModel('groups'); //$groups = $model->getAllGroups(null, null, null, null, false,false, false); $db = JFactory::getDbo(); $query = "SELECT * FROM " . $db->quoteName('#__community_groups') . " WHERE " . $db->quoteName('published') . '=' . $db->quote(1); $db->setQuery($query); $groups = $db->loadObjectList(); $value = ''; if (!count($groups)) { return; } foreach ($groups as $group) { $selected = !empty($this->value) && in_array($group->id, $this->value) ? 'selected' : ''; $value .= '<option ' . $selected . ' value="' . $group->id . '" >' . $group->name . '</option>'; } return '<select multiple id="' . $this->id . '" name="' . $this->name . '">' . $value . '</select>'; }
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 get() { $user = $this->plugin->get('user'); $model = CFactory::getModel('Photos'); $albums = $model->getAllAlbums($user->get('id')); $this->plugin->setResponse($albums); }
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; }
/** * Return points for various actions. Return value should be configurable from the backend * */ function getActionPoint($action, $gid = 0) { include_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'userpoints.php'; $userPoint = ''; if (class_exists('CFactory')) { $userPoint = CFactory::getModel('userpoints'); } else { $userPoint = new CommunityModelUserPoints(); } $point = 0; $upObj = $userPoint->getPointData($action); if (!empty($upObj)) { $published = $upObj->published; $point = $upObj->points; $access = $upObj->access; if ($published == '0') { $point = 0; } else { if ($access != $gid) { $point = 0; } } } return $point; }
$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) {
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; } }
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; }
/** * Adds a notification item in JomSocial * * @access public * @param TableBlog $blog The blog table. */ public function addNotification($title, $type, $target, $author, $link) { jimport('joomla.filesystem.file'); // @since this only works with JomSocial 2.6, we need to test certain files. $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'notificationtypes.php'; if (!$this->exists || empty($target) || $target[0] == $author->getId() || !JFile::exists($file)) { return false; } CFactory::load('helpers', 'notificationtypes'); CFactory::load('helpers', 'content'); CFactory::load('libraries', 'notificationtypes'); // @task: Set the necessary parameters first. $params = EasyBlogHelper::getRegistry(''); $params->set('url', str_replace("administrator/", "", $author->getProfileLink())); // @task: Obtain model from jomsocial. $model = CFactory::getModel('Notification'); // @task: Currently we are not using this, so we should just skip this. $requireAction = 0; if (!is_array($target)) { $target = array($target); } foreach ($target as $targetId) { JTable::addIncludePath(JPATH_ROOT . '/components/com_community/tables'); $notification = JTable::getInstance('Notification', 'CTable'); $notification->actor = $author->getId(); $notification->target = $targetId; $notification->content = $title; $notification->created = EasyBlogHelper::getDate()->toMySQL(); $notification->params = $params->toString(); $notification->cmd_type = CNotificationTypesHelper::convertNotifId($type); $notification->type = 0; $notification->store(); } return true; }