/** * Application full view **/ public function appFullView() { $document = JFactory::getDocument(); $this->showSubmenu(); $applicationName = JString::strtolower(JRequest::getVar('app', '', 'GET')); if (empty($applicationName)) { JError::raiseError(500, 'COM_COMMUNITY_APP_ID_REQUIRED'); } if (!$this->accessAllowed('registered')) { return; } $output = ''; //@todo: Since group walls doesn't use application yet, we process it manually now. if ($applicationName == 'walls') { CFactory::load('libraries', 'wall'); $jConfig = JFactory::getConfig(); $limit = JRequest::getInt('limit', 5, 'REQUEST'); $limitstart = JRequest::getInt('limitstart', 0, 'REQUEST'); $eventId = JRequest::getInt('eventid', '', 'GET'); $my = CFactory::getUser(); $config = CFactory::getConfig(); $eventsModel = CFactory::getModel('Events'); $event =& JTable::getInstance('Event', 'CTable'); $event->load($eventId); $config = CFactory::getConfig(); $document->setTitle(JText::sprintf('COM_COMMUNITY_EVENTS_WALL_TITLE', $event->title)); CFactory::load('helpers', 'owner'); $guest = $event->isMember($my->id); $waitingApproval = $event->isPendingApproval($my->id); $status = $event->getUserStatus($my->id, 'events'); $responded = $status == COMMUNITY_EVENT_STATUS_ATTEND || $status == COMMUNITY_EVENT_STATUS_WONTATTEND || $status == COMMUNITY_EVENT_STATUS_MAYBE; if (!$config->get('lockeventwalls') || $config->get('lockeventwalls') && $guest && !$waitingApproval && $responded || COwnerHelper::isCommunityAdmin()) { $output .= CWallLibrary::getWallInputForm($event->id, 'events,ajaxSaveWall', 'events,ajaxRemoveWall'); // Get the walls content $output .= '<div id="wallContent">'; $output .= CWallLibrary::getWallContents('events', $event->id, $event->isAdmin($my->id), $limit, $limitstart, 'wall.content', 'events,events'); $output .= '</div>'; jimport('joomla.html.pagination'); $wallModel = CFactory::getModel('wall'); $pagination = new JPagination($wallModel->getCount($event->id, 'events'), $limitstart, $limit); $output .= '<div class="pagination-container">' . $pagination->getPagesLinks() . '</div>'; } } else { CFactory::load('libraries', 'apps'); $model = CFactory::getModel('apps'); $applications =& CAppPlugins::getInstance(); $applicationId = $model->getUserApplicationId($applicationName); $application = $applications->get($applicationName, $applicationId); if (!$application) { JError::raiseError(500, 'COM_COMMUNITY_APPS_NOT_FOUND'); } // Get the parameters $manifest = CPluginHelper::getPluginPath('community', $applicationName) . DS . $applicationName . DS . $applicationName . '.xml'; $params = new CParameter($model->getUserAppParams($applicationId), $manifest); $application->params =& $params; $application->id = $applicationId; $output = $application->onAppDisplay($params); } echo $output; }
public function ajaxBrowse($data) { $mainframe =& JFactory::getApplication(); $my = CFactory::getUser(); // Get application's favicon $addedAppCount = 0; foreach ($data->applications as $appData) { if (JFile::exists(CPluginHelper::getPluginPath('community', $appData->name) . DS . $appData->name . DS . 'favicon_64.png')) { $appData->favicon['64'] = rtrim(JURI::root(), '/') . CPluginHelper::getPluginURI('community', $appData->name) . '/' . $appData->name . '/favicon_64.png'; } else { $appData->favicon['64'] = rtrim(JURI::root(), '/') . '/components/com_community/assets/app_avatar.png'; } // Get total added applications //$addedAppCount = $appData->added == 1 ? $addedAppCount+1 : $addedAppCount; } $tmpl = new CTemplate(); echo $tmpl->set('apps', $data->applications)->set('itemType', 'browse')->fetch('application.item'); }
/** * Application full view **/ public function appFullView() { $document = JFactory::getDocument(); $document->setTitle(JText::_('COM_COMMUNITY_VIDEOS_WALL_TITLE')); $applicationName = JString::strtolower(JRequest::getVar('app', '', 'GET')); if (empty($applicationName)) { JError::raiseError(500, 'COM_COMMUNITY_APP_ID_REQUIRED'); } $output = ''; if ($applicationName == 'walls') { CFactory::load('libraries', 'wall'); $limit = JRequest::getVar('limit', 5, 'REQUEST'); $limitstart = JRequest::getVar('limitstart', 0, 'REQUEST'); $videoId = JRequest::getInt('videoid', '', 'GET'); $my = CFactory::getUser(); $config = CFactory::getConfig(); $videoModel = CFactory::getModel('videos'); $video =& JTable::getInstance('Video', 'CTable'); $video->load($videoId); CFactory::load('helpers', 'owner'); CFactory::load('helpers', 'friends'); if (!$config->get('lockvideoswalls') || $config->get('lockvideoswalls') && CFriendsHelper::isConnected($my->id, $video->creator) || COwnerHelper::isCommunityAdmin()) { $viewAllLink = false; if (JRequest::getVar('task', '', 'REQUEST') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=videos&task=app&videoid=' . $video->id . '&app=walls'); } $output .= CWallLibrary::getWallInputForm($video->id, 'videos,ajaxSaveWall', 'videos,ajaxRemoveWall', $viewAllLink); } // Get the walls content $output .= '<div id="wallContent">'; $output .= CWallLibrary::getWallContents('videos', $video->id, COwnerHelper::isCommunityAdmin() || COwnerHelper::isMine($my->id, $video->creator), $limit, $limitstart); $output .= '</div>'; jimport('joomla.html.pagination'); $wallModel = CFactory::getModel('wall'); $pagination = new JPagination($wallModel->getCount($video->id, 'videos'), $limitstart, $limit); $output .= '<div class="pagination-container">' . $pagination->getPagesLinks() . '</div>'; } else { $model = CFactory::getModel('apps'); $applications =& CAppPlugins::getInstance(); $applicationId = $model->getUserApplicationId($applicationName); $application = $applications->get($applicationName, $applicationId); // Get the parameters $manifest = CPluginHelper::getPluginPath('community', $applicationName) . DS . $applicationName . DS . $applicationName . '.xml'; $params = new CParameter($model->getUserAppParams($applicationId), $manifest); $application->params =& $params; $application->id = $applicationId; $output = $application->onAppDisplay($params); } echo $output; }
public function ajaxAddApp($name, $position) { // Check permissions $my = CFactory::getUser(); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $filter = JFilterInput::getInstance(); $name = $filter->clean($name, 'string'); $position = $filter->clean($position, 'string'); // Add application $appModel = CFactory::getModel('apps'); $appModel->addApp($my->id, $name, $position); // Activity stream $act = new stdClass(); $act->cmd = 'application.add'; $act->actor = $my->id; $act->target = 0; $act->title = ''; //JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED'); $act->content = ''; $act->app = 'app.install'; $act->cid = 0; // application id $params = new JRegistry(''); $params->set('app', $name); //CActivityStream::addActor( $act, $params->toString() ); // User points //CFactory::load( 'libraries' , 'userpoints' ); CUserPoints::assignPoint('application.add'); // Get application $id = $appModel->getUserApplicationId($name, $my->id); $appInfo = $appModel->getAppInfo($name); $params = new CParameter($appModel->getPluginParams($id, null)); $isCoreApp = $appInfo->coreapp; $app = new stdClass(); $app->id = $id; $app->title = isset($appInfo->title) ? $appInfo->title : ''; $app->description = isset($appInfo->description) ? $appInfo->description : ''; $app->isCoreApp = $isCoreApp; $app->name = $name; if ($appInfo->customFavicon != '') { $app->favicon['64'] = JURI::root(true) . '/' . $appInfo->customFavicon; } elseif (JFile::exists(CPluginHelper::getPluginPath('community', $name) . '/favicon_64.png')) { $app->favicon['64'] = JURI::root(true) . CPluginHelper::getPluginURI('community', $name) . '/' . $name . '/favicon_64.png'; } else { $app->favicon['64'] = JURI::root(true) . '/components/com_community/assets/app_avatar.png'; } $tmpl = new CTemplate(); $tmpl->set('apps', array($app)); $tmpl->set('itemType', 'edit'); $tmpl->set('position', $position); $html = $tmpl->fetch('application.item'); $json = array('success' => true, 'title' => $app->title, 'item' => $html, 'id' => $app->id); die(json_encode($json)); }
public function ajaxSendReport() { $reportFunc = func_get_arg(0); $pageLink = func_get_arg(1); $message = func_get_arg(2); $argsCount = func_num_args(); $method = explode(',', $reportFunc); $args = array(); $args[] = $pageLink; $args[] = $message; for ($i = 3; $i < $argsCount; $i++) { $args[] = func_get_arg($i); } // Reporting should be session sensitive // Construct $output if ($reportFunc == 'activities,reportActivities' && strpos($pageLink, 'actid') === false) { $pageLink = $pageLink . '&actid=' . func_get_arg(3); } $uniqueString = md5($reportFunc . $pageLink); $session = JFactory::getSession(); if ($session->has('action-report-' . $uniqueString)) { $output = JText::_('COM_COMMUNITY_REPORT_ALREADY_SENT'); } else { if (is_array($method) && $method[0] != 'plugins') { $controller = JString::strtolower(basename($method[0])); require_once JPATH_ROOT . '/components/com_community/controllers/controller.php'; require_once JPATH_ROOT . '/components/com_community/controllers' . '/' . $controller . '.php'; $controller = JString::ucfirst($controller); $controller = 'Community' . $controller . 'Controller'; $controller = new $controller(); $output = call_user_func_array(array(&$controller, $method[1]), $args); } else { if (is_array($method) && $method[0] == 'plugins') { // Application method calls $element = JString::strtolower($method[1]); require_once CPluginHelper::getPluginPath('community', $element) . '/' . $element . '.php'; $className = 'plgCommunity' . JString::ucfirst($element); $output = call_user_func_array(array($className, $method[2]), $args); } } } $session->set('action-report-' . $uniqueString, true); $json = array('message' => $output); die(json_encode($json)); }
/** * Ajax functiion to handle ajax calls */ public function ajaxPerformAction($actionId, $ignore = 0) { $objResponse = new JAXResponse(); $output = ''; // Require Jomsocial core lib require_once JPATH_ROOT . '/components/com_community/libraries/core.php'; $language = JFactory::getLanguage(); $language->load('com_community', JPATH_ROOT); // Get the action data $action = JTable::getInstance('ReportsActions', 'CommunityTable'); $action->load($actionId); // Get the report data $report = JTable::getInstance('Reports', 'CommunityTable'); $report->load($action->reportid); $actions = '<input type="button" class="btn btn-inverse btn-mini pull-left" onclick="cWindowHide(); location.reload();" value="' . JText::_('COM_COMMUNITY_CLOSE') . '"/>'; if ($ignore != 0) { $report->status = 2; $report->store(); $output = JText::_('COM_COMMUNITY_REPORTS_IGNORED_MESSAGE'); $objResponse->addAssign('cWindowContent', 'innerHTML', $output); $objResponse->addScriptCall('cWindowActions', $actions); return $objResponse->sendResponse(); } $method = explode(',', $action->method); $args = explode(',', $action->parameters); if (is_array($method) && $method[0] != 'plugins') { $controller = JString::strtolower($method[0]); require_once JPATH_ROOT . '/components/com_community/controllers/controller.php'; require_once JPATH_ROOT . '/components/com_community/controllers/' . $controller . '.php'; $controller = JString::ucfirst($controller); $controller = 'Community' . $controller . 'Controller'; $controller = new $controller(); $output = call_user_func_array(array(&$controller, $method[1]), $args); } else { if (is_array($method) && $method[0] == 'plugins') { // Application method calls $element = JString::strtolower($method[1]); require_once CPluginHelper::getPluginPath('community', $element) . '/' . $element . '.php'; $className = 'plgCommunity' . JString::ucfirst($element); $output = call_user_func_array(array($className, $method[2]), $args); } } $objResponse->addAssign('cWindowContent', 'innerHTML', $output); $objResponse->addScriptCall('cWindowActions', $actions); if ($report->status == 1) { $report->status = 0; } else { $report->status = 1; } $report->store(); return $objResponse->sendResponse(); }
/** * Executes a default action */ public function executeDefaultAction() { $db =& JFactory::getDBO(); // Send notification to specified emails notifying them the action has been taken. $jConfig =& JFactory::getConfig(); $config = CFactory::getConfig(); $from = $jConfig->getValue('mailfrom'); $fromName = $jConfig->getValue('fromname'); $recipients = $config->get('notifyMaxReport'); $recipients = explode(',', $recipients); $query = 'SELECT * FROM ' . $db->nameQuote('#__community_reports_actions') . ' ' . 'WHERE ' . $db->nameQuote('reportid') . '=' . $db->Quote($this->report->id) . ' ' . 'AND ' . $db->nameQuote('defaultaction') . '=' . $db->Quote(1) . ' ' . 'ORDER BY ' . $db->nameQuote('id') . ' LIMIT 1'; $db->setQuery($query); $result = $db->loadObject(); // No defaultaction specified for this current if (!$result) { return false; } // Execute the default action $method = explode(',', $result->method); $args = explode(',', $result->parameters); if (is_array($method) && $method[0] != 'plugins') { $controller = JString::strtolower($method[0]); require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'controllers' . DS . 'controller.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'controllers' . DS . $controller . '.php'; $controller = JString::ucfirst($controller); $controller = 'Community' . $controller . 'Controller'; $controller = new $controller(); if (method_exists($controller, $method[1])) { $resultData = call_user_func_array(array(&$controller, $method[1]), $args); } else { // Continue adding the action as there might be changes to the method name. return false; } } else { if (is_array($method) && $method[0] == 'plugins') { // Application method calls $element = JString::strtolower($method[1]); require_once CPluginHelper::getPluginPath('community', $element) . DS . $element . '.php'; $className = 'plgCommunity' . JString::ucfirst($element); $plugin = new $className(); if (method_exists($plugin, $method[2])) { $resultData = call_user_func_array(array($plugin, $method[2]), $args); } else { // Continue adding the action as there might be changes to the method name. return false; } } else { return false; } } // Send notification to specified emails notifying them the action has been taken. $jConfig =& JFactory::getConfig(); $config = CFactory::getConfig(); $from = $jConfig->getValue('mailfrom'); $fromName = $jConfig->getValue('fromname'); $recipients = $config->get('notifyMaxReport'); $recipients = explode(',', $recipients); $subject = JText::sprintf('COM_COMMUNITY_REPORT_THRESHOLD_REACHED_SUBJECT', $this->report->link); CFactory::load('libraries', 'notification'); $params = new CParameter(''); $params->set('url', $this->report->link); CNotificationLibrary::add('etype_system_reports_threshold', $from, $recipients, $subject, '', 'reports.threshold', $params); $this->report->status = 1; $this->report->store(); return true; }
public function editPage() { if (!$this->accessAllowed('registered')) { return; } $my = CFactory::getUser(); $appsModel = CFactory::getModel('apps'); //------ pre-1.8 ------// // Get coreapps $coreApps = $appsModel->getCoreApps(); for ($i = 0; $i < count($coreApps); $i++) { $appInfo = $appsModel->getAppInfo($coreApps[$i]->apps); // @rule: Try to get proper app id from #__community_users table first. $id = $appsModel->getUserApplicationId($coreApps[$i]->apps, $my->id); // @rule: If there aren't any records, we need to get it from #__plugins table. if (empty($id)) { $id = $appsModel->getPluginId($coreApps[$i]->apps, null, true); } $coreApps[$i]->id = $id; $coreApps[$i]->title = $appInfo->title; $coreApps[$i]->description = $appInfo->description; $coreApps[$i]->name = $coreApps[$i]->apps; //$coreApps[$i]->coreapp = $params->get( 'coreapp' ); //Get application favicon if (JFile::exists(CPluginHelper::getPluginPath('community', $coreApps[$i]->apps) . '/' . $coreApps[$i]->apps . '/favicon_64.png')) { $coreApps[$i]->appFavicon = JURI::root(true) . CPluginHelper::getPluginURI('community', $coreApps[$i]->apps) . '/' . $coreApps[$i]->apps . '/favicon_64.png'; } else { $coreApps[$i]->appFavicon = JURI::root(true) . '/components/com_community/assets/app_favicon.png'; } } //------ pre-1.8 ------// // Get user apps $userApps = $appsModel->getUserApps($my->id); $appsList = array(); for ($i = 0; $i < count($userApps); $i++) { // TODO: getUserApps should return all this value already $id = $appsModel->getPluginId($userApps[$i]->apps, null, true); $appInfo = $appsModel->getAppInfo($userApps[$i]->apps); $params = new CParameter($appsModel->getPluginParams($id, null)); $isCoreApp = $params->get('coreapp'); $corePosition = $params->get('position'); $userApps[$i]->title = isset($appInfo->title) ? $appInfo->title : ''; $userApps[$i]->description = isset($appInfo->description) ? $appInfo->description : ''; $userApps[$i]->coreapp = $isCoreApp; // Pre 1.8x $userApps[$i]->isCoreApp = $isCoreApp; $userApps[$i]->name = $userApps[$i]->apps; $userApps[$i]->hide_empty = isset($appInfo->hide_empty) ? $appInfo->hide_empty : 0; //------ pre-1.8 ------// if ($params->get('favicon') != '') { $userApps[$i]->favicon['64'] = JURI::root(true) . '/' . $params->get('favicon'); } elseif (JFile::exists(CPluginHelper::getPluginPath('community', $userApps[$i]->apps) . '/favicon_64.png')) { $userApps[$i]->favicon['64'] = JURI::root(true) . CPluginHelper::getPluginURI('community', $userApps[$i]->apps) . '/' . $userApps[$i]->apps . '/favicon_64.png'; } else { $userApps[$i]->favicon['64'] = JURI::root(true) . '/components/com_community/assets/app_avatar.png'; } if ($isCoreApp) { $position = $corePosition . (strpos($corePosition, '-core') === FALSE ? '-core' : ''); } else { $position = !empty($userApps[$i]->position) ? $userApps[$i]->position : 'content'; } $appsList[$position][] = $userApps[$i]; } foreach (array('sidebar-top', 'sidebar-bottom', 'sidebar-top-stacked', 'sidebar-bottom-stacked', 'content') as $position) { if (isset($appsList[$position . '-core'])) { if (!isset($appsList[$position])) { $appsList[$position] = array(); } $appsList[$position] = array_merge($appsList[$position . '-core'], $appsList[$position]); unset($appsList[$position . '-core']); } } $appTitles = array(); $appTitles['sidebar-top'] = ''; $appTitles['sidebar-top-stacked'] = ''; $appTitles['sidebar-bottom'] = ''; $appTitles['sidebar-bottom-stacked'] = ''; $appTitles['content'] = ''; $appItems = array(); $appItems['sidebar-top'] = ''; $appItems['sidebar-top-stacked'] = ''; $appItems['sidebar-bottom'] = ''; $appItems['sidebar-bottom-stacked'] = ''; $appItems['content'] = ''; foreach ($appsList as $position => $apps) { $tmpl = new CTemplate(); if (isset($appItems[$position])) { $appTitles[$position] .= $tmpl->set('apps', $apps)->set('position', $position)->fetch('application.title'); $appItems[$position] .= $tmpl->set('apps', $apps)->set('position', $position)->set('itemType', 'edit')->fetch('application.item'); } } // Get available apps for comparison $appsModel = CFactory::getModel('apps'); $apps = $appsModel->getAvailableApps(false); $appsname = array(); $availableApps = array(); if (!empty($apps)) { foreach ($apps as $data) { array_push($availableApps, $data->name); } } // Check if apps exist, if not delete it. $obsoleteApps = array(); $obsoleteApps = array_diff($appsname, $availableApps); if (!empty($obsoleteApps)) { foreach ($obsoleteApps as $key => $obsoleteApp) { $appRecords = $appsModel->checkObsoleteApp($obsoleteApp); if (empty($appRecords)) { if ($appRecords == NULL) { $appsModel->removeObsoleteApp($obsoleteApp); } unset($userApps[$key]); } } $userApps = array_values($userApps); } /** * Opengraph */ CHeadHelper::setType('website', JText::_('COM_COMMUNITY_APPS_MINE')); $this->addPathway(JText::_('COM_COMMUNITY_APPS_MINE')); //$this->showSubMenu(); // pre-1.8 //CFactory::load( 'libraries' , 'window' ); CWindow::load(); // CFactory::attach('assets/jquery.tablednd_0_5.js', 'js'); // pre-1.8 // CFactory::attach('assets/ui.core.js', 'js'); // CFactory::attach('assets/ui.sortable.js', 'js'); // CFactory::attach('assets/applayout.js', 'js'); // about me $tmpl = new CTemplate(); $lastLogin = JText::_('COM_COMMUNITY_PROFILE_NEVER_LOGGED_IN'); if ($my->lastvisitDate != '0000-00-00 00:00:00') { $myLastLogin = new JDate($my->lastvisitDate); $lastLogin = CActivityStream::_createdLapse($myLastLogin); } $profileModel = CFactory::getModel('profile'); $profileData = $profileModel->getViewableProfile($my->id, $my->getProfileType()); $multiprofile = JTable::getInstance('MultiProfile', 'CTable'); $multiprofile->load($my->getProfileType()); $aboutTitle = ucfirst(JText::_('COM_COMMUNITY_ABOUT_ME')); $aboutItem = $tmpl->set('registerDate', $my->registerDate)->set('lastLogin', $lastLogin)->set('about', $this->_getProfileHTML($profileData, true))->set('multiprofile', $multiprofile)->fetch('profile/aboutme'); $tmpl = new CTemplate(); echo $tmpl->set('coreApplications', $coreApps)->set('applications', $userApps)->set('appItems', $appItems)->set('appTitles', $appTitles)->set('aboutTitle', $aboutTitle)->set('aboutItem', $aboutItem)->set('submenu', $this->showSubmenu(false))->fetch('applications.edit'); }
/** * Return an array of activity data * * @param mixed $type string or arrayn or string */ private function _getData($options) { $dispatcher =& CDispatcher::getInstanceStatic(); $observers =& $dispatcher->getObservers(); $plgObj = false; for ($i = 0; $i < count($observers); $i++) { if ($observers[$i] instanceof plgCommunityWordfilter) { $plgObj = $observers[$i]; } } // Default params $default = array('actor' => 0, 'target' => 0, 'date' => null, 'app' => null, 'cid' => null, 'groupid' => null, 'eventid' => null, 'maxList' => 20, 'type' => '', 'exclusions' => null, 'displayArchived' => false); $options = array_merge($default, $options); extract($options); CFactory::load('libraries', 'mapping'); CFactory::load('libraries', 'wall'); CFactory::load('libraries', 'groups'); CFactory::load('libraries', 'events'); CFactory::load('helpers', 'friends'); $activities = CFactory::getModel('activities'); $appModel = CFactory::getModel('apps'); $html = ''; $numLines = 0; $my = CFactory::getUser(); $actorId = $actor; $htmlData = array(); $config = CFactory::getConfig(); //Get blocked list $model = CFactory::getModel('block'); $blockLists = $model->getBanList($my->id); $blockedUserId = array(); foreach ($blockLists as $blocklist) { $blockedUserId[] = $blocklist->blocked_userid; } // Exclude banned userid if (!empty($target) && !empty($blockedUserId)) { $target = array_diff($target, $blockedUserId); } if (!empty($app)) { $rows = $activities->getAppActivities($options); } else { $rows = $activities->getActivities($actor, $target, $date, $maxList, $config->get('respectactivityprivacy'), $exclusions, $displayArchived); } $day = -1; // If exclusion is set, we need to remove activities that arrives // after the exclusion list is set. // Inject additional properties for processing for ($i = 0; $i < count($rows); $i++) { $row =& $rows[$i]; // A 'used' activities = activities that has been aggregated $row->used = false; // If the id is larger than any of the exclusion list, // we simply hide it if (isset($exclusion) && $exclusion > 0 && $row->id > $exclusions) { $row->used = true; } } unset($row); $dayinterval = ACTIVITY_INTERVAL_DAY; $lastTitle = ''; // Experimental Viewer Sensitive Profile Status $viewer = CFactory::getUser()->id; $view = JRequest::getCmd('view'); foreach ($rows as $row) { /* if ($row->app=='profile') { // strip off {actor} and {target} from the previous format $row->title = CString::str_ireplace('{actor} to {target}', '', $row->title); $row->title = CString::str_ireplace('{actor}', '', $row->title); $row->title = CString::str_ireplace('{target}', '', $row->title); // self-post status and status from other on viewer's profile - don't display target // @todo: this really need to go to the template instead $titleString = ($row->actor == $row->target || $row->target == 0 ) ? '{actor}' : '{actor} <span class="com_icons com_icons12 com_icons-inline com_icons-rarr">»</span> {target}'; $titleString = '<div class="newsfeed-content-actor">'.$titleString. '</div>%1$s'; $row->title = JText::sprintf($titleString,$row->title); } */ if ($row->app == 'events.wall' || $row->app == 'groups.wall') { //add actor //$row->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_STATUS_MESSAGE',$row->title); } } for ($i = 0; $i < count($rows) && count($htmlData) <= $maxList; $i++) { $row = $rows[$i]; $oRow =& $rows[$i]; // The original object // store aggregated activities $oRow->activities = array(); if (!$row->used && count($htmlData) <= $maxList) { $oRow =& $rows[$i]; if (!isset($row->used)) { $row->used = false; } if ($day != $row->getDayDiff()) { $act = new stdClass(); $act->type = 'content'; $day = $row->getDayDiff(); if ($day == 0) { $act->title = JText::_('TODAY'); } else { if ($day == 1) { $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_YESTERDAY'); } else { if ($day < 7) { $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_DAYS_AGO', $day); } else { if ($day >= 7 && $day < 30) { $dayinterval = ACTIVITY_INTERVAL_WEEK; $act->title = intval($day / $dayinterval) == 1 ? JText::_('COM_COMMUNITY_ACTIVITIES_WEEK_AGO') : JText::sprintf('COM_COMMUNITY_ACTIVITIES_WEEK_AGO_MANY', intval($day / $dayinterval)); } else { if ($day >= 30) { $dayinterval = ACTIVITY_INTERVAL_MONTH; $act->title = intval($day / $dayinterval) == 1 ? JText::_('COM_COMMUNITY_ACTIVITIES_MONTH_AGO') : JText::sprintf('COM_COMMUNITY_ACTIVITIES_MONTH_AGO_MANY', intval($day / $dayinterval)); } } } } } // set to a new 'title' type if this new one has a new title // only add if this is a new title if ($act->title != $lastTitle) { $lastTitle = $act->title; $act->type = 'title'; $htmlData[] = $act; } } $act = new stdClass(); $act->type = 'content'; // Set to compact view if necessary // This method is a bit crude, but we have no other reliable data // to choose which will go to compact view // Attend an event $act->compactView = !(strpos($oRow->params, 'action=events.attendence.attend') === FALSE); $act->compactView = $act->compactView || !(strpos($oRow->params, '"action":"events.attendence.attend"') === FALSE); // Create an event $act->compactView = $act->compactView || !(strpos($oRow->params, 'action=events.create') === FALSE); $act->compactView = $act->compactView || !(strpos($oRow->params, '"action":"events.create"') === FALSE); // Update/join group $act->compactView = $act->compactView || $oRow->app == 'groups' && empty($oRow->content); // Add as friend $act->compactView = $act->compactView || $oRow->app == 'friends'; // Add/Remove app. This is tricky since string is hard-coded // and no other info is available $act->compactView = $act->compactView || $oRow->title == JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED'); // Feature a user $act->compactView = $act->compactView || $oRow->app == 'users'; $title = $row->title; $app = $row->app; $cid = $row->cid; $actor = $row->actor; //Check for event or group title if exists if ($row->eventid) { $eventModel = CFactory::getModel('events'); $act->appTitle = $eventModel->getTitle($row->eventid); } else { if ($row->groupid) { $groupModel = CFactory::getModel('groups'); $act->appTitle = $groupModel->getGroupName($row->groupid); } } for ($j = $i; $j < count($rows) && $row->getDayDiff() == $day; $j++) { $row = $rows[$j]; // we aggregate stream that has the same content on the same day. // we should not however aggregate content that does not support // multiple content. How do we detect? easy, they don't have // {multiple} in the title string // However, if the activity is from the same user, we only want // to show the laste acitivity if ($row->getDayDiff() == $day && $row->title == $title && $app == $row->app && $cid == $row->cid && (JString::strpos($row->title, '{/multiple}') !== FALSE || $row->actor == $actor)) { // @rule: If an exclusion is added, we need to fetch activities without these items. // Aggregated activities should also be excluded. $row->used = true; $oRow->activities[] = $row; } } $app = !empty($oRow->app) ? $this->_appLink($oRow->app, $oRow->actor, $oRow->target, $oRow->title) : ''; $oRow->title = CString::str_ireplace('{app}', $app, $oRow->title); $favicon = ''; // this should not really be empty if (!empty($oRow->app)) { // Favicon override with group image for known group stream data //if(in_array($oRow->app, CGroups::getStreamAppCode())){ if ($oRow->groupid) { // check if the image icon exist in template folder $favicon = JURI::root() . 'components/com_community/assets/favicon/groups.png'; if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . $config->get('template') . DS . 'images' . DS . 'favicon' . DS . 'groups.png')) { $favicon = JURI::root() . 'components/com_community/templates/' . $config->get('template') . '/images/favicon/groups.png'; } } // Favicon override with event image for known event stream data // This would override group favicon if ($oRow->eventid) { // check if the image icon exist in template folder $favicon = JURI::root() . 'components/com_community/assets/favicon/events.png'; if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . $config->get('template') . DS . 'images' . DS . 'favicon' . DS . 'groups.png')) { $favicon = JURI::root() . 'components/com_community/templates/' . $config->get('template') . '/images/favicon/events.png'; } } // If it is not group or event stream, use normal favicon search if (!($oRow->groupid || $oRow->eventid)) { // check if the image icon exist in template folder if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . $config->get('template') . DS . 'images' . DS . 'favicon' . DS . $oRow->app . '.png')) { $favicon = JURI::root() . 'components/com_community/templates/' . $config->get('template') . '/images/favicon/' . $oRow->app . '.png'; } else { // check if the image icon exist in asset folder if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'assets' . DS . 'favicon' . DS . $oRow->app . '.png')) { $favicon = JURI::root() . 'components/com_community/assets/favicon/' . $oRow->app . '.png'; } elseif (JFile::exists(CPluginHelper::getPluginPath('community', $oRow->app) . DS . $oRow->app . DS . 'favicon.png')) { $favicon = JURI::root() . CPluginHelper::getPluginURI('community', $oRow->app) . '/' . $oRow->app . '/favicon.png'; } else { $favicon = JURI::root() . 'components/com_community/assets/favicon/default.png'; } } } } else { $favicon = JURI::root() . 'components/com_community/assets/favicon/default.png'; } $act->favicon = $favicon; $target = $this->_targetLink($oRow->target, true); $oRow->title = CString::str_ireplace('{target}', $target, $oRow->title); if (count($oRow->activities) > 1) { // multiple $actorsLink = ''; foreach ($oRow->activities as $actor) { if (empty($actorsLink)) { $actorsLink = $this->_actorLink(intval($actor->actor)); } else { // only add if this actor is NOT already linked $alink = $this->_actorLink(intval($actor->actor)); $pos = strpos($actorsLink, $alink); if ($pos === false) { $actorsLink .= ', ' . $alink; } } } $actorLink = $this->_actorLink(intval($oRow->actor)); $count = count($oRow->activities); $oRow->title = preg_replace('/\\{single\\}(.*?)\\{\\/single\\}/i', '', $oRow->title); $search = array('{multiple}', '{/multiple}'); $oRow->title = CString::str_ireplace($search, '', $oRow->title); //Joomla 1.6 CString::str_ireplace issue of not replacing correctly strings with backslashes $oRow->title = str_ireplace($search, '', $oRow->title); $oRow->title = CString::str_ireplace('{actors}', $actorsLink, $oRow->title); $oRow->title = CString::str_ireplace('{actor}', $actorLink, $oRow->title); $oRow->title = CString::str_ireplace('{count}', $count, $oRow->title); } else { // single $actorLink = $this->_actorLink(intval($oRow->actor)); $oRow->title = preg_replace('/\\{multiple\\}(.*)\\{\\/multiple\\}/i', '', $oRow->title); $search = array('{single}', '{/single}'); $oRow->title = CString::str_ireplace($search, '', $oRow->title); $oRow->title = CString::str_ireplace('{actor}', $actorLink, $oRow->title); } // If the param contains any data, replace it with the content preg_match_all("/{(.*?)}/", $oRow->title, $matches, PREG_SET_ORDER); if (!empty($matches)) { $params = new CParameter($oRow->params); 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::_($replaceWith); } if (!is_null($replaceWith)) { $oRow->title = CString::str_ireplace($val[0], $replaceWith, $oRow->title); } } } // Format the title $oRow->title = $plgObj ? $plgObj->_censor($oRow->title) : $oRow->title; $oRow->title = $this->_formatTitle($oRow); $act->id = $oRow->id; $act->title = $oRow->title; $act->actor = $oRow->actor; $act->target = $oRow->target; $act->content = $this->getActivityContent($oRow); $timeFormat = $config->get('activitiestimeformat'); $dayFormat = $config->get('activitiesdayformat'); $date = CTimeHelper::getDate($oRow->created); $createdTime = ''; if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) { $createdTime = $date->toFormat($dayinterval == ACTIVITY_INTERVAL_DAY ? $timeFormat : $dayFormat, true); } else { $createdTime = CTimeHelper::timeLapse($date); } $act->created = $createdTime; $act->createdDate = C_JOOMLA_15 == 1 ? $date->toFormat(JText::_('DATE_FORMAT_LC2')) : $date->Format(JText::_('DATE_FORMAT_LC2')); $act->createdDateRaw = $oRow->created; $act->app = $oRow->app; $act->eventid = $oRow->eventid; $act->groupid = $oRow->groupid; $act->group_access = $oRow->group_access; $act->event_access = $oRow->event_access; $act->location = $oRow->getLocation(); $act->commentCount = $oRow->getCommentCount(); $act->commentAllowed = $oRow->allowComment(); $act->commentLast = $oRow->getLastComment(); $act->likeCount = $oRow->getLikeCount(); $act->likeAllowed = $oRow->allowLike(); $act->isFriend = $my->isFriendWith($act->actor); $act->isMyGroup = $my->isInGroup($oRow->groupid); $act->isMyEvent = $my->isInEvent($oRow->eventid); $act->userLiked = $oRow->userLiked($my->id); $htmlData[] = $act; } } $objActivity = new stdClass(); $objActivity->data = $htmlData; return $objActivity; }
private function _sendLogInfo() { if (JFile::exists(JPATH_ROOT . CPluginHelper::getPluginURI('community', 'log') . DS . 'log.php') && JPluginHelper::isEnabled('community', 'log')) { require_once JPATH_ROOT . CPluginHelper::getPluginURI('community', 'log') . DS . 'log.php'; } else { return; } if (class_exists('plgCommunityLog')) { $dispatcher =& JDispatcher::getInstance(); $plugin =& JPluginHelper::getPlugin('community', 'log'); $instance = new plgCommunityLog($dispatcher, (array) $plugin); if ($instance->export()) { $this->message[] = JText::_('Success uploading log files'); } else { $this->message[] = JText::_('Failed to upload log files'); } } }
public function hasConfig($element) { jimport('joomla.filesystem.file'); return JFile::exists(CPluginHelper::getPluginPath('community', JString::trim($element)) . '/' . JString::trim($element) . '/config.xml'); }
public function editPage() { if (!$this->accessAllowed('registered')) { return; } $my = CFactory::getUser(); $appsModel = CFactory::getModel('apps'); //------ pre-1.8 ------// // Get coreapps $coreApps = $appsModel->getCoreApps(); for ($i = 0; $i < count($coreApps); $i++) { $appInfo = $appsModel->getAppInfo($coreApps[$i]->apps); // @rule: Try to get proper app id from #__community_users table first. $id = $appsModel->getUserApplicationId($coreApps[$i]->apps, $my->id); // @rule: If there aren't any records, we need to get it from #__plugins table. if (empty($id)) { $id = $appsModel->getPluginId($coreApps[$i]->apps, null, true); } $coreApps[$i]->id = $id; $coreApps[$i]->title = $appInfo->title; $coreApps[$i]->description = $appInfo->description; $coreApps[$i]->name = $coreApps[$i]->apps; //$coreApps[$i]->coreapp = $params->get( 'coreapp' ); //Get application favicon if (JFile::exists(CPluginHelper::getPluginPath('community', $coreApps[$i]->apps) . '/' . $coreApps[$i]->apps . '/favicon_64.png')) { $coreApps[$i]->appFavicon = JURI::root(true) . CPluginHelper::getPluginURI('community', $coreApps[$i]->apps) . '/' . $coreApps[$i]->apps . '/favicon_64.png'; } else { $coreApps[$i]->appFavicon = JURI::root(true) . '/components/com_community/assets/app_favicon.png'; } } //------ pre-1.8 ------// // Get user apps $userApps = $appsModel->getUserApps($my->id); $appItems = array(); $appItems['sidebar-top-core'] = ''; $appItems['sidebar-bottom-core'] = ''; $appItems['sidebar-top'] = ''; $appItems['sidebar-bottom'] = ''; $appItems['content'] = ''; $appItems['content-core'] = ''; $appsList = array(); for ($i = 0; $i < count($userApps); $i++) { // TODO: getUserApps should return all this value already $id = $appsModel->getPluginId($userApps[$i]->apps, null, true); $appInfo = $appsModel->getAppInfo($userApps[$i]->apps); $params = new CParameter($appsModel->getPluginParams($id, null)); $isCoreApp = $params->get('coreapp'); $corePosition = $params->get('position'); $userApps[$i]->title = isset($appInfo->title) ? $appInfo->title : ''; $userApps[$i]->description = isset($appInfo->description) ? $appInfo->description : ''; $userApps[$i]->coreapp = $isCoreApp; // Pre 1.8x $userApps[$i]->isCoreApp = $isCoreApp; $userApps[$i]->name = $userApps[$i]->apps; $userApps[$i]->hide_empty = $appInfo->hide_empty; //------ pre-1.8 ------// if (JFile::exists(CPluginHelper::getPluginPath('community', $userApps[$i]->apps) . '/favicon.png')) { $userApps[$i]->favicon['16'] = JURI::root(true) . CPluginHelper::getPluginURI('community', $userApps[$i]->apps) . '/' . $userApps[$i]->apps . '/favicon.png'; } else { $userApps[$i]->favicon['16'] = JURI::root(true) . '/components/com_community/assets/app_favicon.png'; } $position = !empty($userApps[$i]->position) ? $userApps[$i]->position : 'content' . ($isCoreApp ? '-core' : ''); // if this is core app, use the config from coreposition instead $position = $isCoreApp ? $corePosition : $position; $appsList[$position][] = $userApps[$i]; } foreach ($appsList as $position => $apps) { $tmpl = new CTemplate(); if (isset($appItems[$position])) { $appItems[$position] .= $tmpl->set('apps', $apps)->set('itemType', 'edit')->fetch('application.item'); } } // Get available apps for comparison $appsModel = CFactory::getModel('apps'); $apps = $appsModel->getAvailableApps(false); $appsname = array(); $availableApps = array(); if (!empty($apps)) { foreach ($apps as $data) { array_push($availableApps, $data->name); } } // Check if apps exist, if not delete it. $obsoleteApps = array(); $obsoleteApps = array_diff($appsname, $availableApps); if (!empty($obsoleteApps)) { foreach ($obsoleteApps as $key => $obsoleteApp) { $appRecords = $appsModel->checkObsoleteApp($obsoleteApp); if (empty($appRecords)) { if ($appRecords == NULL) { $appsModel->removeObsoleteApp($obsoleteApp); } unset($userApps[$key]); } } $userApps = array_values($userApps); } /** * Opengraph */ CHeadHelper::setType('website', JText::_('COM_COMMUNITY_APPS_MINE')); $this->addPathway(JText::_('COM_COMMUNITY_APPS_MINE')); //$this->showSubMenu(); // pre-1.8 //CFactory::load( 'libraries' , 'window' ); CWindow::load(); // CFactory::attach('assets/jquery.tablednd_0_5.js', 'js'); // pre-1.8 // CFactory::attach('assets/ui.core.js', 'js'); // CFactory::attach('assets/ui.sortable.js', 'js'); // CFactory::attach('assets/applayout.js', 'js'); $tmpl = new CTemplate(); echo $tmpl->set('coreApplications', $coreApps)->set('applications', $userApps)->set('appItems', $appItems)->set('submenu', $this->showSubmenu(false))->fetch('applications.edit'); }
/** * Return current user status * @return string user status */ public function getStatus($rawFormat = false) { jimport('joomla.filesystem.file'); // @rule: If user requested for a raw format, we should pass back the raw status. $statusmodel = CFactory::getModel('status'); $statusmodel = $statusmodel->get($this->_userid); $status = $statusmodel->status; if ($rawFormat) { return $status; } // @rule: We need to escape any unwanted stuffs here before proceeding. CFactory::load('helpers', 'string'); $status = CStringHelper::escape($status); if (JFile::Exists(CPluginHelper::getPluginURI('community', 'wordfilter') . DS . 'wordfilter.php') && JPluginHelper::isEnabled('community', 'wordfilter')) { require_once CPluginHelper::getPluginURI('community', 'wordfilter') . DS . 'wordfilter.php'; if (class_exists('plgCommunityWordfilter')) { $dispatcher =& JDispatcher::getInstance(); $plugin =& JPluginHelper::getPlugin('community', 'wordfilter'); $instance = new plgCommunityWordfilter($dispatcher, (array) $plugin); } $status = $instance->_censor($status); } // @rule: Create proper line breaks. $status = CStringHelper::nl2br($status); // @rule: Auto link statuses CFactory::load('helpers', 'linkgenerator'); $status = CLinkGeneratorHelper::replaceURL($status); return $status; }
/** * Return an array of activity data * * @param type $options * @return mixed $type string or arrayn or string */ private function _getData($options) { $dispatcher = CDispatcher::getInstanceStatic(); $observers = $dispatcher->getObservers(); $plgObj = false; for ($i = 0; $i < count($observers); $i++) { if ($observers[$i] instanceof plgCommunityWordfilter) { $plgObj = $observers[$i]; } } // Default params $default = array('actid' => null, 'actor' => 0, 'target' => 0, 'date' => null, 'app' => null, 'cid' => null, 'groupid' => null, 'eventid' => null, 'maxList' => 20, 'type' => '', 'exclusions' => null, 'displayArchived' => false); /* Merge with input options */ $options = array_merge($default, $options); extract($options); /* Get models */ $activities = CFactory::getModel('activities'); /* Variables */ $my = CFactory::getUser(); $htmlData = array(); $config = CFactory::getConfig(); $blockLists = $my->getBlockedUsers(); $blockedUserId = array(); foreach ($blockLists as $blocklist) { $blockedUserId[] = $blocklist->blocked_userid; } // Exclude banned userid if (!empty($target) && !empty($blockedUserId)) { $target = array_diff($target, $blockedUserId); } if (!empty($app)) { $rows = $activities->getAppActivities($options); } else { $rows = $activities->getActivities($actor, $target, $date, $maxList, $config->get('respectactivityprivacy'), $exclusions, $displayArchived, $actid, $groupid, $eventid, $options); } $day = -1; // If exclusion is set, we need to remove activities that arrives // after the exclusion list is set. // Inject additional properties for processing for ($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; // A 'used' activities = activities that has been aggregated $row->used = false; // If the id is larger than any of the exclusion list, // we simply hide it if (isset($exclusion) && $exclusion > 0 && $row->id > $exclusions) { $row->used = true; } } unset($row); $dayinterval = ACTIVITY_INTERVAL_DAY; $lastTitle = ''; for ($i = 0; $i < count($rows) && count($htmlData) <= $maxList; $i++) { $row = $rows[$i]; $oRow = $rows[$i]; // The original object // store aggregated activities $oRow->activities = array(); if (!$row->used && count($htmlData) <= $maxList) { $oRow = $rows[$i]; if (!isset($row->used)) { $row->used = false; } if ($day != $row->getDayDiff()) { $act = new stdClass(); $act->type = 'content'; $day = $row->getDayDiff(); if ($day == 0) { $act->title = JText::_('TODAY'); } else { if ($day == 1) { $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_YESTERDAY'); } else { if ($day < 7) { $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_DAYS_AGO', $day); } else { if ($day >= 7 && $day < 30) { $dayinterval = ACTIVITY_INTERVAL_WEEK; $act->title = intval($day / $dayinterval) == 1 ? JText::_('COM_COMMUNITY_ACTIVITIES_WEEK_AGO') : JText::sprintf('COM_COMMUNITY_ACTIVITIES_WEEK_AGO_MANY', intval($day / $dayinterval)); } else { if ($day >= 30) { $dayinterval = ACTIVITY_INTERVAL_MONTH; $act->title = intval($day / $dayinterval) == 1 ? JText::_('COM_COMMUNITY_ACTIVITIES_MONTH_AGO') : JText::sprintf('COM_COMMUNITY_ACTIVITIES_MONTH_AGO_MANY', intval($day / $dayinterval)); } } } } } // set to a new 'title' type if this new one has a new title // only add if this is a new title if ($act->title != $lastTitle) { $lastTitle = $act->title; $act->type = 'title'; $htmlData[] = $act; } } $act = new stdClass(); $act->type = 'content'; $title = $row->title; $app = $row->app; $cid = $row->cid; $actor = $row->actor; $commentTypeId = $row->comment_type . $row->comment_id; //Check for event or group title if exists if ($row->eventid) { $eventModel = CFactory::getModel('events'); $act->appTitle = $eventModel->getTitle($row->eventid); } else { if ($row->groupid) { $groupModel = CFactory::getModel('groups'); $act->appTitle = $groupModel->getGroupName($row->groupid); } } for ($j = $i; $j < count($rows) && $row->getDayDiff() == $day; $j++) { $row = $rows[$j]; // we aggregate stream that has the same content on the same day. // we should not however aggregate content that does not support // multiple content. How do we detect? easy, they don't have // {multiple} in the title string // However, if the activity is from the same user, we only want // to show the laste acitivity if ($row->getDayDiff() == $day && $row->title == $title && $app == $row->app && $cid == $row->cid && (JString::strpos($row->title, '{/multiple}') !== FALSE || $row->actor == $actor) && $commentTypeId == $row->comment_type . $row->comment_id && $row->app != "photos") { // @rule: If an exclusion is added, we need to fetch activities without these items. // Aggregated activities should also be excluded. // $row->used = true; $oRow->activities[] = $row; } } $app = !empty($oRow->app) ? $this->_appLink($oRow->app, $oRow->actor, $oRow->target, $oRow->title) : ''; $oRow->title = CString::str_ireplace('{app}', $app, $oRow->title); $favicon = ''; // this should not really be empty if (!empty($oRow->app)) { // Favicon override with group image for known group stream data //if(in_array($oRow->app, CGroups::getStreamAppCode())){ if ($oRow->groupid) { // check if the image icon exist in template folder $favicon = JURI::root() . 'components/com_community/assets/favicon/groups.png'; if (JFile::exists(JPATH_ROOT . '/components/com_community/templates' . '/' . $config->get('template') . '/images/favicon/groups.png')) { $favicon = JURI::root(true) . '/components/com_community/templates/' . $config->get('template') . '/images/favicon/groups.png'; } } // Favicon override with event image for known event stream data // This would override group favicon if ($oRow->eventid) { // check if the image icon exist in template folder $favicon = JURI::root() . 'components/com_community/assets/favicon/events.png'; if (JFile::exists(JPATH_ROOT . '/components/com_community/templates' . '/' . $config->get('template') . '/images/favicon/groups.png')) { $favicon = JURI::root(true) . '/components/com_community/templates/' . $config->get('template') . '/images/favicon/events.png'; } } // If it is not group or event stream, use normal favicon search if (!($oRow->groupid || $oRow->eventid)) { // check if the image icon exist in template folder if (JFile::exists(JPATH_ROOT . '/components/com_community/templates' . '/' . $config->get('template') . '/images/favicon' . '/' . $oRow->app . '.png')) { $favicon = JURI::root(true) . '/components/com_community/templates/' . $config->get('template') . '/images/favicon/' . $oRow->app . '.png'; } else { $CPluginHelper = new CPluginHelper(); // check if the image icon exist in asset folder if (JFile::exists(JPATH_ROOT . '/components/com_community/assets/favicon' . '/' . $oRow->app . '.png')) { $favicon = JURI::root(true) . '/components/com_community/assets/favicon/' . $oRow->app . '.png'; } elseif (JFile::exists($CPluginHelper->getPluginPath('community', $oRow->app) . '/' . $oRow->app . '/favicon.png')) { $favicon = JURI::root(true) . "/" . $CPluginHelper->getPluginURI('community', $oRow->app) . '/' . $oRow->app . '/favicon.png'; } else { $favicon = JURI::root(true) . '/components/com_community/assets/favicon/default.png'; } } } } else { $favicon = JURI::root(true) . '/components/com_community/assets/favicon/default.png'; } $act->favicon = $favicon; $target = $this->_targetLink($oRow->target, true); $act->title = $oRow->title; $act->id = $oRow->id; $act->cid = $oRow->cid; $act->title = $oRow->title; $act->actor = $oRow->actor; $act->actors = $oRow->actors; $act->target = $oRow->target; $act->access = $oRow->access; $timeFormat = $config->get('activitiestimeformat'); $dayFormat = $config->get('activitiesdayformat'); $date = CTimeHelper::getDate($oRow->created); // Do not modify created time // $createdTime = ''; // if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) { // $createdTime = $date->format($dayinterval == ACTIVITY_INTERVAL_DAY ? $timeFormat : $dayFormat, true); // } else { // $createdTime = CTimeHelper::timeLapse($date); // } $act->created = $oRow->created; $act->createdDate = $date->Format(JText::_('DATE_FORMAT_LC2')); $act->createdDateRaw = $oRow->created; $act->app = $oRow->app; $act->eventid = $oRow->eventid; $act->groupid = $oRow->groupid; $act->group_access = $oRow->group_access; $act->event_access = $oRow->event_access; $act->location = $oRow->getLocation(); $act->commentCount = $oRow->getCommentCount(); $act->commentAllowed = $oRow->allowComment(); $act->commentLast = $oRow->getLastComment(); $act->commentsAll = $oRow->getCommentsAll(); $act->likeCount = $oRow->getLikeCount(); $act->likeAllowed = $oRow->allowLike(); $act->isFriend = $my->isFriendWith($act->actor); $act->isMyGroup = $my->isInGroup($oRow->groupid); $act->isMyEvent = $my->isInEvent($oRow->eventid); $act->userLiked = $oRow->userLiked($my->id); $act->latitude = $oRow->latitude; $act->longitude = $oRow->longitude; $act->params = !empty($oRow->params) ? $oRow->params : ''; // Create and pass album, videos, groups, event object switch ($act->app) { case 'photos': // Album object $act->album = JTable::getInstance('Album', 'CTable'); $act->album->load($act->cid); $oRow->album = $act->album; break; case 'videos': // Album object $act->video = JTable::getInstance('Video', 'CTable'); $act->video->load($act->cid); $oRow->video = $act->video; break; } // get the content $act->content = $this->getActivityContent($oRow); //$act->title = $this->getActivityTitle($oRow); $act->title = $oRow->title; $act->content = $oRow->content; $htmlData[] = $act; } } $objActivity = new stdClass(); $objActivity->data = $htmlData; return $objActivity; }
/** * Return current user status * @return string user status */ public function getStatus($rawFormat = false) { jimport('joomla.filesystem.file'); // @rule: If user requested for a raw format, we should pass back the raw status. $statusmodel = CFactory::getModel('status'); $statusmodel = $statusmodel->get($this->_userid); $status = $statusmodel->status; if ($rawFormat) { return $status; } $CPluginHelper = new CPluginHelper(); if (JFile::Exists($CPluginHelper->getPluginURI('community', 'wordfilter') . '/wordfilter.php') && $CPluginHelper->isEnabled('community', 'wordfilter')) { require_once $CPluginHelper->getPluginURI('community', 'wordfilter') . '/wordfilter.php'; if (class_exists('plgCommunityWordfilter')) { $dispatcher = JDispatcher::getInstance(); $plugin = JPluginHelper::getPlugin('community', 'wordfilter'); $instance = new plgCommunityWordfilter($dispatcher, (array) $plugin); } $status = $instance->_censor($status); } // Damn it! this really should have been in the template! not littered in the code here $status = CActivities::format($status); return $status; }
public function appFullView() { $userid = JRequest::getInt('userid', null); $profileModel =& $this->getModel('profile'); $avatarModel =& $this->getModel('avatar'); $applications =& CAppPlugins::getInstance(); $appName = JString::strtolower(JRequest::getVar('app', '', 'GET')); if (empty($appName)) { JError::raiseError(500, 'COM_COMMUNITY_APPS_ID_REQUIRED'); } if (is_null($userid)) { JError::raiseError(500, 'COM_COMMUNITY_USER_ID_REQUIRED'); } $user = CFactory::getUser($userid); $document = JFactory::getDocument(); $document->setTitle($user->getDisplayName() . ' : ' . $user->getStatus()); $appsModel = CFactory::getModel('apps'); $appId = $appsModel->getUserApplicationId($appName); $plugin =& $applications->get($appName, $appId); if (!$plugin) { JError::raiseError(500, 'COM_COMMUNITY_APPS_NOT_FOUND'); } // Load plugin params $paramsPath = CPluginHelper::getPluginPath('community', $appName) . DS . $appName . '.xml'; $params = new CParameter($appsModel->getPluginParams($appsModel->getPluginId($appName)), $paramsPath); $plugin->params =& $params; // Load user params $xmlPath = CPluginHelper::getPluginPath('community', $appName) . DS . $appName . DS . $appName . '.xml'; $userParams = new CParameter($appsModel->getUserAppParams($appId, $user->id), $xmlPath); $plugin->userparams =& $userParams; $plugin->id = $appId; $appObj = new stdClass(); $appObj->name = $plugin->name; $appObj->html = $plugin->onAppDisplay($params); $data->html = $appObj->html; $this->attachMiniHeaderUser($user->id); echo $data->html; }
/** * Application full view **/ public function appFullView() { $document = JFactory::getDocument(); $document->setTitle(JText::_('COM_COMMUNITY_GROUPS_WALL_TITLE')); $applicationName = JString::strtolower(JRequest::getVar('app', '', 'GET')); if (empty($applicationName)) { JError::raiseError(500, 'COM_COMMUNITY_APP_ID_REQUIRED'); } $output = ''; $groupModel = CFactory::getModel('groups'); $groupId = JRequest::getInt('groupid', '', 'GET'); $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupId); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { $this->_redirectUnpublishGroup(); return; } //@todo: Since group walls doesn't use application yet, we process it manually now. if ($applicationName == 'walls') { CFactory::load('libraries', 'wall'); $limit = JRequest::getInt('limit', 5, 'REQUEST'); $limitstart = JRequest::getInt('limitstart', 0, 'REQUEST'); $my = CFactory::getUser(); $config = CFactory::getConfig(); $isBanned = $group->isBanned($my->id); // Test if the current browser is a member of the group $isMember = $group->isMember($my->id); $waitingApproval = $groupModel->isWaitingAuthorization($my->id, $group->id); CFactory::load('helpers', 'owner'); if (!$isMember && !COwnerHelper::isCommunityAdmin() && $group->approvals == COMMUNITY_PRIVATE_GROUP) { $this->noAccess(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE')); return; } if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && ($isMember && !$isBanned) && !$waitingApproval || COwnerHelper::isCommunityAdmin()) { $output .= CWallLibrary::getWallInputForm($group->id, 'groups,ajaxSaveWall', 'groups,ajaxRemoveWall'); } // Get the walls content $output .= '<div id="wallContent">'; if (!$isBanned) { $output .= CWallLibrary::getWallContents('groups', $group->id, $my->id == $group->ownerid, $limit, $limitstart, 'wall.content', 'groups,group'); } else { $output .= CWallLibrary::getWallContents('groups', $group->id, $my->id == $group->ownerid, $limit, $limitstart, 'wall.content', 'groups,group', null, 1); } $output .= '</div>'; jimport('joomla.html.pagination'); $wallModel = CFactory::getModel('wall'); $pagination = new JPagination($wallModel->getCount($group->id, 'groups'), $limitstart, $limit); $output .= '<div class="pagination-container">' . $pagination->getPagesLinks() . '</div>'; } else { CFactory::load('libraries', 'apps'); $model = CFactory::getModel('apps'); $applications =& CAppPlugins::getInstance(); $applicationId = $model->getUserApplicationId($applicationName); $application = $applications->get($applicationName, $applicationId); if (!$application) { JError::raiseError(500, 'COM_COMMUNITY_APPS_NOT_FOUND'); } // Get the parameters $manifest = CPluginHelper::getPluginPath('community', $applicationName) . DS . $applicationName . DS . $applicationName . '.xml'; $params = new CParameter($model->getUserAppParams($applicationId), $manifest); $application->params =& $params; $application->id = $applicationId; $output = $application->onAppDisplay($params); } echo $output; }
public function ajaxSendReport() { $reportFunc = func_get_arg(0); $pageLink = func_get_arg(1); $message = func_get_arg(2); $argsCount = func_num_args(); $method = explode(',', $reportFunc); $args = array(); $args[] = $pageLink; $args[] = $message; for ($i = 3; $i < $argsCount; $i++) { $args[] = func_get_arg($i); } // Reporting should be session sensitive // Construct $output $uniqueString = md5($reportFunc . $pageLink); $session = JFactory::getSession(); if ($session->has('action-report-' . $uniqueString)) { $output = JText::_('COM_COMMUNITY_REPORT_ALREADY_SENT'); } else { if (is_array($method) && $method[0] != 'plugins') { $controller = JString::strtolower(basename($method[0])); require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'controllers' . DS . 'controller.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'controllers' . DS . $controller . '.php'; $controller = JString::ucfirst($controller); $controller = 'Community' . $controller . 'Controller'; $controller = new $controller(); $output = call_user_func_array(array(&$controller, $method[1]), $args); } else { if (is_array($method) && $method[0] == 'plugins') { // Application method calls $element = JString::strtolower($method[1]); require_once CPluginHelper::getPluginPath('community', $element) . DS . $element . '.php'; $className = 'plgCommunity' . JString::ucfirst($element); $output = call_user_func_array(array($className, $method[2]), $args); } } } $session->set('action-report-' . $uniqueString, true); // Construct the action buttons $action ob_start(); ?> <button class="button" onclick="javascript:cWindowHide();" name="cancel"> <?php echo JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON'); ?> </button> <?php $action = ob_get_contents(); ob_end_clean(); // Construct the ajax response $objResponse = new JAXResponse(); $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_REPORT_SENT')); $objResponse->addScriptCall('cWindowAddContent', $output, $action); return $objResponse->sendResponse(); }
public function ajaxAddApp($name, $position) { // Check permissions $my =& JFactory::getUser(); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $filter = JFilterInput::getInstance(); $name = $filter->clean($name, 'string'); $position = $filter->clean($position, 'string'); // Add application $appModel = CFactory::getModel('apps'); $appModel->addApp($my->id, $name, $position); // Activity stream $act = new stdClass(); $act->cmd = 'application.add'; $act->actor = $my->id; $act->target = 0; $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED'); $act->content = ''; $act->app = $name; $act->cid = $my->id; CFactory::load('libraries', 'activities'); CActivityStream::add($act); // User points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('application.add'); // Get application $id = $appModel->getUserApplicationId($name, $my->id); $appInfo = $appModel->getAppInfo($name); $params = new CParameter($appModel->getPluginParams($id, null)); $isCoreApp = $params->get('coreapp'); $app->id = $id; $app->title = isset($appInfo->title) ? $appInfo->title : ''; $app->description = isset($appInfo->description) ? $appInfo->description : ''; $app->isCoreApp = $isCoreApp; $app->name = $name; if (JFile::exists(CPluginHelper::getPluginPath('community', $name) . DS . $name . DS . 'favicon.png')) { $app->favicon['16'] = rtrim(JURI::root(), '/') . CPluginHelper::getPluginURI('community', $name) . '/' . $name . '/favicon.png'; } else { $app->favicon['16'] = rtrim(JURI::root(), '/') . '/components/com_community/assets/app_favicon.png'; } $tmpl = new CTemplate(); $tmpl->set('apps', array($app)); $tmpl->set('itemType', 'edit'); $html = $tmpl->fetch('application.item'); $objResponse = new JAXResponse(); $objResponse->addScriptCall('joms.apps.showSettingsWindow', $app->id, $app->name); $objResponse->addScriptCall('joms.editLayout.addAppToLayout', $position, $html); // $objResponse->addScriptCall('cWindowHide();'); return $objResponse->sendResponse(); }
require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'error.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'apps.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'user.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'helpers' . DS . 'access.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'helpers' . DS . 'calendar.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'helpers' . DS . 'kses.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'cache.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'storage.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'parameter.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'helpers' . DS . 'plugins.php'; require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'tables' . DS . 'cache.php'; JTable::addIncludePath(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'tables'); JTable::addIncludePath(COMMUNITY_COM_PATH . DS . 'tables'); //define ZEND_PATH if (!defined('ZEND_PATH')) { define('ZEND_PATH', CPluginHelper::getPluginPath('system', 'zend')); } // In case our core.php files are loaded by 3rd party extensions, we need to define the plugin path environments for Zend. $paths = explode(PATH_SEPARATOR, get_include_path()); if (!in_array(ZEND_PATH, $paths)) { set_include_path('.' . PATH_SEPARATOR . ZEND_PATH . PATH_SEPARATOR . get_include_path()); } if (!class_exists('Zend_Cache')) { $zendAutoLoader = ZEND_PATH . DS . 'Zend' . DS . 'Loader' . DS . 'Autoloader.php'; $isZendEnabled = JPluginHelper::isEnabled('system', 'zend'); $isLoaderExists = JFile::exists($zendAutoLoader); if ($isZendEnabled && $isLoaderExists) { // Only include the zend loader if it has not been loaded first include_once $zendAutoLoader; // register auto-loader $loader = Zend_Loader_Autoloader::getInstance();
/** * Application full view * */ public function appFullView() { /** * Opengraph */ // CHeadHelper::setType('website', JText::_('COM_COMMUNITY_PHOTOS_WALL_TITLE')); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $applicationName = JString::strtolower($jinput->get->get('app', '', 'STRING')); if (empty($applicationName)) { JError::raiseError(500, JText::_('COM_COMMUNITY_APP_ID_REQUIRED')); } $output = '<div class="joms-page">'; $output .= '<h3 class="joms-page__title">' . JText::_('COM_COMMUNITY_PHOTOS_WALL_TITLE') . '</h3>'; if ($applicationName == 'walls') { //CFactory::load( 'libraries' , 'wall' ); $limit = $jinput->request->get('limit', 5, 'INT'); //JRequest::getVar( 'limit' , 5 , 'REQUEST' ); $limitstart = $jinput->request->get('limitstart', 0, 'INT'); //JRequest::getVar( 'limitstart', 0, 'REQUEST' ); $albumId = JRequest::getInt('albumid', ''); $my = CFactory::getUser(); $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); //CFactory::load( 'helpers' , 'owner' ); //CFactory::load( 'helpers' , 'friends' ); // Get the walls content $viewAllLink = false; $wallCount = false; if ($jinput->request->get('task', '') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls'); $wallCount = CWallLibrary::getWallCount('album', $album->id); } $output .= CWallLibrary::getWallContents('albums', $album->id, COwnerHelper::isCommunityAdmin() || COwnerHelper::isMine($my->id, $album->creator), $limit, $limitstart); if (CFriendsHelper::isConnected($my->id, $album->creator) || COwnerHelper::isCommunityAdmin()) { $output .= CWallLibrary::getWallInputForm($album->id, 'photos,ajaxAlbumSaveWall', 'photos,ajaxAlbumRemoveWall'); } $output .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); jimport('joomla.html.pagination'); $wallModel = CFactory::getModel('wall'); $pagination = new JPagination($wallModel->getCount($album->id, 'albums'), $limitstart, $limit); $output .= '<div class="cPagination">' . $pagination->getPagesLinks() . '</div>'; } else { $model = CFactory::getModel('apps'); $applications = CAppPlugins::getInstance(); $applicationId = $model->getUserApplicationId($applicationName); $application = $applications->get($applicationName, $applicationId); if (is_callable(array($application, 'onAppDisplay'), true)) { // Get the parameters $manifest = CPluginHelper::getPluginPath('community', $applicationName) . '/' . $applicationName . '/' . $applicationName . '.xml'; $params = new CParameter($model->getUserAppParams($applicationId), $manifest); $application->params = $params; $application->id = $applicationId; $output = $application->onAppDisplay($params); } else { JError::raiseError(500, JText::_('COM_COMMUNITY_APPS_NOT_FOUND')); } } $output .= '</div>'; echo $output; }
/** * Ajax functiion to handle ajax calls */ public function _ajaxPerformAction($actionId) { $objResponse = new JAXResponse(); $output = ''; // Require Jomsocial core lib require_once JPATH_ROOT . '/components/com_community/libraries/core.php'; $language = JFactory::getLanguage(); $language->load('com_community', JPATH_ROOT); // Get the action data $action = JTable::getInstance('ReportsActions', 'CommunityTable'); $action->load($actionId); // Get the report data $report = JTable::getInstance('Reports', 'CommunityTable'); $report->load($action->reportid); $method = explode(',', $action->action); $args = explode(',', $action->args); if (is_array($method) && $method[0] != 'plugins') { $controller = JString::strtolower($method[0]); require_once JPATH_ROOT . '/components/com_community/controllers/controller.php'; require_once JPATH_ROOT . '/components/com_community/controllers/' . $controller . '.php'; $controller = JString::ucfirst($controller); $controller = 'Community' . $controller . 'Controller'; $controller = new $controller(); $output = call_user_func_array(array(&$controller, $method[1]), $args); } else { if (is_array($method) && $method[0] == 'plugins') { // Application method calls $element = JString::strtolower($method[1]); require_once CPluginHelper::getPluginPath('community', $element) . '/' . $element . '.php'; $className = 'plgCommunity' . JString::ucfirst($element); $output = call_user_func_array(array($className, $method[2]), $args); } } $objResponse->addAssign('cWindowContent', 'innerHTML', $output); // Delete actions $report->deleteChilds(); // Delete the current report $report->delete(); $objResponse->addScriptCall('joms.jQuery("#row' . $report->id . '").remove();'); return $objResponse->sendResponse(); }