예제 #1
0
 /**
  * remove friend
  */
 public function removeFriend($friendid)
 {
     $mainframe =& JFactory::getApplication();
     $model = CFactory::getModel('friends');
     $my = CFactory::getUser();
     $viewName = JRequest::getVar('view', '', 'GET');
     $view = CFactory::getView($viewName);
     if ($model->deleteFriend($my->id, $friendid)) {
         // Substract the friend count
         $model->updateFriendCount($my->id);
         $model->updateFriendCount($friendid);
         //add user points
         // we deduct poinst to both parties
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('friends.remove');
         CUserPoints::assignPoint('friends.remove', $friendid);
         $friend = CFactory::getUser($friendId);
         $view->addInfo(JText::sprintf('COM_COMMUNITY_FRIENDS_REMOVED', $friend->getDisplayName()));
         //@todo notify friend after remove them from our friend list
         //trigger for onFriendRemove
         $eventObject = new stdClass();
         $eventObject->profileOwnerId = $my->id;
         $eventObject->friendId = $friendid;
         $this->_triggerFriendEvents('onFriendRemove', $eventObject);
         unset($eventObject);
     } else {
         $view->addinfo(JText::_('COM_COMMUNITY_FRIENDS_REMOVING_FRIEND_ERROR'));
     }
 }
예제 #2
0
 public function view($type = null)
 {
     if ($type == null) {
         return $this->_internalView;
     } else {
         $view = CFactory::getView($type);
         return $view;
     }
 }
예제 #3
0
 public function browse($data = null)
 {
     //require_once (JPATH_COMPONENT . '/libraries/template.php');
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $this->addPathway(JText::_('COM_COMMUNITY_GROUPS_MEMBERS'), '');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_GROUPS_MEMBERS'));
     $my = CFactory::getUser();
     $view = CFactory::getView('search');
     $searchModel = CFactory::getModel('search');
     $userModel = CFactory::getModel('user');
     $avatar = CFactory::getModel('avatar');
     $friends = CFactory::getModel('friends');
     $tmpl = new CTemplate();
     $sorted = $jinput->get->get('sort', 'latest', 'STRING');
     //JRequest::getVar( 'sort' , 'latest' , 'GET' );
     $filter = JRequest::getWord('filter', 'all', 'GET');
     $profiletype = $jinput->get('profiletype', 0, 'INT');
     $rows = $searchModel->getPeople($sorted, $filter, $profiletype);
     $sortItems = array('online' => JText::_('COM_COMMUNITY_SORT_ONLINE'), 'latest' => JText::_('COM_COMMUNITY_SORT_LATEST'), 'alphabetical' => JText::_('COM_COMMUNITY_SORT_ALPHABETICAL'));
     $filterItems = array();
     $config = CFactory::getConfig();
     if ($config->get('alphabetfiltering')) {
         $filterItems = array('all' => JText::_('COM_COMMUNITY_JUMP_ALL'), 'abc' => JText::_('COM_COMMUNITY_JUMP_ABC'), 'def' => JText::_('COM_COMMUNITY_JUMP_DEF'), 'ghi' => JText::_('COM_COMMUNITY_JUMP_GHI'), 'jkl' => JText::_('COM_COMMUNITY_JUMP_JKL'), 'mno' => JText::_('COM_COMMUNITY_JUMP_MNO'), 'pqr' => JText::_('COM_COMMUNITY_JUMP_PQR'), 'stu' => JText::_('COM_COMMUNITY_JUMP_STU'), 'vwx' => JText::_('COM_COMMUNITY_JUMP_VWX'), 'yz' => JText::_('COM_COMMUNITY_JUMP_YZ'), 'others' => JText::_('COM_COMMUNITY_JUMP_OTHERS'));
     }
     $html = '';
     $totalUser = $userModel->getMembersCount();
     $resultRows = array();
     $alreadyfriend = array();
     // No need to pre-load multiple users at once since $searchModel->getPeople
     // already did
     for ($i = 0; $i < count($rows); $i++) {
         $row = $rows[$i];
         $obj = clone $row;
         $user = CFactory::getUser($row->id);
         $obj->friendsCount = $user->getFriendCount();
         $obj->user = $user;
         $obj->profileLink = CUrl::build('profile', '', array('userid' => $row->id));
         $isFriend = CFriendsHelper::isConnected($row->id, $my->id);
         $connection = $friends->getFriendConnection($my->id, $row->id);
         $obj->isMyFriend = false;
         if (!empty($connection)) {
             if ($connection[0]->connect_from == $my->id) {
                 $obj->isMyFriend = true;
             }
         }
         $obj->addFriend = !$isFriend && $my->id != $row->id ? true : false;
         if ($obj->addFriend) {
             $alreadyfriend[$row->id] = $row->id;
         }
         $resultRows[] = $obj;
     }
     $featuredList = $this->_cachedCall('getFeaturedMember', array(), '', array(COMMUNITY_CACHE_TAG_FEATURED));
     $config = CFactory::getConfig();
     if ($config->get('alphabetfiltering')) {
         $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest');
         $alphabetHTML = CFilterBar::getHTML(CRoute::getURI(), '', '', $filterItems, 'all');
     } else {
         $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest');
     }
     $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=browse&filter=' . $filter . '&sort=' . $sorted), '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=browse&filter=' . $filter . '&sort=' . $sorted . '&profiletype=' . $profile->id), 'name' => $profile->name, 'selected' => $profile->id == $profiletype ? 1 : 0);
             }
         }
     }
     echo $tmpl->set('featuredList', $featuredList)->set('hasMultiprofile', $hasMultiprofile)->set('multiprofileArr', $multiprofileArr)->set('alreadyfriend', $alreadyfriend)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('data', $resultRows)->set('sortings', $sortingsHTML)->set('alphabet', $alphabetHTML)->set('my', $my)->set('submenu', $this->showSubmenu(false))->set('totalUser', $totalUser)->set('showFeaturedList', $config->get('show_featured'))->set('pagination', $searchModel->getPagination())->fetch('people.browse');
 }
