示例#1
0
 /**
  * @see SystemHandlerInterface::disable_module()
  * @param integer $module_id
  * @return bool
  */
 public static function disable_module($module_id)
 {
     global $transaction;
     if (is_numeric($module_id)) {
         $transaction_id = $transaction->begin();
         $module_access = new BaseModule_Access($module_id);
         if ($module_access->get_disabled() == true) {
             $module_enable_event = new ModuleEnableEvent($module_id);
             $event_handler = new EventHandler($module_enable_event);
             if ($event_handler->get_success() == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
             if ($module_access->set_disabled(false) == true) {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
         } else {
             $module_disable_event = new ModuleDisableEvent($module_id);
             $event_handler = new EventHandler($module_disable_event);
             if ($event_handler->get_success() == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
             if ($module_access->set_disabled(true) == true) {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
         }
     } else {
         return false;
     }
 }