function getRecentPosts($params)
{
	global $tikilib, $userlib, $bloglib;

	$appkeyp = $params->getParam(0);
	$appkey = $appkeyp->scalarval();
	$blogidp = $params->getParam(1);
	$blogid = $blogidp->scalarval();
	$usernamep = $params->getParam(2);
	$username = $usernamep->scalarval();
	$passwordp = $params->getParam(3);
	$password = $passwordp->scalarval();
	$passp = $params->getParam(4);
	$number = $passp->scalarval();

	// Now check if the user is valid and if the user can post a submission
	list($ok, $username, $e) = $userlib->validate_user($username, $password, '', '');
	if (!$ok) {
		return new XML_RPC_Response(0, 101, 'Invalid username or password');
	}

	if (!check_individual($username, $blogid, 'tiki_p_blog_post')) {
		return new XML_RPC_Response(
						0,
						101,
						'User is not allowed to post to this weblog due to individual restrictions for this weblog therefore the user cannot edit a post'
		);
	}

	if (!$userlib->user_has_permission($username, 'tiki_p_blog_post')) {
		return new XML_RPC_Response(0, 101, 'User is not allowed to post');
	}

	// Now get the post information
	$posts = $bloglib->list_blog_posts($blogid, false, 0, $number, 'created_desc', '', '');

	if (count($posts) == 0) {
		return new XML_RPC_Response(0, 101, 'No posts');
	}

	$arrayval = array();

	foreach ($posts['data'] as $post) {
		$dateCreated = $tikilib->get_iso8601_datetime($post['created']);

		$myStruct = new XML_RPC_Value(
						array(
							'userid' => new XML_RPC_Value($username),
							'dateCreated' => new XML_RPC_Value($dateCreated, 'dateTime.iso8601'),
							'content' => new XML_RPC_Value($post['data']),
							'postid' => new XML_RPC_Value($post['postId'])
						),
						'struct'
		);

		$arrayval[] = $myStruct;
	}

	// User ok and can submit then submit an article
	$myVal = new XML_RPC_Value($arrayval, 'array');
	return new XML_RPC_Response($myVal);
}
Esempio n. 2
0
function getRecentPosts($params)
{
    global $gBitSystem, $userlib, $gBlog;
    $appkeyp = $params->getParam(0);
    $appkey = $appkeyp->scalarval();
    $blogidp = $params->getParam(1);
    $blogid = $blogidp->scalarval();
    $usernamep = $params->getParam(2);
    $username = $usernamep->scalarval();
    $passwordp = $params->getParam(3);
    $password = $passwordp->scalarval();
    $passp = $params->getParam(4);
    $number = $passp->scalarval();
    // Now check if the user is valid and if the user can post a submission
    if (!$gBitUser->validate($username, $password, '', '')) {
        return new xmlrpcresp(0, 101, "Invalid username or password");
    }
    if (!check_individual($username, $blogid, 'p_blogs_post')) {
        return new xmlrpcresp(0, 101, "User is not allowed to post to this weblog due to individual restrictions for this weblog therefore the user cannot edit a post");
    }
    if (!$gBitUser->user_has_permission($username, 'p_blogs_post')) {
        return new xmlrpcresp(0, 101, "User is not allowed to post");
    }
    // Now get the post information
    $posts = $gBlog->list_blog_posts($blogid, 0, $number, 'created_desc', '', '');
    if (count($posts) == 0) {
        return new xmlrpcresp(0, 101, "No posts");
    }
    $arrayval = array();
    foreach ($posts["data"] as $post) {
        #    $dateCreated=date("Ymd",$post["created"])."T".date("h:i:s",$post["created"]);
        $dateCreated = $gBitSystem->get_iso8601_datetime($post["created"]);
        $myStruct = new xmlrpcval(array("userid" => new xmlrpcval($username), "dateCreated" => new xmlrpcval($dateCreated, "dateTime.iso8601"), "content" => new xmlrpcval("<title>" . $post["title"] . "</title>" . $post["data"]), "postid" => new xmlrpcval($post["post_id"])), "struct");
        $arrayval[] = $myStruct;
    }
    // User ok and can submit then submit an article
    $myVal = new xmlrpcval($arrayval, "array");
    return new xmlrpcresp($myVal);
}