From: Thomas Tanghus Date: Wed, 27 Jun 2012 00:12:14 +0000 (+0200) Subject: Load default categories if there are none, X-Git-Tag: v4.5.0beta1~74^2~402^2~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3edc40a68a7cf576d7197328e57c001d1667ae39;p=nextcloud-server.git Load default categories if there are none, --- diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index 29428763d60..b3a7abd28bc 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -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.