/** * 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); }
/** * Create and return a cloned copy of this item * * If the new item uses a 'name' field, it will contain a number at the end to make it unique * * @param Saveable $item Item to clone * @param bool|Saveable $item Returns the new clone on success, or false on failure * @return Saveable|Fieldgroup * */ public function ___clone(Saveable $item) { return parent::___clone($item); // @TODO clone the field context data /* $id = $item->id; $item = parent::___clone($item); if(!$item) return false; return $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); }