These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * ownCloud - Tasks |
||
4 | * |
||
5 | * @author Raimund Schlüßler |
||
6 | * @copyright 2015 Raimund Schlüßler [email protected] |
||
7 | * |
||
8 | * This library is free software; you can redistribute it and/or |
||
9 | * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||
10 | * License as published by the Free Software Foundation; either |
||
11 | * version 3 of the License, or any later version. |
||
12 | * |
||
13 | * This library is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Affero General Public |
||
19 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||
20 | * |
||
21 | */ |
||
22 | |||
23 | $installedVersionTasks=OCP\Config::getAppValue('tasks', 'installed_version'); |
||
24 | $installedVersionTasksEnhanced=OCP\Config::getAppValue('tasks_enhanced', 'installed_version'); |
||
25 | |||
26 | \OC::$CLASSPATH['OC_Calendar_Calendar'] = 'calendar/lib/calendar.php'; |
||
27 | \OC::$CLASSPATH['OC_Calendar_Object'] = 'calendar/lib/object.php'; |
||
28 | |||
29 | if ( version_compare($installedVersionTasksEnhanced, '0.4.1', '<=') && version_compare($installedVersionTasks, '0.5.0', '<=') ) { |
||
30 | try { |
||
31 | |||
32 | $stmt = \OCP\DB::prepare( 'SELECT * FROM `*PREFIX*clndr_calendars`'); |
||
33 | $result = $stmt->execute(); |
||
34 | |||
35 | $calendars = array(); |
||
36 | while( $row = $result->fetchRow()) { |
||
37 | $calendars[] = $row; |
||
38 | } |
||
39 | |||
40 | foreach( $calendars as $calendar ) { |
||
41 | $calendar_entries = \OC_Calendar_Object::all($calendar['id']); |
||
42 | |||
43 | foreach( $calendar_entries as $task ) { |
||
44 | if($task['objecttype']!='VTODO') { |
||
45 | continue; |
||
46 | } |
||
47 | $vcalendar = \Sabre\VObject\Reader::read($task['calendardata']); |
||
48 | $vtodo = $vcalendar->VTODO; |
||
49 | $children = $vtodo->children; |
||
50 | $taskId = $task['id']; |
||
51 | |||
52 | $comments = $vtodo->COMMENT; |
||
53 | if($comments){ |
||
54 | foreach($comments as $com) { |
||
55 | |||
56 | $idx = 0; |
||
57 | foreach ($children as $i => &$property) { |
||
58 | if ( $property['ID'] && $com['ID']) { |
||
59 | if ( $property->name == 'COMMENT' && $property['ID']->getValue() == (int)$com['ID']->getValue() ) { |
||
60 | unset($vtodo->children[$idx]); |
||
61 | } |
||
62 | } |
||
63 | $idx += 1; |
||
64 | } |
||
65 | if ( $com['ID'] && $com['USERID'] && $com['DATE-TIME'] ) { |
||
66 | $vtodo->add('COMMENT',$com->getValue(), |
||
67 | array( |
||
68 | 'X-OC-ID' => (int)$com['ID']->getValue(), |
||
69 | 'X-OC-USERID' => $com['USERID']->getValue(), |
||
70 | 'X-OC-DATE-TIME' => $com['DATE-TIME']->getValue() |
||
71 | ) |
||
72 | ); |
||
73 | } |
||
74 | OCP\Util::emitHook('OC_Calendar', 'editEvent', $taskId); |
||
75 | } |
||
76 | $data = $vcalendar->serialize(); |
||
77 | $oldobject = \OC_Calendar_Object::find($taskId); |
||
78 | |||
79 | $object = \Sabre\VObject\Reader::read($data); |
||
80 | |||
81 | $type = 'VTODO'; |
||
82 | $startdate = null; |
||
83 | $enddate = null; |
||
84 | $summary = ''; |
||
85 | $repeating = 0; |
||
86 | $uid = null; |
||
87 | |||
88 | foreach($object->children as $property) { |
||
89 | if($property->name == 'VTODO') { |
||
90 | foreach($property->children as &$element) { |
||
91 | if($element->name == 'SUMMARY') { |
||
92 | $summary = $element->getValue(); |
||
93 | } |
||
94 | elseif($element->name == 'UID') { |
||
95 | $uid = $element->getValue(); |
||
96 | } |
||
97 | }; |
||
98 | break; |
||
99 | } |
||
100 | } |
||
101 | |||
102 | $stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*clndr_objects` SET `objecttype`=?,`startdate`=?,`enddate`=?,`repeating`=?,`summary`=?,`calendardata`=?,`lastmodified`= ? WHERE `id` = ?' ); |
||
103 | $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$taskId)); |
||
104 | |||
105 | \OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | } catch (\Exception $e){ |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
Loading history...
|
|||
110 | |||
111 | } |
||
112 | } |
||
113 |