Exemplo n.º 1
0
 /**
  * Inject data from paramter to content tags ({}) .
  *
  * @param	$content	Original content with content tags.
  * @param	$params	Text contain all values need to be replaced.
  * @param	$html	Auto detect url tag and insert inline.
  * @return	$text	The content after replacing.
  **/
 public static function injectTags($content, $paramsTxt, $html = false)
 {
     $params = new CParameter($paramsTxt);
     preg_match_all("/{(.*?)}/", $content, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $val) {
             $replaceWith = JString::trim($params->get($val[1], null));
             if (!is_null($replaceWith)) {
                 //if the replacement start with 'index.php', we can CRoute it
                 if (JString::strpos($replaceWith, 'index.php') === 0) {
                     $replaceWith = CRoute::getExternalURL($replaceWith);
                 }
                 if ($html) {
                     $replaceUrl = $params->get($val[1] . '_url', null);
                     if (!is_null($replaceUrl)) {
                         if ($val[1] == 'stream') {
                             $replaceUrl .= '#activity-stream-container';
                         }
                         //if the replacement start with 'index.php', we can CRoute it
                         if (JString::strpos($replaceUrl, 'index.php') === 0) {
                             $replaceUrl = CRoute::getExternalURL($replaceUrl);
                         }
                         $replaceWith = '<a href="' . $replaceUrl . '">' . $replaceWith . '</a>';
                     }
                 }
                 $content = CString::str_ireplace($val[0], $replaceWith, $content);
             }
         }
     }
     return $content;
 }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
 /**
  * Retrieve menu items in JomSocial's toolbar
  * 
  * @access	public
  * @param
  * 
  * @return	Array	An array of #__menu objects.
  **/
 public function getItems()
 {
     $config = CFactory::getConfig();
     $db = JFactory::getDBO();
     $menus = array();
     // For menu access
     $my = CFactory::getUser();
     //joomla 1.6
     $menutitlecol = !C_JOOMLA_15 ? 'title' : 'name';
     $query = 'SELECT a.' . $db->nameQuote('id') . ', a.' . $db->nameQuote('link') . ', a.' . $menutitlecol . ' as name, a.' . $db->nameQuote(TABLE_MENU_PARENTID) . ', false as script ' . ' FROM ' . $db->nameQuote('#__menu') . ' AS a ' . ' LEFT JOIN ' . $db->nameQuote('#__menu') . ' AS b ' . ' ON b.' . $db->nameQuote('id') . '=a.' . $db->nameQuote(TABLE_MENU_PARENTID) . ' AND b.' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' ' . ' WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' ' . ' AND a.' . $db->nameQuote('menutype') . '=' . $db->Quote($config->get('toolbar_menutype'));
     if ($my->id == 0) {
         $query .= ' AND a.' . $db->nameQuote('access') . '=' . $db->Quote(0);
     }
     CFactory::load('helpers', 'owner');
     if ($my->id > 0 && !COwnerHelper::isCommunityAdmin()) {
         //			$query	.= ' AND a.' . $db->nameQuote( 'access' ) . '>=' . $db->Quote( 0 ) . ' AND a.' . $db->nameQuote( 'access' ) . '<' . $db->Quote( 2 );
         //we haven't supported access level setting for toolbar menu yet.
         $query .= ' AND a.' . $db->nameQuote('access') . '>=' . $db->Quote(0);
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $query .= ' AND a.' . $db->nameQuote('access') . '>=' . $db->Quote(0);
     }
     $ordering_field = TABLE_MENU_ORDERING_FIELD;
     $query .= ' ORDER BY a.' . $db->nameQuote($ordering_field);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     // remove disabled apps base on &view=value in result's link
     $this->cleanMenus($result);
     //avoid multiple count execution
     $parentColumn = TABLE_MENU_PARENTID;
     $menus = array();
     foreach ($result as $i => $row) {
         //get top main links on toolbar
         //add Itemid if not our components and dont add item id for external link
         $row->link = CString::str_ireplace('https://', 'http://', $row->link);
         if (strpos($row->link, 'com_community') == false && strpos($row->link, 'http://') === false) {
             $row->link .= "&Itemid=" . $row->id;
         }
         if ($row->{$parentColumn} == MENU_PARENT_ID) {
             $obj = new stdClass();
             $obj->item = $row;
             $obj->item->script = false;
             $obj->childs = null;
             $menus[$row->id] = $obj;
         }
     }
     // Retrieve child menus from the original result.
     // Since we reduce the number of sql queries, we need to use php to split the menu's out
     // accordingly.
     foreach ($result as $i => $row) {
         if ($row->{$parentColumn} != MENU_PARENT_ID && isset($menus[$row->{$parentColumn}])) {
             if (!is_array($menus[$row->{$parentColumn}]->childs)) {
                 $menus[$row->{$parentColumn}]->childs = array();
             }
             $menus[$row->{$parentColumn}]->childs[] = $row;
         }
     }
     return $menus;
 }
Exemplo n.º 4
0
 function onActivityContentDisplay($args)
 {
     $model =& CFactory::getModel('Wall');
     $wall =& JTable::getInstance('Wall', 'CTable');
     $my = CFactory::getUser();
     if (empty($args->content)) {
         return '';
     }
     $wall->load($args->cid);
     CFactory::load('libraries', 'privacy');
     CFactory::load('libraries', 'comment');
     $comment = CComment::stripCommentData($wall->comment);
     $config = CFactory::getConfig();
     $commentcut = false;
     if (strlen($comment) > $config->getInt('streamcontentlength')) {
         $origcomment = $comment;
         $comment = JString::substr($comment, 0, $config->getInt('streamcontentlength')) . ' ...';
         $commentcut = true;
     }
     if (CPrivacy::isAccessAllowed($my->id, $args->target, 'user', 'privacyProfileView')) {
         CFactory::load('helpers', 'videos');
         CFactory::load('libraries', 'videos');
         CFactory::load('libraries', 'wall');
         $videoContent = '';
         $params = new CParameter($args->params);
         $videoLink = $params->get('videolink');
         $image = $params->get('url');
         // For older activities that does not have videoLink , we need to process it the old way.
         if (!$videoLink) {
             $html = CWallLibrary::_processWallContent($comment);
             $tmpl = new CTemplate();
             $html = CStringHelper::escape($html);
             if ($commentcut) {
                 //add read more/less link for content
                 $html .= '<br /><br /><a href="javascript:void(0)" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').hide(); jQuery(\'#origcomment_' . $args->cid . '\').show();" >' . JText::_('COM_COMMUNITY_READ_MORE') . '</a>';
                 $html = '<div id="shortcomment_' . $args->cid . '">' . $html . '</div>';
                 $html .= '<div id="origcomment_' . $args->cid . '" style="display:none;">' . $origcomment . '<br /><br /><a href="javascript:void(0);" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').show(); jQuery(\'#origcomment_' . $args->cid . '\').hide();" >' . JText::_('COM_COMMUNITY_READ_LESS') . '</a></div>';
             }
             $tmpl->set('comment', $html);
             $html = $tmpl->fetch('activity.wall.post');
         } else {
             $html = '<ul class ="cDetailList clrfix">';
             $html .= '<li>';
             $image = !$image ? rtrim(JURI::root(), '/') . '/components/com_community/assets/playvideo.gif' : $image;
             $videoLib = new CVideoLibrary();
             $provider = $videoLib->getProvider($videoLink);
             $html .= '<!-- avatar --><div class="avatarWrap"><a href="javascript:void(0);" onclick="joms.activities.showVideo(\'' . $args->id . '\');"><img width="64" src="' . $image . '" class="cAvatar"/></a></div><!-- avatar -->';
             $videoPlayer = $provider->getViewHTML($provider->getId(), '300', '300');
             $comment = CString::str_ireplace($videoLink, '', $comment);
             $html .= '<!-- details --><div class="detailWrap alpha">' . $comment . '</div><!-- details -->';
             if (!empty($videoPlayer)) {
                 $html .= '<div style="display: none;clear: both;padding-top: 5px;" class="video-object">' . $videoPlayer . '</div>';
             }
             $html .= '</li>';
             $html .= '</ul>';
         }
         return $html;
     }
 }
