Exemple #1
0
 /**
  *
  */
 protected function _initApplication()
 {
     //$defaultDb = $this->multidb->getDb();
     //Oray_Db_Helper::getInstance()->set('tudu-md', $defaultDb);
     Oray_Dao_Abstract::setDefaultAdapter($this->multidb->getDb());
     Oray_Dao_Abstract::registerErrorHandler(array($this, 'daoErrorHandler'));
     Tudu_Dao_Manager::setDbs(array(Tudu_Dao_Manager::DB_MD => $this->multidb->getDb('md')));
     Tudu_User::setMemcache($this->getResource('memcache'));
     $resourceManager = new Tudu_Model_ResourceManager_Registry();
     $resourceManager->setResource('config', $this->_options);
     Tudu_Model::setResourceManager($resourceManager);
     //set_error_handler(array($this, 'errorHandler'));
 }
 public function init()
 {
     parent::init();
     if (!$this->_user->isLogined()) {
         return $this->json(false, $this->lang['login_timeout']);
     }
     Tudu_AddressBook::getInstance()->setCache($this->cache);
     $this->lang = Tudu_Lang::getInstance()->load(array('common', 'tudu'));
     Tudu_Dao_Manager::setDbs(array(Tudu_Dao_Manager::DB_MD => $this->multidb->getDefaultDb(), Tudu_Dao_Manager::DB_TS => $this->getTsDb()));
     $resourceManager = new Tudu_Model_ResourceManager_Registry();
     $resourceManager->setResource(Tudu_Model::RESOURCE_CONFIG, $this->bootstrap->getOptions());
     Tudu_Model::setResourceManager($resourceManager);
 }
 /**
  * 认领图度
  */
 public function claimAction()
 {
     $tuduId = trim($this->_request->getParam('tid'));
     $resourceManager = new Tudu_Model_ResourceManager_Registry();
     $resourceManager->setResource(Tudu_Model::RESOURCE_CONFIG, $this->bootstrap->getOptions());
     Tudu_Model::setResourceManager($resourceManager);
     $model = new Model_Tudu_Manager_Tudu();
     try {
         $model->claim(array('tuduid' => $tuduId));
     } catch (Model_Tudu_Exception $e) {
         $err = $this->lang['tudu_claim_failed'];
         switch ($e->getCode()) {
             case Model_Tudu_Manager_Tudu::CODE_INVALID_TUDUID:
                 $err = $this->lang['tudu_not_exists'];
                 break;
             case Model_Tudu_Manager_Tudu::CODE_STEP_NOTCLAIM:
                 $err = $this->lang['step_not_claim'];
                 break;
             case Model_Tudu_Manager_Tudu::CODE_STEP_CLAIM_FINISH:
                 $err = $this->lang['tudu_has_already_claim'];
                 break;
         }
         return $this->json(false, $err);
     }
     return $this->json(true, $this->lang['tudu_claim_success']);
 }
Exemple #4
0
 /**
  * 创建图度组织
  */
 public function createOrg()
 {
     if (empty($this->_orgParams)) {
         require_once 'Tudu/Install/Exception.php';
         throw new Tudu_Install_Exception('empty org params');
     }
     if (empty($this->_configs['mysql'])) {
         require_once 'Tudu/Install/Exception.php';
         throw new Tudu_Install_Exception('empty configs database');
     }
     $this->_configs['mysql'] = array_merge($this->_configs['mysql'], array('charset' => 'utf8'));
     require_once 'Zend/Db.php';
     require_once 'Zend/Db/Exception.php';
     $db = Zend_Db::factory('pdo_mysql', $this->_configs['mysql']);
     require_once 'Tudu/Dao/Manager.php';
     Tudu_Dao_Manager::setDbs(array(Tudu_Dao_Manager::DB_MD => $db, Tudu_Dao_Manager::DB_TS => $db));
     if (!empty($this->_dataPath)) {
         $dataPath = array('data' => array('path' => $this->_dataPath));
         require_once 'Tudu/Model.php';
         require_once 'Tudu/Model/ResourceManager/Registry.php';
         $resourceManager = new Tudu_Model_ResourceManager_Registry();
         $resourceManager->setResource('config', $dataPath);
         Tudu_Model::setResourceManager($resourceManager);
     }
     require_once 'Model/Org/Org.php';
     require_once 'Model/Org/Exception.php';
     /* @var $modelOrg Model_Org_Org */
     $modelOrg = Tudu_Model::factory('Model_Org_Org');
     try {
         $modelOrg->addAction('create', array($modelOrg, 'createAdmin'), 10);
         $modelOrg->addAction('create', array($modelOrg, 'active'), 9);
         $modelOrg->execute('create', array(array('orgid' => $this->_orgParams['orgid'], 'orgname' => $this->_orgParams['orgname'], 'userid' => $this->_orgParams['userid'], 'password' => $this->_orgParams['password'], 'truename' => $this->_orgParams['userid'], 'domain' => $this->_orgParams['domain'])));
     } catch (Model_Org_Exception $e) {
         require_once 'Tudu/Install/Exception.php';
         throw new Tudu_Install_Exception($e->getMessage());
     }
 }