Beispiel #1
0
 public static function setComplete($vtodo, $percent_complete, $completed)
 {
     if (!empty($percent_complete)) {
         $vtodo->setString('PERCENT-COMPLETE', $percent_complete);
     } else {
         $vtodo->__unset('PERCENT-COMPLETE');
     }
     if ($percent_complete == 100) {
         if (!$completed) {
             $completed = 'now';
         }
     } else {
         $completed = null;
     }
     if ($completed) {
         $timezone = OC_Calendar_App::getTimezone();
         $timezone = new DateTimeZone($timezone);
         $completed = new DateTime($completed, $timezone);
         $vtodo->setDateTime('COMPLETED', $completed);
         OCP\Util::emitHook('OC_Task', 'taskCompleted', $vtodo);
     } else {
         unset($vtodo->COMPLETED);
     }
 }
Beispiel #2
0
 public static function moveToCalendar($id, $calendarid)
 {
     $calendar = OC_Calendar_Calendar::find($calendarid);
     if ($calendar['userid'] != OCP\User::getUser()) {
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $calendarid);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & OCP\PERMISSION_DELETE)) {
             throw new Exception(OC_Calendar_App::$l10n->t('You do not have the permissions to add events to this calendar.'));
         }
     }
     $stmt = OCP\DB::prepare('UPDATE `*PREFIX*clndr_objects` SET `calendarid`=? WHERE `id`=?');
     $stmt->execute(array($calendarid, $id));
     OC_Calendar_Calendar::touchCalendar($calendarid);
     OCP\Util::emitHook('OC_Calendar', 'moveEvent', $id);
     return true;
 }
 */
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
// Create default calendar ...
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1);
if (count($calendars) == 0) {
    OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), 'Default calendar');
    $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1);
}
$eventSources = array();
foreach ($calendars as $calendar) {
    $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
}
$eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'true');
$eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false');
OCP\Util::emitHook('OC_Calendar', 'getSources', array('sources' => &$eventSources));
$categories = OC_Calendar_App::getCategoryOptions();
//Fix currentview for fullcalendar
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "agendaWeek");
}
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "month");
}
if (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview") {
    OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "list");
}
OCP\Util::addscript('3rdparty/fullcalendar', 'fullcalendar');
OCP\Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
OCP\Util::addscript('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
Beispiel #4
0
 /**
  * @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_events') {
         $singleevents = OCP\Share::getItemsSharedWith('event', OC_Share_Backend_Event::FORMAT_EVENT);
         $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
         foreach ($singleevents as $singleevent) {
             // Skip this single event if the whole calendar is already shared with the user.
             $calendarShared = false;
             foreach ($calendars as $calendar) {
                 if ($singleevent['calendarid'] === $calendar['id']) {
                     $calendarShared = true;
                     break;
                 }
             }
             if ($calendarShared === true) {
                 continue;
             }
             $singleevent['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($singleevent['id']) . ')';
             $events[] = $singleevent;
         }
     } else {
         if (is_numeric($calendarid)) {
             $calendar = self::getCalendar($calendarid);
             OCP\Response::enableCaching(0);
             OCP\Response::setETagHeader($calendar['ctag']);
             $events = OC_Calendar_Object::allInPeriod($calendarid, $start, $end, $calendar['userid'] !== OCP\User::getUser());
         } else {
             OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events));
         }
     }
     return $events;
 }
 /**
  * @brief removes a calendar
  * @param integer $id
  * @return boolean
  */
 public static function deleteCalendar($id)
 {
     $calendar = self::find($id);
     if (!self::isAllowedToDeleteCalendar($calendar)) {
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $id);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & OCP\PERMISSION_DELETE)) {
             throw new Exception(OC_Calendar_App::$l10n->t('You do not have the permissions to delete this calendar.'));
         }
     }
     $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*clndr_calendars` WHERE `id` = ?');
     $stmt->execute(array($id));
     $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*clndr_objects` WHERE `calendarid` = ?');
     $stmt->execute(array($id));
     OCP\Share::unshareAll('calendar', $id);
     OCP\Util::emitHook('OC_Calendar', 'deleteCalendar', $id);
     if (OCP\USER::isLoggedIn() and count(self::allCalendars(OCP\USER::getUser())) == 0) {
         self::addDefaultCalendars(OCP\USER::getUser());
     }
     return true;
 }
