示例#1
0
/**
 * Get array of latest items
 *
 * @param array of params
 *			- limit (int) the number of items to return
 *			- post_ID (int) return specified item or NULL to return all available
 * @return xmlrpcmsg
 */
function xmlrpc_get_items($params, &$Blog)
{
    global $current_User;
    $params = array_merge(array('limit' => 0, 'item_ID' => 0, 'types' => ''), $params);
    // Protected and private get checked by statuses_where_clause().
    $statuses = array('published', 'redirected', 'protected', 'private');
    if ($current_User->check_perm('blog_ismember', 'view', false, $Blog->ID)) {
        // These statuses require member status:
        $statuses = array_merge($statuses, array('draft', 'deprecated'));
    }
    logIO('Statuses: ' . implode(', ', $statuses));
    if (!empty($params['item_ID'])) {
        logIO('Getting item #' . $params['item_ID']);
        $filters = array('visibility_array' => $statuses, 'types' => NULL, 'post_ID' => $params['item_ID']);
    } else {
        logIO(sprintf('Trying to get latest items (%s)', $params['limit'] ? $params['limit'] : 'all'));
        $filters = array('visibility_array' => $statuses, 'types' => $params['types'], 'order' => 'DESC', 'unit' => 'posts');
    }
    // Get the pages to display:
    load_class('items/model/_itemlist.class.php', 'ItemList2');
    $ItemList = new ItemList2($Blog, NULL, NULL, $params['limit']);
    $ItemList->set_filters($filters, false);
    // Run the query:
    $ItemList->query();
    logIO('Items found: ' . $ItemList->result_num_rows);
    $data = array();
    while ($Item =& $ItemList->get_item()) {
        $data[] = _wp_mw_get_item_struct($Item);
    }
    return $data;
}
示例#2
0
/**
 * metaWeblog.getPost retieves a given post.
 *
 * @see http://www.xmlrpc.com/metaWeblogApi#basicEntrypoints
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 postid (string): Unique identifier of the post
 *					1 username (string): Login for a Blogger user who has permission to edit the given
 *						post (either the user who originally created it or an admin of the blog).
 *					2 password (string): Password for said username.
 * @return xmlrpcresp XML-RPC Response
 */
function mw_getpost($m)
{
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET POST:
    /**
     * @var Item
     */
    if (!($edited_Item =& xmlrpcs_get_Item($m, 0))) {
        // Failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // CHECK PERMISSION:
    if (!xmlrpcs_can_view_item($edited_Item, $current_User)) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    $item = _wp_mw_get_item_struct($edited_Item);
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($item, 'struct'));
}