lib/kolab_sync_backend.php lib/kolab_sync_data.php

Aleksander Machniak machniak at kolabsys.com
Thu Sep 20 14:23:37 CEST 2012


 lib/kolab_sync_backend.php |   17 -----------------
 lib/kolab_sync_data.php    |   15 ++++++---------
 2 files changed, 6 insertions(+), 26 deletions(-)

New commits:
commit 78a3a7cea01352ae2b840a15aad2532de820df1e
Author: Aleksander Machniak <alec at alec.pl>
Date:   Thu Sep 20 14:23:03 2012 +0200

    Clean up and simplify last commits

diff --git a/lib/kolab_sync_backend.php b/lib/kolab_sync_backend.php
index a8fc4f2..1950159 100644
--- a/lib/kolab_sync_backend.php
+++ b/lib/kolab_sync_backend.php
@@ -110,23 +110,6 @@ class kolab_sync_backend
         $this->storage->set_pagesize(999999);
     }
 
-    public static function default_type_id_for_type($type) {
-        if (!isset(self::$types[$type])) {
-            return $type;
-        }
-
-        $type_str = self::$types[$type];
-
-        $default_type_str = self::$types[$type] . ".default";
-
-        $default_type_id = array_search($default_type_str, self::$types);
-
-        if (!$default_type_id) {
-            return $type;
-        } else {
-            return $default_type_id;
-        }
-    }
 
     /**
      * List known devices
diff --git a/lib/kolab_sync_data.php b/lib/kolab_sync_data.php
index 0cdb25c..9b647f5 100644
--- a/lib/kolab_sync_data.php
+++ b/lib/kolab_sync_data.php
@@ -183,19 +183,18 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
      */
     public function getAllFolders()
     {
-        $_list = array();
         $list = array();
 
         // device supports multiple folders ?
         if (in_array(strtolower($this->device->devicetype), array('iphone', 'ipad', 'thundertine', 'windowsphone'))) {
             // get the folders the user has access to
-            $_list = $this->backend->folders_list($this->device->deviceid, $this->modelName);
+            $list = $this->backend->folders_list($this->device->deviceid, $this->modelName);
         }
         else if ($default = $this->getDefaultFolder()) {
-            $_list = array($default['serverId'] => $default);
+            $list = array($default['serverId'] => $default);
         }
 
-        foreach ($_list as $idx => $folder) {
+        foreach ($list as $idx => $folder) {
             $list[$idx] = new Syncroton_Model_Folder($folder);
         }
 
@@ -207,8 +206,6 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
      */
     protected function getDefaultFolder()
     {
-        $default = null;
-
         // Check if there's any folder configured for sync
         $folders = $this->backend->folders_list($this->device->deviceid, $this->modelName);
 
@@ -225,10 +222,10 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
 
         // Return first on the list if there's no default
         if (empty($default)) {
-            $keys = array_keys($folders);
-            $key = array_shift($keys);
+            $key     = array_shift(array_keys($folders));
             $default = $folders[$key];
-            $default['type'] = kolab_sync_backend::default_type_id_for_type($default['type']);
+            // make sure the type is default here
+            $default['type'] = $this->defaultFolderType;
         }
 
         // Remember real folder ID and set ID/name to root folder





More information about the commits mailing list