Example #1
0
 /**
  * Feature the given user
  *
  * @param  int $memberId userid to feature
  * @return [type]           [description]
  */
 public function ajaxAddFeatured($memberId)
 {
     $filter = JFilterInput::getInstance();
     $memberId = $filter->clean($memberId, 'int');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $config = CFactory::getConfig();
             $limit = $config->get('featured' . FEATURED_USERS . 'limit', 10);
             if ($featured->add($memberId, $my->id) === true) {
                 $html = JText::sprintf('COM_COMMUNITY_MEMBER_IS_FEATURED', $member->getDisplayName());
             } else {
                 $html = JText::sprintf('COM_COMMUNITY_MEMBER_LIMIT_REACHED_FEATURED', $member->getDisplayName(), $limit);
             }
         } else {
             $html = JText::_('COM_COMMUNITY_USER_ALREADY_FEATURED');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED));
     $json = array();
     $json['title'] = ' ';
     $json['html'] = $html;
     die(json_encode($json));
 }
Example #2
0
 public function ajaxAddFeatured($memberId)
 {
     $objResponse = new JAXResponse();
     CFactory::load('helpers', 'owner');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             CFactory::load('libraries', 'featured');
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $featured->add($memberId, $my->id);
             $objResponse->addAssign('cWindowContent', 'innerHTML', JText::sprintf('CC MEMBER IS FEATURED', $member->getDisplayName()));
         } else {
             $objResponse->addAssign('cWindowContent', 'innerHTML', JText::_('CC USER ALREADY FEATURED'));
         }
     } else {
         $objResponse->addAssign('cWindowContent', 'innerHTML', JText::_('CC NOT ALLOWED TO ACCESS SECTION'));
     }
     $buttons = '<input type="button" class="button" onclick="window.location.reload();" value="' . JText::_('CC BUTTON CLOSE') . '"/>';
     $objResponse->addScriptCall('cWindowActions', $buttons);
     return $objResponse->sendResponse();
 }
Example #3
0
 public function ajaxAddFeatured($memberId)
 {
     $filter = JFilterInput::getInstance();
     $memberId = $filter->clean($memberId, 'int');
     $objResponse = new JAXResponse();
     CFactory::load('helpers', 'owner');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             CFactory::load('libraries', 'featured');
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $featured->add($memberId, $my->id);
             $html = JText::sprintf('COM_COMMUNITY_MEMBER_IS_FEATURED', $member->getDisplayName());
         } else {
             $html = JText::_('COM_COMMUNITY_USER_ALREADY_FEATURED');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     $actions = '<input type="button" class="button" onclick="window.location.reload();" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '"/>';
     $objResponse->addScriptCall('cWindowAddContent', $html, $actions);
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED));
     return $objResponse->sendResponse();
 }
Example #4
0
 /**
  *  Get Featured Videos
  *
  *  @return     array   Objects of random featured videos
  *  @since      1.5
  */
 public function _getFeatVideos()
 {
     $featured = new CFeatured(FEATURED_VIDEOS);
     $featuredVideos = $featured->getItemIds();
     $featuredList = array();
     foreach ($featuredVideos as $videoId) {
         $table = JTable::getInstance('Video', 'CTable');
         $table->load($videoId);
         $table->loadExtra();
         $featuredList[] = $table;
     }
     return $featuredList;
 }
Example #5
0
 /**
  *	Get Featured Videos
  *	
  *	@return		array	Objects of random featured videos
  *	@since		1.5
  */
 private function _getFeatVideos()
 {
     CFactory::load('libraries', 'featured');
     CFactory::load('helpers', 'videos');
     $featured = new CFeatured(FEATURED_VIDEOS);
     $featuredVideos = $featured->getItemIds();
     $featuredList = array();
     foreach ($featuredVideos as $videoId) {
         $table =& JTable::getInstance('Video', 'CTable');
         $table->load($videoId);
         $featuredList[] = $table;
     }
     return $featuredList;
 }
Example #6
0
 /**
  *    Get Featured Videos
  *
  * @return        array    Objects of random featured videos
  * @since        1.5
  */
 private function _getFeatVideos()
 {
     $featured = new CFeatured(FEATURED_VIDEOS);
     $featuredVideos = $featured->getItemIds();
     $featuredList = array();
     foreach ($featuredVideos as $videoId) {
         $table = JTable::getInstance('Video', 'CTable');
         $table->load($videoId);
         if (empty($table->id)) {
             continue;
         }
         $featuredList[] = $table;
     }
     return $featuredList;
 }
Example #7
0
 public function deleteGroup()
 {
     require_once JPATH_ROOT . '/components/com_community/libraries/featured.php';
     require_once JPATH_ROOT . '/components/com_community/defines.community.php';
     $featured = new CFeatured(FEATURED_GROUPS);
     $groupWithError = array();
     $group = JTable::getInstance('Group', 'CTable');
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $id = $jinput->post->get('cid', '', 'NONE');
     //JRequest::getVar( 'cid' , '' , 'post' );
     if (empty($id)) {
         JError::raiseError('500', JText::_('COM_COMMUNITY_INVALID_ID'));
     }
     foreach ($id as $data) {
         require_once JPATH_ROOT . '/components/com_community/models/groups.php';
         //delete group bulletins
         CommunityModelGroups::deleteGroupBulletins($data);
         //delete group members
         CommunityModelGroups::deleteGroupMembers($data);
         //delete group wall
         CommunityModelGroups::deleteGroupWall($data);
         //delete group discussions
         CommunityModelGroups::deleteGroupDiscussions($data);
         //delete group media files
         CommunityModelGroups::deleteGroupMedia($data);
         //load group data before delete
         $group->load($data);
         $groupData = $group;
         //delete group avatar.
         jimport('joomla.filesystem.file');
         if (!empty($groupData->avatar)) {
             //images/avatar/groups/d203ccc8be817ad5b6a8335c.png
             $path = explode('/', $groupData->avatar);
             $file = JPATH_ROOT . '/' . $path[0] . '/' . $path[1] . '/' . $path[2] . '/' . $path[3];
             if (file_exists($file)) {
                 JFile::delete($file);
             }
         }
         if (!empty($groupData->thumb)) {
             //images/avatar/groups/thumb_d203ccc8be817ad5b6a8335c.png
             $path = explode('/', $groupData->thumb);
             $file = JPATH_ROOT . '/' . $path[0] . '/' . $path[1] . '/' . $path[2] . '/' . $path[3];
             if (file_exists($file)) {
                 JFile::delete($file);
             }
         }
         if (!$group->delete($data)) {
             array_push($groupWithError, $data . ':' . $groupData->name);
         }
         $featured->delete($data);
     }
     $message = '';
     if (empty($error)) {
         $message = JText::_('COM_COMMUNITY_GROUP_DELETED');
     } else {
         $error = implode(',', $groupWithError);
         $message = JText::sprintf('COM_COMMUNITY_GROUPS_DELETE_GROUP_ERROR', $error);
     }
     $mainframe = JFactory::getApplication();
     $mainframe->redirect('index.php?option=com_community&view=groups', $message, 'message');
 }
