本文整理汇总了PHP中CUserPoints::assignPoint方法的典型用法代码示例。如果您正苦于以下问题:PHP CUserPoints::assignPoint方法的具体用法?PHP CUserPoints::assignPoint怎么用?PHP CUserPoints::assignPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUserPoints
的用法示例。
在下文中一共展示了CUserPoints::assignPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deletegroupmembers
function deletegroupmembers($data)
{
require_once JPATH_SITE . '/components/com_community/libraries/core.php';
CFactory::load('libraries', 'apps');
$error_messages = array();
$success_messages = array();
$response = NULL;
$validated = true;
if ("" == $data['groupid'] || 0 == $data['groupid']) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "groupid", "message" => "Groupid cannot be blank");
}
if (false == array_key_exists('memberids', $data) || 0 == sizeof($data['memberids'])) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "memberids", "message" => "Memberids cannot be blank");
}
if (true == $validated) {
$model =& CFactory::getModel('groups');
$group =& JTable::getInstance('Group', 'CTable');
$group->id = $data['groupid'];
$group->ownerid = $data['ownerid'];
}
if ($data['ownerid'] == $data['memberids']) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "ownerid/memberid", "message" => "owner id and member id are same.please update 'ownwrid or memberid' fields in request");
} else {
$groupMember =& JTable::getInstance('GroupMembers', 'CTable');
$memberId = $data['memberids'];
$groupId = $data['groupid'];
$groupMember->load($memberId, $groupId);
$data = new stdClass();
$data->groupid = $groupId;
$data->memberid = $memberId;
$data = new stdClass();
$data->groupid = $groupId;
$data->memberid = $memberId;
$model->removeMember($data);
$db =& JFactory::getDBO();
$query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__community_groups_members') . ' ' . 'WHERE groupid=' . $db->Quote($groupId) . ' ' . 'AND approved=' . $db->Quote('1');
$db->setQuery($query);
$membercount = $db->loadResult();
$members = new stdClass();
$members->id = $groupId;
$members->membercount = $membercount;
$db->updateObject('#__community_groups', $members, 'id');
//add user points
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('group.member.remove', $memberId);
}
if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
$res = array();
foreach ($error_messages as $key => $error_message) {
$res[] = $error_message;
}
$response = array("id" => 0, 'errors' => $res);
} else {
$response = array('id' => $memberId);
}
return $response;
}
示例2: onAfterVote
function onAfterVote($poll, $option_id)
{
$user =& JFactory::getUser();
$points = JPATH_ROOT . '/components/com_community/libraries/core.php';
$activity = JPATH_ROOT . '/components/com_community/libraries/core.php';
if ($this->params->get('points', '0') == '1' && file_exists($points)) {
require_once $points;
CUserPoints::assignPoint('com_acepolls.vote');
}
if ($this->params->get('activity', '0') == '1' && file_exists($activity)) {
require_once $activity;
$text = JText::_('COM_ACEPOLLS_ACTIVITY_TEXT');
$link = JRoute::_('index.php?option=com_acepolls&view=poll&id=' . $poll->id . ":" . $poll->alias . self::getItemid($poll->id));
$act = new stdClass();
$act->cmd = 'wall.write';
$act->actor = $user->id;
$act->target = 0;
$act->title = JText::_('{actor} ' . $text . ' <a href="' . $link . '">' . $poll->title . '</a>');
$act->content = '';
$act->app = 'wall';
$act->cid = 0;
CFactory::load('libraries', 'activities');
CActivityStream::add($act);
}
}
示例3: deletewallpost
function deletewallpost($data)
{
require_once JPATH_SITE . '/components/com_community/libraries/core.php';
$error_messages = array();
$response = NULL;
$validated = true;
$db =& JFactory::getDBO();
if ($data['wall_id'] == "" || $data['wall_id'] == "0") {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "Wall id cannot be blank");
}
//@rule: Check if user is really allowed to remove the current wall
$my = CFactory::getUser();
$model =& CFactory::getModel('wall');
$wall = $model->get($data['wall_id']);
$groupModel =& CFactory::getModel('groups');
$group =& JTable::getInstance('Group', 'CTable');
$group->load($wall->contentid);
$query = "SELECT contentid FROM #__community_wall WHERE id ='" . $data['wall_id'] . "' AND type = 'groups'";
$db->setQuery($query);
$contentid = $db->LoadResult();
CFactory::load('helpers', 'owner');
$query = "SELECT id FROM #__community_wall WHERE id ='" . $data['wall_id'] . "' AND type = 'groups'";
$db->setQuery($query);
$isdiscussion = $db->LoadResult();
if (!$isdiscussion) {
$error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "wall id for type groups does not exists. Modify the wall_id field");
} else {
if (!$model->deletePost($data['wall_id'])) {
$validated = false;
//$error_messages[] = 'wall id does not exists. Modify the wall_id fields in request';
$error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "wall id does not exists. Modify the wall_id field");
} else {
if ($wall->post_by != 0) {
//add user points
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('wall.remove', $wall->post_by);
}
}
//$groupModel->substractWallCount( $data['wall_id'] );
// Substract the count
$query = 'SELECT COUNT(*) FROM ' . $db->nameQuote('#__community_wall') . ' ' . 'WHERE contentid=' . $db->Quote($contentid) . ' ' . 'AND type="groups"';
$db->setQuery($query);
$wall_count = $db->loadResult();
$wallcount = new stdClass();
$wallcount->id = $contentid;
$wallcount->wallcount = $wall_count;
$db->updateObject('#__community_groups', $wallcount, 'id');
}
if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
$res = array();
foreach ($error_messages as $key => $error_message) {
$res[] = $error_message;
}
$response = array("id" => 0, 'errors' => $res);
} else {
$response = array('id' => $wall->id);
}
return $response;
}
示例4: onAfterThankyou
public function onAfterThankyou($target, $actor, $message)
{
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('com_kunena.thread.thankyou', $target);
$username = KunenaFactory::getUser($actor)->username;
$act = new stdClass();
$act->cmd = 'wall.write';
$act->actor = JFactory::getUser()->id;
$act->target = $target;
$act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_TITLE', $username));
$act->content = NULL;
$act->app = 'kunena.thankyou';
$act->cid = $target;
$act->access = $this->getAccess($message->getCategory());
// Comments and like support
$act->comment_id = $target;
$act->comment_type = 'kunena.thankyou';
$act->like_id = $target;
$act->like_type = 'kunena.thankyou';
// Do not add private activities
if ($act->access > 20) {
return;
}
CFactory::load('libraries', 'activities');
CActivityStream::add($act);
}
示例5: removeFriend
/**
* 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'));
}
}
示例6: deletegroupannouncement
function deletegroupannouncement($data)
{
require_once JPATH_SITE . '/components/com_community/libraries/core.php';
require_once JPATH_SITE . '/libraries/joomla/filesystem/folder.php';
CFactory::load('libraries', 'apps');
$error_messages = array();
$response = NULL;
$validated = true;
if ("" == $data['groupid'] || 0 == $data['groupid']) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "groupid", "message" => "Groupid cannot be blank");
}
if ($data['bulletinid'] == "" || 0 == $data['bulletinid']) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "bulletinid", "message" => "Bulletinid cannot be blank");
}
$user =& JFactory::getUser();
$group =& JTable::getInstance('Group', 'CTable');
$group->id = $data['groupid'];
if (true == $validated) {
$bulletin =& JTable::getInstance('Bulletin', 'CTable');
$bulletin->id = $data['bulletinid'];
$bulletin->groupid = $data['groupid'];
$validated = true;
if (true == empty($bulletin->id)) {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "bulletinid", "message" => "Invalid bulletin id. Check 'bulletinid' field in request");
}
CFactory::load('helpers', 'owner');
CFactory::load('models', 'bulletins');
$groupsModel =& CFactory::getModel('groups');
$bulletin =& JTable::getInstance('Bulletin', 'CTable');
$group =& JTable::getInstance('Group', 'CTable');
$group->load($groupid);
$bulletin->id = $data['bulletinid'];
$bulletin->groupid = $data['groupid'];
if ($bulletin->delete()) {
//add user points
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('group.news.remove');
}
}
if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
$res = array();
foreach ($error_messages as $key => $error_message) {
$res[] = $error_message;
}
$response = array("id" => 0, 'errors' => $res);
} else {
$response = array('id' => $bulletin->id);
}
return $response;
}
示例7: onAfterThankyou
public function onAfterThankyou($thankyoutargetid, $username , $message) {
CFactory::load ( 'libraries', 'userpoints' );
CUserPoints::assignPoint ( 'com_kunena.thread.thankyou', $thankyoutargetid );
$act = new stdClass ();
$act->cmd = 'wall.write';
$act->actor = JFactory::getUser()->id;
$act->target = $thankyoutargetid;
$act->title = JText::_ ( '{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::_( 'COM_KUNENA_JS_ACTIVITYSTREAM_THANKYOU' ).' <a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a> ' . JText::_ ( 'COM_KUNENA_JS_ACTIVITYSTREAM_REPLY_MSG2' ) );
$act->content = NULL;
$act->app = 'kunena.thankyou';
$act->cid = $thankyoutargetid;
$act->access = $this->getAccess($message->getCategory());
CFactory::load ( 'libraries', 'activities' );
CActivityStream::add ( $act );
}
示例8: uploadAvatar
//.........这里部分代码省略.........
}
}
}
}
//makesafe on the file
$file['name'] = $my->id . '_' . JFile::makeSafe($file['name']);
if (isset($file['name'])) {
$target_file_path = $upload_path;
$relative_target_file = $rel_upload_path . DIRECTORY_SEPARATOR . $file['name'];
$target_file = JPath::clean($target_file_path . DIRECTORY_SEPARATOR . JFile::makeSafe($file['name']));
$isNew = false;
if (EB::image()->canUpload($file, $err)) {
if (!$isFromBackend) {
EB::info()->set(JText::_($err), 'error');
$mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
} else {
//from backend
$mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=users', false), JText::_($err), 'error');
}
return;
}
if (0 != (int) $file['error']) {
if (!$isFromBackend) {
EB::info()->set($file['error'], 'error');
$mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
} else {
//from backend
$mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=users', false), $file['error'], 'error');
}
return;
}
//rename the file 1st.
$oldAvatar = $profile->avatar;
$tempAvatar = '';
if ($oldAvatar != 'default.png' && $oldAvatar != 'default_blogger.png') {
$session = JFactory::getSession();
$sessionId = $session->getToken();
$fileExt = JFile::getExt(JPath::clean($target_file_path . DIRECTORY_SEPARATOR . $oldAvatar));
$tempAvatar = JPath::clean($target_file_path . DIRECTORY_SEPARATOR . $sessionId . '.' . $fileExt);
JFile::move($target_file_path . DIRECTORY_SEPARATOR . $oldAvatar, $tempAvatar);
} else {
$isNew = true;
}
if (JFile::exists($target_file)) {
if ($oldAvatar != 'default.png' && $oldAvatar != 'default_blogger.png') {
//rename back to the previous one.
JFile::move($tempAvatar, $target_file_path . DIRECTORY_SEPARATOR . $oldAvatar);
}
if (!$isFromBackend) {
EB::info()->set(JText::sprintf('ERROR.FILE_ALREADY_EXISTS', $relative_target_file), 'error');
$mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
} else {
//from backend
$mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=users', false), JText::sprintf('ERROR.FILE_ALREADY_EXISTS', $relative_target_file), 'error');
}
return;
}
if (JFolder::exists($target_file)) {
if ($oldAvatar != 'default.png' && $oldAvatar != 'default_blogger.png') {
//rename back to the previous one.
JFile::move($tempAvatar, $target_file_path . DIRECTORY_SEPARATOR . $oldAvatar);
}
if (!$isFromBackend) {
//JError::raiseNotice(100, JText::sprintf('ERROR.FOLDER_ALREADY_EXISTS',$relative_target_file));
EB::info()->set(JText::sprintf('ERROR.FOLDER_ALREADY_EXISTS', $relative_target_file), 'error');
$mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=dashboard&layout=profile', false));
} else {
//from backend
$mainframe->redirect(EBR::_('index.php?option=com_easyblog&view=users', false), JText::sprintf('ERROR.FILE_ALREADY_EXISTS', $relative_target_file), 'error');
}
return;
}
$configImageWidth = EBLOG_AVATAR_LARGE_WIDTH;
$configImageHeight = EBLOG_AVATAR_LARGE_HEIGHT;
$image = EB::simpleimage();
$image->load($file['tmp_name']);
$image->resizeToFill($configImageWidth, $configImageHeight);
$image->save($target_file, $image->image_type);
//now we update the user avatar. If needed, we remove the old avatar.
if ($oldAvatar != 'default.png' && $oldAvatar != 'default_blogger.png') {
//if(JFile::exists( JPATH_ROOT.DIRECTORY_SEPARATOR.$oldAvatar ))
if (JFile::exists($tempAvatar)) {
//JFile::delete( JPATH_ROOT.DIRECTORY_SEPARATOR.$oldAvatar );
JFile::delete($tempAvatar);
}
}
if ($isNew && !$isFromBackend) {
if ($my->id != 0 && $config->get('main_jomsocial_userpoint')) {
$jsUserPoint = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php';
if (JFile::exists($jsUserPoint)) {
require_once $jsUserPoint;
CUserPoints::assignPoint('com_easyblog.avatar.upload', $my->id);
}
}
}
return JFile::makeSafe($file['name']);
} else {
return 'default_blogger.png';
}
}
示例9: editPost
//.........这里部分代码省略.........
}
}
}
if ($isDraft) {
$blog->pending_approval = true;
// we need to process trackbacks and tags here.
//adding trackback.
if (!empty($acl->rules->add_trackback)) {
$trackback = isset($content['mt_tb_ping_urls']) ? $content['mt_tb_ping_urls'] : '';
if (!empty($trackback) && count($trackback) > 0) {
$trackback = implode("\n", $trackback);
$blog->trackbacks = $trackback;
}
}
// add new tag
$tags = isset($content['mt_keywords']) ? $content['mt_keywords'] : '';
$blog->tags = $tags;
}
if (!$blog->store()) {
$msg = $blog->getError();
$msg = empty($msg) ? 'Post store failed' : $msg;
return new xmlrpcresp(0, $xmlrpcerruser + 1, $msg);
}
if ($isDraft && !empty($blog->id)) {
// if this post is under moderation, we will stop here.
return new xmlrpcresp(new xmlrpcval($blog->id, $xmlrpcString));
}
/**
* JomSocial userpoint.
*/
if ($isNew && $blog->published == '1' && $my->id != 0) {
// Assign EasySocial points
$easysocial = EasyBlogHelper::getHelper('EasySocial');
$easysocial->assignPoints('blog.create', $my->id);
if ($config->get('main_jomsocial_userpoint')) {
$jsUserPoint = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php';
if (JFile::exists($jsUserPoint)) {
require_once $jsUserPoint;
CUserPoints::assignPoint('com_easyblog.blog.add', $my->id);
}
}
// @rule: Integrations with EasyDiscuss
EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.blog', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_BLOG', $blog->title));
EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.blog', $my->id);
EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.blog', $my->id);
// Assign badge for users that report blog post.
// Only give points if the viewer is viewing another person's blog post.
EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.create', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_CREATE_BLOG_POST'));
// @rule: Mighty Touch karma points
EasyBlogHelper::getHelper('MightyTouch')->setKarma($my->id, 'new_blog');
}
//add jomsocial activities
if ($blog->published == '1' && $config->get('main_jomsocial_activity')) {
EasyBlogXMLRPCHelper::addJomsocialActivities($blog, $isNew);
}
// AlphaUserPoints
// since 1.2
if (EasyBlogHelper::isAUPEnabled()) {
// get blog post URL
$url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id);
AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_blog', '', 'easyblog_add_blog_' . $blog->id, JText::sprintf('AUP NEW BLOG CREATED', $url, $blog->title));
}
//adding trackback.
if (!empty($acl->rules->add_trackback)) {
$trackback = isset($content['mt_tb_ping_urls']) ? $content['mt_tb_ping_urls'] : '';
EasyBlogXMLRPCHelper::addTrackback($trackback, $blog, $my);
示例10: ajaxStreamAdd
//.........这里部分代码省略.........
$activityParams = new CParameter('');
/* Save cords if exists */
if (isset($attachment['location'])) {
/* Save geo name */
$act->location = $attachment['location'][0];
$act->latitude = $attachment['location'][1];
$act->longitude = $attachment['location'][2];
}
$headMeta = new CParameter('');
if (isset($attachment['fetch'])) {
$headMeta->set('title', $attachment['fetch'][2]);
$headMeta->set('description', $attachment['fetch'][3]);
$headMeta->set('image', $attachment['fetch'][1]);
$headMeta->set('link', $attachment['fetch'][0]);
//do checking if this is a video link
$video = JTable::getInstance('Video', 'CTable');
$isValidVideo = @$video->init($attachment['fetch'][0]);
if ($isValidVideo) {
$headMeta->set('type', 'video');
$headMeta->set('video_provider', $video->type);
$headMeta->set('video_id', $video->getVideoId());
$headMeta->set('height', $video->getHeight());
$headMeta->set('width', $video->getWidth());
}
$activityParams->set('headMetas', $headMeta->toString());
}
//Store mood in paramm
if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
$activityParams->set('mood', $attachment['mood']);
}
$act->params = $activityParams->toString();
//CActivityStream::add($act);
//check if the user points is enabled
if (CUserPoints::assignPoint('profile.status.update')) {
/* Let use our new CApiStream */
$activityData = CApiActivities::add($act);
CTags::add($activityData);
$recipient = CFactory::getUser($attachment['target']);
$params = new CParameter('');
$params->set('actorName', $my->getDisplayName());
$params->set('recipientName', $recipient->getDisplayName());
$params->set('url', CUrlHelper::userLink($act->target, false));
$params->set('message', $message);
$params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
$params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_FRIEND_WALL_POST', $my->getDisplayName()), '', 'wall.post', $params);
//email and add notification if user are tagged
CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
}
break;
// Message posted from Group page
// Message posted from Group page
case 'groups':
//
$groupLib = new CGroups();
$group = JTable::getInstance('Group', 'CTable');
$group->load($attachment['target']);
// Permission check, only site admin and those who has
// mark their attendance can post message
if (!COwnerHelper::isCommunityAdmin() && !$group->isMember($my->id) && $config->get('lockgroupwalls')) {
$objResponse->addScriptCall("alert('permission denied');");
return $objResponse->sendResponse();
}
$act = new stdClass();
$act->cmd = 'groups.wall';
$act->actor = $my->id;
示例11: mapStatus
/**
* Maps a user status with JomSocial's user status
*
* @param Array User values
**/
public function mapStatus($userId)
{
$result = $this->facebook->api('/me/statuses');
$status = isset($result['data'][0]) ? $result['data'][0] : '';
if (empty($status)) {
return;
}
CFactory::load('helpers', 'linkgenerator');
$connectModel = CFactory::getModel('Connect');
$status = $status['message'];
$rawStatus = $status;
// @rule: Do not strip html tags but escape them.
CFactory::load('helpers', 'string');
$status = CStringHelper::escape($status);
// @rule: Autolink hyperlinks
$status = CLinkGeneratorHelper::replaceURL($status);
// @rule: Autolink to users profile when message contains @username
$status = CLinkGeneratorHelper::replaceAliasURL($status);
// Reload $my from CUser so we can use some of the methods there.
$my = CFactory::getUser($userId);
$params = $my->getParams();
// @rule: For existing statuses, do not set them.
if ($connectModel->statusExists($status, $userId)) {
return;
}
CFactory::load('libraries', 'activities');
$act = new stdClass();
$act->cmd = 'profile.status.update';
$act->actor = $userId;
$act->target = $userId;
$act->title = '{actor} ' . $status;
$act->content = '';
$act->app = 'profile';
$act->cid = $userId;
$act->access = $params->get('privacyProfileView');
$act->comment_id = CActivities::COMMENT_SELF;
$act->comment_type = 'profile.status';
$act->like_id = CActivities::LIKE_SELF;
$act->like_type = 'profile.status';
CActivityStream::add($act);
//add user points
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('profile.status.update');
// Update status from facebook.
$my->setStatus($rawStatus);
}
示例12: ajaxDeleteActivity
public function ajaxDeleteActivity($app, $activityId)
{
$my = CFactory::getUser();
$objResponse = new JAXResponse();
$filter = JFilterInput::getInstance();
$app = $filter->clean($app, 'string');
$activityId = $filter->clean($activityId, 'int');
$activity = JTable::getInstance('Activity', 'CTable');
$activity->load($activityId);
$json = array();
// @todo: do permission checking within the ACL
if ($my->authorise('community.delete', 'activities.' . $activityId, $activity)) {
$activity->delete($app);
if ($activity->app == 'profile') {
$model = $this->getModel('activities');
$data = $model->getAppActivities(array('app' => 'profile', 'cid' => $activity->cid, 'limit' => 1));
$status = $this->getModel('status');
$status->update($activity->cid, $data[0]->title, $activity->access);
$user = CFactory::getUser($activity->cid);
$today = JFactory::getDate();
$user->set('_status', $data[0]->title);
$user->set('_posted_on', $today->toSql());
}
$json = array('success' => true);
CUserPoints::assignPoint('wall.remove');
} else {
$json = array('error' => true);
}
$this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
die(json_encode($json));
}
示例13: ajaxGroupRejectRequest
/**
* Ajax function to decline Private Group Request
*
**/
public function ajaxGroupRejectRequest($memberId, $groupId)
{
$filter = JFilterInput::getInstance();
$groupId = $filter->clean($groupId, 'int');
$memberId = $filter->clean($memberId, 'int');
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$objResponse = new JAXResponse();
$my = CFactory::getUser();
$model = $this->getModel('groups');
$group = JTable::getInstance('Group', 'CTable');
$group->load($groupId);
//CFactory::load( 'helpers' , 'owner' );
if (!$group->isAdmin($my->id, $groupId) && !COwnerHelper::isCommunityAdmin()) {
$objResponse->addScriptCall(JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'));
} else {
//Load Necessary Table
$groupMember = JTable::getInstance('GroupMembers', 'CTable');
$data = new stdClass();
$data->groupid = $groupId;
$data->memberid = $memberId;
$model->removeMember($data);
//add user points
//CFactory::load( 'libraries' , 'userpoints' );
CUserPoints::assignPoint('group.member.remove', $memberId);
//trigger for onGroupLeave
$this->triggerEvents('onGroupLeave', $group, $memberId);
$group->updateStats();
$group->store();
$url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
$objResponse->addScriptCall('joms.jQuery("#msg-request-' . $memberId . '").html("' . addslashes(JText::sprintf('COM_COMMUNITY_EVENTS_REJECTED', $group->name, $url)) . '");');
$objResponse->addScriptCall('joms.notifications.updateNotifyCount();');
$objResponse->addScriptCall('joms.jQuery("#noti-request-group-' . $memberId . '").fadeOut(1000, function() { joms.jQuery("#noti-request-group-' . $memberId . '").remove();} );');
$objResponse->addScriptCall('aspan = joms.jQuery("#jsMenu .jsMenuIcon span"); aspan.html(parseInt(aspan.html())-1);');
}
return $objResponse->sendResponse();
}
示例14: ajaxCoverUpload
/**
* Process Uploaded Photo Cover
* @return [JSON OBJECT] [description]
*/
public function ajaxCoverUpload()
{
$jinput = JFactory::getApplication()->input;
$parentId = $jinput->get->get('parentId', null, 'Int');
$type = strtolower($jinput->get->get('type', null, 'String'));
$file = $jinput->files->get('uploadCover');
$config = CFactory::getConfig();
$my = CFactory::getUser();
$now = new JDate();
$addStream = true;
if (!CImageHelper::checkImageSize(filesize($file['tmp_name']))) {
$msg['error'] = JText::sprintf('COM_COMMUNITY_VIDEOS_IMAGE_FILE_SIZE_EXCEEDED_MB', CFactory::getConfig()->get('maxuploadsize'));
echo json_encode($msg);
exit;
}
//check if file is allwoed
if (!CImageHelper::isValidType($file['type'])) {
$msg['error'] = JText::_('COM_COMMUNITY_IMAGE_FILE_NOT_SUPPORTED');
echo json_encode($msg);
exit;
}
CImageHelper::autoRotate($file['tmp_name']);
$album = JTable::getInstance('Album', 'CTable');
if (!($albumId = $album->isCoverExist($type, $parentId))) {
$albumId = $album->addCoverAlbum($type, $parentId);
}
$imgMaxWidht = 1140;
// Get a hash for the file name.
$fileName = JApplication::getHash($file['tmp_name'] . time());
$hashFileName = JString::substr($fileName, 0, 24);
if (!JFolder::exists(JPATH_ROOT . '/' . $config->getString('imagefolder') . '/cover/' . $type . '/' . $parentId . '/')) {
JFolder::create(JPATH_ROOT . '/' . $config->getString('imagefolder') . '/cover/' . $type . '/' . $parentId . '/');
}
$dest = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/cover/' . $type . '/' . $parentId . '/' . md5($type . '_cover' . time()) . CImageHelper::getExtension($file['type']);
$thumbPath = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/cover/' . $type . '/' . $parentId . '/thumb_' . md5($type . '_cover' . time()) . CImageHelper::getExtension($file['type']);
// Generate full image
if (!CImageHelper::resizeProportional($file['tmp_name'], $dest, $file['type'], $imgMaxWidht)) {
$msg['error'] = JText::sprintf('COM_COMMUNITY_ERROR_MOVING_UPLOADED_FILE', $storageImage);
echo json_encode($msg);
exit;
}
CPhotos::generateThumbnail($file['tmp_name'], $thumbPath, $file['type']);
$cTable = JTable::getInstance(ucfirst($type), 'CTable');
$cTable->load($parentId);
if ($cTable->setCover(str_replace(JPATH_ROOT . '/', '', $dest))) {
$photo = JTable::getInstance('Photo', 'CTable');
$photo->albumid = $albumId;
$photo->image = str_replace(JPATH_ROOT . '/', '', $dest);
$photo->caption = $file['name'];
$photo->filesize = $file['size'];
$photo->creator = $my->id;
$photo->created = $now->toSql();
$photo->published = 1;
$photo->thumbnail = str_replace(JPATH_ROOT . '/', '', $thumbPath);
if ($photo->store()) {
$album->load($albumId);
$album->photoid = $photo->id;
$album->store();
}
$msg['success'] = true;
$msg['path'] = JURI::root() . str_replace(JPATH_ROOT . '/', '', $dest);
$msg['cancelbutton'] = JText::_('COM_COMMUNITY_CANCEL_BUTTON');
$msg['savebutton'] = JText::_("COM_COMMUNITY_SAVE_BUTTON");
// Generate activity stream.
$act = new stdClass();
$act->cmd = 'cover.upload';
$act->actor = $my->id;
$act->target = 0;
$act->title = '';
$act->content = '';
$act->access = $type == 'profile' ? $my->_cparams->get("privacyPhotoView") : 0;
$act->app = 'cover.upload';
$act->cid = $photo->id;
$act->comment_id = CActivities::COMMENT_SELF;
$act->comment_type = 'cover.upload';
$act->groupid = $type == 'group' ? $parentId : 0;
$act->eventid = $type == 'event' ? $parentId : 0;
$act->group_access = $type == 'group' ? $cTable->approvals : 0;
$act->event_access = $type == 'event' ? $cTable->permission : 0;
$act->like_id = CActivities::LIKE_SELF;
$act->like_type = 'cover.upload';
$params = new JRegistry();
$params->set('attachment', str_replace(JPATH_ROOT . '/', '', $dest));
$params->set('type', $type);
$params->set('album_id', $albumId);
$params->set('photo_id', $photo->id);
//assign points based on types.
switch ($type) {
case 'group':
$addStream = CUserPoints::assignPoint('group.cover.upload');
break;
case 'event':
$addStream = CUserPoints::assignPoint('event.cover.upload');
break;
default:
$addStream = CUserPoints::assignPoint('profile.cover.upload');
//.........这里部分代码省略.........
示例15: ajaxRemoveWall
/**
* Delete post message
*
* @param response An ajax Response object
* @param id A unique identifier for the wall row
*
* returns response
*/
function ajaxRemoveWall($response, $id, $cache_id = "")
{
$my = CFactory::getUser();
$wallModel = CFactory::getModel('wall');
$wall = $wallModel->get($id);
CError::assert($id, '', '!empty', __FILE__, __LINE__);
CFactory::load('helpers', 'owner');
// Make sure the current user actually has the correct permission
// Only the original writer and the person the wall is meant for (and admin of course)
// can delete the wall
if ($my->id == $wall->post_by || $my->id == $wall->contentid || COwnerHelper::isCommunityAdmin()) {
if ($wallModel->deletePost($id)) {
// @rule: Remove the wall activity from the database as well
CFactory::load('libraries', 'activities');
CActivityStream::remove('walls', $id);
//add user points
if ($wall->post_by != 0) {
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('wall.remove', $wall->post_by);
}
} else {
$html = JText::_('Error while removing wall. Line:' . __LINE__);
$response->addAlert($html);
}
$cache =& JFactory::getCache('plgCommunityWalls');
$cache->remove($cache_id);
$cache =& JFactory::getCache('plgCommunityWalls_fullview');
$cache->remove($cache_id);
} else {
$html = JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING');
$response->addAlert($html);
}
return $response;
}