Exemplo n.º 5
0
 /**
  * Displays the viewing profile page.
  * 	 	
  * @access	public
  * @param	array  An associative array to display the fields
  */
 public function profile(&$data)
 {
     $mainframe = JFactory::getApplication();
     $friendsModel = CFactory::getModel('friends');
     $showfriends = JRequest::getVar('showfriends', false);
     $userid = JRequest::getVar('userid', '');
     $user = CFactory::getUser($userid);
     $linkUrl = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
     $document = JFactory::getDocument();
     $document->setTitle(JText::sprintf('COM_COMMUNITY_USERS_FEED_TITLE', $user->getDisplayName()));
     $document->setDescription(JText::sprintf('COM_COMMUNITY_USERS_FEED_DESCRIPTION', $user->getDisplayName(), $user->lastvisitDate));
     $document->setLink($linkUrl);
     include_once JPATH_COMPONENT . '/libraries/activities.php';
     $act = new CActivityStream();
     $friendIds = $friendsModel->getFriendIds($user->id);
     $friendIds = $showfriends ? $friendIds : null;
     $rows = $act->getFEED($user->id, $friendIds, null, $mainframe->getCfg('feed_limit'));
     // add the avatar image
     $rssImage = new JFeedImage();
     $rssImage->url = $user->getThumbAvatar();
     $rssImage->link = $linkUrl;
     $rssImage->width = 64;
     $rssImage->height = 64;
     $document->image = $rssImage;
     //CFactory::load( 'helpers' , 'string' );
     //CFactory::load( 'helpers' , 'time' );
     foreach ($rows->data as $row) {
         if ($row->type != 'title') {
             // Get activities link
             $pattern = '/<a href=\\"(.*?)\\"/';
             preg_match_all($pattern, $row->title, $matches);
             // Use activity owner link when activity link is not available
             if (!empty($matches[1][1])) {
                 $linkUrl = $matches[1][1];
             } else {
                 if (!empty($matches[1][0])) {
                     $linkUrl = $matches[1][0];
                 }
             }
             // load individual item creator class
             $item = new JFeedItem();
             $item->title = $row->title;
             $item->link = $linkUrl;
             $item->description = "<img src=\"{$row->favicon}\" alt=\"\" />&nbsp;" . $row->title;
             $item->date = CTimeHelper::getDate($row->createdDateRaw)->toRFC822();
             $item->category = '';
             //$row->category;
             $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
             // Make sure url is absolute
             $pattern = '/href="(.*?)index.php/';
             $replace = 'href="' . JURI::base() . 'index.php';
             $string = $item->description;
             $item->description = preg_replace($pattern, $replace, $string);
             // loads item info into rss array
             $document->addItem($item);
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Add sharing sites into bookmarks
  * @params	string	$providerName	Pass the provider name to be displayed
  * @params	string	$imageURL	 	 Image that needs to be displayed beside the provider
  * @params	string	$apiURL			Api URL that JomSocial should link to
  **/
 public function add($providerName, $className, $apiURL)
 {
     $apiURL = CString::str_ireplace('{uri}', $this->currentURI, $apiURL);
     $obj = new stdClass();
     $obj->name = $providerName;
     $obj->className = $className;
     $obj->link = $apiURL;
     $this->_bookmarks[JString::strtolower($providerName)] = $obj;
 }
Exemplo n.º 7
0
 /**
  * The default method that will display the output of this view which is called by
  * Joomla
  *
  * @param	string template	Template file name
  **/
 public function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $params = $this->get('Params');
     //user's email privacy setting
     //CFactory::load( 'libraries' , 'notificationtypes' );
     $notificationTypes = new CNotificationTypes();
     $lists = array();
     for ($i = 1; $i <= 31; $i++) {
         $qscale[] = JHTML::_('select.option', $i, $i);
     }
     $lists['qscale'] = JHTML::_('select.genericlist', $qscale, 'qscale', 'class="inputbox" size="1"', 'value', 'text', $params->get('qscale', '11'));
     $videosSize = array(JHTML::_('select.option', '320x240', '320x240 (QVGA 4:3)'), JHTML::_('select.option', '400x240', '400x240 (WQVGA 5:3)'), JHTML::_('select.option', '400x300', '400x300 (Quarter SVGA 4:3)'), JHTML::_('select.option', '480x272', '480x272 (Sony PSP 30:17)'), JHTML::_('select.option', '480x320', '480x320 (iPhone 3:2)'), JHTML::_('select.option', '480x360', '480x360 (4:3)'), JHTML::_('select.option', '512x384', '512x384 (4:3)'), JHTML::_('select.option', '600x480', '600x480 (4:3)'), JHTML::_('select.option', '640x360', '640x360 (16:9)'), JHTML::_('select.option', '640x480', '640x480 (VCA 4:3)'), JHTML::_('select.option', '800x600', '800x600 (SVGA 4:3)'));
     $lists['videosSize'] = JHTML::_('select.genericlist', $videosSize, 'videosSize', 'class="inputbox" size="1"', 'value', 'text', $params->get('videosSize'));
     $imgQuality = array(JHTML::_('select.option', '60', 'Low'), JHTML::_('select.option', '80', 'Medium'), JHTML::_('select.option', '90', 'High'), JHTML::_('select.option', '95', 'Very High'));
     $lists['imgQuality'] = JHTML::_('select.genericlist', $imgQuality, 'output_image_quality', 'class="inputbox" size="1"', 'value', 'text', $params->get('output_image_quality'));
     //album mode
     $albumMode = array(JHTML::_('select.option', '0', JText::_('COM_COMMUNITY_SAME_WINDOW')), JHTML::_('select.option', '1', JText::_('COM_COMMUNITY_MODAL_WINDOW')));
     $lists['albumMode'] = JHTML::_('select.genericlist', $albumMode, 'album_mode', 'class="inputbox" size="1"', 'value', 'text', $params->get('album_mode'));
     //video mode
     $videoMode = array(JHTML::_('select.option', '0', JText::_('COM_COMMUNITY_SAME_WINDOW')), JHTML::_('select.option', '1', JText::_('COM_COMMUNITY_MODAL_WINDOW')));
     $lists['videoMode'] = JHTML::_('select.genericlist', $videoMode, 'video_mode', 'class="inputbox" size="1"', 'value', 'text', $params->get('video_mode'));
     //video native
     $videoNative = array(JHTML::_('select.option', '0', JText::_('COM_COMMUNITY_STREAM_VIDEO_PLAYER_MEDIAELEMENT')), JHTML::_('select.option', '1', JText::_('COM_COMMUNITY_STREAM_VIDEO_PLAYER_NATIVE')));
     $lists['videoNative'] = JHTML::_('select.genericlist', $videoNative, 'video_native', 'class="inputbox" size="1"', 'value', 'text', $params->get('video_native'));
     // Group discussion order option
     $groupDiscussionOrder = array(JHTML::_('select.option', 'ASC', 'Older first'), JHTML::_('select.option', 'DESC', 'Newer first'));
     $lists['groupDicussOrder'] = JHTML::_('select.genericlist', $groupDiscussionOrder, 'group_discuss_order', 'class="inputbox" size="1"', 'value', 'text', $params->get('group_discuss_order'));
     $videoThumbSize = array(JHTML::_('select.option', '320x180', '320x180'), JHTML::_('select.option', '640x360', '640x360'), JHTML::_('select.option', '1280x720', '1280x720'));
     $lists['videoThumbSize'] = JHTML::_('select.genericlist', $videoThumbSize, 'videosThumbSize', 'class="inputbox" size="1"', 'value', 'text', $params->get('videosThumbSize'));
     $dstOffset = array();
     $counter = -4;
     for ($i = 0; $i <= 8; $i++) {
         $dstOffset[] = JHTML::_('select.option', $counter, $counter);
         $counter++;
     }
     $watermarkPosition = array(JHTML::_('select.option', 'left_top', JText::_('COM_COMMUNITY_CONFIGURATION_PHOTOS_WATERMARK_POSITION_LFFT_TOP')), JHTML::_('select.option', 'left_bottom', JText::_('COM_COMMUNITY_CONFIGURATION_PHOTOS_WATERMARK_POSITION_LFFT_BOTTOM')), JHTML::_('select.option', 'right_top', JText::_('COM_COMMUNITY_CONFIGURATION_PHOTOS_WATERMARK_POSITION_RIGHT_TOP')), JHTML::_('select.option', 'right_bottom', JText::_('COM_COMMUNITY_CONFIGURATION_PHOTOS_WATERMARK_POSITION_RIGHT_BOTTOM')));
     $lists['watermarkPosition'] = JHTML::_('select.genericlist', $watermarkPosition, 'watermark_position', 'class="inputbox" size="1"', 'value', 'text', $params->get('watermark_position'));
     $lists['dstOffset'] = JHTML::_('select.genericlist', $dstOffset, 'daylightsavingoffset', 'class="inputbox" size="1"', 'value', 'text', $params->get('daylightsavingoffset'));
     $networkModel = $this->getModel('network', false);
     $JSNInfo = $networkModel->getJSNInfo();
     $JSON_output = $networkModel->getJSON();
     $lists['enable'] = JHTML::_('select.booleanlist', 'network_enable', 'class="inputbox"', $JSNInfo['network_enable']);
     $uploadLimit = ini_get('upload_max_filesize');
     $uploadLimit = CString::str_ireplace('M', ' MB', $uploadLimit);
     require_once JPATH_ROOT . '/administrator/components/com_community/libraries/autoupdate.php';
     $isuptodate = CAutoUpdate::checkUpdate();
     $this->assign('JSNInfo', $JSNInfo);
     $this->assign('JSON_output', $JSON_output);
     $this->assign('lists', $lists);
     $this->assign('uploadLimit', $uploadLimit);
     $this->assign('config', $params);
     $this->assign('isuptodate', $isuptodate);
     $this->assign('notificationTypes', $notificationTypes);
     parent::display($tpl);
 }
Exemplo n.º 8
0
 public function friends($data = null)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $id = JRequest::getCmd('userid', 0);
     $sorted = $jinput->get->get('sort', 'latest', 'STRING');
     //JRequest::getVar( 'sort' , 'latest' , 'GET' );
     $filter = JRequest::getWord('filter', 'all', 'GET');
     $isMine = $id == $my->id && $my->id != 0;
     $my = CFactory::getUser();
     $id = $id == 0 ? $my->id : $id;
     $user = CFactory::getUser($id);
     $friends = CFactory::getModel('friends');
     $blockModel = CFactory::getModel('block');
     $document->setLink(CRoute::_('index.php?option=com_community'));
     $rows = $friends->getFriends($id, $sorted, true, $filter);
     // Hide submenu if we are viewing other's friends
     if ($isMine) {
         $document->setTitle(JText::_('COM_COMMUNITY_FRIENDS_MY_FRIENDS'));
     } else {
         $document->setTitle(JText::sprintf('COM_COMMUNITY_FRIENDS_ALL_FRIENDS', $user->getDisplayName()));
     }
     $sortItems = array('latest' => JText::_('COM_COMMUNITY_SORT_RECENT_FRIENDS'), 'online' => JText::_('COM_COMMUNITY_ONLINE'));
     $resultRows = array();
     // @todo: preload all friends
     foreach ($rows as $row) {
         $user = CFactory::getUser($row->id);
         $obj = clone $row;
         $obj->friendsCount = $user->getFriendCount();
         $obj->profileLink = CUrlHelper::userLink($row->id);
         $obj->isFriend = true;
         $obj->isBlocked = $blockModel->getBlockStatus($user->id, $my->id);
         $resultRows[] = $obj;
     }
     unset($rows);
     foreach ($resultRows as $row) {
         if (!$row->isBlocked) {
             // load individual item creator class
             $item = new JFeedItem();
             $item->title = strip_tags($row->name);
             $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->id);
             $item->description = '<img src="' . JURI::base() . $row->_thumb . '" alt="" />&nbsp;' . $row->_status;
             $item->date = $row->lastvisitDate;
             $item->category = '';
             //$row->category;
             $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
             // Make sure url is absolute
             $item->description = CString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
             // loads item info into rss array
             $document->addItem($item);
         }
     }
 }
