public function saveWall($uniqueId, $message, $appType, &$creator, $isOwner, $processFunc = '', $templateFile = 'wall.content', $wallId = 0) { $my = CFactory::getUser(); // Add some required parameters, otherwise assert here CError::assert($uniqueId, '', '!empty', __FILE__, __LINE__); CError::assert($appType, '', '!empty', __FILE__, __LINE__); CError::assert($message, '', '!empty', __FILE__, __LINE__); CError::assert($my->id, '', '!empty', __FILE__, __LINE__); // Load the models CFactory::load('models', 'wall'); CFactory::load('helpers', 'url'); $wall =& JTable::getInstance('Wall', 'CTable'); $wall->load($wallId); if ($wallId == 0) { // Get current date $now =& JFactory::getDate(); $now = $now->toMySQL(); // Set the wall properties $wall->type = $appType; $wall->contentid = $uniqueId; $wall->post_by = $creator->id; $wall->date = $now; $wall->published = 1; // @todo: set the ip address $wall->ip = $_SERVER['REMOTE_ADDR']; } $wall->comment = $message; $filter = CFactory::getInputFilter(); $wall->comment = $filter->clean($wall->comment); // Store the wall message $wall->store(); // Convert it to array so that the walls can be processed by plugins $args = array(); $args[0] =& $wall; //Process wall comments CFactory::load('libraries', 'comment'); $comment = new CComment(); $wallComments = $wall->comment; $wall->comment = $comment->stripCommentData($wall->comment); // Trigger the wall comments CWall::triggerWallComments($args); $wallData = new stdClass(); $wallData->id = $wall->id; $wallData->content = CWallLibrary::_getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile); CFactory::load('helpers', 'string'); $wallData->content = CStringHelper::replaceThumbnails($wallData->content); return $wallData; }
/** * @param $uniqueId * @param $message * @param $appType * @param $creator * @param $isOwner * @param string $processFunc * @param string $templateFile * @param int $wallId * @param int $photoId to attach photoid in the wall if exists * @return stdClass */ public static function saveWall($uniqueId, $message, $appType, &$creator, $isOwner, $processFunc = '', $templateFile = 'wall/content', $wallId = 0, $photoId = 0) { $my = CFactory::getUser(); // Add some required parameters, otherwise assert here CError::assert($uniqueId, '', '!empty', __FILE__, __LINE__); CError::assert($appType, '', '!empty', __FILE__, __LINE__); CError::assert($my->id, '', '!empty', __FILE__, __LINE__); // Load the models $wall = JTable::getInstance('Wall', 'CTable'); $wall->load($wallId); if ($wallId == 0) { // Get current date $now = JFactory::getDate(); $now = $now->toSql(); // Set the wall properties $wall->type = $appType; $wall->contentid = $uniqueId; $wall->post_by = $creator->id; $wall->date = $now; $wall->published = 1; // @todo: set the ip address $wall->ip = $_SERVER['REMOTE_ADDR']; } //if photo id is not 0, this wall is appended with a picture if ($photoId > 0) { //lets check if the photo belongs to the uploader $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoId); //save the data into the wall table $wallParam = new CParameter($wall->params); if ($photo->creator == $my->id && $photo->albumid == '-1') { $wallParam->set('attached_photo_id', $photoId); //sets the status to ready so that it wont be deleted on cron run $photo->status = 'ready'; $photo->store(); } $wall->params = $wallParam->toString(); } elseif ($photoId == -1) { //if there is nothing, remove the param if applicable $wallParam = new CParameter($wall->params); //delete from db and files $photoModel = CFactory::getModel('photos'); if ($wallParam->get('attached_photo_id') > 0) { $photoTable = $photoModel->getPhoto($wallParam->get('attached_photo_id')); $photoTable->delete(); } $wallParam->set('attached_photo_id', 0); $wall->params = $wallParam->toString(); } /* URL fetch */ $graphObject = CParsers::linkFetch($message); if ($graphObject) { $graphObject->merge(new CParameter($wall->params)); $wall->params = $graphObject->toString(); } $wall->comment = $message; // Store the wall message $wall->store(); // Convert it to array so that the walls can be processed by plugins $args = array(); $args[0] = $wall; //Process wall comments $comment = new CComment(); $wallComments = $wall->comment; $wall->comment = $comment->stripCommentData($wall->comment); // Trigger the wall comments CWall::triggerWallComments($args); $wallData = new stdClass(); $wallData->id = $wall->id; $wallData->content = CWallLibrary::_getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile); $wallData->content = CStringHelper::replaceThumbnails($wallData->content); CTags::add($wall); return $wallData; }
/** * Populate the wall area in photos with wall/comments content */ public function showWallContents($photoId, $singleComment = 0) { // Include necessary libraries $my = CFactory::getUser(); $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoId); //@todo: Add limit $limit = 20; if ($photo->id == '0') { echo JText::_('COM_COMMUNITY_PHOTOS_INVALID_PHOTO_ID'); return; } $contents = CWallLibrary::getWallContents('photos', $photoId, $my->id == $photo->creator || COwnerHelper::isCommunityAdmin(), $singleComment, 0, 'wall/content', 'photos,photo'); $contents = CStringHelper::replaceThumbnails($contents); return $contents; }
/** * Execute a request */ public function execute($task = '') { global $mainframe; $document =& JFactory::getDocument(); $my =& JFactory::getUser(); $pathway =& $mainframe->getPathway(); $menus =& JSite::getMenu(); $menuitem =& $menus->getActive(); $userId = JRequest::getInt('userid', '', 'GET'); $tmpl = JRequest::getVar('tmpl', '', 'REQUEST'); $format = JRequest::getVar('format', '', 'REQUEST'); $nohtml = JRequest::getVar('no_html', '', 'REQUEST'); if ($tmpl != 'component' && $format != 'feed' && $format != 'ical' && $nohtml != 1 && $format != 'raw') { // This is to fix MSIE that has incorrect user agent because jquery doesn't detect correctly. $ieFix = "<!--[if IE 6]><script type=\"text/javascript\">var jomsIE6 = true;</script><![endif]-->"; $document->addCustomTag($ieFix); } // Add custom css for the specific view if needed. $config = CFactory::getConfig(); $viewName = JString::strtolower(JRequest::getVar('view', '', 'REQUEST')); jimport('joomla.filesystem.file'); if ($config->get('enablecustomviewcss')) { CTemplate::addStylesheet($viewName); } $env = CTemplate::getTemplateEnvironment(); $html = '<div id="community-wrap" class="on-' . $env->joomlaTemplate . ' ' . $document->direction . '">'; // Build the component menu module ob_start(); CTemplate::renderModules('js_top'); $moduleHTML = ob_get_contents(); ob_end_clean(); $html .= $moduleHTML; // Build the content HTML CFactory::load('helpers', 'azrul'); $inbox =& $this->getModel('inbox'); $unread = $inbox->countUnRead(array('user_id' => $my->id)); $param = array('inbox' => $unread); if (!empty($task) && method_exists($this, $task)) { ob_start(); if (method_exists($this, '_viewEnabled') && !$this->_viewEnabled()) { echo property_exists($this, '_disabledMessage') ? $this->_disabledMessage : JText::_('Function is disabled'); } else { $this->{$task}(); } $output = ob_get_contents(); ob_end_clean(); } else { ob_start(); $this->display(); $output = ob_get_contents(); ob_end_clean(); } // Build toolbar HTML ob_start(); $view =& $this->getView(JRequest::getCmd('view', 'frontpage')); $view->showToolbar($param); // Header title will use view->title. If not specified, we will // use current page title $headerTitle = !empty($view->title) ? $view->title : $document->getTitle(); $view->showHeader($headerTitle, $this->_icon); $header = ob_get_contents(); ob_end_clean(); $html .= $header; // @rule: Super admin should always be allowed regardless of their block status // block member to access profile owner details CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'block'); $getBlockStatus = new blockUser(); $blocked = $getBlockStatus->isUserBlocked($userId, $viewName); if ($blocked) { if (COwnerHelper::isCommunityAdmin()) { $mainframe =& JFactory::getApplication(); $mainframe->enqueueMessage(JText::_('CC YOU ARE BLOCKED BY USER', 'error')); } else { $tmpl = new CTemplate(); $output .= $tmpl->fetch('block.denied'); } } // Build the component bottom module ob_start(); CTemplate::renderModules('js_bottom'); $moduleHTML = ob_get_contents(); ob_end_clean(); $html .= $output . $moduleHTML . '</div>'; CFactory::load('helpers', 'string'); $html = CStringHelper::replaceThumbnails($html); $html = JString::str_ireplace(array('{error}', '{warning}', '{info}'), '', $html); // Trigger onModuleDisplay() CFactory::load('libraries', 'apps'); $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $moduleHTML = $appsLib->triggerEvent('onModuleRender'); $mods = array(); foreach ($moduleHTML as $modules) { foreach ($modules as $position => $content) { if (empty($mods[$position])) { $mods[$position] = ''; } $mods[$position] .= $content; } } foreach ($mods as $position => $module) { $html = str_replace('<!-- ' . $position . ' -->', $module, $html); } // Display viewType switcher // $browser = CBrowser::getInstance(); // if( $browser->_mobile ) // { // CFactory::load('libraries', 'mobile'); // ob_start(); // CMobile::showSwitcher(); // $switcherHTML = ob_get_contents(); // ob_end_clean(); // $html .= $switcherHTML; // } echo $html; }
function _getWallHTML($userid, $limit, $limitstart, $allowPosting, $allowRemoval) { $config = CFactory::getConfig(); $html = ''; $viewAllLink = false; if (JRequest::getVar('task', '', 'REQUEST') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $userid . '&task=app&app=walls'); } $wallCount = CWallLibrary::getWallCount('user', $userid); $wallModel = CFactory::getModel('wall'); $wallsinput = ""; if ($allowPosting) { $wallsinput = CWallLibrary::getWallInputForm($userid, 'plugins,walls,ajaxSaveWall', 'plugins,walls,ajaxRemoveWall', $viewAllLink); } $contents = CWallLibrary::getWallContents('user', $userid, $allowRemoval, $limit, $limitstart, 'wall.content', 'profile,profile'); $contents .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); $html .= $wallsinput; $html .= '<div id="wallContent" style="display: block; visibility: visible;">'; if ($contents == '') { $html .= ' <div id="wall-empty-container"> <div class="icon-nopost"> <img src="' . JURI::base() . 'plugins/community/walls/favicon.png" alt="" /> </div> <div class="content-nopost">' . JText::_('PLG_WALLS_NO_WALL_POST') . ' </div> </div>'; } else { $html .= CStringHelper::replaceThumbnails($contents); } $html .= '</div>'; // Add pagination links, only in full app view if (JRequest::getVar('task', '', 'REQUEST') == 'app') { jimport('joomla.html.pagination'); $pagination = new JPagination($wallModel->getCount($userid, 'user'), $limitstart, $limit); $html .= ' <!-- Pagination --> <div style="text-align: center;"> ' . $pagination->getPagesLinks() . ' </div> <!-- End Pagination -->'; } return $html; }
public function ajaxGetOlderWalls($groupId, $discussionId, $limitStart) { $filter = JFilterInput::getInstance(); $groupId = $filter->clean($groupId, 'int'); $discussionId = $filter->clean($discussionId, 'int'); $limitStart = $filter->clean($limitStart, 'int'); $limitStart = max(0, $limitStart); $response = new JAXResponse(); $app = JFactory::getApplication(); $my = CFactory::getUser(); //$jconfig = JFactory::getConfig(); $groupModel = CFactory::getModel('groups'); $isGroupAdmin = $groupModel->isAdmin($my->id, $groupId); $html = CWall::getWallContents('discussions', $discussionId, $isGroupAdmin, $app->getCfg('list_limit'), $limitStart, 'wall/content', 'groups,discussion', $groupId); // parse the user avatar $html = CStringHelper::replaceThumbnails($html); $html = CString::str_ireplace(array('{error}', '{warning}', '{info}'), '', $html); $config = CFactory::getConfig(); $order = $config->get('group_discuss_order'); if ($order == 'ASC') { // Append new data at Top. $response->addScriptCall('joms.walls.prepend', $html); } else { // Append new data at bottom. $response->addScriptCall('joms.walls.append', $html); } return $response->sendResponse(); }
/** * Execute a request */ public function execute($task) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $document = JFactory::getDocument(); $my = CFactory::getUser(); $pathway = $mainframe->getPathway(); $menus = $mainframe->getMenu(); $menuitem = $menus->getActive(); $userId = $jinput->get->get('userid', '', 'INT'); $tmpl = $jinput->request->get('tmpl', '', 'STRING'); $format = $jinput->request->get('format', '', 'STRING'); $nohtml = $jinput->request->get('no_html', '', 'STRING'); if ($tmpl != 'component' && $format != 'feed' && $format != 'ical' && $nohtml != 1 && $format != 'raw') { // This is to fix MSIE that has incorrect user agent because jquery doesn't detect correctly. $ieFix = "<!--[if IE 6]><script type=\"text/javascript\">var jomsIE6 = true;</script><![endif]-->"; $document->addCustomTag($ieFix); } // Add custom css for the specific view if needed. $config = CFactory::getConfig(); $viewName = JString::strtolower($jinput->request->get('view', '', 'STRING')); jimport('joomla.filesystem.file'); if ($config->get('enablecustomviewcss')) { CTemplate::addStylesheet($viewName); } $template = JFactory::getApplication()->getTemplate(); // echo var_dump(CTemplate::addStylesheet('beez2')); if ($template == 'beez_20' && JVERSION > 2 && JVERSION < 3) { CTemplate::addStylesheet('beez2'); } $env = CTemplate::getTemplateEnvironment(); $svgFile = CFactory::getPath('template://assets/icon/joms-icon.svg'); // non ajax-prefixed tasks that should avoid svg $excludeSvgList = array('changeAvatar', 'multiUpload', 'uploadvideo'); // exclude svg file from ajax response if ($svgFile && substr($task, 0, 4) != 'ajax' && !in_array($task, $excludeSvgList)) { include_once $svgFile; } $html = '<div id="community-wrap" class="jomsocial-wrapper on-' . $env->joomlaTemplate . ' ' . $document->direction . ' c' . ucfirst($viewName) . '">'; $html .= '<div class="jomsocial">'; // Build the component menu module ob_start(); $tmpl = new CTemplate(); $tmpl->renderModules('js_top'); $moduleHTML = ob_get_contents(); ob_end_clean(); $html .= $moduleHTML; // Build the content HTML //CFactory::load( 'helpers' , 'azrul' ); if (!empty($task) && method_exists($this, $task)) { ob_start(); if (method_exists($this, '_viewEnabled') && !$this->_viewEnabled()) { echo property_exists($this, '_disabledMessage') ? $this->_disabledMessage : JText::_('COM_COMMUNITY_CONTROLLER_FUNCTION_DISABLED_WARNING'); } else { $this->{$task}(); } $output = ob_get_contents(); ob_end_clean(); } else { ob_start(); $this->display(); $output = ob_get_contents(); ob_end_clean(); } // Build toolbar HTML ob_start(); $view = $this->getView(JString::strtolower($jinput->get('view', 'frontpage', 'STRING'))); // Do not rely on the toolbar to include necessary css or javascripts. $view->attachHeaders(); // Display the site's toolbar. $view->showToolbar(); // Header title will use view->title. If not specified, we will // use current page title $headerTitle = !empty($view->title) ? $view->title : $document->getTitle(); $view->showHeader($headerTitle, $this->_icon); $header = ob_get_contents(); ob_end_clean(); $html .= $header; // @rule: Super admin should always be allowed regardless of their block status // block member to access profile owner details //CFactory::load( 'helpers' , 'owner' ); //CFactory::load( 'libraries' , 'block' ); $getBlockStatus = new blockUser(); $blocked = $getBlockStatus->isUserBlocked($userId, $viewName); if ($blocked) { if (COwnerHelper::isCommunityAdmin()) { $mainframe = JFactory::getApplication(); $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_YOU_ARE_BLOCKED_BY_USER', 'error')); } else { $tmpl = new CTemplate(); $view->showToolbar(); echo $tmpl->fetch('block.denied'); return; $block = true; } } // Build the component bottom module ob_start(); $tmpl = new CTemplate(); $tmpl->renderModules('js_bottom'); $moduleHTML = ob_get_contents(); ob_end_clean(); $html .= $output . $moduleHTML . '</div></div>'; //CFactory::load( 'helpers' , 'string' ); $html = CStringHelper::replaceThumbnails($html); $html = CString::str_ireplace(array('{error}', '{warning}', '{info}'), '', $html); // Trigger onModuleDisplay() //CFactory::load( 'libraries' , 'apps' ); $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $moduleHTML = $appsLib->triggerEvent('onModuleRender'); $mods = array(); if (is_array($moduleHTML)) { foreach ($moduleHTML as $modules) { if (is_array($modules)) { foreach ($modules as $position => $content) { if (empty($mods[$position])) { $mods[$position] = ''; } $mods[$position] .= $content; } } } } foreach ($mods as $position => $module) { $html = str_replace('<!-- ' . $position . ' -->', $module, $html); } echo $html; // Fix UI quirks. echo PHP_EOL; echo '<script>window.joms && joms.fixUI && joms.fixUI();</script>'; echo PHP_EOL; }
/** * Populate the wall area in photos with wall/comments content */ public function showWallContents($photoId) { // Include necessary libraries CFactory::load('libraries', 'wall'); CFactory::load('models', 'photos'); $my = CFactory::getUser(); $photo =& JTable::getInstance('Photo', 'CTable'); $photo->load($photoId); //@todo: Add limit $limit = 20; if ($photo->id == '0') { echo JText::_('CC INVALID PHOTO ID'); return; } CFactory::load('helpers', 'owner'); $contents = CWallLibrary::getWallContents('photos', $photoId, $my->id == $photo->creator || COwnerHelper::isCommunityAdmin(), $limit, 0, 'wall.content', 'photos,photo'); CFactory::load('helpers', 'string'); $contents = CStringHelper::replaceThumbnails($contents); return $contents; }
public function renderComment($cmtObj) { $my = CFactory::getUser(); $user = CFactory::getUser($cmtObj->creator); // Process the text CFactory::load('helpers', 'string'); $cmtObj->text = nl2br(CStringHelper::escape($cmtObj->text)); //format the date $dateObject = CTimeHelper::getDate($cmtObj->date); $date = C_JOOMLA_15 == 1 ? $dateObject->toFormat(JText::_('DATE_FORMAT_LC2')) : $dateObject->Format(JText::_('DATE_FORMAT_LC2')); $html = ''; $html .= '<div class="cComment">'; CFactory::load('helpers', 'user'); $html .= CUserHelper::getThumb($user->id, 'wall-coc-avatar'); CFactory::load('helpers', 'string'); $html = CStringHelper::replaceThumbnails($html); $html .= '<a class="wall-coc-author" href="' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id) . '">' . $user->getDisplayName() . '</a> '; $html .= JText::sprintf('COM_COMMUNITY_COMMENT_POSTED_ON', '<span class="wall-coc-date">' . $date . '</span>'); CFactory::load('helpers', 'owner'); if ($my->id == $user->id || COwnerHelper::isCommunityAdmin()) { $html .= ' | <a class="coc-remove coc-' . $cmtObj->creator . '" onclick="joms.comments.remove(this);" href="javascript:void(0)">' . JText::_('COM_COMMUNITY_REMOVE') . '</a>'; } $html .= '<p>' . $cmtObj->text . '</p>'; $html .= '</div>'; return $html; }
/** * Deprecated since 1.8 */ function cReplaceThumbnails($data) { return CStringHelper::replaceThumbnails($data); }
public function ajaxGetOlderWalls($groupId, $discussionId, $limitStart) { $response = new JAXResponse(); $my = CFactory::getUser(); $jconfig = JFactory::getConfig(); $groupModel = CFactory::getModel('groups'); $isGroupAdmin = $groupModel->isAdmin($my->id, $groupId); CFactory::load('libraries', 'wall'); $html = CWall::getWallContents('discussions', $discussionId, $isGroupAdmin, $jconfig->get('list_limit'), $limitStart, 'wall.content', 'groups,discussion', $groupId); // parse the user avatar CFactory::load('helpers', 'string'); $html = CStringHelper::replaceThumbnails($html); $html = JString::str_ireplace(array('{error}', '{warning}', '{info}'), '', $html); $config = CFactory::getConfig(); $order = $config->get('group_discuss_order'); if ($order == 'ASC') { // Append new data at Top. $response->addScriptCall('joms.walls.prepend', $html); } else { // Append new data at bottom. $response->addScriptCall('joms.walls.append', $html); } return $response->sendResponse(); }