add() public static method

Add a new notice
public static add ( $type, $message = NULL, array $values = NULL ) : void
$values array
return void
コード例 #1
0
ファイル: Auth.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action login
  */
 public function action_login()
 {
     $post = $this->request->post();
     $username = Arr::get($post, 'username');
     $password = Arr::get($post, 'password');
     $remember = Arr::get($post, 'remember') ?: 0;
     // If there is post login
     if ($this->request->post('login')) {
         // ログインチェック
         if (Auth::instance()->login($username, $password, $remember)) {
             // ロールチェック
             if (Auth::instance()->logged_in('direct') or Auth::instance()->logged_in('admin') or Auth::instance()->logged_in('edit')) {
                 // Add success notice
                 Notice::add(Notice::SUCCESS, Kohana::message('auth', 'login_success'), array(':user' => $username));
                 // Redirect to home
                 $this->redirect(URL::site($this->settings->backend_name, 'http'));
             } else {
                 // Add error notice
                 Notice::add(Notice::ERROR, Kohana::message('auth', 'login_refusal'), NULL, Kohana::message('auth', 'login_refusal_messages'));
             }
         } else {
             // Add error notice
             Notice::add(Notice::ERROR, Kohana::message('auth', 'login_failed'), NULL, Kohana::message('auth', 'login_failed_messages'));
         }
     }
     /**
      * View
      */
     // Get content
     $content_file = Tpl::get_file('login', $this->settings->back_tpl_dir . '/auth');
     $this->content = Tpl::factory($content_file)->set('post', $post);
 }
コード例 #2
0
ファイル: Search.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action result
  */
 public function action_result()
 {
     // Get result from file and direct set to search
     $result = new stdClass();
     $result->content = Tpl::get_file('result', $this->settings->front_tpl_dir . '/search');
     // If there are post
     if ($this->request->post()) {
         // Set post to author
         $result->content = $this->request->post('content');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Update file
             Cms_Helper::set_file("result", $this->settings->front_tpl_dir . '/search', $this->request->post('content'));
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     /**
      * View
      */
     $content_file = Tpl::get_file('result', $this->settings->back_tpl_dir . '/search', $this->partials);
     $this->content = Tpl::factory($content_file)->set('result', $result);
 }
コード例 #3
0
ファイル: Emails.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get comment, if there is nothing then throw to 404
     $received_email = Tbl::factory('received_emails')->get($id);
     if (!$received_email) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         /**
          * Delete
          */
         $received_email->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/received_emails/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR);
     }
     // Redirect to received_emails index
     $this->redirect(URL::site("{$this->settings->backend_name}/received_emails/index", 'http'));
 }