Exemplo n.º 9
0
 /**
  * The default method that will display the output of this view which is called by
  * Joomla
  * 
  * @param	string template	Template file name
  **/
 public function display($tpl = null)
 {
     //Load pane behavior
     jimport('joomla.html.pane');
     $pane =& JPane::getInstance('sliders');
     $document =& JFactory::getDocument();
     // Load tooltips
     JHTML::_('behavior.tooltip', '.hasTip');
     $params = $this->get('Params');
     //user's email privacy setting
     CFactory::load('libraries', 'emailtypes');
     $emailtypes = new CEmailTypes();
     // Add submenu
     $contents = '';
     ob_start();
     require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'views' . DS . 'configuration' . DS . 'tmpl' . DS . 'navigation.php';
     $contents = ob_get_contents();
     ob_end_clean();
     $document =& JFactory::getDocument();
     $document->setBuffer($contents, 'modules', 'submenu');
     $lists = array();
     for ($i = 1; $i <= 31; $i++) {
         $qscale[] = JHTML::_('select.option', $i, $i);
     }
     $lists['qscale'] = JHTML::_('select.genericlist', $qscale, 'qscale', 'class="inputbox" size="1"', 'value', 'text', $params->get('qscale', '11'));
     $videosSize = array(JHTML::_('select.option', '320x240', '320x240 (QVGA 4:3)'), JHTML::_('select.option', '400x240', '400x240 (WQVGA 5:3)'), JHTML::_('select.option', '400x300', '400x300 (Quarter SVGA 4:3)'), JHTML::_('select.option', '480x272', '480x272 (Sony PSP 30:17)'), JHTML::_('select.option', '480x320', '480x320 (iPhone 3:2)'), JHTML::_('select.option', '480x360', '480x360 (4:3)'), JHTML::_('select.option', '512x384', '512x384 (4:3)'), JHTML::_('select.option', '600x480', '600x480 (4:3)'), JHTML::_('select.option', '640x360', '640x360 (16:9)'), JHTML::_('select.option', '640x480', '640x480 (VCA 4:3)'), JHTML::_('select.option', '800x600', '800x600 (SVGA 4:3)'));
     $lists['videosSize'] = JHTML::_('select.genericlist', $videosSize, 'videosSize', 'class="inputbox" size="1"', 'value', 'text', $params->get('videosSize'));
     $imgQuality = array(JHTML::_('select.option', '60', 'Low'), JHTML::_('select.option', '80', 'Medium'), JHTML::_('select.option', '90', 'High'), JHTML::_('select.option', '95', 'Very High'));
     $lists['imgQuality'] = JHTML::_('select.genericlist', $imgQuality, 'output_image_quality', 'class="inputbox" size="1"', 'value', 'text', $params->get('output_image_quality'));
     // Group discussion order option
     $groupDiscussionOrder = array(JHTML::_('select.option', 'ASC', 'Older first'), JHTML::_('select.option', 'DESC', 'Newer first'));
     $lists['groupDicussOrder'] = JHTML::_('select.genericlist', $groupDiscussionOrder, 'group_discuss_order', 'class="inputbox" size="1"', 'value', 'text', $params->get('group_discuss_order'));
     $dstOffset = array();
     $counter = -4;
     for ($i = 0; $i <= 8; $i++) {
         $dstOffset[] = JHTML::_('select.option', $counter, $counter);
         $counter++;
     }
     $lists['dstOffset'] = JHTML::_('select.genericlist', $dstOffset, 'daylightsavingoffset', 'class="inputbox" size="1"', 'value', 'text', $params->get('daylightsavingoffset'));
     $networkModel = $this->getModel('network', false);
     $JSNInfo =& $networkModel->getJSNInfo();
     $JSON_output =& $networkModel->getJSON();
     $lists['enable'] = JHTML::_('select.booleanlist', 'network_enable', 'class="inputbox"', $JSNInfo['network_enable']);
     $uploadLimit = ini_get('upload_max_filesize');
     $uploadLimit = CString::str_ireplace('M', ' MB', $uploadLimit);
     $this->assignRef('JSNInfo', $JSNInfo);
     $this->assignRef('JSON_output', $JSON_output);
     $this->assignRef('lists', $lists);
     $this->assign('uploadLimit', $uploadLimit);
     $this->assign('config', $params);
     $this->assign('emailtypes', $emailtypes->getEmailTypes());
     parent::display($tpl);
 }