Example #8
0
 public function advanceSearch()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     //load calendar behavior
     JHtml::_('behavior.calendar');
     JHtml::_('behavior.tooltip');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_TITLE_CUSTOM_SEARCH'));
     //$this->showSubMenu();
     $this->addPathway(JText::_('COM_COMMUNITY_TITLE_CUSTOM_SEARCH'));
     $profileType = $jinput->get('profiletype', 0, 'INT');
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $result = null;
     $fields = CAdvanceSearch::getFields($profileType);
     $data = new stdClass();
     $post = JRequest::get('GET');
     $keyList = isset($post['key-list']) ? $post['key-list'] : '';
     $avatarOnly = $jinput->get('avatar', '', 'NONE');
     if (JString::strlen($keyList) > 0) {
         //formatting the assoc array
         $filter = array();
         $key = explode(',', $keyList);
         $joinOperator = isset($post['operator']) ? $post['operator'] : '';
         foreach ($key as $idx) {
             $obj = new stdClass();
             $obj->field = $post['field' . $idx];
             $obj->condition = $post['condition' . $idx];
             $obj->fieldType = $post['fieldType' . $idx];
             if ($obj->fieldType == 'email') {
                 $obj->condition = 'equal';
             }
             // we need to check whether the value contain start and end kind of values.
             // if yes, make them an array.
             if (isset($post['value' . $idx . '_2'])) {
                 if ($obj->fieldType == 'date') {
                     $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx];
                     $endDate = empty($post['value' . $idx . '_2']) ? '01/01/1970' : $post['value' . $idx . '_2'];
                     // Joomla 1.5 uses "/"
                     // Joomla 1.6 uses "-"
                     $delimeter = '-';
                     if (strpos($startDate, '/')) {
                         $delimeter = '/';
                     }
                     $sdate = explode($delimeter, $startDate);
                     $edate = explode($delimeter, $endDate);
                     if (isset($sdate[2]) && isset($edate[2])) {
                         $obj->value = array($sdate[0] . '-' . $sdate[1] . '-' . $sdate[2] . ' 00:00:00', $edate[0] . '-' . $edate[1] . '-' . $edate[2] . ' 23:59:59');
                     } else {
                         $obj->value = array(0, 0);
                     }
                 } else {
                     $obj->value = array($post['value' . $idx], $post['value' . $idx . '_2']);
                 }
             } else {
                 if ($obj->fieldType == 'date') {
                     $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx];
                     $delimeter = '-';
                     if (strpos($startDate, '/')) {
                         $delimeter = '/';
                     }
                     $sdate = explode($delimeter, $startDate);
                     if (isset($sdate[2])) {
                         $obj->value = $sdate[2] . '-' . $sdate[1] . '-' . $sdate[0] . ' 00:00:00';
                     } else {
                         $obj->value = 0;
                     }
                 } else {
                     if ($obj->fieldType == 'checkbox') {
                         if (empty($post['value' . $idx])) {
                             //this mean user didnot check any of the option.
                             $obj->value = '';
                         } else {
                             $obj->value = isset($post['value' . $idx]) ? implode(',', $post['value' . $idx]) : '';
                         }
                     } else {
                         $obj->value = isset($post['value' . $idx]) ? $post['value' . $idx] : '';
                     }
                 }
             }
             $filter[] = $obj;
         }
         $data->search = CAdvanceSearch::getResult($filter, $joinOperator, $avatarOnly, '', $profileType);
         $data->filter = $post;
     }
     $rows = !empty($data->search) ? $data->search->result : array();
     $pagination = !empty($data->search) ? $data->search->pagination : '';
     $filter = !empty($data->filter) ? $data->filter : array();
     $resultRows = array();
     $friendsModel = CFactory::getModel('friends');
     for ($i = 0; $i < count($rows); $i++) {
         $row = $rows[$i];
         //filter the user profile type
         if ($profileType && $row->_profile_id != $profileType) {
             continue;
         }
         $obj = new stdClass();
         $obj->user = $row;
         $obj->friendsCount = $row->getFriendCount();
         $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->id);
         $isFriend = CFriendsHelper::isConnected($row->id, $my->id);
         $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $row->id ? true : false;
         $resultRows[] = $obj;
     }
     if (class_exists('Services_JSON')) {
         $json = new Services_JSON();
     } else {
         require_once AZRUL_SYSTEM_PATH . '/pc_includes/JSON.php';
         $json = new Services_JSON();
     }
     $tmpl = new CTemplate();
     $multiprofileArr = array();
     $hasMultiprofile = false;
     //let see if we have any multiprofile enabled
     if ($config->get('profile_multiprofile')) {
         $hasMultiprofile = true;
         //lets get the available profile
         $profileModel = CFactory::getModel('Profile');
         $profiles = $profileModel->getProfileTypes();
         if ($profiles) {
             $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=advancesearch'), 'name' => JText::_('COM_COMMUNITY_ALL_PROFILE'), 'selected' => !$profileType ? 1 : 0);
             foreach ($profiles as $profile) {
                 $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=advancesearch&profiletype=' . $profile->id), 'name' => $profile->name, 'selected' => $profile->id == $profileType ? 1 : 0);
             }
         }
     }
     $searchForm = $tmpl->set('fields', $fields)->set('hasMultiprofile', $hasMultiprofile)->set('multiprofileArr', $multiprofileArr)->set('keyList', $keyList)->set('profileType', $profileType)->set('avatarOnly', $avatarOnly)->set('filterJson', $json->encode($filter))->set('postresult', isset($post['key-list']))->set('submenu', $this->showSubmenu(false))->fetch('search.advancesearch');
     if (isset($post['key-list'])) {
         //result template
         $tmplResult = new CTemplate();
         $featured = new CFeatured(FEATURED_USERS);
         $featuredList = $featured->getItemIds();
         $tmpl->set('featuredList', $featuredList);
         $searchForm .= $tmplResult->set('my', $my)->set('showFeaturedList', false)->set('multiprofileArr', $multiprofileArr)->set('featuredList', $featuredList)->set('data', $resultRows)->set('isAdvanceSearch', true)->set('hasMultiprofile', $hasMultiprofile)->set('sortings', '')->set('pagination', $pagination)->set('filter', $filter)->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->fetch('people.browse');
     }
     echo $searchForm;
 }
Example #9
0
 * @author iJoomla.com <*****@*****.**>
 * @url https://www.jomsocial.com/license-agreement
 * The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
 * More info at https://www.jomsocial.com/license-agreement
 */
