public function handleSaveAnswer($request_method, $request_data) { $msg = NULL; $error = FALSE; switch ($request_method) { case 'POST': filter_all_post($request_data); $request_data['answer'] = trim($request_data['answer']); if (empty($request_data['answer'])) { $msg = __('Answer can not be left blank'); $error = true; } else { $comment = new Comment(); // setting some variables $usr = PA::$user; $comment->comment = $comment->subject = $request_data['answer']; $comment->parent_type = TYPE_ANSWER; $id = $comment->parent_id = $comment->content_id = $request_data['id']; $comment->user_id = $usr->user_id; $comment->name = $usr->login_name; $comment->email = $usr->email; if ($comment->spam_check()) { $msg = __('Sorry, your Answer cannot be posted as it looks like spam. Try removing any links to possibly suspect sites, and re-submitting.'); $error = true; Logger::log('Comment rejected by spam filter', LOGGER_ACTION); } else { $msg = __('Your Answer has been posted successfully'); $comment->save_comment(); if ($comment->spam_state != SPAM_STATE_OK) { $msg = __('Sorry, your answer cannot be posted as it was classified as spam by Akismet, or contained links to blacklisted sites. Please check the links in your post, and that your name and e-mail address are correct.'); $error = true; } else { unset($request_data); //invalidate cache of content block as it is modified now if (PA::$network_info) { $nid = '_network_' . PA::$network_info->network_id; } else { $nid = ''; } //unique name $cache_id = 'content_' . $id . $nid; CachedTemplate::invalidate_cache($cache_id); } } } break; } $msg_array = array(); $msg_array['failure_msg'] = $msg; $msg_array['success_msg'] = NULL; $redirect_url = NULL; $query_str = NULL; set_web_variables($msg_array, $redirect_url, $query_str); }
$id = $_POST['id']; if ($comment->spam_check()) { $error_message = "Sorry, your comment cannot be posted as it looks like spam. Try removing any links to possibly suspect sites, and re-submitting."; Logger::log("Comment rejected by spam filter", LOGGER_ACTION); } else { $error_message = 'Your comment has been posted successfully'; $comment->save_comment(); if ($comment->spam_state != SPAM_STATE_OK) { $error_message = "Sorry, your comment cannot be posted as it was classified as spam by Akismet, or contained links to blacklisted sites. Please check the links in your post, and that your name and e-mail address are correct."; } else { //TO DO: comment should be posted to contents of other network rather then just mother network //$params['cid'] = $comment->content_id; //auto_email_notification('comment_posted', $params ); //** when uncommenting the above line, don't forget to uncomment the include of auto_email_notify.php at the top of this file too! unset($_POST); //invalidate cache of content block as it is modified now if ($network_info) { $nid = '_network_' . $network_info->network_id; } else { $nid = ''; } //unique name $cache_id = 'content_' . $id . $nid; CachedTemplate::invalidate_cache($cache_id); } } } $location = $_SERVER['HTTP_REFERER'] . '&msg_id=' . $error_message; header("Location: {$location}"); exit; }
function uihelper_generate_center_content($cid, $permalink = 0, $show = 0) { global $app; $content_tpl = array('Question'); if ($permalink == 1) { $permalink_content = uihelper_generate_center_content_permalink($cid, $show); return $permalink_content; } //if we are in network then cached file's id should have content as well as network id if (PA::$network_info) { $nid = '_network_' . PA::$network_info->network_id; } else { $nid = ''; } //unique name $cache_id = 'content_' . $cid . $nid . PA::$language; $middle_content = new CachedTemplate($cache_id); //if this file is not cached then generate one for this if (!$middle_content->is_cached()) { $image_media_gallery = $audio_media_gallery = $video_media_gallery = FALSE; $back_page = PA::$url . $app->current_route; $content = CNContent::load_content((int) $cid, (int) PA::$login_uid); // sanity rulez if (empty($content)) { // echo "<hr>cid $cid doesn't exist<hr>"; return ''; } // filter content filelds for output $content->title = _out($content->title); $content->body = _out($content->body); $content_url = PA::$url . PA_ROUTE_CONTENT . "/cid={$content->content_id}"; $content->title = '<a href="' . $content_url . '" >' . $content->title . '</a>'; if (strstr($back_page, PA_ROUTE_CONTENT)) { if ($content->parent_collection_id > 0) { // IF permalink content is a group content redirect to group homepage $back_page = PA::$url . PA_ROUTE_GROUP . "/gid=" . $content->parent_collection_id; } else { //if coming from permalink page then redirect to user page $back_page = PA::$url . PA_ROUTE_USER_PUBLIC . "/" . $content->author_id; } } $back_page = urlencode($back_page); if (!$content->is_html) { $content->body = nl2br($content->body); } if (trim($content->type) == 'Image') { $image_media_gallery = TRUE; } if (trim($content->type) == 'Audio') { $audio_media_gallery = TRUE; } if (trim($content->type) == 'Video') { $video_media_gallery = TRUE; } if (isset(PA::$login_uid) && PA::$login_uid == $content->author_id) { $editable = TRUE; } $content->no_of_comments = Comment::count_comments_for_content($cid); $content->no_of_trackbacks = CNContent::count_trackbacks_for_content($cid); $content->trackback_url = PA::$url . "/pa_trackback.php?cid=" . $cid; $content_user = new User(); $content_user->load((int) $content->author_id); $content->author_name = '<a href= "' . PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $content_user->user_id . '">' . chop_string($content_user->display_name, 20) . '</a>'; $content->create_time = PA::date($content->changed, 'long'); // date("l, F d, Y", $content->changed); $tags = Tag::load_tags_for_content($cid); if ($tags) { $t = array(); for ($i = 0; $i < count($tags); $i++) { $name = _out($tags[$i]['name']); $uid = PA::$login_uid; $url = PA::$url . '/' . FILE_TAG_SEARCH . '?name_string=content_tag&keyword=' . $tags[$i]["name"]; $t[] = "<a href={$url}>" . $name . "</a>"; } $tag_string = "<b>" . __("Tags:") . " </b>" . implode(", ", $t); } else { $tag_string = ""; } $content->tag_entry = $tag_string; if (property_exists(get_class($content), 'sbname')) { if (substr($content->sbname, 0, 5) == 'event') { $content->type = 'SBEvent'; // need to } if (substr($content->sbname, 0, 6) == 'review') { $content->type = 'Review'; } if (substr($content->sbname, 0, 11) == 'media/audio') { $content->type = 'Audio'; } if (substr($content->sbname, 0, 11) == 'media/video') { $content->type = 'Video'; } if (substr($content->sbname, 0, 11) == 'media/image') { $content->type = 'Image'; } if (substr($content->sbname, 0, 14) == 'showcase/group') { $content->type = 'GroupShowCase'; } if (substr($content->sbname, 0, 15) == 'showcase/person') { $content->type = 'PersonShowCase'; } } // replace magic strings $content->replace_percent_strings(PA::$url); /* Permalink and edit links for content */ $perma_link = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $content->content_id; $middle_content->set_object('contents', $content); //TODO: gaurav: I am setting this to FALSE because for some reason edit links were appearing on other peoples posts also $middle_content->set('editable', FALSE); $middle_content->set('permalink', $perma_link); $middle_content->set('outer_block_id', 'outer_block_' . $content->content_id); $middle_content->set('inner_block_id', 'inner_block_' . $content->content_id); $middle_content->set('user_name', $content_user->login_name); $middle_content->set('current_theme_path', PA::$theme_url); $middle_content->set('back_page', $back_page); $middle_content->set('image_media_gallery', $image_media_gallery); $middle_content->set('audio_media_gallery', $audio_media_gallery); $middle_content->set('video_media_gallery', $video_media_gallery); if ($show == 1) { $middle_content->set('show', $show); } $return_content = ''; if (!in_array($content->type, $content_tpl) && getShadowedPath(CURRENT_THEME_FSPATH . '/' . $content->type . ".php")) { $return_content = $middle_content->fetch_cache(getShadowedPath(CURRENT_THEME_FSPATH . '/' . $content->type . ".php")); } } else { //this will load the file with cache id //it means there is already file which is cached $return_content = $middle_content->fetch_cache(); } return $return_content; }
* [description including history] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @author [creator, or "Original Author"] * @license http://bit.ly/aVWqRV PayAsYouGo License * @copyright Copyright (c) 2010 Broadband Mechanics * @package PeopleAggregator */ $login_required = TRUE; include_once "web/includes/page.php"; require_once "api/Theme/Template.php"; require_once "api/Login/PA_Login.class.php"; require_once "web/includes/classes/UrlHelper.class.php"; // if return url is set in the request then after logout redirect to the location else redirect to homepage. if (!empty($_REQUEST['return'])) { $return = $_REQUEST['return']; } else { // build rthe url via UrlHelper so we can respect the SSL directives $return = UrlHelper::url_for(PA::$url . '/' . FILE_LOGIN, array(), 'https'); } // destroy the login cookie PA_Login::log_out(); // invalidate the cache for user profile $file = PA::$theme_url . "/user_profile.tpl?uid=" . PA::$login_uid; CachedTemplate::invalidate_cache($file); // kill the session $_SESSION = array(); session_destroy(); session_start(); // and go home :) header("Location: {$return}"); exit;
function handlePOST_submitComment($request_data) { global $error_msg; if ($request_data['action'] == 'submitComment' && !empty(PA::$login_uid)) { $ccid_string = ""; if (!empty($request_data['ccid'])) { $ccid_string = "&ccid=" . $request_data['ccid']; } $error_msg = ""; if (strlen(trim(strip_tags($request_data['comment']))) == 0) { $error_msg = "Your comment contains some illegal characters. Please try again.<br>"; } if (trim($request_data['comment']) == '') { $error_msg = "Comment can not be left blank<br>"; } if (isset($request_data['name']) && trim($request_data['name']) == '') { $error_msg .= "Please enter name<br>"; } if (isset($request_data['email']) && trim($request_data['email']) == '') { $error_msg .= "Please enter email address"; } else { if (isset($request_data['email']) && !validate_email($request_data['email'])) { $error_msg .= "Please enter a valid email address"; } } /* if(strlen($error_msg) > 0) { $location = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $request_data["cid"]; $this->controller->redirect($location); } */ /* Function for Filtering the POST data Array */ filter_all_post($request_data); if (empty($error_msg)) { // no errors occured $comment = new Comment(); $id = trim($request_data['cid']); $comment->content_id = $id; $comment->subject = ''; $comment->comment = trim($request_data['comment']); if (PA::$login_uid) { $user = new User(); $user->load((int) PA::$login_uid); $comment->user_id = $user->user_id; $comment->name = ''; $comment->email = ''; $comment->homepage = ''; unset($request_data['err']); } else { $comment->name = trim($request_data['name']); $comment->email = trim($request_data['email']); if (!empty($request_data['homepage'])) { $comment->homepage = validate_url(trim($request_data['homepage'])); } else { $comment->homepage = ""; } } // In old method $comment->parent_type = TYPE_CONTENT; $comment->parent_id = $id; if ($comment->spam_check()) { $error_msg = "Sorry, your comment cannot be posted as it looks like spam. Try removing any links to possibly suspect sites, and re-submitting."; Logger::log("Comment rejected by spam filter", LOGGER_ACTION); } else { $error_msg = 'Your comment has been posted successfully'; $comment->save(); if ($comment->spam_state != SPAM_STATE_OK) { $error_msg = "Sorry, your comment cannot be posted as it was classified as spam by Akismet, or contained links to blacklisted sites. Please check the links in your post, and that your name and e-mail address are correct."; } else { //for rivers of people $activity = 'user_post_a_comment'; $activity_extra['info'] = $user->display_name . 'has left a comment'; $activity_extra['comment_id'] = $comment->comment_id; $activity_extra['content_url'] = PA::$url . PA_ROUTE_CONTENT . "/cid={$id}"; $extra = serialize($activity_extra); Activities::save($user->user_id, $activity, $comment->comment_id, $extra); //TO DO: comment should be posted to contents of other network rather then just mother network //$params['cid'] = $comment->content_id; //auto_email_notification('comment_posted', $params ); //** when uncommenting the above line, don't forget to uncomment the include of auto_email_notify.php at the top of this file too! unset($request_data); //invalidate cache of content block as it is modified now if (PA::$network_info) { $nid = '_network_' . PA::$network_info->network_id; } else { $nid = ''; } //unique name $cache_id = 'content_' . $id . $nid; CachedTemplate::invalidate_cache($cache_id); } } } } }
/** * Returns a CachedTemplate object loaded from a plugin template * Plugins are different in the sense that they store their templates in the * plugins/xxx/templates, where 'xxx' is the plugin identifier * * @param pluginId The id of the plugin, which matches the name of a folder * under the plugins/ folder. * @param templateName Name of the template, without the .template extension * @param blogInfo * @return a CachedTemplate object */ function PluginCachedTemplate($pluginId, $templateName, $blogInfo = null) { // define the template file name $templateFolder = TemplateSetStorage::getPluginTemplateFolder($pluginId); $templateFileName = $templateFolder . $templateName . '.template'; $t = new CachedTemplate($templateFileName); $t->setTemplateDir($templateFolder); $t->assign('templatename', $templateName); $t->assign('admintemplatepath', TemplateSetStorage::getAdminTemplateFolder()); $t->assign('plugintemplatepath', $templateFolder); // change a few things... $t = $this->_configureTemplateSettings($t, $blogInfo); return $t; }
function metaWeblog_editPost($args) { $postid = $args['postid']; $login = $args['login']; $password = $args['password']; $post = $args['post']; $publish = $args['publish']; // ignored $user = api_load_user($login, $password); list($ccid, $context, $group, $cid, $content) = api_parse_postid($user, $postid); // assert access if ($content->author_id != $user->user_id) { throw new PAException(USER_ACCESS_DENIED, "Only the author can edit a post"); } // save changes to post BlogPost::save_blogpost($cid, $user->user_id, $post['title'], $post['description'], array(), array(), $ccid); // invalidate caches $cache_id = 'content_' . $cid; if (PA::$network_info) { $cache_id .= '_network_' . PA::$network_info->network_id; } CachedTemplate::invalidate_cache($cache_id); Logger::log("invalidating cache for {$cache_id}"); return true; }
/** !! * Called by web/dynamic.php, which does the page generation. * * @param string $request_method Not used. But here for standards. * @param array $request_data POST data to save. */ public function handleRequest($request_method, $request_data) { $msg = NULL; $action = isset($request_data['do']) ? $request_data['do'] : NULL; if ($action == 'delete') { $this->delete_id = $this->relation_uid; Relation::delete_relation($this->uid, $this->delete_id, PA::$network_info->network_id); $this->cache_id = 'relation_private_' . $this->uid; CachedTemplate::invalidate_cache($this->cache_id); $this->cache_id = 'relation_public_' . $this->uid; CachedTemplate::invalidate_cache($this->cache_id); // invalidate cache of user who is being added in relation module $this->cache_id = 'in_relation_private_' . $this->delete_id; CachedTemplate::invalidate_cache($this->cache_id); $this->cache_id = 'in_relation_public_' . $this->delete_id; CachedTemplate::invalidate_cache($this->cache_id); header('Location:' . PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $this->delete_id . '&delete=1'); } //getting relations of logged in user $this->all_relations = Relation::get_all_relations((int) $this->uid); $this->relationship_level = 2; //default relation level id is 2 for friend foreach ($this->all_relations as $relation) { if ($this->relation_uid == $relation['user_id']) { $this->relationship_level = $relation['relation_type_id']; $this->in_family = $relation['in_family']; $this->status = $relation['status']; if ($this->status == PENDING) { if (PA::$extra['reciprocated_relationship'] == NET_YES && $action == 'add') { $msg = sprintf(__('Your request for adding %s as a relation has already been sent'), $relation['display_name']); } } } } try { $this->user->load((int) $this->relation_uid); $this->title = __('Edit Relationship') . ' - ' . $this->user->display_name; //title of the web page //picture and login relation $this->relation_picture = $this->user->picture; $this->login_name = $this->user->login_name; $this->display_name = $this->user->display_name; } catch (PAException $e) { $mesg = $e->message; $this->is_error = TRUE; } if (isset($request_data['submit'])) { $this->rel_creater = PA::$user; $this->relationship_level = $request_data['level']; if (PA::$extra['reciprocated_relationship'] == NET_YES) { if (Relation::getRelationData($this->relation_uid, $this->uid, PA::$network_info->network_id)) { Relation::update_relation_status($this->relation_uid, $this->uid, APPROVED, PA::$network_info->network_id); Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, APPROVED); $relation_obj = Relation::getRelationData($this->relation_uid, $this->uid, PA::$network_info->network_id); PANotify::send("reciprocated_relation_estab", PA::$network_info, PA::$login_user, $relation_obj); // recipient is network owner $location = PA_ROUTE_USER_PRIVATE . '/msg=' . urlencode(__("The relationship request was approved.")); header('Location:' . PA::$url . $location); exit; } $this->status = PENDING; } else { $this->status = APPROVED; } try { $this->relation = Relation::get_relation($this->rel_creater->user_id, $this->relation_uid, PA::$network_info->network_id); $this->edit = $this->relation ? TRUE : FALSE; } catch (PAException $e) { $this->edit = FALSE; } try { if (isset($request_data['in_family'])) { // If the user has checked the in_family checkbox. Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, $this->status); } else { Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, NULL, $this->status); } $this->user = PA::$user; // relationship establisher image $relation_obj = Relation::getRelationData($this->uid, $this->relation_uid, PA::$network_info->network_id); if ($this->edit == FALSE) { if (PA::$extra['reciprocated_relationship'] == NET_YES) { PANotify::send("friend_request_sent", PA::$user, PA::$login_user, $relation_obj); } else { PANotify::send("relation_added", PA::$network_info, PA::$login_user, $relation_obj); // recipient is network owner PANotify::send("relationship_created_with_other_member", PA::$user, PA::$login_user, $relation_obj); //for rivers of people $activity = 'user_friend_added'; //for rivers of people $activities_extra['info'] = $this->display_name . ' added new friend with id =' . $request_data['uid']; $extra = serialize($activities_extra); $object = $this->relation_uid; Activities::save(PA::$login_uid, $activity, $object, $extra); } } //invalidate cache of logged in user's relation module $this->cache_id = 'relation_private_' . $this->uid; CachedTemplate::invalidate_cache($this->cache_id); $this->cache_id = 'relation_public_' . $this->uid; CachedTemplate::invalidate_cache($this->cache_id); // invalidate cache of user who is being added in relation module $this->cache_id = 'in_relation_private_' . $this->relation_uid; CachedTemplate::invalidate_cache($this->cache_id); $this->cache_id = 'in_relation_public_' . $this->relation_uid; CachedTemplate::invalidate_cache($this->cache_id); if (PA::$extra['reciprocated_relationship'] == NET_NO) { if ($request_data['do']) { $location = PA_ROUTE_USER_PUBLIC . '/' . $this->relation_uid . "&msg=" . urlencode(__("Relationship estabilished.")); } } else { $location = PA_ROUTE_USER_PRIVATE . '/msg_id=' . urlencode(__("Your request has been sent for approval")); } header('Location:' . PA::$url . $location); } catch (PAException $e) { $message = $e->message; } } $msg_array = array(); $msg_array['failure_msg'] = $msg; $msg_array['success_msg'] = NULL; $redirect_url = NULL; $query_str = NULL; set_web_variables($msg_array, $redirect_url, $query_str); }