OSDN Git Service

PDO対応
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / xmlrpc / api_mt.inc.php
index e04883b..f21e9a8 100755 (executable)
-<?php\r
-\r
-/*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2005 The Nucleus Group\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * (see nucleus/documentation/index.html#license for more info)\r
- */\r
-/**\r
- * This file contains definitions for the methods in the Movable Type API\r
- *\r
- * Wouter Demuynck 2003-08-31\r
- *\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2005 The Nucleus Group\r
- * @version $Id: api_mt.inc.php,v 1.4 2005-04-20 07:02:31 kimitake Exp $\r
- * $NucleusJP: api_mt.inc.php,v 1.3 2005/03/12 06:19:06 kimitake Exp $\r
- */\r
-\r
-       // mt.supportedMethods\r
-       $f_mt_supportedMethods_sig = array(array(\r
-                       // return type\r
-                       $xmlrpcArray // array of strings\r
-               ));\r
-       $f_mt_supportedMethods_doc = 'returns an array of supported methods';\r
-       function f_mt_supportedMethods($m) {\r
-               $res = new xmlrpcresp(new xmlrpcval( \r
-                       array(\r
-                               new xmlrpcval('mt.supportedMethods', 'string'),\r
-                               new xmlrpcval('mt.supportedTextFilters', 'string'),\r
-                               new xmlrpcval('mt.publishPost', 'string'),\r
-                               new xmlrpcval('mt.getCategoryList', 'string'),\r
-                               new xmlrpcval('mt.getPostCategories', 'string'),\r
-                               new xmlrpcval('mt.setPostCategories', 'string'),\r
-                               new xmlrpcval('mt.getRecentPostTitles', 'string'),\r
-                               new xmlrpcval('mt.getTrackbackPings','string'),\r
-                       ), 'array')\r
-               );\r
-               return $res;\r
-       }\r
-       \r
-       // mt.supportedTextFilters\r
-       $f_mt_supportedTextFilters_sig = array(array(\r
-                       // return type\r
-                       $xmlrpcArray    // array of structs\r
-               ));\r
-       $f_mt_supportedTextFilters_doc = 'returns the supported text filters';\r
-       function f_mt_supportedTextFilters($m) {\r
-               $res = new xmlrpcresp(new xmlrpcval( \r
-                       array(\r
-                               // no text filters in nucleus\r
-                       ), 'array')\r
-               );\r
-               return $res;\r
-       }\r
-       \r
-       // mt.getCategoryList\r
-       $f_mt_getCategoryList_sig = array(array(\r
-                       // return type\r
-                       $xmlrpcArray,           // array of structs\r
-                       \r
-                       // params\r
-                       $xmlrpcString,          // blogid\r
-                       $xmlrpcString,          // username\r
-                       $xmlrpcString           // password\r
-                       \r
-               ));\r
-       $f_mt_getCategoryList_doc = 'Returns a list of all categories defined in the weblog';\r
-       function f_mt_getCategoryList($m) {\r
-               $blogid =       _getScalar($m,0);\r
-               $username =     _getScalar($m,1);\r
-               $password =     _getScalar($m,2);\r
-\r
-               return _mt_categoryList($blogid, $username, $password);\r
-       }\r
-       \r
-       // mt.publishPost\r
-       $f_mt_publishPost_sig = array(array(\r
-                       // return type\r
-                       $xmlrpcBoolean,         // true\r
-                       \r
-                       // params\r
-                       $xmlrpcString,          // itemid\r
-                       $xmlrpcString,          // username\r
-                       $xmlrpcString           // password\r
-               ));\r
-       $f_mt_publishPost_doc = 'Transfers an item from the "draft" state to the "published" state. For items that were published earlier, does nothing.';\r
-       function f_mt_publishPost($m) {\r
-               $itemid         = intval(_getScalar($m, 0));\r
-               $username       = _getScalar($m, 1);\r
-               $password       = _getScalar($m, 2);            \r
-               \r
-               return _mt_publishPost($itemid, $username, $password);\r
-       }\r
-       \r
-       // mt.getPostCategories\r
-       $f_mt_getPostCategories_sig = array(array(\r
-               // return\r
-               $xmlrpcArray,           // array of structs\r
-               // parameters\r
-               $xmlrpcString,          // itemid\r
-               $xmlrpcString,          // username\r
-               $xmlrpcString           // password\r
-       ));\r
-       $f_mt_getPostCategories_doc = 'Returns a list of all categories to which the post is assigned.';\r
-       function f_mt_getPostCategories($m) {\r
-               $itemid         = intval(_getScalar($m, 0));\r
-               $username       = _getScalar($m, 1);\r
-               $password       = _getScalar($m, 2);\r
-               \r
-               return _mt_getPostCategories($itemid, $username, $password);\r
-       }\r
-\r
-       // mt.setPostCategories\r
-       $f_mt_setPostCategories_sig = array(array(\r
-               // return\r
-               $xmlrpcBoolean,         // true\r
-               // parameters\r
-               $xmlrpcString,          // itemid\r
-               $xmlrpcString,          // username\r
-               $xmlrpcString,          // password\r
-               $xmlrpcArray            // categories\r
-       ));\r
-       $f_mt_setPostCategories_doc = 'Sets the categories for a post. Only the primary category will be stored';\r
-       function f_mt_setPostCategories($m) {\r
-               $itemid         = intval(_getScalar($m, 0));\r
-               $username       = _getScalar($m, 1);\r
-               $password       = _getScalar($m, 2);\r
-\r
-               $categories = $m->getParam(3);\r
-               $iSize = $categories->arraysize();              \r
-\r
-               $category = '';\r
-               for ($i=0;$i<$iSize;$i++) {\r
-                       $struct = $categories->arraymem($i);\r
-                       $bPrimary = $struct->structmem('isPrimary');\r
-                       if ($bPrimary)\r
-                               $bPrimary = $bPrimary->scalarval();\r
-                       else if (!$category)\r
-                               $bPrimary = 1;  // "Using isPrimary to set the primary category is optional--\r
-                                                               // in the absence of this flag, the first struct in the array \r
-                                                               // will be assigned the primary category for the post." (MT doc)\r
-                       if ($bPrimary) {\r
-                               $category = $struct->structmem('categoryId');\r
-                               $category = $category->scalarval();\r
-                       }\r
-                       \r
-               }\r
-               \r
-               return _mt_setPostCategories($itemid, $username, $password, $category);\r
-       }\r
-       \r
-       // mt.getRecentPostTitles\r
-       $f_mt_getRecentPostTitles_sig = array(array(\r
-               // return\r
-               $xmlrpcArray,           // array of structs\r
-               // params\r
-               $xmlrpcString,          // blogid\r
-               $xmlrpcString,          // userid\r
-               $xmlrpcString,          // password,\r
-               $xmlrpcInt                      // number of posts\r
-       ));\r
-       $f_mt_getRecentPostTitles_doc = 'Returns a bandwidth-friendly list of the most recent posts in the system.';\r
-       function f_mt_getRecentPostTitles($m) {\r
-               $blogid         = intval(_getScalar($m, 0));\r
-               $username       = _getScalar($m, 1);            \r
-               $password       = _getScalar($m, 2);\r
-               $iAmount        = intval(_getScalar($m, 3));\r
-               \r
-               return _mt_getRecentPostTitles($blogid, $username, $password, $iAmount);\r
-       }\r
-\r
-       // mt.getTrackbackPings\r
-       $f_mt_getTrackbackPings_sig = array(array(\r
-               // return\r
-               $xmlrpcArray,           // array of structs\r
-               // params\r
-               $xmlrpcString           // postid\r
-       ));\r
-       $f_mt_getTrackbackPings_doc = '(this is currently just a placeholder. It returns an empty array.)';\r
-       function f_mt_getTrackbackPings($m) {\r
-               $itemid = intval(_getScalar($m, 0));\r
-                               \r
-               return new xmlrpcresp(new xmlrpcval(array(), 'array'));\r
-       }\r
-       \r
-       $functionDefs = array_merge($functionDefs,\r
-               array(\r
-                        "mt.supportedMethods" =>\r
-                        array( "function" => "f_mt_supportedMethods",\r
-                               "signature" => $f_mt_supportedMethods_sig,\r
-                               "docstring" => $f_mt_supportedMethods_doc),\r
-               \r
-                        "mt.supportedTextFilters" =>\r
-                        array( "function" => "f_mt_supportedTextFilters",\r
-                               "signature" => $f_mt_supportedTextFilters_sig,\r
-                               "docstring" => $f_mt_supportedTextFilters_doc),\r
-                               \r
-                        "mt.getCategoryList" =>\r
-                        array( "function" => "f_mt_getCategoryList",\r
-                               "signature" => $f_mt_getCategoryList_sig,\r
-                               "docstring" => $f_mt_getCategoryList_doc),\r
-                               \r
-                        "mt.publishPost" =>\r
-                        array( "function" => "f_mt_publishPost",\r
-                               "signature" => $f_mt_publishPost_sig,\r
-                               "docstring" => $f_mt_publishPost_doc),\r
-                               \r
-                        "mt.getPostCategories" =>\r
-                        array( "function" => "f_mt_getPostCategories",\r
-                               "signature" => $f_mt_getPostCategories_sig,\r
-                               "docstring" => $f_mt_getPostCategories_doc),\r
-                               \r
-                        "mt.setPostCategories" =>\r
-                        array( "function" => "f_mt_setPostCategories",\r
-                               "signature" => $f_mt_setPostCategories_sig,\r
-                               "docstring" => $f_mt_setPostCategories_doc),\r
-                               \r
-                        "mt.getRecentPostTitles" =>\r
-                        array( "function" => "f_mt_getRecentPostTitles",\r
-                               "signature" => $f_mt_getRecentPostTitles_sig,\r
-                               "docstring" => $f_mt_getRecentPostTitles_doc),\r
-\r
-                        "mt.getTrackbackPings" =>\r
-                        array( "function" => "f_mt_getTrackbackPings",\r
-                               "signature" => $f_mt_getTrackbackPings_sig,\r
-                               "docstring" => $f_mt_getTrackbackPings_doc)\r
-\r
-               )\r
-       );\r
-\r
-       function _mt_setPostCategories($itemid, $username, $password, $category) {\r
-               global $manager;\r
-\r
-               // login\r
-               $mem = new MEMBER();\r
-               if (!$mem->login($username, $password))\r
-                       return _error(1,"Could not log in");\r
-\r
-               // check if item exists                 \r
-               if (!$manager->existsItem($itemid,1,1))\r
-                       return _error(6,"No such item ($itemid)");\r
-                       \r
-               $blogid = getBlogIDFromItemID($itemid);\r
-               $blog = new BLOG($blogid);\r
-\r
-               if (!$mem->canAlterItem($itemid))\r
-                       return _error(7,"Not allowed to alter item");\r
-               \r
-               $old =& $manager->getItem($itemid,1,1);         \r
-\r
-               $catid = $blog->getCategoryIdFromName($category);               \r
-\r
-               $publish = 0;\r
-               if ($old['draft'] && $publish) {\r
-                       $wasdraft = 1;\r
-                       $publish = 1;\r
-               } else {\r
-                       $wasdraft = 0;\r
-               }\r
-               \r
-               return _edititem($itemid, $username, $password, $catid, $old['title'], $old['body'], $old['more'], $wasdraft, $publish, $old['closed']);\r
-       }\r
-       \r
-       \r
-       function _mt_getPostCategories($itemid, $username, $password) {\r
-               global $manager;\r
-\r
-               // login\r
-               $mem = new MEMBER();\r
-               if (!$mem->login($username, $password))\r
-                       return _error(1,"Could not log in");\r
-\r
-               // check if item exists                 \r
-               if (!$manager->existsItem($itemid,1,1))\r
-                       return _error(6,"No such item ($itemid)");\r
-\r
-               $blogid = getBlogIDFromItemID($itemid);\r
-               $blog = new BLOG($blogid);\r
-\r
-               if (!$mem->canAlterItem($itemid))\r
-                       return _error(7, 'You are not allowed to request this information');\r
-               \r
-               $info =& $manager->getItem($itemid,1,1);                \r
-               $catName = $blog->getCategoryName($info['catid']);\r
-               \r
-               $struct = new xmlrpcval(\r
-                       array(\r
-                               'categoryId' => new xmlrpcval($catName, 'string'),\r
-                               'categoryName' => new xmlrpcval($catName, 'string'),\r
-                               'isPrimary'     => new xmlrpcval(1, 'boolean')\r
-                       ), 'struct'\r
-               );              \r
-               \r
-               return new xmlrpcresp(new xmlrpcval(array($struct), 'array'));\r
-\r
-       }\r
-       \r
-       function _mt_publishPost($itemid, $username, $password) {\r
-               global $manager;\r
-               \r
-               if (!$manager->existsItem($itemid,1,1))\r
-                       return _error(6,"No such item ($itemid)");\r
-\r
-               // get item data\r
-               $blogid = getBlogIDFromItemID($itemid);\r
-               $blog = new BLOG($blogid);\r
-               $old =& $manager->getItem($itemid,1,1);\r
-\r
-               return _edititem($itemid, $username, $password, $old['catid'], $old['title'], $old['body'], $old['more'], $old['draft'], 1, $old['closed']);\r
-       }\r
-       \r
-       \r
-       function _mt_categoryList($blogid, $username, $password) {\r
-               // 1. login\r
-               $mem = new MEMBER();\r
-               if (!$mem->login($username, $password))\r
-                       return _error(1,"Could not log in");\r
-\r
-               // check if on team and blog exists\r
-               if (!BLOG::existsID($blogid))\r
-                       return _error(2,"No such blog ($blogid)");\r
-               if (!$mem->teamRights($blogid))\r
-                       return _error(3,"Not a team member");\r
-                       \r
-               $b = new BLOG($blogid);\r
-               \r
-               $categorystruct = array();\r
-\r
-               $query =  "SELECT cname, cdesc, catid"\r
-                               . ' FROM '.sql_table('category')\r
-                               . " WHERE cblog=" . intval($blogid)\r
-                               . " ORDER BY cname";\r
-               $r = sql_query($query);\r
-\r
-               while ($obj = mysql_fetch_object($r)) {\r
-\r
-                       $categorystruct[] = new xmlrpcval(\r
-                               array(\r
-                                       "categoryName" => new xmlrpcval($obj->cname,"string"),\r
-                                       "categoryId" => new xmlrpcval($obj->cname,"string")\r
-                               )\r
-                       ,'struct');\r
-                       \r
-               }\r
-               \r
-               \r
-               return new xmlrpcresp(new xmlrpcval( $categorystruct , "array"));\r
-       \r
-       }\r
-       \r
-       function _mt_getRecentPostTitles($blogid, $username, $password, $iAmount) \r
-       {\r
-               $blogid = intval($blogid);\r
-               $iAmount = intval($iAmount);\r
-       \r
-               // 1. login\r
-               $mem = new MEMBER();\r
-               if (!$mem->login($username, $password))\r
-                       return _error(1,"Could not log in");\r
-\r
-               // 2. check if allowed \r
-               if (!BLOG::existsID($blogid))\r
-                       return _error(2,"No such blog ($blogid)");\r
-               if (!$mem->teamRights($blogid))\r
-                       return _error(3,"Not a team member");\r
-               $iAmount = intval($iAmount);\r
-               if ($iAmount < 1)\r
-                       return _error(5,"Amount parameter must be positive");\r
-\r
-               // 3. create and return list of recent items\r
-               // Struct returned has dateCreated, userid, postid and title\r
-               \r
-               $blog = new BLOG($blogid);\r
-\r
-               $structarray = array();         // the array in which the structs will be stored\r
-\r
-               $query = "SELECT inumber, ititle as title, itime, iauthor"\r
-                          .' FROM '.sql_table('item')\r
-                          ." WHERE iblog=$blogid"\r
-                          ." ORDER BY itime DESC"\r
-                          ." LIMIT $iAmount";\r
-               $r = sql_query($query);\r
-               \r
-               while ($row = mysql_fetch_assoc($r)) {\r
-               \r
-                       $newstruct = new xmlrpcval(array(\r
-                               "dateCreated" => new xmlrpcval(iso8601_encode(strtotime($row['itime'])),"dateTime.iso8601"),\r
-                               "postid" => new xmlrpcval($row['inumber'],"string"),\r
-                               "title" => new xmlrpcval($row['title'],"string"),\r
-                               "userid" => new xmlrpcval($row['iauthor'],"string")\r
-                       ),'struct');\r
-               \r
-                       array_push($structarray, $newstruct);           \r
-               }\r
-\r
-               return new xmlrpcresp(new xmlrpcval( $structarray , "array"));\r
-       \r
-       }\r
-       \r
-\r
-\r
-?>\r
+<?php
+
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2009 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * This file contains definitions for the methods in the Movable Type API
+ *
+ * Wouter Demuynck 2003-08-31
+ *
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id$
+ *  * $NucleusJP: api_mt.inc.php,v 1.5 2006/07/17 20:03:45 kimitake Exp $
+ */
+
+       // mt.supportedMethods
+       $f_mt_supportedMethods_sig = array(array(
+                       // return type
+                       $xmlrpcArray // array of strings
+               ));
+       $f_mt_supportedMethods_doc = 'returns an array of supported methods';
+       function f_mt_supportedMethods($m) {
+               $res = new xmlrpcresp(new xmlrpcval(
+                       array(
+                               new xmlrpcval('mt.supportedMethods', 'string'),
+                               new xmlrpcval('mt.supportedTextFilters', 'string'),
+                               new xmlrpcval('mt.publishPost', 'string'),
+                               new xmlrpcval('mt.getCategoryList', 'string'),
+                               new xmlrpcval('mt.getPostCategories', 'string'),
+                               new xmlrpcval('mt.setPostCategories', 'string'),
+                               new xmlrpcval('mt.getRecentPostTitles', 'string'),
+                               new xmlrpcval('mt.getTrackbackPings','string'),
+                       ), 'array')
+               );
+               return $res;
+       }
+
+       // mt.supportedTextFilters
+       $f_mt_supportedTextFilters_sig = array(array(
+                       // return type
+                       $xmlrpcArray    // array of structs
+               ));
+       $f_mt_supportedTextFilters_doc = 'returns the supported text filters';
+       function f_mt_supportedTextFilters($m) {
+               $res = new xmlrpcresp(new xmlrpcval(
+                       array(
+                               // no text filters in nucleus
+                       ), 'array')
+               );
+               return $res;
+       }
+
+       // mt.getCategoryList
+       $f_mt_getCategoryList_sig = array(array(
+                       // return type
+                       $xmlrpcArray,           // array of structs
+
+                       // params
+                       $xmlrpcString,          // blogid
+                       $xmlrpcString,          // username
+                       $xmlrpcString           // password
+
+               ));
+       $f_mt_getCategoryList_doc = 'Returns a list of all categories defined in the weblog';
+       function f_mt_getCategoryList($m) {
+               $blogid =       _getScalar($m,0);
+               $username =     _getScalar($m,1);
+               $password =     _getScalar($m,2);
+
+               return _mt_categoryList($blogid, $username, $password);
+       }
+
+       // mt.publishPost
+       $f_mt_publishPost_sig = array(array(
+                       // return type
+                       $xmlrpcBoolean,         // true
+
+                       // params
+                       $xmlrpcString,          // itemid
+                       $xmlrpcString,          // username
+                       $xmlrpcString           // password
+               ));
+       $f_mt_publishPost_doc = 'Transfers an item from the "draft" state to the "published" state. For items that were published earlier, does nothing.';
+       function f_mt_publishPost($m) {
+               $itemid         = intval(_getScalar($m, 0));
+               $username       = _getScalar($m, 1);
+               $password       = _getScalar($m, 2);
+
+               return _mt_publishPost($itemid, $username, $password);
+       }
+
+       // mt.getPostCategories
+       $f_mt_getPostCategories_sig = array(array(
+               // return
+               $xmlrpcArray,           // array of structs
+               // parameters
+               $xmlrpcString,          // itemid
+               $xmlrpcString,          // username
+               $xmlrpcString           // password
+       ));
+       $f_mt_getPostCategories_doc = 'Returns a list of all categories to which the post is assigned.';
+       function f_mt_getPostCategories($m) {
+               $itemid         = intval(_getScalar($m, 0));
+               $username       = _getScalar($m, 1);
+               $password       = _getScalar($m, 2);
+
+               return _mt_getPostCategories($itemid, $username, $password);
+       }
+
+       // mt.setPostCategories
+       $f_mt_setPostCategories_sig = array(array(
+               // return
+               $xmlrpcBoolean,         // true
+               // parameters
+               $xmlrpcString,          // itemid
+               $xmlrpcString,          // username
+               $xmlrpcString,          // password
+               $xmlrpcArray            // categories
+       ));
+       $f_mt_setPostCategories_doc = 'Sets the categories for a post. Only the primary category will be stored';
+       function f_mt_setPostCategories($m) {
+               $itemid         = intval(_getScalar($m, 0));
+               $username       = _getScalar($m, 1);
+               $password       = _getScalar($m, 2);
+
+               $categories = $m->getParam(3);
+               $iSize = $categories->arraysize();
+
+               $category = '';
+               for ($i=0;$i<$iSize;$i++) {
+                       $struct = $categories->arraymem($i);
+                       $bPrimary = $struct->structmem('isPrimary');
+                       if ($bPrimary)
+                               $bPrimary = $bPrimary->scalarval();
+                       else if (!$category)
+                               $bPrimary = 1;  // "Using isPrimary to set the primary category is optional--
+                                                               // in the absence of this flag, the first struct in the array
+                                                               // will be assigned the primary category for the post." (MT doc)
+                       if ($bPrimary) {
+                               $category = $struct->structmem('categoryId');
+                               $category = $category->scalarval();
+                       }
+
+               }
+
+               return _mt_setPostCategories($itemid, $username, $password, $category);
+       }
+
+       // mt.getRecentPostTitles
+       $f_mt_getRecentPostTitles_sig = array(array(
+               // return
+               $xmlrpcArray,           // array of structs
+               // params
+               $xmlrpcString,          // blogid
+               $xmlrpcString,          // userid
+               $xmlrpcString,          // password,
+               $xmlrpcInt                      // number of posts
+       ));
+       $f_mt_getRecentPostTitles_doc = 'Returns a bandwidth-friendly list of the most recent posts in the system.';
+       function f_mt_getRecentPostTitles($m) {
+               $blogid         = intval(_getScalar($m, 0));
+               $username       = _getScalar($m, 1);
+               $password       = _getScalar($m, 2);
+               $iAmount        = intval(_getScalar($m, 3));
+
+               return _mt_getRecentPostTitles($blogid, $username, $password, $iAmount);
+       }
+
+       // mt.getTrackbackPings
+       $f_mt_getTrackbackPings_sig = array(array(
+               // return
+               $xmlrpcArray,           // array of structs
+               // params
+               $xmlrpcString           // postid
+       ));
+       $f_mt_getTrackbackPings_doc = '(this is currently just a placeholder. It returns an empty array.)';
+       function f_mt_getTrackbackPings($m) {
+               global $manager;
+               
+               $itemid = intval(_getScalar($m, 0));
+
+               $trackbacks = array ();
+               $tbstruct   = array ();
+                       
+               $manager->notify('RetrieveTrackback', array ('tb_id' => $itemid, 'trackbacks' => & $trackbacks));
+                               
+               while (list(,$v) = each ($trackbacks)) {
+                       $tbstruct[] = new xmlrpcval(
+                               array(
+                                       "pingTitle" => new xmlrpcval($v['title'], "string"),
+                                       "pingURL"   => new xmlrpcval($v['url'], "string"),
+                                       "pingIP"    => new xmlrpcval($v['ip'], "string")
+                               )
+                       ,'struct');                     
+               }               
+                               
+               return new xmlrpcresp(new xmlrpcval( $tbstruct , "array"));
+       }
+
+       $functionDefs = array_merge($functionDefs,
+               array(
+                        "mt.supportedMethods" =>
+                        array( "function" => "f_mt_supportedMethods",
+                               "signature" => $f_mt_supportedMethods_sig,
+                               "docstring" => $f_mt_supportedMethods_doc),
+
+                        "mt.supportedTextFilters" =>
+                        array( "function" => "f_mt_supportedTextFilters",
+                               "signature" => $f_mt_supportedTextFilters_sig,
+                               "docstring" => $f_mt_supportedTextFilters_doc),
+
+                        "mt.getCategoryList" =>
+                        array( "function" => "f_mt_getCategoryList",
+                               "signature" => $f_mt_getCategoryList_sig,
+                               "docstring" => $f_mt_getCategoryList_doc),
+
+                        "mt.publishPost" =>
+                        array( "function" => "f_mt_publishPost",
+                               "signature" => $f_mt_publishPost_sig,
+                               "docstring" => $f_mt_publishPost_doc),
+
+                        "mt.getPostCategories" =>
+                        array( "function" => "f_mt_getPostCategories",
+                               "signature" => $f_mt_getPostCategories_sig,
+                               "docstring" => $f_mt_getPostCategories_doc),
+
+                        "mt.setPostCategories" =>
+                        array( "function" => "f_mt_setPostCategories",
+                               "signature" => $f_mt_setPostCategories_sig,
+                               "docstring" => $f_mt_setPostCategories_doc),
+
+                        "mt.getRecentPostTitles" =>
+                        array( "function" => "f_mt_getRecentPostTitles",
+                               "signature" => $f_mt_getRecentPostTitles_sig,
+                               "docstring" => $f_mt_getRecentPostTitles_doc),
+
+                        "mt.getTrackbackPings" =>
+                        array( "function" => "f_mt_getTrackbackPings",
+                               "signature" => $f_mt_getTrackbackPings_sig,
+                               "docstring" => $f_mt_getTrackbackPings_doc)
+
+               )
+       );
+
+       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']);
+       }
+
+
+       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'));
+
+       }
+
+       function _mt_publishPost($itemid, $username, $password) {
+               global $manager;
+
+               if (!$manager->existsItem($itemid,1,1))
+                       return _error(6,"No such item ($itemid)");
+
+               // get item data
+               $blogid = getBlogIDFromItemID($itemid);
+               $blog = new BLOG($blogid);
+               $old =& $manager->getItem($itemid,1,1);
+
+               return _edititem($itemid, $username, $password, $old['catid'], $old['title'], $old['body'], $old['more'], $old['draft'], 1, $old['closed']);
+       }
+
+
+       function _mt_categoryList($blogid, $username, $password) {
+               // 1. login
+               $mem = new MEMBER();
+               if (!$mem->login($username, $password))
+                       return _error(1,"Could not log in");
+
+               // check if on team and blog exists
+               if (!BLOG::existsID($blogid))
+                       return _error(2,"No such blog ($blogid)");
+               if (!$mem->teamRights($blogid))
+                       return _error(3,"Not a team member");
+
+               $b = new BLOG($blogid);
+
+               $categorystruct = array();
+
+               $query =  "SELECT cname, cdesc, catid"
+                               . ' FROM '.sql_table('category')
+                               . " WHERE cblog=" . intval($blogid)
+                               . " ORDER BY cname";
+               $r = sql_query($query);
+
+               while ($obj = sql_fetch_object($r)) {
+
+                       $categorystruct[] = new xmlrpcval(
+                               array(
+                                       "categoryName" => new xmlrpcval($obj->cname,"string"),
+                                       "categoryId" => new xmlrpcval($obj->cname,"string")
+                               )
+                       ,'struct');
+
+               }
+
+
+               return new xmlrpcresp(new xmlrpcval( $categorystruct , "array"));
+
+       }
+
+       function _mt_getRecentPostTitles($blogid, $username, $password, $iAmount)
+       {
+               $blogid = intval($blogid);
+               $iAmount = intval($iAmount);
+
+               // 1. login
+               $mem = new MEMBER();
+               if (!$mem->login($username, $password))
+                       return _error(1,"Could not log in");
+
+               // 2. check if allowed
+               if (!BLOG::existsID($blogid))
+                       return _error(2,"No such blog ($blogid)");
+               if (!$mem->teamRights($blogid))
+                       return _error(3,"Not a team member");
+               $iAmount = intval($iAmount);
+               if ($iAmount < 1)
+                       return _error(5,"Amount parameter must be positive");
+
+               // 3. create and return list of recent items
+               // Struct returned has dateCreated, userid, postid and title
+
+               $blog = new BLOG($blogid);
+
+               $structarray = array();         // the array in which the structs will be stored
+
+               $query = "SELECT inumber, ititle as title, itime, iauthor"
+                          .' FROM '.sql_table('item')
+                          ." WHERE iblog=$blogid"
+                          ." ORDER BY itime DESC"
+                          ." LIMIT $iAmount";
+               $r = sql_query($query);
+
+               while ($row = sql_fetch_assoc($r)) {
+
+                       $newstruct = new xmlrpcval(array(
+                               "dateCreated" => new xmlrpcval(iso8601_encode(strtotime($row['itime'])),"dateTime.iso8601"),
+                               "postid" => new xmlrpcval($row['inumber'],"string"),
+                               "title" => new xmlrpcval($row['title'],"string"),
+                               "userid" => new xmlrpcval($row['iauthor'],"string")
+                       ),'struct');
+
+                       array_push($structarray, $newstruct);
+               }
+
+               return new xmlrpcresp(new xmlrpcval( $structarray , "array"));
+
+       }
+
+
+
+?>
\ No newline at end of file