defined('_JEXEC') or die;
$isMine = COwnerHelper::isMine($my->id, $user->id);
$avatar = $user->getAvatarInfo();
$loggedIn = $my->id != 0;
$profileFields = '';
$themeModel = CFactory::getModel('theme');
$profileModel = CFactory::getModel('profile');
$settings = $themeModel->getSettings('profile');
$my = CFactory::getUser($profile->id);
$config = CFactory::getConfig();
$featured = new CFeatured(FEATURED_USERS);
$featuredList = $featured->getItemIds();
if (isset($settings['profile']['tagline']) && strlen($settings['profile']['tagline'])) {
    $blocks = json_decode($settings['profile']['tagline'], true);
    $blockEnabled = true;
    foreach ($blocks as $block) {
        $blockString = "";
        if ($block['spacebefore']) {
            $blockString .= " ";
        }
        if (strlen($block['before'])) {
            $blockString .= JText::_($block['before']) . " ";
        }
        if (strlen($block['field'])) {
            if (isset($profile->fieldsById->{$block['field']}) && strlen($profile->fieldsById->{$block['field']}->value)) {
                # var_dump($profile->fieldsById->{$block['field']});
Example #10
0
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $id = $jinput->get('listid', '', 'INT');
     //JRequest::getVar( 'listid' , '' );
     $list = JTable::getInstance('MemberList', 'CTable');
     $list->load($id);
     if (empty($list->id) || is_null($list->id)) {
         echo JText::_('COM_COMMUNITY_INVALID_ID');
         return;
     }
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', $list->getTitle());
     $tmpCriterias = $list->getCriterias();
     $criterias = array();
     foreach ($tmpCriterias as $criteria) {
         $obj = new stdClass();
         $obj->field = $criteria->field;
         $obj->condition = $criteria->condition;
         $obj->fieldType = $criteria->type;
         switch ($criteria->type) {
             case 'date':
             case 'birthdate':
                 if ($criteria->condition == 'between') {
                     $date = explode(',', $criteria->value);
                     if (isset($date[1])) {
                         $delimeter = '-';
                         if (strpos($date[0], '/')) {
                             $delimeter = '/';
                         }
                         $startDate = explode($delimeter, $date[0]);
                         $endDate = explode($delimeter, $date[1]);
                         if (isset($startDate[2]) && isset($endDate[2])) {
                             //date format
                             $obj->value = array($startDate[2] . '-' . intval($startDate[1]) . '-' . $startDate[0] . ' 00:00:00', $endDate[2] . '-' . intval($endDate[1]) . '-' . $endDate[0] . ' 23:59:59');
                         } else {
                             //age format
                             $obj->value = array($date[0], $date[1]);
                         }
                     } else {
                         //wrong data, set to default
                         $obj->value = array(0, 0);
                     }
                 } else {
                     $delimeter = '-';
                     if (strpos($criteria->value, '/')) {
                         $delimeter = '/';
                     }
                     $startDate = explode($delimeter, $criteria->value);
                     if (isset($startDate[2])) {
                         //date format
                         $obj->value = $startDate[2] . '-' . intval($startDate[1]) . '-' . $startDate[0] . ' 00:00:00';
                     } else {
                         //age format
                         $obj->value = $criteria->value;
                     }
                 }
                 break;
             case 'checkbox':
             default:
                 $obj->value = $criteria->value;
                 break;
         }
         $criterias[] = $obj;
     }
     //CFactory::load( 'helpers' , 'time');
     $created = CTimeHelper::getDate($list->created);
     //CFactory::load( 'libraries' , 'advancesearch' );
     //CFactory::load( 'libraries' , 'filterbar' );
     $sortItems = array('latest' => JText::_('COM_COMMUNITY_SORT_LATEST'), 'online' => JText::_('COM_COMMUNITY_SORT_ONLINE'), 'alphabetical' => JText::_('COM_COMMUNITY_SORT_ALPHABETICAL'));
     $sorting = $jinput->get->get('sort', 'latest', 'STRING');
     //JRequest::getVar( 'sort' , 'latest' , 'GET' );
     $data = CAdvanceSearch::getResult($criterias, $list->condition, $list->avataronly, $sorting);
     $tmpl = new CTemplate();
     $html = $tmpl->set('list', $list)->set('created', $created)->set('sorting', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'))->fetch('memberlist.result');
     unset($tmpl);
     //CFactory::load( 'libraries' , 'tooltip' );
     //CFactory::load( 'helpers' , 'owner' );
     //CFactory::load( 'libraries' , 'featured' );
     $featured = new CFeatured(FEATURED_USERS);
     $featuredList = $featured->getItemIds();
     $my = CFactory::getUser();
     $resultRows = array();
     $friendsModel = CFactory::getModel('friends');
     $alreadyfriend = array();
     //CFactory::load( 'helpers' , 'friends' );
     foreach ($data->result as $user) {
         $obj = new stdClass();
         $obj->user = $user;
         $obj->friendsCount = $user->getFriendCount();
         $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
         $isFriend = CFriendsHelper::isConnected($user->id, $my->id);
         $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $user->id ? true : false;
         //record friends
         if ($obj->addFriend) {
             $alreadyfriend[$user->id] = $user->id;
         }
         $resultRows[] = $obj;
     }
     $tmpl = new CTemplate();
     echo $tmpl->set('data', $resultRows)->set('alreadyfriend', $alreadyfriend)->set('sortings', '')->set('pagination', $data->pagination)->set('filter', '')->set('featuredList', $featuredList)->set('my', $my)->set('showFeaturedList', false)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->fetch('people.browse');
 }
Example #11
0
 /**
  * This function is used to display the cog options for any users
  * @param $targetId
  * @param int $groupId
  * @param int $eventId
  * @param bool $getHTML
  * @return stdClass|type
  */
 public static function getUserCog($targetId, $groupId = 0, $eventId = 0, $getHTML = false)
 {
     if (!$targetId) {
         return false;
     }
     $my = CFactory::getUser();
     //current user
     $user = CFactory::getUser($targetId);
     $display = new stdClass();
     $display->canFeature = false;
     $display->canBlock = false;
     $display->canIgnore = false;
     $display->canBan = false;
     $display->canUnfeature = false;
     $display->canUnblock = false;
     $display->canUnignore = false;
     $display->canSetGroupAdmin = false;
     $display->canUnsetGroupAdmin = false;
     $display->canSetEventAdmin = false;
     $display->canUnsetEventAdmin = false;
     $display->canBanFromGroup = false;
     $display->canUnbanFromGroup = false;
     $display->canRemoveFromGroup = false;
     $display->canBanFromGroup = false;
     $datas = array('canFeature' => array('lang' => 'COM_COMMUNITY_MAKE_FEATURED', 'href' => 'joms.api.userAddFeatured("' . $targetId . '")'), 'canUnfeature' => array('lang' => 'COM_COMMUNITY_REMOVE_FEATURED', 'href' => 'joms.api.userRemoveFeatured("' . $targetId . '")'), 'canBlock' => array('lang' => 'COM_COMMUNITY_BLOCK_USER', 'href' => 'joms.api.userBlock("' . $targetId . '")'), 'canUnblock' => array('lang' => 'COM_COMMUNITY_UNBLOCK_USER', 'href' => 'joms.api.userUnblock("' . $targetId . '")'), 'canBan' => array('lang' => 'COM_COMMUNITY_BAN_USER', 'href' => 'joms.api.userBan("' . $targetId . '")'), 'canIgnore' => array('lang' => 'COM_COMMUNITY_PREFERENCES_IGNORE', 'href' => 'joms.api.userIgnore("' . $targetId . '")'), 'canUnignore' => array('lang' => 'COM_COMMUNITY_PREFERENCES_UNIGNORE', 'href' => 'joms.api.userUnignore("' . $targetId . '")'), 'canSetGroupAdmin' => array('lang' => 'COM_COMMUNITY_GROUPS_ADMIN', 'href' => 'jax.call("community", "groups,ajaxAddAdmin", "' . $targetId . '", "' . $groupId . '")'), 'canUnsetGroupAdmin' => array('lang' => 'COM_COMMUNITY_GROUPS_REVERT_ADMIN', 'href' => 'jax.call("community", "groups,ajaxRemoveAdmin", "' . $targetId . '", "' . $groupId . '")'), 'canSetEventAdmin' => array('lang' => 'COM_COMMUNITY_EVENTS_ADMIN_SET', 'href' => 'jax.call("community","events,ajaxManageAdmin","' . $targetId . '", "' . $eventId . '","add")'), 'canUnsetEventAdmin' => array('lang' => 'COM_COMMUNITY_EVENTS_ADMIN_REVERT', 'href' => 'jax.call("community","events,ajaxManageAdmin","' . $targetId . '", "' . $eventId . '","remove")'), 'canBanFromGroup' => array('lang' => 'COM_COMMUNITY_GROUPS_BAN_FROM_GROUP', 'href' => 'joms.api.groupBanMember("' . $groupId . '", "' . $targetId . '")'), 'canUnbanFromGroup' => array('lang' => 'COM_COMMUNITY_GROUPS_UNBAN_FROM_GROUP', 'href' => 'joms.api.groupUnbanMember("' . $groupId . '", "' . $targetId . '")'), 'canRemoveFromGroup' => array('lang' => 'COM_COMMUNITY_GROUPS_REMOVE_FROM_GROUP', 'href' => 'joms.api.groupRemoveMember("' . $groupId . '", "' . $targetId . '")'));
     //if user is not logged in, nothing should be displayed at all
     if (!$my->id || $my->id == $targetId) {
         return false;
     }
     if (COwnerHelper::isCommunityAdmin($my->id)) {
         $featured = new CFeatured(FEATURED_USERS);
         $isFeatured = $featured->isFeatured($user->id);
         if ($isFeatured) {
             $display->canUnfeature = true;
         } else {
             $display->canFeature = true;
         }
         $display->canBan = true;
         //always true because if useajaxStreamAddr is banned, he shouldn't be in the list anymore
     }
     //we can only ignore or block user. We cannot do both
     $blockModel = CFactory::getModel('block');
     $block = $blockModel->getBlockStatus($my->id, $user->id, true);
     if ($block) {
         if (isset($block->type) && $block->type == 'block') {
             $display->canUnblock = true;
             $display->canIgnore = true;
         } else {
             //this is ignore list
             $display->canUnignore = true;
             $display->canBlock = true;
         }
     } else {
         $display->canIgnore = true;
         $display->canBlock = true;
     }
     //For Group only
     if ($groupId) {
         $datas['canBan']['lang'] = 'COM_COMMUNITY_BAN_FROM_SITE';
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         if ($group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) {
             if ($group->ownerid != $user->id) {
                 //if user is admin, then we can unset him, unless the admin is the creator
                 if ($group->isAdmin($user->id)) {
                     $display->canUnsetGroupAdmin = true;
                 } else {
                     $display->canSetGroupAdmin = true;
                 }
                 //we can ban any member of the group
                 if ($group->isBanned($user->id)) {
                     $display->canUnbanFromGroup = true;
                 } else {
                     $display->canBanFromGroup = true;
                 }
                 $display->canRemoveFromGroup = true;
             }
         }
     }
     //for event only
     if ($eventId) {
         $datas['canBan']['lang'] = 'COM_COMMUNITY_BAN_FROM_SITE';
         $event = JTable::getInstance('Event', 'CTable');
         $event->load($eventId);
         if ($event->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) {
             if ($event->isMember($user->id) && !$event->isCreator($user->id)) {
                 //if user is admin, then we can unset him, unless the admin is the creator
                 if ($event->isAdmin($user->id)) {
                     $display->canUnsetEventAdmin = true;
                 } else {
                     $display->canSetEventAdmin = true;
                 }
             }
         }
     }
     if ($getHTML) {
         $tmpl = new CTemplate();
         return $tmpl->set('options', $display)->set('datas', $datas)->set('groupid', $groupId ? $groupId : false)->set('eventid', $eventId ? $eventId : false)->fetch('general/user-cog');
     }
     return $display;
 }
Example #12
0
    /**
     * Returns an object of events which the user has registered.
     *
     * @access    public
     * @param    string     User's id.
     * @param    string     sorting criteria.
     * @returns array  An objects of event fields.
     */
    public function getEvents($categoryId = null, $userId = null, $sorting = null, $search = null, $hideOldEvent = true, $showOnlyOldEvent = false, $pending = null, $advance = null, $type = CEventHelper::ALL_TYPES, $contentid = 0, $limit = null, $upcomingOnly = false, $pagination = true, $hidePrivate = false)
    {
        $db = $this->getDBO();
        $join = '';
        $extraSQL = '';
        $input = JFactory::getApplication()->input;
        $my = CFactory::getUser();
        //get current user results as well if this is a private event/private group events
        if (!empty($userId) || $my->id) {
            $join = 'LEFT JOIN ' . $db->quoteName('#__community_events_members') . ' AS b ON a.' . $db->quoteName('id') . '=b.' . $db->quoteName('eventid');
            if ($my->id && empty($userId)) {
                $extraSQL .= ' AND (b.' . $db->quoteName('memberid') . '=' . $db->Quote($my->id) . ' OR 1)';
            } else {
                $extraSQL .= ' AND b.' . $db->quoteName('memberid') . '=' . $db->Quote($userId);
            }
            $pendingFlag = 1;
            if (!is_null($pending)) {
                $pendingFlag = $pending;
            }
            $extraSQL .= ' AND b.' . $db->quoteName('status') . '=' . $db->Quote($pendingFlag);
        }
        $user = CFactory::getUser();
        if ($user->id > 0) {
            if (!COwnerHelper::isCommunityAdmin()) {
                $extraSQL .= '

            AND(' . 'a.' . $db->quoteName('unlisted') . ' = ' . $db->Quote('0') . ' OR(' . 'a.' . $db->quoteName('unlisted') . ' = ' . $db->Quote('1') . ' AND' . '(SELECT COUNT(' . $db->quoteName('eventid') . ') FROM ' . $db->quoteName('#__community_events_members') . ' as b WHERE b.' . $db->quoteName('memberid') . '=' . $db->quote($user->id) . ' and b.' . $db->quoteName('eventid') . '=a.' . $db->quoteName('id') . ') > 0
                 )

                 )';
            }
        } else {
            $extraSQL .= ' AND a.' . $db->quoteName('unlisted') . ' = ' . $db->Quote('0');
        }
        if ($hidePrivate) {
            //hide the private event if current viewer is not the part of the event
            if (!COwnerHelper::isCommunityAdmin()) {
                $extraSQL .= '

            AND(' . 'a.' . $db->quoteName('permission') . ' = ' . $db->Quote('0') . ' OR(' . 'a.' . $db->quoteName('permission') . ' = ' . $db->Quote('1') . ' AND' . '(SELECT COUNT(' . $db->quoteName('eventid') . ') FROM ' . $db->quoteName('#__community_events_members') . ' as b WHERE b.' . $db->quoteName('memberid') . '=' . $db->quote($my->id) . ' and b.' . $db->quoteName('eventid') . '=a.' . $db->quoteName('id') . ') > 0
                 )

                 )';
            }
        }
        if (!empty($search)) {
            $extraSQL .= ' AND a.' . $db->quoteName('title') . ' LIKE ' . $db->Quote('%' . $search . '%');
        }
        if (!empty($categoryId) && $categoryId != 0) {
            if (is_array($categoryId)) {
                $categoryIds = implode(',', $categoryId);
                $extraSQL .= ' AND a.' . $db->quoteName('catid') . ' IN(' . $categoryIds . ')';
            } else {
                $extraSQL .= ' AND a.' . $db->quoteName('catid') . '=' . $db->Quote($categoryId);
            }
        }
        /* Begin : ADVANCE SEARCH */
        if (!empty($advance)) {
            if (!empty($advance['startdate'])) {
                $startDate = CTimeHelper::getDate(strtotime($advance['startdate']));
                $extraSQL .= ' AND a.' . $db->quoteName('startdate') . ' >= ' . $db->Quote($startDate->toSql());
            } else {
                if (!isset($advance['date'])) {
                    // If empty, don't select the past event
                    // $now = CTimeHelper::getDate();
                    // $extraSQL .= ' AND a.' . $db->quoteName('enddate') . ' >= ' . $db->Quote($now->toSql());
                }
            }
            if (!empty($advance['date'])) {
                // to get event within this date
                $between_date = date('Ymd', strtotime($advance['date']));
                $extraSQL .= ' AND DATE_FORMAT(a.' . $db->quoteName('startdate') . ',"%Y%m%d") <= ' . $db->Quote($between_date) . ' AND DATE_FORMAT(a.' . $db->quoteName('enddate') . ',"%Y%m%d") >= ' . $db->Quote($between_date);
                //show old/current event as well
                $hideOldEvent = false;
                $upcomingOnly = false;
            }
            if (!empty($advance['enddate'])) {
                $endDate = CTimeHelper::getDate(strtotime($advance['enddate']));
                $extraSQL .= ' AND a.' . $db->quoteName('startdate') . ' <= ' . $db->Quote($endDate->toSql());
            }
            /* Begin : SEARCH WITHIN */
            if (!empty($advance['radius']) && !empty($advance['fromlocation'])) {
                $longitude = null;
                $latitude = null;
                $data = CMapping::getAddressData($advance['fromlocation']);
                if ($data) {
                    if ($data->status == 'OK') {
                        $latitude = (double) $data->results[0]->geometry->location->lat;
                        $longitude = (double) $data->results[0]->geometry->location->lng;
                    }
                }
                $now = new JDate();
                $lng_min = $longitude - $advance['radius'] / abs(cos(deg2rad($latitude)) * 69);
                $lng_max = $longitude + $advance['radius'] / abs(cos(deg2rad($latitude)) * 69);
                $lat_min = $latitude - $advance['radius'] / 69;
                $lat_max = $latitude + $advance['radius'] / 69;
                $extraSQL .= ' AND a.' . $db->quoteName('longitude') . ' > ' . $db->quote($lng_min) . ' AND a.' . $db->quoteName('longitude') . ' < ' . $db->quote($lng_max) . ' AND a.' . $db->quoteName('latitude') . ' > ' . $db->quote($lat_min) . ' AND a.' . $db->quoteName('latitude') . ' < ' . $db->quote($lat_max);
            }
            if (!empty($advance['parent'])) {
                $extraSQL .= ' AND a.' . $db->quoteName('parent') . ' = ' . $db->Quote($advance['parent']);
            }
            if (!empty($advance['id'])) {
                if (is_array($advance['id']) && count($advance['id']) > 0) {
                    $ids = implode(',', $advance['id']);
                    $extraSQL .= ' AND a.' . $db->quoteName('id') . 'IN (' . $ids . ')';
                }
            }
            /* End : SEARCH WITHIN */
        }
        /* End : ADVANCE SEARCH */
        if ($pagination) {
            $limitstart = $this->getState('limitstart');
        } else {
            $limitstart = 0;
        }
        $limit = $limit === null ? $this->getState('limit') : $limit;
        if ($type != CEventHelper::ALL_TYPES && $type != 'featured_only') {
            $extraSQL .= ' AND a.' . $db->quoteName('type') . '=' . $db->Quote($type);
            if (is_array($contentid)) {
                $contentids = implode(',', $contentid);
                $extraSQL .= ' AND a.' . $db->quoteName('contentid') . ' IN(' . $contentids . ')';
            } elseif ($contentid > 0) {
                $extraSQL .= ' AND a.' . $db->quoteName('contentid') . '=' . $contentid;
            }
        }
        if ($type == 'featured_only') {
            $featured = new CFeatured(FEATURED_EVENTS);
            $featuredEvents = implode(',', $featured->getItemIds());
            if ($featuredEvents) {
                $extraSQL .= ' AND a.' . $db->quoteName('id') . ' IN (' . $featuredEvents . ')';
            } else {
                $extraSQL .= ' AND 0 ';
            }
        }
        if ($type == CEventHelper::GROUP_TYPE || $type == CEventHelper::ALL_TYPES) {
            // @rule: Respect group privacy
            $join .= ' LEFT JOIN ' . $db->quoteName('#__community_groups') . ' AS g';
            $join .= ' ON g.' . $db->quoteName('id') . ' = a.' . $db->quoteName('contentid');
            if ($type != CEventHelper::GROUP_TYPE) {
                $extraSQL .= ' AND (g.' . $db->quoteName('approvals') . ' = ' . $db->Quote('0') . ' OR g.' . $db->quoteName('approvals') . ' IS NULL';
                $extraSQL .= ' OR (g.' . $db->quoteName('approvals') . '=' . $db->Quote('1') . ' AND (SELECT COUNT(' . $db->quoteName('groupid') . ') FROM ' . $db->quoteName('#__community_groups_members') . ' as t WHERE t.' . $db->quoteName('memberid') . '=' . $db->quote($user->id) . ' AND t.' . $db->quoteName('approved') . '=' . $db->Quote('1') . ' and t.' . $db->quoteName('groupid') . '=g.' . $db->quoteName('id') . ') > 0) ';
                if (!empty($userId)) {
                    $extraSQL .= ' OR b.' . $db->quoteName('memberid') . '=' . $db->Quote($userId);
                }
                $extraSQL .= ')';
            }
        }
        $orderBy = '';
        $total = 0;
        switch ($sorting) {
            case 'latest':
                if (empty($orderBy)) {
                    $orderBy = ' ORDER BY a.' . $db->quoteName('created') . ' DESC';
                }
                break;
            case 'alphabetical':
                if (empty($orderBy)) {
                    $orderBy = ' ORDER BY a.' . $db->quoteName('title') . ' ASC';
                }
                break;
            case 'startdate':
                if (empty($orderBy)) {
                    $orderBy = ' ORDER BY a.startdate ASC';
                }
                break;
            default:
                $orderBy = ' ORDER BY a.' . $db->quoteName('startdate') . ' ASC';
                break;
        }
        $now = new JDate();
        /**
         * @todo need check and improve get correctly time with offset
         */
        $CTimeHelper = new CTimeHelper();
        $pastDate = $CTimeHelper->getLocaleDate();
        if ($hideOldEvent && !$upcomingOnly) {
            $extraSQL .= ' AND a.' . $db->quoteName('enddate') . ' >= ' . $db->Quote($pastDate->format('Y-m-d H:i:s', true, false));
        }
        if ($upcomingOnly) {
            $extraSQL .= ' AND a.' . $db->quoteName('startdate') . ' > ' . $db->Quote($pastDate->format('Y-m-d H:i:s', true, false));
        }
        if ($showOnlyOldEvent) {
            $extraSQL .= ' AND a.' . $db->quoteName('enddate') . ' < ' . $db->Quote($pastDate->format('Y-m-d H:i:s', true, false));
        }
        // Filtering on repeat event's parent
        $extraSQL .= ' AND ((a.' . $db->quoteName('parent') . '=' . $db->quote(0) . ' && (a.' . $db->quoteName('repeat') . '=' . $db->quote('') . ' || a.' . $db->quoteName('repeat') . ' IS NULL)) || (a.' . $db->quoteName('parent') . '!= 0 && a.' . $db->quoteName('repeat') . ' IS NOT NULL))';
        $limit = empty($limit) ? 0 : $limit;
        $query = 'SELECT DISTINCT a.* FROM ' . $db->quoteName('#__community_events') . ' AS a ' . $join . 'WHERE a.' . $db->quoteName('published') . '=' . $db->Quote('1') . $extraSQL . $orderBy . ' LIMIT ' . $limitstart . ', ' . $limit;
        $db->setQuery($query);
        $result = $db->loadObjectList();
        if ($db->getErrorNum()) {
            JError::raiseError(500, $db->stderr());
        }
        if ($db->getErrorNum()) {
            JError::raiseError(500, $db->stderr());
        }
        $query = 'SELECT COUNT(DISTINCT(a.' . $db->quoteName('id') . ')) FROM ' . $db->quoteName('#__community_events') . ' AS a ' . $join . 'WHERE a.' . $db->quoteName('published') . '=' . $db->Quote('1') . ' ' . $extraSQL;
        $db->setQuery($query);
        $total = $db->loadResult();
        $this->total = $total;
        if ($db->getErrorNum()) {
            JError::raiseError(500, $db->stderr());
        }
        if (empty($this->_pagination)) {
            jimport('joomla.html.pagination');
            $this->_pagination = new JPagination($total, $limitstart, $limit);
        }
        return $result;
    }
Example #13
0
 function deleteFromCommunityFeatured($user, $groups, $albums, $videos)
 {
     //delete featured user
     $featured = new CFeatured(FEATURED_USERS);
     if (!empty($user)) {
         $featured->delete($user['id']);
     }
     //delete featured groups
     $featured = new CFeatured(FEATURED_GROUPS);
     if (!empty($groups)) {
         $groupIds = explode(",", $groups);
         foreach ($groupIds as $groupId) {
             $featured->delete($groupId);
         }
     }
     //delete featured albums
     $featured = new CFeatured(FEATURED_ALBUMS);
     if (!empty($albums)) {
         foreach ($albums as $albumId) {
             $featured->delete($albumId);
         }
     }
     //delete featured albums
     $featured = new CFeatured(FEATURED_VIDEOS);
     if (!empty($videos)) {
         foreach ($videos as $videoId) {
             $featured->delete($videoId);
         }
     }
 }
Example #14
0
 public function ajaxGetFeaturedVideos($limit)
 {
     $filter = JFilterInput::getInstance();
     $limit = $filter->clean($limit, 'int');
     $limit = max(0, $limit);
     $cache = CFactory::getCache('Core');
     $intRandom = rand(COMMUNITY_CACHE_RANDOM_MIN, COMMUNITY_CACHE_RANDOM_MAX);
     $my = CFactory::getUser();
     $permissions = $my->id == 0 ? 0 : 20;
     if (!($html = $cache->load('frontpage_ajaxGetFeaturedVideos_' . $permissions . '_' . $intRandom))) {
         CFactory::load('libraries', 'featured');
         $featured = new CFeatured(FEATURED_VIDEOS);
         $featuredVideos = $featured->getItemIds();
         if (!empty($featuredVideos)) {
             $videoId = array();
             foreach ($featuredVideos as $featuredVideo) {
                 $videoId[] = $featuredVideo;
             }
             $objResponse = new JAXResponse();
             $oversampledTotal = $limit * COMMUNITY_OVERSAMPLING_FACTOR;
             $model = CFactory::getModel('videos');
             $filter = array('id' => $videoId, 'status' => 'ready', 'permissions' => $permissions, 'sorting' => 'latest', 'limit' => $oversampledTotal);
             $featuredVideos = $model->getVideos($filter, true);
             if (!empty($featuredVideos)) {
                 shuffle($featuredVideos);
                 $maxLatestCount = count($featuredVideos) > $limit ? $limit : count($featuredVideos);
                 $html = $this->prepareVideosData($featuredVideos, $maxLatestCount, $objResponse);
             } else {
                 $html = JText::_('COM_COMMUNITY_VIDEOS_NO_FEATURED_VIDEOS_YET');
             }
         } else {
             $html = JText::_('COM_COMMUNITY_VIDEOS_NO_FEATURED_VIDEOS_YET');
         }
         $cache->save($html, NULL, array(COMMUNITY_CACHE_TAG_VIDEOS));
     }
     $objResponse = new JAXResponse();
     $objResponse->addAssign('latest-videos-container', 'innerHTML', $html);
     $objResponse->addScriptCall("joms.filters.hideLoading();");
     return $objResponse->sendResponse();
 }
Example #15
0
 /**
  * Delete featured videos
  *
  * @param    int $id The id of the video
  * @return    True on success
  * @since    1.2
  * */
 private function _deleteFeaturedVideos($id = 0)
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return;
     }
     $featuredVideo = new CFeatured(FEATURED_VIDEOS);
     $featuredVideo->delete($id);
     return;
 }
Example #16
0
 /**
  * Delete group's media
  *
  * param	string	id The id of the group.
  *
  **/
 public static function deleteGroupMedia($gid)
 {
     $db = JFactory::getDBO();
     $photosModel = CFactory::getModel('photos');
     $videoModel = CFactory::getModel('videos');
     $fileModel = CFactory::getModel('files');
     // group's photos removal.
     $albums = $photosModel->getGroupAlbums($gid, false, false, 0);
     foreach ($albums as $item) {
         $photos = $photosModel->getAllPhotos($item->id, PHOTOS_GROUP_TYPE);
         foreach ($photos as $row) {
             $photo = JTable::getInstance('Photo', 'CTable');
             $photo->load($row->id);
             $photo->delete();
         }
         //now we delete group photo album folder
         $album = JTable::getInstance('Album', 'CTable');
         $album->load($item->id);
         $album->delete();
     }
     //group's videos
     $featuredVideo = new CFeatured(FEATURED_VIDEOS);
     $videos = $videoModel->getGroupVideos($gid);
     foreach ($videos as $vitem) {
         if (!$vitem) {
             continue;
         }
         $video = JTable::getInstance('Video', 'CTable');
         $videaId = (int) $vitem->id;
         $video->load($videaId);
         if ($video->delete()) {
             // Delete all videos related data
             $videoModel->deleteVideoWalls($videaId);
             $videoModel->deleteVideoActivities($videaId);
             //remove featured video
             $featuredVideo->delete($videaId);
             //remove the physical file
             $storage = CStorage::getStorage($video->storage);
             if ($storage->exists($video->thumb)) {
                 $storage->delete($video->thumb);
             }
             if ($storage->exists($video->path)) {
                 $storage->delete($video->path);
             }
         }
     }
     $fileModel->alldelete($gid, 'group');
     return true;
 }
Example #17
0
 public function ajaxGetFeaturedVideos($limit)
 {
     $filter = JFilterInput::getInstance();
     $limit = $filter->clean($limit, 'int');
     $limit = max(0, $limit);
     $my = CFactory::getUser();
     $permissions = $my->id == 0 ? 10 : 20;
     $permissions = COwnerHelper::isCommunityAdmin() ? 40 : $permissions;
     //CFactory::load( 'libraries', 'featured' );
     $featured = new CFeatured(FEATURED_VIDEOS);
     $featuredVideos = $featured->getItemIds();
     if (!empty($featuredVideos)) {
         $videoId = array();
         foreach ($featuredVideos as $featuredVideo) {
             $videoId[] = $featuredVideo;
         }
         $objResponse = new JAXResponse();
         $oversampledTotal = $limit * COMMUNITY_OVERSAMPLING_FACTOR;
         $model = CFactory::getModel('videos');
         $filter = array('id' => $videoId, 'status' => 'ready', 'permissions' => $permissions, 'sorting' => 'latest', 'limit' => $oversampledTotal);
         $featuredVideos = $model->getVideos($filter, true);
         if (!empty($featuredVideos)) {
             shuffle($featuredVideos);
             $maxLatestCount = count($featuredVideos) > $limit ? $limit : count($featuredVideos);
             $html = $this->prepareVideosData($featuredVideos, $maxLatestCount, $objResponse);
         } else {
             $html = JText::_('COM_COMMUNITY_VIDEOS_NO_FEATURED_VIDEOS_YET');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_VIDEOS_NO_FEATURED_VIDEOS_YET');
     }
     $json = array('success' => true, 'html' => $html);
     die(json_encode($json));
 }
Example #18
0
 /**
  * Display a list of pending friend requests
  * */
 public function pending($data = null)
 {
     if (!$this->accessAllowed('registered')) {
         return;
     }
     $mainframe = JFactory::getApplication();
     $config = CFactory::getConfig();
     CWindow::load();
     $my = CFactory::getUser();
     if ($my->id == 0) {
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PLEASE_LOGIN_WARNING'), 'error');
         return;
     }
     // Set pathway
     $this->addPathway(JText::_('COM_COMMUNITY_FRIENDS'), CRoute::_('index.php?option=com_community&view=friends'));
     $this->addPathway(JText::_('COM_COMMUNITY_FRIENDS_AWAITING_AUTHORIZATION'), '');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_FRIENDS_AWAITING_AUTHORIZATION'));
     // Load submenu
     //$this->showSubMenu();
     $rows = !empty($data->pending) ? $data->pending : array();
     for ($i = 0; $i < count($rows); $i++) {
         $row = $rows[$i];
         $row->user = CFactory::getUser($row->id);
         $row->user->friendsCount = $row->user->getFriendCount();
         $row->user->profileLink = CUrlHelper::userLink($row->id);
         $row->msg = $this->escape($row->msg);
     }
     //Featured
     $featured = new CFeatured(FEATURED_USERS);
     $featuredList = $featured->getItemIds();
     $tmpl = new CTemplate();
     echo $tmpl->set('rows', $rows)->setRef('my', $my)->set('config', $config)->set('pagination', $data->pagination)->set('submenu', $this->showSubmenu(false))->set('featuredList', $featuredList)->fetch('friends/request-received');
 }
Example #19
0
 /**
  * Delete an album
  * Set all photo within the album to have albumid = 0
  * Do not yet delete the photos, this could be very slow on an album that
  * has huge amount of photos
  */
 public function delete($pk = null)
 {
     //lets get all the photo info under the album
     $photoModel = CFactory::getModel('photos');
     $photos = $photoModel->getAllPhotos($this->id, $this->type);
     $db = JFactory::getDBO();
     $strSQL = 'UPDATE ' . $db->quoteName('#__community_photos') . ' SET ' . $db->quoteName('albumid') . '=' . $db->Quote(0) . ', ' . $db->quoteName('status') . ' = ' . $db->quote('temp') . ' WHERE ' . $db->quoteName('albumid') . '=' . $db->Quote($this->id);
     $db->setQuery($strSQL);
     $result = $db->query();
     // The whole local folder should be deleted, regardless of the storage type
     // BUT some old version of JomSocial might store other photo in the same
     // folder, we check in db first
     $strSQL = 'SELECT count(*) FROM ' . $db->quoteName('#__community_photos') . ' WHERE ' . $db->quoteName('image') . ' LIKE ' . $db->Quote('%' . dirname($this->path) . '%');
     $db->setQuery($strSQL);
     $result = $db->loadResult();
     if ($result == 0) {
         if (JFolder::exists(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id)) {
             JFolder::delete(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id);
         }
     }
     // We need to delete all activity stream related to this album
     CActivityStream::remove('photos', $this->id);
     //we need to delete all activity related to the photos inside the album as well
     if (isset($photos) && count($photos) > 0) {
         foreach ($photos as $photo) {
             CActivityStream::remove('photos', $photo->id);
         }
     }
     /* Delete album directory */
     $config = CFactory::getConfig();
     $dirPath = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/photos/' . $this->creator . '/' . $this->id;
     if (JFolder::exists($dirPath)) {
         JFolder::delete($dirPath);
     }
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $appsLib->triggerEvent('onAfterAlbumDelete', array($this));
     // @rule: remove from featured item if item is featured
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featured->delete($this->id);
     // if this is an avatar, we have to remove the avatar from the respective user
     if ($this->type == 'profile.avatar') {
         $user = CFactory::getUser($this->creator);
         $userModel = CFactory::getModel('User');
         $userModel->removeProfilePicture($user->id, 'avatar');
         $userModel->removeProfilePicture($user->id, 'thumb');
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('profile.avatar.upload', $user->id);
     } elseif ($this->type == 'event.avatar') {
         $eventTable = JTable::getInstance('Event', 'CTable');
         $eventTable->load($this->eventid);
         $eventTable->removeAvatar();
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('events.avatar.upload', $this->eventid);
     } elseif ($this->type == 'group.avatar') {
         $eventTable = JTable::getInstance('Group', 'CTable');
         $eventTable->load($this->groupid);
         $eventTable->removeAvatar();
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('groups.avatar.upload', $this->groupid);
     }
     //add user points
     CUserPoints::assignPoint('album.remove');
     // Remove from activity stream
     //CActivityStream::remove('photos', $this->id);
     // Remove from activity stream
     CActivityStream::remove('albums', $this->id);
     // Remove likes activity
     $likeModel = CFactory::getModel('like');
     $likeModel->removeLikes('album', $this->id);
     // Remove comment
     $wallModel = CFactory::getModel('wall');
     $wallModel->deletePostByType('albums', $this->id);
     return parent::delete();
 }
$categories = $model->getAllCategories();
$categoryIds = CCategoryHelper::getCategoryChilds($categories, $category->id);
if (!$eventType) {
    //upcoming events
    $result = $model->getEvents($categoryIds, $userid, $sorted, null, true, false, null, array('parent' => $eventparent), CEventHelper::ALL_TYPES, 0, $limit, $upcomingOnly, false);
} else {
    //my event
    if (!$userid) {
        //if no id is provided and this is user type, the result should be empty
        $result = array();
    } else {
        $result = $model->getEvents(null, $userid, $sorted);
    }
}
$events = array();
$featuredOnly = $params->get('filter_by', 0);
if ($featuredOnly) {
    //1 = featured only
    $featured = new CFeatured(FEATURED_EVENTS);
    $featuredEvents = $featured->getItemIds();
}
foreach ($result as $row) {
    if ($featuredOnly && !in_array($row->id, $featuredEvents)) {
        //if we only show featured item, and the item does not exists.
        continue;
    }
    $event = JTable::getInstance('Event', 'CTable');
    $event->bind($row);
    $events[] = $event;
}
require JModuleHelper::getLayoutPath('mod_community_events', $params->get('layout', 'default'));
Example #21
0
 public function _getGroupsHTML($tmpGroups, $tmpPagination = NULL)
 {
     $config = CFactory::getConfig();
     $tmpl = new CTemplate();
     CFactory::load('helpers', 'owner');
     CFactory::load('libraries', 'featured');
     $featured = new CFeatured(FEATURED_GROUPS);
     $featuredList = $featured->getItemIds();
     $groups = array();
     if ($tmpGroups) {
         foreach ($tmpGroups as $row) {
             $group =& JTable::getInstance('Group', 'CTable');
             $group->bind($row);
             $group->updateStats();
             //ensure that stats are up-to-date
             $group->description = CStringHelper::clean(CStringHelper::truncate($group->description, $config->get('tips_desc_length')));
             $groups[] = $group;
         }
         unset($tmpGroups);
     }
     $groupsHTML = $tmpl->set('showFeatured', $config->get('show_featured'))->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('groups', $groups)->set('pagination', $tmpPagination)->fetch('groups.list');
     unset($tmpl);
     return $groupsHTML;
 }
Example #22
0
 /**
  * Controller method to remove an album
  **/
 public function removealbum()
 {
     if ($this->blockUnregister()) {
         return;
     }
     // Check for request forgeries
     JRequest::checkToken() or jexit(JText::_('CC INVALID TOKEN'));
     // Get the album id.
     $my = CFactory::getUser();
     $id = JRequest::getInt('albumid', '');
     $task = JRequest::getCmd('currentTask', '');
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($id);
     if ($album->permanent == 1) {
         return;
     }
     /** HTGMOD **/
     $handler = $this->_getHandler($album);
     // Load libraries
     CFactory::load('models', 'photos');
     CFactory::load('libraries', 'activities');
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($id);
     CFactory::load('helpers', 'owner');
     if (!$handler->hasPermission($album->id)) {
         $this->blockUserAccess();
         return;
     }
     $model = CFactory::getModel('photos');
     CFactory::load('libraries', 'apps');
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] = $album;
     $url = $handler->getEditedAlbumURL($album->id);
     if ($album->delete()) {
         $appsLib->triggerEvent('onAfterAlbumDelete', $params);
         // @rule: remove from featured item if item is featured
         CFactory::load('libraries', 'featured');
         $featured = new CFeatured(FEATURED_ALBUMS);
         $featured->delete($album->id);
         //add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('album.remove');
         // Remove from activity stream
         CActivityStream::remove('photos', $id);
         $mainframe =& JFactory::getApplication();
         $task = !empty($task) ? '&task=' . $task : '';
         $message = JText::sprintf('CC ALBUM REMOVED', $album->name);
         $mainframe->redirect($url, $message);
     }
 }
Example #23
0
 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::_('CC MY PHOTOS');
         } else {
             $title = JText::sprintf('CC USERS PHOTO TITLE', $user->getDisplayName());
         }
     } else {
         $title = JText::_('CC ALL PHOTOS TITLE');
     }
     if (!empty($groupId)) {
         $title = JText::_('CC 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::_('CC 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 = JString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
         $document->addItem($item);
     }
     $content = $document->render();
 }
Example #24
0
 private function _getAdminControlHTML($userid)
 {
     $adminControlHTML = '';
     if (COwnerHelper::isCommunityAdmin()) {
         $user = CFactory::getUser($userid);
         $params = $user->getParams();
         $videoid = $params->get('profileVideo', 0);
         $tmpl = new CTemplate();
         $tmpl->set('userid', $userid);
         $isDefaultPhoto = $user->getThumbAvatar() == rtrim(JURI::root(), '/') . '/components/com_community/assets/default_thumb.jpg' ? true : false;
         CFactory::load('libraries', 'featured');
         $featured = new CFeatured(FEATURED_USERS);
         $isFeatured = $featured->isFeatured($user->id);
         $jConfig = JFactory::getConfig();
         $tmpl->set('videoid', $videoid);
         $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin($user->id));
         $tmpl->set('blocked', $user->isBlocked());
         $tmpl->set('isFeatured', $isFeatured);
         $tmpl->set('isDefaultPhoto', $isDefaultPhoto);
         $tmpl->set('jConfig', $jConfig);
         $adminControlHTML = $tmpl->fetch('admin.controls');
     }
     return $adminControlHTML;
 }
Example #25
0
 public function ajaxAddFeatured($albumId)
 {
     $filter = JFilterInput::getInstance();
     $albumId = $filter->clean($albumId, 'int');
     $json = array();
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_ALBUMS, $albumId)) {
             $featured = new CFeatured(FEATURED_ALBUMS);
             $table = JTable::getInstance('Album', 'CTable');
             $table->load($albumId);
             $config = CFactory::getConfig();
             $limit = $config->get('featured' . FEATURED_ALBUMS . 'limit', 10);
             if ($featured->add($albumId, $my->id) === true) {
                 $json['success'] = true;
                 $json['html'] = JText::sprintf('COM_COMMUNITY_ALBUM_IS_FEATURED', $table->name);
             } else {
                 $json['error'] = JText::sprintf('COM_COMMUNITY_ALBUM_LIMIT_REACHED_FEATURED', $table->name, $limit);
             }
         } else {
             $json['error'] = JText::_('COM_COMMUNITY_PHOTOS_ALBUM_ALREADY_FEATURED');
         }
     } else {
         $json['error'] = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     die(json_encode($json));
 }