Exemplo n.º 10
0
 public function getDuration()
 {
     $duration = '';
     //Get duration
     $pattern = "'<span class=gray id=video-duration>(.*?)</span>'s";
     preg_match_all($pattern, $this->xmlContent, $matches);
     if ($matches) {
         $duration = explode(":", CString::str_ireplace("&nbsp;", "", trim(strip_tags($matches[1][0]))));
         $duration = $duration[0] * 60 + $duration[1];
     }
     return $duration;
 }
Exemplo n.º 11
0
 public function getDescription()
 {
     $description = '';
     // Store description
     $pattern = "'<blip\\:puredescription>(.*?)<\\/blip\\:puredescription>'s";
     preg_match_all($pattern, $this->xmlContent, $matches);
     if ($matches) {
         $description = CString::str_ireplace('&apos;', "'", $matches[1][0]);
         $description = CString::str_ireplace('<![CDATA[', '', $description);
         $description = CString::str_ireplace(']]>', '', $description);
     }
     return $description;
 }
Exemplo n.º 12
0
 public function submitToJomsocial()
 {
     require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'network.php';
     $model = new CommunityModelNetwork();
     $network =& $model->getJSNInfo();
     // to run or not to run?
     if (empty($network['network_enable'])) {
         return;
     }
     if ($network['network_cron_freq']) {
         $time_diff = time() - $network['network_cron_last_run'];
         $cron_freq = $network['network_cron_freq'] * 60 * 60;
         // 1 hour
         if ($time_diff < $cron_freq) {
             return;
         }
     }
     // prepare data
     foreach ($network as $key => $value) {
         $token = JUtility::getToken();
         $keys = array('network_site_name', 'network_description', 'network_keywords', 'network_language', 'network_member_count', 'network_group_count', 'network_site_url', 'network_join_url', 'network_logo_url');
         if (in_array($key, $keys)) {
             $key = CString::str_ireplace('network_', '', $key);
             $input_filtered[$key] = $value;
         }
     }
     if (!defined('SERVICES_JSON_SLICE')) {
         include_once AZRUL_SYSTEM_PATH . '/pc_includes/JSON.php';
     }
     $json = new Services_JSON();
     $json_output = $json->encode($input_filtered);
     // post data
     $post_data = array();
     $post_data['jsonText'] = $json_output;
     $config = CFactory::getConfig();
     $post_url = $config->get('jsnetwork_path');
     CFactory::load('helpers', 'remote');
     $test = CRemoteHelper::post($post_url, $post_data);
     // save
     $network['network_cron_last_run'] = time();
     $token = JUtility::getToken();
     $network[$token] = 1;
     // set post data
     foreach ($network as $key => $value) {
         JRequest::setVar($key, $value, 'POST');
     }
     $model->save();
 }
Exemplo n.º 13
0
 public static function _getGoogleAdsHTML($googleCode, $userId)
 {
     ob_start();
     ?>
         <div id="community-mygoodleads-wrap">
             <?php 
     $gCode = html_entity_decode($googleCode);
     $gCode = CString::str_ireplace("<br />", "\n", $gCode);
     $gCode = preg_replace('/eval\\((.*)\\)/', '', $gCode);
     ?>
             <?php 
     echo "{$gCode}\n";
     ?>
         </div>
         <?php 
     $contents = ob_get_contents();
     ob_end_clean();
     return $contents;
 }
