private function UcAddressesAddressBook::deleteOne in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 class/UcAddressesAddressBook.class.php \UcAddressesAddressBook::deleteOne()
Deletes one address.
@access private
Parameters
int $type: Type of the argument given, can be the address id (BY_AID) or the address nickname (BY_NAME).
mixed $arg: Either the address id or the address nickname.
Return value
boolean TRUE if the address was deleted. FALSE otherwise.
Throws
3 calls to UcAddressesAddressBook::deleteOne()
- UcAddressesAddressBook::deleteAddress in class/
UcAddressesAddressBook.class.php - Deletes an addres by giving the addres object.
- UcAddressesAddressBook::deleteAddressById in class/
UcAddressesAddressBook.class.php - Deletes an address by ID.
- UcAddressesAddressBook::deleteAddressByName in class/
UcAddressesAddressBook.class.php - Deletes an address by name.
File
- class/
UcAddressesAddressBook.class.php, line 1013 - Contains the UcAddressesAddressBook class.
Class
- UcAddressesAddressBook
- The address book class
Code
private function deleteOne($type, $arg) {
// Reasons to skip out early
if (!$this
->isOwned()) {
return FALSE;
}
// We can't delete an address that is a default address, so
// we'll need to make sure this address is loaded.
$this
->loadOne($type, $arg);
if ($type == self::BY_AID) {
$address = $this
->getAddressById($arg);
}
if ($type == self::BY_NAME) {
$address = $this
->getAddressByName($arg);
}
if (!$address) {
return FALSE;
}
if ($address
->isDefault('shipping') || $address
->isDefault('billing')) {
return FALSE;
}
// Delete the address from the database only if it is not new (else it won't exist in the db).
if (!$address
->isNew()) {
db_delete('uc_addresses')
->condition('aid', $address
->getId())
->execute();
}
// Remove from address book object.
$this
->removeAddressFromAddressBook($address);
// Give other modules a chance to react on this.
module_invoke_all('uc_addresses_address_delete', $address);
entity_get_controller('uc_addresses')
->invoke('delete', $address);
return TRUE;
}