当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::delete方法代码示例

本文整理汇总了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()));
 }
开发者ID:JakeDawkins,项目名称:NiceCatch,代码行数:10,代码来源:locationTest.php

示例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']);
   }
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:101,代码来源:TreeCache.php

示例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;
                         }
//.........这里部分代码省略.........
开发者ID:hanneseilers,项目名称:Social-Warehouse,代码行数:101,代码来源:DataRequest.php

示例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);
     }
 }
开发者ID:jbagaresgaray,项目名称:DECISION-SUPPORT-SYSTEM,代码行数:12,代码来源:controller.php

示例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();
         }
     }
 }
开发者ID:GerZah,项目名称:plugin-Geolocation,代码行数:30,代码来源:GeolocationPlugin.php

示例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;
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:26,代码来源:LocationController.php

示例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());
 }
开发者ID:sandidgec,项目名称:foodinventory,代码行数:11,代码来源:location-test.php

示例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, '', '&#38;');
             $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, '', '&#38;');
             $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();
     }
 }
开发者ID:suxinde2009,项目名称:www,代码行数:36,代码来源:admin_location.io.php


注:本文中的Location::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。