Добавить пост в избранное

@param int $post_id Номер поста
@return array
@throws IncorrectUsageException
551925
public function addPostToFavorite($post_id)
    {
        $this->checkId($post_id);

        return $this->adapter->put(sprintf('/post/%d/favorite', $post_id));
    }
808572
def query_by_post(postid):
        '''
        
        '''
        return TabReply.select().where(
            TabReply.post_id == postid
        ).order_by(TabReply.timestamp.desc())
338390
public function redirectToPost($post_id)
    {
        $post_id = Container::get('hooks')->fire('model.topic.redirect_to_post', $post_id);

        $result['select'] = ['topic_id', 'posted'];

        $result = DB::forTable('posts')
                      ->select_many($result['select'])
                      ->where('id', $post_id);
        $result = Container::get('hooks')->fireDB('model.topic.redirect_to_post_query', $result);
        $result = $result->find_one();

        if (!$result) {
            throw new  RunBBException(__('Bad request'), 404);
        }

        $post['topic_id'] = $result['topic_id'];
        $posted = $result['posted'];

        // Determine on which page the post is located (depending on $forum_user['disp_posts'])
        $num_posts = DB::forTable('posts')
                        ->where('topic_id', $post['topic_id'])
                        ->where_lt('posted', $posted)
                        ->count('id');

        $num_posts = Container::get('hooks')->fire('model.topic.redirect_to_post_num', $num_posts);

        $post['get_p'] = ceil(($num_posts + 1) / User::get()->disp_posts);

        $post = Container::get('hooks')->fire('model.topic.redirect_to_post', $post);

        return $post;
    }
931704
public function metaboxSave($value, int $post_id)
    {
        $this->setValue($value);

        $previous = get_post_meta($post_id, $this->getName(), false);

        if (is_null($value) || empty($value)) {
            delete_post_meta($post_id, $this->getName());
        } elseif (empty($previous) && is_array($value)) {
            array_walk($value, function ($val) use ($post_id) {
                add_post_meta($post_id, $this->getName(), $val, false);
            });
        } else {
            delete_post_meta($post_id, $this->getName());

            array_walk($value, function ($val) use ($post_id, $previous) {
                add_post_meta($post_id, $this->getName(), $val, false);
            });
        }
    }
275716
protected function _updateObject( $post_id, $fields ) {
		$fields['ID'] = $post_id;
		$updated = wp_update_post( $fields );
		if ( $updated && ! is_wp_error( $updated ) ) {
			$this->_debug( 'Updated post ' . $post_id );
		} elseif ( is_wp_error( $updated ) ) {
			$this->_debug(
				'Update failed for post %d with message [%s] %s',
				$post_id,
				$updated->get_error_code(),
				$updated->get_error_message()
			);
		} else {
			$this->_debug( 'Update failed for post ' . $post_id );
		}

		return $updated;
	}
1131280
public function getAssociations($post_id = null)
    {
        $oConfig       = Factory::service('Config');
        $oDb           = Factory::service('Database');
        $_associations = $oConfig->item('blog_post_associations');

        if (!$_associations) {
            return array();
        }

        // --------------------------------------------------------------------------

        foreach ($_associations as &$assoc) {

            /**
             * Fetch the association data from the source, fail ungracefully - the dev
             * should have this configured correctly.
             *
             * Fetch current associations if a post_id has been supplied
             */

            if ($post_id) {

                $oDb->where('post_id', $post_id);
                $assoc->current = $oDb->get($assoc->target)->result();

            } else {

                $assoc->current = array();
            }

            //  Fetch the raw data
            $oDb->select($assoc->source->id . ' id, ' . $assoc->source->label . ' label');
            $oDb->order_by('label');

            if (isset($assoc->source->where) && $assoc->source->where) {

                $oDb->where($assoc->source->where);
            }

            $assoc->data = $oDb->get($assoc->source->table)->result();
        }

        return $_associations;
    }
674490
public static function findByID($postID, $postTypeSlug = '')
    {
        $postTypeSlug = ($postTypeSlug ? $postTypeSlug : PostType::getSlug());
        $postObj = (new Post())->setTable($postTypeSlug);
        $post = $postObj
            ->where('postID', $postID)
            ->with($postObj->getDefaultRelations(getPostType($postTypeSlug)))
            ->first();
        return $post;
    }
