]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix merge conflicts
authorGeorg Ehrke <dev@georgswebsite.de>
Fri, 13 Apr 2012 20:40:10 +0000 (16:40 -0400)
committerGeorg Ehrke <dev@georgswebsite.de>
Fri, 13 Apr 2012 20:40:10 +0000 (16:40 -0400)
1  2 
apps/calendar/ajax/event/edit.form.php
apps/calendar/ajax/event/new.form.php
apps/calendar/index.php
apps/calendar/js/calendar.js
apps/calendar/lib/app.php
apps/calendar/lib/object.php
apps/calendar/templates/part.eventform.php
core/css/styles.css

index 986ab65ed03d9db2d58a730386d85d8831f21147,98c22eb0206c8f5772750d34d7e0eec08349b602..6582496577b549b5f0a7cbfe2ca58d8ab5b41c04
@@@ -210,17 -195,10 +205,16 @@@ $repeat_bymonth_options = OC_Calendar_A
  $repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
  $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
  
 -$tmpl = new OC_Template('calendar', 'part.editevent');
 -$tmpl->assign('id', $id);
 +if($access == 'owner' || $access == 'rw'){
 +      $tmpl = new OC_Template('calendar', 'part.editevent');
 +}elseif($access == 'r'){
 +      $tmpl = new OC_Template('calendar', 'part.showevent');
 +}
 +
 +$tmpl->assign('eventid', $id);
 +$tmpl->assign('access', $access);
  $tmpl->assign('lastmodified', $lastmodified);
  $tmpl->assign('calendar_options', $calendar_options);
- $tmpl->assign('category_options', $category_options);
  $tmpl->assign('repeat_options', $repeat_options);
  $tmpl->assign('repeat_month_options', $repeat_month_options);
  $tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
@@@ -257,7 -235,14 +251,14 @@@ if($repeat['repeat'] != 'doesnotrepeat'
        $tmpl->assign('repeat_bymonthday', $repeat['bymonthday']);
        $tmpl->assign('repeat_bymonth', $repeat['bymonth']);
        $tmpl->assign('repeat_byweekno', $repeat['byweekno']);
+ } else {
+       $tmpl->assign('repeat_month', 'monthday');
+       $tmpl->assign('repeat_weekdays', array());
+       $tmpl->assign('repeat_interval', 1);
+       $tmpl->assign('repeat_end', 'never');
+       $tmpl->assign('repeat_count', '10');
+       $tmpl->assign('repeat_weekofmonth', 'auto');
+       $tmpl->assign('repeat_date', '');
+       $tmpl->assign('repeat_year', 'bydate');
  }
--$tmpl->printpage();
- ?>
++$tmpl->printpage();
index 69d1dc3f08b6322f269c7d7140ab12afc9607aea,838002a3a09e62edec9a4e2c8021db9e2efcec5e..91b955465697fce80ce676b661d68781ef440dc4
@@@ -45,9 -44,7 +44,8 @@@ $repeat_byweekno_options = OC_Calendar_
  $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
  
  $tmpl = new OC_Template('calendar', 'part.newevent');
 +$tmpl->assign('access', 'owner');
  $tmpl->assign('calendar_options', $calendar_options);
- $tmpl->assign('category_options', $category_options);
  $tmpl->assign('repeat_options', $repeat_options);
  $tmpl->assign('repeat_month_options', $repeat_month_options);
  $tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
index 280b0a18867a525aa9fd6df0358354538c09ac67,f964a13ef790339a50f03b9a736d856f20a2928a..c44de7f07df0bf78e65125e76e764eb801627b9e
@@@ -21,11 -21,8 +21,12 @@@ $eventSources = array()
  foreach($calendars as $calendar){
        $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
  }
 +
 +$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true');
 +$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false');
 +
  OC_Hook::emit('OC_Calendar', 'getSources', array('sources' => &$eventSources));
