本文整理汇总了PHP中COwnerHelper::isMine方法的典型用法代码示例。如果您正苦于以下问题:PHP COwnerHelper::isMine方法的具体用法?PHP COwnerHelper::isMine怎么用?PHP COwnerHelper::isMine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COwnerHelper
的用法示例。
在下文中一共展示了COwnerHelper::isMine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAccessLevel
public static function getAccessLevel($actorId, $targetId)
{
$actor = CFactory::getUser($actorId);
$target = CFactory::getUser($targetId);
CFactory::load('helpers', 'owner');
CFactory::load('helpers', 'friends');
// public guest
$access = 0;
// site members
if ($actor->id > 0) {
$access = 20;
}
// they are friends
if ($target->id > 0 && CFriendsHelper::isConnected($actor->id, $target->id)) {
$access = 30;
}
// mine, target and actor is the same person
if ($target->id > 0 && COwnerHelper::isMine($actor->id, $target->id)) {
$access = 40;
}
if (COwnerHelper::isCommunityAdmin()) {
$access = 40;
}
return $access;
}
示例2: isAccessAllowed
/**
* Return true if actor have access to target's item
* @param type where the privacy setting should be extracted, {user, group, global, custom}
* Site super admin waill always have access to all area
*/
static function isAccessAllowed($actorId, $targetId, $type, $userPrivacyParam)
{
$actor = CFactory::getUser($actorId);
$target = CFactory::getUser($targetId);
CFactory::load('helpers', 'owner');
CFactory::load('helpers', 'friends');
// Load User params
$params =& $target->getParams();
// guest
$relation = 10;
// site members
if ($actor->id != 0) {
$relation = 20;
}
// friends
if (CFriendsHelper::isConnected($actorId, $targetId)) {
$relation = 30;
}
// mine, target and actor is the same person
if (COwnerHelper::isMine($actor->id, $target->id)) {
$relation = 40;
}
// @todo: respect privacy settings
// If type is 'custom', then $userPrivacyParam will contain the exact
// permission level
$permissionLevel = $type == 'custom' ? $userPrivacyParam : $params->get($userPrivacyParam);
if ($relation < $permissionLevel && !COwnerHelper::isCommunityAdmin($actorId)) {
return false;
}
return true;
}
示例3: showMiniHeader
function showMiniHeader($userId)
{
CMiniHeader::load();
CFactory::load('helpers', 'friends');
CFactory::load('helpers', 'owner');
$option = JRequest::getVar('option', '', 'REQUEST');
$lang =& JFactory::getLanguage();
$lang->load('com_community');
$my = CFactory::getUser();
$config = CFactory::getConfig();
if (!empty($userId)) {
$user = CFactory::getUser($userId);
CFactory::load('libraries', 'messaging');
$sendMsg = CMessaging::getPopup($user->id);
$tmpl = new CTemplate();
$tmpl->set('my', $my);
$tmpl->set('user', $user);
$tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id));
$tmpl->set('sendMsg', $sendMsg);
$tmpl->set('config', $config);
$tmpl->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id);
$showMiniHeader = $option == 'com_community' ? $tmpl->fetch('profile.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('profile.miniheader') . '</div>';
return $showMiniHeader;
}
}
示例4: addDefaultStatusCreator
/**
* Add default items for status box
*/
static function addDefaultStatusCreator(&$status)
{
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$my = CFactory::getUser();
$userid = $jinput->get('userid', $my->id, 'INT');
//JRequest::getVar('userid', $my->id);
$user = CFactory::getUser($userid);
$config = CFactory::getConfig();
$template = new CTemplate();
$isMine = COwnerHelper::isMine($my->id, $user->id);
/* Message creator */
$creator = new CUserStatusCreator('message');
$creator->title = JText::_('COM_COMMUNITY_STATUS');
$creator->html = $template->fetch('status.message');
$status->addCreator($creator);
if ($isMine) {
if ($config->get('enablephotos')) {
/* Photo creator */
$creator = new CUserStatusCreator('photo');
$creator->title = JText::_('COM_COMMUNITY_SINGULAR_PHOTO');
$creator->html = $template->fetch('status.photo');
$status->addCreator($creator);
}
if ($config->get('enablevideos')) {
/* Video creator */
$creator = new CUserStatusCreator('video');
$creator->title = JText::_('COM_COMMUNITY_SINGULAR_VIDEO');
$creator->html = $template->fetch('status.video');
$status->addCreator($creator);
}
if ($config->get('enableevents') && ($config->get('createevents') || COwnerHelper::isCommunityAdmin())) {
/* Event creator */
//CFactory::load( 'helpers' , 'event' );
$dateSelection = CEventHelper::getDateSelection();
$model = CFactory::getModel('events');
$categories = $model->getCategories();
// Load category tree
$cTree = CCategoryHelper::getCategories($categories);
$lists['categoryid'] = CCategoryHelper::getSelectList('events', $cTree);
$template->set('startDate', $dateSelection->startDate);
$template->set('endDate', $dateSelection->endDate);
$template->set('startHourSelect', $dateSelection->startHour);
$template->set('endHourSelect', $dateSelection->endHour);
$template->set('startMinSelect', $dateSelection->startMin);
$template->set('repeatEnd', $dateSelection->endDate);
$template->set('enableRepeat', $my->authorise('community.view', 'events.repeat'));
$template->set('endMinSelect', $dateSelection->endMin);
$template->set('startAmPmSelect', $dateSelection->startAmPm);
$template->set('endAmPmSelect', $dateSelection->endAmPm);
$template->set('lists', $lists);
$creator = new CUserStatusCreator('event');
$creator->title = JText::_('COM_COMMUNITY_SINGULAR_EVENT');
$creator->html = $template->fetch('status.event');
$status->addCreator($creator);
}
}
}
示例5: showMiniHeader
public static function showMiniHeader($userId)
{
CMiniHeader::load();
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
JFactory::getLanguage()->load('com_community');
$option = $jinput->get('option', '', 'STRING');
//JRequest::getVar('option', '' , 'REQUEST');
$my = CFactory::getUser();
$config = CFactory::getConfig();
if (!empty($userId)) {
$user = CFactory::getUser($userId);
$params = $user->getParams();
//links information
$photoEnabled = $config->get('enablephotos') ? true : false;
$eventEnabled = $config->get('enableevents') ? true : false;
$groupEnabled = $config->get('enablegroups') ? true : false;
$videoEnabled = $config->get('enablevideos') ? true : false;
//likes
CFactory::load('libraries', 'like');
$like = new Clike();
$isLikeEnabled = $like->enabled('profile') && $params->get('profileLikes', 1) ? 1 : 0;
$isUserLiked = $like->userLiked('profile', $user->id, $my->id);
/* likes count */
$likes = $like->getLikeCount('profile', $user->id);
//profile
$profileModel = CFactory::getModel('profile');
$profile = $profileModel->getViewableProfile($user->id, $user->getProfileType());
$profile = JArrayHelper::toObject($profile);
$profile->largeAvatar = $user->getAvatar();
$profile->defaultAvatar = $user->isDefaultAvatar();
$profile->status = $user->getStatus();
$profile->defaultCover = $user->isDefaultCover();
$profile->cover = $user->getCover();
$profile->coverPostion = $params->get('coverPosition', '');
if (strpos($profile->coverPostion, '%') === false) {
$profile->coverPostion = 0;
}
$groupmodel = CFactory::getModel('groups');
$profile->_groups = $groupmodel->getGroupsCount($profile->id);
$eventmodel = CFactory::getModel('events');
$profile->_events = $eventmodel->getEventsCount($profile->id);
$profile->_friends = $user->_friendcount;
$videoModel = CFactory::getModel('Videos');
$profile->_videos = $videoModel->getVideosCount($profile->id);
$photosModel = CFactory::getModel('photos');
$profile->_photos = $photosModel->getPhotosCount($profile->id);
/* is featured */
$modelFeatured = CFactory::getModel('Featured');
$profile->featured = $modelFeatured->isExists(FEATURED_USERS, $profile->id);
$sendMsg = CMessaging::getPopup($user->id);
$tmpl = new CTemplate();
$tmpl->set('my', $my)->set('user', $user)->set('isBlocked', $user->isBlocked())->set('isMine', COwnerHelper::isMine($my->id, $user->id))->set('sendMsg', $sendMsg)->set('config', $config)->set('isWaitingApproval', CFriendsHelper::isWaitingApproval($my->id, $user->id))->set('isLikeEnabled', $isLikeEnabled)->set('photoEnabled', $photoEnabled)->set('eventEnabled', $eventEnabled)->set('groupEnabled', $groupEnabled)->set('videoEnabled', $videoEnabled)->set('profile', $profile)->set('isUserLiked', $isUserLiked)->set('likes', $likes)->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id);
$showMiniHeader = $option == 'com_community' ? $tmpl->fetch('profile.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('profile.miniheader') . '</div>';
return $showMiniHeader;
}
}
示例6: ajaxWallShowComments
public function ajaxWallShowComments($uniqueId, $type = false)
{
$my = CFactory::getUser();
$html = '';
if ($type == 'albums') {
$album = JTable::getInstance('Album', 'CTable');
$album->load($uniqueId);
$html = CWallLibrary::getWallContents($type, $album->id, COwnerHelper::isCommunityAdmin() || COwnerHelper::isMine($my->id, $album->creator), 0, 0);
} else {
if ($type == 'discussions') {
$discussion = JTable::getInstance('Discussion', 'CTable');
$discussion->load($uniqueId);
$html = CWallLibrary::getWallContents($type, $discussion->id, $my->id == $discussion->creator, 0, 0, 'wall/content', 'groups,discussion');
} else {
if ($type == 'videos') {
$video = JTable::getInstance('Video', 'CTable');
$video->load($uniqueId);
$html = CWallLibrary::getWallContents($type, $video->id, COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0, 0, 0, 'wall/content', 'videos,video');
} else {
if ($type == 'photos') {
$photo = JTable::getInstance('Photo', 'CTable');
$photo->load($uniqueId);
$html = CWallLibrary::getWallContents($type, $photo->id, COwnerHelper::isCommunityAdmin() || $my->id == $photo->creator, 0, 0, 'wall/content', 'photos,photo');
}
}
}
}
$json = array();
$json['success'] = true;
$json['html'] = $html;
die(json_encode($json));
}
示例7: isPermitted
/**
* Check if permitted to play the video
*
* @param int $myid The current user's id
* @param int $userid The active profile user's id
* @param int $permission The video's permission
* @return bool True if it's permitted
* @since 1.2
*/
public function isPermitted($myid = 0, $userid = 0, $permissions = 0)
{
if ($permissions == 0) {
return true;
}
// public
// Load Libraries
CFactory::load('helpers', 'friends');
CFactory::load('helpers', 'owner');
if (COwnerHelper::isCommunityAdmin()) {
return true;
}
$relation = 0;
if ($myid != 0) {
$relation = 20;
}
// site members
if (CFriendsHelper::isConnected($myid, $userid)) {
$relation = 30;
}
// friends
if (COwnerHelper::isMine($myid, $userid)) {
$relation = 40;
// mine
}
if ($relation >= $permissions) {
return true;
}
return false;
}
示例8: isPermitted
/**
* Check if permitted to play the video
*
* @param int $myid The current user's id
* @param int $userid The active profile user's id
* @param int $permission The video's permission
* @return bool True if it's permitted
* @since 1.2
*/
public function isPermitted($myid = 0, $userid = 0, $permissions = 0)
{
if ($permissions == 0) {
return true;
}
// public
if (COwnerHelper::isCommunityAdmin()) {
return true;
}
$relation = 0;
if ($myid != 0) {
$relation = 20;
}
// site members
if (CFriendsHelper::isConnected($myid, $userid)) {
$relation = 30;
}
// friends
if (COwnerHelper::isMine($myid, $userid)) {
$relation = 40;
// mine
}
if ($relation >= $permissions) {
return true;
}
return false;
}
示例9: getHTML
/**
* Return html formatted activity stream
* @access public
* @todo Add caching - Improve performance via caching
*/
function getHTML($actor, $target, $date = null, $maxEntry = 0, $type = '', $idprefix = '', $showActivityContent = true, $showMoreActivity = false, $exclusions = null, $displayArchived = false)
{
jimport('joomla.utilities.date');
$mainframe =& JFactory::getApplication();
CFactory::load('helpers', 'url');
CFactory::load('helpers', 'owner');
CFactory::load('libraries', 'template');
$activities = CFactory::getModel('activities');
$appModel = CFactory::getModel('apps');
$config = CFactory::getConfig();
$html = '';
$numLines = 0;
$my = CFactory::getUser();
$actorId = $actor;
$htmlData = array();
$tmpl = new CTemplate();
$maxList = $maxEntry == 0 ? $config->get('maxactivities') : $maxEntry;
$config = CFactory::getConfig();
$isSuperAdmin = COwnerHelper::isCommunityAdmin();
$data = $this->_getData($actor, $target, $date, $maxList, $type, $exclusions, $displayArchived);
// Do not show more activity button if there is nothing more to read.
if ($activities->getTotalActivities() <= $config->get('maxactivities')) {
$showMoreActivity = false;
}
// We should also exclude any data that earlier (hence larger id) than any
// of the current exclusion list
$exclusions = $data->exclusions;
$htmlData = $data->data;
$tmpl->set('showMoreActivity', $showMoreActivity);
$tmpl->set('exclusions', $exclusions);
$tmpl->set('isMine', COwnerHelper::isMine($my->id, $actor));
$tmpl->set('activities', $htmlData);
$tmpl->set('idprefix', $idprefix);
$tmpl->set('my', $my);
$tmpl->set('isSuperAdmin', $isSuperAdmin);
$tmpl->set('config', $config);
$tmpl->set('showMore', $showActivityContent);
return $tmpl->fetch('activities.index');
}
示例10: video
//.........这里部分代码省略.........
/**
* Opengraph
*/
CHeadHelper::setType('website', JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'));
$mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS', 'notice'));
switch ($video->permissions) {
case '40':
$this->noAccess(JText::_('COM_COMMUNITY_VIDEOS_OWNER_ONLY', 'notice'));
break;
case '30':
$owner = CFactory::getUser($video->creator);
$this->noAccess(JText::sprintf('COM_COMMUNITY_VIDEOS_FRIEND_PERMISSION_MESSAGE', $owner->getDisplayName()));
break;
default:
$this->noAccess();
break;
}
return;
}
// Set pathway
$pathway = $mainframe->getPathway();
$pathway->addItem('Video', CRoute::_('index.php?option=com_community&view=videos'));
$pathway->addItem($video->getTitle(), '');
$filters = array('status' => 'ready', 'category_id' => $cat_id, 'creator' => $user->id, 'permissions' => $permissions, 'or_group_privacy' => 0, 'sorting' => $sorted, 'limit' => $limit);
$otherVideos = $model->getVideos($filters);
}
// Set the current user's active profile
CFactory::setActiveProfile($video->creator);
// Hit counter + 1
$video->hit();
// Get reporting html
$reportHTML = '';
$report = new CReportingLibrary();
if ($user->id != $my->id) {
$reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_VIDEOS_REPORT_VIDEOS'), 'videos,reportVideo', array($video->id));
}
// Get bookmark html
$bookmarks = new CBookmarks($video->getPermalink());
$bookmarksHTML = $bookmarks->getHTML();
// Get the walls
$wallContent = CWallLibrary::getWallContents('videos', $video->id, COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0, $config->get('stream_default_comments'), 0, 'wall/content', 'videos,video');
$wallCount = CWallLibrary::getWallCount('videos', $video->id);
$viewAllLink = CRoute::_('index.php?option=com_community&view=videos&task=app&videoid=' . $video->id . '&app=walls');
$wallViewAll = '';
if ($wallCount > $config->get('stream_default_comments')) {
$wallViewAll = CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
}
$wallForm = '';
if ($this->isPermitted($my->id, $video->creator, PRIVACY_FRIENDS) || !$config->get('lockvideoswalls')) {
$wallForm = CWallLibrary::getWallInputForm($video->id, 'videos,ajaxSaveWall', 'videos,ajaxRemoveWall', $viewAllLink);
}
$redirectUrl = CRoute::getURI(false);
// Get like information.
$like = new CLike();
$likeCount = $like->getLikeCount('videos', $video->id);
$likeLiked = $like->userLiked('videos', $video->id, $my->id) === COMMUNITY_LIKE;
$tmpl = new CTemplate();
if ($video->creator_type == VIDEO_GROUP_TYPE) {
$group = JTable::getInstance('Group', 'CTable');
$group->load($groupId);
$document = JFactory::getDocument();
$document->addHeadLink($group->getThumbAvatar(), 'image_src', 'rel');
}
if ($video->location !== '' && $videoMapsDefault) {
$zoomableMap = CMapping::drawZoomableMap($video->location, 220, 150, $video->longitude, $video->latitude);
} else {
$zoomableMap = "";
}
//friend list for video tag
$tagging = new CVideoTagging();
$taggedList = $tagging->getTaggedList($video->id);
for ($t = 0; $t < count($taggedList); $t++) {
$tagItem = $taggedList[$t];
$tagUser = CFactory::getUser($tagItem->userid);
$canRemoveTag = 0;
// 1st we check the tagged user is the video owner.
// If yes, canRemoveTag == true.
// If no, then check on user is the tag creator or not.
// If yes, canRemoveTag == true
// If no, then check on user whether user is being tagged
if (COwnerHelper::isMine($my->id, $video->creator) || COwnerHelper::isMine($my->id, $tagItem->created_by) || COwnerHelper::isMine($my->id, $tagItem->userid)) {
$canRemoveTag = 1;
}
$tagItem->user = $tagUser;
$tagItem->canRemoveTag = $canRemoveTag;
}
if ($video->type == "file") {
$storage = CStorage::getStorage($video->storage);
$video->path = $storage->getURI($video->path);
}
$config = CFactory::getConfig();
$canSearch = 1;
if ($my->id == 0 && !$config->get('enableguestsearchvideos')) {
$canSearch = 0;
}
CHeadHelper::addOpengraph('og:image', JUri::root() . $video->thumb, true);
CHeadHelper::setType('website', $video->title);
$video->tagged = $taggedList;
echo $tmpl->setMetaTags('video', $video)->set('user', $user)->set('zoomableMap', $zoomableMap)->set('likeCount', $likeCount)->set('canSearch', $canSearch)->set('likeLiked', $likeLiked)->set('redirectUrl', $redirectUrl)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('wallCount', $wallCount)->set('wallViewAll', $wallViewAll)->set('bookmarksHTML', $bookmarksHTML)->set('reportHTML', $reportHTML)->set('video', $video)->set('otherVideos', $otherVideos)->set('videoMapsDefault', $videoMapsDefault)->set('wallCount', $wallCount)->set('isGroup', $groupId ? true : false)->set('groupId', $groupId ? $groupId : null)->set('submenu', $this->showSubmenu(false))->fetch('videos/single');
}
示例11: ajaxUpdate
/**
* Update the status of current user
*/
public function ajaxUpdate($message = '')
{
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$mainframe =& JFactory::getApplication();
$objResponse = new JAXResponse();
//@rule: In case someone bypasses the status in the html, we enforce the character limit.
$config = CFactory::getConfig();
if (JString::strlen($message) > $config->get('statusmaxchar')) {
$message = JString::substr($message, 0, $config->get('statusmaxchar'));
}
//trim it here so that it wun go into activities stream.
$message = JString::trim($message);
$my = CFactory::getUser();
$status =& $this->getModel('status');
$status->update($my->id, $message);
//set user status for current session.
$today =& JFactory::getDate();
$message2 = empty($message) ? ' ' : $message;
$my->set('_status', $message2);
$my->set('_posted_on', $today->toMySQL());
$profileid = JRequest::getVar('userid', 0, 'GET');
if (COwnerHelper::isMine($my->id, $profileid)) {
$objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($message) . "');");
}
CFactory::load('helpers', 'string');
$message = CStringHelper::escape($message);
if (!empty($message)) {
$act = new stdClass();
$act->cmd = 'profile.status.update';
$act->actor = $my->id;
$act->target = $my->id;
CFactory::load('helpers', 'linkgenerator');
// @rule: Autolink hyperlinks
$message = CLinkGeneratorHelper::replaceURL($message);
// @rule: Autolink to users profile when message contains @username
$message = CLinkGeneratorHelper::replaceAliasURL($message);
$privacyParams = $my->getParams();
$act->title = '{actor} ' . $message;
$act->content = '';
$act->app = 'profile';
$act->cid = $my->id;
$act->access = $privacyParams->get('privacyProfileView');
CFactory::load('libraries', 'activities');
CActivityStream::add($act);
//add user points
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('profile.status.update');
//now we need to reload the activities streams
$friendsModel = CFactory::getModel('friends');
$memberSince = CTimeHelper::getDate($my->registerDate);
$friendIds = $friendsModel->getFriendIds($my->id);
include_once JPATH_COMPONENT . DS . 'libraries' . DS . 'activities.php';
$act = new CActivityStream();
$params =& $my->getParams();
$limit = !empty($params) ? $params->get('activityLimit', '') : '';
$html = $act->getHTML($my->id, $friendIds, $memberSince, $limit);
$status = $my->getStatus();
$status = addslashes($status);
$objResponse->addScriptCall("joms.jQuery('#profile-status-message').html('" . $status . "');");
$objResponse->addScriptCall("joms.jQuery('title').val('" . $status . "');");
$objResponse->addAssign('activity-stream-container', 'innerHTML', $html);
}
return $objResponse->sendResponse();
}
示例12: _getMiniHeader
/**
* Show profile miniheader
*/
function _getMiniHeader()
{
CFactory::load('helpers', 'friends');
$my = CFactory::getUser();
$config = CFactory::getConfig();
if (!empty($this->_showMiniHeaderUser)) {
$user = CFactory::getUser($this->_showMiniHeaderUser);
CFactory::load('libraries', 'messaging');
$sendMsg = CMessaging::getPopup($user->id);
$tmpl = new CTemplate();
$tmpl->set('my', $my);
$tmpl->set('user', $user);
$tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id));
$tmpl->set('sendMsg', $sendMsg);
$tmpl->set('config', $config);
$tmpl->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id);
return $tmpl->fetch('profile.miniheader');
}
}
示例13:
<?php
if ($enableReporting) {
?>
<button class="joms-button--neutral joms-button--small" onclick="joms.api.photoReport('<?php
echo $photo->id;
?>
');"><?php
echo JText::_('COM_COMMUNITY_REPORT');
?>
</button>
<?php
}
?>
<?php
if (COwnerHelper::isMine($my->id, $album->creator) || CFriendsHelper::isConnected($my->id, $album->creator)) {
?>
<button class="joms-button--neutral joms-button--small joms-js--btn-tag"><?php
echo JText::_('COM_COMMUNITY_TAG_THIS_PHOTO');
?>
</button>
<?php
}
?>
<div class="joms-js--photo-tag-ct"></div>
<div class="joms-gap"></div>
<div>
<h5 class="joms-text--title"><?php
echo JText::_('COM_COMMUNITY_PHOTOS_ALBUM_DESC');
示例14: ajaxUpdate
/**
* Update the status of current user
*/
public function ajaxUpdate($message = '')
{
$filter = JFilterInput::getInstance();
$message = $filter->clean($message, 'string');
$cache = CFactory::getFastCache();
$cache->clean(array('activities'));
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$objResponse = new JAXResponse();
//@rule: In case someone bypasses the status in the html, we enforce the character limit.
$config = CFactory::getConfig();
if (JString::strlen($message) > $config->get('statusmaxchar')) {
$message = JHTML::_('string.truncate', $message, $config->get('statusmaxchar'));
}
//trim it here so that it wun go into activities stream.
$message = JString::trim($message);
$my = CFactory::getUser();
$status = $this->getModel('status');
// @rule: Spam checks
if ($config->get('antispam_akismet_status')) {
//CFactory::load( 'libraries' , 'spamfilter' );
$filter = CSpamFilter::getFilter();
$filter->setAuthor($my->getDisplayName());
$filter->setMessage($message);
$filter->setEmail($my->email);
$filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
$filter->setType('message');
$filter->setIP($_SERVER['REMOTE_ADDR']);
if ($filter->isSpam()) {
$objResponse->addAlert(JText::_('COM_COMMUNITY_STATUS_MARKED_SPAM'));
return $objResponse->sendResponse();
}
}
$status->update($my->id, $message);
//set user status for current session.
$today = JFactory::getDate();
$message2 = empty($message) ? ' ' : $message;
$my->set('_status', $message2);
$my->set('_posted_on', $today->toSql());
$profileid = $jinput->get->get('userid', 0, 'INT');
//JRequest::getVar('userid' , 0 , 'GET');
if (COwnerHelper::isMine($my->id, $profileid)) {
$objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($message) . "');");
}
//CFactory::load( 'helpers' , 'string' );
// $message = CStringHelper::escape( $message );
if (!empty($message)) {
$act = new stdClass();
$act->cmd = 'profile.status.update';
$act->actor = $my->id;
$act->target = $my->id;
//CFactory::load( 'helpers' , 'linkgenerator' );
// @rule: Autolink hyperlinks
$message = CLinkGeneratorHelper::replaceURL($message);
// @rule: Autolink to users profile when message contains @username
$message = CUserHelper::replaceAliasURL($message);
$privacyParams = $my->getParams();
$act->title = $message;
$act->content = '';
$act->app = 'profile';
$act->cid = $my->id;
$act->access = $privacyParams->get('privacyProfileView');
$act->comment_id = CActivities::COMMENT_SELF;
$act->comment_type = 'profile.status';
$act->like_id = CActivities::LIKE_SELF;
$act->like_type = 'profile.status';
//add user points
//CFactory::load( 'libraries' , 'userpoints' );
if (CUserPoints::assignPoint('profile.status.update')) {
//only assign act if user points is set to true
CActivityStream::add($act);
}
//now we need to reload the activities streams (since some report regarding update status from hello me we disabled update the stream, cuz hellome usually called out from jomsocial page)
$friendsModel = CFactory::getModel('friends');
$memberSince = CTimeHelper::getDate($my->registerDate);
$friendIds = $friendsModel->getFriendIds($my->id);
//include_once(JPATH_COMPONENT .'/libraries/activities.php');
$act = new CActivityStream();
$params = $my->getParams();
$limit = !empty($params) ? $params->get('activityLimit', '') : '';
//$html = $act->getHTML($my->id, $friendIds, $memberSince, $limit );
$status = $my->getStatus();
$status = str_replace(array("\r\n", "\n", "\r"), "", $status);
$status = addslashes($status);
// also update hellome module if available
$script = "joms.jQuery('.joms-js--mod-hellome-label').html('" . $status . "');";
$script .= "joms.jQuery('.joms-js--mod-hellome-loading').hide();";
$objResponse->addScriptCall($script);
}
return $objResponse->sendResponse();
}
示例15: modProfileUserinfo
public function modProfileUserinfo()
{
jimport('joomla.utilities.arrayhelper');
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$my = CFactory::getUser();
$userid = $jinput->get('userid', $my->id, 'INT');
$user = CFactory::getUser($userid);
$params = $user->getParams();
$userModel = CFactory::getModel('user');
$profileModel = CFactory::getModel('profile');
//Reassign needed variable
$data = new stdClass();
$data->user = $user;
$data->profile = $profileModel->getViewableProfile($userid, $user->getProfileType());
$data->videoid = $params->get('profileVideo', 0);
CFactory::load('libraries', 'messaging');
$isMine = COwnerHelper::isMine($my->id, $user->id);
// Get the admin controls HTML data
$adminControlHTML = '';
$tmpl = new CTemplate();
// get how many unread message
$filter = array();
$inboxModel = CFactory::getModel('inbox');
$filter['user_id'] = $my->id;
$unread = $inboxModel->countUnRead($filter);
// get how many pending connection
$friendModel = CFactory::getModel('friends');
$pending = $friendModel->countPending($my->id);
$profile = JArrayHelper::toObject($data->profile);
$profile->largeAvatar = $user->getAvatar();
$profile->defaultAvatar = $user->isDefaultAvatar();
$profile->status = $user->getStatus();
$profile->defaultCover = $user->isDefaultCover();
$profile->cover = $user->getCover();
$profile->coverPostion = $params->get('coverPosition', '');
if (strpos($profile->coverPostion, '%') === false) {
$profile->coverPostion = 0;
}
$groupmodel = CFactory::getModel('groups');
$profile->_groups = $groupmodel->getGroupsCount($profile->id);
$eventmodel = CFactory::getModel('events');
$profile->_events = $eventmodel->getEventsCount($profile->id);
$profile->_friends = $user->_friendcount;
$videoModel = CFactory::getModel('Videos');
$profile->_videos = $videoModel->getVideosCount($profile->id);
$photosModel = CFactory::getModel('photos');
$profile->_photos = $photosModel->getPhotosCount($profile->id);
if ($profile->status !== '') {
$postedOn = new JDate($user->_posted_on);
$postedOn = CActivityStream::_createdLapse($postedOn);
$profile->posted_on = $user->_posted_on == '0000-00-00 00:00:00' ? '' : $postedOn;
} else {
$profile->posted_on = '';
}
/* is featured */
$modelFeatured = CFactory::getModel('Featured');
$profile->featured = $modelFeatured->isExists(FEATURED_USERS, $profile->id);
// Assign videoId
$profile->profilevideo = $data->videoid;
$video = JTable::getInstance('Video', 'CTable');
$video->load($profile->profilevideo);
$profile->profilevideoTitle = $video->getTitle();
$addbuddy = "joms.api.friendAdd('{$profile->id}')";
$sendMsg = CMessaging::getPopup($profile->id);
$config = CFactory::getConfig();
$jConfig = JFactory::getConfig();
$lastLogin = JText::_('COM_COMMUNITY_PROFILE_NEVER_LOGGED_IN');
if ($user->lastvisitDate != '0000-00-00 00:00:00') {
$userLastLogin = new JDate($user->lastvisitDate);
$lastLogin = CActivityStream::_createdLapse($userLastLogin);
}
// @todo : beside checking the owner, maybe we want to check for a cookie,
// say every few hours only the hit get increment by 1.
if (!$isMine) {
$user->viewHit();
}
// @rule: myblog integrations
$showBlogLink = false;
$myblog = CMyBlog::getInstance();
if ($config->get('enablemyblogicon') && $myblog) {
if ($myblog->userCanPost($user->id)) {
$showBlogLink = true;
}
$tmpl->set('blogItemId', $myblog->getItemId());
}
$photoEnabled = $config->get('enablephotos') ? true : false;
$eventEnabled = $config->get('enableevents') ? true : false;
$groupEnabled = $config->get('enablegroups') ? true : false;
$videoEnabled = $config->get('enablevideos') ? true : false;
$isSEFEnabled = $jConfig->get('sef') ? true : false;
$multiprofile = JTable::getInstance('MultiProfile', 'CTable');
$multiprofile->load($user->getProfileType());
CFactory::load('libraries', 'like');
$like = new Clike();
$isLikeEnabled = $like->enabled('profile') && $params->get('profileLikes', 1) ? 1 : 0;
$isUserLiked = $like->userLiked('profile', $user->id, $my->id);
/* likes count */
$likes = $like->getLikeCount('profile', $user->id);
/* User status */
//.........这里部分代码省略.........