コード例 #1
0
ファイル: ATK4HomePage.php プロジェクト: atk4/atk4-homepage
 protected function addEditOnFrontendButton(\CRUD $c)
 {
     if (isset($this->app->auth)) {
         $b = $c->addButton('Frontend edit');
         $b->js('click')->univ()->ajaxec($this->app->url(null, ['frontend_edit' => 'true']));
         if ($_GET['frontend_edit'] == 'true') {
             if (!isset($this->app->auth)) {
                 $this->js()->univ()->errorMessage('There is no Auth, you cannot use this functional.')->execute();
             }
             $session = $this->add('atk4\\atk4homepage\\Model_Session')->generate($this->app->auth->model->id, Model_Session::TYPE_EDIT_ON_FRONTEND)->setValidForHours(8)->save();
             $this->js()->redirect($this->app->url($this->getFrontendEditUrlString(), [Config::getInstance($this->app)->getFrontendGetParameterName() => $session->get('access_code')]))->execute();
         }
     }
 }