update.php 612 B

1234567891011121314151617
  1. <?php
  2. $installedVersion=OCP\Config::getAppValue('calendar', 'installed_version');
  3. if (version_compare($installedVersion, '0.2.1', '<')) {
  4. $stmt = OCP\DB::prepare( 'SELECT id, calendarcolor FROM *PREFIX*calendar_calendars WHERE calendarcolor IS NOT NULL' );
  5. $result = $stmt->execute();
  6. while( $row = $result->fetchRow()) {
  7. $id = $row['id'];
  8. $color = $row['calendarcolor'];
  9. if ($color[0] == '#' || strlen($color) < 6) {
  10. continue;
  11. }
  12. $color = '#' .$color;
  13. $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET calendarcolor=? WHERE id=?' );
  14. $r = $stmt->execute(array($color,$id));
  15. }
  16. }