PageRenderTime 100ms CodeModel.GetById 20ms app.highlight 59ms RepoModel.GetById 1ms app.codeStats 2ms

/webapp/lib/db/commu.php

https://github.com/openpne/OpenPNE2
PHP | 3587 lines | 2505 code | 447 blank | 635 comment | 255 complexity | 752d16dac63b5fc31cf09b64ed98683a MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1<?php
   2/**
   3 * @copyright 2005-2008 OpenPNE Project
   4 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
   5 */
   6
   7//// c_commu
   8
   9/**
  10 * コミュニティ情報をIDから取得
  11 *
  12 * @param  int $c_commu_id
  13 * @return array コミュニティ情報
  14 */
  15function db_commu_c_commu4c_commu_id($c_commu_id)
  16{
  17    $sql = 'SELECT * FROM c_commu WHERE c_commu_id = ?';
  18    $params = array(intval($c_commu_id));
  19    if (!$c_commu = db_get_row($sql, $params)) return array();
  20
  21    $c_commu['c_commu_category'] =
  22        db_commu_get_c_commu_category4id($c_commu['c_commu_category_id']);
  23    $c_commu['c_member_admin'] =
  24        db_member_c_member4c_member_id($c_commu['c_member_id_admin']);
  25
  26    return $c_commu;
  27}
  28
  29/**
  30 * コミュニティ情報を得る
  31 */
  32function db_commu_c_commu4c_commu_id2($c_commu_id)
  33{
  34    static $is_recurred = false;  //再帰処理中かどうかの判定フラグ
  35
  36    if (!$is_recurred) {  //function cacheのために再帰処理を行う
  37        $is_recurred = true;
  38        $funcargs = func_get_args();
  39        $result = pne_cache_recursive_call(OPENPNE_FUNCTION_CACHE_LIFETIME_LONG, __FUNCTION__, $funcargs);
  40        $is_recurred = false;
  41        return $result;
  42    }
  43
  44    if ($c_commu = db_commu_c_commu4c_commu_id($c_commu_id)) {
  45        $c_commu['member_count'] = db_commu_count_c_commu_member_list4c_commu_id($c_commu_id);
  46    }
  47    return $c_commu;
  48}
  49
  50/**
  51 * コミュニティ情報をIDから返す
  52 */
  53function db_commu_c_commu4c_commu_id_k($c_commu_id)
  54{
  55    static $is_recurred = false;  //再帰処理中かどうかの判定フラグ
  56
  57    if (!$is_recurred) {  //function cacheのために再帰処理を行う
  58        $is_recurred = true;
  59        $funcargs = func_get_args();
  60        $result = pne_cache_recursive_call(OPENPNE_FUNCTION_CACHE_LIFETIME_LONG, __FUNCTION__, $funcargs);
  61        $is_recurred = false;
  62        return $result;
  63    }
  64
  65    if ($c_commu = db_commu_c_commu4c_commu_id($c_commu_id)) {
  66        $c_commu['count_member'] = db_commu_count_c_commu_member_list4c_commu_id($c_commu_id);
  67    }
  68    return $c_commu;
  69}
  70
  71function db_commu_is_commu4c_commu_name($c_commu_name)
  72{
  73    $sql = 'SELECT c_commu_id FROM c_commu WHERE name = ?';
  74    $params = array($c_commu_name);
  75    return (bool)db_get_one($sql, $params);
  76}
  77
  78/**
  79 * 登録時に強制参加させるコミュニティIDのリスト
  80 */
  81function db_commu_regist_join_list()
  82{
  83    $sql = 'SELECT c_commu_id FROM c_commu WHERE is_regist_join = 1';
  84    return db_get_col($sql);
  85}
  86
  87//// c_commu_member
  88
  89/**
  90 * コミュニティの参加メンバー数を取得
  91 *
  92 * @param   int $c_commu_id
  93 * @return  int 参加メンバー数
  94 */
  95function db_commu_count_c_commu_member_list4c_commu_id($c_commu_id)
  96{
  97    $sql = 'SELECT COUNT(*) FROM c_commu_member WHERE c_commu_id = ?';
  98    $params = array(intval($c_commu_id));
  99    return db_get_one($sql, $params);
 100}
 101
 102/**
 103 * メンバーの参加コミュニティ数を取得
 104 *
 105 * @param int $c_member_id
 106 * @return int 参加コミュニティ数
 107 */
 108function db_commu_count_c_commu4c_member_id($c_member_id)
 109{
 110    $sql = 'SELECT COUNT(*) FROM c_commu_member WHERE c_member_id = ?';
 111    $params = array(intval($c_member_id));
 112    return db_get_one($sql, $params);
 113}
 114
 115//// c_commu_topic
 116
 117//// c_commu_topic_comment
 118
 119/**
 120 * max
 121 */
 122function db_commu_get_max_c_commu_topic_comment_number4c_topic_id($c_commu_topic_id)
 123{
 124    $sql = 'SELECT MAX(number) FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
 125    $params = array(intval($c_commu_topic_id));
 126    return db_get_one($sql, $params, 'main');
 127}
 128
 129/**
 130 * 次の書き込み番号取得
 131 *
 132 * @param  int $c_commu_topic_id
 133 * @return int 次の書き込み番号
 134 */
 135function db_commu_c_commu_topic_comment_number4c_commu_topic_id($c_commu_topic_id)
 136{
 137    return db_commu_get_max_c_commu_topic_comment_number4c_topic_id($c_commu_topic_id) + 1;
 138}
 139
 140//// 判定
 141
 142/**
 143 * コミュニティのメンバーかどうか判定
 144 *
 145 * @param  int c_commu_id
 146 * @param  int c_member_id
 147 * @return bool
 148 */
 149function db_commu_is_c_commu_member($c_commu_id, $c_member_id)
 150{
 151    $sql = 'SELECT c_commu_member_id FROM c_commu_member' .
 152            ' WHERE c_commu_id = ? AND c_member_id = ?';
 153    $params = array(intval($c_commu_id), intval($c_member_id));
 154    return (bool)db_get_one($sql, $params, 'main');
 155}
 156
 157/**
 158 * コミュニティの管理者かどうかを判定
 159 *
 160 * @param  int $c_commu_id
 161 * @param  int $c_member_id
 162 * @return bool
 163 */
 164function db_commu_is_c_commu_admin($c_commu_id, $c_member_id)
 165{
 166    $sql = 'SELECT c_commu_id FROM c_commu' .
 167            ' WHERE c_commu_id = ? AND c_member_id_admin = ?';
 168    $params = array(intval($c_commu_id), intval($c_member_id));
 169    return ( (bool)db_get_one($sql, $params) || db_commu_is_c_commu_sub_admin($c_commu_id, $c_member_id) );
 170}
 171
 172/**
 173 * コミュニティの副管理者かどうかを判定
 174 *
 175 * @param  int $c_commu_id
 176 * @param  int $c_member_id
 177 * @return bool
 178 */
 179function db_commu_is_c_commu_sub_admin($c_commu_id, $c_member_id)
 180{
 181    $sql = 'SELECT c_commu_id FROM c_commu' .
 182            ' WHERE c_commu_id = ? AND c_member_id_sub_admin = ?';
 183    $params = array(intval($c_commu_id), intval($c_member_id));
 184    return (bool)db_get_one($sql, $params);
 185}
 186
 187function db_commu_is_c_topic_admin($c_commu_topic_id, $c_member_id)
 188{
 189    $sql = 'SELECT c_commu_topic_id FROM c_commu_topic' .
 190            ' WHERE c_commu_topic_id = ? AND c_member_id = ?';
 191    $params = array(intval($c_commu_topic_id), intval($c_member_id));
 192    return (bool)db_get_one($sql, $params);
 193}
 194
 195/**
 196 * コミュニティ参加承認待ち状態かどうか
 197 */
 198function db_commu_is_c_commu_join_wait($c_commu_id, $c_member_id)
 199{
 200    $sql = 'SELECT c_commu_member_confirm_id FROM c_commu_member_confirm' .
 201            ' WHERE c_commu_id = ? AND c_member_id = ?';
 202    $params = array(intval($c_commu_id), intval($c_member_id));
 203    return (bool)db_get_one($sql, $params, 'main');
 204}
 205
 206function db_commu_is_c_commu_view4c_commu_idAc_member_id($c_commu_id,$c_member_id)
 207{
 208    $ret = false;
 209    $c_commu = db_commu_c_commu4c_commu_id($c_commu_id);
 210
 211    $is_c_commu_member = db_commu_is_c_commu_member($c_commu_id, $c_member_id);
 212
 213    switch($c_commu['is_open']) {
 214    case "public":
 215        $ret = true;
 216        break;
 217    case "member":
 218        if ($is_c_commu_member) {
 219            $ret = true;
 220        } else {
 221            $ret = false;
 222        }
 223        break;
 224    }
 225    return $ret;
 226}
 227
 228////
 229
 230/**
 231 * コミュニティメール(ktai)受信設定を取得
 232 */
 233function db_commu_is_receive_mail_ktai($c_commu_id, $c_member_id)
 234{
 235    $sql = 'SELECT is_receive_mail FROM c_commu_member' .
 236            ' WHERE c_commu_id = ? AND c_member_id = ?';
 237    $params = array(intval($c_commu_id), intval($c_member_id));
 238    return db_get_one($sql, $params);
 239}
 240
 241/**
 242 * コミュニティメール(PC)受信設定を取得
 243 */
 244function db_commu_is_receive_mail_pc($c_commu_id, $c_member_id)
 245{
 246    $sql = 'SELECT is_receive_mail_pc FROM c_commu_member' .
 247            ' WHERE c_commu_id = ? AND c_member_id = ?';
 248    $params = array(intval($c_commu_id), intval($c_member_id));
 249    return db_get_one($sql, $params);
 250}
 251
 252/**
 253 * コミュニティメッセージ受信設定を取得
 254 */
 255function db_commu_is_receive_message($c_commu_id, $c_member_id)
 256{
 257    $sql = 'SELECT is_receive_message FROM c_commu_member' .
 258            ' WHERE c_commu_id = ? AND c_member_id = ?';
 259    $params = array(intval($c_commu_id), intval($c_member_id));
 260    return db_get_one($sql, $params);
 261}
 262
 263/**
 264 * コミュニティメールの受信メールアドレスリスト(携帯)
 265 */
 266function db_common_receive_ktai_address_list4c_commu_id($c_commu_id)
 267{
 268    $sql = 'SELECT c_member_id FROM c_commu_member' .
 269            ' WHERE c_commu_id = ? AND is_receive_mail = 1';
 270    $params = array(intval($c_commu_id));
 271    $list = db_get_col($sql, $params);
 272
 273    $ktai_list = array();
 274    foreach ($list as $c_member_id) {
 275        $sec = db_member_c_member_secure4c_member_id($c_member_id);
 276        if ($sec['ktai_address']) {
 277            $ktai_list[$c_member_id] = $sec['ktai_address'];
 278        }
 279    }
 280    return $ktai_list;
 281}
 282
 283/**
 284 * コミュニティメールの受信メールアドレスリスト(PC)
 285 */
 286function db_common_receive_pc_address_list4c_commu_id($c_commu_id)
 287{
 288    $sql = "SELECT m.pc_address" .
 289            " FROM c_member_secure AS m, c_commu_member AS cm" .
 290            " WHERE cm.c_commu_id = ?".
 291            " AND cm.is_receive_mail_pc = 1" .
 292            " AND cm.c_member_id = m.c_member_id" .
 293            " AND m.pc_address <> ''";
 294    $params = array(intval($c_commu_id));
 295    $c_member_list = db_get_col($sql, $params);
 296
 297    return array_map('t_decrypt', $c_member_list);
 298}
 299
 300////
 301
 302/**
 303 * 管理者交代の要請情報をIDから取得
 304 *
 305 * @param  int $c_commu_admin_confirm_id
 306 * @return array
 307 *              c_commu_admin_confirm,
 308 *              c_member_id_admin       : 管理者のメンバーID
 309 */
 310function db_c_commu_admin_confirm4c_commu_admin_confirm_id($c_commu_admin_confirm_id)
 311{
 312    $sql = "SELECT cac.*, c.c_member_id_admin FROM c_commu_admin_confirm AS cac, c_commu AS c";
 313    $sql .= " WHERE cac.c_commu_admin_confirm_id = ?";
 314    $sql .= " AND cac.c_commu_id=c.c_commu_id";
 315    $params = array(intval($c_commu_admin_confirm_id));
 316    return db_get_row($sql, $params);
 317}
 318
 319/**
 320 * 副管理者の要請情報をIDから取得
 321 *
 322 * @param  int $c_commu_sub_admin_confirm_id
 323 * @return array
 324 *              c_commu_sub_admin_confirm,
 325 *              c_member_id_admin       : 管理者のメンバーID
 326 */
 327function db_c_commu_sub_admin_confirm4c_commu_sub_admin_confirm_id($c_commu_sub_admin_confirm_id)
 328{
 329    $sql = "SELECT cac.*, c.c_member_id_admin FROM c_commu_sub_admin_confirm AS cac, c_commu AS c";
 330    $sql .= " WHERE cac.c_commu_sub_admin_confirm_id = ?";
 331    $sql .= " AND cac.c_commu_id=c.c_commu_id";
 332    $params = array(intval($c_commu_sub_admin_confirm_id));
 333    return db_get_row($sql, $params);
 334}
 335
 336// 参加コミュニティリスト
 337function db_commu_c_commu_list4c_member_id($c_member_id, $page, $page_size)
 338{
 339    $sql = "SELECT c_commu.*" .
 340            " ,c_commu_member.is_display_topic_home" .
 341            " FROM c_commu_member , c_commu";
 342    $sql .= " WHERE c_commu_member.c_member_id=?";
 343    $sql .= " AND c_commu.c_commu_id=c_commu_member.c_commu_id";
 344    $sql .= " ORDER BY c_commu.c_commu_id DESC ";
 345    $params = array(intval($c_member_id));
 346    $c_commu_list = db_get_all_page($sql, $page, $page_size, $params);
 347
 348    foreach ($c_commu_list as $key => $value) {
 349        $c_commu_list[$key]['count_members'] =
 350            db_commu_count_c_commu_member_list4c_commu_id($value['c_commu_id']);
 351    }
 352
 353    $pager = array(
 354        "total_num" => db_commu_count_c_commu4c_member_id($c_member_id),
 355        "disp_num"  => count($c_commu_list),
 356        "start_num" => 0,
 357        "end_num"   => 0,
 358        "total_page" => 0,
 359        "prev_page" => 0,
 360        "next_page" => 0,
 361    );
 362
 363    if ($pager['disp_num'] > 0) {
 364        $pager['start_num'] = ($page - 1) * $page_size + 1;
 365        $pager['end_num'] = $pager['start_num'] + $pager['disp_num'] - 1;
 366    }
 367
 368    if ($pager['total_num']) {
 369        $pager['total_page'] = ceil($pager['total_num'] / $page_size);
 370
 371        if ($page < $pager['total_page']) {
 372            $pager['next_page'] = max($page + 1, 1);
 373        }
 374        if ($page > 1) {
 375            $pager['prev_page'] = min($page - 1, $pager['total_page']);
 376        }
 377    }
 378
 379    return array($c_commu_list, $pager);
 380}
 381
 382/**
 383 * コミュニティトピックからコミュニティIDを取得
 384 */
 385function db_commu_c_commu_id4c_commu_topic_id($c_commu_topic_id)
 386{
 387    $sql = "SELECT c_commu_id FROM c_commu_topic WHERE c_commu_topic_id = ?";
 388    $params = array(intval($c_commu_topic_id));
 389    return db_get_one($sql, $params);
 390}
 391
 392// $c_commu_id の community に参加しているメンバーを返す
 393function db_commu_c_member_list4c_commu_id($c_commu_id, $page_size, $page)
 394{
 395    $c_commu = db_commu_c_commu4c_commu_id($c_commu_id);
 396
 397    $sql =  "SELECT c_member.c_member_id,".
 398                "nickname,".
 399                "image_filename ," .
 400                "c_commu_member.r_datetime".
 401            " FROM c_member,".
 402                "c_commu_member".
 403            " WHERE c_commu_id = ?".
 404            " AND c_commu_member.c_member_id = c_member.c_member_id".
 405            " ORDER BY c_commu_member.r_datetime DESC";
 406    $params = array(intval($c_commu_id));
 407    $list = db_get_all_page($sql, $page, $page_size, $params);
 408
 409    $new_list = array();
 410    foreach ($list as $key => $value) {
 411        $new_list[] = $value;
 412    }
 413    $list = $new_list;
 414
 415    $sql = 'SELECT * FROM c_commu_admin_confirm WHERE c_commu_id = ?';
 416    $params = array(intval($c_commu_id));
 417    $c_commu_admin_confirm = db_get_row($sql, $params);
 418
 419    $sql = 'SELECT * FROM c_commu_sub_admin_confirm WHERE c_commu_id = ?';
 420    $c_commu_sub_admin_confirm = db_get_row($sql, $params);
 421
 422    if ($c_commu_admin_confirm) {
 423        foreach ($list as $key => $c_member) {
 424            if ($list[$key]['c_member_id'] == $c_commu_admin_confirm['c_member_id_to']) {
 425                $list[$key]['c_commu_admin_confirm_id'] = $c_commu_admin_confirm['c_commu_admin_confirm_id'];
 426            } else {
 427                $list[$key]['c_commu_admin_confirm_id'] = 0;
 428            }
 429        }
 430    } else {
 431        foreach ($list as $key => $c_member) {
 432            $list[$key]['c_commu_admin_confirm_id'] = -1;
 433        }
 434    }
 435
 436    if ($c_commu_sub_admin_confirm) {
 437        foreach ($list as $key => $c_member) {
 438            if ($list[$key]['c_member_id'] == $c_commu_sub_admin_confirm['c_member_id_to']) {
 439                $list[$key]['c_commu_sub_admin_confirm_id'] = $c_commu_sub_admin_confirm['c_commu_sub_admin_confirm_id'];
 440            } else {
 441                $list[$key]['c_commu_sub_admin_confirm_id'] = 0;
 442            }
 443        }
 444    } else {
 445        foreach ($list as $key => $c_member) {
 446            $list[$key]['c_commu_sub_admin_confirm_id'] = -1;
 447        }
 448    }
 449
 450    foreach ($list as $key => $c_member) {
 451        $list[$key]['is_c_commu_admin'] = db_commu_is_c_commu_admin($c_commu_id, $list[$key]['c_member_id']);
 452        $list[$key]['is_c_commu_sub_admin'] = db_commu_is_c_commu_sub_admin($c_commu_id, $list[$key]['c_member_id']);
 453    }
 454
 455    $total_num = db_commu_count_c_commu_member_list4c_commu_id($c_commu_id);
 456    if ($total_num != 0) {
 457        $total_page_num = ceil($total_num / $page_size);
 458        if ($page >= $total_page_num) {
 459            $next = false;
 460        } else {
 461            $next = true;
 462        }
 463
 464        if ($page <= 1) {
 465            $prev = false;
 466        } else {
 467            $prev = true;
 468        }
 469    }
 470
 471    return array($list, $prev, $next, $total_num);
 472}
 473
 474/**
 475 * コミュニティメンバーのリストを得る
 476 */
 477function db_commu_c_commu_member_list4c_commu_id($c_commu_id ,$limit = 9)
 478{
 479    static $is_recurred = false;  //再帰処理中かどうかの判定フラグ
 480
 481    if (!$is_recurred) {  //function cacheのために再帰処理を行う
 482        $is_recurred = true;
 483        $funcargs = func_get_args();
 484        $result = pne_cache_recursive_call(OPENPNE_FUNCTION_CACHE_LIFETIME_LONG, __FUNCTION__, $funcargs);
 485        $is_recurred = false;
 486        return $result;
 487    }
 488
 489    $sql = 'SELECT c_member.* FROM c_member, c_commu_member' .
 490            ' WHERE c_member.c_member_id = c_commu_member.c_member_id' .
 491            ' AND c_commu_id = ?' . db_order_by_rand();
 492    $params = array(intval($c_commu_id));
 493    $lst = db_get_all_limit($sql, 0, $limit, $params);
 494
 495    foreach ($lst as $key => $value) {
 496        $lst[$key]['friend_count'] = db_friend_count_friends($value['c_member_id']);
 497    }
 498    return $lst;
 499}
 500
 501function db_commu_new_topic_comment4c_commu_id($c_commu_id, $limit, $event_flag = 0)
 502{
 503    static $is_recurred = false;  //再帰処理中かどうかの判定フラグ
 504
 505    if (!$is_recurred) {  //function cacheのために再帰処理を行う
 506        $is_recurred = true;
 507        $funcargs = func_get_args();
 508        $result = pne_cache_recursive_call(OPENPNE_FUNCTION_CACHE_LIFETIME_FAST, __FUNCTION__, $funcargs);
 509        $is_recurred = false;
 510        return $result;
 511    }
 512
 513    $sql = "SELECT c_commu_topic_id , name, u_datetime as r_datetime , c_commu_id " .
 514            " FROM c_commu_topic" .
 515            " WHERE event_flag = ? AND c_commu_id = ?".
 516            " ORDER BY r_datetime DESC";
 517    $params = array((bool)$event_flag, intval($c_commu_id));
 518    $list = db_get_all_limit($sql, 0, $limit, $params);
 519
 520    foreach ($list as $key => $value) {
 521        $list[$key]['count_comments'] = db_commu_get_max_c_commu_topic_comment_number4c_topic_id($value['c_commu_topic_id']);
 522        $start_comment = db_commu_get_start_c_topic_comment($value['c_commu_topic_id']);
 523        $list[$key]['image_filename1'] = $start_comment['image_filename1'];
 524        $list[$key]['image_filename2'] = $start_comment['image_filename2'];
 525        $list[$key]['image_filename3'] = $start_comment['image_filename3'];
 526    }
 527    return $list;
 528}
 529
 530/**
 531 * コミュニティに招待するMyフレンドのリストを得る
 532 * コミュニティに参加していないMyフレンドを全員表示
 533 *
 534 * @param   int $c_member_id
 535 * @param   int $c_commu_id
 536 */
 537function db_commu_invite_list4c_member_id4c_commu_id($c_member_id, $c_commu_id)
 538{
 539    //友達リスト
 540    $friend_list = db_friend_c_member_id_list($c_member_id);
 541
 542    //参加者リスト
 543    $sql = 'SELECT c_member_id FROM c_commu_member WHERE c_commu_id = ?';
 544    $params = array(intval($c_commu_id));
 545    $member_list = db_get_col($sql, $params);
 546
 547    //友達リストから参加者リストを引く
 548    $result = array_diff($friend_list, $member_list);
 549
 550    if (empty($result)) {
 551        return array();
 552    } else {
 553        $result = implode(",", $result);
 554
 555        $sql = 'SELECT c_member_id, nickname '
 556            . ' FROM c_member'
 557            . ' WHERE c_member_id'
 558            . ' IN ( '. $result. ') ';
 559
 560        return db_get_all($sql);
 561    }
 562}
 563
 564function db_commu_c_members4c_commu_id($c_commu_id, $page_size, $page)
 565{
 566    $sql = 'SELECT c_member_id FROM c_commu_member WHERE c_commu_id = ? ORDER BY r_datetime DESC';
 567    $params = array(intval($c_commu_id));
 568    $id_list = db_get_all_page($sql, $page, $page_size, $params);
 569
 570    $list = array();
 571    foreach ($id_list as $key => $value) {
 572        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id']);
 573        $c_member['friend_count'] = db_friend_count_friends($value['c_member_id']);
 574        $list[] = $c_member;
 575    }
 576
 577    $sql = 'SELECT COUNT(*) FROM c_commu_member WHERE c_commu_id = ?';
 578    $total_num = db_get_one($sql, $params);
 579
 580    if ($total_num != 0) {
 581        $total_page_num = ceil($total_num / $page_size);
 582        if ($page >= $total_page_num) {
 583            $next = false;
 584        } else {
 585            $next = true;
 586        }
 587
 588        if ($page <= 1) {
 589            $prev = false;
 590        } else {
 591            $prev = true;
 592        }
 593    }
 594
 595    $start_num = ($page - 1) * $page_size + 1 ;
 596    $end_num   = ($page - 1) * $page_size + $page_size > $total_num ? $total_num : ($page - 1) * $page_size + $page_size ;
 597
 598    return array($list , $prev , $next, $total_num, $start_num, $end_num);
 599}
 600
 601function db_commu_c_commu_list4c_member_id_2($c_member_id, $limit = 9)
 602{
 603    static $is_recurred = false;  //再帰処理中かどうかの判定フラグ
 604
 605    if (!$is_recurred) {  //function cacheのために再帰処理を行う
 606        $is_recurred = true;
 607        $funcargs = func_get_args();
 608        $result = pne_cache_recursive_call(OPENPNE_FUNCTION_CACHE_LIFETIME_LONG, __FUNCTION__, $funcargs);
 609        $is_recurred = false;
 610        return $result;
 611    }
 612
 613    $sql = "SELECT c_commu.c_commu_id, c_commu.image_filename, c_commu.name, c_commu.c_member_id_admin" .
 614        " FROM c_commu ,c_commu_member " .
 615        " WHERE c_commu_member.c_member_id = ?".
 616        " AND c_commu.c_commu_id =  c_commu_member.c_commu_id" .
 617        db_order_by_rand();
 618    $params = array(intval($c_member_id));
 619    $lst = db_get_all_limit($sql, 0, $limit, $params);
 620
 621    foreach ($lst as $key => $value) {
 622        $lst[$key]['count_commu_members'] = db_commu_count_c_commu_member_list4c_commu_id($value['c_commu_id']);
 623    }
 624    return $lst;
 625}
 626
 627/**
 628 * あなたに(の)管理コミュニティに参加を希望しているメンバー
 629 * 
 630 * @param   int $c_member_id    : 要請されている方(あなた=管理者)
 631 * @return  array_of_array
 632 *              c_commu_member_confirm.*
 633 *              c_commu_name    : コミュニティの名前
 634 *              nickname        : 要請している人の名前
 635 *              image_filename  : 要請している人の画像
 636 * @see     h_confirm_list.php
 637 */
 638function db_commu_anatani_c_commu_member_confirm_list4c_member_id($c_member_id)
 639{
 640    $sql = "SELECT cmc.*, c.name AS c_commu_name";
 641    $sql .= " FROM c_commu_member_confirm AS cmc, c_commu AS c";
 642    $sql .= " WHERE (c.c_member_id_admin = ? OR c.c_member_id_sub_admin = ?) AND cmc.c_commu_id=c.c_commu_id";
 643    $params = array(intval($c_member_id), intval($c_member_id));
 644    $c_commu_member_confirm_list = db_get_all($sql, $params);
 645
 646    foreach ($c_commu_member_confirm_list as $key => $value) {
 647        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id']);
 648        $c_commu_member_confirm_list[$key]['nickname'] = $c_member['nickname'];
 649        $c_commu_member_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 650    }
 651    return $c_commu_member_confirm_list;
 652}
 653/**
 654 * あなたがコミュニティ参加要請しているコミュニティ
 655 * 
 656 * @param   int $c_member_id    : 要請している方(あなた)
 657 * @return  array_of_array
 658 *              c_commu_member_confirm.*,
 659 *              c_commu_name        : コミュニティの名前
 660 *              c_member_id_admin   : 管理者のメンバーID
 661 *              nickname            : 管理者の名前
 662 *              image_filename      : 管理者の画像
 663 * @see     h_confirm_list.php
 664 */
 665function db_commu_anataga_c_commu_member_confirm_list4c_member_id($c_member_id)
 666{
 667    $sql = "SELECT cmc.*, c.name AS c_commu_name, c.c_member_id_admin";
 668    $sql .= " FROM c_commu_member_confirm AS cmc, c_commu AS c";
 669    $sql .= " WHERE cmc.c_member_id = ? AND cmc.c_commu_id=c.c_commu_id";
 670    $params = array(intval($c_member_id));
 671    $c_commu_member_confirm_list = db_get_all($sql, $params);
 672
 673    foreach ($c_commu_member_confirm_list as $key => $value) {
 674        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_admin']);
 675        $c_commu_member_confirm_list[$key]['nickname'] = $c_member['nickname'];
 676        $c_commu_member_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 677    }
 678    return $c_commu_member_confirm_list;
 679}
 680
 681/**
 682 * あなたにコミュニティ管理者交代を希望しているメンバー
 683 * 
 684 * @param   int $c_member_id_to : 要請されている方(あなた)
 685 * @return  array_of_array
 686 *              c_commu_admin_confirm.*
 687 *              c_commu_name        : コミュニティ名
 688 *              c_member_id_admin   : 要請している人(=現管理者)のID
 689 *              nickname            : 要請している人の名前
 690 *              image_filename      : 要請している人の画像
 691 * @see     h_confirm_list.php
 692 */
 693function db_commu_anatani_c_commu_admin_confirm_list4c_member_id($c_member_id_to)
 694{
 695    $sql = "SELECT cac.*, c.name AS c_commu_name, c.c_member_id_admin";
 696    $sql .= " FROM c_commu_admin_confirm AS cac, c_commu AS c";
 697    $sql .= " WHERE cac.c_member_id_to = ? AND cac.c_commu_id=c.c_commu_id";
 698    $params = array(intval($c_member_id_to));
 699    $c_commu_admin_confirm_list = db_get_all($sql, $params);
 700
 701    foreach ($c_commu_admin_confirm_list as $key => $value) {
 702        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_admin']);
 703        $c_commu_admin_confirm_list[$key]['nickname'] = $c_member['nickname'];
 704        $c_commu_admin_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 705    }
 706    return $c_commu_admin_confirm_list;
 707}
 708
 709/**
 710 * あなたがコミュニティ管理者交代を要請しているメンバー
 711 * 
 712 * @param   int $c_member_id_admin  : 要請している方(あなた)
 713 * @return  array_of_array
 714 *              c_commu_admin_confirm.*
 715 *              nickname            : 要請されている人の名前
 716 *              image_filename      : 要請されている人の画像
 717 * @see     h_confirm_list.php
 718 */
 719function db_commu_anataga_c_commu_admin_confirm_list4c_member_id($c_member_id_admin)
 720{
 721    $sql = "SELECT cac.*, c.name AS c_commu_name, c.c_member_id_admin";
 722    $sql .= " FROM c_commu_admin_confirm AS cac, c_commu AS c";
 723    $sql .= " WHERE c.c_member_id_admin = ? AND cac.c_commu_id=c.c_commu_id";
 724    $params = array(intval($c_member_id_admin));
 725    $c_commu_admin_confirm_list = db_get_all($sql, $params);
 726
 727    foreach ($c_commu_admin_confirm_list as $key => $value) {
 728        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_to']);
 729        $c_commu_admin_confirm_list[$key]['nickname'] = $c_member['nickname'];
 730        $c_commu_admin_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 731    }
 732    return $c_commu_admin_confirm_list;
 733}
 734
 735
 736/**
 737 * あなたにコミュニティ副管理者を希望しているメンバー
 738 * 
 739 * @param   int $c_member_id_to : 要請されている方(あなた)
 740 * @return  array_of_array
 741 *              c_commu_sub_admin_confirm.*
 742 *              c_commu_name        : コミュニティ名
 743 *              c_member_id_sub_admin   : 要請している人(=現管理者)のID
 744 *              nickname            : 要請している人の名前
 745 *              image_filename      : 要請している人の画像
 746 * @see     h_confirm_list.php
 747 */
 748function db_commu_anatani_c_commu_sub_admin_confirm_list4c_member_id($c_member_id_to)
 749{
 750    $sql = "SELECT cac.*, c.name AS c_commu_name, c.c_member_id_admin";
 751    $sql .= " FROM c_commu_sub_admin_confirm AS cac, c_commu AS c";
 752    $sql .= " WHERE cac.c_member_id_to = ? AND cac.c_commu_id=c.c_commu_id";
 753    $params = array(intval($c_member_id_to));
 754    $c_commu_sub_admin_confirm_list = db_get_all($sql, $params);
 755
 756    foreach ($c_commu_sub_admin_confirm_list as $key => $value) {
 757        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_admin']);
 758        $c_commu_sub_admin_confirm_list[$key]['nickname'] = $c_member['nickname'];
 759        $c_commu_sub_admin_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 760    }
 761    return $c_commu_sub_admin_confirm_list;
 762}
 763
 764/**
 765 * あなたがコミュニティ副管理者を要請しているメンバー
 766 * 
 767 * @param   int $c_member_id_admin  : 要請している方(あなた)
 768 * @return  array_of_array
 769 *              c_commu_sub_admin_confirm.*
 770 *              nickname            : 要請されている人の名前
 771 *              image_filename      : 要請されている人の画像
 772 * @see     h_confirm_list.php
 773 */
 774function db_commu_anataga_c_commu_sub_admin_confirm_list4c_member_id($c_member_id_admin)
 775{
 776    $sql = "SELECT cac.*, c.name AS c_commu_name, c.c_member_id_admin";
 777    $sql .= " FROM c_commu_sub_admin_confirm AS cac, c_commu AS c";
 778    $sql .= " WHERE c.c_member_id_admin = ? AND cac.c_commu_id=c.c_commu_id";
 779    $params = array(intval($c_member_id_admin));
 780    $c_commu_sub_admin_confirm_list = db_get_all($sql, $params);
 781
 782    foreach ($c_commu_sub_admin_confirm_list as $key => $value) {
 783        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_to']);
 784        $c_commu_sub_admin_confirm_list[$key]['nickname'] = $c_member['nickname'];
 785        $c_commu_sub_admin_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 786    }
 787    return $c_commu_sub_admin_confirm_list;
 788}
 789
 790/**
 791 * あなたに(の)管理コミュニティに参加を希望しているメンバー数を取得
 792 *
 793 * @param int $c_member_id
 794 * @return int 希望しているメンバー数
 795 */
 796function db_commu_count_c_anatani_c_commu_member_confirm($c_member_id)
 797{
 798    $sql = "SELECT COUNT(*) FROM c_commu_member_confirm AS cmc, c_commu AS c";
 799    $sql .= " WHERE (c.c_member_id_admin = ? OR c.c_member_id_sub_admin = ?) AND cmc.c_commu_id=c.c_commu_id";
 800    $params = array(intval($c_member_id), intval($c_member_id));
 801    return db_get_one($sql, $params);
 802}
 803
 804/**
 805 * あなたに(の)管理コミュニティに参加を希望しているメンバー(携帯用にpagerを追加)
 806 * 
 807 * @param   int $c_member_id    : 要請されている方(あなた=管理者)
 808 * @return  array_of_array
 809 *              c_commu_member_confirm.*
 810 *              c_commu_name    : コミュニティの名前
 811 *              nickname        : 要請している人の名前
 812 *              image_filename  : 要請している人の画像
 813 * @see     h_confirm_list.php
 814 */
 815function db_commu_ktai_anatani_c_commu_member_confirm_list4c_member_id($c_member_id, $page_size, $page)
 816{
 817    $sql = "SELECT cmc.*, c.name AS c_commu_name";
 818    $sql .= " FROM c_commu_member_confirm AS cmc, c_commu AS c";
 819    $sql .= " WHERE (c.c_member_id_admin = ? OR c.c_member_id_sub_admin = ?) AND cmc.c_commu_id=c.c_commu_id";
 820    $sql .= " ORDER BY cmc.r_datetime ASC";
 821    $params = array(intval($c_member_id), intval($c_member_id));
 822    $c_commu_member_confirm_list = db_get_all_page($sql, $page, $page_size, $params);
 823
 824    foreach ($c_commu_member_confirm_list as $key => $value) {
 825        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id']);
 826        $c_commu_member_confirm_list[$key]['nickname'] = $c_member['nickname'];
 827        $c_commu_member_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 828    }
 829
 830    $total_num = db_commu_count_c_anatani_c_commu_member_confirm($c_member_id);
 831
 832    if ($total_num != 0) {
 833        $total_page_num = ceil($total_num / $page_size);
 834        if ($page >= $total_page_num) {
 835            $next = false;
 836        } else {
 837            $next = true;
 838        }
 839
 840        if ($page <= 1) {
 841            $prev = false;
 842        } else {
 843            $prev = true;
 844        }
 845    }
 846    return array($c_commu_member_confirm_list, $prev, $next, $total_num);
 847}
 848
 849/**
 850 * あなたが管理コミュニティに参加希望している数を取得
 851 *
 852 * @param int $c_member_id
 853 * @return int 希望している数
 854 */
 855function db_commu_count_c_anataga_c_commu_member_confirm($c_member_id)
 856{
 857    $sql = "SELECT COUNT(*) FROM c_commu_member_confirm AS cmc, c_commu AS c";
 858    $sql .= " WHERE cmc.c_member_id = ? AND cmc.c_commu_id=c.c_commu_id";
 859    $params = array(intval($c_member_id));
 860    return db_get_one($sql, $params);
 861}
 862
 863/**
 864 * あなたがコミュニティ参加要請しているコミュニティ(携帯用にpagerを追加)
 865 * 
 866 * @param   int $c_member_id    : 要請している方(あなた)
 867 * @return  array_of_array
 868 *              c_commu_member_confirm.*,
 869 *              c_commu_name        : コミュニティの名前
 870 *              c_member_id_admin   : 管理者のメンバーID
 871 *              nickname            : 管理者の名前
 872 *              image_filename      : 管理者の画像
 873 * @see     h_confirm_list.php
 874 */
 875function db_commu_ktai_anataga_c_commu_member_confirm_list4c_member_id($c_member_id, $page_size, $page)
 876{
 877    $sql = "SELECT cmc.*, c.name AS c_commu_name, c.c_member_id_admin";
 878    $sql .= " FROM c_commu_member_confirm AS cmc, c_commu AS c";
 879    $sql .= " WHERE cmc.c_member_id = ? AND cmc.c_commu_id=c.c_commu_id";
 880    $sql .= " ORDER BY cmc.r_datetime ASC";
 881    $params = array(intval($c_member_id));
 882    $c_commu_member_confirm_list = db_get_all_page($sql, $page, $page_size, $params);
 883
 884    foreach ($c_commu_member_confirm_list as $key => $value) {
 885        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_admin']);
 886        $c_commu_member_confirm_list[$key]['nickname'] = $c_member['nickname'];
 887        $c_commu_member_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 888    }
 889
 890    $total_num = db_commu_count_c_anataga_c_commu_member_confirm($c_member_id);
 891
 892    if ($total_num != 0) {
 893        $total_page_num = ceil($total_num / $page_size);
 894        if ($page >= $total_page_num) {
 895            $next = false;
 896        } else {
 897            $next = true;
 898        }
 899
 900        if ($page <= 1) {
 901            $prev = false;
 902        } else {
 903            $prev = true;
 904        }
 905    }
 906    return array($c_commu_member_confirm_list, $prev, $next, $total_num);
 907}
 908
 909/**
 910 * あなたにコミュニティ管理者交代を希望している数を取得
 911 *
 912 * @param int $c_member_id
 913 * @return int 希望している数
 914 */
 915function db_commu_count_c_anatani_c_commu_admin_confirm($c_member_id)
 916{
 917    $sql = "SELECT COUNT(*) FROM c_commu_admin_confirm AS cac, c_commu AS c";
 918    $sql .= " WHERE cac.c_member_id_to = ? AND cac.c_commu_id=c.c_commu_id";
 919    $params = array(intval($c_member_id));
 920    return db_get_one($sql, $params);
 921}
 922
 923/**
 924 * あなたにコミュニティ管理者交代を希望しているメンバー(携帯用にpagerを追加)
 925 * 
 926 * @param   int $c_member_id_to : 要請されている方(あなた)
 927 * @return  array_of_array
 928 *              c_commu_admin_confirm.*
 929 *              c_commu_name        : コミュニティ名
 930 *              c_member_id_admin   : 要請している人(=現管理者)のID
 931 *              nickname            : 要請している人の名前
 932 *              image_filename      : 要請している人の画像
 933 * @see     h_confirm_list.php
 934 */
 935function db_commu_ktai_anatani_c_commu_admin_confirm_list4c_member_id($c_member_id_to, $page_size, $page)
 936{
 937    $sql = "SELECT cac.*, c.name AS c_commu_name, c.c_member_id_admin";
 938    $sql .= " FROM c_commu_admin_confirm AS cac, c_commu AS c";
 939    $sql .= " WHERE cac.c_member_id_to = ? AND cac.c_commu_id=c.c_commu_id";
 940    $sql .= " ORDER BY cac.r_datetime ASC";
 941    $params = array(intval($c_member_id_to));
 942    $c_commu_admin_confirm_list = db_get_all_page($sql, $page, $page_size, $params);
 943
 944    foreach ($c_commu_admin_confirm_list as $key => $value) {
 945        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_admin']);
 946        $c_commu_admin_confirm_list[$key]['nickname'] = $c_member['nickname'];
 947        $c_commu_admin_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
 948    }
 949    $total_num = db_commu_count_c_anatani_c_commu_admin_confirm($c_member_id_to);
 950
 951    if ($total_num != 0) {
 952        $total_page_num = ceil($total_num / $page_size);
 953        if ($page >= $total_page_num) {
 954            $next = false;
 955        } else {
 956            $next = true;
 957        }
 958
 959        if ($page <= 1) {
 960            $prev = false;
 961        } else {
 962            $prev = true;
 963        }
 964    }
 965    return array($c_commu_admin_confirm_list, $prev, $next, $total_num);
 966}
 967
 968/**
 969 * あなたが管理しているコミュニティ管理者交代を要請している数を取得
 970 *
 971 * @param int $c_member_id
 972 * @return int 要請している数
 973 */
 974function db_commu_count_c_anataga_c_commu_admin_confirm($c_member_id)
 975{
 976    $sql = "SELECT COUNT(*) FROM c_commu_admin_confirm AS cac, c_commu AS c";
 977    $sql .= " WHERE c.c_member_id_admin = ? AND cac.c_commu_id=c.c_commu_id";
 978    $params = array(intval($c_member_id));
 979    return db_get_one($sql, $params);
 980}
 981
 982/**
 983 * あなたが管理しているコミュニティ管理者交代を要請しているメンバー(携帯用にpagerを追加)
 984 * 
 985 * @param   int $c_member_id_admin  : 要請している方(あなた)
 986 * @return  array_of_array
 987 *              c_commu_admin_confirm.*
 988 *              nickname            : 要請されている人の名前
 989 *              image_filename      : 要請されている人の画像
 990 * @see     h_confirm_list.php
 991 */
 992function db_commu_ktai_anataga_c_commu_admin_confirm_list4c_member_id($c_member_id_admin, $page_size, $page)
 993{
 994    $sql = "SELECT cac.*, c.name AS c_commu_name, c.c_member_id_admin";
 995    $sql .= " FROM c_commu_admin_confirm AS cac, c_commu AS c";
 996    $sql .= " WHERE c.c_member_id_admin = ? AND cac.c_commu_id=c.c_commu_id";
 997    $sql .= " ORDER BY cac.r_datetime ASC";
 998    $params = array(intval($c_member_id_admin));
 999    $c_commu_admin_confirm_list = db_get_all_page($sql, $page, $page_size, $params);
1000
1001    foreach ($c_commu_admin_confirm_list as $key => $value) {
1002        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_to']);
1003        $c_commu_admin_confirm_list[$key]['nickname'] = $c_member['nickname'];
1004        $c_commu_admin_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
1005    }
1006
1007    $total_num = db_commu_count_c_anataga_c_commu_admin_confirm($c_member_id_admin);
1008
1009    if ($total_num != 0) {
1010        $total_page_num = ceil($total_num / $page_size);
1011        if ($page >= $total_page_num) {
1012            $next = false;
1013        } else {
1014            $next = true;
1015        }
1016
1017        if ($page <= 1) {
1018            $prev = false;
1019        } else {
1020            $prev = true;
1021        }
1022    }
1023    return array($c_commu_admin_confirm_list, $prev, $next, $total_num);
1024}
1025
1026/**
1027 * あなたに管理コミュニティ副管理者交代を希望している数を取得
1028 *
1029 * @param int $c_member_id
1030 * @return int 希望している数
1031 */
1032function db_commu_count_c_anatani_c_commu_sub_admin_confirm($c_member_id)
1033{
1034    $sql = "SELECT COUNT(*) FROM c_commu_sub_admin_confirm AS cac, c_commu AS c";
1035    $sql .= " WHERE cac.c_member_id_to = ? AND cac.c_commu_id=c.c_commu_id";
1036    $params = array(intval($c_member_id));
1037    return db_get_one($sql, $params);
1038}
1039
1040/**
1041 * あなたにコミュニティ副管理者を希望しているメンバー(携帯用にpagerを追加)
1042 * 
1043 * @param   int $c_member_id_to : 要請されている方(あなた)
1044 * @return  array_of_array
1045 *              c_commu_sub_admin_confirm.*
1046 *              c_commu_name        : コミュニティ名
1047 *              c_member_id_sub_admin   : 要請している人(=現管理者)のID
1048 *              nickname            : 要請している人の名前
1049 *              image_filename      : 要請している人の画像
1050 * @see     h_confirm_list.php
1051 */
1052function db_commu_ktai_anatani_c_commu_sub_admin_confirm_list4c_member_id($c_member_id_to, $page_size, $page)
1053{
1054    $sql = "SELECT cac.*, c.name AS c_commu_name, c.c_member_id_admin";
1055    $sql .= " FROM c_commu_sub_admin_confirm AS cac, c_commu AS c";
1056    $sql .= " WHERE cac.c_member_id_to = ? AND cac.c_commu_id=c.c_commu_id";
1057    $sql .= " ORDER BY cac.r_datetime ASC";
1058    $params = array(intval($c_member_id_to));
1059    $c_commu_sub_admin_confirm_list = db_get_all_page($sql, $page, $page_size, $params);
1060
1061    foreach ($c_commu_sub_admin_confirm_list as $key => $value) {
1062        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_admin']);
1063        $c_commu_sub_admin_confirm_list[$key]['nickname'] = $c_member['nickname'];
1064        $c_commu_sub_admin_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
1065    }
1066    $total_num = db_commu_count_c_anatani_c_commu_sub_admin_confirm($c_member_id_to);
1067
1068    if ($total_num != 0) {
1069        $total_page_num = ceil($total_num / $page_size);
1070        if ($page >= $total_page_num) {
1071            $next = false;
1072        } else {
1073            $next = true;
1074        }
1075
1076        if ($page <= 1) {
1077            $prev = false;
1078        } else {
1079            $prev = true;
1080        }
1081    }
1082    return array($c_commu_sub_admin_confirm_list, $prev, $next, $total_num);
1083}
1084
1085/**
1086 * あなたが管理しているコミュニティ副管理者交代を要請している数を取得
1087 *
1088 * @param int $c_member_id
1089 * @return int 要請している数
1090 */
1091function db_commu_count_c_anataga_c_commu_sub_admin_confirm($c_member_id)
1092{
1093    $sql = "SELECT COUNT(*) FROM c_commu_sub_admin_confirm AS cac, c_commu AS c";
1094    $sql .= " WHERE c.c_member_id_admin = ? AND cac.c_commu_id=c.c_commu_id";
1095    $params = array(intval($c_member_id));
1096    return db_get_one($sql, $params);
1097}
1098
1099/**
1100 * あなたがコミュニティ副管理者を要請しているメンバー(携帯用にpagerを追加)
1101 * 
1102 * @param   int $c_member_id_admin  : 要請している方(あなた)
1103 * @return  array_of_array
1104 *              c_commu_sub_admin_confirm.*
1105 *              nickname            : 要請されている人の名前
1106 *              image_filename      : 要請されている人の画像
1107 * @see     h_confirm_list.php
1108 */
1109function db_commu_ktai_anataga_c_commu_sub_admin_confirm_list4c_member_id($c_member_id_admin, $page_size, $page)
1110{
1111    $sql = "SELECT cac.*, c.name AS c_commu_name, c.c_member_id_admin";
1112    $sql .= " FROM c_commu_sub_admin_confirm AS cac, c_commu AS c";
1113    $sql .= " WHERE c.c_member_id_admin = ? AND cac.c_commu_id=c.c_commu_id";
1114    $sql .= " ORDER BY cac.r_datetime ASC";
1115    $params = array(intval($c_member_id_admin));
1116    $c_commu_sub_admin_confirm_list = db_get_all_page($sql, $page, $page_size, $params);
1117
1118    foreach ($c_commu_sub_admin_confirm_list as $key => $value) {
1119        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id_to']);
1120        $c_commu_sub_admin_confirm_list[$key]['nickname'] = $c_member['nickname'];
1121        $c_commu_sub_admin_confirm_list[$key]['image_filename'] = $c_member['image_filename'];
1122    }
1123
1124    $total_num = db_commu_count_c_anataga_c_commu_sub_admin_confirm($c_member_id_admin);
1125
1126    if ($total_num != 0) {
1127        $total_page_num = ceil($total_num / $page_size);
1128        if ($page >= $total_page_num) {
1129            $next = false;
1130        } else {
1131            $next = true;
1132        }
1133
1134        if ($page <= 1) {
1135            $prev = false;
1136        } else {
1137            $prev = true;
1138        }
1139    }
1140    return array($c_commu_sub_admin_confirm_list, $prev, $next, $total_num);
1141}
1142
1143/**
1144 * 参加コミュニティ新着書き込みリスト取得
1145 */
1146function db_commu_c_commu_topic_comment_list4c_member_id($c_member_id, $limit, $is_display_topic_home = false)
1147{
1148    static $is_recurred = false;  //再帰処理中かどうかの判定フラグ
1149
1150    if (!$is_recurred) {  //function cacheのために再帰処理を行う
1151        $is_recurred = true;
1152        $funcargs = func_get_args();
1153        $result = pne_cache_recursive_call(OPENPNE_FUNCTION_CACHE_LIFETIME_FAST, __FUNCTION__, $funcargs);
1154        $is_recurred = false;
1155        return $result;
1156    }
1157
1158    $sql = 'SELECT c_commu_id FROM c_commu_member WHERE c_member_id = ?';
1159    $c_commu_id_list = db_get_col($sql, array(intval($c_member_id)));
1160    if (!$c_commu_id_list) {
1161        return array();
1162    }
1163    $ids = implode(", ", $c_commu_id_list);
1164
1165    $hint = db_mysql_hint('USE INDEX (r_datetime_c_commu_id)');
1166    $sql = 'SELECT a.c_commu_topic_id, a.c_commu_id, a.u_datetime as r_datetime, a.c_member_id,'.
1167        ' a.name as c_commu_topic_name'.
1168        ' FROM c_commu_topic as a INNER JOIN c_commu_member as b USING(c_commu_id)'.
1169        ' WHERE b.c_member_id = ?';
1170    if ($is_display_topic_home) {
1171        $sql .= ' AND b.is_display_topic_home = 1';
1172    }
1173    $sql .= ' ORDER BY r_datetime DESC';
1174    $params = array(intval($c_member_id));
1175    $c_commu_topic_list = db_get_all_limit($sql, 0, $limit, $params);
1176
1177    foreach ($c_commu_topic_list as $key => $value) {
1178        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id']);
1179        $c_commu_topic_list[$key]['nickname'] = $c_member['nickname'];
1180
1181        $temp = db_commu_get_start_c_topic_comment($value['c_commu_topic_id']);
1182
1183        $sql = 'SELECT name AS c_commu_name FROM c_commu WHERE c_commu_id = ?';
1184        $c_commu_name = db_get_one($sql, $value['c_commu_id']);
1185
1186        //最新の書き込み番号
1187        $number = db_commu_get_max_c_commu_topic_comment_number4c_topic_id($value['c_commu_topic_id']);
1188
1189        $c_commu_topic_list[$key]['number'] = $number;
1190        $c_commu_topic_list[$key]['image_filename1'] = $temp['image_filename1'];
1191        $c_commu_topic_list[$key]['image_filename2'] = $temp['image_filename2'];
1192        $c_commu_topic_list[$key]['image_filename3'] = $temp['image_filename3'];
1193        $c_commu_topic_list[$key]['c_commu_name'] = $c_commu_name;
1194    }
1195
1196    return $c_commu_topic_list;
1197}
1198
1199function db_commu_c_commu_topic_comment_list4c_member_id_2($c_member_id, $limit,$page)
1200{
1201    $sql = 'SELECT c_commu_id FROM c_commu_member WHERE c_member_id = ?';
1202    $c_commu_id_list = db_get_col($sql, array(intval($c_member_id)));
1203    if (!$c_commu_id_list) {
1204        return array();
1205    }
1206    $ids = implode(", ", $c_commu_id_list);
1207
1208    $hint = db_mysql_hint('USE INDEX (r_datetime_c_commu_id)');
1209    $sql = 'SELECT a.c_commu_topic_id, a.c_commu_id, a.u_datetime as r_datetime, a.c_member_id,'.
1210        ' a.name as c_commu_topic_name'.
1211        ' FROM c_commu_topic as a INNER JOIN c_commu_member as b USING(c_commu_id)'.
1212        ' WHERE b.c_member_id = ?'.
1213        ' ORDER BY r_datetime DESC';
1214    $params = array(intval($c_member_id));
1215    $c_commu_topic_list = db_get_all_limit($sql, ($page-1)*$limit, $limit, $params);
1216
1217    foreach ($c_commu_topic_list as $key => $value) {
1218        $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id']);
1219        $c_commu_topic_list[$key]['nickname'] = $c_member['nickname'];
1220
1221        $temp = db_commu_get_start_c_topic_comment($value['c_commu_topic_id']);
1222
1223        $sql = 'SELECT name AS c_commu_name FROM c_commu WHERE c_commu_id = ?';
1224        $c_commu_name = db_get_one($sql, $value['c_commu_id']);
1225
1226        //最新の書き込み番号
1227        $number = db_commu_get_max_c_commu_topic_comment_number4c_topic_id($value['c_commu_topic_id']);
1228
1229        $c_commu_topic_list[$key]['number'] = $number;
1230        $c_commu_topic_list[$key]['image_filename1'] = $temp['image_filename1'];
1231        $c_commu_topic_list[$key]['image_filename2'] = $temp['image_filename2'];
1232        $c_commu_topic_list[$key]['image_filename3'] = $temp['image_filename3'];
1233        $c_commu_topic_list[$key]['c_commu_name'] = $c_commu_name;
1234    }
1235
1236    $sql = "SELECT count(DISTINCT ct.c_commu_topic_id)";
1237    $sql .= " FROM c_commu_member AS cm, c_commu_topic_comment AS cc";
1238    $sql .= ", c_commu AS c, c_commu_topic AS ct";
1239    $sql .= " WHERE cm.c_member_id = ?";
1240    $sql .= " AND cc.c_commu_id=cm.c_commu_id";
1241    $sql .= " AND c.c_commu_id=cm.c_commu_id";
1242    $sql .= " AND ct.c_commu_id=cm.c_commu_id";
1243    $sql .= " AND ct.c_commu_topic_id=cc.c_commu_topic_id";
1244    $params = array(intval($c_member_id));
1245    $total_num = db_get_one($sql, $params);
1246    if ($total_num != 0) {
1247        $total_page_num =  ceil($total_num / $limit);
1248        if ($page >= $total_page_num) {
1249            $next = false;
1250        } else {
1251            $next = true;
1252        }
1253        if ($page <= 1) {
1254            $prev = false;
1255        } else {
1256            $prev = true;
1257        }
1258    }
1259    return array($c_commu_topic_list , $prev , $next,$total_num);
1260}
1261
1262function db_commu_c_topic_list4target_c_commu_id($c_commu_id, $c_member_id, $page = 1, $page_size = 10, $event_flag = 0, $topic_with_event = 0)
1263{
1264    $sql = " SELECT cct.c_commu_topic_id, max(cct.u_datetime) as newest_write_datetime " .
1265            " FROM c_commu_topic as cct, c_commu_topic_comment as cctc " .
1266            " WHERE cct.c_commu_topic_id = cctc.c_commu_topic_id ";
1267
1268    if ($topic_with_event) {
1269        $sql .= " AND cct.event_flag = $event_flag";
1270    }
1271
1272    $sql .= " AND cct.c_commu_id = ?" .
1273            " GROUP BY cct.c_commu_topic_id " .
1274            " ORDER BY newest_write_datetime DESC";
1275    $params = array(intval($c_commu_id));
1276    $lst = db_get_all_page($sql, $page, $page_size, $params);
1277
1278    foreach ($lst as $key => $value) {
1279        $sql = "SELECT cct.c_commu_topic_id, cct.name, cct.u_datetime, cctc.body , cctc.image_filename1, cctc.image_filename2, image_filename3" .
1280               " FROM c_commu_topic as cct, c_commu_topic_comment as cctc" .
1281               " WHERE cct.c_commu_topic_id = cctc.c_commu_topic_id" .
1282               " AND cctc.number = 0" .
1283               " AND cct.c_commu_topic_id = ?";
1284        $params = array(intval($value['c_commu_topic_id']));
1285        $lst[$key] = db_get_row($sql, $params);
1286    }
1287
1288    foreach ($lst as $key => $value) {
1289        $lst[$key]['is_c_event_member'] = db_commu_is_c_event_member($value['c_commu_topic_id'], $c_member_id);
1290        $lst[$key]['is_c_topic_admin'] = db_commu_is_c_topic_admin($value['c_commu_topic_id'], $c_member_id);
1291        $lst[$key]['write_num'] = db_commu_get_max_c_commu_topic_comment_number4c_topic_id($value['c_commu_topic_id']);
1292    }
1293
1294    $sql = 'SELECT COUNT(*) FROM c_commu_topic WHERE c_commu_id = ?';
1295    if ($topic_with_event) {
1296        $sql .= " AND event_flag = $event_flag";
1297    }
1298    $params = array(intval($c_commu_id));
1299    $total_num = db_get_one($sql, $params);
1300
1301    if ($total_num != 0) {
1302        $total_page_num = ceil($total_num / $page_size);
1303        if ($page >= $total_page_num) {
1304            $next = false;
1305        } else {
1306            $next = true;
1307        }
1308        if ($page <= 1) {
1309            $prev = false;
1310        } else {
1311            $prev = true;
1312        }
1313    }
1314    $start_num = ($page - 1) * $page_size + 1 ;
1315    $end_num   = ($page - 1) * $page_size + $page_size > $total_num ? $total_num : ($page - 1) * $page_size + $page_size ;
1316
1317    return array($lst, $prev, $next, $total_num, $start_num, $end_num);
1318}
1319
1320function db_commu_c_topic4c_commu_topic_id($c_commu_topic_id)
1321{
1322    $sql = "SELECT ct.*, ctc.*, c_member.nickname" .
1323        " FROM c_commu_topic AS ct" .
1324            " LEFT JOIN c_member USING (c_member_id)" .
1325            ", c_commu_topic_comment AS ctc" .
1326        " WHERE ct.c_commu_topic_id = ctc.c_commu_topic_id " .
1327            " AND ct.c_commu_topic_id = ?".
1328            " AND ctc.number = 0";
1329    $params = array(intval($c_commu_topic_id));
1330    return db_get_row($sql, $params);
1331}
1332
1333function db_commu_is_topic4c_commu_id($c_commu_id)
1334{
1335    $sql = 'SELECT c_commu_topic_id FROM c_commu_topic WHERE c_commu_id = ?';
1336    $params = array(intval($c_commu_id));
1337    return db_get_one($sql, $params);
1338}
1339
1340/**
1341 * IDからコミュニ��…

Large files files are truncated, but you can click here to view the full file