Ejemplo n.º 1
0
 /**
  * Реализация паттерна Singleton
  *
  * @return Miao_Office_Request
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 public function execute()
 {
     $error = '';
     $res = false;
     $message = '';
     try {
         $request = Miao_Office_Request::getInstance();
         $groupId = $request->getValueOf('group_id');
         $resourceId = $request->getValueOf('resource_id');
         $action = $request->getValueOf('action');
         $acs = Miaox_Acs_Instance::adapter();
         $class = 'icon-off';
         if ($action) {
             $class = 'icon-ok';
             $res = $acs->allowResource($groupId, $resourceId);
             $message .= 'Success allow. ';
         } else {
             $res = $acs->denyResource($groupId, $resourceId);
             $message .= 'Success deny. ';
         }
         if (false === $res) {
             $error = 'Something wrong';
         }
         $message .= sprintf('Group id: %s, resource_id: %s, action: %s', $groupId, $resourceId, $action);
     } catch (Exception $e) {
         $error = $e->getMessage();
     }
     $data = array('message' => $message, 'error' => $error, 'class' => $class);
     return json_encode($data);
 }
Ejemplo n.º 3
0
 public function isValid($run = false)
 {
     if ($run) {
         $request = Miao_Office_Request::getInstance();
         $data = $request->getVars();
         $this->_isValid = $this->_form->isValid($data);
     }
     return $this->_isValid;
 }
Ejemplo n.º 4
0
 protected function __construct()
 {
     $this->_generateFid();
     $session = Miao_Session::getInstance();
     $form = $session->loadObject($this->_fid, null, true);
     $session->saveObject($this->_fid, null);
     if (is_null($form)) {
         $this->_form = $this->buildForm();
     } else {
         $this->_form = $form;
         $this->_isRedirect = true;
         $request = Miao_Office_Request::getInstance();
         $data = $request->getVars();
         $this->_isValid = $this->_form->isValid($data);
     }
     $this->save();
 }
Ejemplo n.º 5
0
 protected function _init()
 {
     $this->_generateFid();
     $this->_load();
     $this->_clear();
     if (is_null($this->_form)) {
         $this->_form = $this->buildForm();
         $this->_save();
     } else {
         if ($this->isRedirect()) {
             $this->_isRedirect = false;
             $this->_isValid = $this->_form->isValid();
             if ($this->_isValid) {
                 $this->_form->clearValue();
             }
             $this->_clear();
         } else {
             $request = Miao_Office_Request::getInstance();
             if ('POST' === $request->getMethod()) {
                 $data = $request->getVars();
                 $this->_isValid = $this->_form->isValid($data);
             }
             $this->_save();
         }
     }
 }
Ejemplo n.º 6
0
<?php

require realpath(dirname(__FILE__) . '/../../../') . '/scripts/bootstrap.php';
try {
    $request = Miao_Office_Request::getInstance();
    $params = $_GET;
    $factory = new Miao_Office_Factory(array('defaultPrefix' => '${born-properties.lib_name}_FrontOffice'));
    $fo = $factory->getOffice($params, array('_view' => 'Main'));
    $fo->sendResponse(false);
} catch (Exception $e) {
    // --- dump ---
    echo '<pre>';
    echo __FILE__ . chr(10);
    echo __METHOD__ . chr(10);
    var_dump($e);
    echo '</pre>';
    // --- // ---
}
Ejemplo n.º 7
0
 public function testGetServerVar()
 {
     $_SERVER = array('REQUEST_URI' => '/');
     $r = Miao_Office_Request::getInstance();
     $this->assertSame($r->getServerVar('HTTP_HOST'), false);
     $_SERVER['HTTP_HOST'] = 'test.rbc.ru';
     $this->assertSame($r->getServerVar('HTTP_HOST'), 'test.rbc.ru');
     $_SERVER['SERVER_NAME'] = 'test2.rbc.ru';
     $this->assertSame($r->getServerVar('HTTP_HOST'), 'test2.rbc.ru');
     $this->assertSame($r->getServerVar('SERVER_NAME'), 'test2.rbc.ru');
     unset($_SERVER['SERVER_NAME']);
     $this->assertSame($r->getServerVar('SERVER_NAME'), 'test.rbc.ru');
     $this->assertSame($r->getServerVar('REQUEST_URI'), '/');
 }