Exemplo n.º 14
0
 /**
  * Add new notification
  */
 public function add($from, $to, $title, $content, $privacy = COMMUNITY_PRIVACY_PUBLIC)
 {
     jimport('joomla.utilities.date');
     $db =& $this->getDBO();
     $date =& JFactory::getDate();
     $obj = new stdClass();
     $obj->actor = $from;
     $obj->target = $to;
     $obj->title = $title;
     $obj->content = $content;
     $obj->created = $date->toMySQL();
     $userFrom =& JFactory::getUser($from);
     $userTo =& JFactory::getUser($to);
     // Porcess the message and title
     $search = array('{actor}', '{target}');
     $replace = array($userFrom->name, $userTo->name);
     $title = CString::str_ireplace($search, $replace, $title);
     $content = CString::str_ireplace($search, $replace, $content);
     return $this;
 }
Exemplo n.º 15
0
 public function display($data = null)
 {
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $model = CFactory::getModel('search');
     $members = $model->getPeople();
     // Prepare feeds
     // 		$document->setTitle($title);
     foreach ($members as $member) {
         $user = CFactory::getUser($member->id);
         $friendCount = JText::sprintf(CStringHelper::isPlural($user->getFriendCount()) ? 'COM_COMMUNITY_FRIENDS_COUNT_MANY' : 'COM_COMMUNITY_FRIENDS_COUNT', $user->getFriendCount());
         $item = new JFeedItem();
         $item->title = $user->getDisplayName();
         $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
         $item->description = '<img src="' . $user->getThumbAvatar() . '" alt="" />&nbsp;' . $friendCount;
         $item->date = '';
         $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
         // Make sure url is absolute
         $item->description = CString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
         $document->addItem($item);
     }
 }
Exemplo n.º 16
0
 /**
  *	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.
  *
  **/
 public 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 = CString::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 = CString::str_ireplace('/', DS, $oldFile);
             JFile::delete($oldFile);
         }
     }
 }
Exemplo n.º 17
0
 public function display($data = null)
 {
     $mainframe = JFactory::getApplication();
     $config = CFactory::getConfig();
     $document = JFactory::getDocument();
     $document->setTitle(JText::sprintf('COM_COMMUNITY_FRONTPAGE_TITLE', $config->get('sitename')));
     $document->setLink(CRoute::_('index.php?option=com_community'));
     $my = CFactory::getUser();
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'string');
     CFactory::load('helpers', 'time');
     $act = new CActivityStream();
     $rows = $act->getFEED('', '', null, $mainframe->getCfg('feed_limit'));
     if ($config->get('showactivitystream') == COMMUNITY_SHOW || $config->get('showactivitystream') == COMMUNITY_MEMBERS_ONLY && $my->id != 0) {
         foreach ($rows->data as $row) {
             if ($row->type != 'title') {
                 // load individual item creator class
                 $item = new JFeedItem();
                 // cannot escape the title. it's already formated. we should
                 // escape it during CActivityStream::add
                 //$item->title 		= CStringHelper::escape($row->title);
                 $item->title = $row->title;
                 $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->actor);
                 $item->description = "<img src=\"{$row->favicon}\" alt=\"\"/>&nbsp;" . $row->title;
                 $item->date = CTimeHelper::getDate($row->createdDateRaw)->toRFC822();
                 $item->category = '';
                 //$row->category;
                 $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
                 // Make sure url is absolute
                 $item->description = CString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
                 // loads item info into rss array
                 $document->addItem($item);
             }
         }
     }
 }
Exemplo n.º 18
0
 private function _updateUserWatermark($user, $type, $hashName)
 {
     $config = CFactory::getConfig();
     $oldAvatar = $user->_avatar;
     // @rule: This is the original avatar path
     //CFactory::load( 'helpers' , 'image' );
     $userImageType = '_' . $type;
     $data = @getimagesize(JPATH_ROOT . '/' . CString::str_ireplace('/', '/', $user->{$userImageType}));
     $original = JPATH_ROOT . '/images/watermarks/original' . '/' . md5($user->id . '_' . $type) . CImageHelper::getExtension($data['mime']);
     if (!$config->get('profile_multiprofile') || !JFile::exists($original)) {
         return false;
     }
     static $types = array();
     if (empty($types)) {
         $model = CFactory::getModel('Profile');
         $rows = $model->getProfileTypes();
         if ($rows) {
             foreach ($rows as $row) {
                 $types[$row->id] = $row;
             }
         }
     }
     $model = CFactory::getModel('User');
     if (isset($types[$user->_profile_id])) {
         // Bind the data to the current object so we can access it here.
         $this->bind($types[$user->_profile_id]);
         // Path to the watermark image.
         $watermarkPath = JPATH_ROOT . '/' . CString::str_ireplace('/', '/', $this->watermark);
         // Retrieve original image info
         $originalData = getimagesize($original);
         // Generate image file name.
         $fileName = $type == 'thumb' ? 'thumb_' : '';
         $fileName .= $hashName;
         $fileName .= CImageHelper::getExtension($originalData['mime']);
         // Absolute path to the image (local)
         $newImagePath = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/avatar' . '/' . $fileName;
         // Relative path to the image (uri)
         $newImageUri = $config->getString('imagefolder') . '/avatar/' . $fileName;
         // Retrieve the height and width for watermark and original image.
         list($watermarkWidth, $watermarkHeight) = getimagesize($watermarkPath);
         list($originalWidth, $originalHeight) = getimagesize($original);
         // Retrieve the proper coordinates to the watermark location
         $position = CImageHelper::getPositions($this->watermark_location, $originalWidth, $originalHeight, $watermarkWidth, $watermarkHeight);
         // Create the new image with the watermarks.
         CImageHelper::addWatermark($original, $newImagePath, $originalData['mime'], $watermarkPath, $position->x, $position->y, false);
         $model->setImage($user->id, $newImageUri, $type);
         // Remove the user's old image
         $oldFile = JPATH_ROOT . '/' . CString::str_ireplace('/', '/', $user->{$userImageType});
         if (JFile::exists($oldFile)) {
             JFile::delete($oldFile);
         }
         if ($type == 'avatar') {
             $oldImg = explode('avatar/', $oldAvatar);
             $oldImg = explode('.', $oldImg[1]);
             $oldImg = $config->getString('imagefolder') . '/avatar/' . $oldImg[0] . '_stream_.' . $oldImg[1];
             JFile::copy($newImageUri, $oldImg);
         }
         // We need to update the property in CUser as well otherwise when we save the hash, it'll
         // use the old user avatar.
         $user->set($userImageType, $newImageUri);
         // We need to restore the storage method.
         $user->set('_storage', 'file');
         // Update the watermark hash with the latest hash
         $user->set('_watermark_hash', $this->watermark_hash);
         $user->save();
     }
     return true;
 }