예제 #4
0
파일: groups.php 프로젝트: Jougito/DynWeb
 public static function groupsAvatarUpload($userId, $groupId, $group)
 {
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $viewName = JRequest::getCmd('view');
     $view = CFactory::getView($viewName, '', $viewType);
     if ($userId == 0) {
         CAccess::setError('blockUnregister');
         return false;
     } else {
         if (!$group->isAdmin($userId) && !COwnerHelper::isCommunityAdmin()) {
             CAccess::setError($view->noAccess());
             return false;
         } else {
             return true;
         }
     }
 }
예제 #5
0
 /**
  * Return the view object, which will output the final html. The view object
  * is a singleton
  * 	 	 
  * @param	string		view name
  * #param	string		view class prefix, optional	 
  * @param	string		document type, html/pdf/etc/
  * @return	object		the view object	 
  */
 public function getView($viewName = 'frontpage', $prefix = '', $viewType = '')
 {
     return CFactory::getView($viewName, $prefix, $viewType);
 }
예제 #6
0
 public function ajaxBrowse($position = 'content')
 {
     $filter = JFilterInput::getInstance();
     $position = $filter->clean($position, 'string');
     // Get the proper views and models
     $view = CFactory::getView('apps');
     $appsModel = CFactory::getModel('apps');
     $my = CFactory::getUser();
     $data = new stdClass();
     // Check permissions
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     // Get the application listing
     $apps = $appsModel->getAvailableApps(false);
     $realApps = array();
     for ($i = 0; $i < count($apps); $i++) {
         $app = $apps[$i];
         // Hide wall apps
         if (!$appsModel->isAppUsed($my->id, $app->name) && $app->coreapp != '1' && $app->name != 'walls') {
             $app->position = $position;
             $realApps[] = $app;
         }
     }
     $data->applications = $realApps;
     $html = $view->get('ajaxBrowse', $data);
     $json = array('title' => JText::_('COM_COMMUNITY_APPS_BROWSE'), 'html' => $html);
     die(json_encode($json));
 }
예제 #7
0
 public function ajaxBrowse($position = 'content')
 {
     $filter = JFilterInput::getInstance();
     $position = $filter->clean($position, 'string');
     // Get the proper views and models
     $view = CFactory::getView('apps');
     $appsModel = CFactory::getModel('apps');
     $my = CFactory::getUser();
     $data = new stdClass();
     // Check permissions
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     // Get the application listing
     $apps = $appsModel->getAvailableApps(false);
     $realApps = array();
     for ($i = 0; $i < count($apps); $i++) {
         $app =& $apps[$i];
         // Hide wall apps
         if (!$appsModel->isAppUsed($my->id, $app->name) && $app->coreapp != '1' && $app->name != 'walls') {
             $app->position = $position;
             $realApps[] = $app;
         }
     }
     $data->applications = $realApps;
     $objResponse = new JAXResponse();
     $html = $view->get('ajaxBrowse', $data);
     $objResponse->addAssign("cwin_logo", 'innerHTML', JText::_('COM_COMMUNITY_APPS_BROWSE'));
     $objResponse->addScriptCall('cWindowAddContent', $html);
     return $objResponse->sendResponse();
 }
