/** * Moves one item to a given category (category existance should be checked by caller) * errors are returned * @param int $itemid * @param int $destCatid category ID to which the item will be moved */ function moveOneItem($itemid, $destCatid) { global $member; // only allow if user is allowed to move item if (!$member->canUpdateItem($itemid, $destCatid)) { return _ERROR_DISALLOWED; } ITEM::move($itemid, $destCatid); }
/** * Updates an item * * @static */ function update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp = 0) { global $manager; $itemid = intval($itemid); // make sure value is 1 or 0 if ($closed != 1) { $closed = 0; } // get destination blogid $new_blogid = getBlogIDFromCatID($catid); $old_blogid = getBlogIDFromItemID($itemid); // move will be done on end of method if ($new_blogid != $old_blogid) { $moveNeeded = 1; } // add <br /> before newlines $blog =& $manager->getBlog($new_blogid); if ($blog->convertBreaks()) { $body = addBreaks($body); $more = addBreaks($more); } // call plugins $manager->notify('PreUpdateItem', array('itemid' => $itemid, 'title' => &$title, 'body' => &$body, 'more' => &$more, 'blog' => &$blog, 'closed' => &$closed, 'catid' => &$catid)); // update item itsself $query = 'UPDATE ' . sql_table('item') . ' SET' . " ibody='" . sql_real_escape_string($body) . "'," . " ititle='" . sql_real_escape_string($title) . "'," . " imore='" . sql_real_escape_string($more) . "'," . " iclosed=" . intval($closed) . "," . " icat=" . intval($catid); // if we received an updated timestamp in the past, but past posting is not allowed, // reject that date change (timestamp = 0 will make sure the current date is kept) if (!$blog->allowPastPosting() && $timestamp < $blog->getCorrectTime()) { $timestamp = 0; } if ($timestamp > $blog->getCorrectTime(time())) { $isFuture = 1; $query .= ', iposted=0'; } else { $isFuture = 0; $query .= ', iposted=1'; } if ($wasdraft && $publish) { // set timestamp to current date only if it's not a future item // draft items have timestamp == 0 // don't allow timestamps in the past (unless otherwise defined in blogsettings) $query .= ', idraft=0'; if ($timestamp == 0) { $timestamp = $blog->getCorrectTime(); } // send new item notification if (!$isFuture && $blog->getNotifyAddress() && $blog->notifyOnNewItem()) { $blog->sendNewItemNotification($itemid, $title, $body); } } // save back to drafts if (!$wasdraft && !$publish) { $query .= ', idraft=1'; // set timestamp back to zero for a draft $query .= ", itime=" . mysqldate($timestamp); } // update timestamp when needed if ($timestamp != 0) { $query .= ", itime=" . mysqldate($timestamp); } // make sure the correct item is updated $query .= ' WHERE inumber=' . $itemid; // off we go! sql_query($query); $manager->notify('PostUpdateItem', array('itemid' => $itemid)); // when needed, move item and comments to new blog if ($moveNeeded) { ITEM::move($itemid, $catid); } //update the itemOptions $aOptions = requestArray('plugoption'); NucleusPlugin::_applyPluginOptions($aOptions); $manager->notify('PostPluginOptionsUpdate', array('context' => 'item', 'itemid' => $itemid, 'item' => array('title' => $title, 'body' => $body, 'more' => $more, 'closed' => $closed, 'catid' => $catid))); }