Exemplo n.º 19
0
 /**
  *
  */
 public function _setImage($id, $path, $type, $appType)
 {
     $db = $this->getDBO();
     $obj = new stdClass();
     $obj->id = $id;
     // Fix back quotes
     $obj->path = CString::str_ireplace('\\', '/', $path);
     $obj->type = $type;
     $obj->appType = $appType;
     $sql = 'SELECT COUNT(*) FROM ' . $db->quoteName('#__community_avatar') . ' WHERE ' . $db->quoteName('id') . '=' . $db->Quote($id) . ' AND ' . $db->quoteName('apptype') . '=' . $db->Quote($appType) . ' AND ' . $db->quoteName('type') . '=' . $db->Quote($type);
     $db->setQuery($sql);
     $exist = $db->loadResult();
     if (!$exist) {
         $db->insertObject('#__community_avatar', $obj);
         if ($db->getErrorNum()) {
             JError::raiseError(500, $db->stderr());
         }
     } else {
         // Need to delete old image
         $sql = 'SELECT ' . $db->quoteName('path') . ' FROM ' . $db->quoteName('#__community_avatar') . ' WHERE ' . $db->quoteName('id') . '=' . $db->Quote($id) . ' AND ' . $db->quoteName('apptype') . '=' . $db->Quote($appType) . ' AND ' . $db->quoteName('type') . '=' . $db->Quote($type);
         $db->setQuery($sql);
         $oldfile = $db->loadResult();
         $oldfile = CString::str_ireplace('/', '/', $oldfile);
         if ($db->getErrorNum()) {
             JError::raiseError(500, $db->stderr());
         }
         JFile::delete($oldfile);
         $sql = 'UPDATE ' . $db->quoteName('#__community_avatar') . ' SET ' . $db->quoteName('path') . '=' . $db->Quote($obj->path) . ' WHERE ' . $db->quoteName('id') . '=' . $db->Quote($id) . ' AND ' . $db->quoteName('apptype') . '=' . $db->Quote($appType) . ' AND ' . $db->quoteName('type') . '=' . $db->Quote($type);
         $db->setQuery($sql);
         $db->query();
         if ($db->getErrorNum()) {
             JError::raiseError(500, $db->stderr());
         }
     }
 }
Exemplo n.º 20
0
 /**
  * Get or create default album ( if not exists )
  * @param mixed $value
  * @return type
  */
 protected function _getRequestUserAlbum($value)
 {
     $model = CFactory::getModel('photos');
     $album = JTable::getInstance('Album', 'CTable');
     $my = CFactory::getUser();
     /* Prepare default albumName */
     $albumName = JText::sprintf('COM_COMMUNITY_DEFAULT_ALBUM_CAPTION', $my->getDisplayName());
     /* Request album by id */
     if (is_numeric($value)) {
         /* Load album by request id */
         $album->load($value);
     } else {
         /* Request album by albumName */
         $albumName = $value;
         /* If album name provided it's mean they want create new album and upload into this one */
         $album->load(array('name' => $albumName, 'creator' => $my->id, 'default' => 1));
     }
     /* Request album not exists */
     if ($album->id == 0) {
         /**
          * Do get / set defaultAlbum in cuser
          * By this way we'll allow user can change default album name without trouble
          * @since 3.2
          */
         $defaultAlbum = $my->getParam('defaultAlbum');
         if ($defaultAlbum) {
             /* Load default album */
             if ($album->load($defaultAlbum)) {
                 return $album;
             }
         }
         /* Get album table */
         $album = JTable::getInstance('Album', 'CTable');
         $album->load();
         /* Get handler */
         $handler = $this->_getHandler($album);
         /* Do create new album */
         $now = new JDate();
         $album->creator = $my->id;
         $album->created = $now->toSql();
         $album->name = $albumName;
         $album->type = $handler->getType();
         $album->default = '1';
         /* General album path */
         $albumPath = $handler->getAlbumPath($album->id);
         $albumPath = CString::str_ireplace(JPATH_ROOT . '/', '', $albumPath);
         $albumPath = CString::str_ireplace('\\', '/', $albumPath);
         $album->path = $albumPath;
         $album->store();
         /* Store new default album was created into CUser */
         $my->setParam('defaultAlbum', $album->id);
         $my->save();
     }
     return $album;
 }
Exemplo n.º 21
0
 /**
  *
  * @param type $type
  * @param type $id
  * @param type $sourceX
  * @param type $sourceY
  * @param type $width
  * @param type $height
  */
 public static function updateAvatar($type, $id, $sourceX, $sourceY, $width, $height)
 {
     $filter = JFilterInput::getInstance();
     /* Filter input values */
     $type = $filter->clean($type, 'string');
     $id = $filter->clean($id, 'integer');
     $sourceX = $filter->clean($sourceX, 'float');
     $sourceY = $filter->clean($sourceY, 'float');
     $width = $filter->clean($width, 'float');
     $height = $filter->clean($height, 'float');
     $cTable = JTable::getInstance(ucfirst($type), 'CTable');
     $cTable->load($id);
     $cTable->storage = 'file';
     $cTable->store();
     $srcPath = JPATH_ROOT . '/' . $cTable->avatar;
     $destPath = JPATH_ROOT . '/' . $cTable->thumb;
     /* */
     $config = CFactory::getConfig();
     $avatarFolder = $type != 'profile' && $type != '' ? $type . '/' : '';
     /* Get original image */
     $originalPath = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/avatar' . '/' . $avatarFolder . '/' . $type . '-' . JFile::getName($cTable->avatar);
     /**
      * If original image does not exists than we use source image
      * @todo we should get from facebook original avatar file
      */
     if (!JFile::exists($originalPath)) {
         $originalPath = $srcPath;
     }
     $srcPath = str_replace('/', '/', $srcPath);
     $destPath = str_replace('/', '/', $destPath);
     $info = getimagesize($srcPath);
     $destType = $info['mime'];
     $destWidth = COMMUNITY_SMALL_AVATAR_WIDTH;
     $destHeight = COMMUNITY_SMALL_AVATAR_WIDTH;
     /* thumb size */
     $currentWidth = $width;
     $currentHeight = $height;
     /* avatar size */
     $imageMaxWidth = 160;
     $imageMaxHeight = 160;
     /**
      * @todo Should we generate new filename and update into database ?
      */
     /* do avatar resize */
     CImageHelper::resize($originalPath, $srcPath, $destType, $imageMaxWidth, $imageMaxHeight, $sourceX, $sourceY, $currentWidth, $currentHeight);
     /* do thumb resize */
     CImageHelper::resize($originalPath, $destPath, $destType, $destWidth, $destHeight, $sourceX, $sourceY, $currentWidth, $currentHeight);
     /**
      * Now we do check and process watermark
      */
     /* Check multiprofile to reapply watermark for thumbnail */
     $my = CFactory::getUser();
     $profileType = $my->getProfileType();
     $multiprofile = JTable::getInstance('MultiProfile', 'CTable');
     $multiprofile->load($profileType);
     $useWatermark = $profileType != COMMUNITY_DEFAULT_PROFILE && $config->get('profile_multiprofile') && !empty($multiprofile->watermark) ? true : false;
     if ($useWatermark && $type == 'profile') {
         $watermarkPath = JPATH_ROOT . '/' . CString::str_ireplace('/', '/', $multiprofile->watermark);
         list($watermarkWidth, $watermarkHeight) = getimagesize($watermarkPath);
         list($thumbWidth, $thumbHeight) = getimagesize($destPath);
         list($avatarWidth, $avatarHeight) = getimagesize($srcPath);
         // Avatar Properties
         $avatarPosition = CImageHelper::getPositions($multiprofile->watermark_location, $avatarWidth, $avatarHeight, $watermarkWidth, $watermarkHeight);
         // The original image file will be removed from the system once it generates a new watermark image.
         CImageHelper::addWatermark($srcPath, $srcPath, $destType, $watermarkPath, $avatarPosition->x, $avatarPosition->y);
         $thumbPosition = CImageHelper::getPositions($multiprofile->watermark_location, $thumbWidth, $thumbHeight, $watermarkWidth, $watermarkHeight);
         /* addWatermark into thumbnail */
         CImageHelper::addWatermark($destPath, $destPath, $destType, $watermarkPath, $thumbPosition->x, $thumbPosition->y);
     }
     // we need to update the activity stream of group if applicable, so the cropped image will be updated as well
     if ($type == 'group') {
         $groupParams = new JRegistry($cTable->params);
         $actId = $groupParams->get('avatar_activity_id');
         if ($actId) {
             $act = JTable::getInstance('Activity', 'CTable');
             $act->load($actId);
             $actParams = new JRegistry($act->params);
             $actParams->set('avatar_cropped_thumb', $cTable->avatar);
             $act->params = $actParams->toString();
             $act->store();
         }
     }
     $connectModel = CFactory::getModel('connect');
     // For facebook user, we need to add the watermark back on
     if ($connectModel->isAssociated($my->id) && $config->get('fbwatermark') && $type == 'profile') {
         list($watermarkWidth, $watermarkHeight) = getimagesize(FACEBOOK_FAVICON);
         CImageHelper::addWatermark($destPath, $destPath, $destType, FACEBOOK_FAVICON, $destWidth - $watermarkWidth, $destHeight - $watermarkHeight);
     }
 }
