Exemplo n.º 1
0
 public static function getNames()
 {
     $calendars = X2Calendar::model()->findAllByAttributes(array('googleCalendar' => false));
     $names = array();
     foreach ($calendars as $calendar) {
         $names["{$calendar->id}"] = $calendar->name;
     }
     return $names;
 }
Exemplo n.º 2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = X2Calendar::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.'));
     }
     return $model;
 }
Exemplo n.º 3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Actions();
     $users = User::getNames();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Actions'])) {
         //			$this->render('test', array('model'=>$_POST));
         $temp = $model->attributes;
         if (isset($_POST['inCalendar'])) {
             // create new calendar event
             foreach (array_keys($model->attributes) as $field) {
                 if (isset($_POST['CalendarEvent'][$field])) {
                     $model->{$field} = $_POST['CalendarEvent'][$field];
                 }
             }
             $model->actionDescription = $_POST['Actions']['actionDescription'];
             //				$this->render('test', array('model'=>$_POST['CalendarEvent']));
         } else {
             foreach (array_keys($model->attributes) as $field) {
                 if (isset($_POST['Actions'][$field])) {
                     $model->{$field} = $_POST['Actions'][$field];
                 }
             }
         }
         if (is_numeric($model->assignedTo)) {
             // assigned to calendar instead of user?
             $calendar = X2Calendar::model()->findByPk($model->assignedTo);
             if (isset($calendar)) {
                 $model->calendarId = $model->assignedTo;
                 $model->assignedTo = null;
                 if ($calendar->googleCalendar && $calendar->googleCalendarId) {
                     $model->dueDate = $this->parseDateTime($model->dueDate);
                     if ($model->completeDate) {
                         $model->completeDate = $this->parseDateTime($model->completeDate);
                     }
                     $calendar->createGoogleEvent($model);
                     // action/event assigned to Google Calendar, no need to create Action since it's saved to google
                     $this->redirect(array('/calendar/index'));
                 }
             }
         }
         $this->create($model, $temp, '0');
     }
     if (isset($_GET['param'])) {
         $pieces = explode(';', $_GET['param']);
         $user = $pieces[0];
         $pieces2 = explode(':', $pieces[1]);
         $type = $pieces2[0];
         $id = $pieces2[1];
     } else {
         // defaults
         $user = Yii::app()->user->getName();
         $type = 'none';
         $id = null;
     }
     $model->associationType = $type;
     $model->assignedTo = $user;
     if (!empty($id)) {
         $model->associationId = $id;
     }
     $this->render('create', array('model' => $model, 'users' => $users));
 }
Exemplo n.º 4
0
     echo "</ul>\n";
     $this->endWidget();
 }
 if (isset($this->googleCalendars) && $this->googleCalendars !== null) {
     $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('calendar', 'Google Calendars'), 'id' => 'google-calendars'));
     $showGoogleCalendars = $showCalendars['googleCalendars'];
     echo '<ul style="font-size: 0.8em; font-weight: bold; color: black;">';
     foreach ($this->googleCalendars as $calendarId => $calendarName) {
         if (isset($editableCalendars[$calendarId])) {
             // check if current user has permission to edit calendar
             $editable = 'true';
         } else {
             $editable = 'false';
         }
         echo "<li>\n";
         $calendar = X2Calendar::model()->findByPk($calendarId);
         // checkbox for each user; current user and Anyone are set to checked
         if ($calendar->googleCalendarId) {
             // read/write google calendar
             echo CHtml::checkBox($calendarId, in_array($calendarId, $showGoogleCalendars), array('onChange' => "toggleCalendarSourceGoogle({$calendarId}, this.checked, {$editable});"));
         } else {
             // read only google calendar feed
             echo CHtml::checkBox($calendarId, in_array($calendarId, $showGoogleCalendars), array('onChange' => "toggleCalendarSourceGoogleFeed({$calendarId}, this.checked, '{$calendar->googleFeed}');"));
         }
         echo "<label for=\"{$calendarId}\">{$calendarName}</label>\n";
         echo "</li>";
     }
     echo "</ul>\n";
     $this->endWidget();
 }
 if (isset($this->calendarFilter) && $this->calendarFilter !== null) {