Example #1
0
 public function __construct()
 {
     Cowl::timer('cowl init');
     @session_start();
     // I know that the @-notation is frowned upon, but adding it to session_start saves us unnecessary warnings
     Cache::setDir(COWL_CACHE_DIR);
     Current::initialize(COWL_DIR);
     if (COWL_CLI) {
         $this->parseCLIPath();
     } else {
         $this->parseRequestPath();
     }
     Cowl::timer('cowl set defaults');
     // Get and set all directories for various things.
     list($commands_dir, $model_dir, $validators_dir, $library_dir, $view_dir, $helpers_dir, $helpers_app_dir, $drivers_dir, $app_dir, $view_layout_dir, $validator_error_messages, $lang) = Current::$config->gets('paths.commands', 'paths.model', 'paths.validators', 'paths.library', 'paths.view', 'paths.helpers', 'paths.helpers_app', 'paths.drivers', 'paths.app', 'paths.layouts', 'paths.validator_messages', 'lang');
     Controller::setDir($commands_dir);
     DataMapper::setMappersDir($model_dir);
     DataMapper::setObjectsDir($model_dir);
     Validator::setPath($validators_dir);
     Validator::loadStrings($validator_error_messages, $lang);
     Templater::setBaseDir($view_dir);
     Templater::setLayoutDir($view_layout_dir);
     Library::setPath($library_dir);
     Helpers::setPath($helpers_dir);
     Helpers::setAppPath($helpers_app_dir);
     Database::setPath($drivers_dir);
     StaticServer::setDir($app_dir);
     Cowl::timerEnd('cowl set defaults');
     Cowl::timer('cowl plugins load');
     Current::$plugins = new Plugins();
     Cowl::timerEnd('cowl plugins load');
     // Load default helper
     Helpers::load('standard', 'form');
     Cowl::timerEnd('cowl init');
 }
Example #2
0
 /**
  * Execution method always used for tasks
  *
  * @return void
  */
 public function execute()
 {
     Security::setHash('sha512');
     $file = Hash::get($this->args, '0');
     if (!file_exists($file)) {
         $this->out(__d('users', '<warning>Not found file.</warning>'));
         return;
     }
     $user = $this->User->findById(1);
     CakeSession::write(AuthComponent::$sessionKey, $user['User']);
     $request = new CakeRequest();
     $controller = new Controller($request);
     Current::initialize($controller);
     if (!$this->User->importUsers($file)) {
         //バリデーションエラーの場合
         //$this->NetCommons->handleValidationError($this->User->validationErrors);
         $this->out(__d('users', '<error>Import error.</error>'));
         $this->out(var_export($this->User->validationErrors, true));
     } else {
         $this->out(__d('users', '<success>Import success.</success>'));
     }
 }