Exemplo n.º 22
0
 /**
  * Get content for activity based on the activity id.
  *
  * @params    $activityId    Int    Activity id
  * */
 public function ajaxGetContent($activityId)
 {
     $my = CFactory::getUser();
     $showMore = true;
     $objResponse = new JAXResponse();
     $model = CFactory::getModel('Activities');
     $filter = JFilterInput::getInstance();
     $activityId = $filter->clean($activityId, 'int');
     // These core apps has default privacy issues with it
     $coreapps = array('photos', 'walls', 'videos', 'groups');
     // make sure current user has access to the content item
     // For known apps, we can filter this manually
     $activity = $model->getActivity($activityId);
     if (in_array($activity->app, $coreapps)) {
         switch ($activity->app) {
             case 'walls':
                 // make sure current user has permission to the profile
                 $showMore = CPrivacy::isAccessAllowed($my->id, $activity->target, 'user', 'privacyProfileView');
                 break;
             case 'videos':
                 // Each video has its own privacy setting within the video itself
                 $video = JTable::getInstance('Video', 'CTable');
                 $video->load($activity->cid);
                 $showMore = CPrivacy::isAccessAllowed($my->id, $activity->actor, 'custom', $video->permissions);
                 break;
             case 'photos':
                 // for photos, we uses the actor since the target is 0 and he
                 // is doing the action himself
                 $album = JTable::getInstance('Album', 'CTable');
                 $album->load($activity->cid);
                 $showMore = CPrivacy::isAccessAllowed($my->id, $activity->actor, 'custom', $album->permissions);
                 break;
             case 'groups':
         }
     } else {
         // if it is not one of the core apps, we should allow plugins to decide
         // if they want to block the 'more' view
     }
     if ($showMore) {
         $act = $model->getActivity($activityId);
         $content = CActivityStream::getActivityContent($act);
         $objResponse->addScriptCall('joms.activities.setContent', $activityId, $content);
     } else {
         $content = JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN');
         $content = nl2br($content);
         $content = CString::str_ireplace("\n", '', $content);
         $objResponse->addScriptCall('joms.activities.setContent', $activityId, $content);
     }
     $objResponse->addScriptCall('joms.tooltip.setup();');
     return $objResponse->sendResponse();
 }
Exemplo n.º 23
0
 /**
  * Automatically link username in the provided message when message contains @username
  * @param $message
  * @param bool $email
  * @param bool $usernameOnly only pass username without hyperlink
  * @return mixed $message A modified copy of the message with the proper hyperlinks or username.
  */
 public static function replaceAliasURL($message, $email = false, $usernameOnly = false)
 {
     $pattern = '/@\\[\\[(\\d+):([a-z]+):([^\\]]+)\\]\\]/';
     preg_match_all($pattern, $message, $matches);
     if (isset($matches[1]) && count($matches[1]) > 0) {
         foreach ($matches[1] as $key => $uid) {
             $id = CFactory::getUser($uid)->get('id');
             $username = $matches[3][$key];
             if ($id != 0) {
                 if ($usernameOnly) {
                     $message = CString::str_ireplace($matches[0][$key], $username, $message);
                 } else {
                     $message = CString::str_ireplace($matches[0][$key], CLinkGeneratorHelper::getUserURL($id, $username, $email), $message);
                 }
             }
         }
     }
     return $message;
 }
Exemplo n.º 24
0
 public function _getAllAlbums()
 {
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $my = CFactory::getUser();
     $userId = JRequest::getInt('userid', '');
     //CFactory::load( 'models', 'groups' );
     $model = CFactory::getModel('photos');
     $groupId = JRequest::getInt('groupid', '', 'REQUEST');
     $type = PHOTOS_USER_TYPE;
     if (!empty($userId)) {
         $user = CFactory::getUser($userId);
         // Set document title
         //CFactory::load( 'helpers' , 'owner' );
         $blocked = $user->isBlocked();
         if ($blocked && !COwnerHelper::isCommunityAdmin()) {
             $tmpl = new CTemplate();
             echo $tmpl->fetch('profile.blocked');
             return;
         }
         if ($my->id == $user->id) {
             $title = JText::_('COM_COMMUNITY_PHOTOS_MY_PHOTOS');
         } else {
             $title = JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $user->getDisplayName());
         }
     } else {
         $title = JText::_('COM_COMMUNITY_PHOTOS_ALL_PHOTOS_TITLE');
     }
     if (!empty($groupId)) {
         $title = JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_PHOTOS_FEEDS');
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         //@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)) {
             echo JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN');
             return;
         }
         $type = PHOTOS_GROUP_TYPE;
         $albumsData = $model->getGroupAlbums($groupId, false, false, $mainframe->getCfg('feed_limit'));
     } else {
         // Get ALL albums or USER albums
         if (!empty($userId)) {
             $albumsData = $model->_getAlbums($userId, $type, false, false, $mainframe->getCfg('feed_limit'));
         } else {
             $albumsData = $model->getAllAlbums($userId, $mainframe->getCfg('feed_limit'));
         }
     }
     //CFactory::load( 'libraries' , 'featured' );
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featuredAlbums = $featured->getItemIds();
     $featuredList = array();
     // Prepare feeds
     $document->setTitle($title);
     foreach ($albumsData as $album) {
         $table = JTable::getInstance('Album', 'CTable');
         $table->bind($album);
         $table->thumbnail = $table->getCoverThumbPath();
         $albumAuthor = CFactory::getUser($table->creator);
         $description = '<img src="' . $table->thumbnail . '" alt="" />&nbsp;';
         $description .= $albumAuthor->getDisplayName() . ' posted ' . $album->count . ' photos ';
         //print_r($albumAuthor); exit;
         $item = new JFeedItem();
         $item->title = $table->name;
         $item->link = CRoute::_('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $albumAuthor->id);
         $item->description = $description . $table->description;
         $item->date = $table->created;
         $item->author = $albumAuthor->getDisplayName();
         // Make sure url is absolute
         $item->description = CString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
         $document->addItem($item);
     }
     $content = $document->render();
 }
