]> source.dussan.org Git - nextcloud-server.git/commitdiff
Load default categories if there are none,
authorThomas Tanghus <thomas@tanghus.net>
Wed, 27 Jun 2012 00:12:14 +0000 (02:12 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Wed, 27 Jun 2012 00:12:53 +0000 (02:12 +0200)
apps/contacts/lib/app.php

index 29428763d60b538796dff255a16bb10704755ec8..b3a7abd28bcea169c8a07accd4855a17fb0ed1e8 100644 (file)
@@ -10,7 +10,6 @@
  * This class manages our app actions
  */
 OC_Contacts_App::$l10n = OC_L10N::get('contacts');
-OC_Contacts_App::$categories = new OC_VCategories('contacts');
 class OC_Contacts_App {
        /*
         * @brief language object for calendar app
@@ -137,30 +136,54 @@ class OC_Contacts_App {
                }
        }
 
-       /*
+       /**
         * @brief returns the vcategories object of the user
         * @return (object) $vcategories
         */
        protected static function getVCategories() {
                if (is_null(self::$categories)) {
-                       self::$categories = new OC_VCategories('contacts');
+                       self::$categories = new OC_VCategories('contacts', null, self::getDefaultCategories());
                }
                return self::$categories;
        }
        
-       /*
+       /**
         * @brief returns the categories for the user
         * @return (Array) $categories
         */
        public static function getCategories() {
-               $categories = self::$categories->categories();
+               $categories = self::getVCategories()->categories();
                if(count($categories) == 0) {
                        self::scanCategories();
                        $categories = self::$categories->categories();
                }
-               return $categories;
+               return ($categories ? $categories : self::getDefaultCategories());
        }
 
+       /**
+        * @brief returns the default categories of ownCloud
+        * @return (array) $categories
+        */
+       protected static function getDefaultCategories(){
+               return array(
+                       (string)self::$l10n->t('Birthday'),
+                       (string)self::$l10n->t('Business'),
+                       (string)self::$l10n->t('Call'),
+                       (string)self::$l10n->t('Clients'),
+                       (string)self::$l10n->t('Deliverer'),
+                       (string)self::$l10n->t('Holidays'),
+                       (string)self::$l10n->t('Ideas'),
+                       (string)self::$l10n->t('Journey'),
+                       (string)self::$l10n->t('Jubilee'),
+                       (string)self::$l10n->t('Meeting'),
+                       (string)self::$l10n->t('Other'),
+                       (string)self::$l10n->t('Personal'),
+                       (string)self::$l10n->t('Projects'),
+                       (string)self::$l10n->t('Questions'),
+                       (string)self::$l10n->t('Work'),
+               );
+       }
+       
        /**
         * scan vcards for categories.
         * @param $vccontacts VCards to scan. null to check all vcards for the current user.