+ $categories = OC_Calendar_App::getCategoryOptions();
  
  //Fix currentview for fullcalendar
  if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
Simple merge
index 58cc34658c67ebc1233331819e2accfd01289491,22c1133e0063dabb22db21dd836b7afd26fd1831..ee1d39bc662d468fd9a01d1f805d140c888acf36
   * This class manages our app actions
   */
  OC_Calendar_App::$l10n = new OC_L10N('calendar');
 +OC_Calendar_App::$tz = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
  class OC_Calendar_App{
 +      const CALENDAR = 'calendar';
 +      const EVENT = 'event';
 +      /*
 +       * @brief language object for calendar app
 +       */
        public static $l10n;
+       protected static $categories = null;
  
 -      public static function getCalendar($id){
 -              $calendar = OC_Calendar_Calendar::find( $id );
 -              if( $calendar === false || $calendar['userid'] != OC_User::getUser()){
 -                      OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar'))));
 -                      exit();
 +      /*
 +       * @brief timezone of the user
 +       */
 +      public static $tz;
 +      
 +      /*
 +       * @brief returns informations about a calendar
 +       * @param int $id - id of the calendar
 +       * @param bool $security - check access rights or not
 +       * @param bool $shared - check if the user got access via sharing
 +       * @return mixed - bool / array
 +       */
 +      public static function getCalendar($id, $security = true, $shared = false){
 +              $calendar = OC_Calendar_Calendar::find($id);
 +              if($shared === true){
 +                      if(OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::CALENDAR)){
 +                              return $calendar;
 +                      }
 +              }
 +              if($security === true){
 +                      if($calendar['userid'] != OC_User::getUser()){
 +                              return false;
 +                      }
                }
 -              return $calendar;
 +              if($calendar === false){
 +                      return false;
 +              }
 +              return OC_Calendar_Calendar::find($id);
        }
 -
 -      public static function getEventObject($id){
 -              $event_object = OC_Calendar_Object::find( $id );
 -              if( $event_object === false ){
 -                      OC_JSON::error();
 -                      exit();
 +      
 +      /*
 +       * @brief returns informations about an event
 +       * @param int $id - id of the event
 +       * @param bool $security - check access rights or not
 +       * @param bool $shared - check if the user got access via sharing
 +       * @return mixed - bool / array
 +       */
 +      public static function getEventObject($id, $security = true, $shared = false){
 +              $event = OC_Calendar_Object::find($id);
 +              if($shared === true){
 +                      if(OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::EVENT)){
 +                              return $event;
 +                      }
                }
 -
 -              self::getCalendar( $event_object['calendarid'] );//access check
 -              return $event_object;
 +              if($security === true){
 +                      $calendar = self::getCalendar($event['calendarid'], false);
 +                      if($calendar['userid'] != OC_User::getUser()){
 +                              return false;
 +                      }
 +              }
 +              if($event === false){
 +                      return false;
 +              }
 +              return $event;
        }
 -
 -      public static function getVCalendar($id){
 -              $event_object = self::getEventObject( $id );
 -
 -              $vcalendar = OC_VObject::parse($event_object['calendardata']);
 -              // Check if the vcalendar is valid
 -              if(is_null($vcalendar)){
 -                      OC_JSON::error();
 -                      exit();
 +      
 +      /*
 +       * @brief returns the parsed calendar data
 +       * @param int $id - id of the event
 +       * @param bool $security - check access rights or not
 +       * @return mixed - bool / object
 +       */
 +      public static function getVCalendar($id, $security = true, $shared = false){
 +              $event_object = self::getEventObject($id, $security, $shared);
 +              if($event_object === false){
 +                      return false;
                }
 -              return $vcalendar;
 +              $vobject = OC_VObject::parse($event_object['calendardata']);
 +              if(is_null($vobject)){
 +                      return false;
 +              }
 +              return $vobject;
        }
 -
 -      public static function isNotModified($vevent, $lastmodified)
 -      {
 +      
 +      /*
 +       * @brief checks if an event was edited and dies if it was
 +       * @param (object) $vevent - vevent object of the event
 +       * @param (int) $lastmodified - time of last modification as unix timestamp
 +       * @return (bool)
 +       */
 +      public static function isNotModified($vevent, $lastmodified){
                $last_modified = $vevent->__get('LAST-MODIFIED');
                if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')){
                        OC_JSON::error(array('modified'=>true));
                        exit;
                }
 +              return true;
        }
-       /*
-        * THIS FUNCTION IS DEPRECATED AND WILL BE REMOVED SOON
-        * @brief returns the valid categories
-        * @return array - categories
+       protected static function getDefaultCategories()
+       {
+               return array(
+                       self::$l10n->t('Birthday'),
+                       self::$l10n->t('Business'),
+                       self::$l10n->t('Call'),
+                       self::$l10n->t('Clients'),
+                       self::$l10n->t('Deliverer'),
+                       self::$l10n->t('Holidays'),
+                       self::$l10n->t('Ideas'),
+                       self::$l10n->t('Journey'),
+                       self::$l10n->t('Jubilee'),
+                       self::$l10n->t('Meeting'),
+                       self::$l10n->t('Other'),
+                       self::$l10n->t('Personal'),
+                       self::$l10n->t('Projects'),
+                       self::$l10n->t('Questions'),
+                       self::$l10n->t('Work'),
+               );
+       }
+       protected static function getVCategories() {
+               if (is_null(self::$categories)) {
+                       self::$categories = new OC_VCategories('calendar', null, self::getDefaultCategories());
+               }
+               return self::$categories;
+       }
+       public static function getCategoryOptions()
+       {
+               $categories = self::getVCategories()->categories();
+               return $categories;
+       }
+       /**
+        * scan events for categories.
+        * @param $events VEVENTs to scan. null to check all events for the current user.
         */
-       public static function getCategoryOptions(){
-               return OC_Calendar_Object::getCategoryOptions(self::$l10n);
+       public static function scanCategories($events = null) {
+               if (is_null($events)) {
+                       $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+                       if(count($calendars) > 0) {
+                               $events = array();
+                               foreach($calendars as $calendar) {
+                                       $calendar_events = OC_Calendar_Object::all($calendar['id']);
+                                       $events = $events + $calendar_events;
+                               }
+                       }
+               }
+               if(is_array($events) && count($events) > 0) {
+                       $vcategories = self::getVCategories();
+                       $vcategories->delete($vcategories->categories());
+                       foreach($events as $event) {
+                               $vobject = OC_VObject::parse($event['calendardata']);
+                               if(!is_null($vobject)) {
+                                       $vcategories->loadFromVObject($vobject->VEVENT, true);
+                               }
+                       }
+               }
        }
-       
-       /*
-        * @brief returns the options for an repeating event
-        * @return array - valid inputs for repeating events
+       /**
+        * check VEvent for new categories.
+        * @see OC_VCategories::loadFromVObject
         */
+       public static function loadCategoriesFromVCalendar(OC_VObject $calendar) {
+               self::getVCategories()->loadFromVObject($calendar->VEVENT, true);
+       }
        public static function getRepeatOptions(){
                return OC_Calendar_Object::getRepeatOptions(self::$l10n);
        }
        public static function getWeekofMonth(){
                return OC_Calendar_Object::getWeekofMonth(self::$l10n);
        }
 -}
 +      
 +      /*
 +       * @brief checks the access for a calendar / an event
 +       * @param (int) $id - id of the calendar / event
 +       * @param (string) $type - type of the id (calendar/event)
 +       * @return (string) $access - level of access
 +       */
 +      public static function getaccess($id, $type){
 +              if($type == self::CALENDAR){
 +                      $calendar = self::getCalendar($id, false, false);
 +                      if($calendar['userid'] == OC_User::getUser()){
 +                              return 'owner';
 +                      }
 +                      $isshared = OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::CALENDAR);
 +                      if($isshared){
 +                              $writeaccess = OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::CALENDAR);
 +                              if($writeaccess){
 +                                      return 'rw';
 +                              }else{
 +                                      return 'r';
 +                              }
 +                      }else{
 +                              return false;
 +                      }
 +              }elseif($type == self::EVENT){
 +                      if(OC_Calendar_Object::getowner($id) == OC_User::getUser()){
 +                              return 'owner';
 +                      }
 +                      $isshared = OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::EVENT);
 +                      if($isshared){
 +                              $writeaccess = OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::EVENT);
 +                              if($writeaccess){
 +                                      return 'rw';
 +                              }else{
 +                                      return 'r';
 +                              }
 +                      }else{
 +                              return false;
 +                      }
 +              }
 +      }
 +      
 +      /*
 +       * @brief analyses the parameter for calendar parameter and returns the objects
 +       * @param (string) $calendarid - calendarid
 +       * @param (int) $start - unixtimestamp of start
 +       * @param (int) $end - unixtimestamp of end
 +       * @return (array) $events 
 +       */
 +      public static function getrequestedEvents($calendarid, $start, $end){
-               
 +              $events = array();
 +              if($calendarid == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){
 +                      $calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r');
 +                      foreach($calendars as $calendar){
 +                              $calendarevents = OC_Calendar_Object::allInPeriod($calendar['calendarid'], $start, $end);
 +                              $events = array_merge($events, $calendarevents);
 +                      }
 +                      $singleevents = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::EVENT, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r');
 +                      foreach($singleevents as $singleevent){
 +                              $event = OC_Calendar_Object::find($singleevent['eventid']);
 +                              $events[] =  $event;
 +                      }
 +              }else{
 +                      $calendar_id = $_GET['calendar_id'];
 +                      if (is_numeric($calendar_id)) {
 +                              $calendar = self::getCalendar($calendar_id);
 +                              OC_Response::enableCaching(0);
 +                              OC_Response::setETagHeader($calendar['ctag']);
 +                              $events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end);
 +                      } else {
 +                              OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events));
 +                      }
 +              }
 +              return $events;
 +      }
 +      
 +      /*
 +       * @brief generates the output for an event which will be readable for our js
 +       * @param (mixed) $event - event object / array
 +       * @param (int) $start - unixtimestamp of start
 +       * @param (int) $end - unixtimestamp of end
 +       * @return (array) $output - readable output
 +       */
 +      public static function generateEventOutput($event, $start, $end){
 +              $output = array();
 +              
 +              if(isset($event['calendardata'])){
 +                      $object = OC_VObject::parse($event['calendardata']);
 +                      $vevent = $object->VEVENT;
 +              }else{
 +                      $vevent = $event['vevent'];
 +              }
 +              
 +              $last_modified = @$vevent->__get('LAST-MODIFIED');
 +              $lastmodified = ($last_modified)?$last_modified->getDateTime()->format('U'):0;
 +              
 +              $output = array('id'=>(int)$event['id'],
 +                                              'title' => htmlspecialchars(($event['summary']!=NULL || $event['summary'] != '')?$event['summary']: self::$l10n->t('unnamed')),
 +                                              'description' => isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):'',
 +                                              'lastmodified'=>$lastmodified);
 +              
 +              $dtstart = $vevent->DTSTART;
 +              $start_dt = $dtstart->getDateTime();
 +              $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
 +              $end_dt = $dtend->getDateTime();
 +              
 +              if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){
 +                      $output['allDay'] = true;
 +              }else{
 +                      $output['allDay'] = false;
 +                      $start_dt->setTimezone(new DateTimeZone(self::$tz));
 +                      $end_dt->setTimezone(new DateTimeZone(self::$tz));
 +              }
 +              
 +              if($event['repeating'] == 1){
 +                      $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U');
 +                      $r = new When();
 +                      $r->recur($start_dt)->rrule((string) $vevent->RRULE);
 +                      /*$r = new iCal_Repeat_Generator(array('RECUR'  => $start_dt,
 +                       *                                                                         'RRULE'  => (string)$vevent->RRULE
 +                       *                                                                         'RDATE'  => (string)$vevent->RDATE                                           
 +                       *                                                                         'EXRULE' => (string)$vevent->EXRULE
 +                       *                                                                         'EXDATE' => (string)$vevent->EXDATE));*/
 +                      while($result = $r->next()){
 +                              if($result < $start){
 +                                      continue;
 +                              }
 +                              if($result > $end){
 +                                      break;
 +                              }
 +                              if($output['allDay'] == true){
 +                                      $output['start'] = $result->format('Y-m-d');
 +                                      $output['end'] = date('Y-m-d', $result->format('U') + --$duration);
 +                              }else{
 +                                      $output['start'] = $result->format('Y-m-d H:i:s');
 +                                      $output['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration);
 +                              }
 +                      }
 +              }else{
 +                      if($output['allDay'] == true){
 +                              $output['start'] = $start_dt->format('Y-m-d');
 +                              $end_dt->modify('-1 sec');
 +                              $output['end'] = $end_dt->format('Y-m-d');
 +                      }else{
 +                              $output['start'] = $start_dt->format('Y-m-d H:i:s');
 +                              $output['end'] = $end_dt->format('Y-m-d H:i:s');
 +                      }
 +              }
 +              return $output;
 +      }
 +}
