コード例 #1
0
 public static function saveProfile(eProfile $eProfile)
 {
     $oBus = new Response_Business();
     $MY =& MY_Controller::get_instance();
     /* @var $mProfile Profile_Model */
     $mProfile =& $MY->mProfile;
     $oTransaction = new MY_Business();
     $oTransaction->begin();
     try {
         $isEditable = TRUE;
         if (!$eProfile->isEmpty()) {
             $eProfileT = $mProfile->load($eProfile->id);
             if (!Helper_App_Session::isSuperAdminProfile()) {
                 if ($eProfileT->isSuperAdmin == 1 || $eProfileT->isAdmin == 1) {
                     throw new Exception("Prohibido editar éste perfil");
                 }
                 $isEditable = $eProfileT->isEditable == 1;
             }
             $eProfile->isSuperAdmin = $eProfileT->isSuperAdmin;
             $eProfile->isAdmin = $eProfileT->isAdmin;
             $eProfile->isEditable = $eProfileT->isEditable;
         }
         if ($isEditable) {
             $mProfile->save($eProfile);
         }
         $oTransaction->commit();
         $oBus->isSuccess(TRUE);
         $oBus->message("Guardado exitosamente");
     } catch (Exception $e) {
         $oTransaction->rollback();
         $oBus->isSuccess(FALSE);
         $oBus->message($e->getMessage());
     }
     return $oBus;
 }