示例#1
0
 function createUserLocality($data)
 {
     $data = $this->_filterInputUserLocality($data)->getUnescaped();
     $userRowLocalityData = DbTable_UserLocality::getInstance()->createRow()->setUserId($data['user_id'])->setEnterpriseId(isset($data['enterprise_id']) ? $data['enterprise_id'] : null)->setRegionalId(isset($data['regional_id']) ? $data['regional_id'] : null);
     $userRowLocalityData->save();
     return array('status' => true, 'lastInsertId' => $userRowLocalityData->getId());
 }
示例#2
0
 public function deleteUser($userRow)
 {
     DbTable_User::getInstance()->getAdapter()->beginTransaction();
     try {
         /* Deleta todos os UserLocality */
         $whereDeleteUserLocality = array('UserId = ?' => $userRow->getId());
         DbTable_UserLocality::getInstance()->delete($whereDeleteUserLocality);
         /* Deleta todos as UserRole */
         $whereDeleteUserRole = array('UserId = ?' => $userRow->getId());
         DbTable_UserRole::getInstance()->delete($whereDeleteUserRole);
         $queryApE = DbTable_AppraiserEnterprise::getInstance()->select()->from(array('ApE' => 'AppraiserEnterprise'), array('AppraiserEnterprise' => 'ApE.UserId'))->where('ApE.UserId = ?', $userRow->getId());
         $objResultApE = DbTable_Question::getInstance()->fetchRow($queryApE);
         if ($objResultApE) {
             return array('status' => false, 'messageError' => 'Usuário não pode ser deletado, há empresas relacionadas ao mesmo.');
         }
         $userRow->delete();
         DbTable_User::getInstance()->getAdapter()->commit();
         return array('status' => true);
     } catch (Vtx_UserException $e) {
         DbTable_User::getInstance()->getAdapter()->rollBack();
         return array('status' => false, 'messageError' => $e->getMessage());
     } catch (Exception $e) {
         DbTable_User::getInstance()->getAdapter()->rollBack();
         throw new Exception($e);
     }
 }