发布测试版 2.5.0
This commit is contained in:
@@ -58,16 +58,16 @@ class CalendarController extends DefaultController
|
||||
$url = url('event/index', ['calendar_id'=>$calendar['id']]);
|
||||
}
|
||||
$sources[] = [
|
||||
'url' => $url,
|
||||
'id' => $calendar['id'],
|
||||
'userid' => $calendar['userid'],
|
||||
'url' => $url,
|
||||
'id' => $calendar['id'],
|
||||
'userid' => $calendar['userid'],
|
||||
'backgroundColor' => $calendar['calendarcolor'],
|
||||
"borderColor" => $calendar['calendarcolor'],
|
||||
"borderColor" => $calendar['calendarcolor'],
|
||||
];
|
||||
}
|
||||
return $this->json([
|
||||
'calendars' => $calendars,
|
||||
'sources' => $sources,
|
||||
'sources' => $sources,
|
||||
], true);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ use Illuminate\Support\Arr;
|
||||
|
||||
class EventController extends DefaultController
|
||||
{
|
||||
public $permission = ['share', 'items'];
|
||||
public $permission = ['data'];
|
||||
|
||||
// 事件列表
|
||||
public function index()
|
||||
@@ -60,8 +60,8 @@ class EventController extends DefaultController
|
||||
return $events;
|
||||
}
|
||||
|
||||
// 客户端显示事件列表
|
||||
public function items()
|
||||
// 客户端获取数据
|
||||
public function data()
|
||||
{
|
||||
$gets = Request::all();
|
||||
$start = strtotime($gets['start']);
|
||||
@@ -89,7 +89,7 @@ class EventController extends DefaultController
|
||||
],
|
||||
];
|
||||
|
||||
$repeat = CalendarObjectService::getEventRepeat($master, '1D', 'Y-n-j');
|
||||
$repeat = CalendarObjectService::getEventRepeat($master, '1D', 'Y-m-d');
|
||||
$items = array_merge($items, $repeat);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class EventController extends DefaultController
|
||||
'name' => $row['displayname'],
|
||||
],
|
||||
];
|
||||
$repeat = CalendarObjectService::getEventRepeat($master, '1D', 'Y-n-j');
|
||||
$repeat = CalendarObjectService::getEventRepeat($master, '1D', 'Y-m-d');
|
||||
$items = array_merge($items, $repeat);
|
||||
}
|
||||
return $items;
|
||||
@@ -148,7 +148,7 @@ class EventController extends DefaultController
|
||||
$vevent->setDateTime('LAST-MODIFIED', 'now', \Sabre\VObject\Property\DateTime::UTC);
|
||||
$vevent->setDateTime('DTSTAMP', 'now', \Sabre\VObject\Property\DateTime::UTC);
|
||||
|
||||
CalendarService::edit($gets['id'], $vcalendar->serialize());
|
||||
CalendarService::edit($gets, $vcalendar);
|
||||
|
||||
$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
|
||||
return $this->json(['lastmodified' => $lastmodified->format('U')], true);
|
||||
@@ -195,7 +195,7 @@ class EventController extends DefaultController
|
||||
$vevent->setDateTime('DTSTAMP', 'now', \Sabre\VObject\Property\DateTime::UTC);
|
||||
|
||||
try {
|
||||
CalendarService::edit($gets['id'], $vcalendar->serialize());
|
||||
CalendarService::edit($gets, $vcalendar);
|
||||
} catch (\Exception $e) {
|
||||
return $this->json($e->getMessage());
|
||||
}
|
||||
@@ -216,18 +216,10 @@ class EventController extends DefaultController
|
||||
$vcalendar = CalendarService::createVCalendarFromRequest($gets);
|
||||
try {
|
||||
$attachment = join(',', array_filter((array)$gets['attachment']));
|
||||
$id = CalendarService::add($gets['calendarid'], $vcalendar->serialize(), $attachment);
|
||||
$id = CalendarService::add($gets, $vcalendar);
|
||||
AttachmentService::publish($gets['attachment']);
|
||||
|
||||
// 写入共享数据
|
||||
ShareService::addItem(array(
|
||||
'source_id' => $id,
|
||||
'source_type' => 'event',
|
||||
'receive_id' => $gets['receive_id'],
|
||||
'receive_name' => $gets['receive_name'],
|
||||
));
|
||||
|
||||
return $this->json(['id'=>$id], true);
|
||||
return $this->json(['id' => $id], true);
|
||||
} catch (\Exception $e) {
|
||||
return $this->json($e->getMessage());
|
||||
}
|
||||
@@ -316,27 +308,9 @@ class EventController extends DefaultController
|
||||
CalendarService::updateVCalendarFromRequest($gets, $vcalendar);
|
||||
try {
|
||||
$attachment = join(',', array_filter((array)$gets['attachment']));
|
||||
CalendarService::edit($gets['id'], $vcalendar->serialize(), $attachment);
|
||||
CalendarService::edit($gets, $vcalendar);
|
||||
AttachmentService::publish($gets['attachment']);
|
||||
|
||||
$start_at = strtotime($gets['from'].' '.$gets['fromtime']);
|
||||
$end_at = strtotime($gets['to'].' '.$gets['totime']);
|
||||
|
||||
$share_data = array(
|
||||
'source_id' => $gets['id'],
|
||||
'source_type' => 'event',
|
||||
'receive_id' => $gets['receive_id'],
|
||||
'receive_name' => $gets['receive_name'],
|
||||
'start_at' => $start_at,
|
||||
'end_at' => $end_at,
|
||||
);
|
||||
|
||||
$share = ShareService::getItem('event', $gets['id']);
|
||||
if (empty($share)) {
|
||||
ShareService::addItem($share_data);
|
||||
} else {
|
||||
ShareService::editItem('event', $gets['id'], $share_data);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->json($e->getMessage());
|
||||
}
|
||||
@@ -352,254 +326,252 @@ class EventController extends DefaultController
|
||||
}
|
||||
|
||||
// 新增表单
|
||||
if (Request::method() == 'GET') {
|
||||
$event = CalendarService::getEvent($gets['id']);
|
||||
$event = CalendarService::getEvent($gets['id']);
|
||||
|
||||
if (empty($event)) {
|
||||
return $this->json('事件数据不正确。');
|
||||
}
|
||||
|
||||
$object = VObject::parse($event['calendardata']);
|
||||
$vevent = $object->VEVENT;
|
||||
$dtstart = $vevent->DTSTART;
|
||||
$dtend = CalendarService::getDTEndFromVEvent($vevent);
|
||||
|
||||
switch ($dtstart->getDateType()) {
|
||||
case \Sabre\VObject\Property\DateTime::UTC:
|
||||
$timezone = new \DateTimeZone(CalendarService::getTimezone());
|
||||
$newDT = $dtstart->getDateTime();
|
||||
$newDT->setTimezone($timezone);
|
||||
$dtstart->setDateTime($newDT);
|
||||
$newDT = $dtend->getDateTime();
|
||||
$newDT->setTimezone($timezone);
|
||||
$dtend->setDateTime($newDT);
|
||||
// no break
|
||||
case \Sabre\VObject\Property\DateTime::LOCALTZ:
|
||||
case \Sabre\VObject\Property\DateTime::LOCAL:
|
||||
$startdate = $dtstart->getDateTime()->format('Y-m-d');
|
||||
$starttime = $dtstart->getDateTime()->format('H:i');
|
||||
$enddate = $dtend->getDateTime()->format('Y-m-d');
|
||||
$endtime = $dtend->getDateTime()->format('H:i');
|
||||
$allday = false;
|
||||
break;
|
||||
case \Sabre\VObject\Property\DateTime::DATE:
|
||||
$startdate = $dtstart->getDateTime()->format('Y-m-d');
|
||||
$starttime = '';
|
||||
$dtend->getDateTime()->modify('-1 day');
|
||||
$enddate = $dtend->getDateTime()->format('Y-m-d');
|
||||
$endtime = '';
|
||||
$allday = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$summary = strtr($vevent->getAsString('SUMMARY'), array('\,' => ',', '\;' => ';'));
|
||||
$location = strtr($vevent->getAsString('LOCATION'), array('\,' => ',', '\;' => ';'));
|
||||
$description = strtr($vevent->getAsString('DESCRIPTION'), array('\,' => ',', '\;' => ';'));
|
||||
$categories = $vevent->getAsString('CATEGORIES');
|
||||
|
||||
if ($vevent->VALARM) {
|
||||
$valarm = $vevent->VALARM->getAsString('TRIGGER');
|
||||
}
|
||||
|
||||
if ($vevent->RRULE) {
|
||||
$rrule = explode(';', $vevent->getAsString('RRULE'));
|
||||
$rrulearr = array();
|
||||
foreach ($rrule as $rule) {
|
||||
list($attr, $val) = explode('=', $rule);
|
||||
$rrulearr[$attr] = $val;
|
||||
}
|
||||
if (!isset($rrulearr['INTERVAL']) || $rrulearr['INTERVAL'] == '') {
|
||||
$rrulearr['INTERVAL'] = 1;
|
||||
}
|
||||
if (array_key_exists('BYDAY', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYDAY'], ',') == 0) {
|
||||
if (strlen($rrulearr['BYDAY']) == 2) {
|
||||
$repeat['weekdays'] = array($rrulearr['BYDAY']);
|
||||
} elseif (strlen($rrulearr['BYDAY']) == 3) {
|
||||
$repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 1);
|
||||
$repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 1, 2));
|
||||
} elseif (strlen($rrulearr['BYDAY']) == 4) {
|
||||
$repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 2);
|
||||
$repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 2, 2));
|
||||
}
|
||||
} else {
|
||||
$byday_days = explode(',', $rrulearr['BYDAY']);
|
||||
foreach ($byday_days as $byday_day) {
|
||||
if (strlen($byday_day) == 2) {
|
||||
$repeat['weekdays'][] = $byday_day;
|
||||
} elseif (strlen($byday_day) == 3) {
|
||||
$repeat['weekofmonth'] = substr($byday_day, 0, 1);
|
||||
$repeat['weekdays'][] = substr($byday_day, 1, 2);
|
||||
} elseif (strlen($byday_day) == 4) {
|
||||
$repeat['weekofmonth'] = substr($byday_day, 0, 2);
|
||||
$repeat['weekdays'][] = substr($byday_day, 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('BYMONTHDAY', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYMONTHDAY'], ',') == 0) {
|
||||
$repeat['bymonthday'][] = $rrulearr['BYMONTHDAY'];
|
||||
} else {
|
||||
$bymonthdays = explode(',', $rrulearr['BYMONTHDAY']);
|
||||
foreach ($bymonthdays as $bymonthday) {
|
||||
$repeat['bymonthday'][] = $bymonthday;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('BYYEARDAY', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYYEARDAY'], ',') == 0) {
|
||||
$repeat['byyearday'][] = $rrulearr['BYYEARDAY'];
|
||||
} else {
|
||||
$byyeardays = explode(',', $rrulearr['BYYEARDAY']);
|
||||
foreach ($byyeardays as $yearday) {
|
||||
$repeat['byyearday'][] = $yearday;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('BYWEEKNO', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYWEEKNO'], ',') == 0) {
|
||||
$repeat['byweekno'][] = (string) $rrulearr['BYWEEKNO'];
|
||||
} else {
|
||||
$byweekno = explode(',', $rrulearr['BYWEEKNO']);
|
||||
foreach ($byweekno as $weekno) {
|
||||
$repeat['byweekno'][] = (string) $weekno;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('BYMONTH', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYMONTH'], ',') == 0) {
|
||||
$repeat['bymonth'][] = $month;
|
||||
} else {
|
||||
$bymonth = explode(',', $rrulearr['BYMONTH']);
|
||||
foreach ($bymonth as $month) {
|
||||
$repeat['bymonth'][] = $month;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch ($rrulearr['FREQ']) {
|
||||
case 'DAILY':
|
||||
$repeat['repeat'] = 'daily';
|
||||
break;
|
||||
case 'WEEKLY':
|
||||
if ($rrulearr['INTERVAL'] % 2 == 0) {
|
||||
$repeat['repeat'] = 'biweekly';
|
||||
$rrulearr['INTERVAL'] = $rrulearr['INTERVAL'] / 2;
|
||||
} elseif ($rrulearr['BYDAY'] == 'MO,TU,WE,TH,FR') {
|
||||
$repeat['repeat'] = 'weekday';
|
||||
} else {
|
||||
$repeat['repeat'] = 'weekly';
|
||||
}
|
||||
break;
|
||||
case 'MONTHLY':
|
||||
$repeat['repeat'] = 'monthly';
|
||||
if (array_key_exists('BYDAY', $rrulearr)) {
|
||||
$repeat['month'] = 'weekday';
|
||||
} else {
|
||||
$repeat['month'] = 'monthday';
|
||||
}
|
||||
break;
|
||||
case 'YEARLY':
|
||||
$repeat['repeat'] = 'yearly';
|
||||
if (array_key_exists('BYMONTH', $rrulearr)) {
|
||||
$repeat['year'] = 'bydaymonth';
|
||||
} elseif (array_key_exists('BYWEEKNO', $rrulearr)) {
|
||||
$repeat['year'] = 'byweekno';
|
||||
} else {
|
||||
$repeat['year'] = 'byyearday';
|
||||
}
|
||||
}
|
||||
$repeat['interval'] = $rrulearr['INTERVAL'];
|
||||
if (array_key_exists('COUNT', $rrulearr)) {
|
||||
$repeat['end'] = 'count';
|
||||
$repeat['count'] = $rrulearr['COUNT'];
|
||||
} elseif (array_key_exists('UNTIL', $rrulearr)) {
|
||||
$repeat['end'] = 'date';
|
||||
$endbydate_year = substr($rrulearr['UNTIL'], 0, 4);
|
||||
$endbydate_month = substr($rrulearr['UNTIL'], 4, 2);
|
||||
$endbydate_day = substr($rrulearr['UNTIL'], 6, 2);
|
||||
$repeat['date'] = $endbydate_year . '-' . $endbydate_month . '-' . $endbydate_day;
|
||||
} else {
|
||||
$repeat['end'] = 'never';
|
||||
}
|
||||
if (array_key_exists('weekdays', $repeat)) {
|
||||
$repeat_weekdays_ = array();
|
||||
foreach ($repeat['weekdays'] as $weekday) {
|
||||
$repeat_weekdays_[] = $weekday;
|
||||
}
|
||||
$repeat['weekdays'] = $repeat_weekdays_;
|
||||
}
|
||||
} else {
|
||||
$repeat['repeat'] = 'doesnotrepeat';
|
||||
}
|
||||
|
||||
$options['calendar_options']= CalendarService::getCalendars(Auth::id(), false);
|
||||
$options['access_class_options'] = CalendarService::getAccessClassOptions();
|
||||
$options['valarm_options'] = CalendarService::getValarmOptions();
|
||||
$options['repeat_options'] = CalendarService::getRepeatOptions();
|
||||
$options['repeat_end_options'] = CalendarService::getEndOptions();
|
||||
$options['repeat_month_options'] = CalendarService::getMonthOptions();
|
||||
$options['repeat_year_options'] = CalendarService::getYearOptions();
|
||||
$options['repeat_weekly_options'] = CalendarService::getWeeklyOptions();
|
||||
$options['repeat_weekofmonth_options'] = CalendarService::getWeekofMonth();
|
||||
$options['repeat_byyearday_options'] = CalendarService::getByYearDayOptions();
|
||||
$options['repeat_bymonth_options'] = CalendarService::getByMonthOptions();
|
||||
$options['repeat_byweekno_options'] = CalendarService::getByWeekNoOptions();
|
||||
$options['repeat_bymonthday_options'] = CalendarService::getByMonthDayOptions();
|
||||
|
||||
$options['id'] = $gets['id'];
|
||||
$options['lastmodified'] = $event['lastmodified'];
|
||||
$options['title'] = $summary;
|
||||
$options['location'] = $location;
|
||||
$options['categories'] = $categories;
|
||||
$options['calendarid'] = $event['calendarid'];
|
||||
$options['allday'] = $allday;
|
||||
$options['valarm'] = $valarm;
|
||||
$options['startdate'] = $startdate;
|
||||
$options['starttime'] = $starttime;
|
||||
$options['enddate'] = $enddate;
|
||||
$options['endtime'] = $endtime;
|
||||
$options['description'] = $description;
|
||||
|
||||
$repeats['repeat'] = $repeat['repeat'];
|
||||
|
||||
if ($repeat['repeat'] != 'doesnotrepeat') {
|
||||
$repeats['repeat_month'] = isset($repeat['month']) ? $repeat['month'] : 'monthday';
|
||||
$repeats['repeat_weekdays'] = isset($repeat['weekdays']) ? $repeat['weekdays'] : array();
|
||||
$repeats['repeat_interval'] = isset($repeat['interval']) ? $repeat['interval'] : '1';
|
||||
$repeats['repeat_end'] = isset($repeat['end']) ? $repeat['end'] : 'never';
|
||||
$repeats['repeat_count'] = isset($repeat['count']) ? $repeat['count'] : '10';
|
||||
$repeats['repeat_weekofmonth'] = $repeat['weekofmonth'];
|
||||
$repeats['repeat_date'] = isset($repeat['date']) ? $repeat['date'] : '';
|
||||
$repeats['repeat_year'] = isset($repeat['year']) ? $repeat['year'] : array();
|
||||
$repeats['repeat_byyearday'] = isset($repeat['byyearday']) ? $repeat['byyearday'] : array();
|
||||
$repeats['repeat_bymonthday'] = isset($repeat['bymonthday']) ? $repeat['bymonthday'] : array();
|
||||
$repeats['repeat_bymonth'] = isset($repeat['bymonth']) ? $repeat['bymonth'] : array();
|
||||
$repeats['repeat_byweekno'] = isset($repeat['byweekno']) ? $repeat['byweekno'] : array();
|
||||
} else {
|
||||
$repeats['repeat_month'] = 'monthday';
|
||||
$repeats['repeat_weekdays'] = array();
|
||||
$repeats['repeat_byyearday'] = array();
|
||||
$repeats['repeat_bymonthday'] = array();
|
||||
$repeats['repeat_bymonth'] = array();
|
||||
$repeats['repeat_byweekno'] = array();
|
||||
$repeats['repeat_interval'] = '1';
|
||||
$repeats['repeat_end'] = 'never';
|
||||
$repeats['repeat_count'] = '10';
|
||||
$repeats['repeat_weekofmonth'] = 'auto';
|
||||
$repeats['repeat_date'] = '';
|
||||
$repeats['repeat_year'] = 'bydate';
|
||||
}
|
||||
|
||||
$attachment = AttachmentService::edit($event['attachment'], 'calendar_object', 'attachment', 'calendar');
|
||||
$share = ShareService::getItem('event', $gets['id']);
|
||||
return $this->render(array(
|
||||
'attachment' => $attachment,
|
||||
'repeats' => $repeats,
|
||||
'options' => $options,
|
||||
'share' => $share,
|
||||
), 'add');
|
||||
if (empty($event)) {
|
||||
return $this->json('事件数据不正确。');
|
||||
}
|
||||
|
||||
$object = VObject::parse($event['calendardata']);
|
||||
$vevent = $object->VEVENT;
|
||||
$dtstart = $vevent->DTSTART;
|
||||
$dtend = CalendarService::getDTEndFromVEvent($vevent);
|
||||
|
||||
switch ($dtstart->getDateType()) {
|
||||
case \Sabre\VObject\Property\DateTime::UTC:
|
||||
$timezone = new \DateTimeZone(CalendarService::getTimezone());
|
||||
$newDT = $dtstart->getDateTime();
|
||||
$newDT->setTimezone($timezone);
|
||||
$dtstart->setDateTime($newDT);
|
||||
$newDT = $dtend->getDateTime();
|
||||
$newDT->setTimezone($timezone);
|
||||
$dtend->setDateTime($newDT);
|
||||
// no break
|
||||
case \Sabre\VObject\Property\DateTime::LOCALTZ:
|
||||
case \Sabre\VObject\Property\DateTime::LOCAL:
|
||||
$startdate = $dtstart->getDateTime()->format('Y-m-d');
|
||||
$starttime = $dtstart->getDateTime()->format('H:i');
|
||||
$enddate = $dtend->getDateTime()->format('Y-m-d');
|
||||
$endtime = $dtend->getDateTime()->format('H:i');
|
||||
$allday = false;
|
||||
break;
|
||||
case \Sabre\VObject\Property\DateTime::DATE:
|
||||
$startdate = $dtstart->getDateTime()->format('Y-m-d');
|
||||
$starttime = '';
|
||||
$dtend->getDateTime()->modify('-1 day');
|
||||
$enddate = $dtend->getDateTime()->format('Y-m-d');
|
||||
$endtime = '';
|
||||
$allday = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$summary = strtr($vevent->getAsString('SUMMARY'), array('\,' => ',', '\;' => ';'));
|
||||
$location = strtr($vevent->getAsString('LOCATION'), array('\,' => ',', '\;' => ';'));
|
||||
$description = strtr($vevent->getAsString('DESCRIPTION'), array('\,' => ',', '\;' => ';'));
|
||||
$categories = $vevent->getAsString('CATEGORIES');
|
||||
|
||||
if ($vevent->VALARM) {
|
||||
$valarm = $vevent->VALARM->getAsString('TRIGGER');
|
||||
}
|
||||
|
||||
if ($vevent->RRULE) {
|
||||
$rrule = explode(';', $vevent->getAsString('RRULE'));
|
||||
$rrulearr = array();
|
||||
foreach ($rrule as $rule) {
|
||||
list($attr, $val) = explode('=', $rule);
|
||||
$rrulearr[$attr] = $val;
|
||||
}
|
||||
if (!isset($rrulearr['INTERVAL']) || $rrulearr['INTERVAL'] == '') {
|
||||
$rrulearr['INTERVAL'] = 1;
|
||||
}
|
||||
if (array_key_exists('BYDAY', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYDAY'], ',') == 0) {
|
||||
if (strlen($rrulearr['BYDAY']) == 2) {
|
||||
$repeat['weekdays'] = array($rrulearr['BYDAY']);
|
||||
} elseif (strlen($rrulearr['BYDAY']) == 3) {
|
||||
$repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 1);
|
||||
$repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 1, 2));
|
||||
} elseif (strlen($rrulearr['BYDAY']) == 4) {
|
||||
$repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 2);
|
||||
$repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 2, 2));
|
||||
}
|
||||
} else {
|
||||
$byday_days = explode(',', $rrulearr['BYDAY']);
|
||||
foreach ($byday_days as $byday_day) {
|
||||
if (strlen($byday_day) == 2) {
|
||||
$repeat['weekdays'][] = $byday_day;
|
||||
} elseif (strlen($byday_day) == 3) {
|
||||
$repeat['weekofmonth'] = substr($byday_day, 0, 1);
|
||||
$repeat['weekdays'][] = substr($byday_day, 1, 2);
|
||||
} elseif (strlen($byday_day) == 4) {
|
||||
$repeat['weekofmonth'] = substr($byday_day, 0, 2);
|
||||
$repeat['weekdays'][] = substr($byday_day, 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('BYMONTHDAY', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYMONTHDAY'], ',') == 0) {
|
||||
$repeat['bymonthday'][] = $rrulearr['BYMONTHDAY'];
|
||||
} else {
|
||||
$bymonthdays = explode(',', $rrulearr['BYMONTHDAY']);
|
||||
foreach ($bymonthdays as $bymonthday) {
|
||||
$repeat['bymonthday'][] = $bymonthday;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('BYYEARDAY', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYYEARDAY'], ',') == 0) {
|
||||
$repeat['byyearday'][] = $rrulearr['BYYEARDAY'];
|
||||
} else {
|
||||
$byyeardays = explode(',', $rrulearr['BYYEARDAY']);
|
||||
foreach ($byyeardays as $yearday) {
|
||||
$repeat['byyearday'][] = $yearday;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('BYWEEKNO', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYWEEKNO'], ',') == 0) {
|
||||
$repeat['byweekno'][] = (string) $rrulearr['BYWEEKNO'];
|
||||
} else {
|
||||
$byweekno = explode(',', $rrulearr['BYWEEKNO']);
|
||||
foreach ($byweekno as $weekno) {
|
||||
$repeat['byweekno'][] = (string) $weekno;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('BYMONTH', $rrulearr)) {
|
||||
if (substr_count($rrulearr['BYMONTH'], ',') == 0) {
|
||||
$repeat['bymonth'][] = $month;
|
||||
} else {
|
||||
$bymonth = explode(',', $rrulearr['BYMONTH']);
|
||||
foreach ($bymonth as $month) {
|
||||
$repeat['bymonth'][] = $month;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch ($rrulearr['FREQ']) {
|
||||
case 'DAILY':
|
||||
$repeat['repeat'] = 'daily';
|
||||
break;
|
||||
case 'WEEKLY':
|
||||
if ($rrulearr['INTERVAL'] % 2 == 0) {
|
||||
$repeat['repeat'] = 'biweekly';
|
||||
$rrulearr['INTERVAL'] = $rrulearr['INTERVAL'] / 2;
|
||||
} elseif ($rrulearr['BYDAY'] == 'MO,TU,WE,TH,FR') {
|
||||
$repeat['repeat'] = 'weekday';
|
||||
} else {
|
||||
$repeat['repeat'] = 'weekly';
|
||||
}
|
||||
break;
|
||||
case 'MONTHLY':
|
||||
$repeat['repeat'] = 'monthly';
|
||||
if (array_key_exists('BYDAY', $rrulearr)) {
|
||||
$repeat['month'] = 'weekday';
|
||||
} else {
|
||||
$repeat['month'] = 'monthday';
|
||||
}
|
||||
break;
|
||||
case 'YEARLY':
|
||||
$repeat['repeat'] = 'yearly';
|
||||
if (array_key_exists('BYMONTH', $rrulearr)) {
|
||||
$repeat['year'] = 'bydaymonth';
|
||||
} elseif (array_key_exists('BYWEEKNO', $rrulearr)) {
|
||||
$repeat['year'] = 'byweekno';
|
||||
} else {
|
||||
$repeat['year'] = 'byyearday';
|
||||
}
|
||||
}
|
||||
$repeat['interval'] = $rrulearr['INTERVAL'];
|
||||
if (array_key_exists('COUNT', $rrulearr)) {
|
||||
$repeat['end'] = 'count';
|
||||
$repeat['count'] = $rrulearr['COUNT'];
|
||||
} elseif (array_key_exists('UNTIL', $rrulearr)) {
|
||||
$repeat['end'] = 'date';
|
||||
$endbydate_year = substr($rrulearr['UNTIL'], 0, 4);
|
||||
$endbydate_month = substr($rrulearr['UNTIL'], 4, 2);
|
||||
$endbydate_day = substr($rrulearr['UNTIL'], 6, 2);
|
||||
$repeat['date'] = $endbydate_year . '-' . $endbydate_month . '-' . $endbydate_day;
|
||||
} else {
|
||||
$repeat['end'] = 'never';
|
||||
}
|
||||
if (array_key_exists('weekdays', $repeat)) {
|
||||
$repeat_weekdays_ = array();
|
||||
foreach ($repeat['weekdays'] as $weekday) {
|
||||
$repeat_weekdays_[] = $weekday;
|
||||
}
|
||||
$repeat['weekdays'] = $repeat_weekdays_;
|
||||
}
|
||||
} else {
|
||||
$repeat['repeat'] = 'doesnotrepeat';
|
||||
}
|
||||
|
||||
$options['calendar_options']= CalendarService::getCalendars(Auth::id(), false);
|
||||
$options['access_class_options'] = CalendarService::getAccessClassOptions();
|
||||
$options['valarm_options'] = CalendarService::getValarmOptions();
|
||||
$options['repeat_options'] = CalendarService::getRepeatOptions();
|
||||
$options['repeat_end_options'] = CalendarService::getEndOptions();
|
||||
$options['repeat_month_options'] = CalendarService::getMonthOptions();
|
||||
$options['repeat_year_options'] = CalendarService::getYearOptions();
|
||||
$options['repeat_weekly_options'] = CalendarService::getWeeklyOptions();
|
||||
$options['repeat_weekofmonth_options'] = CalendarService::getWeekofMonth();
|
||||
$options['repeat_byyearday_options'] = CalendarService::getByYearDayOptions();
|
||||
$options['repeat_bymonth_options'] = CalendarService::getByMonthOptions();
|
||||
$options['repeat_byweekno_options'] = CalendarService::getByWeekNoOptions();
|
||||
$options['repeat_bymonthday_options'] = CalendarService::getByMonthDayOptions();
|
||||
|
||||
$options['id'] = $gets['id'];
|
||||
$options['lastmodified'] = $event['lastmodified'];
|
||||
$options['title'] = $summary;
|
||||
$options['location'] = $location;
|
||||
$options['categories'] = $categories;
|
||||
$options['calendarid'] = $event['calendarid'];
|
||||
$options['allday'] = $allday;
|
||||
$options['valarm'] = $valarm;
|
||||
$options['startdate'] = $startdate;
|
||||
$options['starttime'] = $starttime;
|
||||
$options['enddate'] = $enddate;
|
||||
$options['endtime'] = $endtime;
|
||||
$options['description'] = $description;
|
||||
|
||||
$repeats['repeat'] = $repeat['repeat'];
|
||||
|
||||
if ($repeat['repeat'] != 'doesnotrepeat') {
|
||||
$repeats['repeat_month'] = isset($repeat['month']) ? $repeat['month'] : 'monthday';
|
||||
$repeats['repeat_weekdays'] = isset($repeat['weekdays']) ? $repeat['weekdays'] : array();
|
||||
$repeats['repeat_interval'] = isset($repeat['interval']) ? $repeat['interval'] : '1';
|
||||
$repeats['repeat_end'] = isset($repeat['end']) ? $repeat['end'] : 'never';
|
||||
$repeats['repeat_count'] = isset($repeat['count']) ? $repeat['count'] : '10';
|
||||
$repeats['repeat_weekofmonth'] = $repeat['weekofmonth'];
|
||||
$repeats['repeat_date'] = isset($repeat['date']) ? $repeat['date'] : '';
|
||||
$repeats['repeat_year'] = isset($repeat['year']) ? $repeat['year'] : array();
|
||||
$repeats['repeat_byyearday'] = isset($repeat['byyearday']) ? $repeat['byyearday'] : array();
|
||||
$repeats['repeat_bymonthday'] = isset($repeat['bymonthday']) ? $repeat['bymonthday'] : array();
|
||||
$repeats['repeat_bymonth'] = isset($repeat['bymonth']) ? $repeat['bymonth'] : array();
|
||||
$repeats['repeat_byweekno'] = isset($repeat['byweekno']) ? $repeat['byweekno'] : array();
|
||||
} else {
|
||||
$repeats['repeat_month'] = 'monthday';
|
||||
$repeats['repeat_weekdays'] = array();
|
||||
$repeats['repeat_byyearday'] = array();
|
||||
$repeats['repeat_bymonthday'] = array();
|
||||
$repeats['repeat_bymonth'] = array();
|
||||
$repeats['repeat_byweekno'] = array();
|
||||
$repeats['repeat_interval'] = '1';
|
||||
$repeats['repeat_end'] = 'never';
|
||||
$repeats['repeat_count'] = '10';
|
||||
$repeats['repeat_weekofmonth'] = 'auto';
|
||||
$repeats['repeat_date'] = '';
|
||||
$repeats['repeat_year'] = 'bydate';
|
||||
}
|
||||
|
||||
$attachment = AttachmentService::edit($event['attachment'], 'calendar_object', 'attachment', 'calendar');
|
||||
$share = ShareService::getItem('event', $gets['id']);
|
||||
return $this->render(array(
|
||||
'attachment' => $attachment,
|
||||
'repeats' => $repeats,
|
||||
'options' => $options,
|
||||
'share' => $share,
|
||||
), 'add');
|
||||
}
|
||||
|
||||
public function view()
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php namespace Gdoo\Calendar\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class WidgetController extends DefaultController
|
||||
{
|
||||
public $permission = ['index'];
|
||||
|
||||
// 日程
|
||||
public function index()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\Calendar\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CalendarReminder extends BaseModel
|
||||
{
|
||||
public $table = 'calendar_reminder';
|
||||
}
|
||||
@@ -392,15 +392,15 @@ class CalDAV extends \Sabre\CalDAV\Backend\AbstractBackend
|
||||
{
|
||||
$extraData = $this->getDenormalizedData($calendarData);
|
||||
$data = array(
|
||||
'calendarid' => $calendarId,
|
||||
'calendardata' => $calendarData,
|
||||
'uri' => $objectUri,
|
||||
'etag' => $extraData['etag'],
|
||||
'size' => $extraData['size'],
|
||||
'componenttype' => $extraData['componentType'],
|
||||
'calendarid' => $calendarId,
|
||||
'uri' => $objectUri,
|
||||
'calendardata' => $calendarData,
|
||||
'lastmodified' => time(),
|
||||
'etag' => $extraData['etag'],
|
||||
'size' => $extraData['size'],
|
||||
'componenttype' => $extraData['componentType'],
|
||||
'firstoccurence' => $extraData['firstOccurence'],
|
||||
'lastoccurence' => $extraData['lastOccurence'],
|
||||
'lastmodified' => time(),
|
||||
'lastoccurence' => $extraData['lastOccurence'],
|
||||
);
|
||||
CalendarObject::insert($data);
|
||||
CalendarService::touchCalendar($calendarId);
|
||||
@@ -427,13 +427,13 @@ class CalDAV extends \Sabre\CalDAV\Backend\AbstractBackend
|
||||
{
|
||||
$extraData = $this->getDenormalizedData($calendarData);
|
||||
$update = array(
|
||||
'calendardata' => $calendarData,
|
||||
'etag' => $extraData['etag'],
|
||||
'size' => $extraData['size'],
|
||||
'componenttype' => $extraData['componentType'],
|
||||
'calendardata' => $calendarData,
|
||||
'lastmodified' => time(),
|
||||
'etag' => $extraData['etag'],
|
||||
'size' => $extraData['size'],
|
||||
'componenttype' => $extraData['componentType'],
|
||||
'firstoccurence' => $extraData['firstOccurence'],
|
||||
'lastoccurence' => $extraData['lastOccurence'],
|
||||
'lastmodified' => time(),
|
||||
'lastoccurence' => $extraData['lastOccurence'],
|
||||
);
|
||||
CalendarObject::where('calendarid', $calendarId)->where('uri', $objectUri)->update($update);
|
||||
CalendarService::touchCalendar($calendarId);
|
||||
|
||||
@@ -26,6 +26,8 @@ class CalendarObjectService
|
||||
if ($data['allday']) {
|
||||
foreach ($ranges as $date) {
|
||||
$item['date'] = $date->format($format);
|
||||
$item['_start'] = $start->format($format);
|
||||
$item['_end'] = $end->format($format);
|
||||
$items[] = $item;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,8 @@ use App\Support\VObject;
|
||||
use Gdoo\Index\Services\AttachmentService;
|
||||
use Gdoo\Calendar\Models\Calendar;
|
||||
use Gdoo\Calendar\Models\CalendarObject;
|
||||
use Gdoo\Calendar\Models\CalendarReminder;
|
||||
use Gdoo\Index\Services\ShareService;
|
||||
|
||||
class CalendarService
|
||||
{
|
||||
@@ -94,7 +96,7 @@ class CalendarService
|
||||
{
|
||||
$calendar = self::getCalendar($id, false);
|
||||
if ($calendar['userid'] != Auth::id()) {
|
||||
throw new \Exception('您没有权限编辑此日历。');
|
||||
abort_error('您没有权限编辑此日历。');
|
||||
}
|
||||
|
||||
if (is_null($name)) {
|
||||
@@ -154,7 +156,7 @@ class CalendarService
|
||||
$calendar = self::getCalendar($id, false);
|
||||
|
||||
if ($calendar['userid'] != Auth::id()) {
|
||||
throw new \Exception('您没有权限删除此日历。');
|
||||
abort_error('您没有权限删除此日历。');
|
||||
}
|
||||
$events = CalendarObject::where('calendarid', $id)->get();
|
||||
if (sizeof($events)) {
|
||||
@@ -187,15 +189,6 @@ class CalendarService
|
||||
$start = strtotime($start);
|
||||
$end = strtotime($end);
|
||||
|
||||
/*
|
||||
$model = CalendarObject::where(function ($q) use ($start, $end) {
|
||||
$q->where('rrule', 0);
|
||||
$q->whereBetween('firstoccurence', [$start, $end]);
|
||||
$q->orWhereBetween('lastoccurence', [$start, $end]);
|
||||
})->orWhere(function ($q) use ($start, $end) {
|
||||
$q->where('rrule', 1)->where('firstoccurence', '<=', $end);
|
||||
});
|
||||
*/
|
||||
$model = CalendarObject::whereRaw('(
|
||||
(firstoccurence between '.$start.' and '.$end.' or lastoccurence between '.$start.' and '.$end.')
|
||||
or (rrule = 1 and firstoccurence <= '.$end.')
|
||||
@@ -231,13 +224,13 @@ class CalendarService
|
||||
$allday = ($vcalendar->VEVENT->DTSTART->getDateType() == \Sabre\VObject\Property\DateTime::DATE) ? true : false;
|
||||
|
||||
$output = array(
|
||||
'id' => (int)$row->id,
|
||||
'calendarid' => (int)$row->calendarid,
|
||||
'title' => (isset($vevent->SUMMARY) && $vevent->SUMMARY->value) ? strtr($vevent->SUMMARY->value, array('\,' => ',', '\;' => ';')) : 'unnamed',
|
||||
'description' => (isset($vevent->DESCRIPTION) && $vevent->DESCRIPTION->value) ? strtr($vevent->DESCRIPTION->value, array('\,' => ',', '\;' => ';')) : '',
|
||||
'location' => (isset($vevent->LOCATION) && $vevent->LOCATION->value) ? strtr($vevent->LOCATION->value, array('\,' => ',', '\;' => ';')) : '',
|
||||
'id' => (int)$row->id,
|
||||
'calendarid' => (int)$row->calendarid,
|
||||
'title' => (isset($vevent->SUMMARY) && $vevent->SUMMARY->value) ? strtr($vevent->SUMMARY->value, array('\,' => ',', '\;' => ';')) : 'unnamed',
|
||||
'description' => (isset($vevent->DESCRIPTION) && $vevent->DESCRIPTION->value) ? strtr($vevent->DESCRIPTION->value, array('\,' => ',', '\;' => ';')) : '',
|
||||
'location' => (isset($vevent->LOCATION) && $vevent->LOCATION->value) ? strtr($vevent->LOCATION->value, array('\,' => ',', '\;' => ';')) : '',
|
||||
'lastmodified' => $row->lastmodified,
|
||||
'allDay' => $allday,
|
||||
'allDay' => $allday,
|
||||
);
|
||||
|
||||
if ($vcalendar->VEVENT->RRULE) {
|
||||
@@ -277,31 +270,60 @@ class CalendarService
|
||||
* @param string $attachment
|
||||
* @return integer
|
||||
*/
|
||||
public static function add($id, $calendardata, $attachment = null)
|
||||
public static function add($params, $vcalendar)
|
||||
{
|
||||
$calendar = self::getCalendar($id);
|
||||
$calendarid = $params['calendarid'];
|
||||
$calendar = self::getCalendar($calendarid);
|
||||
|
||||
if ($calendar['userid'] != Auth::id()) {
|
||||
throw new \Exception('您没有权限添加事件到此日历。');
|
||||
abort_error('您没有权限添加事件到此日历。');
|
||||
}
|
||||
|
||||
$calendardata = $vcalendar->serialize();
|
||||
$extraData = self::getDenormalizedData($calendardata);
|
||||
$uri = self::createURI().'.ics';
|
||||
$data = [
|
||||
'calendarid' => $id,
|
||||
'calendarid' => $calendarid,
|
||||
'calendardata' => $calendardata,
|
||||
'attachment' => $attachment,
|
||||
'uri' => $uri,
|
||||
'rrule' => $extraData['rrule'],
|
||||
'etag' => $extraData['etag'],
|
||||
'size' => $extraData['size'],
|
||||
'uri' => $uri,
|
||||
'lastmodified' => time(),
|
||||
'attachment' => $params['attachment'],
|
||||
'componenttype' => $extraData['componentType'],
|
||||
'firstoccurence' => $extraData['firstOccurence'],
|
||||
'lastoccurence' => $extraData['lastOccurence'],
|
||||
'lastmodified' => time(),
|
||||
];
|
||||
$objectId = CalendarObject::insertGetId($data);
|
||||
self::touchCalendar($id);
|
||||
|
||||
// 是重复事件
|
||||
$is_recurring = $vcalendar->VEVENT->RRULE ? 1 : 0;
|
||||
|
||||
// 事件提醒
|
||||
if (isset($vcalendar->VEVENT->VALARM)) {
|
||||
$triggerTime = $vcalendar->VEVENT->VALARM->getEffectiveTriggerTime();
|
||||
$valarm_at = $triggerTime->getTimeStamp();
|
||||
CalendarReminder::insert([
|
||||
'calendar_id' => $calendarid,
|
||||
'object_id' => $objectId,
|
||||
'is_recurring' => $is_recurring,
|
||||
'alarm_at' => $valarm_at,
|
||||
]);
|
||||
}
|
||||
|
||||
// 写入共享数据
|
||||
ShareService::addItem([
|
||||
'source_id' => $objectId,
|
||||
'source_type' => 'event',
|
||||
'is_repeat' => $is_recurring,
|
||||
'receive_id' => $params['receive_id'],
|
||||
'receive_name' => $params['receive_name'],
|
||||
'start_at' => $extraData['firstOccurence'],
|
||||
'end_at' => $extraData['lastOccurence'],
|
||||
]);
|
||||
|
||||
self::touchCalendar($calendarid);
|
||||
return $objectId;
|
||||
}
|
||||
|
||||
@@ -311,32 +333,72 @@ class CalendarService
|
||||
* @param string $data object
|
||||
* @return boolean
|
||||
*/
|
||||
public static function edit($id, $calendardata, $attachment = null)
|
||||
public static function edit($params, $vcalendar)
|
||||
{
|
||||
$event = self::getEvent($id);
|
||||
$event = self::getEvent($params['id']);
|
||||
$calendar = self::getCalendar($event['calendarid']);
|
||||
|
||||
if ($calendar['userid'] != Auth::id()) {
|
||||
throw new \Exception('您没有权限编辑此事件。');
|
||||
}
|
||||
|
||||
if (empty($attachment)) {
|
||||
$attachment = $event['attachment'];
|
||||
abort_error('您没有权限编辑此事件。');
|
||||
}
|
||||
|
||||
$calendardata = $vcalendar->serialize();
|
||||
$extraData = self::getDenormalizedData($calendardata);
|
||||
$data = [
|
||||
'calendardata' => $calendardata,
|
||||
'attachment' => $attachment,
|
||||
'lastmodified' => time(),
|
||||
'rrule' => $extraData['rrule'],
|
||||
'etag' => $extraData['etag'],
|
||||
'size' => $extraData['size'],
|
||||
'componenttype' => $extraData['componentType'],
|
||||
'firstoccurence' => $extraData['firstOccurence'],
|
||||
'lastoccurence' => $extraData['lastOccurence'],
|
||||
'lastmodified' => time(),
|
||||
];
|
||||
CalendarObject::where('id', $id)->update($data);
|
||||
|
||||
// 存在附件字段
|
||||
if (isset($params['attachment'])) {
|
||||
$data['attachment'] = $params['attachment'];
|
||||
}
|
||||
|
||||
CalendarObject::where('id', $params['id'])->update($data);
|
||||
|
||||
// 是重复事件
|
||||
$is_recurring = $vcalendar->VEVENT->RRULE ? 1 : 0;
|
||||
|
||||
// 事件提醒
|
||||
if ($vcalendar->VEVENT->VALARM->TRIGGER) {
|
||||
$triggerTime = $vcalendar->VEVENT->VALARM->getEffectiveTriggerTime();
|
||||
$valarm_at = $triggerTime->getTimeStamp();
|
||||
$reminder = CalendarReminder::firstOrNew(['calendar_id' => $event['calendarid'], 'object_id' => $event['id']]);
|
||||
$reminder->is_recurring = $is_recurring;
|
||||
$reminder->alarm_at = $valarm_at;
|
||||
$reminder->save();
|
||||
} else {
|
||||
CalendarReminder::where('object_id', $event['id'])->delete();
|
||||
}
|
||||
|
||||
// 修改共享数据
|
||||
$share_data = [
|
||||
'source_id' => $params['id'],
|
||||
'source_type' => 'event',
|
||||
'is_repeat' => $is_recurring,
|
||||
'start_at' => $extraData['firstOccurence'],
|
||||
'end_at' => $extraData['lastOccurence'],
|
||||
];
|
||||
|
||||
// 存在接收人字段
|
||||
if (isset($params['receive_id'])) {
|
||||
$share_data['receive_id'] = $params['receive_id'];
|
||||
$share_data['receive_name'] = $params['receive_name'];
|
||||
}
|
||||
|
||||
$share = ShareService::getItem('event', $params['id']);
|
||||
if (empty($share)) {
|
||||
ShareService::addItem($share_data);
|
||||
} else {
|
||||
ShareService::editItem('event', $params['id'], $share_data);
|
||||
}
|
||||
|
||||
self::touchCalendar($event['calendarid']);
|
||||
return true;
|
||||
}
|
||||
@@ -352,11 +414,12 @@ class CalendarService
|
||||
$calendar = self::getCalendar($event['calendarid']);
|
||||
|
||||
if ($calendar['userid'] != Auth::id()) {
|
||||
throw new \Exception('您没有权限删除此事件。');
|
||||
abort_error('您没有权限删除此事件。');
|
||||
}
|
||||
|
||||
AttachmentService::remove($event['attachment']);
|
||||
CalendarObject::where('id', $id)->delete();
|
||||
CalendarReminder::where('object_id', $id)->delete();
|
||||
self::touchCalendar($event['calendarid']);
|
||||
return true;
|
||||
}
|
||||
@@ -365,7 +428,7 @@ class CalendarService
|
||||
{
|
||||
$calendar = self::getCalendar($calendarid);
|
||||
if ($calendar['userid'] != Auth::id()) {
|
||||
throw new \Exception('您没有权限添加事件到此日历。');
|
||||
abort_error('您没有权限添加事件到此日历。');
|
||||
}
|
||||
CalendarObject::where('id', $id)->update(array('calendarid'=>$calendarid));
|
||||
self::touchCalendar($calendarid);
|
||||
@@ -440,14 +503,14 @@ class CalendarService
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
return array(
|
||||
'etag' => md5($calendarData),
|
||||
'size' => strlen($calendarData),
|
||||
'rrule' => $rrule,
|
||||
'componentType' => $componentType,
|
||||
'firstOccurence' => $firstOccurence,
|
||||
'lastOccurence' => $lastOccurence,
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1103,6 +1166,7 @@ class CalendarService
|
||||
|
||||
if ($allday) {
|
||||
$return['start'] = $start_dt->format('Y-m-d');
|
||||
//$end_dt->modify('-1 minute');
|
||||
while ($start_dt >= $end_dt) {
|
||||
$end_dt->modify('+1 day');
|
||||
}
|
||||
|
||||
@@ -7,6 +7,14 @@ return [
|
||||
['name' => '工作', 'id' => 'work'],
|
||||
['name' => '日程管理', 'id' => 'calendar_calendar_index', 'parent' => 'work', 'url' => 'calendar/calendar/index'],
|
||||
],
|
||||
'widgets' => [
|
||||
'widget_calendar_index' => [
|
||||
'name' => '日程管理',
|
||||
'type' => 1,
|
||||
'url' => 'calendar/widget/index',
|
||||
'more_url' => 'calendar/calendar/index',
|
||||
],
|
||||
],
|
||||
"controllers" => [
|
||||
"calendar" => [
|
||||
"name" => "日历",
|
||||
@@ -28,6 +36,9 @@ return [
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"help" => [
|
||||
"name" => "帮助"
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
@@ -67,8 +67,8 @@ function InitCalendar(sources)
|
||||
allDayText:'全天',
|
||||
slotLabelFormat: 'HH:mm',
|
||||
timeFormat: 'HH:mm',
|
||||
minTime:'07:00:00',
|
||||
maxTime:'23:00:00',
|
||||
//minTime:'07:00:00',
|
||||
//maxTime:'23:00:00',
|
||||
titleRangeSeparator:' - ',
|
||||
monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
|
||||
monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
|
||||
@@ -87,13 +87,11 @@ function InitCalendar(sources)
|
||||
});
|
||||
},
|
||||
viewRender:function(view) {
|
||||
/*
|
||||
window.clearInterval(timelineInterval);
|
||||
timelineInterval = window.setInterval(function() {
|
||||
timeLine(view);
|
||||
}, 10000);
|
||||
timeLine(view);
|
||||
*/
|
||||
},
|
||||
loading:function(status, view) {
|
||||
if (status) {
|
||||
@@ -105,33 +103,29 @@ function InitCalendar(sources)
|
||||
|
||||
// 改变大小事件 event, dayDelta, minuteDelta, revertFunc
|
||||
eventResize: function(event, delta, revertFunc) {
|
||||
|
||||
if(auth_id == user_id) {
|
||||
if (auth_id == user_id) {
|
||||
resizeEvent(event, delta, revertFunc);
|
||||
} else {
|
||||
toastrError('不能给下属调整事件。');
|
||||
revertFunc();
|
||||
}
|
||||
},
|
||||
|
||||
// 拖动事件
|
||||
eventDrop: function(event, delta, revertFunc) {
|
||||
|
||||
if(auth_id == user_id) {
|
||||
if (auth_id == user_id) {
|
||||
moveEvent(event, delta, revertFunc);
|
||||
} else {
|
||||
toastrError('不能给下属移动事件。');
|
||||
revertFunc();
|
||||
}
|
||||
},
|
||||
|
||||
// 点击事件
|
||||
eventClick: function(event, jsEvent, view) {
|
||||
if(event.shared == true) {
|
||||
if (event.shared == true) {
|
||||
viewEvent(event, jsEvent, view);
|
||||
|
||||
} else if(auth_id == event.userid) {
|
||||
if(event.id > 0) {
|
||||
} else if (auth_id == event.userid) {
|
||||
if (event.id > 0) {
|
||||
editEvent(event, jsEvent, view);
|
||||
} else {
|
||||
addEvent(event, jsEvent, view);
|
||||
@@ -143,8 +137,7 @@ function InitCalendar(sources)
|
||||
|
||||
// 选择后弹出
|
||||
select: function(start, end, jsEvent, view) {
|
||||
|
||||
if(auth_id == user_id) {
|
||||
if (auth_id == user_id) {
|
||||
addEvent({start: start, end: end}, jsEvent, view);
|
||||
} else {
|
||||
toastrError('不能给下属添加事件。');
|
||||
@@ -155,7 +148,6 @@ function InitCalendar(sources)
|
||||
if(view.type == 'listMonth') {
|
||||
return;
|
||||
}
|
||||
|
||||
overlay.find('#overlay-title').text(calEvent.title);
|
||||
overlay.find('#overlay-start').text(calEvent.start.format());
|
||||
overlay.find('#overlay-end').text(calEvent.end.format());
|
||||
@@ -207,7 +199,7 @@ function timeLine(curView) {
|
||||
|
||||
var timeline = parentDiv.children(".timeline");
|
||||
if (timeline.length == 0) {
|
||||
//添加时间线标签
|
||||
// 添加时间线标签
|
||||
timeline = $("<hr>").addClass("timeline");
|
||||
parentDiv.prepend(timeline);
|
||||
}
|
||||
@@ -222,7 +214,7 @@ function timeLine(curView) {
|
||||
var percentOfDay = curSeconds / 86400;
|
||||
var topPos = Math.floor(parentDiv.height() * percentOfDay);
|
||||
|
||||
timeline.css("top", topPos+"px");
|
||||
timeline.css("top", topPos + "px");
|
||||
|
||||
// 周视图时设置时间线的位置和宽度
|
||||
if (curView.name == "agendaWeek") {
|
||||
@@ -332,8 +324,8 @@ function moveEvent(event, delta, revertFunc)
|
||||
function editEvent(event, jsEvent, view)
|
||||
{
|
||||
var data = dateFormat(event);
|
||||
data.id = event.id;
|
||||
data.title = event.title;
|
||||
data.id = event.id;
|
||||
data.title = event.title;
|
||||
data.location = event.location;
|
||||
data.description = event.description;
|
||||
data.lastmodified = event.lastmodified;
|
||||
@@ -351,7 +343,6 @@ function editEvent(event, jsEvent, view)
|
||||
text: '提交',
|
||||
'class': 'btn-info',
|
||||
click: function() {
|
||||
|
||||
var $this = $(this);
|
||||
if ($('#title').val().length == 0) {
|
||||
toastrError('主题必须填写。');
|
||||
@@ -461,15 +452,16 @@ function getCalendars(callback)
|
||||
if(this.active == 1) {
|
||||
var checkbox = 'checked';
|
||||
}
|
||||
|
||||
if(this.id == 'shared') {
|
||||
var checkbox = 'checked disabled';
|
||||
var checkbox = 'checked';
|
||||
}
|
||||
rows.push('<li class="list-group-item">'+ edit +'<label class="checkbox-inline"><input data-calendar="active" data-id="'+this.id+'" type="checkbox" '+checkbox+' /> <span class="text" style="color:'+this.calendarcolor+'">'+this.displayname+'</span></label></li>');
|
||||
});
|
||||
rows.push('</ul>');
|
||||
$('#calendars').html(rows.join(''));
|
||||
|
||||
if(callback) {
|
||||
if (callback) {
|
||||
callback(res.data.sources);
|
||||
}
|
||||
});
|
||||
@@ -520,7 +512,7 @@ $(function() {
|
||||
|
||||
#loading { background:red; color:#fff; padding:3px; position:absolute; top:5px;right:5px;z-index:9999;}
|
||||
|
||||
.category .tree ul {padding:5px 0;}
|
||||
.category .tree ul { padding:5px 0; }
|
||||
.category .tree ul li.me {padding:5px; color:#666;}
|
||||
.category .tree ul li ul {padding:5px 0 0;}
|
||||
.category .tree ul li ul li {padding:5px 5px 0 5px; border:0;border-top:1px solid #eee;}
|
||||
@@ -542,13 +534,13 @@ $(function() {
|
||||
<div class="tree">
|
||||
|
||||
<ul class="list-group">
|
||||
|
||||
|
||||
<li class="list-group-item"><strong>下属日历</strong></li>
|
||||
|
||||
@if($underling['role'])
|
||||
@foreach($underling['role'] as $role_id => $role)
|
||||
<li class="list-group-item">
|
||||
{{$role['title']}}
|
||||
<i class="fa fa-angle-down"></i> {{$role['name']}}
|
||||
<ul>
|
||||
@if($underling['user'][$role_id])
|
||||
@foreach($underling['user'][$role_id] as $user)
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
<div class="gdoo-list-grid">
|
||||
|
||||
<div id="widget_calendar_datetime" class="m-t-xs"></div>
|
||||
|
||||
@verbatim
|
||||
<div class="b-t" id="widget_calendar_event_list" style="width:100%;height:200px;">
|
||||
<div v-for="row in data.dayEvents">
|
||||
<li class="calendar-day-event">
|
||||
<div v-if="row.allday" class="day-tag">
|
||||
<span title="全天">全天</span>
|
||||
</div>
|
||||
<div class="day-tag time-tag" v-else>
|
||||
<span :title="row.start">{{row.start}}</span>
|
||||
<span :title="row.end">{{row.end}}</span>
|
||||
</div>
|
||||
<div class="title-tag" v-if="row.allday" :title="row.title">
|
||||
<div class="text_overflow" style="cursor:pointer;">{{row.title}}</div>
|
||||
<i class="text_overflow">{{row._start}} - {{row._end}} </i>
|
||||
</div>
|
||||
<div class="title-tag title-time-tag" v-else :title="row.title">
|
||||
<div class="text_overflow" style="cursor:pointer;">{{row.title}}</div>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
@endverbatim
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#widget_calendar_event_list {
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
padding: 5px;
|
||||
}
|
||||
.calendar-day-event {
|
||||
list-style: none;
|
||||
position: relative;
|
||||
border-bottom: 1px solid #efefef;
|
||||
padding: 6px 0 0;
|
||||
height: 44px;
|
||||
}
|
||||
.calendar-day-event .day-tag {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 6px;
|
||||
width: 46px;
|
||||
border-right: 2px solid #53aaff;
|
||||
height: 30px;
|
||||
text-align: center;
|
||||
line-height: 30px;
|
||||
}
|
||||
.calendar-day-event .time-tag {
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.calendar-day-event .day-tag span {
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
.calendar-day-event .title-tag {
|
||||
position: absolute;
|
||||
padding-left: 56px;
|
||||
margin: 0;
|
||||
}
|
||||
.calendar-day-event .title-time-tag {
|
||||
line-height: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
.calendar-day-event .title-tag i {
|
||||
line-height: 14px;
|
||||
height: 14px;
|
||||
overflow: hidden;
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-style: normal;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
$.fn.datetimepicker.Constructor.Default = $.extend({}, $.fn.datetimepicker.Constructor.Default, {
|
||||
dayViewHeaderFormat:'YYYY年MM月',
|
||||
icons: {
|
||||
today: 'fa fa-caret-square-o-right',
|
||||
clear: 'fa fa-trash-o',
|
||||
close: 'fa fa-close',
|
||||
time: "fa fa-clock-o",
|
||||
date: "fa fa-calendar-check-o",
|
||||
up: "fa fa-arrow-up",
|
||||
down: "fa fa-arrow-down",
|
||||
previous: 'fa fa-angle-left',
|
||||
next: 'fa fa-angle-right',
|
||||
},
|
||||
tooltips:{
|
||||
today: '今天',
|
||||
time: '时间',
|
||||
clear: '清除',
|
||||
close: '关闭',
|
||||
selectMonth: '选择月份',
|
||||
prevMonth: '上个月',
|
||||
nextMonth: '下个月',
|
||||
selectYear: '选择年份',
|
||||
prevYear: '上一年',
|
||||
nextYear: '下一年',
|
||||
selectDecade: '选择时期',
|
||||
prevDecade: '上个年代',
|
||||
nextDecade: '下个年代',
|
||||
prevCentury: '上个世纪',
|
||||
nextCentury: '下个世纪',
|
||||
incrementHour: '增加一小时',
|
||||
pickHour: '选择小时',
|
||||
decrementHour:'减少一小时',
|
||||
incrementMinute: '增加一分钟',
|
||||
pickMinute: '选择分',
|
||||
decrementMinute:'减少一分钟',
|
||||
incrementSecond: '增加一秒',
|
||||
pickSecond: '选择秒',
|
||||
decrementSecond:'减少一秒'
|
||||
}
|
||||
});
|
||||
|
||||
(function ($) {
|
||||
var datas = [];
|
||||
var $calendar = $('#widget_calendar_datetime');
|
||||
$calendar.datetimepicker({
|
||||
format: 'YYYY-MM-DD',
|
||||
inline: true,
|
||||
sideBySide: true,
|
||||
onSelectDay: function(clsName, day) {
|
||||
if (datas[day]) {
|
||||
clsName += ' todo';
|
||||
}
|
||||
return clsName;
|
||||
}
|
||||
});
|
||||
var picker = $calendar.data('datetimepicker');
|
||||
|
||||
function getStartEndDate(viewDate, callback) {
|
||||
datas = {};
|
||||
let start = viewDate.clone().startOf('M').startOf('w').startOf('d');
|
||||
let end = start.clone().add(41, 'd').format('L');
|
||||
start = start.format('L');
|
||||
$.getJSON(app.url('calendar/event/data', {start, end}), function(rows) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = rows[i];
|
||||
datas[row.date] = datas[row.date] || [];
|
||||
datas[row.date].push(row);
|
||||
}
|
||||
picker._fillDate();
|
||||
if (typeof callback === 'function') {
|
||||
callback(datas);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 初始化数据
|
||||
getStartEndDate(picker._viewDate, function() {
|
||||
let day = picker.date().format('L');
|
||||
vueData.dayEvents = datas[day] || [];
|
||||
});
|
||||
|
||||
$calendar.on('update.datetimepicker', function(e) {
|
||||
getStartEndDate(e.viewDate);
|
||||
});
|
||||
|
||||
$calendar.on('change.datetimepicker', function(e) {
|
||||
let day = e.date.format('L');
|
||||
vueData.dayEvents = datas[day] || [];
|
||||
});
|
||||
|
||||
let vueData = Vue.reactive({dayEvents:[]});
|
||||
let vm = Vue.createApp({
|
||||
setup(props, ctx) {
|
||||
return {data: vueData};
|
||||
}
|
||||
}).mount("#widget_calendar_event_list");
|
||||
|
||||
gdoo.widgets['calendar_widget_index'] = {
|
||||
remoteData: function() {
|
||||
picker._doAction({}, 'today');
|
||||
getStartEndDate(picker._viewDate);
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
</script>
|
||||
Reference in New Issue
Block a user