예제 #8
0
 public function showFeaturedGroups($total = 5)
 {
     $tmpl = new CTemplate();
     $config = CFactory::getConfig();
     $showlatestgroups = intval($tmpl->params->get('showlatestgroups'));
     $html = '';
     $data = array();
     if ($showlatestgroups != 0) {
         $groupModel = CFactory::getModel('groups');
         $tmpGroups = $groupModel->getAllGroups(null, null, null, $total);
         $groups = array();
         $data = array();
         $groupView = CFactory::getView('groups');
         $groups = $groupView->getGroupsFeaturedList();
         $tmpl = new CTemplate();
         $html = $tmpl->setRef('groups', $groups)->fetch('frontpage.latestgroup');
     }
     $data['HTML'] = $html;
     return $data;
 }
예제 #9
0
 /**
  * Show the user invite window
  */
 public function invite()
 {
     $view = CFactory::getView('friends');
     $validated = false;
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     if (JRequest::getVar('action', '', 'POST') == 'invite') {
         $mainframe =& JFactory::getApplication();
         CFactory::load('libraries', 'apps');
         $appsLib =& CAppPlugins::getInstance();
         $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-friends-invite'));
         if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
             $validated = true;
             $emailExistError = array();
             $emailInvalidError = array();
             $emails = JRequest::getVar('emails', '', 'POST');
             if (empty($emails)) {
                 $validated = false;
                 $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_FRIENDS_EMAIL_CANNOT_BE_EMPTY'), 'error');
             } else {
                 $emails = explode(',', $emails);
                 $userModel = CFactory::getModel('user');
                 // Do simple email validation
                 // make sure user is not a member yet
                 // check for duplicate emails
                 // make sure email is valid
                 // make sure user is not already on the system
                 CFactory::load('helpers', 'validate');
                 $actualEmails = array();
                 for ($i = 0; $i < count($emails); $i++) {
                     //trim the value
                     $emails[$i] = JString::trim($emails[$i]);
                     if (!empty($emails[$i]) && (bool) CValidateHelper::email($emails[$i])) {
                         //now if the email already exist in system, alert the user.
                         if (!$userModel->userExistsbyEmail($emails[$i])) {
                             $actualEmails[$emails[$i]] = true;
                         } else {
                             $emailExistError[] = $emails[$i];
                         }
                     } else {
                         // log the error and display to user.
                         if (!empty($emails[$i])) {
                             $emailInvalidError[] = $emails[$i];
                         }
                     }
                 }
                 $emails = array_keys($actualEmails);
                 unset($actualEmails);
                 if (count($emails) <= 0) {
                     $validated = false;
                 }
                 if (count($emailInvalidError) > 0) {
                     for ($i = 0; $i < count($emailInvalidError); $i++) {
                         $mainframe->enqueueMessage(JText::sprintf('COM_COMMUNITY_INVITE_EMAIL_INVALID', $emailInvalidError[$i]), 'error');
                     }
                     $validated = false;
                 }
                 if (count($emailExistError) > 0) {
                     for ($i = 0; $i < count($emailExistError); $i++) {
                         $mainframe->enqueueMessage(JText::sprintf('COM_COMMUNITY_INVITE_EMAIL_EXIST', $emailExistError[$i]), 'error');
                     }
                     $validated = false;
                 }
             }
             $message = JRequest::getVar('message', '', 'POST');
             $config = CFactory::getConfig();
             if ($validated) {
                 CFactory::load('libraries', 'notification');
                 for ($i = 0; $i < count($emails); $i++) {
                     $emails[$i] = JString::trim($emails[$i]);
                     $params = new CParameter('');
                     $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $my->id . '&invite=' . $my->id);
                     $params->set('message', $message);
                     CNotificationLibrary::add('etype_friends_invite_users', $my->id, $emails[$i], JText::sprintf('COM_COMMUNITY_INVITE_EMAIL_SUBJECT', $my->getDisplayName(), $config->get('sitename')), '', 'friends.invite', $params);
                 }
                 $mainframe->enqueueMessage(JText::sprintf(CStringHelper::isPlural(count($emails)) ? 'COM_COMMUNITY_INVITE_EMAIL_SENT_MANY' : 'COM_COMMUNITY_INVITE_EMAIL_SENT', count($emails)));
                 //add user points - friends.invite removed @ 20090313
                 //clear the post value.
                 JRequest::setVar('emails', '');
                 JRequest::setVar('message', '');
             } else {
                 // Display error message
             }
         }
     }
     echo $view->get('invite');
 }