Example #26
0
 public function ajaxRemoveFeatured($eventId)
 {
     $filter = JFilterInput::getInstance();
     $eventId = $filter->clean($eventId, 'int');
     $objResponse = new JAXResponse();
     CFactory::load('helpers', 'owner');
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         CFactory::load('libraries', 'featured');
         $featured = new CFeatured(FEATURED_EVENTS);
         $my = CFactory::getUser();
         if ($featured->delete($eventId)) {
             $html = JText::_('COM_COMMUNITY_EVENT_REMOVED_FROM_FEATURED');
         } else {
             $html = JText::_('COM_COMMUNITY_REMOVING_EVENT_FROM_FEATURED_ERROR');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     $buttons = '<input type="button" class="button" onclick="window.location.reload();" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '"/>';
     $objResponse->addScriptCall('cWindowAddContent', $html, $buttons);
     //ClearCache in Featured List
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_GROUPS));
     return $objResponse->sendResponse();
 }
Example #27
0
 /**
  * //@todo Use usort to sort the data when PHP 5.3 is the minimal requirement
  * Sort album key based on the key data comparison given
  * @param $albums
  * @param string $sort
  * @return array
  */
 private function sortAlbums($albums, $sort = 'date')
 {
     $data = array();
     foreach ($albums as $row) {
         $album = JTable::getInstance('Album', 'CTable');
         $album->bind($row);
         $album->thumbnail = $album->getCoverThumbPath();
         $lastupdated = new DateTime($album->lastupdated);
         //sorting happens here
         switch ($sort) {
             case 'hit':
                 //$key = $this->getNextUniqueAlbumKey($album->hits,$data);
                 $data[] = $album;
                 break;
             case 'name':
                 if (array_key_exists($album->name, $data)) {
                     $data[strtolower($album->name) . (strtotime("now") + rand('1', '100000'))] = $album;
                 } else {
                     $data[strtolower($album->name) . strtotime("now")] = $album;
                 }
                 break;
             case 'featured_only':
                 $featured = new CFeatured(FEATURED_ALBUMS);
                 $featuredAlbums = $featured->getItemIds();
                 foreach ($featuredAlbums as $featuredAlbum) {
                     if ($album->id == $featuredAlbum) {
                         $data[] = $album;
                     }
                 }
                 break;
             case 'featured':
                 $data[] = $album;
                 break;
                 /* removed in 4.0
                    very heavy to filter
                    case 'like' :
                        $like = new CLike();
                        $totalLikes = $like->getLikeCount('album', $album->id);
                        $key = $this->getNextUniqueAlbumKey($totalLikes,$data);
                        $data[$key] = $album;
                        break;
                    case 'comment';
                        $totalComments = CWallLibrary::getWallCount('albums',$album->id);
                        $key = $this->getNextUniqueAlbumKey($totalComments,$data);
                        $data[$key] = $album;
                        break;
                    */
             /* removed in 4.0
                very heavy to filter
                case 'like' :
                    $like = new CLike();
                    $totalLikes = $like->getLikeCount('album', $album->id);
                    $key = $this->getNextUniqueAlbumKey($totalLikes,$data);
                    $data[$key] = $album;
                    break;
                case 'comment';
                    $totalComments = CWallLibrary::getWallCount('albums',$album->id);
                    $key = $this->getNextUniqueAlbumKey($totalComments,$data);
                    $data[$key] = $album;
                    break;
                */
             default:
                 //date
                 $key = $this->getNextUniqueAlbumKey($lastupdated->format('U'), $data);
                 $data[$key] = $album;
         }
     }
     //sort by the key
     if ($sort != 'featured') {
         krsort($data);
     }
     if ($sort == 'name' || $sort == 'hit') {
         $data = array_reverse($data);
     }
     return $data;
 }
