Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-06-27 03:03:18 +0400
committerThomas Tanghus <thomas@tanghus.net>2012-06-27 03:03:53 +0400
commita25ae4b4b66e54e627912e5691f01da998f17029 (patch)
treecdb1022f67e39c0068ef29f4549b3a40ca2451e6 /lib/vcategories.php
parentf55f13eebc3c3f15e74a7026a058ffaa5079f0e3 (diff)
Make Categories a bit quieter.
Diffstat (limited to 'lib/vcategories.php')
-rw-r--r--lib/vcategories.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 1e79b62f0d6..8157c343868 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -55,7 +55,7 @@ class OC_VCategories {
$this->app = $app;
$this->user = is_null($user) ? OC_User::getUser() : $user;
$categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, ''));
- $this->categories = $categories != '' ? unserialize($categories) : $defcategories;
+ $this->categories = $categories != '' ? @unserialize($categories) : $defcategories;
}
/**
@@ -64,6 +64,9 @@ class OC_VCategories {
*/
public function categories() {
//OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG);
+ if(!$this->categories) {
+ return array();
+ }
usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys
return $this->categories;
}
@@ -203,11 +206,17 @@ class OC_VCategories {
// case-insensitive in_array
private function in_arrayi($needle, $haystack) {
+ if(!is_array($haystack)) {
+ return false;
+ }
return in_array(strtolower($needle), array_map('strtolower', $haystack));
}
// case-insensitive array_search
private function array_searchi($needle, $haystack) {
+ if(!is_array($haystack)) {
+ return false;
+ }
return array_search(strtolower($needle),array_map('strtolower',$haystack));
}