/** * 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 setImage($path, $type = 'thumb') { CError::assert($path, '', '!empty', __FILE__, __LINE__); $db = $this->getDBO(); // Fix the back quotes $path = CString::str_ireplace('\\', '/', $path); $type = JString::strtolower($type); // Test if the record exists. $oldFile = $this->{$type}; if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } if ($oldFile) { // File exists, try to remove old files first. $oldFile = CString::str_ireplace('/', '/', $oldFile); // If old file is default_thumb or default, we should not remove it. // // Need proper way to test it if (!JString::stristr($oldFile, 'group.jpg') && !JString::stristr($oldFile, 'group_thumb.jpg') && !JString::stristr($oldFile, 'default.jpg') && !JString::stristr($oldFile, 'default_thumb.jpg')) { jimport('joomla.filesystem.file'); JFile::delete($oldFile); } } $this->{$type} = $path; $this->store(); }
public function onDiscussionDisplay($row) { CError::assert($row->message, '', '!empty', __FILE__, __LINE__); // @rule: Only nl2br text that doesn't contain html tags if (!CStringHelper::isHTML($row->message)) { $row->message = CStringHelper::nl2br($row->message); } }
function onDiscussionDisplay(&$row) { CError::assert($row->message, '', '!empty', __FILE__, __LINE__); $config = CFactory::getConfig(); // If editor is disabled, we only want to replace newlines with BR otherwise it doesn't make any sense to replace so many br if ($config->get('editor') == '0') { $row->message = $this->_filterText($row->message); } }
public function onMessageDisplay($row) { CFactory::load('helpers', 'string'); CError::assert($row->body, '', '!empty', __FILE__, __LINE__); // @rule: Only nl2br text that doesn't contain html tags if (!CStringHelper::isHTML($row->body)) { $row->body = CStringHelper::nl2br($row->body); } }
public function onWallDisplay($row) { //CFactory::load( 'helpers' , 'string' ); CError::assert($row->comment, '', '!empty', __FILE__, __LINE__); // @rule: Only nl2br text that doesn't contain html tags if (!CStringHelper::isHTML($row->comment)) { $row->comment = CStringHelper::nl2br($row->comment); } }
public function onWallDisplay($row) { //CFactory::load( 'helpers' , 'string' ); CError::assert($row->comment, '', '!empty', __FILE__, __LINE__); // @rule: Only nl2br text that doesn't contain html tags //@since 4.1 new rule added, to ignore newline replace if (!CStringHelper::isHTML($row->comment) && !isset($row->newlineReplace)) { $row->comment = CStringHelper::nl2br($row->comment); } }
/** * Add new activity, * @access static * */ function add($activity, $params = '', $points = 1) { CError::assert($activity, '', '!empty', __FILE__, __LINE__); // If params is an object, instead of a string, we convert it to string $cmd = !empty($activity->cmd) ? $activity->cmd : ''; if (!empty($cmd)) { $userPointModel = CFactory::getModel('Userpoints'); // Test command, with userpoint command. If is unpublished do not proceed into adding to activity stream. $point = $userPointModel->getPointData($cmd); if ($point && !$point->published) { return; } } $actor = !empty($activity->actor) ? $activity->actor : ''; $target = !empty($activity->target) ? $activity->target : 0; $title = !empty($activity->title) ? $activity->title : ''; $content = !empty($activity->content) ? $activity->content : ''; $appname = !empty($activity->app) ? $activity->app : ''; $cid = !empty($activity->cid) ? $activity->cid : 0; $points = !empty($activity->points) ? $activity->points : $points; $access = !empty($activity->access) ? $activity->access : 0; // If the params in embedded within the activity object, use it // if it is not explicitly overriden if (empty($params) && !empty($activity->params)) { $params = $activity->params; } include_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'activities.php'; if (class_exists('CFactory')) { $activities = CFactory::getModel('activities'); } else { $activities = new CommunityModelActivities(); } // Update access for activity based on the user's profile privacy if (!empty($actor) && $actor != 0) { $user = CFactory::getUser($actor); $userParams = $user->getParams(); $profileAccess = $userParams->get('privacyProfileView'); // Only overwrite access if the user global profile privacy is higher // BUT, if access is defined as PRIVACY_FORCE_PUBLIC, do not modify it if ($access != PRIVACY_FORCE_PUBLIC && $profileAccess > $access) { $access = $profileAccess; } } $activities->add($actor, $target, $title, $content, $appname, $cid, $params, $points, $access); }
public static function build($view, $task = '', $keys = null, $route = true) { // View cannot be empty. Assertion must be included here. CError::assert($view, '', '!empty', __FILE__, __LINE__); $url = 'index.php?option=com_community&view=' . $view; // Task might be optional $url .= !empty($task) ? '&task=' . $task : ''; if (!is_null($keys) && is_array($keys)) { foreach ($keys as $key => $value) { $url .= '&' . $key . '=' . $value; } } // Test if it needs JRoute if ($route) { return CRoute::_($url); } return $url; }
/** * Set the avatar for specific application. Caller must have a database table * that is named after the appType. E.g, users should have jos_community_users * * @param appType Application type. ( users , groups ) * @param path The relative path to the avatars. * @param type The type of Image, thumb or avatar. * **/ function setImage($id, $path, $type = 'thumb') { CError::assert($id, '', '!empty', __FILE__, __LINE__); CError::assert($path, '', '!empty', __FILE__, __LINE__); $db =& $this->getDBO(); // Fix the back quotes $path = JString::str_ireplace('\\', '/', $path); $type = JString::strtolower($type); // Test if the record exists. $query = 'SELECT ' . $db->nameQuote($type) . ' FROM ' . $db->nameQuote('#__community_users') . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id); $db->setQuery($query); $oldFile = $db->loadResult(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } if (!$oldFile) { $query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($path) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id); $db->setQuery($query); $db->query($query); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } } else { $query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($path) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id); $db->setQuery($query); $db->query($query); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } // If old file is default_thumb or default, we should not remove it. // Need proper way to test it if (!Jstring::stristr($oldFile, 'components/com_community/assets/default.jpg') && !Jstring::stristr($oldFile, 'components/com_community/assets/default_thumb.jpg')) { // File exists, try to remove old files first. $oldFile = JString::str_ireplace('/', DS, $oldFile); JFile::delete($oldFile); } } }
/** * Formats the comment in the rows * * @param Array An array of wall objects **/ function triggerWallComments(&$rows) { CError::assert($rows, 'array', 'istype', __FILE__, __LINE__); require_once COMMUNITY_COM_PATH . DS . 'libraries' . DS . 'apps.php'; $appsLib =& CAppPlugins::getInstance(); $appsLib->loadApplications(); for ($i = 0; $i < count($rows); $i++) { $args = array(); $args[] =& $rows[$i]; $appsLib->triggerEvent('onWallDisplay', $args); } return true; }
function _groupAlbum() { CFactory::load('models', 'photos'); CFactory::load('helpers', 'friends'); CFactory::load('models', 'groups'); $mainframe =& JFactory::getApplication(); $document =& JFactory::getDocument(); $config = CFactory::getConfig(); $my = CFactory::getUser(); $model = CFactory::getModel('photos'); $groupModel = CFactory::getModel('groups'); $albumId = JRequest::getInt('albumid', '', 'GET'); $defaultId = JRequest::getVar('photo', '', 'GET'); $groupId = JRequest::getInt('groupid', '', 'REQUEST'); $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupId); if (empty($albumId)) { echo JText::_('CC NO PROPER ALBUM ID'); return; } CFactory::load('helpers', 'owner'); //@rule: Do not allow non members to view albums for private group if ($group->approvals == COMMUNITY_PRIVATE_GROUP && !$group->isMember($my->id) && !$group->isAdmin($my->id) && !COwnerHelper::isCommunityAdmin()) { // Set document title $document->setTitle(JText::_('CC RESTRICTED ACCESS')); $mainframe->enqueueMessage(JText::_('CC RESTRICTED ACCESS', 'notice')); echo JText::_('CC ALBUM NEED GROUP MEMBER PERMISSION'); return; } $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); // Set document title CFactory::load('helpers', 'string'); $document->setTitle(JText::sprintf('CC USER PHOTOS TITLE', $group->name) . ' - ' . $album->name); $this->setTitle($album->name); $pathway =& $mainframe->getPathway(); $pathway->addItem($album->name, ''); CError::assert($group, 'object', 'istype', __FILE__, __LINE__); // Get list of photos and set some limit to be displayed. // @todo: make limit configurable? $photos = $model->getAllPhotos($albumId, PHOTOS_GROUP_TYPE, null, null, COMMUNITY_ORDER_BY_DESC, COMMUNITY_ORDERING_BY_CREATED); // Need to append the absolute path for the captions for ($i = 0; $i < count($photos); $i++) { $item =& JTable::getInstance('Photo', 'CTable'); $item->bind($photos[$i]); $photos[$i] = $item; $photo =& $photos[$i]; $photo->link = CRoute::_('index.php?option=com_community&view=photos&task=photo&groupid=' . $groupId . '&albumid=' . $photo->albumid) . '#photoid=' . $photo->id; } CFactory::load('helpers', 'group'); $allowManagePhotos = CGroupHelper::allowManagePhoto($groupId); if (($group->isAdmin($my->id) || $allowManagePhotos) && $my->id != 0) { $this->addSubmenuItem('index.php?option=com_community&view=photos&task=uploader&albumid=' . $album->id . '&groupid=' . $group->id, JText::_('CC UPLOAD PHOTOS'), '', true); $this->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $group->id, JText::_('CC ADD ALBUM'), '', true); } $tmpl = new CTemplate(); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $group->id)); $bookmarksHTML = $bookmarks->getHTML(); $tmpl->set('bookmarksHTML', $bookmarksHTML); $tmpl->set('isOwner', $group->isAdmin($my->id)); $tmpl->set('photos', $photos); $tmpl->set('album', $album); echo $tmpl->fetch('photos.album'); }
/** * Displays specific groups **/ public function viewGroup($group) { $mainframe =& JFactory::getApplication(); CFactory::load('libraries', 'tooltip'); CFactory::load('libraries', 'wall'); CFactory::load('libraries', 'window'); CFactory::load('libraries', 'videos'); CFactory::load('libraries', 'activities'); CFactory::load('helpers', 'group'); CWindow::load(); $config = CFactory::getConfig(); $document = JFactory::getDocument(); $groupLib = new CGroups(); // Load appropriate models $groupModel = CFactory::getModel('groups'); $wallModel = CFactory::getModel('wall'); $userModel = CFactory::getModel('user'); $discussModel = CFactory::getModel('discussions'); $bulletinModel = CFactory::getModel('bulletins'); $photosModel = CFactory::getModel('photos'); $activityModel = CFactory::getModel('activities'); //$groupid = JRequest::getInt( 'groupid' , '' ); //CError::assert( $groupid , '' , '!empty' , __FILE__ , __LINE__ ); $editGroup = JRequest::getVar('edit', false, 'GET'); $editGroup = $editGroup == 1 ? true : false; $params = $group->getParams(); CFactory::load('helpers', 'string'); $document->setMetaData('title', CStringHelper::escape($group->name)); $document->setMetaData('description', CStringHelper::escape(strip_tags($group->description))); $document->addCustomTag('<link rel="image_src" href="' . JURI::root() . $group->thumb . '" />'); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { $this->_redirectUnpublishGroup(); return; } // Show submenu $this->showSubmenu(); // Set the group info to contain proper <br> $group->description = nl2br($group->description); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_NAME_TITLE', $group->name), ''); // Load the current browsers data $my = CFactory::getUser(); // If user are invited $isInvited = $groupModel->isInvited($my->id, $group->id); // Get members list for display //$members = $groupModel->getAllMember($group->id); //Set limit for member listing on view group page $limit = 12; $approvedMembers = $groupModel->getMembers($group->id, $limit, true, false, true); CError::assert($approvedMembers, 'array', 'istype', __FILE__, __LINE__); $membersCount = $groupModel->total; // Is there any my friend is the member of this group? $join = ''; $friendsCount = 0; if ($isInvited) { // Get the invitors $invitors = $groupModel->getInvitors($my->id, $group->id); if (count($invitors) == 1) { $user = CFactory::getUser($invitors[0]->creator); $join = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { for ($i = 0; $i < count($invitors); $i++) { $user = CFactory::getUser($invitors[$i]->creator); if ($i + 1 == count($invitors)) { $join .= ' ' . JText::_('COM_COMMUNITY_AND') . ' ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { $join .= ', ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } } } // Get users friends in this group $friendsCount = $groupModel->getFriendsCount($my->id, $group->id); } $admins = $groupModel->getAdmins($group->id, $limit, CC_RANDOMIZE); // Get list of unapproved members $groupModel->getMembers($group->id, null, false); $unapproved = $groupModel->total; //Get list of approved members // Test if the current user is admin $isAdmin = $groupModel->isAdmin($my->id, $group->id); // Test if the current browser is a member of the group $isMember = $groupModel->isMember($my->id, $group->id); $waitingApproval = false; // Test if the current user is banned from this group $isBanned = $group->isBanned($my->id); // Attach avatar of the member // Pre-load multiple users at once $userids = array(); $limitloop = $limit; foreach ($approvedMembers as $uid) { $userids[] = $uid->id; if (--$limitloop < 1) { break; } } CFactory::loadUsers($userids); $limitloop = $limit; for ($i = 0; $i < count($approvedMembers); $i++) { $row =& $approvedMembers[$i]; $approvedMembers[$i] = CFactory::getUser($row->id); if (--$limitloop < 1) { break; } } if ($isBanned) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_MEMBER_BANNED'), 'error'); } // If I have tried to join this group, but not yet approved, display a notice if ($groupModel->isWaitingAuthorization($my->id, $group->id)) { $waitingApproval = true; } // Get the walls if (!$isBanned) { $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group'); } else { $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group', null, '1'); } $wallCount = CWallLibrary::getWallCount('groups', $group->id); $viewAllLink = false; if (JRequest::getVar('task', '', 'REQUEST') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=app&groupid=' . $group->id . '&app=walls'); } $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); $wallForm = ''; CFactory::load('helpers', 'owner'); if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && ($isMember && !$isBanned) && !$waitingApproval || COwnerHelper::isCommunityAdmin()) { $wallForm = CWallLibrary::getWallInputForm($group->id, 'groups,ajaxSaveWall', 'groups,ajaxRemoveWall'); } // Get like CFactory::load('libraries', 'like'); $likes = new CLike(); $likesHTML = $isMember && !$isBanned ? $likes->getHTML('groups', $group->id, $my->id) : $likes->getHtmlPublic('groups', $group->id); // Get discussions data $discussionData = $this->_cachedCall('_getDiscussionListHTML', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $discussionsHTML = $discussionData['HTML']; $totalDiscussion = $discussionData['total']; $discussions = $discussionData['data']; // Get bulletins data $bulletinData = $this->_cachedCall('_getBulletinListHTML', array($group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $totalBulletin = $bulletinData['total']; $bulletinsHTML = $bulletinData['HTML']; $bulletins = $bulletinData['data']; // Get album data $albumData = $this->_cachedCall('_getAlbums', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $albums = $albumData['data']; $totalAlbums = $albumData['total']; // Get video data $videoData = $this->_getVideos($params, $group->id); $videos = $videoData['data']; $totalVideos = $videoData['total']; $tmpl = new CTemplate(); // Get categories list // We should really load this in saperate file // @todo: editing group should really open a new page if ($my->id == $group->ownerid || COwnerHelper::isCommunityAdmin()) { $categories = $groupModel->getCategories(); CError::assert($categories, 'array', 'istype', __FILE__, __LINE__); $tmpl->set('categories', $categories); } $isMine = $my->id == $group->ownerid; // Get reporting html CFactory::load('libraries', 'reporting'); $report = new CReportingLibrary(); $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_REPORT_GROUP'), 'groups,reportGroup', array($group->id)); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '1' && !$isMine && !$isMember && !$isSuperAdmin) { $this->addWarning(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE')); } $videoThumbWidth = CVideoLibrary::thumbSize('width'); $videoThumbHeight = CVideoLibrary::thumbSize('height'); $eventsModel = CFactory::getModel('Events'); $tmpEvents =& $eventsModel->getGroupEvents($group->id, $params->get('grouprecentevents', GROUP_EVENT_RECENT_LIMIT)); $totalEvents = $eventsModel->getTotalGroupEvents($group->id); $events = array(); foreach ($tmpEvents as $event) { $table =& JTable::getInstance('Event', 'CTable'); $table->bind($event); $events[] = $table; } $allowManagePhotos = CGroupHelper::allowManagePhoto($group->id); $allowManageVideos = CGroupHelper::allowManageVideo($group->id); $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $group->id); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id)); $bookmarksHTML = $bookmarks->getHTML(); $isCommunityAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '0' || $isMine || $isMember && !$isBanned || $isCommunityAdmin) { // Set feed url $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletins&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_BULLETIN_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_DISCUSSION_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=photos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_PHOTOS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_VIDEOS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=events&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_EVENTS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); } $friendsModel = CFactory::getModel('Friends'); $groupsModel = CFactory::getModel('Groups'); CFactory::load('libraries', 'invitation'); $inviteHTML = CInvitation::getHTML(null, 'groups,inviteUsers', $group->id); // Add tagging code /* $tagsHTML = ''; if($config->get('tags_groups')){ CFactory::load('libraries', 'tags'); $tags = new CTags(); $tagsHTML = $tags->getHTML('groups', $group->id, $isAdmin ); } */ // Upgrade wall to stream @since 2.5 if (!$params->get('stream', FALSE)) { $group->upgradeWallToStream(); } // Add custom stream $activities = new CActivities(); $streamHTML = $groupLib->getStreamHTML($group); $totalStream = $activityModel->getTotalActivities(array("`groupid` = '{$group->id}'")); CFactory::load('libraries', 'userstatus'); $creators = array(); $creators[] = CUserStatusCreator::getMessageInstance(); if ($isAdmin && $params->get('photopermission') == 1 || $isMember && $params->get('photopermission') == 2) { $creators[] = CUserStatusCreator::getPhotoInstance(); } if ($isAdmin && $params->get('videopermission') == 1 || $isMember && $params->get('videopermission') == 2) { $creators[] = CUserStatusCreator::getVideoInstance(); } if ($allowCreateEvent && $config->get('group_events') && $config->get('enableevents') && ($config->get('createevents') || COwnerHelper::isCommunityAdmin())) { $creators[] = CUserStatusCreator::getEventInstance(); } $status = new CUserStatus($group->id, 'groups', $creators); // Get Event Admins $groupAdmins = $group->getAdmins(12, CC_RANDOMIZE); $adminsInArray = array(); // Attach avatar of the admin for ($i = 0; $i < count($groupAdmins); $i++) { $row =& $groupAdmins[$i]; $admin = CFactory::getUser($row->id); array_push($adminsInArray, '<a href="' . CUrlHelper::userLink($admin->id) . '">' . $admin->getDisplayName() . '</a>'); } $adminsList = ltrim(implode(', ', $adminsInArray), ','); echo $tmpl->setMetaTags('group', $group)->set('streamHTML', $streamHTML)->set('status', $status)->set('likesHTML', $likesHTML)->set('events', $events)->set('totalEvents', $totalEvents)->set('inviteHTML', $inviteHTML)->set('showEvents', $config->get('group_events') && $config->get('enableevents'))->set('showPhotos', $params->get('photopermission') != -1)->set('showVideos', $params->get('videopermission') != -1)->set('bookmarksHTML', $bookmarksHTML)->set('allowManagePhotos', $allowManagePhotos)->set('allowManageVideos', $allowManageVideos)->set('allowCreateEvent', $allowCreateEvent)->set('videos', $videos)->set('videoThumbWidth', $videoThumbWidth)->set('videoThumbHeight', $videoThumbHeight)->set('totalVideos', $totalVideos)->set('albums', $albums)->set('totalAlbums', $totalAlbums)->set('reportHTML', $reportHTML)->set('editGroup', $editGroup)->set('waitingApproval', $waitingApproval)->set('config', $config)->set('my', $my)->set('isMine', $isMine)->set('isAdmin', $isAdmin)->set('isSuperAdmin', $isSuperAdmin)->set('isMember', $isMember)->set('isInvited', $isInvited)->set('friendsCount', $friendsCount)->set('join', $join)->set('unapproved', $unapproved)->set('membersCount', $membersCount)->set('group', $group)->set('totalBulletin', $totalBulletin)->set('totalDiscussion', $totalDiscussion)->set('totalVideos', $totalVideos)->set('members', $approvedMembers)->set('bulletins', $bulletins)->set('wallForm', $wallForm)->set('wallContent', $wallContent)->set('discussions', $discussions)->set('discussionsHTML', $discussionsHTML)->set('bulletinsHTML', $bulletinsHTML)->set('isCommunityAdmin', $isCommunityAdmin)->set('isBanned', $isBanned)->set('isPrivate', $group->approvals)->set('limit', $limit)->set('adminsList', $adminsList)->set('alertNewDiscussion', $my->count('group_discussion_' . $group->id) != $totalDiscussion)->set('alertNewBulletin', $my->count('group_bulletin_' . $group->id) != $totalBulletin)->set('alertNewStream', $my->count('group_activity_' . $group->id) != $totalStream)->fetch('groups.viewgroup'); // Update stream count cache, can only set this after we've set the alert aove $my->setCount('group_activity_' . $group->id, $totalStream); }
public function _getFieldIdFromFieldCode($code) { CError::assert($code, '', '!empty', __FILE__, __LINE__); $db = $this->getDBO(); $query = 'SELECT' . $db->quoteName('id') . ' ' . 'FROM ' . $db->quoteName('#__community_fields') . ' ' . 'WHERE ' . $db->quoteName('fieldcode') . '=' . $db->Quote($code); $db->setQuery($query); $id = $db->loadResult(); CError::assert($id, '', '!empty', __FILE__, __LINE__); return $id; }
public function triggerEvent($eventName, &$args, $target = null) { CError::assert($args, 'object', 'istype', __FILE__, __LINE__); require_once COMMUNITY_COM_PATH . '/libraries/apps.php'; $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $params = array(); $params[] = $args; if (!is_null($target)) { $params[] = $target; } $appsLib->triggerEvent($eventName, $params); return true; }
private function _manipulateParameter($groupid, $eventid, $config) { if ($groupid) { $allowManageVideos = CGroupHelper::allowManageVideo($groupid); CError::assert($allowManageVideos, '', '!empty', __FILE__, __LINE__); $creatorType = VIDEO_GROUP_TYPE; $videoLimit = $config->get('groupvideouploadlimit'); } elseif ($eventid) { $creatorType = VIDEO_EVENT_TYPE; $videoLimit = $config->get('eventvideouploadlimit'); } else { $creatorType = VIDEO_USER_TYPE; $videoLimit = $config->get('videouploadlimit'); } return array($creatorType, $videoLimit); }
/** * Controller method to remove a video **/ public function deleteVideo($videoId = 0, $redirect = true) { if ($this->blockUnregister()) { return; } // Load libraries CFactory::load('models', 'videos'); $video = JTable::getInstance('Video', 'CTable'); $mainframe = JFactory::getApplication(); $video->load((int) $videoId); if (!empty($video->groupid)) { CFactory::load('helpers', 'group'); $allowManageVideos = CGroupHelper::allowManageVideo($video->groupid); CError::assert($allowManageVideos, '', '!empty', __FILE__, __LINE__); } // @rule: Add point when user removes a video CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('video.remove', $video->creator); if ($video->delete()) { // Delete all videos related data $this->_deleteVideoWalls($video->id); $this->_deleteVideoActivities($video->id); $this->_deleteFeaturedVideos($video->id); $this->_deleteVideoFiles($video); $this->_deleteProfileVideo($video->creator, $video->id); if (!empty($video->groupid)) { $message = JText::sprintf('CC VIDEO REMOVED', $video->title); $redirect = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $video->groupid, false); } else { $message = JText::sprintf('CC VIDEO REMOVED', $video->title); $redirect = CRoute::_('index.php?option=com_community&view=videos', false); } /** HTGMOD **/ $this->_triggerEvent('onAfterVideoDelete', $video); /** END HTGMOD **/ } if ($redirect === true) { $mainframe->redirect($redirect, $message); } return $message; }
/** * Add new activity, * @access static * */ public function add($activity, $params = '', $points = 1) { CError::assert($activity, '', '!empty', __FILE__, __LINE__); // If params is an object, instead of a string, we convert it to string $cmd = !empty($activity->cmd) ? $activity->cmd : ''; if (!empty($cmd)) { $userPointModel = CFactory::getModel('Userpoints'); // Test command, with userpoint command. If is unpublished do not proceed into adding to activity stream. $point = $userPointModel->getPointData($cmd); if ($point && !$point->published) { return; } } $actor = !empty($activity->actor) ? $activity->actor : ''; $target = !empty($activity->target) ? $activity->target : 0; $title = !empty($activity->title) ? $activity->title : ''; $content = !empty($activity->content) ? $activity->content : ''; $appname = !empty($activity->app) ? $activity->app : ''; $cid = !empty($activity->cid) ? $activity->cid : 0; $groupid = !empty($activity->groupid) ? $activity->groupid : 0; $group_access = !empty($activity->group_access) ? $activity->group_access : 0; $event_access = !empty($activity->event_access) ? $activity->event_access : 0; $eventid = !empty($activity->eventid) ? $activity->eventid : 0; $points = !empty($activity->points) ? $activity->points : $points; $access = !empty($activity->access) ? $activity->access : 0; $location = !empty($activity->location) ? $activity->location : ''; $comment_id = !empty($activity->comment_id) ? $activity->comment_id : 0; $comment_type = !empty($activity->comment_type) ? $activity->comment_type : ''; $like_id = !empty($activity->like_id) ? $activity->like_id : 0; $like_type = !empty($activity->like_type) ? $activity->like_type : ''; // If the params in embedded within the activity object, use it // if it is not explicitly overriden if (empty($params) && !empty($activity->params)) { $params = $activity->params; } $activities = CFactory::getModel('activities'); // Update access for activity based on the user's profile privacy if (!empty($actor) && $actor != 0) { $user = CFactory::getUser($actor); $userParams = $user->getParams(); $profileAccess = $userParams->get('privacyProfileView'); // Only overwrite access if the user global profile privacy is higher // BUT, if access is defined as PRIVACY_FORCE_PUBLIC, do not modify it if ($access != PRIVACY_FORCE_PUBLIC && $profileAccess > $access) { $access = $profileAccess; } } $table =& JTable::getInstance('Activity', 'CTable'); $table->actor = $actor; $table->target = $target; $table->title = $title; $table->content = $content; $table->app = $appname; $table->cid = $cid; $table->groupid = $groupid; $table->group_access = $group_access; $table->eventid = $eventid; $table->event_access = $event_access; $table->points = $points; $table->access = $access; $table->location = $location; $table->params = $params; $table->comment_id = $comment_id; $table->comment_type = $comment_type; $table->like_id = $like_id; $table->like_type = $like_type; $table->store(); // Update comment id, if we comment on the stream itself if ($comment_id == CActivities::COMMENT_SELF) { $table->comment_id = $table->id; } // Update comment id, if we like on the stream itself if ($comment_id == CActivities::LIKE_SELF) { $table->like_id = $table->id; } if ($comment_id == CActivities::COMMENT_SELF || $comment_id == CActivities::LIKE_SELF) { $table->store(); } }
static function addJSGroupMember($group_name, $username, $permissions, $course_id) { 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/models/groups.php'; $group = JTable::getInstance('Group', 'CTable'); $groupModel = CFactory::getModel('groups'); $member = JTable::getInstance('GroupMembers', 'CTable'); $group_id = JoomdleHelperGroups::get_js_group_by_course_id($course_id); if (!$group_id) { return "NO GROUP"; } $group->load($group_id); //$my = CFactory::getUser($username); $user_id = JUserHelper::getUserId($username); $my = JFactory::getUser($user_id); $params = $group->getParams(); // Set the properties for the members table $member->groupid = $group->id; $member->memberid = $my->id; CFactory::load('helpers', 'owner'); /* kludge: remove when fixing call_method fns */ if ($permissions == -1) { $permissions = 0; } $member->permissions = $permissions; $member->approved = '1'; // Get the owner data // $owner = CFactory::getUser( $group->ownerid ); $store = $member->store(); // Add assertion if storing fails CError::assert($store, true, 'eq', __FILE__, __LINE__); $group->updateStats(); $group->store(); return "OK"; }
public function triggerEvents($eventName, &$args, $target = null) { CError::assert($args, 'object', 'istype', __FILE__, __LINE__); require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'apps.php'; $appsLib =& CAppPlugins::getInstance(); $appsLib->loadApplications(); $params = array(); $params[] =& $args; if (!is_null($target)) { $params[] = $target; } $appsLib->triggerEvent($eventName, $params); return true; }
public function ajaxRemoveWall($wallId) { $filter = JFilterInput::getInstance(); $wallId = $filter->clean($wallId, 'int'); CError::assert($wallId, '', '!empty', __FILE__, __LINE__); $response = new JAXResponse(); CFactory::load('helpers', 'owner'); if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } //@rule: Check if user is really allowed to remove the current wall $my = CFactory::getUser(); $wallModel =& $this->getModel('wall'); $wall = $wallModel->get($wallId); $eventModel =& $this->getModel('events'); $event =& JTable::getInstance('Event', 'CTable'); $event->load($wall->contentid); if (!COwnerHelper::isCommunityAdmin() && !$event->isAdmin($my->id)) { $response->addScriptCall('alert', JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_REMOVE_WALL')); } else { if (!$wallModel->deletePost($wallId)) { $response->addAlert(JText::_('COM_COMMUNITY_GROUPS_REMOVE_WALL_ERROR')); } else { if ($wall->post_by != 0) { //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('wall.remove', $wall->post_by); } } // Substract the count $event->substractWallCount(); } $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES)); return $response->sendResponse(); }
/** * Set user profile avatar */ public function setImage($path, $type = 'thumb') { CError::assert($path, '', '!empty', __FILE__, __LINE__); $db = $this->getDBO(); // Fix the back quotes $path = JString::str_ireplace('\\', '/', $path); $type = JString::strtolower($type); // Test if the record exists. $oldFile = $this->{$type}; if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } if ($oldFile) { // File exists, try to remove old files first. $oldFile = JString::str_ireplace('/', '/', $oldFile); // If old file is default_thumb or default, we should not remove it. if (!JString::stristr($oldFile, 'user.png') && !JString::stristr($oldFile, 'user_thumb.png') && !JString::stristr($oldFile, 'avatar_')) { jimport('joomla.filesystem.file'); JFile::delete($oldFile); } } $this->{$type} = $path; $this->store(); // Trigger profile avatar update event. if ($type == 'avatar') { $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $args = array(); $args[] = $this->userid; // userid $args[] = $oldFile; // old path $args[] = $path; // new path $appsLib->triggerEvent('onProfileAvatarUpdate', $args); } }
/** * Delete post message * * @param response An ajax Response object * @param id A unique identifier for the wall row * * returns response */ function ajaxRemoveWall($response, $id, $cache_id = "") { $my = CFactory::getUser(); $wallModel = CFactory::getModel('wall'); $wall = $wallModel->get($id); CError::assert($id, '', '!empty', __FILE__, __LINE__); CFactory::load('helpers', 'owner'); // Make sure the current user actually has the correct permission // Only the original writer and the person the wall is meant for (and admin of course) // can delete the wall if ($my->id == $wall->post_by || $my->id == $wall->contentid || COwnerHelper::isCommunityAdmin()) { if ($wallModel->deletePost($id)) { // @rule: Remove the wall activity from the database as well CFactory::load('libraries', 'activities'); CActivityStream::remove('walls', $id); //add user points if ($wall->post_by != 0) { CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('wall.remove', $wall->post_by); } } else { $html = JText::_('Error while removing wall. Line:' . __LINE__); $response->addAlert($html); } $cache =& JFactory::getCache('plgCommunityWalls'); $cache->remove($cache_id); $cache =& JFactory::getCache('plgCommunityWalls_fullview'); $cache->remove($cache_id); } else { $html = JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'); $response->addAlert($html); } return $response; }
/** * Add new activity, * @access static * */ public static function add($activity, $params = '', $points = 1) { CError::assert($activity, '', '!empty', __FILE__, __LINE__); $cmd = !empty($activity->cmd) ? $activity->cmd : ''; if (!empty($cmd)) { $userPointModel = CFactory::getModel('Userpoints'); $point = $userPointModel->getPointData($cmd); //no reason to disable activity if no points is given if ($point) { if (!$point->published) { return; } } } // If params is an object, instead of a string, we convert it to string $cmd = !empty($activity->cmd) ? $activity->cmd : ''; $actor = !empty($activity->actor) ? $activity->actor : ''; $actors = !empty($activity->actors) ? $activity->actors : ''; $target = !empty($activity->target) ? $activity->target : 0; $title = !empty($activity->title) ? $activity->title : ''; $content = !empty($activity->content) ? $activity->content : ''; $appname = !empty($activity->app) ? $activity->app : ''; $cid = !empty($activity->cid) ? $activity->cid : 0; $groupid = !empty($activity->groupid) ? $activity->groupid : 0; $group_access = !empty($activity->group_access) ? $activity->group_access : 0; $event_access = !empty($activity->event_access) ? $activity->event_access : 0; $eventid = !empty($activity->eventid) ? $activity->eventid : 0; $points = !empty($activity->points) ? $activity->points : $points; $access = !empty($activity->access) ? $activity->access : 0; $location = !empty($activity->location) ? $activity->location : ''; $comment_id = !empty($activity->comment_id) ? $activity->comment_id : 0; $comment_type = !empty($activity->comment_type) ? $activity->comment_type : ''; $like_id = !empty($activity->like_id) ? $activity->like_id : 0; $like_type = !empty($activity->like_type) ? $activity->like_type : ''; $latitude = !empty($activity->latitude) ? $activity->latitude : null; $longitude = !empty($activity->longitude) ? $activity->longitude : null; // If the params in embedded within the activity object, use it // if it is not explicitly overriden if (empty($params) && !empty($activity->params)) { $params = $activity->params; } // Update access for activity based on the user's profile privacy // since 2.4.2 if access is provided, dont use the default if (!empty($actor) && $actor != 0 && !isset($access)) { $user = CFactory::getUser($actor); $userParams = $user->getParams(); $profileAccess = $userParams->get('privacyProfileView'); // Only overwrite access if the user global profile privacy is higher // BUT, if access is defined as PRIVACY_FORCE_PUBLIC, do not modify it if ($access != PRIVACY_FORCE_PUBLIC && $profileAccess > $access) { $access = $profileAccess; } } $table = JTable::getInstance('Activity', 'CTable'); //before adding we must aggregate the videos/album/photo comments $aggregateApps = array('videos.comment', 'albums.comment', 'photos.comment'); if (in_array($appname, $aggregateApps)) { //we need to check if this activity exists $filter = array('app' => $appname, 'cid' => $cid); $activitiesModel = CFactory::getModel('activities'); $activityId = $activitiesModel->getActivityId($filter); if ($activityId) { $table->load($activityId); $passedParams = new JRegistry($params); // update wall id if needed $wallid = $passedParams->get('wallid'); $params = new JRegistry($table->params); $params->set('wallid', $wallid); $act = $params->get('actors'); if (!is_array($act)) { $params->set('actors', array($actor)); } else { array_unshift($act, $actor); $act = array_unique($act); // latest user must be on the first $params->set('actors', $act); } $table->created = JFactory::getDate()->toSql(); $table->params = $params->toString(); $table->store(); return $table; } else { //if this is the first creation $params = new JRegistry($params); $params->set('actors', array($actor)); $params = $params->toString(); } } $table->actor = $actor; $table->actors = $actors; $table->target = $target; $table->title = $title; $table->content = $content; $table->app = $appname; $table->cid = $cid; $table->groupid = $groupid; $table->group_access = $group_access; $table->eventid = $eventid; $table->event_access = $event_access; $table->points = $points; $table->access = $access; $table->location = $location; $table->params = $params; $table->comment_id = $comment_id; $table->comment_type = $comment_type; $table->like_id = $like_id; $table->like_type = $like_type; $table->latitude = $latitude; $table->longitude = $longitude; $table->store(); // Update comment id, if we comment on the stream itself if ($comment_id == CActivities::COMMENT_SELF) { $table->comment_id = $table->id; } // Update comment id, if we like on the stream itself if ($like_id == CActivities::LIKE_SELF) { $table->like_id = $table->id; } if ($comment_id == CActivities::COMMENT_SELF || $like_id == CActivities::LIKE_SELF) { $table->store($table); } return $table; }
/** * Returns the category name of the specific category * * @access public * @param string Category Id * @returns string Category name * */ public function getCategoryName($categoryId) { CError::assert($categoryId, '', '!empty', __FILE__, __LINE__); $db = $this->getDBO(); $query = 'SELECT ' . $db->quoteName('name') . ' ' . 'FROM ' . $db->quoteName('#__community_events_category') . ' ' . 'WHERE ' . $db->quoteName('id') . '=' . $db->Quote($categoryId); $db->setQuery($query); $result = $db->loadResult(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } CError::assert($result, '', '!empty', __FILE__, __LINE__); return $result; }
public function getBannedMembers($groupid, $limit = 0, $randomize = false) { CError::assert($groupid, '', '!empty', __FILE__, __LINE__); $db = $this->getDBO(); $limit = $limit === 0 ? $this->getState('limit') : $limit; $limitstart = $this->getState('limitstart'); $query = 'SELECT a.' . $db->quoteName('memberid') . ' AS id, a.' . $db->quoteName('approved') . ' , b.' . $db->quoteName('name') . ' as name ' . ' FROM ' . $db->quoteName('#__community_groups_members') . ' AS a ' . ' INNER JOIN ' . $db->quoteName('#__users') . ' AS b ' . ' WHERE b.' . $db->quoteName('id') . '=a.' . $db->quoteName('memberid') . ' AND a.' . $db->quoteName('groupid') . '=' . $db->Quote($groupid) . ' AND a.' . $db->quoteName('permissions') . '=' . $db->Quote(COMMUNITY_GROUP_BANNED); if ($randomize) { $query .= ' ORDER BY RAND() '; } if (!is_null($limit)) { $query .= ' LIMIT ' . $limitstart . ',' . $limit; } $db->setQuery($query); $result = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $query = 'SELECT COUNT(*) FROM ' . $db->quoteName('#__community_groups_members') . ' AS a ' . ' INNER JOIN ' . $db->quoteName('#__users') . ' AS b ' . ' WHERE b.' . $db->quoteName('id') . '=a.' . $db->quoteName('memberid') . ' AND a.' . $db->quoteName('groupid') . '=' . $db->Quote($groupid) . ' ' . ' AND a.' . $db->quoteName('permissions') . '=' . $db->Quote(COMMUNITY_GROUP_BANNED); $db->setQuery($query); $total = $db->loadResult(); $this->total = $total; if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($total, $limitstart, $limit); } return $result; }
/** * Formats the comment in the rows * * @param Array An array of wall objects * */ public static function triggerWallComments(&$rows, $newlineReplace = true) { CError::assert($rows, 'array', 'istype', __FILE__, __LINE__); require_once COMMUNITY_COM_PATH . '/libraries/apps.php'; $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); for ($i = 0; $i < count($rows); $i++) { if (isset($rows[$i]->comment) && !empty($rows[$i]->comment)) { $args = array(); if (!$newlineReplace) { // if newline replace is false, pass the information to the comment to leave out the newline // replace in wall.trigger $rows[$i]->newlineReplace = false; } $args[] = $rows[$i]; $appsLib->triggerEvent('onWallDisplay', $args); } } return true; }
/** * Set the avatar for specific application. Caller must have a database table * that is named after the appType. E.g, users should have jos_community_users * * @param appType Application type. ( users , groups ) * @param path The relative path to the avatars. * @param type The type of Image, thumb or avatar. * **/ function setImage($id, $path, $type = 'thumb', $removeOldImage = true) { CError::assert($id, '', '!empty', __FILE__, __LINE__); CError::assert($path, '', '!empty', __FILE__, __LINE__); $db =& $this->getDBO(); // Fix the back quotes $path = JString::str_ireplace('\\', '/', $path); $type = JString::strtolower($type); // Test if the record exists. $query = 'SELECT ' . $db->nameQuote($type) . ' FROM ' . $db->nameQuote('#__community_users') . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id); $db->setQuery($query); $oldFile = $db->loadResult(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $appsLib =& CAppPlugins::getInstance(); $appsLib->loadApplications(); $args = array(); $args[] =& $id; // userid $args[] =& $oldFile; // old path $args[] =& $path; // new path $appsLib->triggerEvent('onProfileAvatarUpdate', $args); if (!$oldFile) { $query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($path) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id); $db->setQuery($query); $db->query($query); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } } else { $query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($path) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id); $db->setQuery($query); $db->Query(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } // If old file is default_thumb or default, we should not remove it. // Need proper way to test it if (!JString::stristr($oldFile, 'components/com_community/assets/default.jpg') && !JString::stristr($oldFile, 'components/com_community/assets/default_thumb.jpg') && $removeOldImage) { // File exists, try to remove old files first. $oldFile = JString::str_ireplace('/', DS, $oldFile); if (JFile::exists($oldFile)) { JFile::delete($oldFile); } } } }
/** * Gets the count of wall entries for specific item * * @params uniqueId The unique id for the speicific item * @params type The unique type for the specific item **/ public function getCount($uniqueId, $type) { $cache = CFactory::getFastCache(); $cacheid = __FILE__ . __LINE__ . serialize(func_get_args()) . serialize(JRequest::get()); if ($data = $cache->get($cacheid)) { return $data; } CError::assert($uniqueId, '', '!empty', __FILE__, __LINE__); $db =& $this->getDBO(); $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote('#__community_wall') . 'WHERE ' . $db->nameQuote('contentid') . '=' . $db->Quote($uniqueId) . 'AND ' . $db->nameQuote('type') . '=' . $db->Quote($type); $db->setQuery($query); $count = $db->loadResult(); $cache->store($count, $cacheid); return $count; }
/** * Method to set the property when the properties are already * assigned * * @param property The property value that needs to be changed * @param value The value that needs to be set * **/ public function set($property, $value) { CError::assert($property, '', '!empty', __FILE__, __LINE__); $this->{$property} = $value; }