/** * Delete an item. If the current revision is not a draft, publish the region too. * * @param string $itemID * @return void * @author Drew McLellan */ public function delete_item($itemID) { $is_draft = $this->has_draft(); $new_rev = $this->create_new_revision(); $Items = new PerchContent_Items(); $Item = $Items->find_item($this->id(), $itemID, $new_rev); $Item->delete(); if (!$is_draft) { $this->publish($new_rev); } return true; }
$Region = $Regions->find($id); } // Check we have a region if (!$Region || !is_object($Region)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/'); } // Check permissions if (!$Region->role_may_edit($CurrentUser)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/edit/denied/'); } $Form = new PerchForm('reorder'); if ($Form->posted() && $Form->validate()) { $items = $Form->find_items('item_'); if (PerchUtil::count($items)) { foreach ($items as $itemID => $itemOrder) { $Item = $Items->find_item($Region->id(), $itemID, $Region->regionLatestRev()); if (is_object($Item)) { $data = array(); $data['itemOrder'] = (int) $itemOrder; $Item->update($data); } } $Region->set_option('sortField', ''); if (!$Region->has_draft()) { $Region->publish(); $Region->index(); } $Alert->set('success', PerchLang::get('Item orders successfully updated.')); PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . $Region->id()); } }