Exemplo n.º 1
0
 /**
  * The index action.
  * 
  * @access  public
  * @return  void
  */
 public function action_index()
 {
     $is_draft = \Input::get('is_draft', 0);
     $is_published = \Util_toolkit::reverse_bool($is_draft, true);
     $data = array();
     $data['is_draft'] = $is_draft;
     list($data['list'], $data['pagination']) = \Site_Model::get_pagenation_list('news', array('related' => 'news_category'));
     $this->template->layout = 'wide';
     $this->set_title_and_breadcrumbs(term('news.view', 'site.management'));
     $this->template->subtitle = \View::forge('news/_parts/list_subtitle');
     $this->template->content = \View::forge('news/list', $data);
 }
Exemplo n.º 2
0
 public static function get_list($limit, $page = 1, $self_member_id = 0, $target_member_obj = null, $is_mypage = false, $is_draft = 0)
 {
     if ($target_member_obj && !$target_member_obj instanceof \Model_Member) {
         throw new InvalidArgumentException('forth parameter is invalid.');
     }
     $is_published = \Util_toolkit::reverse_bool($is_draft, true);
     $data = Model_Note::get_pager_list(array('related' => 'member', 'where' => \Site_Model::get_where_params4list($target_member_obj ? $target_member_obj->id : 0, $self_member_id ?: 0, $is_mypage, array(array('is_published', $is_published))), 'limit' => $limit, 'order_by' => array('created_at' => 'desc')), $page);
     $data['is_draft'] = $is_draft;
     $data['member'] = $target_member_obj;
     $data['is_mypage'] = $is_mypage;
     $data['liked_note_ids'] = conf('like.isEnabled') && $self_member_id ? \Site_Model::get_liked_ids('note', $self_member_id, $data['list']) : array();
     return $data;
 }
Exemplo n.º 3
0
    public function action_change_password()
    {
        \Util_security::check_method('POST');
        \Util_security::check_csrf();
        $form = $this->form_setting_password();
        $val = $form->validation();
        if ($val->run()) {
            $post = $val->validated();
            $data = array();
            $data['to_name'] = $this->u->username;
            $data['to_address'] = $this->u->email;
            $data['from_name'] = conf('mail.admin.from_name');
            $data['from_address'] = conf('mail.admin.from_email');
            $data['subject'] = term('site.password', 'form.update', 'form.complete') . 'の' . term('site.notice');
            $term_password = term('site.password');
            $data['body'] = <<<END
{$data['to_name']} 様

{$term_password}を変更しました。

END;
            try {
                \DB::start_transaction();
                $this->change_password($post['old_password'], $post['password']);
                \DB::commit_transaction();
                \Util_toolkit::sendmail($data);
                \Session::set_flash('message', term('site.password') . 'を変更しました。');
                \Response::redirect('admin/setting');
            } catch (\EmailValidationFailedException $e) {
                $this->display_error(term('site.password', 'form.update') . ': 送信エラー', __METHOD__ . ' email validation error: ' . $e->getMessage());
            } catch (\EmailSendingFailedException $e) {
                $this->display_error(term('site.password', 'form.update') . ': 送信エラー', __METHOD__ . ' email sending error: ' . $e->getMessage());
            } catch (\WrongPasswordException $e) {
                if (\DB::in_transaction()) {
                    \DB::rollback_transaction();
                }
                \Session::set_flash('error', sprintf('現在の%sが正しくありません。', term('site.password')));
            } catch (\FuelException $e) {
                if (\DB::in_transaction()) {
                    \DB::rollback_transaction();
                }
                \Session::set_flash('error', $e->getMessage());
            }
        } else {
            \Session::set_flash('error', $val->show_errors());
        }
        $this->action_password();
    }
Exemplo n.º 4
0
    private function send_mail_create_user($data)
    {
        if (!is_array($data)) {
            $data = (array) $data;
        }
        $data['body'] = <<<END
メンバー登録が完了しました。

====================
ユーザ名: {$data['to_name']}
メールアドレス: {$data['to_address']}
仮パスワード: {$data['password']}
====================
※パスワードはログイン後、変更してください。

END;
        \Util_toolkit::sendmail($data);
    }
