/** * deletes an item */ function _deleteItem($itemid, $username, $password) { global $manager; // 1. login $mem = new MEMBER(); if (!$mem->login($username, $password)) { return _error(1, "Could not log in"); } // 2. check if allowed if (!$manager->existsItem($itemid, 1, 1)) { return _error(6, "No such item ({$itemid})"); } $blogid = getBlogIDFromItemID($itemid); if (!$mem->teamRights($blogid)) { return _error(3, "Not a team member"); } // delete the item ITEM::delete($itemid); return new xmlrpcresp(new xmlrpcval(1, "boolean")); }
/** * Adds a item to the chosen blog */ function action_additem() { global $manager, $CONF; $manager->loadClass('ITEM'); $result = ITEM::createFromRequest(); if ($result['status'] == 'error') { $this->error($result['message']); } $blogid = getBlogIDFromItemID($result['itemid']); $blog =& $manager->getBlog($blogid); $btimestamp = $blog->getCorrectTime(); $item = $manager->getItem(intval($result['itemid']), 1, 1); if ($result['status'] == 'newcategory') { $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid)); $this->action_categoryedit($result['catid'], $blogid, $distURI); } else { $methodName = 'action_itemList'; call_user_func(array(&$this, $methodName), $blogid); } }
/** * Tries to create an draft from the data in the current request (comes from * bookmarklet or admin area * * Returns an array with status info: * status = 'added', 'error', 'newcategory' * * @static * * Used by xmlHTTPRequest AutoDraft */ function createDraftFromRequest() { global $member, $manager; $i_author = $member->getID(); $i_body = postVar('body'); $i_title = postVar('title'); $i_more = postVar('more'); if (strtoupper(_CHARSET) != 'UTF-8') { $i_body = mb_convert_encoding($i_body, _CHARSET, "UTF-8"); $i_title = mb_convert_encoding($i_title, _CHARSET, "UTF-8"); $i_more = mb_convert_encoding($i_more, _CHARSET, "UTF-8"); } //$i_actiontype = postVar('actiontype'); $i_closed = intPostVar('closed'); //$i_hour = intPostVar('hour'); //$i_minutes = intPostVar('minutes'); //$i_month = intPostVar('month'); //$i_day = intPostVar('day'); //$i_year = intPostVar('year'); $i_catid = postVar('catid'); $i_draft = 1; $type = postVar('type'); if ($type == 'edit') { $i_blogid = getBlogIDFromItemID(intPostVar('itemid')); } else { $i_blogid = intPostVar('blogid'); } $i_draftid = intPostVar('draftid'); if (!$member->canAddItem($i_catid)) { return array('status' => 'error', 'message' => _ERROR_DISALLOWED); } if (!trim($i_body)) { return array('status' => 'error', 'message' => _ERROR_NOEMPTYITEMS); } // create new category if needed if (strstr($i_catid, 'newcat')) { // Set in default category $blog =& $manager->getBlog($i_blogid); $i_catid = $blog->getDefaultCategory(); } else { // force blogid (must be same as category id) $i_blogid = getBlogIDFromCatID($i_catid); $blog =& $manager->getBlog($i_blogid); } $posttime = 0; if ($i_draftid > 0) { ITEM::update($i_draftid, $i_catid, $i_title, $i_body, $i_more, $i_closed, 1, 0, 0); $itemid = $i_draftid; } else { $itemid = $blog->additem($i_catid, $i_title, $i_body, $i_more, $i_blogid, $i_author, $posttime, $i_closed, $i_draft); } // No plugin support in AutoSaveDraft yet //Setting the itemOptions //$aOptions = requestArray('plugoption'); //NucleusPlugin::_applyPluginOptions($aOptions, $itemid); //$manager->notify('PostPluginOptionsUpdate',array('context' => 'item', 'itemid' => $itemid, 'item' => array('title' => $i_title, 'body' => $i_body, 'more' => $i_more, 'closed' => $i_closed, 'catid' => $i_catid))); // success return array('status' => 'added', 'draftid' => $itemid); }
/** * Parse skinvar comments * include comments for one item */ function parse_comments($template) { global $itemid, $manager, $blog, $highlight; $template =& $manager->getTemplate($template); // create parser object & action handler $actions =& new ITEMACTIONS($blog); $parser =& new PARSER($actions->getDefinedActions(), $actions); $actions->setTemplate($template); $actions->setParser($parser); $item = ITEM::getitem($itemid, 0, 0); $actions->setCurrentItem($item); $comments =& new COMMENTS($itemid); $comments->setItemActions($actions); $comments->showComments($template, -1, 1, $highlight); // shows ALL comments }
/** * Handles AutoSaveDraft */ function autoDraft() { global $manager; if ($manager->checkTicket()) { $manager->loadClass('ITEM'); $info = ITEM::createDraftFromRequest(); if ($info['status'] == 'error') { echo $info['message']; } else { echo $info['draftid']; } } else { echo _ERROR . ':' . _ERROR_BADTICKET; } return FALSE; }
function bm_doEditItem() { global $member, $manager, $CONF; $itemid = intRequestVar('itemid'); $catid = postVar('catid'); // only allow if user is allowed to alter item if (!$member->canUpdateItem($itemid, $catid)) { bm_doError(_ERROR_DISALLOWED); } $body = postVar('body'); $title = postVar('title'); $more = postVar('more'); $closed = intPostVar('closed'); $actiontype = postVar('actiontype'); $draftid = intPostVar('draftid'); // redirect to admin area on delete (has delete confirmation) if ($actiontype == 'delete') { redirect('index.php?action=itemdelete&itemid=' . $itemid); exit; } // create new category if needed (only on edit/changedate) if (strstr($catid, 'newcat')) { // get blogid list($blogid) = sscanf($catid, "newcat-%d"); // create $blog =& $manager->getBlog($blogid); $catid = $blog->createNewCategory(); // show error when sth goes wrong if (!$catid) { bm_doError(_BOOKMARKLET_ERROR_COULDNTNEWCAT); } } // only edit action is allowed for bookmarklet edit switch ($actiontype) { case 'changedate': $publish = 1; $wasdraft = 0; $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year')); break; case 'edit': $publish = 1; $wasdraft = 0; $timestamp = 0; break; case 'backtodrafts': $publish = 0; $wasdraft = 0; $timestamp = 0; break; default: bm_doError(_BOOKMARKLET_ERROR_SOMETHINGWRONG); } // update item for real ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp); if ($draftid > 0) { ITEM::delete($draftid); } // show success message if ($catid != intPostVar('catid')) { $href = 'index.php?action=categoryedit&blogid=' . $blog->getID() . '&catid=' . $catid; $onclick = 'if (event && event.preventDefault) event.preventDefault(); window.open(this.href); return false;'; $title = _BOOKMARKLET_NEW_WINDOW; $aTag = ' <a href="' . $href . '" onclick="' . $onclick . '" title="' . $title . '">'; $message = _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>'; bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _BOOKMARKLET_NEW_CATEGORY . $aTag . _BOOKMARKLET_NEW_CATEGORY_EDIT . '</a>', ''); } else { bm_message(_ITEM_UPDATED, _ITEM_UPDATED, _ITEM_UPDATED, ''); } }
/** * Checks if an item exists */ function existsItem($id, $future, $draft) { $this->_loadClass('ITEM', 'ITEM.php'); return ITEM::exists($id, $future, $draft); }