/** * Updates an item. Username and password are required to login */ function _edititem($itemid, $username, $password, $catid, $title, $body, $more, $wasdraft, $publish, $closed) { global $manager; // 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 (!$manager->existsItem($itemid, 1, 1)) { return _error(6, "No such item ({$itemid})"); } if (!$mem->canAlterItem($itemid)) { return _error(7, "Not allowed to alter item"); } if (strtolower(_CHARSET) != 'utf-8') { $title = mb_convert_encoding($title, _CHARSET, _CHARSET . ",UTF-8"); $body = mb_convert_encoding($body, _CHARSET, _CHARSET . ",UTF-8"); $more = mb_convert_encoding($more, _CHARSET, _CHARSET . ",UTF-8"); } // 3. update item ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, 0); return new xmlrpcresp(new xmlrpcval(1, "boolean")); }
function _mt_getPostCategories($itemid, $username, $password) { 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, 'You are not allowed to request this information'); } $info =& $manager->getItem($itemid, 1, 1); $catName = $blog->getCategoryName($info['catid']); $struct = new xmlrpcval(array('categoryId' => new xmlrpcval($catName, 'string'), 'categoryName' => new xmlrpcval($catName, 'string'), 'isPrimary' => new xmlrpcval(1, 'boolean')), 'struct'); return new xmlrpcresp(new xmlrpcval(array($struct), 'array')); }