本文整理汇总了PHP中Location::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::delete方法的具体用法?PHP Location::delete怎么用?PHP Location::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location::delete方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDelete
public function testDelete()
{
$loc = new Location();
$loc->setBuildingID(1);
$loc->setRoom(9999);
$loc->save();
$this->assertTrue(Location::locationExists($loc->getBuildingId(), $loc->getRoom()) != false);
$loc->delete();
$this->assertTrue(!Location::locationExists($loc->getBuildingId(), $loc->getRoom()));
}
示例2: testTree
//.........这里部分代码省略.........
$sons = getSonsOf('glpi_locations',$id[0]);
$this->assertEquals(3, count($sons));
$this->assertArrayHasKey($id[0], $sons);
$this->assertArrayHasKey($id[1], $sons);
$this->assertArrayHasKey($id[2], $sons);
// Ancestors of A (none)
$parent = getAncestorsOf('glpi_locations', $id[0]);
$this->assertEquals(0, count($parent));
// Ancestors of AA (A)
$parent = getAncestorsOf('glpi_locations', $id[1]);
$this->assertEquals(1, count($parent));
$this->assertArrayHasKey($id[0], $parent);
// Ancestors of BB (none)
$parent = getAncestorsOf('glpi_locations', $id[2]);
$this->assertEquals(1, count($parent));
$this->assertArrayHasKey($id[0], $parent);
// B
$id[3] = $loc->add(array('entities_id' => $entity,
'locations_id' => 0,
'name' => 'B'));
$this->assertGreaterThan(0, $id[3]);
// B > CC
$id[4] = $loc->add(array('entities_id' => $entity,
'locations_id' => $id[3],
'name' => 'CC'));
$this->assertGreaterThan(0, $id[4]);
$this->assertTrue($loc->getFromDB($id[4]));
$this->assertEquals('B > CC', $loc->fields['completename']);
$sons = getSonsOf('glpi_locations',$id[3]);
$this->assertEquals(2, count($sons));
$this->assertArrayHasKey($id[4], $sons);
// B > CC > XXX
$id[5] = $loc->add(array('entities_id' => $entity,
'locations_id' => $id[4],
'name' => 'XXX'));
$this->assertGreaterThan(0, $id[5]);
$this->assertTrue($loc->getFromDB($id[5]));
$this->assertEquals('B > CC > XXX', $loc->fields['completename']);
// B > CC => A > CC
$res = $loc->update(array('id' => $id[4],
'locations_id' => $id[0]));
$this->assertTrue($res);
$this->assertTrue($loc->getFromDB($id[4]));
$this->assertEquals('A > CC', $loc->fields['completename']);
// B > CC > XXX => A > CC > XXX
$this->assertTrue($loc->getFromDB($id[5]));
$this->assertEquals('A > CC > XXX', $loc->fields['completename']);
// New parent of CC (A)
$parent = getAncestorsOf('glpi_locations', $id[4]);
$this->assertEquals(1, count($parent));
$this->assertArrayHasKey($id[0], $parent);
// New sons of B (only B)
$sons = getSonsOf('glpi_locations',$id[3]);
$this->assertEquals(1, count($sons));
$this->assertArrayHasKey($id[3], $sons);
// New sons of A (A, AA, BB, CC)
$sons = getSonsOf('glpi_locations',$id[0]);
$this->assertEquals(5, count($sons));
$this->assertArrayHasKey($id[4], $sons);
$this->assertArrayHasKey($id[5], $sons);
// Rename A => C
$res = $loc->update(array('id' => $id[0],
'name' => 'C'));
$this->assertTrue($res);
// Check complete name of sons
$this->assertTrue($loc->getFromDB($id[4]));
$this->assertEquals('C > CC', $loc->fields['completename']);
$this->assertTrue($loc->getFromDB($id[5]));
$this->assertEquals('C > CC > XXX', $loc->fields['completename']);
$this->assertEquals(3, $loc->fields['level']);
// Delete CC and move child under B
$res = $loc->delete(array('id' => $id[4],
'_replace_by' => $id[3]));
$this->assertTrue($res);
// Sons of B (B and XXX)
$sons = getSonsOf('glpi_locations',$id[3]);
$this->assertEquals(2, count($sons));
$this->assertArrayHasKey($id[5], $sons);
$this->assertTrue($loc->getFromDB($id[5]));
$this->assertEquals('B > XXX', $loc->fields['completename']);
$this->assertEquals(2, $loc->fields['level']);
}
示例3: process
public function process()
{
// check if session is active
$session = new Session($this->sessionId);
if ($session->sessionId > 0) {
// update session
$session->update();
// process restricted functions
switch ($this->f) {
case 'checkLogin':
return Login::checkLogin($session->sessionId);
case 'getSession':
return $session;
case 'getWarehouse':
if (isset($this->data->update)) {
$warehouse = new Warehouse($session->warehouseId, $this->data->update);
} else {
$warehouse = new Warehouse($session->warehouseId);
}
$warehouse->dMail = $warehouse->getMail();
$warehouse->dDisableLocationLess = $warehouse->isLocationLessDisabled();
$warehouse->dDisablePaletteLess = $warehouse->isPaletteLessDisabled();
return $warehouse;
case 'editWarehouse':
if (!$session->restricted) {
$data = $this->data;
$warehouse = new Warehouse($session->warehouseId);
// update warehouse data
if (isset($data->name)) {
$warehouse->name = $data->name;
}
if (isset($data->description)) {
$warehouse->description = $data->description;
}
if (isset($data->country)) {
$warehouse->country = $data->country;
}
if (isset($data->city)) {
$warehouse->city = $data->city;
}
if (isset($data->password)) {
$warehouse->setPassword($data->password);
}
if (isset($data->passwordRestricted)) {
$warehouse->setPasswordRestricted($data->passwordRestricted);
}
if (isset($data->mail)) {
$warehouse->setMail($data->mail);
}
if (isset($data->disableLocationLess)) {
$warehouse->setDisableLocationLess($data->disableLocationLess);
}
if (isset($data->disablePaletteLess)) {
$warehouse->setDisablePaletteLess($data->disablePaletteLess);
}
// update database entry
return $warehouse->edit();
}
break;
case 'deleteWarehouse':
if (!$session->restricted) {
$warehouse = new Warehouse($session->warehouseId);
if ($warehouse->id > 0 && $warehouse->delete()) {
return $session->destroy();
}
}
break;
case 'addCategory':
if (!$session->restricted && isset($this->data->name)) {
$category = new Category(null, $session->warehouseId);
$category->name = $this->data->name;
if (isset($this->data->parent)) {
$category->parent = $this->data->parent;
}
if ($category->edit()) {
return $category->id;
}
}
break;
case 'getCategory':
if (isset($this->data->id) && isset($this->data->update)) {
return new Category($this->data->id, $session->warehouseId, $this->data->update);
} elseif (isset($this->data->id)) {
return new Category($this->data->id, $session->warehouseId);
}
break;
case 'deleteCategory':
if (!$session->restricted && isset($this->data->id)) {
$category = new Category($this->data->id, $session->warehouseId);
return $category->delete();
}
break;
case 'editCategory':
if (isset($this->data->id)) {
$data = $this->data;
$category = new Category($this->data->id, $session->warehouseId);
if (!$session->restricted) {
if (isset($data->name)) {
$category->name = $data->name;
}
//.........这里部分代码省略.........
示例4: delete
public static function delete($id)
{
session_start();
$headers = apache_request_headers();
$token = $headers['X-Auth-Token'];
if ($token != $_SESSION['form_token']) {
header('Invalid CSRF Token', true, 401);
return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
} else {
Location::delete($id);
}
}
示例5: hookAfterSaveItem
public function hookAfterSaveItem($args)
{
if (!($post = $args['post'])) {
return;
}
$item = $args['record'];
// If we don't have the geolocation form on the page, don't do anything!
if (!isset($post['geolocation'])) {
return;
}
// Find the location object for the item
$location = $this->_db->getTable('Location')->findLocationByItem($item, true);
// If we have filled out info for the geolocation, then submit to the db
$geolocationPost = $post['geolocation'];
if (!empty($geolocationPost) && $geolocationPost['latitude'] != '' && $geolocationPost['longitude'] != '') {
if (!$location) {
$location = new Location();
$location->item_id = $item->id;
}
$location->setPostData($geolocationPost);
# echo "<pre>". print_r($location,true) ."</pre>"; die();
$location->save();
} else {
// If the form is empty, then we want to delete whatever location is
// currently stored
if ($location) {
$location->delete();
}
}
}
示例6: deleteAction
/**
* Allows a user to delete a location
*
*/
public function deleteAction()
{
$get = Zend_Registry::get('getFilter');
if (!isset($get->locationId)) {
throw new Ot_Exception_Input('msg-error-locationIdNotSet');
}
$location = new Location();
$thisLocation = $location->find($get->locationId);
if (is_null($thisLocation)) {
throw new Ot_Exception_Data('msg-error-noLocation');
}
$this->view->location = $thisLocation;
$form = Ot_Form_Template::delete('deleteForm');
if ($this->_request->isPost() && $form->isValid($_POST)) {
$where = $location->getAdapter()->quoteInto('locationId = ?', $get->locationId);
$location->delete($where);
$this->_helper->flashMessenger->addMessage('msg-info-locationDeleted');
$this->_helper->redirector->gotoUrl('/workshop/location/index');
}
$this->_helper->pageTitle('workshop-location-delete:title');
$this->view->form = $form;
}
示例7: testDeleteInvalidLocation
/**
* test deleting a Location that does not exist
*
* @expectedException PDOException
**/
public function testDeleteInvalidLocation()
{
// create a Location and try to delete it without actually inserting it
$location = new Location(null, $this->VALID_storageCode, $this->VALID_description);
$location->delete($this->getPDO());
}
示例8: delete
/**
* @throws LocationIDMissingException
*/
public static function delete()
{
if ($_GET['id']) {
if ($_GET['sure'] != "true") {
$template = new HTMLTemplate("location/admin/location/delete.html");
$paramquery = $_GET;
$paramquery['sure'] = "true";
$params = http_build_query($paramquery);
$template->set_var("yes_params", $params);
$paramquery = $_GET;
unset($paramquery['sure']);
unset($paramquery['action']);
unset($paramquery['id']);
$params = http_build_query($paramquery, '', '&');
$template->set_var("no_params", $params);
$template->output();
} else {
$paramquery = $_GET;
unset($paramquery['sure']);
unset($paramquery['action']);
unset($paramquery['id']);
$params = http_build_query($paramquery, '', '&');
$location = new Location($_GET['id']);
if ($location->delete()) {
Common_IO::step_proceed($params, "Delete Location", "Operation Successful", null);
} else {
Common_IO::step_proceed($params, "Delete Location", "Operation Failed", null);
}
}
} else {
throw new LocationIDMissingException();
}
}