public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new Post_Manager(); } return self::$_instance; }
define('ADMIN', 2); define('OWNER', 3); require '../../classes/DB.php'; require '../../classes/Base_Account.php'; require '../../classes/User.php'; require '../../classes/Post_Manager.php'; require '../../classes/Session.php'; require '../../classes/Token.php'; if (isset($_POST['task']) && $_POST['task'] == 'post-submit') { if (Token::check($_POST['token'])) { // data to be encoded as JSON and passed back to client: $data = []; // need to generate new session token as we've just consumed the previous one: $new_token = Token::generate(); // get instance of the post_manager: $pm = Post_Manager::getInstance(); // user submitting the post: $user = new User($_POST['user']); // target of the post: // @TODO: switch target_type to instantiate the target as the appropriate type $target = new User($_POST['target']); // The target type (user, music, dance, comedy): // @TODO: this will be used to properly instantiate the target object $target_type = $_POST['target_type']; // The actual post with line breaks preserved: $post = str_replace("\n", "<br/>", $_POST['post']); if ($user->exists() && $target->exists()) { $post_info = $pm->create_post($user, $target, $target_type, $post); if ($post_info) { $data['post_id'] = $post_info['id']; $data['post'] = $post;
</div> </div> <div class="post-submit-content-wrapper"> <textarea id="post-content" placeholder="Type Away..."></textarea> </div> </div><!--post-submit-wrapper--> </div> <?php } // if($current_users_profile) ?> <div class="col-10"> <ul class="posts-list"> <?php // Post manager instance for retrieving posts: $post_manager = Post_Manager::getInstance(); // Retrieve all posts related to the targetted profile: $posts_query = $post_manager->get_posts($target); if ($posts_query) { foreach ($posts_query as $post_data) { ?> <li class="post" id="<?php echo $post_data['id']; ?> "> <div class="post-img-wrapper"> <img src="<?php echo $avatar; ?> " alt="" class="post-img"/> </div>