Пример #1
0
 public function run()
 {
     // Prevent the small calendar from showing when using the larger calendar
     if (Yii::app()->controller->modelClass == 'X2Calendar' && Yii::app()->controller->action->getId() == 'index') {
         return;
     }
     // Fetch the calendars to display
     $user = User::model()->findByPk(Yii::app()->user->getId());
     if (is_null($user->showCalendars)) {
         $user->initCheckedCalendars();
     }
     $showCalendars = $user->showCalendars;
     // Possible urls for the calendar to call
     $urls = X2Calendar::getCalendarUrls();
     $widgetSettingUrl = $this->controller->createUrl('/site/widgetSetting');
     $justMe = Profile::getWidgetSetting('SmallCalendar', 'justMe');
     Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/js/fullcalendar-1.6.1/fullcalendar/fullcalendar.css');
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/components/smallCalendar.css');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/fullcalendar-1.6.1/fullcalendar/fullcalendar.js');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->getModule('calendar')->assetsUrl . '/js/calendar.js', CClientScript::POS_END);
     $this->render('smallCalendar', array('showCalendars' => $showCalendars, 'urls' => $urls, 'user' => $user->username, 'widgetSettingUrl' => $widgetSettingUrl, 'justMe' => $justMe));
 }
Пример #2
0
//Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl().'/protected/extensions/CJuiDateTimePicker/assets/jquery-ui-timepicker-addon.js');
$menuOptions = array('index', 'myPermissions');
if (Yii::app()->params->isAdmin) {
    $menuOptions[] = 'userPermissions';
}
if (Yii::app()->settings->googleIntegration) {
    $menuOptions[] = 'sync';
}
$this->insertMenu($menuOptions);
$this->calendarUsers = X2CalendarPermissions::getViewableUserCalendarNames();
$this->groupCalendars = X2Calendar::getViewableGroupCalendarNames();
//$this->sharedCalendars = X2Calendar::getViewableCalendarNames();
//$this->googleCalendars = X2Calendar::getViewableGoogleCalendarNames();
$this->calendarFilter = X2Calendar::getCalendarFilters();
// urls for ajax (and other javascript) calls
$urls = X2Calendar::getCalendarUrls();
$user = User::model()->findByPk(Yii::app()->user->getId());
$showCalendars = json_decode($user->showCalendars, true);
// fix showCalendars['groupCalendars']
if (!isset($showCalendars['groupCalendars'])) {
    $showCalendars['groupCalendars'] = array();
    $user->showCalendars = json_encode($showCalendars);
    $user->update();
}
$userCalendars = $showCalendars['userCalendars'];
$groupCalendars = $showCalendars['groupCalendars'];
$sharedCalendars = $showCalendars['sharedCalendars'];
$googleCalendars = $showCalendars['googleCalendars'];
$checkedUserCalendars = '';
foreach ($userCalendars as $user) {
    if (isset($this->calendarUsers[$user])) {