PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/webapp_biz/modules/biz/page/fh_biz_schedule_view.php

https://github.com/openpne/OpenPNE2
PHP | 124 lines | 87 code | 22 blank | 15 comment | 13 complexity | 824d7e7935cba37ae60b7e876ad37493 MD5 | raw 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
  7class biz_page_fh_biz_schedule_view extends OpenPNE_Action
  8{
  9    function execute($requests)
 10    {
 11        $u = $GLOBALS['AUTH']->uid();
 12
 13        if (!biz_isPermissionSchedule($u, $requests['id'])) {
 14            handle_kengen_error();
 15        }
 16
 17        $form_val['subject'] = $requests['subject'];
 18        $form_val['body'] = $requests['body'];
 19
 20        $sessid = session_id();
 21
 22        if (empty($requests['target_id']) || ($requests['target_id'] == $u)) {
 23            //自分自身
 24            $target_id = $u;
 25            $this->set('is_h', true);  //判別フラグ
 26            $this->set('inc_navi',fetch_inc_navi('h'));
 27        } else {
 28            //他人
 29            $target_id = $requests['target_id'];
 30            $this->set('is_f', true);  //判別フラグ
 31            $this->set('inc_navi',fetch_inc_navi('f',$requests['target_id']));
 32        }
 33
 34        //プロフィール
 35        $target_member = db_member_c_member4c_member_id($u);
 36        $this->set("target_member", $target_member);
 37        $this->set("form_val", $form_val);
 38        $this->set("target_c_member_id", $requests['target_id']);
 39
 40        //カレンダー関係
 41        //カレンダー開始用変数
 42        $year = date("Y");
 43        $month= date("n");
 44        //カレンダー用変数
 45        $date_val=  array(
 46            'year' => $year,
 47            'month' => $month,
 48            'day' => null,
 49        );
 50        $this->set("date_val", $date_val);
 51
 52        //日記のカレンダー
 53        $calendar = db_common_diary_monthly_calendar($year, $month, $u);
 54
 55        $this->set("calendar", $calendar['days']);
 56        $this->set("ym", $calendar['ym']);
 57
 58        $list = biz_getScheduleInfo($requests['id']);
 59
 60        //繰り返しフラグのチェック
 61        $dayofweek = array('日','月','火','水','木','金', '土');
 62
 63        foreach ($dayofweek as $key => $value) {
 64            if ($list['rep_type'] & (1 << $key)) {
 65                $tmp .= $value;
 66            }
 67        }
 68
 69        $list['rep_type_loc'] = $tmp;
 70        $list['writer_name'] = biz_getMemberNickname($list['c_member_id']);
 71        $list['begin_time'] = substr($list['begin_time'], 0, 5);
 72        $list['finish_time'] = substr($list['finish_time'], 0, 5);
 73
 74        $jmembers = biz_getJoinMemberSchedule($requests['id']);
 75        if (array_search($target_member['nickname'], $jmembers)) {
 76            $jmembers[$target_member['c_member_id']] = $target_member['nickname'];
 77        } else {
 78            $list['target_c_member_nickname'] = biz_getMemberNickname($requests['target_id']);
 79        }
 80        $this->set('jmembers', $jmembers);
 81
 82        $this->set('schedule', $list);
 83        $this->set('jmembers', $jmembers);
 84        $this->set('jmembers_enc', serialize($jmembers));
 85
 86        $this->set('schedule_id', $requests['id']);
 87        $this->set('w', $requests['w']);
 88        $this->set('is_h', true);
 89
 90        if ($list['rep_type']) {
 91            //繰り返し予定の場合は開始日と期間をセット
 92            $repeat_begin = biz_getRepeatBegin($requests['id']);
 93            $repeat_finish = biz_getRepeatFinish($requests['id']);
 94            $repeat_term = strtotime($repeat_finish) - strtotime($repeat_begin);
 95
 96            $daycount = ceil($repeat_term / (24 * 60 * 60) / 6);
 97            if ($repeat_finish == $repeat_begin) {
 98                $daycount = 1;
 99            }
100            $this->set('repeat_begin_date', $repeat_begin);
101            $this->set('repeat_term', ceil($daycount));
102        } else{
103            // 繰り返さない予定の場合、日数をセット
104            $term = strtotime($list["finish_date"]) - strtotime($list["begin_date"]);
105
106            $daycount = ceil($term / (24 * 60 * 60)) + 1;
107            $this->set('sc_bn', $daycount);
108        }
109
110        if ($list['rep_type']) {
111            //繰り返し予定の場合はまとめて既読済みに
112            $rep_schedule = biz_getRepeatScheduleID($requests['id']);
113            foreach ($rep_schedule as $value) {
114                biz_readSchedule($u, $value);
115            }
116        } else {
117            biz_readSchedule($u, $requests['id']);
118        }
119
120        return 'success';
121    }
122}
123
124?>