/** * Delete the given fieldgroup from the database * * Also deletes the references in fieldgroups_fields table * * @param Fieldgroup $fieldgroup * @return Fieldgroups $this * */ public function ___delete(Saveable $item) { $templates = array(); foreach ($this->fuel('templates') as $template) { if ($template->fieldgroup->id == $item->id) { $templates[] = $template->name; } } if (count($templates)) { throw new WireException("Can't delete fieldgroup '{$item->name}' because it is in use by template(s): " . implode(', ', $templates)); } parent::___delete($item); }
/** * Delete the given fieldgroup from the database * * Also deletes the references in fieldgroups_fields table * * @param Fieldgroup $fieldgroup * @return Fieldgroups $this * */ public function ___delete(Saveable $item) { parent::___delete($item); }
/** * Delete the provided item from the database, only if it's not a permanent user * */ public function ___delete(Saveable $item) { if (!$item instanceof User || $item instanceof NullUser) { throw new WireException("Item passed Users::delete is not a User"); } if ($item->isPermanent()) { throw new WireException("User ID {$item->id} is permanent and may not be deleted"); } return parent::___delete($item); }
/** * Per WireSaveableItemsLookup interface, delete the given role but only if it's not a permament one * */ public function ___delete(Saveable $item) { if (!$item instanceof Role) { throw new WireException("Roles::delete requires Role instance"); } if ($item->isPermanent()) { throw new WireException("Role {$item->name} is required by the system and may not be deleted"); } $this->fuel('pagesRoles')->deletePagesFromRole($item); $this->fuel('db')->query("DELETE from users_roles WHERE roles_id=" . (int) $item->id); return parent::___delete($item); }