]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge branch 'master' of github.com:owncloud/core into vcategories_db
authorThomas Tanghus <thomas@tanghus.net>
Mon, 5 Nov 2012 11:06:59 +0000 (12:06 +0100)
committerThomas Tanghus <thomas@tanghus.net>
Mon, 5 Nov 2012 11:06:59 +0000 (12:06 +0100)
Conflicts:
lib/vcategories.php

1  2 
core/routes.php
lib/db.php
lib/vcategories.php

diff --cc core/routes.php
Simple merge
diff --cc lib/db.php
Simple merge
index 7032afd5fde41e85587d2d737f4e2c86532fad8f,46256def9c4e674b5a74c0dbbe1e0660d3ba7e46..bae9e3d03916b08a8b6981d304299db7422ace4a
@@@ -661,73 -173,33 +661,75 @@@ class OC_VCategories 
                if(!is_array($names)) {
                        $names = array($names);
                }
 -              OC_Log::write('core', 'OC_VCategories::delete, before: '.print_r($this->categories, true), OC_Log::DEBUG);
++
 +              OC_Log::write('core', __METHOD__ . ', before: '
 +                      . print_r($this->categories, true), OC_Log::DEBUG);
                foreach($names as $name) {
 -                      OC_Log::write('core', 'OC_VCategories::delete: '.$name, OC_Log::DEBUG);
 +                      $id = null;
 +                      OC_Log::write('core', __METHOD__.', '.$name, OC_Log::DEBUG);
                        if($this->hasCategory($name)) {
 -                              //OC_Log::write('core', 'OC_VCategories::delete: '.$name.' got it', OC_Log::DEBUG);
 -                              unset($this->categories[$this->array_searchi($name, $this->categories)]);
 +                              $id = $this->array_searchi($name, $this->categories);
 +                              unset($this->categories[$id]);
 +                      }
 +                      try {
 +                              $stmt = OCP\DB::prepare('DELETE FROM `' . self::CATEGORY_TABLE . '` WHERE '
 +                                      . '`uid` = ? AND `type` = ? AND `category` = ?');
 +                              $result = $stmt->execute(array($this->user, $this->type, $name));
 +                      } catch(Exception $e) {
 +                              OCP\Util::writeLog('core', __METHOD__ . ', exception: '
 +                                      . $e->getMessage(), OCP\Util::ERROR);
 +                      }
 +                      if(!is_null($id) && $id !== false) {
 +                              try {
 +                                      $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
 +                                                      . 'WHERE `categoryid` = ?';
 +                                      $stmt = OCP\DB::prepare($sql);
 +                                      $stmt->execute(array($id));
 +                              } catch(Exception $e) {
 +                                      OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
 +                                              OCP\Util::ERROR);
 +                                      return false;
 +                              }
                        }
                }
 -              $this->save();
 -              OC_Log::write('core', 'OC_VCategories::delete, after: '.print_r($this->categories, true), OC_Log::DEBUG);
 +              OC_Log::write('core', __METHOD__.', after: '
 +                      . print_r($this->categories, true), OC_Log::DEBUG);
                if(!is_null($objects)) {
                        foreach($objects as $key=>&$value) {
                                $vobject = OC_VObject::parse($value[1]);
                                if(!is_null($vobject)) {
 -                                      $categories = $vobject->getAsArray('CATEGORIES');
 -                                      //OC_Log::write('core', 'OC_VCategories::delete, before: '.$key.': '.print_r($categories, true), OC_Log::DEBUG);
 +                                      $object = null;
 +                                      $componentname = '';
 +                                      if (isset($vobject->VEVENT)) {
 +                                              $object = $vobject->VEVENT;
 +                                              $componentname = 'VEVENT';
 +                                      } else
 +                                      if (isset($vobject->VTODO)) {
 +                                              $object = $vobject->VTODO;
 +                                              $componentname = 'VTODO';
 +                                      } else
 +                                      if (isset($vobject->VJOURNAL)) {
 +                                              $object = $vobject->VJOURNAL;
 +                                              $componentname = 'VJOURNAL';
 +                                      } else {
 +                                              $object = $vobject;
 +                                      }
 +                                      $categories = $object->getAsArray('CATEGORIES');
                                        foreach($names as $name) {
                                                $idx = $this->array_searchi($name, $categories);
 -                                              //OC_Log::write('core', 'OC_VCategories::delete, loop: '.$name.', '.print_r($idx, true), OC_Log::DEBUG);
                                                if($idx !== false) {
 -                                                      OC_Log::write('core', 'OC_VCategories::delete, unsetting: '.$categories[$this->array_searchi($name, $categories)], OC_Log::DEBUG);
 +                                                      OC_Log::write('core', __METHOD__
 +                                                              .', unsetting: '
 +                                                              . $categories[$this->array_searchi($name, $categories)],
 +                                                              OC_Log::DEBUG);
                                                        unset($categories[$this->array_searchi($name, $categories)]);
 -                                                      //unset($categories[$idx]);
                                                }
                                        }
 -                                      //OC_Log::write('core', 'OC_VCategories::delete, after: '.$key.': '.print_r($categories, true), OC_Log::DEBUG);
 -                                      $vobject->setString('CATEGORIES', implode(',', $categories));
++
 +                                      $object->setString('CATEGORIES', implode(',', $categories));
 +                                      if($vobject !== $object) {
 +                                              $vobject[$componentname] = $object;
 +                                      }
                                        $value[1] = $vobject->serialize();
                                        $objects[$key] = $value;
                                } else {