Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/tasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaimund Schlüßler <raimund.schluessler@googlemail.com>2015-02-01 19:42:27 +0300
committerRaimund Schlüßler <raimund.schluessler@googlemail.com>2015-02-01 19:42:27 +0300
commitc4eefaebf49fe418c717630c1ac62bbf3d52449c (patch)
tree01e7d969170eafe1bb56767a7747ea32f468fc2a /appinfo
parent5a8e0a79e796bf34c70d28621a7283bdf1fe330c (diff)
Update script for old comments
Diffstat (limited to 'appinfo')
-rw-r--r--appinfo/info.xml2
-rw-r--r--appinfo/update.php89
-rw-r--r--appinfo/version2
3 files changed, 91 insertions, 2 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml
index ef0f9ba2..aaf11aac 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -2,7 +2,7 @@
<info>
<id>tasks</id>
<name>Tasks</name>
- <version>0.5</version>
+ <version>0.5.1</version>
<licence>AGPL</licence>
<author>Raimund Schlüßler</author>
<require>6.0.0</require>
diff --git a/appinfo/update.php b/appinfo/update.php
new file mode 100644
index 00000000..7ab2e187
--- /dev/null
+++ b/appinfo/update.php
@@ -0,0 +1,89 @@
+<?php
+
+$installedVersionTasks=OCP\Config::getAppValue('tasks', 'installed_version');
+$installedVersionTasksEnhanced=OCP\Config::getAppValue('tasks_enhanced', 'installed_version');
+
+\OC::$CLASSPATH['OC_Calendar_Calendar'] = 'calendar/lib/calendar.php';
+\OC::$CLASSPATH['OC_Calendar_Object'] = 'calendar/lib/object.php';
+
+if ( version_compare($installedVersionTasksEnhanced, '0.4.1', '<=') && version_compare($installedVersionTasks, '0.5.0', '<=') ) {
+ try {
+
+ $stmt = \OCP\DB::prepare( 'SELECT * FROM `*PREFIX*clndr_calendars`');
+ $result = $stmt->execute();
+
+ $calendars = array();
+ while( $row = $result->fetchRow()) {
+ $calendars[] = $row;
+ }
+
+ foreach( $calendars as $calendar ) {
+ $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
+
+ foreach( $calendar_entries as $task ) {
+ if($task['objecttype']!='VTODO') {
+ continue;
+ }
+ $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;
+ }
+ elseif($element->name == 'UID') {
+ $uid = $element->value;
+ }
+ };
+ break;
+ }
+ }
+
+ $stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*clndr_objects` SET `objecttype`=?,`startdate`=?,`enddate`=?,`repeating`=?,`summary`=?,`calendardata`=?,`lastmodified`= ? WHERE `id` = ?' );
+ $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$taskId));
+
+ \OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']);
+ }
+ }
+ }
+ } catch (\Exception $e){
+
+ }
+} \ No newline at end of file
diff --git a/appinfo/version b/appinfo/version
index ea2303bc..5d4294b9 100644
--- a/appinfo/version
+++ b/appinfo/version
@@ -1 +1 @@
-0.5 \ No newline at end of file
+0.5.1 \ No newline at end of file