예제 #10
0
파일: profile.php 프로젝트: bizanto/Hooked
 /**
  * Allow user to set their privacy setting.
  * User privacy setting is actually just part of their params	 
  */
 public function privacy()
 {
     CFactory::setActiveProfile();
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     if (JRequest::getVar('action', '', 'POST') != '') {
         CFactory::load('libraries', 'apps');
         $appsLib =& CAppPlugins::getInstance();
         $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-profile-privacy'));
         if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
             $params =& $my->getParams();
             $postvars = JRequest::get('POST');
             $previousProfilePermission = $my->get('privacyProfileView');
             foreach ($postvars as $key => $val) {
                 $params->set($key, $val);
             }
             $my->save('params');
             //add user points
             CFactory::load('libraries', 'userpoints');
             CUserPoints::assignPoint('profile.privacy.update');
             //Update all photos and album permission
             $photoPermission = JRequest::getVar('privacyPhotoView', 0, 'POST');
             $photoModel = CFactory::getModel('photos');
             $photoModel->updatePermission($my->id, $photoPermission);
             //update all profile related activity streams.
             $profilePermission = JRequest::getVar('privacyProfileView', 0, 'POST');
             $activityModel = CFactory::getModel('activities');
             $activityModel->updatePermission($profilePermission, $previousProfilePermission, $my->id);
             $mainframe =& JFactory::getApplication();
             $mainframe->enqueueMessage(JText::_('CC PRIVACY SETTINGS SAVED'));
         }
     }
     $view = CFactory::getView('profile');
     echo $view->get('privacy');
 }
예제 #11
0
 /**
  * Allow user to set their privacy setting.
  * User privacy setting is actually just part of their params	 
  */
 public function privacy()
 {
     CFactory::setActiveProfile();
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     if (JRequest::getVar('action', '', 'POST') != '') {
         CFactory::load('libraries', 'apps');
         $appsLib =& CAppPlugins::getInstance();
         $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-profile-privacy'));
         if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
             $params =& $my->getParams();
             $postvars = JRequest::get('POST');
             $searchMail = JRequest::getVar('search_email');
             $my->_search_email = $searchMail;
             $previousProfilePermission = $my->get('privacyProfileView');
             $activityModel = CFactory::getModel('activities');
             if (isset($postvars['resetPrivacyPhotoView'])) {
                 //Update all photos and album permission
                 $photoPermission = JRequest::getVar('privacyPhotoView', 0, 'POST');
                 $photoModel = CFactory::getModel('photos');
                 $photoModel->updatePermission($my->id, $photoPermission);
                 // Update all photos activity stream permission
                 $activityModel->updatePermission($photoPermission, null, $my->id, 'photos');
                 unset($postvars['resetPrivacyPhotoView']);
             }
             if (isset($postvars['resetPrivacyVideoView'])) {
                 //Update all videos permission
                 $videoPermission = JRequest::getVar('privacyVideoView', 0, 'POST');
                 $videoModel = CFactory::getModel('videos');
                 $videoModel->updatePermission($my->id, $videoPermission);
                 // Update all videos activity stream permission
                 $activityModel->updatePermission($videoPermission, null, $my->id, 'videos');
                 unset($postvars['resetPrivacyVideoView']);
             }
             foreach ($postvars as $key => $val) {
                 $params->set($key, $val);
             }
             $my->save('params');
             //add user points
             CFactory::load('libraries', 'userpoints');
             CUserPoints::assignPoint('profile.privacy.update');
             //fix, we do not reset old privacy setting of old activities
             //update all profile related activity streams.
             //$profilePermission = JRequest::getVar('privacyProfileView', 0, 'POST');
             //$activityModel->updatePermission($profilePermission, $previousProfilePermission , $my->id, 'profile' );
             $post['sendEmail'] = JRequest::getVar('notifyEmailSystem');
             $jUser =& JFactory::getUser($my->id);
             $jUser->sendEmail = $post['sendEmail'];
             if (!$jUser->save()) {
                 $msg = $jUser->getError();
                 $msg = stripslashes($msg);
                 $mainframe->redirect(CRoute::_('index.php?option=com_community&view=profile&task=privacy', false), $msg, 'error');
             }
             $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_ACTIVITIES, COMMUNITY_CACHE_TAG_MEMBERS, COMMUNITY_CACHE_TAG_FRONTPAGE));
             $mainframe =& JFactory::getApplication();
             $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PRIVACY_SETTINGS_SAVED'));
         }
     }
     $view = CFactory::getView('profile');
     echo $view->get('privacy');
 }