Exemplo n.º 25
0
 protected function _buildQuery($filters = array())
 {
     $db = $this->getDBO();
     $activities = array();
     $user = CFactory::getUser(isset($options['userid']) ? $options['userid'] : null);
     $blockLists = $user->getBlockedUsers();
     $blockedUserIds = array();
     foreach ($blockLists as $blocklist) {
         $blockedUserIds[] = $blocklist->blocked_userid;
     }
     $defFilter = array('actor' => $user->id, 'friends' => $user->getFriendIds(), 'blockedUsers' => $blockedUserIds, 'afterDate' => $user->registerDate, 'maxEntries' => 20, 'respectPrivacy' => true, 'actidRange' => null, 'displayArchived' => null, 'actid' => null, 'groupid' => null, 'eventid' => null, 'app' => null);
     $filters = array_merge($defFilter, $filters);
     $query = $this->_buildSelect($filters) . $this->_buildFrom($filters) . $this->_buildWhere($filters) . $this->_buildG($filters) . $this->_buildORDERBY($filters);
     return CString::str_ireplace('WHERE (  ) AND', ' WHERE ', $query);
 }
Exemplo n.º 26
0
 /**
  *
  *
  * @return $embedvideo specific embeded code to play the video
  */
 public function getViewHTML($videoId, $videoWidth, $videoHeight)
 {
     if (!$videoId) {
         $videoId = $this->videoId;
     }
     $file = 'http://media.photobucket.com/video/' . CString::str_ireplace(" ", "%20", $videoId);
     $xmlContent = CRemoteHelper::getContent($file);
     if ($xmlContent == FALSE) {
         return false;
     }
     $pattern = "'<link rel=\"video_src\" href=\"(.*?)\" \\/>'s";
     preg_match_all($pattern, $xmlContent, $matches);
     if ($matches) {
         $videoUrl = rawurldecode($matches[1][0]);
     }
     $embedCode = '<embed width="' . $videoWidth . '" height="' . $videoHeight . '" type="application/x-shockwave-flash" wmode="transparent" src="' . CVideosHelper::getIURL($videoUrl) . '">';
     return $embedCode;
 }
Exemplo n.º 27
0
 public function display($data = null)
 {
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $my = CFactory::getUser();
     $userid = JRequest::getInt('userid', '');
     $groupId = JRequest::getInt('groupid', '');
     if (!empty($userid)) {
         $user = CFactory::getUser($userid);
         // Set document title
         //CFactory::load( 'helpers' , 'owner' );
         $blocked = $user->isBlocked();
         if ($blocked && !COwnerHelper::isCommunityAdmin()) {
             $tmpl = new CTemplate();
             echo $tmpl->fetch('profile.blocked');
             return;
         }
         if ($my->id == $user->id) {
             $title = JText::_('COM_COMMUNITY_VIDEOS_MY');
         } else {
             $title = JText::sprintf('COM_COMMUNITY_VIDEOS_USERS_VIDEO_TITLE', $user->getDisplayName());
         }
     } else {
         $title = JText::_('COM_COMMUNITY_VIDEOS_ALL_DESC');
     }
     // list user videos or group videos
     if (!empty($groupId)) {
         $title = JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_VIDEOS_FEEDS');
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         //CFactory::load( 'helpers' , 'owner' );
         $isMember = $group->isMember($my->id);
         $isMine = $my->id == $group->ownerid;
         if (!$isMember && !$isMine && !COwnerHelper::isCommunityAdmin() && $group->approvals == COMMUNITY_PRIVATE_GROUP) {
             echo JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE');
             return;
         }
         $tmpVideos = $this->model->getGroupVideos($groupId, '', $mainframe->getCfg('feed_limit'));
         $videos = array();
         foreach ($tmpVideos as $videoEntry) {
             $video = JTable::getInstance('Video', 'CTable');
             $video->bind($videoEntry);
             $videos[] = $video;
         }
     } else {
         $filters = array('creator' => $userid, 'status' => 'ready', 'groupid' => 0, 'limit' => $mainframe->getCfg('feed_limit'), 'limitstart' => 0, 'sorting' => JRequest::getVar('sort', 'latest'));
         // list all user videos & all group videos
         if (empty($userid)) {
             unset($filters['creator']);
             unset($filters['groupid']);
         }
         $videos = array();
         $tmpVideos = $this->model->getVideos($filters, true);
         foreach ($tmpVideos as $videoEntry) {
             $video = JTable::getInstance('Video', 'CTable');
             $video->bind($videoEntry);
             $videos[] = $video;
         }
     }
     $videosCount = count($videos);
     $feedLimit = $mainframe->getCfg('feed_limit');
     $limit = $videosCount < $feedLimit ? $videosCount : $feedLimit;
     // Prepare feeds
     $document->setTitle($title);
     for ($i = 0; $i < $limit; $i++) {
         $video = $videos[$i];
         $item = new JFeedItem();
         $item->title = $video->getTitle();
         $item->link = $video->getURL();
         $item->description = '<img src="' . $video->getThumbnail() . '" alt="" />&nbsp;' . $video->getDescription();
         $item->date = $video->created;
         $item->author = $video->getCreatorName();
         $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
         if (!empty($video->id)) {
             $document->addItem($item);
         }
     }
 }
Exemplo n.º 28
0
 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();
 }
Exemplo n.º 29
0
 private function _createPhoto($data)
 {
     $db = $this->getDBO();
     // Fix the directory separators.
     $data->image = CString::str_ireplace('\\', '/', $data->image);
     $data->thumbnail = CString::str_ireplace('\\', '/', $data->thumbnail);
     $db->insertObject('#__community_photos', $data);
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $data->id = $db->insertid();
     return $data;
 }
Exemplo n.º 30
0
 /**
  * Overrides parent store function as we need to clean up some variables
  * */
 public function store($updateNulls = false)
 {
     if (!$this->check()) {
         return false;
     }
     $this->image = CString::str_ireplace('\\', '/', $this->image);
     $this->thumbnail = CString::str_ireplace('\\', '/', $this->thumbnail);
     $this->original = CString::str_ireplace('\\', '/', $this->original);
     // Store params
     $this->params = $this->_params->toString();
     $result = parent::store();
     if ($this->status != 'temp' && $result) {
         // Changes in photos will affect the album. Do a store on album
         $album = JTable::getInstance('Album', 'CTable');
         $album->load($this->albumid);
         $album->store();
     }
     return $result;
 }