549349
public function postEdit(PostRequest $request, $id)
    {
        $command = new EditPostCommand($request->all());

        try 
        {
            $this->bus->execute($command);
        }
        catch(ValidationException $e)
        {
            return Redirect::to(\OogleeBConfig::get('laravelblog::routes.base_uri_admin').'/post/{$id}/edit')->withErrors($e->getErrors());
        }
        catch(\DomainException $e)
        {
            return Redirect::to(\OogleeBConfig::get('laravelblog::routes.base_uri_admin').'/post/{$id}/edit')->withErrors($e->getErrors());
        }

        return Redirect::to(\OogleeBConfig::get('laravelblog::routes.base_uri_admin').'/posts')->with(['message' => 'success!']);
    }
681602
def get_post_by_id(self, post_id):
        
        r = None
        post_id = _as_int(post_id)
        with self._engine.begin() as conn:
            try:
                post_statement = sqla.select([self._post_table]) \
                    .where(self._post_table.c.id == post_id) \
                    .alias('post')

                joined_statement = post_statement.join(self._tag_posts_table) \
                    .join(self._tag_table) \
                    .join(self._user_posts_table) \
                    .alias('join')

                # Note this will retrieve one row per tag
                all_rows = conn.execute(
                    sqla.select([joined_statement])
                ).fetchall()
                r = self._serialise_posts_and_tags_from_joined_rows(
                    all_rows
                )[0]

            except Exception as e:
                self._logger.exception(str(e))
                r = None
        return r
820521
public function removePostFromFavorite($post_id)
    {
        $this->checkId($post_id);

        return $this->adapter->delete(sprintf('/post/%d/favorite', $post_id));
    }
459553
function get_options( $options, $post_id )
	{
		// loaded by PHP already?
		if( !empty($options) )
		{
			return $options;	
		}
		
		
		// defaults
	 	$options = array(
	 		'position'			=>	'normal',
	 		'layout'			=>	'no_box',
	 		'hide_on_screen'	=>	array(),
	 	);
	 	
	 	
	 	// vars
	 	$position = get_post_meta($post_id, 'position', true);
	 	if( $position )
		{
			$options['position'] = $position;
		}
		
		$layout = get_post_meta($post_id, 'layout', true);
	 	if( $layout )
		{
			$options['layout'] = $layout;
		}
		
		$hide_on_screen = get_post_meta($post_id, 'hide_on_screen', true);
	 	if( $hide_on_screen )
		{
			$hide_on_screen = maybe_unserialize($hide_on_screen);
			$options['hide_on_screen'] = $hide_on_screen;
		}
		
	 	
	 	// return
	 	return $options;
	}
653325
public function getPostModules()
    {
        if (!isset($_POST['id']) || empty($_POST['id']) || is_null($_POST['id'])) {
            echo 'false';
            wp_die();
        }

        $post_modules = \Modularity\Editor::getPostModules($_POST['id']);
        foreach ($post_modules as $post_module) {
            if (!empty($post_module['modules'])) {
                foreach ($post_module['modules'] as &$module) {
                    $incompability = apply_filters('Modularity/Editor/SidebarIncompability', array(), $module->post_type);
                    $module->sidebar_incompability = (!empty($incompability['sidebar_incompability'])) ? $incompability['sidebar_incompability'] : array();
                }
            }
        }

        echo json_encode($post_modules);
        wp_die();
    }
494820
public function increaseCount($post_id)
    {
        $this->checkId($post_id);

        return $this->adapter->put(sprintf('/post/%d/viewcount', $post_id));
    }
889542
public function votePlus($post_id)
    {
        $this->checkId($post_id);

        return $this->vote($post_id, self::VOTE_PLUS);
    }
220958
public function save ($post_ID)
    {
        if (!$this->doSave())
            return;
        if ($post_ID === self::SITE)
            update_option($this->identifier, $this->getPostValue());
        else
            update_post_meta($post_ID, $this->identifier, $this->getPostValue());
    }
721898
public function getAll( $post_id, $as_strings = true ) {
		$contributors = [];
		foreach ( $this->valid as $contributor_type ) {
			if ( $as_strings ) {
				$contributors[ $contributor_type ] = $this->get( $post_id, $contributor_type );
			} else {
				$contributors[ $contributor_type ] = $this->getArray( $post_id, $contributor_type );
			}
		}
		return $contributors;
	}
1273590
protected function _deleteObject( $post_id ) {
		$post = get_post( $post_id );
		if ( ! $post ) {
			return false;
		}

		$deleted = wp_delete_post( $post_id, true );
		if ( $deleted ) {
			$this->_debug( 'Deleted post with ID: ' . $post_id );
			return true;
		}

		$this->_debug( 'Post removal failed for ID: ' . $post_id );
		return false;
	}