예제 #12
0
 function browse($data = null)
 {
     require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'template.php';
     $mainframe =& JFactory::getApplication();
     $document =& JFactory::getDocument();
     // Load required filterbar library that will be used to display the filtering and sorting.
     CFactory::load('libraries', 'filterbar');
     $this->addPathway(JText::_('CC MEMBERS'), '');
     $document->setTitle(JText::_('CC MEMBERS'));
     CFactory::load('helpers', 'friends');
     CFactory::load('libraries', 'template');
     CFactory::load('libraries', 'tooltip');
     CFactory::load('helpers', 'owner');
     CFactory::load('libraries', 'featured');
     $my = CFactory::getUser();
     $view = CFactory::getView('search');
     $searchModel = CFactory::getModel('search');
     $userModel = CFactory::getModel('user');
     $avatar = CFactory::getModel('avatar');
     $friends = CFactory::getModel('friends');
     $tmpl = new CTemplate();
     $sorted = JRequest::getVar('sort', 'latest', 'GET');
     $filter = JRequest::getWord('filter', 'all', 'GET');
     $rows = $searchModel->getPeople($sorted, $filter);
     $sortItems = array('latest' => JText::_('CC SORT LATEST'), 'online' => JText::_('CC SORT ONLINE'), 'alphabetical' => JText::_('CC SORT ALPHABETICAL'));
     $filterItems = array();
     $config = CFactory::getConfig();
     if ($config->get('alphabetfiltering')) {
         $filterItems = array('all' => JText::_('CC ALL'), 'abc' => JText::_('CC ABC'), 'def' => JText::_('CC DEF'), 'ghi' => JText::_('CC GHI'), 'jkl' => JText::_('CC JKL'), 'mno' => JText::_('CC MNO'), 'pqr' => JText::_('CC PQR'), 'stu' => JText::_('CC STU'), 'vwx' => JText::_('CC VWX'), 'yz' => JText::_('CC YZ'), 'others' => JText::_('CC OTHERS'));
     }
     $html = '';
     $totalUser = $userModel->getMembersCount();
     $resultRows = array();
     // No need to pre-load multiple users at once since $searchModel->getPeople
     // already did
     for ($i = 0; $i < count($rows); $i++) {
         $row =& $rows[$i];
         $obj = clone $row;
         $user = CFactory::getUser($row->id);
         $obj->friendsCount = $user->getFriendCount();
         $obj->user = $user;
         $obj->profileLink = CUrl::build('profile', '', array('userid' => $row->id));
         $isFriend = CFriendsHelper::isConnected($row->id, $my->id);
         $obj->addFriend = !$isFriend && $my->id != $row->id ? true : false;
         $resultRows[] = $obj;
     }
     $featured = new CFeatured(FEATURED_USERS);
     $featuredList = $featured->getItemIds();
     $config = CFactory::getConfig();
     if ($config->get('alphabetfiltering')) {
         $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest', $filterItems, 'all');
     } else {
         $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest');
     }
     $tmpl->set('featuredList', $featuredList);
     $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin());
     $tmpl->set('featuredList', $featuredList);
     $tmpl->set('data', $resultRows);
     $tmpl->set('sortings', $sortingsHTML);
     $tmpl->set('my', $my);
     $tmpl->set('totalUser', $totalUser);
     $tmpl->set('showFeaturedList', true);
     $tmpl->set('pagination', $searchModel->getPagination());
     echo $tmpl->fetch('people.browse');
 }