Exemplo n.º 5
0
// Bootstrap the framework DO NOT edit this
require COREPATH . 'bootstrap.php';
\Autoloader::add_classes(array('Controller' => APPPATH . 'classes/controller.php', 'Database_Query_Builder_Update' => APPPATH . 'classes/database/query/builder/update.php', 'DBUtil' => APPPATH . 'classes/dbutil.php', 'Uri' => APPPATH . 'classes/uri.php', 'Str' => APPPATH . 'classes/str.php', 'Html' => APPPATH . 'classes/html.php', 'Validation' => APPPATH . 'classes/validation.php', 'Agent' => APPPATH . 'classes/agent.php', 'Asset' => APPPATH . 'classes/asset.php', 'Asset_Instance' => APPPATH . 'classes/asset/instance.php', 'Fieldset' => APPPATH . 'classes/fieldset.php', 'Fieldset_Field' => APPPATH . 'classes/fieldset/field.php'));
// Register the autoloader
\Autoloader::register();
/**
 * Your environment.  Can be set to any of the following:
 *
 * Fuel::DEVELOPMENT
 * Fuel::TEST
 * Fuel::STAGING
 * Fuel::PRODUCTION
 */
\Fuel::$env = isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : strtolower(FBD_ENVIRONMENT);
// include helpers.
Util_toolkit::include_php_files(APPPATH . 'helpers');
// Initialize the framework with the config file.
\Fuel::init('config.php');
// Config load.
Config::load('site', 'site');
Config::load('term', 'term');
Config::load('icon', 'icon');
Config::load('page', 'page');
Config::load('template', 'template');
Config::load('exif', 'exif');
Config::load('less', 'less');
// Config of each module load.
$modules = Site_Util::get_active_modules();
foreach ($modules as $module => $path) {
    if (file_exists(sprintf('%sconfig/%s.php', $path, $module))) {
        Config::load(sprintf('%s::%s', $module, $module), $module);
Exemplo n.º 6
0
    private function send_account_lock_mail($data)
    {
        $data['subject'] = 'アカウントがロックされました';
        $data['body'] = <<<END
アカウントがロックされました。

====================
ログインに失敗したメールアドレス: {$data['login_failed_email']}
====================

END;
        if ($is_admin) {
            $data['body'] .= <<<END
管理者向け情報
====================
member_id: {$data['member_id']}
ニックネーム: {$data['member_name']}
====================

END;
        }
        Util_toolkit::sendmail($data);
    }
Exemplo n.º 7
0
if (empty($btn_type)) {
    $btn_type = 'default';
}
if (empty($btn_size)) {
    $btn_size = '';
}
if (!isset($btn_group_attrs)) {
    $btn_group_attrs = array();
}
$default_btn_group_attrs = array('class' => 'btn-group');
$btn_group_attrs = Util_toolkit::convert_to_attr($btn_group_attrs, $default_btn_group_attrs);
if (!isset($btn_attrs)) {
    $btn_attrs = array();
}
$default_btn_attrs = array('data-toggle' => 'dropdown');
$btn_attrs = Util_toolkit::convert_to_attr($btn_attrs, $default_btn_attrs);
$menu_id = !empty($btn_attrs['data-menu']) ? str_replace('#', '', $btn_attrs['data-menu']) : '';
if (empty($btn_with_text)) {
    $btn_with_text = false;
}
?>
<div <?php 
echo array_to_attr($btn_group_attrs);
?>
>
	<?php 
echo btn($type, null, 'dropdown-toggle', $btn_with_text, $btn_size, $btn_type, $btn_attrs, null, 'button', null, null, $with_caret);
?>
	<ul class="dropdown-menu<?php 
if ($is_popover_align_right) {
    ?>
Exemplo n.º 8
0
function site_get_time($mysql_datetime, $display_type = 'relative', $format = 'Y年n月j日 H:i', $display_both_length = '+7 day', $is_normal_timestamp = false)
{
    $accept_display_types = array('relative', 'normal', 'both');
    if (!in_array($display_type, $accept_display_types)) {
        throw new InvalidArgumentException('Second parameter is invalid.');
    }
    $time = $mysql_datetime;
    if (!$is_normal_timestamp) {
        $time = strtotime($mysql_datetime);
    }
    $normal_time = date($format, $time);
    if ($display_type == 'normal') {
        return $normal_time;
    }
    $past_time = sprintf('<span data-livestamp="%s"></span>', date(DATE_ISO8601, $time));
    $display = '';
    if ($display_type == 'both' && (is_null($display_both_length) || !is_null($display_both_length) && time() < strtotime($normal_time . ' ' . $display_both_length))) {
        $display = sprintf('%s (%s)', $normal_time, $past_time);
    } else {
        if ($time < strtotime('-1 day')) {
            $display = $normal_time;
        } elseif ($time >= strtotime('-1 day') && $time < strtotime('-1 hour')) {
            $past_hours = Util_toolkit::get_past_time($time);
            $display = sprintf('約%d時間前', $past_hours);
        } else {
            $display = $past_time;
        }
    }
    return $display;
}