public function getDelete(Item $task) { if ($task->onwer_id == Auth::user()->id) { $task->delete(); } return Redirect::route('home'); }
function testDeleteEnd() { $Item = new Item(); $Item->delete(5); $results = $Item->find('all'); $expected = array(array('Item' => array('id' => 1, 'name' => 'Item A', 'order' => 0)), array('Item' => array('id' => 2, 'name' => 'Item B', 'order' => 1)), array('Item' => array('id' => 3, 'name' => 'Item C', 'order' => 2)), array('Item' => array('id' => 4, 'name' => 'Item D', 'order' => 3))); $this->assertEqual($results, $expected); }
function item_delete() { $item = new Item(); $item->where('id', $this->post('id')); $item->get(); $item->delete(); $message = array('id' => $this->post('id'), 'message' => 'DELETED!'); $this->response($message, 200); // 200 being the HTTP response code }
public function deleteItems($user) { Zend_Registry::get('logger')->entering(); Zend_Registry::get('logger')->debug('Load all items by user'); $itemTable = new Item(); $items = $itemTable->fetchAllByUser($user); foreach ($items as $item) { Zend_Registry::get('logger')->debug('Delete all tags from item'); $itemTable->deleteTags($item->id); Zend_Registry::get('logger')->debug('Delete item'); $where = $this->_db->quoteInto('id = ?', $item->id); $itemTable->delete($where); } Zend_Registry::get('logger')->exiting(); }
function testDelete() { // Arrange $collection_name = "Star Wars cards"; $test_collection = new Collection($collection_name); $test_collection->save(); $test_collection_id = $test_collection->getId(); $name = "Darth Vader Black Border Premier"; $test_item = new Item($name, $test_collection_id); $test_item->save(); // Act $test_item->delete(); $collection_items = $test_collection->getItems(); // Assert $this->assertEquals([], $collection_items); }
if ($s_oncology) { $s_newitem_id = $flot->datastore->s_new_item($s_oncology); $s_new_page = S_BASE_EXTENSION . "flot-admin/admin/index.php?section=items&oncology={$s_oncology}&item=" . $s_newitem_id . "&action=edit"; $flot->_page_change($s_new_page); } else { echo "no page type :("; } break; case 'delete': # create the new item, then do a page change to be editing it $s_page_id = $ufUf->s_get_var('item', false); if ($s_page_id) { // delete 'physical' copy on disk $o_item = $flot->datastore->get_item_data($s_page_id); $Item = new Item($o_item); $Item->delete(); // remove from datastore $flot->datastore->_delete_item($s_page_id); $s_new_page = S_BASE_EXTENSION . "flot-admin/admin/index.php?section=items&oncology=page&action=list"; $flot->_page_change($s_new_page); } break; } break; case "elements": $s_action = $ufUf->s_get_var_from_allowed("action", array("edit", "list", "new", "delete"), "list"); switch ($s_action) { case 'edit': $s_element_id = $ufUf->s_get_var('element', false); # menu items; purge from cache, preview, regenerate, delete if ($s_element_id) {
protected function delete_row() { if (empty($_REQUEST['item'])) { throw new Exception('No item specified'); } if (empty($_REQUEST['name'])) { throw new Exception('No field name specified'); } $item = new Item($_REQUEST['item']); $item->delete($_REQUEST['name']); echo json_encode(array('msg' => 'Removed row', 'code' => 0)); die; }
/** * @see EquipmentInterface::delete() * @return bool * @throws EquipmentDeleteItemLinkException * @throws EquipmentDeleteFailedException * @throws EquipmentNoInstanceException */ public function delete() { global $transaction; if ($this->equipment_id and $this->equipment) { $transaction_id = $transaction->begin(); try { parent::delete(); $equipment_is_item = new EquipmentIsItem_Access($this->equipment_id); if ($equipment_is_item->delete() == false) { throw new EquipmentDeleteItemLinkException(); } if ($this->equipment->delete() == false) { throw new EquipmentDeleteFailedException(); } } catch (BaseException $e) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw $e; } if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { throw new EquipmentNoInstanceException(); } }
public function test_get_a_week() { $currentWeek = jdate("W", time(), "", "Asia/Tehran", "en"); $currentYear = jdate("Y"); $twoWeekAgo = strtotime("-2 week"); $weekAgo = strtotime("-1 week"); $current = time() + 30; // chone ke momkene moghe get kardan state taghir kone man dige inja 30 sanie balatar zadam ke az in jahat moshekl pish nayad! $twoWeekLater = strtotime("+2 week"); $weekLater = strtotime("+1 week"); $oneHour = 3600; $tempItem = new Item(); $itemTwoWeekAge = new Item(); $itemTwoWeekAge->create($twoWeekAgo, $twoWeekAgo + $oneHour, "2 hafte gozashte", ITEM_STATE_DONE, 3)->save($this->user, $this->task); $itemOneWeekAge = new Item(); $itemOneWeekAge->create($weekAgo, $weekAgo + $oneHour, "1 hafte gozashte", ITEM_STATE_UNDONE)->save($this->user, $this->task); $itemCurrentWeek = new Item(); $itemCurrentWeek->create($current, $current + $oneHour, "hamin hafte", ITEM_STATE_INCOMING)->save($this->user, $this->task); $itemOneWeekLater = new Item(); $itemOneWeekLater->create($weekLater, $weekLater + $oneHour, "1 hafte bad", ITEM_STATE_UNDONE)->save($this->user, $this->task); $itemTwoWeekLater = new Item(); $itemTwoWeekLater->create($twoWeekLater, $twoWeekLater + $oneHour, "2 hafte bad", ITEM_STATE_UNDONE)->save($this->user, $this->task); $this->_assert_true($itemTwoWeekAge->__toString() == $tempItem->getByWeek($currentYear, $currentWeek - 2, $this->user)->__toString()); $this->_assert_true($itemOneWeekAge->__toString() == $tempItem->getByWeek($currentYear, $currentWeek - 1, $this->user)->__toString()); $this->_assert_true($itemCurrentWeek->__toString() == $tempItem->getByWeek($currentYear, $currentWeek, $this->user)->__toString()); $this->_assert_true($itemOneWeekLater->__toString() == $tempItem->getByWeek($currentYear, $currentWeek + 1, $this->user)->__toString()); $this->_assert_true($itemTwoWeekLater->__toString() == $tempItem->getByWeek($currentYear, $currentWeek + 2, $this->user)->__toString()); $itemTwoWeekAge->delete(); $itemOneWeekAge->delete(); $itemCurrentWeek->delete(); $itemOneWeekLater->delete(); $itemTwoWeekLater->delete(); }
/** * Attach a list of files to an item. * * @param Item $item * @param array $fileUrls An array of the urls of files to attach to item. * @param boolean $itemDelete Delete item (default) or not if the file can't * be ingested. * @return boolean True if success, false else. */ protected function _attachFilesToItem($item, $fileUrls, $itemDelete = true) { // Sometime, fileUrls is a null or an empty string. if (empty($fileUrls)) { return true; } foreach ($fileUrls as $fileUrl) { // Set the transfer strategy according to file name. $parsedFileUrl = parse_url($fileUrl); if (!isset($parsedFileUrl['scheme']) || $parsedFileUrl['scheme'] == 'file') { $transferStrategy = 'Filesystem'; $fileUrlOriginal = $fileUrl; $fileUrl = $parsedFileUrl['path']; if (!$this->_allowLocalPath($fileUrl)) { $msg = 'Local paths are not allowed by the administrator (%s) [%s].'; $this->_log($msg, array($fileUrlOriginal, !isset($parsedFileUrl['scheme']) ? 'no scheme' : 'file scheme'), Zend_Log::ERR); if ($itemDelete) { $item->delete(); } release_object($item); return false; } } else { $transferStrategy = 'Url'; $fileUrl = $this->_rawUrlEncode($fileUrl); } // Import the file and attach it to the item. try { $files = insert_files_for_item($item, $transferStrategy, $fileUrl, array('ignore_invalid_files' => false)); } catch (Omeka_File_Ingest_InvalidException $e) { $msg = 'Invalid file URL "%s": %s'; $this->_log($msg, array($fileUrl, $e->getMessage()), Zend_Log::ERR); if ($itemDelete) { $item->delete(); } release_object($item); return false; } catch (Omeka_File_Ingest_Exception $e) { $msg = 'Could not import file "%s": %s'; $this->_log($msg, array($fileUrl, $e->getMessage()), Zend_Log::ERR); if ($itemDelete) { $item->delete(); } release_object($item); return false; } release_object($files); } return true; }
function testDelete() { //Arrange $description = "Pliny the Elder"; $cost = 5.0; $id = null; $test_item = new Item($description, $cost, $id); $test_item->save(); $description2 = "Lagunitas IPA"; $cost2 = 7.0; $test_item2 = new Item($description2, $cost2, $id); $test_item2->save(); //Act $test_item->delete(); $result = Item::getAll(); //Assert $this->assertEquals($test_item2, $result[0]); }
public function delete() { if ($this->f3->exists('PARAMS.tok')) { //getIdByTok $getIdByTok = new Item($this->db); $getIdByTok->getIdByTok($this->f3->get('PARAMS.tok')); $iid = $this->f3->get('ID.id'); // del by ID (not by TOK) $tags = new Tag2Item($this->db); $loaderase = $tags->getByItemId($iid); if (count($loaderase) > 0) { foreach ($loaderase as $t) { $itemid = $t['id']; $deltags = new Tag2Item($this->db); $deltags->delete($itemid); } } $item = new Item($this->db); $item->delete($this->f3->get('PARAMS.tok')); } $this->f3->set('COOKIE.message', 'The bookmark was deleted'); $this->f3->set('COOKIE.messagetype', 'alert-info hide5s'); $this->f3->reroute('/'); }
private function deleteItem($id_item = null) { if (is_null($id_item)) { return false; } $item = new Item($id_item); return $item->delete(); }
public function destroyAction() { $this->logger->entering(); $this->logger->info('Loading item from params'); $items = new Item(); $item = $this->_getParam('item'); $this->logger->info("Loading item by id"); $id = $item['id']; $item = $items->find($id)->current(); $this->logger->info('Ensure owned by user'); if ($this->session->user_id != $item->owner_id) { $this->logger->warn('User is not item owner'); $this->flash->notice = "Invalid Action"; $this->_redirect('/'); } $this->logger->info("Delete item by id {$id}"); $where = $this->db->quoteInto('id = ?', $id); $rows_affected = $items->delete($where); $this->logger->info('Delete item tag associations'); $items->deleteTags($id); $this->logger->info("Removing old item from search index"); ItemIndex::delete($item); $this->logger->info('Redirect to item index'); $this->_redirect('items'); $this->logger->exiting(); }
function test_uncompleted_after_completed() { $item = new Item(); $item->create(time() + 1000, time() + 10000, "this item created for testing goal completed", ITEM_STATE_DONE_WAIT_FOR_FEEDBACK)->save($this->user, $this->task); $this->goal->create(100, strtotime("-1 week"), strtotime("+1 week"))->save($this->task); $item->delete(); $this->goal->get($this->goal->getId()); $this->_assert_equals($this->goal->getAchieveTime(), null); $item->delete(); }
//TODO Check item exists in database. if(!isset($_GET['id']) || !is_numeric($_GET['id'])){ redirect_to_url('/'); //Send to homepage. } else { $item_id = (int)$_GET['id']; } $item = new Item($item_id); QR::item($item_id); $valid_actions = array('delete', 'checkout', 'return'); if(isset($_GET['action']) && in_array($_GET['action'], $valid_actions)){ $auth->require_login(); $action = $_GET['action']; if( $action == 'delete' && $item->get_owner_id() == $user_id ){ Item::delete($item_id); redirect_to_url('/items/view_items.php?u=' . $user_id); } //TODO: May want to add check if item is available to be checked out else if( $action == 'checkout' ){ Item::checkout_by_ids($item_id, $user_id); redirect_to_url('/items/view_items.php?u=' . $user_id); } else if( $action == 'return' ){ Item::return_by_id($item_id, $user_id); //redirect_to_url('/items/view_items.php?u=' . $user_id); } } $page->assign('item', $item->to_array()); $page->assign('page_title', 'Item Details');
<?php include "../Errors.php"; require_once '../Classes/Item.php'; require_once '../Classes/Partida_Item.php'; $id_item = $_POST['TempDel']; $Partida_Item = new Partida_Item(); $Partida_Item->delete($id_item); $Item = new Item(); $Item->delete($id_item); echo 'Item Eliminat Correctament!!'; header('Location: ../../panel.php');
public function testShouldDeleteForeverIfAsked() { $this->Item->delete('hard', 1); $this->Item->includeDeletedRecords(); $this->assertEmpty($this->Item->read(null, 1)); }
/** * @see SampleInterface::delete() * @return bool * @throws SampleDeleteLocationException * @throws SampleDeleteUserException * @throws SampleDeleteOrganisationUnitException * @throws SampleDeleteItemException * @throws SampleDeleteFolderException * @throws SampleDeleteEventFailedException * @throws SampleDeleteFailedException * @throws SampleDeleteItemLinkException * @throws SampleNoInstanceException */ public function delete() { global $transaction; if ($this->sample_id and $this->sample) { $transaction_id = $transaction->begin(); try { array_push(self::$sample_delete_array, $this->sample_id); $tmp_sample_id = $this->sample_id; // Location Relations $sample_has_location_array = SampleHasLocation_Access::list_entries_by_sample_id($tmp_sample_id); if (is_array($sample_has_location_array) and count($sample_has_location_array) >= 1) { foreach ($sample_has_location_array as $key => $value) { $sample_has_location = new SampleHasLocation_Access($value); if ($sample_has_location->delete() == false) { throw new SampleDeleteLocationException(); } } } // Organisation Unit and User Relations $sample_security = new SampleSecurity($tmp_sample_id); $organisation_unit_array = $sample_security->list_organisation_unit_entries(); if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) { foreach ($organisation_unit_array as $key => $value) { if ($sample_security->delete_organisation_unit($value) == false) { throw new SampleDeleteOrganisationUnitException(); } } } $user_array = $sample_security->list_user_entries(); if (is_array($user_array) and count($user_array) >= 1) { foreach ($user_array as $key => $value) { if ($sample_security->delete_user($value) == false) { throw new SampleDeleteUserException(); } } } // Items $sample_item = new SampleItem($tmp_sample_id); $item_array = $sample_item->get_sample_items(); if (is_array($item_array) and count($item_array) >= 1) { foreach ($item_array as $item_key => $item_value) { $sample_item = new SampleItem($tmp_sample_id); $sample_item->set_item_id($item_value); if ($sample_item->unlink_item() == false) { throw new SampleDeleteItemException(); } } } // Parent-Sample-Sub-Item-Links if (SampleItem::delete_remaining_sample_entries($tmp_sample_id) == false) { throw new SampleDeleteItemException(); } parent::delete(); $sample_delete_event = new SampleDeleteEvent($tmp_sample_id); $event_handler = new EventHandler($sample_delete_event); if ($event_handler->get_success() == false) { throw new SampleDeleteEventFailedException(); } $sample_is_item = new SampleIsItem_Access($tmp_sample_id); if ($sample_is_item->delete() == false) { throw new SampleDeleteItemLinkException(); } if ($this->sample->delete() == false) { throw new SampleDeleteFailedException(); } else { $this->__destruct(); $folder_id = SampleFolder::get_folder_by_sample_id($tmp_sample_id); $folder = Folder::get_instance($folder_id); if ($folder->delete(true, true) == false) { throw new SampleDeleteFolderException(); } } } catch (BaseException $e) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw $e; } if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { throw new SampleNoInstanceException(); } }
public function delete() { $this->checkPermissionsHasAnyOf(Permission::DELETE); return parent::delete(); }
if ($user->check_email($_POST['email'])) { $isAvailable = true; } break; case 'phone': if ($user->check_phone($_POST['phone'])) { $isAvailable = true; } break; case 'vendor_email': if ($vendor->check_email($_POST['email'])) { $isAvailable = true; } break; case 'delete_item': if ($item->delete($_POST['object_id'])) { $isAvailable = true; } break; case 'delete_user': if ($user->delete($_POST['object_id'])) { $isAvailable = true; } break; case 'delete_vendor': if ($vendor->delete($_POST['object_id'])) { $isAvailable = true; } break; case 'toog_item': if ($_POST['status'] == 1) {
public function deleteItem($id) { $db = $this->db; $deleted = new Item(); $deleted->queryItem($db, $id); $deleted->delete($db, $id); }
public function remove_item($book_id) { $item = new Item(); $item->get("book_id = {$book_id} AND cart_id = " . $this->id); $item->delete(); }
if ($item->quantity >= $sellQuantity) { if ($isAdmin) { if ($chargeAdmins) { $itemFee = $item->marketprice / 100 * $auctionFee * $sellQuantity; } else { $itemFee = 0; } if ($player->money >= $itemFee) { $item->changeQuantity(0 - $sellQuantity); $timeNow = time(); $player->spend($itemFee, $useMySQLiConomy, $iConTableName); $itemQuery = mysql_query("INSERT INTO WA_Auctions (name, damage, player, quantity, price, created, allowBids, currentBid, currentWinner) VALUES ('{$item->name}', '{$item->damage}', '{$item->owner}', '{$sellQuantity}', '{$sellPrice}', '{$timeNow}', '{$allowBids}', '{$minBid}', '{$item->owner}')"); $queryLatestAuction = mysql_query("SELECT id FROM WA_Auctions ORDER BY id DESC"); list($latestId) = mysql_fetch_row($queryLatestAuction); if ($item->quantity == 0) { $item->delete(); } if ($useTwitter == true) { try { $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret); if ($sellQuantity == 0) { $twitQuant = "Infinite"; } else { $twitQuant = $sellQuantity; } $twitter->send('[WA] Auction Created: ' . $user . ' is selling ' . $twitQuant . ' x ' . $itemFullName . ' for ' . $currencyPrefix . $sellPrice . $currencyPostfix . ' each. At ' . date("H:i:s") . ' #webauction'); } catch (Exception $e) { //normally means you reached the daily twitter limit. } } $queryEnchants = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemId='{$item->id}' AND itemTableId ='0'");
/** * testSaveWithCounterCache method * * @return void */ public function testSaveWithCounterCache() { $this->loadFixtures('Syfile', 'Item', 'Image', 'Portfolio', 'ItemsPortfolio'); $TestModel = new Syfile(); $TestModel2 = new Item(); $result = $TestModel->findById(1); $this->assertSame($result['Syfile']['item_count'], null); $TestModel2->save(array('name' => 'Item 7', 'syfile_id' => 1, 'published' => false)); $result = $TestModel->findById(1); $this->assertEquals(2, $result['Syfile']['item_count']); $TestModel2->delete(1); $result = $TestModel->findById(1); $this->assertEquals(1, $result['Syfile']['item_count']); $TestModel2->id = 2; $TestModel2->saveField('syfile_id', 1); $result = $TestModel->findById(1); $this->assertEquals(2, $result['Syfile']['item_count']); $result = $TestModel->findById(2); $this->assertEquals(0, $result['Syfile']['item_count']); }
/** * Deletes a DataEntity * @return bool * @throws DataEntityDeleteParentLinkException * @throws DataEntityDeleteItemLinkException * @throws DataEntityDeleteFailedException * @throws DataEntityNoInstanceException */ protected function delete() { global $transaction; if ($this->data_entity_id) { $transaction_id = $transaction->begin(); try { if (DataEntityHasDataEntity_Access::delete_by_data_entity_cid($this->data_entity_id) == false) { throw new DataEntityDeleteParentLinkException(); } $data_entity_is_item = new DataEntityIsItem_Access($this->data_entity_id); if ($data_entity_is_item->delete() == false) { throw new DataEntityDeleteItemLinkException(); } if ($this->data_entity->delete() == false) { throw new DataEntityDeleteFailedException(); } parent::delete(); } catch (BaseException $e) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw $e; } if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { throw new DataEntityNoInstanceException(); } }