Beispiel #1
0
} else {
    $_GET['page'] = 1;
    $_SESSION['bulk']['member'] = array();
}
// 名簿を取得
if (empty($_GET['class_id'])) {
    $where = null;
} else {
    $where = array('members.class_id = :class_id', array('class_id' => $_GET['class_id']));
}
$_view['members'] = select_members(array('where' => $where, 'order_by' => 'id', 'limit' => array(':offset, :limit', array('offset' => $GLOBALS['config']['limits']['member'] * ($_GET['page'] - 1), 'limit' => $GLOBALS['config']['limits']['member']))), array('associate' => true));
$_view['member_count'] = select_members(array('select' => 'COUNT(DISTINCT members.id) AS count', 'where' => $where), array('associate' => true));
$_view['member_count'] = $_view['member_count'][0]['count'];
$_view['member_page'] = ceil($_view['member_count'] / $GLOBALS['config']['limits']['member']);
// 教室を取得
$classes = select_classes(array('order_by' => 'sort, id'));
$class_sets = array();
foreach ($classes as $class) {
    $class_sets[$class['id']] = $class;
}
$_view['class_sets'] = $class_sets;
$_view['classes'] = $classes;
// 分類を取得
$categories = select_categories(array('order_by' => 'sort, id'));
$category_sets = array();
foreach ($categories as $category) {
    $category_sets[$category['id']] = $category;
}
$_view['category_sets'] = $category_sets;
$_view['categories'] = $categories;
// ページャー
Beispiel #2
0
 if (isset($_SESSION['file'][$_GET['target']][$_GET['key']]['name']) && isset($_SESSION['file'][$_GET['target']][$_GET['key']]['data'])) {
     // セッションからファイルを取得
     foreach (array_keys($GLOBALS['config']['file_permissions'][$_GET['format']]) as $permission) {
         if (preg_match($GLOBALS['config']['file_permissions'][$_GET['format']][$permission]['regexp'], $_SESSION['file'][$_GET['target']][$_GET['key']]['name'])) {
             // マイムタイプ
             $mime = $GLOBALS['config']['file_permissions'][$_GET['format']][$permission]['mime'];
             break;
         }
     }
     // コンテンツ
     $content = $_SESSION['file'][$_GET['target']][$_GET['key']]['data'];
 } elseif (isset($_GET['id'])) {
     // 登録内容からファイルを取得
     $results = array();
     if ($_GET['target'] === 'class') {
         $results = select_classes(array('where' => array('id = :id', array('id' => $_GET['id']))));
     } elseif ($_GET['target'] === 'member') {
         $results = select_members(array('where' => array('id = :id', array('id' => $_GET['id']))));
     }
     if (empty($results)) {
         warning('データが見つかりません。');
     } else {
         $result = $results[0];
     }
     $file = $GLOBALS['config']['file_targets'][$_GET['target']] . intval($_GET['id']) . '/' . $result[$_GET['key']];
     if (is_file($file)) {
         foreach (array_keys($GLOBALS['config']['file_permissions'][$_GET['format']]) as $permission) {
             if (preg_match($GLOBALS['config']['file_permissions'][$_GET['format']][$permission]['regexp'], $result[$_GET['key']])) {
                 // マイムタイプ
                 $mime = $GLOBALS['config']['file_permissions'][$_GET['format']][$permission]['mime'];
                 break;
Beispiel #3
0
        }
    }
    if (isset($_GET['_type']) && $_GET['_type'] === 'json') {
        // 名簿情報を取得
        header('Content-Type: application/json; charset=' . MAIN_CHARSET);
        echo json_encode(array('status' => 'OK', 'data' => $_view, 'files' => array('image_01' => $_view['member']['image_01'] ? file_mimetype($_view['member']['image_01']) : null, 'image_02' => $_view['member']['image_02'] ? file_mimetype($_view['member']['image_02']) : null)));
        exit;
    } else {
        // 投稿セッションを初期化
        unset($_SESSION['post']);
        unset($_SESSION['file']);
    }
    // 編集開始日時を記録
    if (!empty($_GET['id'])) {
        $_SESSION['update']['member'] = localdate('Y-m-d H:i:s');
    }
}
if (empty($_POST['view']) || $_POST['view'] !== 'preview') {
    // 名簿の表示用データ作成
    $_view['member'] = view_members($_view['member']);
}
// 教室を取得
$_view['classes'] = select_classes(array('order_by' => 'sort, id'));
// 分類を取得
$_view['categories'] = select_categories(array('order_by' => 'sort, id'));
// タイトル
if (empty($_GET['id'])) {
    $_view['title'] = '名簿登録';
} else {
    $_view['title'] = '名簿編集';
}
Beispiel #4
0
<?php

// コードを取得
if (isset($_params[1])) {
    $_GET['code'] = $_params[1];
}
if (!isset($_GET['code']) || !preg_match('/^[\\w\\-]+$/', $_GET['code'])) {
    error('不正なアクセスです。');
}
// ページを取得
if (isset($_GET['page'])) {
    $_GET['page'] = intval($_GET['page']);
} else {
    $_GET['page'] = 1;
}
// 教室を取得
$classes = select_classes(array('where' => array('code = :code', array('code' => $_GET['code']))));
if (empty($classes)) {
    warning('教室が見つかりません。');
} else {
    $_view['class'] = $classes[0];
}
// 名簿を取得
$_view['members'] = select_members(array('where' => array('members.class_id = :class_id AND members.public = 1', array('class_id' => $_view['class']['id'])), 'order_by' => 'members.id', 'limit' => array(':offset, :limit', array('offset' => $GLOBALS['config']['limits']['member'] * ($_GET['page'] - 1), 'limit' => $GLOBALS['config']['limits']['member']))), array('associate' => true));
$_view['member_count'] = select_members(array('select' => 'COUNT(*) AS count', 'where' => array('members.class_id = :class_id AND members.public = 1', array('class_id' => $_view['class']['id']))), array('associate' => true));
$_view['member_count'] = $_view['member_count'][0]['count'];
$_view['member_page'] = ceil($_view['member_count'] / $GLOBALS['config']['limits']['member']);
// タイトル
$_view['title'] = $_view['class']['name'];