コード例 #4
0
ファイル: Wrappers.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get wrapper, if there is nothing then throw to 404
     $wrapper = Tbl::factory('wrappers')->get($id);
     if (!$wrapper) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         /**
          * Check other tables
          */
         // used by divisions
         $used_divisions = (bool) Tbl::factory('divisions')->where('wrapper_id', '=', $wrapper->id)->read()->count();
         // If this warpper is used by division
         if ($used_divisions) {
             throw new Warning_Exception(Kohana::message('general', 'wrapper_is_used'));
         }
         /**
          * Delete
          */
         // Delete file
         $file = "wrapper/{$wrapper->segment}";
         Cms_Helper::delete_file($file, $this->settings->front_tpl_dir);
         // Delete
         $wrapper->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         // Redirect to wrapper index
         $this->redirect(URL::site("{$this->settings->backend_name}/wrappers/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Warning_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add
         Notice::add(Notice::WARNING, $e->getMessage());
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/wrappers/edit/{$wrapper->id}", 'http'));
 }
コード例 #5
0
ファイル: index.php プロジェクト: webhacking/Textcube
function importer($path, $node, $line)
{
    global $blogid, $migrational, $items, $item;
    switch ($path) {
        case '/blog/setting':
            setProgress($item++ / $items * 100, _t('블로그 설정을 복원하고 있습니다.'));
            $setting = new BlogSetting();
            if (isset($node['title'][0]['.value'])) {
                $setting->title = $node['title'][0]['.value'];
            }
            if (isset($node['description'][0]['.value'])) {
                $setting->description = $node['description'][0]['.value'];
            }
            if (isset($node['banner'][0]['name'][0]['.value'])) {
                $setting->banner = $node['banner'][0]['name'][0]['.value'];
            }
            if (isset($node['useSloganOnPost'][0]['.value'])) {
                $setting->useSloganOnPost = $node['useSloganOnPost'][0]['.value'];
            }
            if (isset($node['postsOnPage'][0]['.value'])) {
                $setting->postsOnPage = $node['postsOnPage'][0]['.value'];
            }
            if (isset($node['postsOnList'][0]['.value'])) {
                $setting->postsOnList = $node['postsOnList'][0]['.value'];
            }
            if (isset($node['postsOnFeed'][0]['.value'])) {
                $setting->postsOnFeed = $node['postsOnFeed'][0]['.value'];
            }
            if (isset($node['publishWholeOnFeed'][0]['.value'])) {
                $setting->publishWholeOnFeed = $node['publishWholeOnFeed'][0]['.value'];
            }
            if (isset($node['acceptGuestComment'][0]['.value'])) {
                $setting->acceptGuestComment = $node['acceptGuestComment'][0]['.value'];
            }
            if (isset($node['acceptcommentOnGuestComment'][0]['.value'])) {
                $setting->acceptcommentOnGuestComment = $node['acceptcommentOnGuestComment'][0]['.value'];
            }
            if (isset($node['language'][0]['.value'])) {
                $setting->language = $node['language'][0]['.value'];
            }
            if (isset($node['timezone'][0]['.value'])) {
                $setting->timezone = $node['timezone'][0]['.value'];
            }
            if (!$setting->save()) {
                user_error(__LINE__ . $setting->error);
            }
            if (!empty($setting->banner) && !empty($node['banner'][0]['content'][0]['.stream'])) {
                Attachment::confirmFolder();
                Utils_Base64Stream::decode($node['banner'][0]['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                fclose($node['banner'][0]['content'][0]['.stream']);
                unset($node['banner'][0]['content'][0]['.stream']);
            }
            return true;
        case '/blog/category':
            setProgress($item++ / $items * 100, _t('분류를 복원하고 있습니다.'));
            $category = new Category();
            $category->name = $node['name'][0]['.value'];
            $category->priority = $node['priority'][0]['.value'];
            if (isset($node['root'][0]['.value'])) {
                $category->id = 0;
            }
            if (!$category->add()) {
                user_error(__LINE__ . $category->error);
            }
            if (isset($node['category'])) {
                for ($i = 0; $i < count($node['category']); $i++) {
                    $childCategory = new Category();
                    $childCategory->parent = $category->id;
                    $cursor =& $node['category'][$i];
                    $childCategory->name = $cursor['name'][0]['.value'];
                    $childCategory->priority = $cursor['priority'][0]['.value'];
                    if (!$childCategory->add()) {
                        user_error(__LINE__ . $childCategory->error);
                    }
                }
            }
            return true;
        case '/blog/post':
            setProgress($item++ / $items * 100, _t('글을 복원하고 있습니다.'));
            $post = new Post();
            $post->id = $node['id'][0]['.value'];
            $post->slogan = @$node['.attributes']['slogan'];
            $post->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $post->starred = $node['starred'][0]['.value'];
            } else {
                $post->starred = 0;
            }
            $post->title = $node['title'][0]['.value'];
            $post->content = $node['content'][0]['.value'];
            $post->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : 'ttml';
            $post->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : 'modern';
            $post->location = $node['location'][0]['.value'];
            $post->password = isset($node['password'][0]['.value']) ? $node['password'][0]['.value'] : null;
            $post->acceptcomment = $node['acceptComment'][0]['.value'];
            $post->accepttrackback = $node['acceptTrackback'][0]['.value'];
            $post->published = $node['published'][0]['.value'];
            if (isset($node['longitude'][0]['.value'])) {
                $post->longitude = $node['longitude'][0]['.value'];
            }
            if (isset($node['latitude'][0]['.value'])) {
                $post->latitude = $node['latitude'][0]['.value'];
            }
            $post->created = @$node['created'][0]['.value'];
            $post->modified = @$node['modified'][0]['.value'];
            if ($post->visibility == 'private' && intval($post->published) > $_SERVER['REQUEST_TIME'] || !empty($node['appointed'][0]['.value']) && $node['appointed'][0]['.value'] == 'true') {
                // for compatibility of appointed entries
                $post->visibility = 'appointed';
            }
            if ($post->slogan == '') {
                $post->slogan = 'Untitled' . $post->id;
            }
            if (!empty($node['category'][0]['.value'])) {
                $post->category = Category::getId($node['category'][0]['.value']);
            }
            if (isset($node['tag'])) {
                $post->tags = array();
                for ($i = 0; $i < count($node['tag']); $i++) {
                    if (!empty($node['tag'][$i]['.value'])) {
                        array_push($post->tags, $node['tag'][$i]['.value']);
                    }
                }
            }
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $post->content = nl2brWithHTML($post->content);
            }
            if (!$post->add()) {
                user_error(__LINE__ . $post->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $post->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (!$attachment->add()) {
                        user_error(__LINE__ . $attachment->error);
                    } else {
                        if ($cursor['name'][0]['.value'] != $attachment->name) {
                            $post2 = new Post();
                            if ($post2->open($post->id, 'id, content')) {
                                $post2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $post2->content);
                                $post2->loadTags();
                                $post2->update();
                                $post2->close();
                            }
                            unset($post2);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            if (isset($node['comment'])) {
                for ($i = 0; $i < count($node['comment']); $i++) {
                    $comment = new Comment();
                    $comment->entry = $post->id;
                    $cursor =& $node['comment'][$i];
                    $comment->name = $cursor['commenter'][0]['name'][0]['.value'];
                    if (!empty($cursor['id'][0]['.value'])) {
                        $comment->id = $cursor['id'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                        $comment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                    }
                    if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                        $comment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                        $comment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                        $comment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                    }
                    $comment->password = $cursor['password'][0]['.value'];
                    $comment->secret = $cursor['secret'][0]['.value'];
                    $comment->written = $cursor['written'][0]['.value'];
                    if (isset($cursor['longitude'][0]['.value'])) {
                        $comment->longitude = $cursor['longitude'][0]['.value'];
                    }
                    if (isset($cursor['latitude'][0]['.value'])) {
                        $comment->latitude = $cursor['latitude'][0]['.value'];
                    }
                    $comment->content = $cursor['content'][0]['.value'];
                    if (!empty($cursor['isFiltered'][0]['.value'])) {
                        $comment->isfiltered = $cursor['isFiltered'][0]['.value'];
                    }
                    if (!$comment->add()) {
                        user_error(__LINE__ . $comment->error);
                    }
                    if (isset($node['comment'][$i]['comment'])) {
                        for ($j = 0; $j < count($node['comment'][$i]['comment']); $j++) {
                            $childComment = new Comment();
                            $childComment->entry = $post->id;
                            $childComment->parent = $comment->id;
                            $cursor =& $node['comment'][$i]['comment'][$j];
                            if (!empty($cursor['id'][0]['.value'])) {
                                $childComment->id = $cursor['id'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                                $childComment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                            }
                            $childComment->name = $cursor['commenter'][0]['name'][0]['.value'];
                            if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                                $childComment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                                $childComment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                                $childComment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                            }
                            $childComment->password = $cursor['password'][0]['.value'];
                            $childComment->secret = $cursor['secret'][0]['.value'];
                            $childComment->written = $cursor['written'][0]['.value'];
                            if (isset($cursor['longitude'][0]['.value'])) {
                                $comment->longitude = $cursor['longitude'][0]['.value'];
                            }
                            if (isset($cursor['latitude'][0]['.value'])) {
                                $comment->latitude = $cursor['latitude'][0]['.value'];
                            }
                            $childComment->content = $cursor['content'][0]['.value'];
                            if (!empty($cursor['isFiltered'][0]['.value'])) {
                                $childComment->isfiltered = $cursor['isFiltered'][0]['.value'];
                            }
                            if (!$childComment->add()) {
                                user_error(__LINE__ . $childComment->error);
                            }
                        }
                    }
                }
            }
            if (isset($node['trackback'])) {
                for ($i = 0; $i < count($node['trackback']); $i++) {
                    $trackback = new Trackback();
                    $trackback->entry = $post->id;
                    $cursor =& $node['trackback'][$i];
                    $trackback->url = $cursor['url'][0]['.value'];
                    $trackback->site = $cursor['site'][0]['.value'];
                    $trackback->title = $cursor['title'][0]['.value'];
                    $trackback->excerpt = @$cursor['excerpt'][0]['.value'];
                    if (!empty($cursor['ip'][0]['.value'])) {
                        $trackback->ip = $cursor['ip'][0]['.value'];
                    }
                    if (!empty($cursor['received'][0]['.value'])) {
                        $trackback->received = $cursor['received'][0]['.value'];
                    }
                    if (!empty($cursor['isFiltered'][0]['.value'])) {
                        $trackback->isFiltered = $cursor['isFiltered'][0]['.value'];
                    }
                    if (!$trackback->add()) {
                        user_error(__LINE__ . $trackback->error);
                    }
                }
            }
            if (isset($node['logs'][0]['trackback'])) {
                for ($i = 0; $i < count($node['logs'][0]['trackback']); $i++) {
                    $log = new TrackbackLog();
                    $log->entry = $post->id;
                    $cursor =& $node['logs'][0]['trackback'][$i];
                    $log->url = $cursor['url'][0]['.value'];
                    if (!empty($cursor['sent'][0]['.value'])) {
                        $log->sent = $cursor['sent'][0]['.value'];
                    }
                    if (!$log->add()) {
                        user_error(__LINE__ . $log->error);
                    }
                }
            }
            return true;
        case '/blog/page':
            setProgress($item++ / $items * 100, _t('페이지를 복원하고 있습니다.'));
            $page = new Page();
            $page->id = $node['id'][0]['.value'];
            $page->slogan = @$node['.attributes']['slogan'];
            $page->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $page->starred = $node['starred'][0]['.value'];
            } else {
                $page->starred = 0;
            }
            $page->title = $node['title'][0]['.value'];
            $page->content = $node['content'][0]['.value'];
            $page->contentformatter = isset($node['content']['.attributes']['formatter']) ? $node['content']['.attributes']['formatter'] : getDefaultFormatter();
            $page->contenteditor = isset($node['content']['.attributes']['editor']) ? $node['content']['.attributes']['editor'] : getDefaultEditor();
            $page->published = $node['published'][0]['.value'];
            $page->created = @$node['created'][0]['.value'];
            $page->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $page->content = nl2brWithHTML($page->content);
            }
            if (!$page->add()) {
                user_error(__LINE__ . $page->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $page->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $page2 = new Page();
                        if ($page2->open($page->id, 'id, content')) {
                            $page2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $page2->content);
                            $page2->update();
                            $page2->close();
                        }
                        unset($page2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/notice':
            setProgress($item++ / $items * 100, _t('공지를 복원하고 있습니다.'));
            $notice = new Notice();
            $notice->id = $node['id'][0]['.value'];
            $notice->slogan = @$node['.attributes']['slogan'];
            $notice->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $notice->starred = $node['starred'][0]['.value'];
            } else {
                $notice->starred = 0;
            }
            $notice->title = $node['title'][0]['.value'];
            $notice->content = $node['content'][0]['.value'];
            $notice->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : getDefaultFormatter();
            $notice->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : getDefaultEditor();
            $notice->published = intval($node['published'][0]['.value']);
            $notice->created = @$node['created'][0]['.value'];
            $notice->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $notice->content = nl2brWithHTML($notice->content);
            }
            if (!$notice->add()) {
                user_error(__LINE__ . $notice->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $notice->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $notice2 = new Notice();
                        if ($notice2->open($notice->id, 'id, content')) {
                            $notice2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $notice2->content);
                            $notice2->update();
                            $notice2->close();
                        }
                        unset($notice2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/keyword':
            setProgress($item++ / $items * 100, _t('키워드를 복원하고 있습니다.'));
            $keyword = new Keyword();
            $keyword->id = $node['id'][0]['.value'];
            $keyword->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $keyword->starred = $node['starred'][0]['.value'];
            } else {
                $keyword->starred = 0;
            }
            $keyword->name = $node['name'][0]['.value'];
            $keyword->description = $node['description'][0]['.value'];
            $keyword->descriptionEditor = isset($node['description'][0]['.attributes']['editor']) ? $node['description'][0]['.attributes']['editor'] : getDefaultEditor();
            $keyword->descriptionFormatter = isset($node['description'][0]['.attributes']['formatter']) ? $node['description'][0]['.attributes']['formatter'] : getDefaultFormatter();
            $keyword->published = intval($node['published'][0]['.value']);
            $keyword->created = @$node['created'][0]['.value'];
            $keyword->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $keyword->description = nl2brWithHTML($keyword->description);
            }
            if (!$keyword->add()) {
                user_error(__LINE__ . $keyword->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $keyword->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $keyword2 = new Keyword();
                        if ($keyword2->open($keyword->id, 'id, content')) {
                            $keyword2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $keyword2->content);
                            $keyword2->update();
                            $keyword2->close();
                        }
                        unset($keyword2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/linkCategories':
            setProgress($item++ / $items * 100, _t('링크 카테고리를 복원하고 있습니다.'));
            $linkCategory = new LinkCategories();
            $linkCategory->name = $node['name'][0]['.value'];
            $linkCategory->priority = $node['priority'][0]['.value'];
            $linkCategory->visibility = !isset($node['visibility'][0]['.value']) || empty($node['visibility'][0]['.value']) ? 2 : $node['visibility'][0]['.value'];
            $linkCategory->id = LinkCategories::getId($linkCategory->name);
            if ($linkCategory->id) {
                if (!$linkCategory->update()) {
                    user_error(__LINE__ . $linkCategory->error);
                }
            } else {
                if (!$linkCategory->add()) {
                    user_error(__LINE__ . $linkCategory->error);
                }
            }
            return true;
        case '/blog/link':
            setProgress($item++ / $items * 100, _t('링크를 복원하고 있습니다.'));
            $link = new Link();
            $link->category = empty($node['category'][0]['.value']) ? 0 : $node['category'][0]['.value'];
            $link->url = $node['url'][0]['.value'];
            $link->title = $node['title'][0]['.value'];
            if (!empty($node['feed'][0]['.value'])) {
                $link->feed = $node['feed'][0]['.value'];
            }
            if (!empty($node['registered'][0]['.value'])) {
                $link->registered = $node['registered'][0]['.value'];
            }
            if (!empty($node['xfn'][0]['.value'])) {
                $link->xfn = $node['xfn'][0]['.value'];
            }
            $link->id = Link::getId($link->url);
            if ($link->id) {
                if (!$link->update()) {
                    user_error(__LINE__ . $link->error);
                }
            } else {
                if (!$link->add()) {
                    user_error(__LINE__ . $link->error);
                }
            }
            return true;
        case '/blog/logs/referer':
            setProgress($item++ / $items * 100, _t('리퍼러 로그를 복원하고 있습니다.'));
            $log = new RefererLog();
            if (isset($node['path'][0]['.value'])) {
                $log->url = $node['path'][0]['.value'];
            } else {
                $log->url = $node['url'][0]['.value'];
            }
            $log->referred = $node['referred'][0]['.value'];
            if (!$log->add(false)) {
                user_error(__LINE__ . $log->error);
            }
            return true;
        case '/blog/commentsNotified/comment':
            setProgress($item++ / $items * 100, _t('댓글 알리미 내용을 복원하고 있습니다.'));
            $cmtNotified = new CommentNotified();
            $cmtNotified->id = $node['id'][0]['.value'];
            $cursor =& $node['commenter'][0];
            $cmtNotified->name = $cursor['name'][0]['.value'];
            $cmtNotified->homepage = $cursor['homepage'][0]['.value'];
            $cmtNotified->ip = $cursor['ip'][0]['.value'];
            $cmtNotified->entry = $node['entry'][0]['.value'];
            $cmtNotified->password = $node['password'][0]['.value'];
            $cmtNotified->content = $node['content'][0]['.value'];
            $cmtNotified->parent = $node['parent'][0]['.value'];
            $cmtNotified->secret = $node['secret'][0]['.value'];
            $cmtNotified->written = $node['written'][0]['.value'];
            $cmtNotified->modified = $node['modified'][0]['.value'];
            $cmtNotified->url = $node['url'][0]['.value'];
            $cmtNotified->isnew = $node['isNew'][0]['.value'];
            $site = new CommentNotifiedSiteInfo();
            if (!$site->open("url = '{$node['site'][0]['.value']}'")) {
                $site->title = '';
                $site->name = '';
                $site->modified = 31536000;
                $site->url = $node['site'][0]['.value'];
                $site->add();
            }
            $cmtNotified->siteid = $site->id;
            $site->close();
            $cmtNotified->remoteid = $node['remoteId'][0]['.value'];
            $cmtNotified->entrytitle = !isset($node['entryTitle'][0]['.value']) || empty($node['entryTitle'][0]['.value']) ? 'No title' : $node['entryTitle'][0]['.value'];
            $cmtNotified->entryurl = $node['entryUrl'][0]['.value'];
            if (!$cmtNotified->add()) {
                user_error(__LINE__ . $cmtNotified->error);
            }
            return true;
        case '/blog/commentsNotifiedSiteInfo/site':
            setProgress($item++ / $items * 100, _t('댓글 알리미 내용을 복원하고 있습니다.'));
            $cmtNotifiedSite = new CommentNotifiedSiteInfo();
            if ($cmtNotifiedSite->open("url = '{$node['url'][0]['.value']}'")) {
                if (intval($node['modified'][0]['.value']) > intval($cmtNotifiedSite->modified)) {
                    $cmtNotifiedSite->title = $node['title'][0]['.value'];
                    $cmtNotifiedSite->name = $node['name'][0]['.value'];
                    $cmtNotifiedSite->modified = $node['modified'][0]['.value'];
                }
                if (!$cmtNotifiedSite->update()) {
                    user_error(__LINE__ . $cmtNotifiedSite->error);
                }
            } else {
                $cmtNotifiedSite->url = $node['url'][0]['.value'];
                $cmtNotifiedSite->title = $node['title'][0]['.value'];
                $cmtNotifiedSite->name = $node['name'][0]['.value'];
                $cmtNotifiedSite->modified = $node['modified'][0]['.value'];
                if (!$cmtNotifiedSite->add()) {
                    user_error(__LINE__ . $cmtNotifiedSite->error);
                }
            }
            return true;
        case '/blog/statistics/referer':
            setProgress($item++ / $items * 100, _t('리퍼러 통계를 복원하고 있습니다.'));
            $statistics = new RefererStatistics();
            $statistics->host = $node['host'][0]['.value'];
            $statistics->count = $node['count'][0]['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/statistics/visits':
            setProgress($item++ / $items * 100, _t('블로그 통계 정보를 복원하고 있습니다.'));
            $statistics = new BlogStatistics();
            $statistics->visits = $node['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/statistics/daily':
            setProgress($item++ / $items * 100, _t('일별 통계 정보를 복원하고 있습니다.'));
            $statistics = new DailyStatistics();
            $statistics->date = $node['date'][0]['.value'];
            $statistics->visits = $node['visits'][0]['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/skin':
            setProgress($item++ / $items * 100, _t('스킨 설정을 복원하고 있습니다.'));
            $setting = new SkinSetting();
            if (false) {
                $setting->skin = $node['name'][0]['.value'];
                if (!$setting->save()) {
                    user_error(__LINE__ . $setting->error);
                }
                $setting->skin = null;
            }
            $setting->entriesOnRecent = $node['entriesOnRecent'][0]['.value'];
            $setting->commentsOnRecent = $node['commentsOnRecent'][0]['.value'];
            $setting->trackbacksOnRecent = $node['trackbacksOnRecent'][0]['.value'];
            $setting->commentsOnGuestbook = $node['commentsOnGuestbook'][0]['.value'];
            $setting->tagsOnTagbox = $node['tagsOnTagbox'][0]['.value'];
            $setting->alignOnTagbox = $node['alignOnTagbox'][0]['.value'];
            $setting->expandComment = $node['expandComment'][0]['.value'];
            $setting->expandTrackback = $node['expandTrackback'][0]['.value'];
            if (!empty($node['recentNoticeLength'][0]['.value'])) {
                $setting->recentNoticeLength = $node['recentNoticeLength'][0]['.value'];
            }
            $setting->recentEntryLength = $node['recentEntryLength'][0]['.value'];
            $setting->recentTrackbackLength = $node['recentTrackbackLength'][0]['.value'];
            $setting->linkLength = $node['linkLength'][0]['.value'];
            $setting->showListOnCategory = $node['showListOnCategory'][0]['.value'];
            $setting->showListOnArchive = $node['showListOnArchive'][0]['.value'];
            if (isset($node['tree'])) {
                $cursor =& $node['tree'][0];
                $setting->tree = $cursor['name'][0]['.value'];
                $setting->colorOnTree = $cursor['color'][0]['.value'];
                $setting->bgcolorOnTree = $cursor['bgColor'][0]['.value'];
                $setting->activecolorOnTree = $cursor['activeColor'][0]['.value'];
                $setting->activebgcolorOnTree = $cursor['activeBgColor'][0]['.value'];
                $setting->labelLengthOnTree = $cursor['labelLength'][0]['.value'];
                $setting->showValueOnTree = $cursor['showValue'][0]['.value'];
            }
            if (!$setting->save()) {
                user_error(__LINE__ . $setting->error);
            }
            return true;
        case '/blog/plugin':
            //			setProgress($item++ / $items * 100, _t('플러그인 설정을 복원하고 있습니다.'));
            //			$setting = new PluginSetting();
            //			$setting->name = $node['name'][0]['.value'];
            //			$setting->setting = $node['setting'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/personalization':
            //			setProgress($item++ / $items * 100, _t('사용자 편의 설정을 복원하고 있습니다.'));
            //			$setting = new UserSetting();
            //			$setting->name = 'rowsPerPage';
            //			$setting->value = $node['rowsPerPage'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'readerPannelVisibility';
            //			$setting->value = $node['readerPannelVisibility'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'readerPannelHeight';
            //			$setting->value = $node['readerPannelHeight'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'lastVisitNotifiedPage';
            //			$setting->value = $node['lastVisitNotifiedPage'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/userSetting':
            //			setProgress($item++ / $items * 100, _t('사용자 편의 설정을 복원하고 있습니다'));
            //			$setting = new UserSetting();
            //			$setting->name = $node['name'][0]['.value'];
            //			$setting->value = $node['value'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/guestbook/comment':
            setProgress($item++ / $items * 100, _t('방명록을 복원하고 있습니다.'));
            $comment = new GuestComment();
            $comment->name = $node['commenter'][0]['name'][0]['.value'];
            if (!empty($node['id'][0]['.value'])) {
                $comment->id = $node['id'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['.attributes']['id'])) {
                $comment->commenter = $node['commenter'][0]['.attributes']['id'];
            }
            if (!empty($node['commenter'][0]['homepage'][0]['.value'])) {
                $comment->homepage = $node['commenter'][0]['homepage'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['ip'][0]['.value'])) {
                $comment->ip = $node['commenter'][0]['ip'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['openid'][0]['.value'])) {
                $comment->openid = $node['commenter'][0]['openid'][0]['.value'];
            }
            $comment->password = $node['password'][0]['.value'];
            $comment->secret = @$node['secret'][0]['.value'];
            $comment->written = $node['written'][0]['.value'];
            $comment->content = $node['content'][0]['.value'];
            if (!$comment->add()) {
                user_error(__LINE__ . $comment->error);
            }
            if (isset($node['comment'])) {
                for ($j = 0; $j < count($node['comment']); $j++) {
                    $childComment = new GuestComment();
                    $childComment->parent = $comment->id;
                    $cursor =& $node['comment'][$j];
                    $childComment->name = $cursor['commenter'][0]['name'][0]['.value'];
                    if (!empty($cursor['id'][0]['.value'])) {
                        $comment->id = $cursor['id'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                        $childComment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                    }
                    if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                        $childComment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                        $childComment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                        $childComment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                    }
                    $childComment->password = $cursor['password'][0]['.value'];
                    $childComment->secret = @$cursor['secret'][0]['.value'];
                    $childComment->written = $cursor['written'][0]['.value'];
                    $childComment->content = $cursor['content'][0]['.value'];
                    if (!$childComment->add()) {
                        user_error(__LINE__ . $childComment->error);
                    }
                }
            }
            return true;
        case '/blog/filter':
            setProgress($item++ / $items * 100, _t('필터 설정을 복원하고 있습니다.'));
            $filter = new Filter();
            $filter->type = $node['.attributes']['type'];
            $filter->pattern = $node['pattern'][0]['.value'];
            if (!$filter->add()) {
                user_error(__LINE__ . $filter->error);
            }
            return true;
        case '/blog/feed':
            setProgress($item++ / $items * 100, _t('리더 데이터를 복원하고 있습니다.'));
            $feed = new Feed();
            if (!empty($node['group'][0]['.value'])) {
                $feed->group = FeedGroup::getId($node['group'][0]['.value'], true);
            }
            $feed->url = $node['url'][0]['.value'];
            if (!$feed->add()) {
                user_error(__LINE__ . $feed->error);
            }
            return true;
        case '/blog/line':
            setProgress($item++ / $items * 100, _t('라인을 복원하고 있습니다.'));
            $line = Model_Line::getInstance();
            $line->reset();
            if (!empty($node['author'][0]['.value'])) {
                $line->author = $node['author'][0]['.value'];
            }
            if (!empty($node['category'][0]['.value'])) {
                $line->category = $node['category'][0]['.value'];
            }
            if (!empty($node['root'][0]['.value'])) {
                $line->root = $node['root'][0]['.value'];
            }
            if (!empty($node['permalink'][0]['.value'])) {
                $line->permalink = $node['permalink'][0]['.value'];
            }
            if (!empty($node['content'][0]['.value'])) {
                $line->content = $node['content'][0]['.value'];
            }
            if (!empty($node['created'][0]['.value'])) {
                $line->created = intval($node['created'][0]['.value']);
            }
            if ($line->add()) {
                return true;
            } else {
                user_error(__LINE__ . $line->_error);
            }
    }
}
コード例 #6
0
ファイル: Tags.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get tag, if there is nothing then throw to 404
     $tag = Tbl::factory('tags')->get($id);
     if (!$tag) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         /**
          * Delete
          */
         // Get items_tags ids has this tag id このfieldのidを持つitems_tagsを取得
         $items_tags_ids = Tbl::factory('items_tags')->where('tag_id', '=', $tag->id)->read()->as_array(NULL, 'id');
         // Delete items_tags
         foreach ($items_tags_ids as $items_tags_id) {
             Tbl::factory('items_tags')->where('id', '=', $items_tags_id)->get()->delete();
         }
         // Delete
         $tag->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/tags/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Warning_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add
         Notice::add(Notice::WARNING, $e->getMessage());
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/tags/index", 'http'));
 }
コード例 #7
0
ファイル: Users.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get tag, if there is nothing then throw to 404
     $user = Tbl::factory('users')->get($id);
     if (!$user) {
         throw HTTP_Exception::factory(404);
     }
     /**
      * Delete
      */
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         // Delete roles_users
         $roles_users_ids = Tbl::factory('roles_users')->where('user_id', '=', $user->id)->read()->as_array(NULL, 'id');
         if ($roles_users_ids) {
             foreach ($roles_users_ids as $roles_users_id) {
                 Tbl::factory('roles_users')->get($roles_users_id)->delete();
             }
         }
         // Delate users_details
         $users_details_ids = Tbl::factory('users_details')->where('user_id', '=', $user->id)->read()->as_array(NULL, 'id');
         if ($users_details_ids) {
             foreach ($users_details_ids as $users_details_id) {
                 Tbl::factory('users_details')->get($users_details_id)->delete();
             }
         }
         // Delete
         $user->delete();
         // Delete image user dir
         Cms_Helper::delete_dir($user->username, $this->settings->image_dir . '/user', TRUE);
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR, $e->getMessage());
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/users", 'http'));
 }
コード例 #8
0
ファイル: Parts.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $segment = $this->request->param('key');
     if (!$segment) {
         throw HTTP_Exception::factory(404);
     }
     // Make part and get content from file and direct set to part
     $part = new stdClass();
     $part->segment = $segment;
     $part->content = Tpl::get_file($segment, $this->settings->front_tpl_dir . '/part');
     // If there is nothing then throw to 404
     if ($part->content === FALSE) {
         throw HTTP_Exception::factory(404);
     }
     // Try
     try {
         /**
          * Delete
          */
         // Delete file
         Cms_Helper::delete_file($part->segment, "{$this->settings->front_tpl_dir}/part");
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/parts/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Exception $e) {
         // Add error notice
         Notice::add(Notice::ERROR);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/parts/edit/{$part->segment}", 'http'));
 }
コード例 #9
0
ファイル: Divisions.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get division, if there is nothing then throw to 404
     $division = Tbl::factory('divisions')->get($id);
     if (!$division) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         /**
          * Check other tables
          */
         // used by items
         $used_items = (bool) Tbl::factory('items')->where('division_id', '=', $division->id)->read()->count();
         // used by categories
         $used_categories = (bool) Tbl::factory('categories')->where('division_id', '=', $division->id)->read()->count();
         // used by fields
         $used_fields = (bool) Tbl::factory('fields')->where('division_id', '=', $division->id)->read()->count();
         // Build tables array
         $tables = array();
         if ($used_items) {
             $tables[] = 'items';
         }
         if ($used_categories) {
             $tables[] = 'categories';
         }
         if ($used_fields) {
             $tables[] = 'fields';
         }
         // If this division is used when throw to warning
         if ($used_items or $used_categories or $used_fields) {
             throw new Warning_Exception(Kohana::message('general', 'division_is_used'), array(':tables' => implode(', ', $tables)));
         }
         /**
          * Delete
          */
         // Delete file まずファイルを消す!
         $file_delete_success = Cms_Helper::delete_file($division->segment, $this->settings->front_tpl_dir . '/division');
         if ($file_delete_success) {
             Cms_Helper::delete_dir($division->segment, $this->settings->item_dir);
             Cms_Helper::delete_dir($division->segment, $this->settings->image_dir . '/item');
         }
         // Delete
         $division->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/divisions/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Warning_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add
         Notice::add(Notice::WARNING, $e->getMessage());
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR, $e->getMessage());
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/divisions/edit/{$division->id}", 'http'));
 }
コード例 #10
0
ファイル: Emails.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get email, if there is nothing then throw to 404
     $email = Tbl::factory('emails')->get($id);
     if (!$email) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         /**
          * Delete
          */
         // used by email
         $used_rule_ids = Tbl::factory('email_rules')->where('email_id', '=', $email->id)->read()->as_array(NULL, 'id');
         if ($used_rule_ids) {
             foreach ($used_rule_ids as $used_rule_id) {
                 Tbl::factory('email_rules')->get($used_rule_id)->delete();
             }
         }
         // Delete file
         Cms_Helper::delete_file($email->segment, "{$this->settings->front_tpl_dir}/email");
         Cms_Helper::delete_file($email->segment, "{$this->settings->front_tpl_dir}/email/confirm");
         Cms_Helper::delete_file($email->segment, "{$this->settings->front_tpl_dir}/email/receive");
         // Delete
         $email->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/emails/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/emails/edit/{$email->id}", 'http'));
 }
コード例 #11
0
ファイル: Settings.php プロジェクト: deraemons/deraemon-cms
 /**
  * Frontend
  */
 public function action_frontend()
 {
     $settings = array('frontend_theme' => basename($this->settings->front_tpl_dir), 'lang' => $this->settings->lang, 'home_page' => $this->settings->home_page, 'site_details' => $this->settings->site_details);
     // If there are post
     if ($this->request->post()) {
         // Set post to email
         $settings['frontend_theme'] = Arr::get($this->request->post(), 'frontend_theme');
         $settings['lang'] = Arr::get($this->request->post(), 'lang');
         $settings['home_page'] = Arr::get($this->request->post(), 'home_page');
         $settings['site_details'] = Arr::get($this->request->post(), 'site_details');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             $validation = Validation::factory($settings)->rule('frontend_theme', 'not_empty')->rule('frontend_theme', 'alpha_numeric')->rule('lang', 'not_empty')->rule('home_page', 'not_empty')->label('front_theme', 'Front theme')->label('lang', 'Lang')->label('home_page', 'Home page');
             // Check validation
             if (!$validation->check()) {
                 throw new Validation_Exception($validation);
             }
             // Build frontend data
             $frontend_data = array('front_tpl_dir' => 'contents/frontend/' . Arr::get($settings, 'frontend_theme'), 'lang' => Arr::get($settings, 'lang'), 'home_page' => Arr::get($settings, 'home_page'), 'site_details' => Arr::get($settings, 'site_details'));
             foreach ($frontend_data as $key => $value) {
                 Tbl::factory('settings')->where('key', '=', $key)->get()->update(array('value' => $value));
             }
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     /**
      * View
      */
     // Get content file
     $content_file = Tpl::get_file('frontend', $this->settings->back_tpl_dir . '/settings', $this->partials);
     $this->content = Tpl::factory($content_file)->set('settings', $settings);
 }
コード例 #12
0
ファイル: Details.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action rule_delete
  */
 public function action_rule_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get detail, if there is nothing then throw to 404
     $detail_rule = Tbl::factory('detail_rules')->get($id);
     if (!$detail_rule) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         // Delete detail
         $detail_rule->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Warning_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add
         Notice::add(Notice::WARNING, $e->getMessage());
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/details/rule/{$detail_rule->detail_id}", 'http'));
 }
コード例 #13
0
ファイル: Author.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action detail
  */
 public function action_detail()
 {
     // Get content from file and direct set to detail
     $detail = new stdClass();
     $detail->content = Tpl::get_file('detail', $this->settings->front_tpl_dir . '/author');
     // If there are post
     if ($this->request->post()) {
         // Set post to author
         $detail->content = $this->request->post('content');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Update file
             Cms_Helper::set_file('detail', $this->settings->front_tpl_dir . '/author', $this->request->post('content'));
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     // usable details
     $usable_details = Tbl::factory('details')->read()->as_array('segment');
     /**
      * View
      */
     $content_file = Tpl::get_file('detail', $this->settings->back_tpl_dir . '/author', $this->partials);
     $this->content = Tpl::factory($content_file)->set('usable_details', $usable_details)->set('detail', $detail);
 }
コード例 #14
0
ファイル: Items.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action received comment delete
  */
 public function action_received_comment_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get ids, if When it is smaller than 2 then throw to 404
     $ids = explode('_', $this->request->param('key'));
     if (!(count($ids) == 2)) {
         throw HTTP_Exception::factory(404);
     }
     // idsをitem_idとreceived_comment_idに分ける
     list($item_id, $received_comment_id) = $ids;
     // Get received_comment, if there is nothing then throw to 404
     $received_comment = Tbl::factory('received_comments')->get($received_comment_id);
     if (!$received_comment) {
         throw HTTP_Exception::factory(404);
     }
     // Get item, if there is nothing then throw to 404
     $this->item = Tbl::factory('items')->get($item_id);
     if (!$this->item) {
         throw HTTP_Exception::factory(404);
     }
     // Get division
     $division = Tbl::factory('divisions')->where('id', '=', $this->item->division_id)->read(1);
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         // Delete
         $received_comment->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         // redirect
         $this->redirect(URL::site("{$this->settings->backend_name}/items/{$division->segment}/received_comments/{$this->item->id}", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR);
     }
     // Redirect to received_comments edit
     $this->redirect(URL::site("{$this->settings->backend_name}/items/{$division->segment}/received_comments/{$this->item->id}", 'http') . URL::query());
 }
コード例 #15
0
ファイル: Shapes.php プロジェクト: deraemons/deraemon-cms
 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $segment = $this->request->param('key');
     if (!$segment) {
         throw HTTP_Exception::factory(404);
     }
     // Make shape and get content from file and direct set to shape
     $shape = new stdClass();
     $shape->segment = $segment;
     $shape->content = Tpl::get_file($segment, $this->settings->front_tpl_dir . '/shape');
     // If there is nothing then throw to 404
     if ($shape->content === FALSE) {
         throw HTTP_Exception::factory(404);
     }
     // Try
     try {
         /**
          * Check other tables
          */
         // used by items
         $used_items = (bool) Tbl::factory('items')->where('shape_segment', '=', $shape->segment)->read()->count();
         // If this shape is used throw to warning
         if ($used_items) {
             throw new Warning_Exception(Kohana::message('general', 'shape_is_used'));
         }
         /**
          * Delete
          */
         // Delete file
         Cms_Helper::delete_file($shape->segment, "{$this->settings->front_tpl_dir}/shape");
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/shapes/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Warning_Exception $e) {
         // Add
         Notice::add(Notice::WARNING, $e->getMessage());
     } catch (Exception $e) {
         // Add error notice
         Notice::add(Notice::ERROR, $e->getMessage() . ' : ' . $e->getFile() . ' : ' . $e->getLine());
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/shapes/edit/{$shape->segment}", 'http'));
 }
コード例 #16
0
ファイル: Template.php プロジェクト: deraemons/deraemon-cms
 /**
  * Before
  */
 public function before()
 {
     /**
      * before
      */
     parent::before();
     /**
      * Get settings
      */
     // <editor-fold defaultstate="collapsed" desc="Get settings">
     $this->settings = Cms_Helper::settings();
     // </editor-fold>
     /**
      * Set website language
      */
     // <editor-fold defaultstate="collapsed" desc="Set website language">
     I18n::lang('backend' . $this->settings->backend_lang);
     // </editor-fold>
     /**
      * Authenticate and get logged in user:ディレクト、アドミン、エディター以外は入れない、入ったときはlogged in userをセット
      */
     // <editor-fold defaultstate="collapsed" desc="Authenticate and get logged in user">
     if (Auth::instance()->logged_in('direct') or Auth::instance()->logged_in('admin') or Auth::instance()->logged_in('edit')) {
         // もしログインしていてアクションがloginの場合はバックエンドホームに飛ばす
         if ($this->request->action() == 'login') {
             HTTP::redirect(URL::site($this->settings->backend_name, 'http'));
         }
         // Set logged in user
         $this->logged_in_user = Tbl::factory('users')->where('id', '=', Auth::instance()->get_user()->id)->read(1);
         // Set logged in user role
         $this->logged_in_user->role = Tbl::factory('roles_users')->select('roles.*')->join('roles')->on('roles_users.role_id', '=', 'roles.id')->where('roles_users.user_id', '=', $this->logged_in_user->id)->where('roles.name', '!=', 'login')->read('name');
         // Set logged in user role name for template
         $this->logged_in_user->{$this->logged_in_user->role} = TRUE;
     } else {
         // If not logged in throw to login
         if (!($this->request->controller() == 'Auth')) {
             $this->redirect(URL::site("{$this->settings->backend_name}/login", 'http'));
         }
     }
     // </editor-fold>
     /**
      * Get item menu:itemのメニューを取得 $menusのitemsに入れる
      */
     // <editor-fold defaultstate="collapsed" desc="Get item menu">
     $divisions = Tbl::factory('divisions')->read()->as_array();
     // itemのチルドレンの配列を作成
     $item_children = array();
     // item search
     // controllerは新しく作ったよ
     $item_children['item_search'] = array('name' => 'item search', 'controller' => 'item_search', 'division' => '', 'actions' => array('index'), 'url' => URL::site("{$this->settings->backend_name}/item_search", 'http'), 'roles' => array('direct', 'admin', 'edit'), 'allow' => FALSE);
     // 作成されたディビジョンの数だけ作成
     foreach ($divisions as $division) {
         $item_children[$division->name] = array('name' => $division->name, 'controller' => 'items', 'division' => $division->segment, 'actions' => array('index', 'edit', 'content', 'images', 'image_delete', 'fields', 'received_comments', 'received_comment_delete', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/items/{$division->segment}", 'http'), 'roles' => array('direct', 'admin', 'edit'), 'allow' => FALSE);
     }
     // </editor-fold>
     /**
      * Build menu:全体のメニューを作成
      *
      * 許可するロールを指定
      * 'roles' => array('direct', 'admin', 'edit')
      */
     // <editor-fold defaultstate="collapsed" desc="Build menu">
     $this->menus = array('dashboard' => array('name' => 'dashboard', 'icon' => 'fa fa-dashboard', 'children' => array('home' => array('name' => 'home', 'controller' => 'home', 'actions' => array('index', 'about', 'syntax'), 'url' => URL::site("{$this->settings->backend_name}/home/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin', 'edit')), 'settings' => array('name' => 'settings', 'controller' => 'settings', 'actions' => array('index', 'frontend'), 'url' => URL::site("{$this->settings->backend_name}/settings/index", 'http'), 'allow' => FALSE, 'roles' => array('direct')), 'users' => array('name' => 'users', 'controller' => 'users', 'actions' => array('index', 'edit', 'avatar_delete', 'detail', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/users/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'received_emails' => array('name' => 'received emails', 'controller' => 'received_emails', 'actions' => array('index', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/received-emails/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'received_comments' => array('name' => 'received comments', 'controller' => 'received_comments', 'actions' => array('index', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/received-comments/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')))), 'template' => array('name' => 'template', 'icon' => 'fa fa-file-o', 'children' => array('wrappers' => array('name' => 'wrappers', 'controller' => 'wrappers', 'actions' => array('index', 'edit', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/wrappers/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'divisions' => array('name' => 'divisions', 'controller' => 'divisions', 'actions' => array('index', 'edit', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/divisions/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'shapes' => array('name' => 'shapes', 'controller' => 'shapes', 'actions' => array('index', 'edit', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/shapes/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'parts' => array('name' => 'parts', 'controller' => 'parts', 'actions' => array('index', 'edit', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/parts/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'search' => array('name' => 'search', 'controller' => 'search', 'actions' => array('form', 'result', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/search/form", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'emails' => array('name' => 'emails', 'controller' => 'emails', 'actions' => array('setting', 'index', 'edit', 'confirm', 'receive', 'rule', 'rule_delete', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/emails/setting", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'comment' => array('name' => 'comment', 'controller' => 'comment', 'actions' => array('setting', 'form', 'result'), 'url' => URL::site("{$this->settings->backend_name}/comment/setting", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'author' => array('name' => 'author', 'controller' => 'author', 'actions' => array('setting', 'login', 'register', 'activate_mail', 'activate', 'forgot', 'reset_mail', 'reset', 'resign', 'account', 'password', 'detail'), 'url' => URL::site("{$this->settings->backend_name}/author/setting", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'errors' => array('name' => 'errors', 'controller' => 'errors', 'actions' => array('404', '500', 'default'), 'url' => URL::site("{$this->settings->backend_name}/errors/404", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')))), 'attachment' => array('name' => 'attachment', 'icon' => 'fa fa-paperclip', 'children' => array('fields' => array('name' => 'fields', 'controller' => 'fields', 'actions' => array('index', 'edit', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/fields/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'categories' => array('name' => 'categories', 'controller' => 'categories', 'actions' => array('index', 'edit', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/categories/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'tags' => array('name' => 'tags', 'controller' => 'tags', 'actions' => array('index', 'edit', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/tags/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')), 'details' => array('name' => 'details', 'controller' => 'details', 'actions' => array('index', 'edit', 'rule', 'rule_delete', 'delete'), 'url' => URL::site("{$this->settings->backend_name}/details/index", 'http'), 'allow' => FALSE, 'roles' => array('direct', 'admin')))), 'items' => array('name' => 'items', 'icon' => 'fa fa-files-o', 'children' => $item_children));
     // </editor-fold>
     /**
      * Set current to menu:currentをセット、現在のページ(current_child)をセット
      */
     // <editor-fold defaultstate="collapsed" desc="Set current to menu">
     $controller = strtolower($this->request->controller());
     $action = strtolower($this->request->action());
     $division = $this->request->param('division');
     $current_child = NULL;
     // メニューをイテレート
     foreach ($this->menus as $key => &$value) {
         // メニューのチャイルドをイテレート
         foreach ($value['children'] as &$child) {
             // If except an item:もしcontrollerがitemsの時で↓
             if ($child['controller'] !== 'items') {
                 // カレントの場合
                 if ($child['controller'] === $controller) {
                     // parrentにTRUEをセット
                     $value['current'] = TRUE;
                     if (in_array($action, $child['actions'])) {
                         // currentにTRUEをセット
                         $child['current'] = TRUE;
                         // カレントチャイルドにセット
                         $current_child = (object) $child;
                         $current_child->parrent = $key;
                     }
                 }
                 // ロールがある場合
                 if ($this->logged_in_user and in_array($this->logged_in_user->role, $child['roles'])) {
                     $child['allow'] = TRUE;
                 }
             } else {
                 // カレントの場合
                 if ($child['division'] === $division) {
                     // currentにTRUEをセット
                     $value['current'] = TRUE;
                     if (in_array($action, $child['actions'])) {
                         // currentにTRUEをセット
                         $child['current'] = TRUE;
                         // カレントチャイルドにセット
                         $current_child = (object) $child;
                         $current_child->parrent = $key;
                     }
                 }
                 // ロールがある場合
                 if ($this->logged_in_user and in_array($this->logged_in_user->role, $child['roles'])) {
                     $child['allow'] = TRUE;
                 }
             }
         }
     }
     // </editor-fold>
     /**
      * Allow page controll:許可するページのみ入れる、それ以外はのNoticeを出してredirect
      *
      * user_idのfilterはitemsのcontlollerで行う
      */
     // <editor-fold defaultstate="collapsed" desc="Allow page controll">
     if ($this->logged_in_user and $current_child) {
         // ロールに含まれない場合
         if (!in_array($this->logged_in_user->role, $current_child->roles)) {
             // ワーニング
             Notice::add(Notice::WARNING, Kohana::message('general', 'no_authority'));
             // リダイレクト
             $this->redirect(URL::site("{$this->settings->backend_name}", 'http'));
         }
     } elseif ($controller !== 'auth' and $action !== 'login') {
         // ワーニング
         Notice::add(Notice::WARNING, Kohana::message('general', 'no_authority'));
         // リダイレクト
         $this->redirect(URL::site("{$this->settings->backend_name}", 'http'));
     }
     // </editor-fold>
     /**
      * View
      */
     // <editor-fold defaultstate="collapsed" desc="View">
     if ($this->auto_render) {
         // Partial header and footer
         $this->partials['header'] = Tpl::get_file('header', $this->settings->back_tpl_dir);
         $this->partials['footer'] = Tpl::get_file('footer', $this->settings->back_tpl_dir);
         $this->partials['snippets'] = Tpl::get_file('snippets', $this->settings->back_tpl_dir);
     }
     // </editor-fold>
 }