index ab005bd4a4aed197be8482595c4d1e06abb8821e,d5622f6251fb0d78db07d79dd130e2e9176fded8..825977c17c55efdc3f36eb57fe0709eb1546f430
@@@ -451,11 -432,12 +432,7 @@@ class OC_Calendar_Object
                        $errarr['title'] = 'true';
                        $errnum++;
                }
 -              $calendar = OC_Calendar_Calendar::find($request['calendar']);
 -              if($calendar['userid'] != OC_User::getUser()){
 -                      $errarr['cal'] = 'true';
 -                      $errnum++;
 -              }
  
-               if(isset($request['categories']) && !is_array($request['categories'])){
-                       $errarr['categories'] = $l10n->t('Not an array');
-               }
                $fromday = substr($request['from'], 0, 2);
                $frommonth = substr($request['from'], 3, 2);
                $fromyear = substr($request['from'], 6, 4);
index 3e12f2973e2ffadd30ffd2f1de8765664674a844,3830c273a730156ac5814a413b2c0f6bdc41a6b2..c63630a5a05482f947eb14380e684555fb349b03
@@@ -244,13 -203,23 +240,13 @@@ echo 'Calendar.UI.Share.idtype = "event
                                        </td>
                                </tr>
                        </table>
 +                      <?php echo $l->t('Summary'); ?>:<span id="repeatsummary"></span>
                </div>
 -              <hr>
 -              <!-- support for attendees will be added in following versions --> 
 -              <table>
 -                      <tr>
 -                              <th width="85px"><?php echo $l->t("Location");?>:</th>
 -                              <td>
 -                                      <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo isset($_['location']) ? htmlspecialchars($_['location']) : '' ?>" maxlength="100"  name="location" />
 -                              </td>
 -                      </tr>
 -              </table>
 -              <table>
 -                      <tr>
 -                              <th width="85px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th>
 -                              <td>
 -                                      <textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo isset($_['description']) ? htmlspecialchars($_['description']) : '' ?></textarea>
 -                              </td>
 -                      </tr>
 -              </table>
 -      </div>
 +</div>
 +<div id="tabs-3">//Alarm</div>
 +<div id="tabs-4">//Attendees</div>
 +<?php if($_['access'] == 'owner') { ?>
 +<div id="tabs-5">
 +      <?php echo $this->inc('share.dropdown'); ?>
 +</div>
- <?php } ?>
++<?php } ?>
Simple merge