Beispiel #6
0
 public function fopen($path, $mode)
 {
     if ($source = $this->getSourcePath($path)) {
         switch ($mode) {
             case 'r+':
             case 'rb+':
             case 'w+':
             case 'wb+':
             case 'x+':
             case 'xb+':
             case 'a+':
             case 'ab+':
             case 'w':
             case 'wb':
             case 'x':
             case 'xb':
             case 'a':
             case 'ab':
                 if (!$this->isUpdatable($path)) {
                     return false;
                 }
         }
         $info = array('target' => $this->sharedFolder . $path, 'source' => $source, 'mode' => $mode);
         OCP\Util::emitHook('OC_Filestorage_Shared', 'fopen', $info);
         $storage = OC_Filesystem::getStorage($source);
         return $storage->fopen($this->getInternalPath($source), $mode);
     }
     return false;
 }
 $vcalendar = \OC_VObject::parse($task['calendardata']);
 $vtodo = $vcalendar->VTODO;
 $children = $vtodo->children;
 $taskId = $task['id'];
 $comments = $vtodo->COMMENT;
 if ($comments) {
     foreach ($comments as $com) {
         $idx = 0;
         foreach ($children as $i => &$property) {
             if ($property->name == 'COMMENT' && $property['ID']->value == (int) $com['ID']->value) {
                 unset($vtodo->children[$idx]);
             }
             $idx += 1;
         }
         $vtodo->addProperty('COMMENT', $com->value, array('X-OC-ID' => (int) $com['ID']->value, 'X-OC-USERID' => $com['USERID']->value, 'X-OC-DATE-TIME' => $com['DATE-TIME']->value));
         OCP\Util::emitHook('OC_Calendar', 'editEvent', $taskId);
     }
     $data = $vcalendar->serialize();
     $oldobject = \OC_Calendar_Object::find($taskId);
     $object = \OC_VObject::parse($data);
     $type = 'VTODO';
     $startdate = null;
     $enddate = null;
     $summary = '';
     $repeating = 0;
     $uid = null;
     foreach ($object->children as $property) {
         if ($property->name == 'VTODO') {
             foreach ($property->children as &$element) {
                 if ($element->name == 'SUMMARY') {
                     $summary = $element->value;
Beispiel #8
0
 public static function getrequestedEvents($calendarid, $start, $end)
 {
     $events = array();
     if ($calendarid == 'shared_rw' || $calendarid == 'shared_r') {
         $calendars = OC_Calendar_Share::allSharedwithuser(OCP\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);
             foreach ($calendarevents as $event) {
                 $event['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($event['id']) . ')';
             }
             $events = array_merge($events, $calendarevents);
         }
         $singleevents = OC_Calendar_Share::allSharedwithuser(OCP\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']);
             if (!array_key_exists('summary', $event)) {
                 $event['summary'] = self::$l10n->t('unnamed');
             }
             $event['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($event['id']) . ')';
             $events[] = $event;
         }
     } else {
         if (is_numeric($calendarid)) {
             $calendar = self::getCalendar($calendarid);
             OCP\Response::enableCaching(0);
             OCP\Response::setETagHeader($calendar['ctag']);
             $events = OC_Calendar_Object::allInPeriod($calendarid, $start, $end);
         } else {
             OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events));
         }
     }
     return $events;
 }
Beispiel #9
0
 /**
  * @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_events') {
         $singleevents = OCP\Share::getItemsSharedWith('event', OC_Share_Backend_Event::FORMAT_EVENT);
         foreach ($singleevents as $singleevent) {
             $singleevent['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($singleevent['id']) . ')';
             $events[] = $singleevent;
         }
     } else {
         if (is_numeric($calendarid)) {
             $calendar = self::getCalendar($calendarid);
             OCP\Response::enableCaching(0);
             OCP\Response::setETagHeader($calendar['ctag']);
             $events = OC_Calendar_Object::allInPeriod($calendarid, $start, $end);
         } else {
             OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events));
         }
     }
     return $events;
 }
Beispiel #10
0
	/**
	* @method OC_Shorty_Hooks::registerClicks
	* @brief Hook offering informations about each click relayed by this app
	* @access public
	* @author Christian Reiner
	*/
	public static function registerClick ( $shorty, $request, $result )
	{
		OCP\Util::writeLog ( 'shorty', sprintf("Registering click to shorty '%s'",$shorty['id']), OCP\Util::DEBUG );
		// add result to details describing this request (click), important for emitting the event further down
		$request['result'] = $result;
		// save click in the database
		$param = array (
			'id'     => $shorty['id'],
			'time'   => $request['time'],
		);
		$query = OCP\DB::prepare ( OC_Shorty_Query::URL_CLICK );
		$query->execute ( $param );

		// allow further processing IF hooks are registered
		OCP\Util::emitHook( 'OC_Shorty', 'registerClick', array('shorty'=>$shorty,'request'=>$request) );
	} // function registerClick
Beispiel #11
0
		if (  (1==count($entries))
			&&(isset($entries[0]['id']))
			&&($p_id==$entries[0]['id']) )
			$entries[0]['relay']=OC_Shorty_Tools::relayUrl ( $entries[0]['id'] );
		else
			throw new OC_Shorty_Exception ( "failed to verify clicked shorty with id '%1s'", array($p_id) );
		$details['shorty'] = $entries[0];
		// now collect some info about the request
		$details['click'] = array (
			'address' => $_SERVER['REMOTE_ADDR'],
			'host'    => $_SERVER['REMOTE_HOST'],
			'time'    => $details['shorty']['accessed'],
			'user'    => OCP\User::getUser(),
		);
		// and off we go (IF any hooks were registered
		OCP\Util::emitHook( "OC_Shorty", "post_clickShorty", $details );

		// report result
		OCP\Util::writeLog( 'shorty', sprintf("Registered click of shorty with id '%s'.",$p_id), OCP\Util::DEBUG );
		OCP\JSON::success ( array (
			'data'    => array('id'=>$p_id),
			'level'   => 'info',
			'message' => OC_Shorty_L10n::t("Click registered") ) );
	}
	else
		throw new OC_Shorty_Exception ( "request failed: missing mandatory argument 'id'" );

	// swallow any accidential output generated by php notices and stuff to preserve a clean JSON reply structure
	OC_Shorty_Tools::ob_control ( FALSE );
} catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); }
?>