示例#1
0
 /**
  * Delete a Field from the database
  *
  * @param Field|Saveable $item Item to save
  * @return bool True on success, false on failure
  * @throws WireException
  *
  */
 public function ___delete(Saveable $item)
 {
     if (!$this->fieldsArray->isValidItem($item)) {
         throw new WireException("Fields::delete(item) only accepts items of type Field");
     }
     // if the field doesn't have an ID, so it's not one that came from the DB
     if (!$item->id) {
         throw new WireException("Unable to delete from '" . $item->getTable() . "' for field that doesn't exist in fields table");
     }
     // if it's in use by any fieldgroups, then we don't allow it to be deleted
     if ($item->numFieldgroups()) {
         $names = $item->getFieldgroups()->implode("', '", "name");
         throw new WireException("Unable to delete field '{$item->name}' because it is in use by these fieldgroups: '{$names}'");
     }
     // if it's a system field, it may not be deleted
     if ($item->flags & Field::flagSystem) {
         throw new WireException("Unable to delete field '{$item->name}' because it is a system field.");
     }
     // delete entries in fieldgroups_fields table. Not really necessary since the above exception prevents this, but here in case that changes.
     $this->fuel('fieldgroups')->deleteField($item);
     // drop the field's table
     if ($item->type) {
         $item->type->deleteField($item);
     }
     return parent::___delete($item);
 }
 /** 
  * Delete the provided item from the database
  *
  * @param Saveable $item
  * @return bool
  * 
  */
 public function ___delete(Saveable $item)
 {
     $database = $this->wire('database');
     $lookupTable = $database->escapeTable($this->getLookupTable());
     $table = $database->escapeTable($this->getTable());
     $item_id = (int) $item->id;
     $query = $database->prepare("DELETE FROM {$lookupTable} WHERE {$table}_id=:item_id");
     // QA
     $query->bindValue(":item_id", $item_id, PDO::PARAM_INT);
     $query->execute();
     return parent::___delete($item);
 }
 /**
  * Delete a template and unset it from this object. 
  *
  */
 public function ___delete(Saveable $item)
 {
     $cnt = $item->getNumPages();
     if ($cnt > 0) {
         throw new WireException("Can't delete template '{$item->name}' because it is used by {$cnt} pages.");
     }
     return parent::___delete($item);
 }
 /**
  * Delete a template and unset it from this object. 
  *
  */
 public function ___delete(Saveable $item)
 {
     if ($item->flags & Template::flagSystem) {
         throw new WireException("Can't delete template '{$item->name}' because it is a system template.");
     }
     $cnt = $item->getNumPages();
     if ($cnt > 0) {
         throw new WireException("Can't delete template '{$item->name}' because it is used by {$cnt} pages.");
     }
     $return = parent::___delete($item);
     $this->wire('cache')->maintenance($item);
     return $return;
 }
 /** 
  * Delete the provided item from the database
  *
  */
 public function ___delete(Saveable $item)
 {
     $this->fuel('db')->query("DELETE FROM " . $this->getLookupTable() . " WHERE " . $this->getTable() . "_id={$item->id}");
     return parent::___delete($item);
 }
 /**
  * Delete the Permission, per WireSaveableItems interface
  *
  * WireSaveableItems (parent) handles deletion of the permission, and this deletes references to the permission in the lookup table
  *
  */
 public function ___delete(Saveable $item)
 {
     $id = (int) $item->id;
     $this->getFuel('db')->query("DELETE FROM roles_permissions WHERE permissions_id='{$id}'");
     return parent::___delete($item);
 }