Example #28
0
 public function _getAlbumsHTML($albums, $type = PHOTOS_USER_TYPE, $pagination = NULL)
 {
     $my = CFactory::getUser();
     $groupId = JRequest::getVar('groupid', '', 'REQUEST');
     $tmpl = new CTemplate();
     CFactory::load('libraries', 'activities');
     CFactory::load('models', 'groups');
     CFactory::load('helpers', 'owner');
     $handler = $this->_getHandler();
     $photoTag = CFactory::getModel('phototagging');
     $photos = array();
     foreach ($albums as &$album) {
         $album->user = CFactory::getUser($album->creator);
         $album->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$album->id}&userid={$album->creator}");
         $album->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$album->id}&userid={$album->creator}&referrer=myphotos");
         $album->uploadLink = "javascript:joms.notifications.showUploadPhoto({$album->id});";
         //CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$album->id}&userid={$album->creator}");
         $album->isOwner = $my->id == $album->creator;
         // Get all photos from album
         $photos[$album->id] = $handler->getAlbumPhotos($album->id);
         $photoCount = count($photos[$album->id]);
         $tagRecords[$album->id] = array();
         // get tag users from photos
         if ($photoCount > 0) {
             for ($i = 0; $i < $photoCount; $i++) {
                 $tempTagRecords = $photoTag->getTaggedList($photos[$album->id][$i]->id);
                 if (count($tempTagRecords) > 0) {
                     $tagRecords[$album->id][] = $tempTagRecords;
                 }
             }
         }
         if ($type == PHOTOS_GROUP_TYPE) {
             $album->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$album->id}&groupid={$album->groupid}");
             $album->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$album->id}&groupid={$album->groupid}&referrer=myphotos");
             $album->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$album->id}&groupid={$album->groupid}");
             $albums[$i]->isOwner = $my->authorise('community.view', 'photos.group.album.' . $groupId, $albums[$i]);
         }
         // If new albums that has just been created and
         // does not contain any images, the lastupdated will always be 0000-00-00 00:00:00:00
         // Try to use the albums creation date instead.
         if ($album->lastupdated == '0000-00-00 00:00:00' || $album->lastupdated == '') {
             $album->lastupdated = $album->created;
             if ($album->lastupdated == '' || $album->lastupdated == '0000-00-00 00:00:00') {
                 $album->lastupdated = JText::_('COM_COMMUNITY_PHOTOS_NO_ACTIVITY');
             } else {
                 $lastUpdated = new JDate($album->lastupdated);
                 $album->lastupdated = CActivityStream::_createdLapse($lastUpdated, false);
             }
         } else {
             $lastUpdated = new JDate($album->lastupdated);
             $album->lastupdated = CActivityStream::_createdLapse($lastUpdated, false);
         }
     }
     CFactory::load('helpers', 'owner');
     $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id);
     if ($type == PHOTOS_GROUP_TYPE) {
         $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId);
         CFactory::load('helpers', 'group');
         $isOwner = CGroupHelper::allowManagePhoto($groupId);
     } else {
         $userId = JRequest::getInt('userid', '', 'REQUEST');
         $user = CFactory::getUser($userId);
         $isOwner = $my->id == $user->id ? true : false;
     }
     CFactory::load('libraries', 'featured');
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featuredList = $featured->getItemIds();
     $task = JRequest::getCmd('task', '');
     return $tmpl->set('isMember', $my->id != 0)->set('isOwner', $isOwner)->set('type', $type)->set('createLink', $createLink)->set('currentTask', $task)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('my', $my)->set('albums', $albums)->set('pagination', $pagination)->set('isSuperAdmin', COwnerHelper::isCommunityAdmin())->set('featuredList', $featuredList)->fetch('albums.list');
 }
