コード例 #1
0
function f_blogger_editPost($m)
{
    global $manager;
    $itemid = intval(_getScalar($m, 1));
    $username = _getScalar($m, 2);
    $password = _getScalar($m, 3);
    $content = _getScalar($m, 4);
    $publish = _getScalar($m, 5);
    $title = blogger_extractTitle($content);
    $category = blogger_extractCategory($content);
    $content = blogger_removeSpecialTags($content);
    // get old title and extended part
    if (!$manager->existsItem($itemid, 1, 1)) {
        return _error(6, "No such item ({$itemid})");
    }
    $old =& $manager->getItem($itemid, 1, 1);
    $blogid = getBlogIDFromItemID($itemid);
    $blog = new BLOG($blogid);
    $catid = $blog->getCategoryIdFromName($category);
    if ($old['draft'] && $publish) {
        $wasdraft = 1;
        $publish = 1;
    } else {
        $wasdraft = 0;
    }
    return _edititem($itemid, $username, $password, $catid, $title, $content, $old['more'], $wasdraft, $publish, $old['closed']);
}
コード例 #2
0
ファイル: api_mt.inc.php プロジェクト: hatone/Nucleus-v3.64
function _mt_setPostCategories($itemid, $username, $password, $category)
{
    global $manager;
    // login
    $mem = new MEMBER();
    if (!$mem->login($username, $password)) {
        return _error(1, "Could not log in");
    }
    // check if item exists
    if (!$manager->existsItem($itemid, 1, 1)) {
        return _error(6, "No such item ({$itemid})");
    }
    $blogid = getBlogIDFromItemID($itemid);
    $blog = new BLOG($blogid);
    if (!$mem->canAlterItem($itemid)) {
        return _error(7, "Not allowed to alter item");
    }
    $old =& $manager->getItem($itemid, 1, 1);
    $catid = $blog->getCategoryIdFromName($category);
    $publish = 0;
    if ($old['draft'] && $publish) {
        $wasdraft = 1;
        $publish = 1;
    } else {
        $wasdraft = 0;
    }
    return _edititem($itemid, $username, $password, $catid, $old['title'], $old['body'], $old['more'], $wasdraft, $publish, $old['closed']);
}
コード例 #3
0
ファイル: server.php プロジェクト: hatone/Nucleus-v3.64
/**
 * Adds item to blog, with time of item given
 */
function _addDatedItem($blogid, $username, $password, $title, $body, $more, $publish, $closed, $timestamp, $future, $catname = "")
{
    // 1. login
    $mem = new MEMBER();
    if (!$mem->login($username, $password)) {
        return _error(1, "Could not log in");
    }
    // 2. check if allowed to add to blog
    if (!BLOG::existsID($blogid)) {
        return _error(2, "No such blog ({$blogid})");
    }
    if (!$mem->teamRights($blogid)) {
        return _error(3, "Not a team member");
    }
    if (!trim($body)) {
        return _error(4, "Cannot add empty items!");
    }
    // 3. calculate missing vars
    $blog = new BLOG($blogid);
    // get category id (or id for default category when false category)
    $catid = $blog->getCategoryIdFromName($catname);
    if ($publish == 1) {
        $draft = 0;
    } else {
        $draft = 1;
    }
    if ($closed != 1) {
        $closed = 0;
    }
    if (strtolower(_CHARSET) != 'utf-8') {
        $title = mb_convert_encoding($title, _CHARSET, "UTF-8");
        $body = mb_convert_encoding($body, _CHARSET, "UTF-8");
        $more = mb_convert_encoding($more, _CHARSET, "UTF-8");
    }
    // 4. add to blog
    $itemid = $blog->additem($catid, $title, $body, $more, $blogid, $mem->getID(), $timestamp, $closed, $draft);
    // [TODO] ping weblogs.com ?
    return new xmlrpcresp(new xmlrpcval($itemid, "string"));
}
コード例 #4
0
function f_metaWeblog_editPost($m)
{
    global $manager;
    $itemid = _getScalar($m, 0);
    $username = _getScalar($m, 1);
    $password = _getScalar($m, 2);
    $category = '';
    $struct = $m->getParam(3);
    $content = _getStructVal($struct, 'description');
    $title = _getStructVal($struct, 'title');
    // category is optional (thus: be careful)!
    $catlist = $struct->structmem('categories');
    if ($catlist && $catlist->kindOf() == "array" && $catlist->arraysize() > 0) {
        $category = _getArrayVal($catlist, 0);
    }
    $publish = _getScalar($m, 4);
    // get old title and extended part
    if (!$manager->existsItem($itemid, 1, 1)) {
        return _error(6, "No such item ({$itemid})");
    }
    $blogid = getBlogIDFromItemID($itemid);
    $old =& $manager->getItem($itemid, 1, 1);
    if ($category == '') {
        // leave category unchanged when not present
        $catid = $old['catid'];
    } else {
        $blog = new BLOG($blogid);
        $catid = $blog->getCategoryIdFromName($category);
    }
    if ($old['draft'] && $publish) {
        $wasdraft = 1;
        $publish = 1;
    } else {
        $wasdraft = 0;
    }
    $more = $struct->structmem('mt_text_more');
    if ($more) {
        $more = _getStructVal($struct, 'mt_text_more');
    } else {
        $more = $old['more'];
    }
    $comments = $struct->structmem('mt_allow_comments');
    if ($comments) {
        //			$comments = (int) _getStructVal($struct, 'mt_allow_comments') ? 0 : 1;
        $closed = intval(_getStructVal($struct, 'mt_allow_comments')) == 1 ? 0 : 1;
    } else {
        //			$comments = $old['closed'];
        $closed = $old['closed'];
    }
    //		$res = _edititem($itemid, $username, $password, $catid, $title, $content, $more, $wasdraft, $publish, $comments);
    $res = _edititem($itemid, $username, $password, $catid, $title, $content, $more, $wasdraft, $publish, $closed);
    // Handle trackbacks
    $trackbacks = array();
    $tblist = $struct->structmem('mt_tb_ping_urls');
    if ($tblist && $tblist->kindOf() == "array" && $tblist->arraysize() > 0) {
        for ($i = 0; $i < $tblist->arraysize(); $i++) {
            $trackbacks[] = _getArrayVal($tblist, $i);
        }
        $manager->notify('SendTrackback', array('tb_id' => $itemid, 'urls' => &$trackbacks));
    }
    return $res;
}