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; }
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); } }
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; }
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); }
/** * 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')); } }
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; }
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 ); }
/** * Allows caller to upload a user's avatar * * @since 4.0 * @access public * @param string * @return */ public static function uploadAvatar($profile, $isFromBackend = false, $file = false) { jimport('joomla.utilities.error'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $my = JFactory::getUser(); $mainframe = JFactory::getApplication(); $config = EasyBlogHelper::getConfig(); $acl = EB::acl(); if (!$isFromBackend) { if (!$acl->get('upload_avatar')) { $url = 'index.php?option=com_easyblog&view=dashboard&layout=profile'; EB::info()->set(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_UPLOAD_AVATAR'), 'error'); $mainframe->redirect(EBR::_($url, false)); } } $avatar_config_path = $config->get('main_avatarpath'); $avatar_config_path = rtrim($avatar_config_path, '/'); $avatar_config_path = str_replace('/', DIRECTORY_SEPARATOR, $avatar_config_path); $upload_path = JPATH_ROOT . DIRECTORY_SEPARATOR . $avatar_config_path; $rel_upload_path = $avatar_config_path; $err = null; if (!$file) { $file = JRequest::getVar('Filedata', '', 'files', 'array'); } //check whether the upload folder exist or not. if not create it. if (!JFolder::exists($upload_path)) { if (!JFolder::create($upload_path)) { // Redirect if (!$isFromBackend) { EB::info()->set(JText::_('COM_EASYBLOG_IMAGE_UPLOADER_FAILED_TO_CREATE_UPLOAD_FOLDER'), '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::_('COM_EASYBLOG_IMAGE_UPLOADER_FAILED_TO_CREATE_UPLOAD_FOLDER'), 'error'); } return; } else { // folder created. now copy index.html into this folder. if (!JFile::exists($upload_path . DIRECTORY_SEPARATOR . 'index.html')) { $targetFile = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'index.html'; $destFile = $upload_path . DIRECTORY_SEPARATOR . 'index.html'; if (JFile::exists($targetFile)) { JFile::copy($targetFile, $destFile); } } } } //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'; } }
public static function editPost($postid, $username, $password, $content, $publish) { $mainframe = JFactory::getApplication(); global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue; EasyBlogXMLRPCHelper::loginUser($username, $password); jimport('joomla.application.component.model'); $my = JFactory::getUser($username); $acl = EasyBlogACLHelper::getRuleSet($my->id); if (empty($my->id)) { return new xmlrpcresp(0, $xmlrpcerruser + 1, JText::_('NO PERMISSION TO CREATE BLOG')); } if (empty($acl->rules->add_entry)) { return new xmlrpcresp(0, $xmlrpcerruser + 1, JText::_('NO PERMISSION TO CREATE BLOG')); } $isNew = true; // create a new blog jtable object $isDraft = false; $blog = ''; if (empty($acl->rules->publish_entry)) { // Try to load this draft to see if it exists $blog = EasyBlogHelper::getTable('Draft'); $isDraft = true; } else { $blog = EasyBlogHelper::getTable('Blog', 'Table'); } if (isset($postid) && !empty($postid)) { $isNew = false; //we are doing editing $blog->load($postid); } //prepare initial blog settings. $config = EasyBlogHelper::getConfig(); $isPrivate = $config->get('main_blogprivacy', '0'); $allowComment = $config->get('main_comment', 1); $allowSubscribe = $config->get('main_subscription', 1); $showFrontpage = $config->get('main_newblogonfrontpage', 0); $sendEmails = $config->get('main_sendemailnotifications', 1); //check if user have permission to enable privacy. $aclBlogPrivacy = $acl->rules->enable_privacy; $isPrivate = empty($aclBlogPrivacy) ? '0' : $isPrivate; $showFrontpage = empty($acl->rules->contribute_frontpage) ? '0' : $showFrontpage; /** * Map the data input into blog's recognised data format */ $post = array(); $post['permalink'] = $blog->permalink; if (isset($content["wp_slug"])) { $post['permalink'] = $content["wp_slug"]; } //check if comment is allow on this blog if (isset($content["mt_allow_comments"])) { if (!is_numeric($content["mt_allow_comments"])) { switch ($content["mt_allow_comments"]) { case "closed": $post['allowcomment'] = 0; break; case "open": $post['allowcomment'] = 1; break; default: $post['allowcomment'] = $allowComment; break; } } else { switch ((int) $content["mt_allow_comments"]) { case 0: case 2: $post['allowcomment'] = 0; break; case 1: $post['allowcomment'] = 1; break; default: $post['allowcomment'] = $allowComment; break; } } } //end if allowcomment $post['title'] = $content['title']; $post['intro'] = ''; $post['content'] = ''; if (isset($content['mt_text_more']) && $content['mt_text_more']) { $post['intro'] = $content['description']; $post['content'] = $content['mt_text_more']; } else { if (isset($content['more_text']) && $content['more_text']) { $post['intro'] = $content['description']; $post['content'] = $content['more_text']; } else { $post['content'] = $content['description']; } } // if introtext still empty and excerpt is provide, then we use it. if (empty($post['intro']) && isset($content['mt_excerpt'])) { $post['intro'] = $content['mt_excerpt']; } //set category if (isset($content['categories'])) { $categoryTitle = ''; if (is_array($content['categories'])) { //always get the 1st option. currently not supported multi categories $categoryTitle = @$content['categories'][0]; } else { $categoryTitle = $content['categories']; } if (empty($categoryTitle)) { if ($isNew) { $post['category_id'] = 1; } // by default the 1 is the uncategorised. } else { $db = EasyBlogHelper::db(); $query = 'SELECT `id` FROM `#__easyblog_category`'; $query .= ' WHERE `title` = ' . $db->Quote($categoryTitle); $db->setQuery($query); $result = $db->loadResult(); if (!empty($result)) { $post['category_id'] = $result; } else { $post['category_id'] = 1; } } } else { if ($isNew) { $post['category_id'] = 1; } } $post['published'] = $publish; $post['private'] = $isPrivate; if (isset($content["post_status"])) { switch ($content["post_status"]) { case 'publish': $post['published'] = 1; break; case 'private': $post['published'] = 1; $post['private'] = 1; break; case 'draft': $post['published'] = 0; break; case 'schedule': $post['published'] = 2; break; case 'pending': default: $post['published'] = 0; break; } } // echo '<pre>'; // var_dump($post['published']); // var_dump($post['content']); // echo '</pre>'; // exit; // Do some timestamp voodoo $tzoffset = EasyBlogDateHelper::getOffSet(); $overwriteDate = false; if (!empty($content['date_created_gmt'])) { $date = EasyBlogHelper::getDate($content['date_created_gmt']); $blog->created = $date->toFormat(); } else { if (!empty($content['dateCreated'])) { $date = EasyBlogHelper::getDate($content['dateCreated']); //$date = EasyBlogDateHelper::dateWithOffSet( $content['dateCreated'] ); $today = EasyBlogHelper::getDate(); // somehow blogsy time always return the current time 5 sec faster. if ($date->toUnix() > $today->toUnix() + 5) { $post['published'] = 2; $overwriteDate['created'] = $today->toFormat(); $overwriteDate['publish_up'] = $date->toFormat(); } else { $blog->created = $date->toFormat(); $overwriteDate['created'] = $date->toFormat(); } // echo $date->toUnix(); // echo '##'; // echo $date->toFormat(); // echo '##'; // echo $today->toFormat(); // echo '##'; // echo $today->toUnix(); // echo '##'; // echo $today->toUnix() + 5; // exit; } else { if (!$isNew) { $date = EasyBlogDateHelper::dateWithOffSet($blog->created); $blog->created = $date->toFormat(); $date = EasyBlogDateHelper::dateWithOffSet($blog->publish_up); $blog->publish_up = $date->toFormat(); } } } // we bind this attribute incase if easyblog was a old version. $post['issitewide'] = '1'; //bind the inputs $blog->bind($post, true); $blog->intro = $post['intro']; $blog->content = $post['content']; $blog->created_by = $my->id; $blog->ispending = 0; //(empty($acl->rules->publish_entry)) ? 1 : 0; $blog->published = $post['published']; if ($overwriteDate !== false) { $blog->created = $overwriteDate['created']; if (isset($overwriteDate['publish_up'])) { $blog->publish_up = $overwriteDate['publish_up']; } } $blog->subscription = $allowSubscribe; $blog->frontpage = $showFrontpage; $blog->send_notification_emails = $sendEmails; $blog->permalink = empty($post['permalink']) ? EasyBlogHelper::getPermalink($blog->title) : $post['permalink']; // add in fancy box style. $postcontent = $blog->intro . $blog->content; // cater for wlw $pattern = '#<a.*?\\><img[^>]*><\\/a>#i'; preg_match_all($pattern, $postcontent, $matches); if ($matches && count($matches[0]) > 0) { foreach ($matches[0] as $match) { $input = $match; $largeImgPath = ''; //getting large image path $pattern = '#<a[^>]*>#i'; preg_match($pattern, $input, $anchors); if ($anchors) { preg_match('/href\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i', $anchors[0], $adata); if ($adata) { $largeImgPath = $adata[1]; } } $input = $match; $pattern = '#<img[^>]*>#i'; preg_match($pattern, $input, $images); if ($images) { preg_match('/src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i', $images[0], $data); if ($data) { $largeImgPath = empty($largeImgPath) ? $data[1] : $largeImgPath; $largeImgPath = urldecode($largeImgPath); $largeImgPath = str_replace(' ', '-', $largeImgPath); $encodedurl = urldecode($data[1]); $encodedurl = str_replace(' ', '-', $encodedurl); $images[0] = str_replace($data[1], $encodedurl, $images[0]); $blog->intro = str_replace($input, '<a class="easyblog-thumb-preview" href="' . $largeImgPath . '">' . $images[0] . '</a>', $blog->intro); $blog->content = str_replace($input, '<a class="easyblog-thumb-preview" href="' . $largeImgPath . '">' . $images[0] . '</a>', $blog->content); } } } } else { $pattern = '#<img[^>]*>#i'; preg_match_all($pattern, $postcontent, $matches); if ($matches && count($matches[0]) > 0) { foreach ($matches[0] as $match) { $input = $match; preg_match('/src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i', $input, $data); if ($data) { $oriImage = $data[1]; $data[1] = urldecode($data[1]); $data[1] = str_replace(' ', '-', $data[1]); $encodedurl = urldecode($oriImage); $encodedurl = str_replace(' ', '-', $encodedurl); $imageurl = str_replace($oriImage, $encodedurl, $input); $blog->intro = str_replace($input, '<a class="easyblog-thumb-preview" href="' . $data[1] . '">' . $imageurl . '</a>', $blog->intro); $blog->content = str_replace($input, '<a class="easyblog-thumb-preview" href="' . $data[1] . '">' . $imageurl . '</a>', $blog->content); } } } } 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); } // add new tag $date = EasyBlogHelper::getDate(); $tags = isset($content['mt_keywords']) ? $content['mt_keywords'] : ''; $postTagModel = EasyBlogHelper::getModel('PostTag'); if ($blog->id != '0') { //Delete existing associated tags. $postTagModel->deletePostTag($blog->id); } if (!empty($tags)) { $arrTags = explode(',', $tags); $tagModel = EasyBlogHelper::getModel('Tags'); foreach ($arrTags as $tag) { if (!empty($tag)) { $table = EasyBlogHelper::getTable('Tag', 'Table'); //@task: Only add tags if it doesn't exist. if (!$table->exists($tag)) { if ($acl->rules->create_tag) { $tagInfo['created_by'] = $my->id; $tagInfo['title'] = JString::trim($tag); $tagInfo['created'] = $date->toMySQL(); $table->bind($tagInfo); $table->published = 1; $table->status = ''; $table->store(); } } else { $table->load($tag, true); } //@task: Store in the post tag $postTagModel->add($table->id, $blog->id, $date->toMySQL()); } } } if ($blog->published) { $allowed = array(EBLOG_OAUTH_LINKEDIN, EBLOG_OAUTH_FACEBOOK, EBLOG_OAUTH_TWITTER); $blog->autopost($allowed, $allowed); } return new xmlrpcresp(new xmlrpcval($blog->id, $xmlrpcString)); }
/** * Called by status box to add new stream data * * @param type $message * @param type $attachment * @return type */ public function ajaxStreamAdd($message, $attachment, $streamFilter = FALSE) { $streamHTML = ''; // $attachment pending filter $cache = CFactory::getFastCache(); $cache->clean(array('activities')); $my = CFactory::getUser(); $userparams = $my->getParams(); if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } //@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')); } $message = JString::trim($message); $objResponse = new JAXResponse(); $rawMessage = $message; // @rule: Autolink hyperlinks // @rule: Autolink to users profile when message contains @username // $message = CUserHelper::replaceAliasURL($message); // the processing is done on display side $emailMessage = CUserHelper::replaceAliasURL($rawMessage, true); // @rule: Spam checks if ($config->get('antispam_akismet_status')) { $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(); } } $attachment = json_decode($attachment, true); switch ($attachment['type']) { case 'message': //if (!empty($message)) { switch ($attachment['element']) { case 'profile': //only update user status if share messgage is on his profile if (COwnerHelper::isMine($my->id, $attachment['target'])) { //save the message $status = $this->getModel('status'); /* If no privacy in attachment than we apply default: Public */ if (!isset($attachment['privacy'])) { $attachment['privacy'] = COMMUNITY_STATUS_PRIVACY_PUBLIC; } $status->update($my->id, $rawMessage, $attachment['privacy']); //set user status for current session. $today = JFactory::getDate(); $message2 = empty($message) ? ' ' : $message; $my->set('_status', $rawMessage); $my->set('_posted_on', $today->toSql()); // Order of replacement $order = array("\r\n", "\n", "\r"); $replace = '<br />'; // Processes \r\n's first so they aren't converted twice. $messageDisplay = str_replace($order, $replace, $message); $messageDisplay = CKses::kses($messageDisplay, CKses::allowed()); //update user status $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($messageDisplay) . "');"); } //if actor posted something to target, the privacy should be under target's profile privacy settings if (!COwnerHelper::isMine($my->id, $attachment['target']) && $attachment['target'] != '') { $attachment['privacy'] = CFactory::getUser($attachment['target'])->getParams()->get('privacyProfileView'); } //push to activity stream $act = new stdClass(); $act->cmd = 'profile.status.update'; $act->actor = $my->id; $act->target = $attachment['target']; $act->title = $message; $act->content = ''; $act->app = $attachment['element']; $act->cid = $my->id; $act->access = $attachment['privacy']; $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = 'profile.status'; $act->like_id = CActivities::LIKE_SELF; $act->like_type = 'profile.status'; $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; $act->target = 0; $act->title = $message; $act->content = ''; $act->app = 'groups.wall'; $act->cid = $attachment['target']; $act->groupid = $group->id; $act->group_access = $group->approvals; $act->eventid = 0; $act->access = 0; $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = 'groups.wall'; $act->like_id = CActivities::LIKE_SELF; $act->like_type = 'groups.wall'; $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(); $activityData = CApiActivities::add($act); CTags::add($activityData); CUserPoints::assignPoint('group.wall.create'); $recipient = CFactory::getUser($attachment['target']); $params = new CParameter(''); $params->set('message', $emailMessage); $params->set('group', $group->name); $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id, false)); //Get group member emails $model = CFactory::getModel('Groups'); $members = $model->getMembers($attachment['target'], null, true, false, true); $membersArray = array(); if (!is_null($members)) { foreach ($members as $row) { if ($my->id != $row->id) { $membersArray[] = $row->id; } } } $groupParams = new CParameter($group->params); if ($groupParams->get('wallnotification')) { CNotificationLibrary::add('groups_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT', $my->getDisplayName(), $group->name), '', 'groups.post', $params); } //@since 4.1 when a there is a new post in group, dump the data into group stats $statsModel = CFactory::getModel('stats'); $statsModel->addGroupStats($group->id, 'post'); // Add custom stream // Reload the stream with new stream data $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true)); break; // Message posted from Event page // Message posted from Event page case 'events': $eventLib = new CEvents(); $event = JTable::getInstance('Event', 'CTable'); $event->load($attachment['target']); // Permission check, only site admin and those who has // mark their attendance can post message if (!COwnerHelper::isCommunityAdmin() && !$event->isMember($my->id) && $config->get('lockeventwalls')) { $objResponse->addScriptCall("alert('permission denied');"); return $objResponse->sendResponse(); } // If this is a group event, set the group object $groupid = $event->type == 'group' ? $event->contentid : 0; // $groupLib = new CGroups(); $group = JTable::getInstance('Group', 'CTable'); $group->load($groupid); $act = new stdClass(); $act->cmd = 'events.wall'; $act->actor = $my->id; $act->target = 0; $act->title = $message; $act->content = ''; $act->app = 'events.wall'; $act->cid = $attachment['target']; $act->groupid = $event->type == 'group' ? $event->contentid : 0; $act->group_access = $group->approvals; $act->eventid = $event->id; $act->event_access = $event->permission; $act->access = 0; $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = 'events.wall'; $act->like_id = CActivities::LIKE_SELF; $act->like_type = 'events.wall'; $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(); $activityData = CApiActivities::add($act); CTags::add($activityData); // add points CUserPoints::assignPoint('event.wall.create'); $params = new CParameter(''); $params->set('message', $emailMessage); $params->set('event', $event->title); $params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id); $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false)); //Get event member emails $members = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE); $membersArray = array(); if (!is_null($members)) { foreach ($members as $row) { if ($my->id != $row->id) { $membersArray[] = $row->id; } } } CNotificationLibrary::add('events_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT_EVENTS', $my->getDisplayName(), $event->title), '', 'events.post', $params); //@since 4.1 when a there is a new post in event, dump the data into event stats $statsModel = CFactory::getModel('stats'); $statsModel->addEventStats($event->id, 'post'); // Reload the stream with new stream data $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true)); break; } $objResponse->addScriptCall('__callback', ''); // /} break; case 'photo': switch ($attachment['element']) { case 'profile': $photoIds = $attachment['id']; //use User Preference for Privacy //$privacy = $userparams->get('privacyPhotoView'); //$privacy = $attachment['privacy']; $photo = JTable::getInstance('Photo', 'CTable'); if (!isset($photoIds[0]) || $photoIds[0] <= 0) { //$objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption)); exit; } //always get album id from the photo itself, do not let it assign by params from user post data $photoModel = CFactory::getModel('photos'); $photo = $photoModel->getPhoto($photoIds[0]); /* OK ! If album_id is not provided than we use album id from photo ( it should be default album id ) */ $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid; $album = JTable::getInstance('Album', 'CTable'); $album->load($albumid); $privacy = $album->permissions; //limit checking // $photoModel = CFactory::getModel( 'photos' ); // $config = CFactory::getConfig(); // $total = $photoModel->getTotalToday( $my->id ); // $max = $config->getInt( 'limit_photo_perday' ); // $remainingUploadCount = $max - $total; $params = array(); foreach ($photoIds as $key => $photoId) { if (CLimitsLibrary::exceedDaily('photos')) { unset($photoIds[$key]); continue; } $photo->load($photoId); $photo->permissions = $privacy; $photo->published = 1; $photo->status = 'ready'; $photo->albumid = $albumid; /* We must update this photo into correct album id */ $photo->store(); $params[] = clone $photo; } if ($config->get('autoalbumcover') && !$album->photoid) { $album->photoid = $photoIds[0]; $album->store(); } // Break if no photo added, which is likely because of daily limit. if (count($photoIds) < 1) { $objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_PHOTO_UPLOAD_LIMIT_EXCEEDED')); return $objResponse->sendResponse(); } // Trigger onPhotoCreate // $apps = CAppPlugins::getInstance(); $apps->loadApplications(); $apps->triggerEvent('onPhotoCreate', array($params)); $act = new stdClass(); $act->cmd = 'photo.upload'; $act->actor = $my->id; $act->access = $privacy; //$attachment['privacy']; $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target']; $act->title = $message; $act->content = ''; // Generated automatically by stream. No need to add anything $act->app = 'photos'; $act->cid = $albumid; $act->location = $album->location; /* Comment and like for individual photo upload is linked * to the photos itsel */ $act->comment_id = $photo->id; $act->comment_type = 'photos'; $act->like_id = $photo->id; $act->like_type = 'photo'; $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id; $albumUrl = CRoute::_($albumUrl); $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id; $photoUrl = CRoute::_($photoUrl); $params = new CParameter(''); $params->set('multiUrl', $albumUrl); $params->set('photoid', $photo->id); $params->set('action', 'upload'); $params->set('stream', '1'); $params->set('photo_url', $photoUrl); $params->set('style', COMMUNITY_STREAM_STYLE); $params->set('photosId', implode(',', $photoIds)); if (count($photoIds > 1)) { $params->set('count', count($photoIds)); $params->set('batchcount', count($photoIds)); } //Store mood in param if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') { $params->set('mood', $attachment['mood']); } // Add activity logging // CActivityStream::remove($act->app, $act->cid); $activityData = CActivityStream::add($act, $params->toString()); // Add user points CUserPoints::assignPoint('photo.upload'); //add a notification to the target user if someone posted photos on target's profile if ($my->id != $attachment['target']) { $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_NOTIFICATION_STREAM_PHOTO_POST', count($photoIds)), '', 'wall.post', $params); } //email and add notification if user are tagged CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment')); $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption)); break; case 'events': $event = JTable::getInstance('Event', 'CTable'); $event->load($attachment['target']); $privacy = 0; //if this is a group event, we need to follow the group privacy if ($event->type == 'group' && $event->contentid) { $group = JTable::getInstance('Group', 'CTable'); $group->load(${$event}->contentid); $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0; } $photoIds = $attachment['id']; $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoIds[0]); $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid; $album = JTable::getInstance('Album', 'CTable'); $album->load($albumid); $params = array(); foreach ($photoIds as $photoId) { $photo->load($photoId); $photo->caption = $message; $photo->permissions = $privacy; $photo->published = 1; $photo->status = 'ready'; $photo->albumid = $albumid; $photo->store(); $params[] = clone $photo; } // Trigger onPhotoCreate // $apps = CAppPlugins::getInstance(); $apps->loadApplications(); $apps->triggerEvent('onPhotoCreate', array($params)); $act = new stdClass(); $act->cmd = 'photo.upload'; $act->actor = $my->id; $act->access = $privacy; $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target']; $act->title = $message; //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name ); $act->content = ''; // Generated automatically by stream. No need to add anything $act->app = 'photos'; $act->cid = $album->id; $act->location = $album->location; $act->eventid = $event->id; $act->group_access = $privacy; // just in case this event belongs to a group //$act->access = $attachment['privacy']; /* Comment and like for individual photo upload is linked * to the photos itsel */ $act->comment_id = $photo->id; $act->comment_type = 'photos'; $act->like_id = $photo->id; $act->like_type = 'photo'; $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id; $albumUrl = CRoute::_($albumUrl); $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id; $photoUrl = CRoute::_($photoUrl); $params = new CParameter(''); $params->set('multiUrl', $albumUrl); $params->set('photoid', $photo->id); $params->set('action', 'upload'); $params->set('stream', '1'); // this photo uploaded from status stream $params->set('photo_url', $photoUrl); $params->set('style', COMMUNITY_STREAM_STYLE); // set stream style $params->set('photosId', implode(',', $photoIds)); // Add activity logging if (count($photoIds > 1)) { $params->set('count', count($photoIds)); $params->set('batchcount', count($photoIds)); } //Store mood in paramm if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') { $params->set('mood', $attachment['mood']); } // CActivityStream::remove($act->app, $act->cid); $activityData = CActivityStream::add($act, $params->toString()); // Add user points CUserPoints::assignPoint('photo.upload'); // Reload the stream with new stream data $eventLib = new CEvents(); $event = JTable::getInstance('Event', 'CTable'); $event->load($attachment['target']); $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true)); $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption)); break; case 'groups': // $groupLib = new CGroups(); $group = JTable::getInstance('Group', 'CTable'); $group->load($attachment['target']); $photoIds = $attachment['id']; $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0; $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoIds[0]); $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid; $album = JTable::getInstance('Album', 'CTable'); $album->load($albumid); $params = array(); foreach ($photoIds as $photoId) { $photo->load($photoId); $photo->caption = $message; $photo->permissions = $privacy; $photo->published = 1; $photo->status = 'ready'; $photo->albumid = $albumid; $photo->store(); $params[] = clone $photo; } // Trigger onPhotoCreate // $apps = CAppPlugins::getInstance(); $apps->loadApplications(); $apps->triggerEvent('onPhotoCreate', array($params)); $act = new stdClass(); $act->cmd = 'photo.upload'; $act->actor = $my->id; $act->access = $privacy; $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target']; $act->title = $message; //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name ); $act->content = ''; // Generated automatically by stream. No need to add anything $act->app = 'photos'; $act->cid = $album->id; $act->location = $album->location; $act->groupid = $group->id; $act->group_access = $group->approvals; $act->eventid = 0; //$act->access = $attachment['privacy']; /* Comment and like for individual photo upload is linked * to the photos itsel */ $act->comment_id = $photo->id; $act->comment_type = 'photos'; $act->like_id = $photo->id; $act->like_type = 'photo'; $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id; $albumUrl = CRoute::_($albumUrl); $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id; $photoUrl = CRoute::_($photoUrl); $params = new CParameter(''); $params->set('multiUrl', $albumUrl); $params->set('photoid', $photo->id); $params->set('action', 'upload'); $params->set('stream', '1'); // this photo uploaded from status stream $params->set('photo_url', $photoUrl); $params->set('style', COMMUNITY_STREAM_STYLE); // set stream style $params->set('photosId', implode(',', $photoIds)); // Add activity logging if (count($photoIds > 1)) { $params->set('count', count($photoIds)); $params->set('batchcount', count($photoIds)); } //Store mood in paramm if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') { $params->set('mood', $attachment['mood']); } // CActivityStream::remove($act->app, $act->cid); $activityData = CActivityStream::add($act, $params->toString()); // Add user points CUserPoints::assignPoint('photo.upload'); // Reload the stream with new stream data $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true)); $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption)); break; dafault: return; } break; case 'video': switch ($attachment['element']) { case 'profile': // attachment id $fetch = $attachment['fetch']; $cid = $fetch[0]; $privacy = isset($attachment['privacy']) ? $attachment['privacy'] : COMMUNITY_STATUS_PRIVACY_PUBLIC; $video = JTable::getInstance('Video', 'CTable'); $video->load($cid); $video->set('creator_type', VIDEO_USER_TYPE); $video->set('status', 'ready'); $video->set('permissions', $privacy); $video->set('title', $fetch[3]); $video->set('description', $fetch[4]); $video->set('category_id', $fetch[5]); /* Save cords if exists */ if (isset($attachment['location'])) { $video->set('location', $attachment['location'][0]); $video->set('latitude', $attachment['location'][1]); $video->set('longitude', $attachment['location'][2]); } // Add activity logging $url = $video->getViewUri(false); $act = new stdClass(); $act->cmd = 'videos.linking'; $act->actor = $my->id; $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target']; $act->access = $privacy; //filter empty message $act->title = $message; $act->app = 'videos.linking'; $act->content = ''; $act->cid = $video->id; $act->location = $video->location; /* 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]; } $act->comment_id = $video->id; $act->comment_type = 'videos.linking'; $act->like_id = $video->id; $act->like_type = 'videos.linking'; $params = new CParameter(''); $params->set('video_url', $url); $params->set('style', COMMUNITY_STREAM_STYLE); // set stream style //Store mood in paramm if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') { $params->set('mood', $attachment['mood']); } // $activityData = CActivityStream::add($act, $params->toString()); //this video must be public because it's posted on someone else's profile if ($my->id != $attachment['target']) { $video->set('permissions', COMMUNITY_STATUS_PRIVACY_PUBLIC); $params = new CParameter(); $params->set('activity_id', $activityData->id); // activity id is used to remove the activity if someone deleted this video $params->set('target_id', $attachment['target']); $video->params = $params->toString(); //also send a notification to the user $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::_('COM_COMMUNITY_NOTIFICATION_STREAM_VIDEO_POST'), '', 'wall.post', $params); } $video->store(); // @rule: Add point when user adds a new video link // CUserPoints::assignPoint('video.add', $video->creator); //email and add notification if user are tagged CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment')); // Trigger for onVideoCreate // $apps = CAppPlugins::getInstance(); $apps->loadApplications(); $params = array(); $params[] = $video; $apps->triggerEvent('onVideoCreate', $params); $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES)); $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title)); break; case 'groups': // attachment id $fetch = $attachment['fetch']; $cid = $fetch[0]; $privacy = 0; //$attachment['privacy']; $video = JTable::getInstance('Video', 'CTable'); $video->load($cid); $video->set('status', 'ready'); $video->set('groupid', $attachment['target']); $video->set('permissions', $privacy); $video->set('creator_type', VIDEO_GROUP_TYPE); $video->set('title', $fetch[3]); $video->set('description', $fetch[4]); $video->set('category_id', $fetch[5]); /* Save cords if exists */ if (isset($attachment['location'])) { $video->set('location', $attachment['location'][0]); $video->set('latitude', $attachment['location'][1]); $video->set('longitude', $attachment['location'][2]); } $video->store(); // $groupLib = new CGroups(); $group = JTable::getInstance('Group', 'CTable'); $group->load($attachment['target']); // Add activity logging $url = $video->getViewUri(false); $act = new stdClass(); $act->cmd = 'videos.linking'; $act->actor = $my->id; $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target']; $act->access = $privacy; //filter empty message $act->title = $message; $act->app = 'videos'; $act->content = ''; $act->cid = $video->id; $act->groupid = $video->groupid; $act->group_access = $group->approvals; $act->location = $video->location; /* 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]; } $act->comment_id = $video->id; $act->comment_type = 'videos'; $act->like_id = $video->id; $act->like_type = 'videos'; $params = new CParameter(''); $params->set('video_url', $url); $params->set('style', COMMUNITY_STREAM_STYLE); // set stream style //Store mood in paramm if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') { $params->set('mood', $attachment['mood']); } $activityData = CActivityStream::add($act, $params->toString()); // @rule: Add point when user adds a new video link CUserPoints::assignPoint('video.add', $video->creator); // Trigger for onVideoCreate $apps = CAppPlugins::getInstance(); $apps->loadApplications(); $params = array(); $params[] = $video; $apps->triggerEvent('onVideoCreate', $params); $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES)); $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title)); // Reload the stream with new stream data $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true)); break; case 'events': //event videos $fetch = $attachment['fetch']; $cid = $fetch[0]; $privacy = 0; //$attachment['privacy']; $video = JTable::getInstance('Video', 'CTable'); $video->load($cid); $video->set('status', 'ready'); $video->set('eventid', $attachment['target']); $video->set('permissions', $privacy); $video->set('creator_type', VIDEO_EVENT_TYPE); $video->set('title', $fetch[3]); $video->set('description', $fetch[4]); $video->set('category_id', $fetch[5]); /* Save cords if exists */ if (isset($attachment['location'])) { $video->set('location', $attachment['location'][0]); $video->set('latitude', $attachment['location'][1]); $video->set('longitude', $attachment['location'][2]); } $video->store(); // $eventLib = new CEvents(); $event = JTable::getInstance('Event', 'CTable'); $event->load($attachment['target']); $group = new stdClass(); if ($event->type == 'group' && $event->contentid) { // check if this a group event, and follow the permission $group = JTable::getInstance('Group', 'CTable'); $group->load($event->contentid); } // Add activity logging $url = $video->getViewUri(false); $act = new stdClass(); $act->cmd = 'videos.linking'; $act->actor = $my->id; $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target']; $act->access = $privacy; //filter empty message $act->title = $message; $act->app = 'videos'; $act->content = ''; $act->cid = $video->id; $act->groupid = 0; $act->group_access = isset($group->approvals) ? $group->approvals : 0; // if this is a group event $act->location = $video->location; /* 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]; } $act->eventid = $event->id; $act->comment_id = $video->id; $act->comment_type = 'videos'; $act->like_id = $video->id; $act->like_type = 'videos'; $params = new CParameter(''); $params->set('video_url', $url); $params->set('style', COMMUNITY_STREAM_STYLE); // set stream style //Store mood in paramm if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') { $params->set('mood', $attachment['mood']); } $activityData = CActivityStream::add($act, $params->toString()); // @rule: Add point when user adds a new video link CUserPoints::assignPoint('video.add', $video->creator); // Trigger for onVideoCreate $apps = CAppPlugins::getInstance(); $apps->loadApplications(); $params = array(); $params[] = $video; $apps->triggerEvent('onVideoCreate', $params); $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES)); $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title)); // Reload the stream with new stream data $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true)); break; default: return; } break; case 'event': switch ($attachment['element']) { case 'profile': require_once COMMUNITY_COM_PATH . '/controllers/events.php'; $eventController = new CommunityEventsController(); // Assign default values where necessary $attachment['description'] = $message; $attachment['ticket'] = 0; $attachment['offset'] = 0; $event = $eventController->ajaxCreate($attachment, $objResponse); $objResponse->addScriptCall('window.location="' . $event->getLink() . '";'); if (CFactory::getConfig()->get('event_moderation')) { $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title)); } break; case 'groups': require_once COMMUNITY_COM_PATH . '/controllers/events.php'; $eventController = new CommunityEventsController(); // $groupLib = new CGroups(); $group = JTable::getInstance('Group', 'CTable'); $group->load($attachment['target']); // Assign default values where necessary $attachment['description'] = $message; $attachment['ticket'] = 0; $attachment['offset'] = 0; $event = $eventController->ajaxCreate($attachment, $objResponse); CEvents::addGroupNotification($event); $objResponse->addScriptCall('window.location="' . $event->getLink() . '";'); // Reload the stream with new stream data $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true)); if (CFactory::getConfig()->get('event_moderation')) { $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title)); } break; } break; case 'link': break; } //no matter what kind of message it is, always filter the hashtag if there's any if (!empty($act->title) && isset($activityData->id) && $activityData->id) { //use model to check if this has a tag in it and insert into the table if possible $hashtags = CContentHelper::getHashTags($act->title); if (count($hashtags)) { //$hashTag $hashtagModel = CFactory::getModel('hashtags'); foreach ($hashtags as $tag) { $hashtagModel->addActivityHashtag($tag, $activityData->id); } } } // Frontpage filter if ($streamFilter != false) { $streamFilter = json_decode($streamFilter); $filter = $streamFilter->filter; $value = $streamFilter->value; $extra = false; // Append added data to the list. if (isset($activityData) && $activityData->id) { $model = CFactory::getModel('Activities'); $extra = $model->getActivity($activityData->id); } switch ($filter) { case 'privacy': if ($value == 'me-and-friends' && $my->id != 0) { $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra); } else { $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra); } break; case 'apps': $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array('apps' => array($value)), $extra); break; case 'hashtag': $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array($filter => $value), $extra); break; default: $defaultFilter = $config->get('frontpageactivitydefault'); if ($defaultFilter == 'friends' && $my->id != 0) { $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra); } else { $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra); } break; } } if (!isset($attachment['filter'])) { $attachment['filter'] = ''; $filter = $config->get('frontpageactivitydefault'); $filter = explode(':', $filter); $attachment['filter'] = isset($filter[1]) ? $filter[1] : $filter[0]; } if (empty($streamHTML)) { if (!isset($attachment['target'])) { $attachment['target'] = ''; } if (!isset($attachment['element'])) { $attachment['element'] = ''; } $streamHTML = CActivities::getActivitiesByFilter($attachment['filter'], $attachment['target'], $attachment['element'], true, array('show_featured' => true, 'showLatestActivityOnTop' => true)); } $objResponse->addAssign('activity-stream-container', 'innerHTML', $streamHTML); // Log user engagement CEngagement::log($attachment['type'] . '.share', $my->id); return $objResponse->sendResponse(); }
/** * 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); }
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)); }
/** * 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(); }
/** * 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'); } if ($type == 'event') { $event = JTable::getInstance('Event', 'CTable'); $event->load($parentId); $group = JTable::getInstance('Group', 'CTable'); $group->load($event->contentid); if ($group->approvals == 1) { $addStream = false; } } if ($addStream) { // Add activity logging if ($type != 'profile' || $type == 'profile' && $parentId == $my->id) { CActivityStream::add($act, $params->toString()); } } echo json_encode($msg); exit; } }
/** * 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; }
public function ajaxAddApp($name, $position) { // Check permissions $my = CFactory::getUser(); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $filter = JFilterInput::getInstance(); $name = $filter->clean($name, 'string'); $position = $filter->clean($position, 'string'); // Add application $appModel = CFactory::getModel('apps'); $appModel->addApp($my->id, $name, $position); // Activity stream $act = new stdClass(); $act->cmd = 'application.add'; $act->actor = $my->id; $act->target = 0; $act->title = ''; //JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED'); $act->content = ''; $act->app = 'app.install'; $act->cid = 0; // application id $params = new JRegistry(''); $params->set('app', $name); //CActivityStream::addActor( $act, $params->toString() ); // User points //CFactory::load( 'libraries' , 'userpoints' ); CUserPoints::assignPoint('application.add'); // Get application $id = $appModel->getUserApplicationId($name, $my->id); $appInfo = $appModel->getAppInfo($name); $params = new CParameter($appModel->getPluginParams($id, null)); $isCoreApp = $appInfo->coreapp; $app = new stdClass(); $app->id = $id; $app->title = isset($appInfo->title) ? $appInfo->title : ''; $app->description = isset($appInfo->description) ? $appInfo->description : ''; $app->isCoreApp = $isCoreApp; $app->name = $name; if ($appInfo->customFavicon != '') { $app->favicon['64'] = JURI::root(true) . '/' . $appInfo->customFavicon; } elseif (JFile::exists(CPluginHelper::getPluginPath('community', $name) . '/favicon_64.png')) { $app->favicon['64'] = JURI::root(true) . CPluginHelper::getPluginURI('community', $name) . '/' . $name . '/favicon_64.png'; } else { $app->favicon['64'] = JURI::root(true) . '/components/com_community/assets/app_avatar.png'; } $tmpl = new CTemplate(); $tmpl->set('apps', array($app)); $tmpl->set('itemType', 'edit'); $tmpl->set('position', $position); $html = $tmpl->fetch('application.item'); $json = array('success' => true, 'title' => $app->title, 'item' => $html, 'id' => $app->id); die(json_encode($json)); }
public function onAfterThankyou($actor, $target, $message) { CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('com_kunena.thread.thankyou', $target); $actor = CFactory::getUser($actor); $target = CFactory::getUser($target); //Create CParameter use for params $params = new CParameter(''); $params->set('actorName', $actor->getDisplayName()); $params->set('recipientName', $target->getDisplayName()); $params->set('recipientUrl', 'index.php?option=com_community&view=profile&userid=' . $target->id); // Actor Link $params->set('url', JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null)); // {url} tag for activity. Used when hovering over avatar in notification window, as well as in email notification $params->set('title', $message->displayField('subject')); // (title) tag in language file $params->set('title_url', $message->getPermaUrl()); // Make the title in notification - linkable $params->set('message', $message->message); // (message) tag in language file $params->set('actor', $actor->getDisplayName()); // Actor in the stream $params->set('actor_url', 'index.php?option=com_community&view=profile&userid=' . $actor->id); // Actor Link // Finally, send notifications CNotificationLibrary::add('kunena_thankyou', $actor->id, $target->id, JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_TITLE_ACT'), JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_TEXT'), '', $params); $act = new stdClass(); $act->cmd = 'wall.write'; $act->actor = $actor->id; $act->target = $target->id; $act->title = JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_WALL', $params->get('actor_url'), $params->get('actor'), $params->get('recipientUrl'), $params->get('recipientName'), $params->get('url'), $params->get('title')); $act->content = NULL; $act->app = 'kunena.message.thankyou'; $act->cid = $target->id; $act->access = $this->getAccess($message->getCategory()); // Comments and like support $act->comment_id = $target->id; $act->comment_type = 'kunena.message.thankyou'; $act->like_id = $target->id; $act->like_type = 'kunena.message.thankyou'; // Do not add private activities if ($act->access > 20) { return; } CFactory::load('libraries', 'activities'); $table = CActivityStream::add($act); if (is_object($table)) { $table->like_id = $table->id; $table->store(); } }
/** * */ public static function joinApproved($groupId, $userid) { $group = JTable::getInstance('Group', 'CTable'); $member = JTable::getInstance('GroupMembers', 'CTable'); $group->load($groupId); $act = new stdClass(); $act->cmd = 'group.join'; $act->actor = $userid; $act->target = 0; $act->title = ''; //JText::sprintf('COM_COMMUNITY_GROUPS_GROUP_JOIN' , '{group_url}' , $group->name ); $act->content = ''; $act->app = 'groups.join'; $act->cid = $group->id; $act->groupid = $group->id; $params = new CParameter(''); $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $params->set('action', 'group.join'); // Add logging if (CUserPoints::assignPoint('group.join')) { CActivityStream::addActor($act, $params->toString()); } // Store the group and update stats $group->updateStats(); $group->store(); }
public function onAfterThankyou($thankyoutargetid, $username, $message) { CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('com_kunena.thread.thankyou', $thankyoutargetid); if (!empty($message->parent)) { //activity stream - reply post require_once KPATH_SITE . '/lib/kunena.link.class.php'; $JSPostLink = CKunenaLink::GetThreadPageURL('view', $message->get('catid'), $message->get('thread'), 1); $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="' . $JSPostLink . '">' . $message->get('subject') . '</a> '); $act->content = NULL; $act->app = 'kunena.thankyou'; $act->cid = $thankyoutargetid; $act->access = $this->getAccess($message); CFactory::load('libraries', 'activities'); CActivityStream::add($act); } }
public function addActivityLikes($post, $question) { $core = JPATH_ROOT . '/components/com_community/libraries/core.php'; $config = DiscussHelper::getConfig(); $my = JFactory::getUser(); if (!JFile::exists($core)) { return false; } require_once $core; // @rule: Insert points for user. if ($config->get('integration_jomsocial_points')) { CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('com_easydiscuss.like.discussion', $my->id); } $lang = JFactory::getLanguage(); $lang->load('com_easydiscuss', JPATH_ROOT); // We do not want to add activities if new blog activity is disabled. if (!$config->get('integration_jomsocial_activity_likes')) { return false; } //get category privacy. $category = DiscussHelper::getTable('Category'); $category->load($question->category_id); $link = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $question->id, false, true); $replyLink = $link . '#' . JText::_('COM_EASYDISCUSS_REPLY_PERMALINK') . '-' . $post->id; $title = $this->getActivityTitle($question->title); $streamTitle = ''; if (!empty($post->parent_id)) { //this reply added into reply section. $streamTitle = JText::sprintf('COM_EASYDISCUSS_JOMSOCIAL_ACTIVITY_LIKE_REPLY', $replyLink, $link, $title); } else { //this reply added into question section. $streamTitle = JText::sprintf('COM_EASYDISCUSS_JOMSOCIAL_ACTIVITY_LIKE_QUESTION', $link, $title); } $obj = new stdClass(); $obj->access = $this->getActivityAccess(); $obj->title = $streamTitle; $obj->content = ''; $obj->cmd = 'easydiscuss.question.like'; $obj->actor = $my->id; $obj->target = 0; $obj->like_id = $question->id; $obj->like_type = 'com_easydiscuss'; $obj->comment_id = $question->id; $obj->comment_type = 'com_easydiscuss'; $obj->app = 'easydiscuss'; $obj->cid = $question->id; // add JomSocial activities CFactory::load('libraries', 'activities'); CActivityStream::add($obj); }
public function ajaxAddApp($name, $position) { // Check permissions $my =& JFactory::getUser(); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $filter = JFilterInput::getInstance(); $name = $filter->clean($name, 'string'); $position = $filter->clean($position, 'string'); // Add application $appModel = CFactory::getModel('apps'); $appModel->addApp($my->id, $name, $position); // Activity stream $act = new stdClass(); $act->cmd = 'application.add'; $act->actor = $my->id; $act->target = 0; $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED'); $act->content = ''; $act->app = $name; $act->cid = $my->id; CFactory::load('libraries', 'activities'); CActivityStream::add($act); // User points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('application.add'); // Get application $id = $appModel->getUserApplicationId($name, $my->id); $appInfo = $appModel->getAppInfo($name); $params = new CParameter($appModel->getPluginParams($id, null)); $isCoreApp = $params->get('coreapp'); $app->id = $id; $app->title = isset($appInfo->title) ? $appInfo->title : ''; $app->description = isset($appInfo->description) ? $appInfo->description : ''; $app->isCoreApp = $isCoreApp; $app->name = $name; if (JFile::exists(CPluginHelper::getPluginPath('community', $name) . DS . $name . DS . 'favicon.png')) { $app->favicon['16'] = rtrim(JURI::root(), '/') . CPluginHelper::getPluginURI('community', $name) . '/' . $name . '/favicon.png'; } else { $app->favicon['16'] = rtrim(JURI::root(), '/') . '/components/com_community/assets/app_favicon.png'; } $tmpl = new CTemplate(); $tmpl->set('apps', array($app)); $tmpl->set('itemType', 'edit'); $html = $tmpl->fetch('application.item'); $objResponse = new JAXResponse(); $objResponse->addScriptCall('joms.apps.showSettingsWindow', $app->id, $app->name); $objResponse->addScriptCall('joms.editLayout.addAppToLayout', $position, $html); // $objResponse->addScriptCall('cWindowHide();'); return $objResponse->sendResponse(); }
public function ajaxRemoveWall($wallId) { $filter = JFilterInput::getInstance(); $wallId = $filter->clean($wallId, 'int'); CError::assert($wallId, '', '!empty', __FILE__, __LINE__); $response = new JAXResponse(); CFactory::load('helpers', 'owner'); if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } //@rule: Check if user is really allowed to remove the current wall $my = CFactory::getUser(); $wallModel =& $this->getModel('wall'); $wall = $wallModel->get($wallId); $eventModel =& $this->getModel('events'); $event =& JTable::getInstance('Event', 'CTable'); $event->load($wall->contentid); if (!COwnerHelper::isCommunityAdmin() && !$event->isAdmin($my->id)) { $response->addScriptCall('alert', JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_REMOVE_WALL')); } else { if (!$wallModel->deletePost($wallId)) { $response->addAlert(JText::_('COM_COMMUNITY_GROUPS_REMOVE_WALL_ERROR')); } else { if ($wall->post_by != 0) { //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('wall.remove', $wall->post_by); } } // Substract the count $event->substractWallCount(); } $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES)); return $response->sendResponse(); }
public static function addJomSocialPoint($action, $userId = 0) { $my = JFactory::getUser(); if (!empty($userId)) { $my = JFactory::getUser($userId); } if ($my->id != 0) { $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($action, $my->id); } } return true; }
public function addLike($element, $itemId) { $my = CFactory::getUser(); $like = JTable::getInstance('Like', 'CTable'); $like->loadInfo($element, $itemId); $like->element = $element; $like->uid = $itemId; // Check if user already like $likesInArray = explode(',', trim($like->like, ',')); /* Like once time */ if (in_array($my->id, $likesInArray)) { return; } array_push($likesInArray, $my->id); $likesInArray = array_unique($likesInArray); $like->like = ltrim(implode(',', $likesInArray), ','); // Check if the user already dislike $dislikesInArray = explode(',', trim($like->dislike, ',')); if (in_array($my->id, $dislikesInArray)) { // Remove user dislike from array $key = array_search($my->id, $dislikesInArray); unset($dislikesInArray[$key]); $like->dislike = implode(',', $dislikesInArray); } switch ($element) { case 'comment': //get the instance of the wall $wall = JTable::getInstance('Wall', 'CTable'); $wall->load($itemId); if (!$wall->id) { break; } if ($wall->type == "profile.status") { $wall->type = "profile"; } //load the stream id from activity stream $stream = JTable::getInstance('Activity', 'CTable'); $stream->load(array('comment_id' => $wall->contentid, 'app' => $wall->type)); if ($stream->id) { $profile = CFactory::getUser($stream->actor); $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id . '#activity-stream-container'; $params = new CParameter(''); $params->set('url', $url); $params->set('comment', JText::_('COM_COMMUNITY_SINGULAR_COMMENT')); $params->set('comment_url', $url); $params->set('actor', $my->getDisplayName()); //add to notifications CNotificationLibrary::add('comments_like', $my->id, $wall->post_by, JText::sprintf('COM_COMMUNITY_PROFILE_WALL_LIKE_EMAIL_SUBJECT'), '', 'comments.like', $params); } break; case 'photo': $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($itemId); if ($photo->id) { $url = $photo->getRawPhotoURI(); $params = new CParameter(''); $params->set('url', $url); $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO')); $params->set('photo_url', $url); CNotificationLibrary::add('photos_like', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_PHOTO_LIKE_EMAIL_SUBJECT'), '', 'photos.like', $params); /* Adding user points */ CUserPoints::assignPoint('photos.like'); } break; case 'album': $album = JTable::getInstance('Album', 'CTable'); $album->load($itemId); if ($album->id) { if ($album->groupid) { $url = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $album->groupid; } else { $url = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id; } $params = new CParameter(''); $params->set('url', $url); $params->set('album', $album->name); $params->set('album_url', $url); CNotificationLibrary::add('photos_like', $my->id, $album->creator, JText::sprintf('COM_COMMUNITY_ALBUM_LIKE_EMAIL_SUBJECT'), '', 'album.like', $params); /* Adding user points */ CUserPoints::assignPoint('album.like'); } break; case 'videos': $video = JTable::getInstance('Video', 'CTable'); $video->load($itemId); if ($video->id) { if ($video->groupid) { $url = 'index.php?option=com_community&view=videos&task=video&groupid=' . $video->groupid . '&videoid=' . $video->id; } else { $url = 'index.php?option=com_community&view=videos&task=video&videoid=' . $video->id; } $params = new CParameter(''); $params->set('url', $url); $params->set('video', $video->title); $params->set('video_url', $url); CNotificationLibrary::add('videos_like', $my->id, $video->creator, JText::sprintf('COM_COMMUNITY_VIDEO_LIKE_EMAIL_SUBJECT'), '', 'videos.like', $params); /* Adding user points */ CUserPoints::assignPoint('videos.like'); } break; case 'profile': $profile = CFactory::getUser($itemId); if ($profile->id) { $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id; $params = new CParameter(''); $params->set('url', $url); $params->set('profile', strtolower(JText::_('COM_COMMUNITY_NOTIFICATIONGROUP_PROFILE'))); $params->set('profile_url', $url); CNotificationLibrary::add('profile_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_LIKE_EMAIL_SUBJECT'), '', 'profile.like', $params); /* Adding user points */ CUserPoints::assignPoint('profile.like'); } break; case 'profile.status': $stream = JTable::getInstance('Activity', 'CTable'); $stream->load($itemId); if ($stream->id) { $profile = CFactory::getUser($stream->actor); $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id; $params = new CParameter(''); $params->set('url', $url); $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM')); $params->set('stream_url', $url); CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_STREAM_LIKE_EMAIL_SUBJECT'), '', 'profile.stream.like', $params); /* Adding user points */ CUserPoints::assignPoint('profile.stream.like'); } break; case 'cover.upload': $photo = JTable::getInstance('Photo', 'CTable'); $photo->load(CPhotosHelper::getPhotoOfStream($itemId)); if ($photo->id) { $url = $photo->getRawPhotoURI(); $params = new CParameter(''); $params->set('url', $url); $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO')); $params->set('photo_url', $url); CNotificationLibrary::add('photos_like', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_COVER_LIKE_EMAIL_SUBJECT'), '', 'photos.like', $params); /* Adding user points */ CUserPoints::assignPoint('photos.like'); } break; case 'profile.avatar.upload': $stream = JTable::getInstance('Activity', 'CTable'); $stream->load($itemId); if ($stream->id) { $profile = CFactory::getUser($stream->actor); $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id; $params = new CParameter(''); $params->set('url', $url); $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM')); $params->set('stream_url', $url); CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_AVATAR_LIKE_EMAIL_SUBJECT'), '', 'profile.stream.like', $params); /* Adding user points */ CUserPoints::assignPoint('profile.stream.like'); } break; case 'album.self.share': $stream = JTable::getInstance('Activity', 'CTable'); $stream->load($itemId); $profile = CFactory::getUser($stream->actor); //get total photo(s) uploaded and determine the string $actParam = new CParameter($stream->params); if ($actParam->get('batchcount') > 1) { $content = JText::sprintf('COM_COMMUNITY_ACTIVITY_ALBUM_PICTURES_LIKE_SUBJECT'); } else { $content = JText::sprintf('COM_COMMUNITY_ACTIVITY_ALBUM_PICTURE_LIKE_SUBJECT'); } $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id; $params = new CParameter(''); $params->set('url', $url); $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM')); $params->set('stream_url', $url); CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, $content, '', 'profile.stream.like', $params); default: CUserPoints::assignPoint($element . '.like'); } // Log user engagement CEngagement::log($element . '.like', $my->id); $like->store(); }
public function onAfterThankyou($thankyoutargetid, $username , $message) { CFactory::load ( 'libraries', 'userpoints' ); CUserPoints::assignPoint ( 'com_kunena.thread.thankyou', $thankyoutargetid ); // Check for permisions of the current category - activity only if public or registered if ($message->getCategory()->pub_access <= 0) { //activity stream - reply post require_once KPATH_SITE.'/lib/kunena.link.class.php'; $JSPostLink = CKunenaLink::GetThreadPageURL ( 'view', $message->catid, $message->thread, 0 ); $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="' . $JSPostLink . '">' . $message->subject . '</a> ' . JText::_ ( 'COM_KUNENA_JS_ACTIVITYSTREAM_REPLY_MSG2' ) ); $act->content = NULL; $act->app = 'kunena.thankyou'; $act->cid = $message->id; // jomsocial 0 = public, 20 = registered members if ($message->getCategory()->pub_access == 0) { $act->access = 0; } else { $act->access = 20; } CFactory::load ( 'libraries', 'activities' ); CActivityStream::add ( $act ); } }
/** * 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(); }
private function _addAvatarUploadActivity($userid, $thumbnail) { if (CUserPoints::assignPoint('profile.avatar.upload')) { // Generate activity stream. $act = new stdClass(); $act->cmd = 'profile.avatar.upload'; $act->actor = $userid; $act->target = 0; $act->title = ''; $act->content = ''; $act->app = 'profile.avatar.upload'; $act->cid = 0; $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = 'profile.avatar.upload'; $act->like_id = CActivities::LIKE_SELF; $act->like_type = 'profile.avatar.upload'; // We need to make a copy of current avatar and set it as stream 'attachement' // which will only gets deleted once teh stream is deleted $params = new JRegistry(); // store a copy of the avatar $imageAttachment = str_replace('thumb_', 'stream_', $thumbnail); $thumbnail = str_replace('thumb_', '', $thumbnail); JFile::copy($thumbnail, $imageAttachment); $params->set('attachment', $imageAttachment); // Add activity logging CActivityStream::add($act, $params->toString()); } }
function createnewgroupdiscussion($data) { require_once JPATH_SITE . '/components/com_community/libraries/core.php'; CFactory::load('libraries', 'apps'); $error_messages = array(); $response = NULL; $validated = true; $db =& JFactory::getDBO(); $survey_filepath = JPATH_ROOT . DS . 'configuration' . DS . 'surveyfiles' . DS . $data['survey_filename']; if ("" == $data['creator'] || 0 == $data['creator']) { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "creator", "message" => "Creator cannot be blank"); } if ("" == $data['groupid'] || 0 == $data['groupid']) { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "groupid", "message" => "Groupid cannot be blank"); } if ($data['title'] == "" || 0 == strlen($data['title'])) { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "title", "message" => "Title cannot be blank"); } if ($data['message'] == "" || 0 == strlen($data['message'])) { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "message", "message" => "Message cannot be blank"); } $inputFilter = CFactory::getInputFilter(true); $validated = true; if (true == $validated) { // Bind the data with the table first $discussion =& JTable::getInstance('Discussion', 'CTable'); $discussion->set('title', strip_tags($data['title'])); $discussion->set('message', $inputFilter->clean($data['message'])); $discussion->set('groupid', $data['groupid']); $discussion->set('creator', $data['creator']); $discussion->set('created', gmdate('Y-m-d H:i:s')); $discussion->set('lastreplied', $discussion->created); $isNew = is_null($discussion->id) || !$discussion->id ? true : false; $query = "SELECT id FROM #__users WHERE id =" . $data['creator']; $db->setQuery($query); $creator = $db->LoadResult(); $query = "SELECT id FROM #__community_groups WHERE id =" . $data['groupid']; $db->setQuery($query); $isgroup = $db->LoadResult(); if (!$creator) { $error_messages[] = array("id" => 1, "fieldname" => "creator", "message" => "Invalid discussion creator id. Check 'creator' field in request"); } if (!$isgroup) { $error_messages[] = array("id" => 1, "fieldname" => "groupid", "message" => "Invalid group id. Check 'groupid' field in request"); } else { if (!file_exists($survey_filepath)) { $validated = false; $error_messages[] = array("id" => 1, "fieldname" => "survey_filename", "message" => "Invalid Survey File Name"); } else { // Save the discussion. $discussion->store(); $survey = new stdClass(); $survey->group_id = $data['groupid']; $survey->discussion_id = $discussion->id; $survey->status = 0; $survey->timestamp = date('Y-m-d H:i:s'); $survey->filename = $data['survey_filename']; $db->insertObject('#__myhsclosure_survey', $survey, 'discussion_id'); } } //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('group.discussion.create'); if (!$creator) { } if (!$isgroup) { } else { if ($data['isqm'] != '') { $db =& JFactory::getDBO(); $row = new stdClass(); $row->id = NULL; $row->discussion_id = $discussion->id; $row->qm_flag = $data['isqm']; $db->insertObject('#__myhs_qmflag', $row, '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' => $discussion->id); } return $response; }
/** * A new message submitted via ajax */ public function ajaxSend($postVars) { //$postVars pending filtering $objResponse = new JAXResponse(); $config = CFactory::getConfig(); $my = CFactory::getUser(); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } //CFactory::load( 'helpers', 'time' ); $inboxModel = $this->getModel('inbox'); $lastSent = $inboxModel->getLastSentTime($my->id); $dateNow = new JDate(); // We need to make sure that this guy are not spamming other people inbox // by checking against his last message time. Make sure it doesn't exceed // pmFloodLimit config (in seconds). if ($dateNow->toUnix() - $lastSent->toUnix() < $config->get('floodLimit') && !COwnerHelper::isCommunityAdmin()) { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_NOTICE'); $json['error'] = JText::sprintf('COM_COMMUNITY_PLEASE_WAIT_BEFORE_SENDING_MESSAGE', $config->get('floodLimit')); die(json_encode($json)); } // Prevent users to send message to themselves. if ($postVars['to'] == $my->id) { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_NOTICE'); $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_CANNOT_SEND_TO_SELF'); die(json_encode($json)); } $postVars = CAjaxHelper::toArray($postVars); $doCont = true; $errMsg = ""; $resizeH = 0; if ($this->_isSpam($my, $postVars['subject'] . ' ' . $postVars['body'])) { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_NOTICE'); $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_MARKED_SPAM'); die(json_encode($json)); } if (empty($postVars['subject']) || JString::trim($postVars['subject']) == '') { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE'); $json['error'] = JText::_('COM_COMMUNITY_INBOX_SUBJECT_MISSING'); $json['samestep'] = true; die(json_encode($json)); } if (empty($postVars['body']) || JString::trim($postVars['body']) == '') { $json = array(); $json['title'] = JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE'); $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_MISSING'); $json['samestep'] = true; die(json_encode($json)); } $data = $postVars; $model = $this->getModel('inbox'); $pattern = "/<br \\/>/i"; $replacement = "\r\n"; $data['body'] = preg_replace($pattern, $replacement, $data['body']); $data['photo'] = isset($data['photo']) ? $data['photo'] : ''; $msgid = $model->send($data); // Add user points. CUserPoints::assignPoint('inbox.message.send'); // Add notification. $params = new CParameter(''); $params->set('url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgid); $params->set('message', $data['body']); $params->set('title', $data['subject']); $params->set('msg_url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgid); $params->set('msg', JText::_('COM_COMMUNITY_PRIVATE_MESSAGE')); CNotificationLibrary::add('inbox_create_message', $my->id, $data['to'], JText::sprintf('COM_COMMUNITY_SENT_YOU_MESSAGE'), '', 'inbox.sent', $params); // Send response. $json = array(); $json['message'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_SENT'); die(json_encode($json)); }
public function upload() { $my = $this->plugin->get('user'); $config = CFactory::getConfig(); $returns = array(); // Load up required models and properties CFactory::load('controllers', 'photos'); CFactory::load('libraries', 'photos'); CFactory::load('models', 'photos'); CFactory::load('helpers', 'image'); $photos = JRequest::get('Files'); $albumId = JRequest::getVar('albumid', '', 'REQUEST'); $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); $handler = $this->_getHandler($album); foreach ($photos as $imageFile) { if (!$this->_validImage($imageFile)) { $this->_showUploadError(true, $this->getError()); return; } if ($this->_imageLimitExceeded(filesize($imageFile['tmp_name']))) { $this->_showUploadError(true, JText::_('CC IMAGE FILE SIZE EXCEEDED')); return; } // We need to read the filetype as uploaded always return application/octet-stream // regardless od the actual file type $info = getimagesize($imageFile['tmp_name']); $isDefaultPhoto = JRequest::getVar('defaultphoto', false, 'REQUEST'); if ($album->id == 0 || $my->id != $album->creator && $album->type != PHOTOS_GROUP_TYPE) { $this->_showUploadError(true, JText::_('CC INVALID ALBUM')); return; } if (!$album->hasAccess($my->id, 'upload')) { $this->_showUploadError(true, JText::_('CC INVALID ALBUM')); return; } // Hash the image file name so that it gets as unique possible $fileName = JUtility::getHash($imageFile['tmp_name'] . time()); $hashFilename = JString::substr($fileName, 0, 24); $imgType = image_type_to_mime_type($info[2]); // Load the tables $photoTable =& JTable::getInstance('Photo', 'CTable'); // @todo: configurable paths? $storage = JPATH_ROOT . DS . $config->getString('photofolder'); $albumPath = empty($album->path) ? '' : $album->id . DS; // Test if the photos path really exists. jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); CFactory::load('helpers', 'limits'); $originalPath = $handler->getOriginalPath($storage, $albumPath, $album->id); CFactory::load('helpers', 'owner'); // @rule: Just in case user tries to exploit the system, we should prevent this from even happening. if ($handler->isExceedUploadLimit() && !COwnerHelper::isCommunityAdmin()) { $config = CFactory::getConfig(); $photoLimit = $config->get('groupphotouploadlimit'); echo JText::sprintf('CC GROUP PHOTO UPLOAD LIMIT REACHED', $photoLimit); return; } if (!JFolder::exists($originalPath)) { if (!JFolder::create($originalPath, (int) octdec($config->get('folderpermissionsphoto')))) { $this->_showUploadError(true, JText::_('CC ERROR CREATING USERS PHOTO FOLDER')); return; } } $locationPath = $handler->getLocationPath($storage, $albumPath, $album->id); if (!JFolder::exists($locationPath)) { if (!JFolder::create($locationPath, (int) octdec($config->get('folderpermissionsphoto')))) { $this->_showUploadError(true, JText::_('CC ERROR CREATING USERS PHOTO FOLDER')); return; } } $thumbPath = $handler->getThumbPath($storage, $album->id); $thumbPath = $thumbPath . DS . $albumPath . 'thumb_' . $hashFilename . CImageHelper::getExtension($imageFile['type']); CPhotos::generateThumbnail($imageFile['tmp_name'], $thumbPath, $imgType); // Original photo need to be kept to make sure that, the gallery works $useAlbumId = empty($album->path) ? 0 : $album->id; $originalFile = $originalPath . $hashFilename . CImageHelper::getExtension($imgType); $this->_storeOriginal($imageFile['tmp_name'], $originalFile, $useAlbumId); $photoTable->original = JString::str_ireplace(JPATH_ROOT . DS, '', $originalFile); // Set photos properties $photoTable->albumid = $albumId; $photoTable->caption = $imageFile['name']; $photoTable->creator = $my->id; $photoTable->created = gmdate('Y-m-d H:i:s'); // Remove the filename extension from the caption if (JString::strlen($photoTable->caption) > 4) { $photoTable->caption = JString::substr($photoTable->caption, 0, JString::strlen($photoTable->caption) - 4); } // @todo: configurable options? // Permission should follow album permission $photoTable->published = '1'; $photoTable->permissions = $album->permissions; // Set the relative path. // @todo: configurable path? $storedPath = $handler->getStoredPath($storage, $albumId); $storedPath = $storedPath . DS . $albumPath . $hashFilename . CImageHelper::getExtension($imageFile['type']); $photoTable->image = JString::str_ireplace(JPATH_ROOT . DS, '', $storedPath); $photoTable->thumbnail = JString::str_ireplace(JPATH_ROOT . DS, '', $thumbPath); //photo filesize, use sprintf to prevent return of unexpected results for large file. $photoTable->filesize = sprintf("%u", filesize($originalPath)); // @rule: Set the proper ordering for the next photo upload. $photoTable->setOrdering(); // Store the object $photoTable->store(); // We need to see if we need to rotate this image, from EXIF orientation data // Only for jpeg image. if ($config->get('photos_auto_rotate') && $imgType == 'image/jpeg') { // Read orientation data from original file $orientation = CImageHelper::getOrientation($imageFile['tmp_name']); //echo $orientation; exit; // A newly uplaoded image might not be resized yet, do it now $displayWidth = $config->getInt('photodisplaysize'); JRequest::setVar('imgid', $photoTable->id, 'GET'); JRequest::setVar('maxW', $displayWidth, 'GET'); JRequest::setVar('maxH', $displayWidth, 'GET'); $this->showimage(false); // Rotata resized files ince it is smaller switch ($orientation) { case 1: // nothing break; case 2: // horizontal flip // $image->flipImage($public,1); break; case 3: // 180 rotate left // $image->rotateImage($public,180); CImageHelper::rotate($storedPath, $storedPath, 180); CImageHelper::rotate($thumbPath, $thumbPath, 180); break; case 4: // vertical flip // $image->flipImage($public,2); break; case 5: // vertical flip + 90 rotate right //$image->flipImage($public, 2); //$image->rotateImage($public, -90); break; case 6: // 90 rotate right // $image->rotateImage($public, -90); CImageHelper::rotate($storedPath, $storedPath, -90); CImageHelper::rotate($thumbPath, $thumbPath, -90); break; case 7: // horizontal flip + 90 rotate right // $image->flipImage($public,1); // $image->rotateImage($public, -90); break; case 8: // 90 rotate left // $image->rotateImage($public, 90); CImageHelper::rotate($storedPath, $storedPath, 90); CImageHelper::rotate($thumbPath, $thumbPath, 90); break; } } // Trigger for onPhotoCreate CFactory::load('libraries', 'apps'); $apps =& CAppPlugins::getInstance(); $apps->loadApplications(); $params = array(); $params[] =& $photoTable; $apps->triggerEvent('onPhotoCreate', $params); // Set image as default if necessary // Load photo album table if ($isDefaultPhoto) { // Set the photo id $album->photoid = $photoTable->id; $album->store(); } // @rule: Set first photo as default album cover if enabled if (!$isDefaultPhoto && $config->get('autoalbumcover')) { $photosModel = CFactory::getModel('Photos'); $totalPhotos = $photosModel->getTotalPhotos($album->id); if ($totalPhotos <= 1) { $album->photoid = $photoTable->id; $album->store(); } } $act = new stdClass(); $act->cmd = 'photo.upload'; $act->actor = $my->id; $act->access = $my->getParam('privacyPhotoView'); $act->target = 0; $act->title = JText::sprintf($handler->getUploadActivityTitle(), '{photo_url}', $album->name); $act->content = '<img src="' . rtrim(JURI::root(), '/') . '/' . $photoTable->thumbnail . '" style=\\"border: 1px solid #eee;margin-right: 3px;" />'; $act->app = 'photos'; $act->cid = $albumId; $params = new JParameter(''); $params->set('multiUrl', $handler->getAlbumURI($albumId, false)); $params->set('photoid', $photoTable->id); $params->set('action', 'upload'); $params->set('photo_url', $handler->getPhotoURI($albumId, $photoTable->id, false)); // Add activity logging CFactory::load('libraries', 'activities'); CActivityStream::add($act, $params->toString()); //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('photo.upload'); // Photo upload was successfull, display a proper message //$this->_showUploadError( false , JText::sprintf('CC PHOTO UPLOADED SUCCESSFULLY', $photoTable->caption ) , $photoTable->getThumbURI(), $albumId ); $returns[] = array('album_id' => $albumId, 'image_id' => $photoTable->id, 'caption' => $photoTable->caption, 'created' => $photoTable->created, 'storage' => $photoTable->storage, 'thumbnail' => $photoTable->getThumbURI(), 'image' => $photoTable->getImageURI()); } return $returns; exit; }