Example #29
0
 public function _getAlbumsHTML($albums, $type = PHOTOS_USER_TYPE, $pagination = NULL)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $my = CFactory::getUser();
     $groupId = $jinput->request->get('groupid', '', 'INT');
     //JRequest::getVar( 'groupid' , '' ,'REQUEST');
     $tmpl = new CTemplate();
     $handler = $this->_getHandler();
     $photoTag = CFactory::getModel('phototagging');
     $photos = array();
     foreach ($albums as &$album) {
         $album->user = CFactory::getUser($album->creator);
         $album->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$album->id}&userid={$album->creator}");
         $album->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$album->id}&userid={$album->creator}&referrer=myphotos");
         $album->uploadLink = "javascript:joms.notifications.showUploadPhoto({$album->id});";
         //CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$album->id}&userid={$album->creator}");
         $album->isOwner = $my->id == $album->creator;
         // Get all photos from album
         $photos[$album->id] = $handler->getAlbumPhotos($album->id);
         $photoCount = count($photos[$album->id]);
         if ($type == PHOTOS_GROUP_TYPE) {
             $album->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$album->id}&groupid={$album->groupid}");
             $album->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$album->id}&groupid={$album->groupid}&referrer=myphotos");
             $album->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$album->id}&groupid={$album->groupid}");
             $albums[$i]->isOwner = $my->authorise('community.view', 'photos.group.album.' . $groupId, $albums[$i]);
         }
     }
     $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id);
     if ($type == PHOTOS_GROUP_TYPE) {
         $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId);
         $baselink = "index.php?option=com_community&view=photos&task=display&groupid=" . $groupId;
         $isOwner = CGroupHelper::allowManagePhoto($groupId);
     } else {
         $userId = JRequest::getInt('userid', '', 'REQUEST');
         $baselink = "index.php?option=com_community&view=photos&task=myphotos&userid=" . $userId;
         $user = CFactory::getUser($userId);
         $isOwner = $my->id == $user->id ? true : false;
     }
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featuredList = $featured->getItemIds();
     $config = CFactory::getConfig();
     $task = JRequest::getCmd('task', '');
     return $tmpl->set('isMember', $my->id != 0)->set('isOwner', $isOwner)->set('type', $type)->set('baseLink', $baselink)->set('createLink', $createLink)->set('currentTask', $task)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('my', $my)->set('albums', $albums)->set('pagination', $pagination)->set('isSuperAdmin', COwnerHelper::isCommunityAdmin())->set('featuredList', $featuredList)->set('showFeatured', $config->get('show_featured'))->set('groupId', $groupId)->set('config', $config)->fetch('album/list');
 }
Example #30
0
 public function _getEventsFeaturedList()
 {
     //CFactory::load( 'libraries' , 'featured' );
     $featured = new CFeatured(FEATURED_EVENTS);
     $featuredEvents = $featured->getItemIds();
     $featuredList = array();
     $now = new JDate();
     foreach ($featuredEvents as $event) {
         $table = JTable::getInstance('Event', 'CTable');
         $table->load($event);
         $expiry = new JDate($table->enddate);
         if ($expiry->toUnix() >= $now->toUnix()) {
             if ($table->id != '') {
                 $featuredList[] = $table;
             }
         }
     }
     if (!empty($featuredList)) {
         foreach ($featuredList as $key => $row) {
             $orderByDate[$key] = strtotime($row->startdate);
         }
         array_multisort($orderByDate, SORT_ASC, $featuredList);
     }
     return $featuredList;
 }