Exemple #1
0
 /**
  * Deletes a role from the db
  *
  * @param array $data
  * @param string $where
  * @return unknown
  */
 public function deleteRole($roleId)
 {
     $dba = $this->getAdapter();
     $inTransaction = false;
     try {
         $dba->beginTransaction();
     } catch (Exception $e) {
         $inTransaction = true;
     }
     $where = $dba->quoteInto('roleId = ?', $roleId);
     try {
         $this->delete($where);
     } catch (Exception $e) {
         if (!$inTransaction) {
             $dba->rollBack();
         }
         throw $e;
     }
     $roleRule = new Ot_Model_DbTable_RoleRule();
     try {
         $roleRule->delete($where);
     } catch (Exception $e) {
         if (!$inTransaction) {
             $dba->rollback();
         }
     }
     $accountRoles = new Ot_Model_DbTable_AccountRoles();
     try {
         $accountRoles->delete($where);
     } catch (Exception $e) {
         if (!$inTransaction) {
             $dba->rollback();
         }
     }
     if (!$inTransaction) {
         $dba->commit();
     }
     $this->_clearCache();
 }
Exemple #2
0
 public function delete($where)
 {
     $inTransaction = false;
     //whether or not we're in a transaction prior to this
     $dba = $this->getAdapter();
     try {
         $dba->beginTransaction();
     } catch (Exception $e) {
         $inTransaction = true;
     }
     $thisAccount = $this->fetchRow($where);
     $accountRoles = new Ot_Model_DbTable_AccountRoles();
     $apiApps = new Ot_Model_DbTable_ApiApp();
     $aar = new Ot_Account_Attribute_Register();
     $cahr = new Ot_CustomAttribute_HostRegister();
     $thisHost = $cahr->getHost('Ot_Profile');
     try {
         $deleteResult = parent::delete($where);
         $accountRoles->delete($where);
         $apiApps->delete($where);
         $aar->delete($thisAccount->accountId);
         $thisHost->delete($thisAccount->accountId);
     } catch (Exception $e) {
         if (!$inTransaction) {
             $dba->rollback();
         }
         throw new Ot_Exception('Account delete failed.');
     }
     if (!$inTransaction) {
         $dba->commit();
     }
     return $deleteResult;
 }