Merge branch 'master' into calendar_dropimport

This commit is contained in:
Georg Ehrke 2012-05-13 19:12:35 +02:00
commit 6e9ed3791b
1 changed files with 10 additions and 6 deletions

View File

@ -96,7 +96,7 @@ class OC_VCategories {
} }
} }
if(count($newones) > 0) { if(count($newones) > 0) {
$this->categories = @array_merge($this->categories, $newones); $this->categories = array_merge($this->categories, $newones);
if($sync === true) { if($sync === true) {
$this->save(); $this->save();
} }
@ -146,10 +146,14 @@ class OC_VCategories {
* @brief Save the list with categories * @brief Save the list with categories
*/ */
private function save() { private function save() {
if(is_array($this->categories)) {
usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys
$escaped_categories = serialize($this->categories); $escaped_categories = serialize($this->categories);
OC_Log::write('core','OC_VCategories::save: '.print_r($this->categories, true), OC_Log::DEBUG);
OC_Preferences::setValue($this->user, $this->app, self::PREF_CATEGORIES_LABEL, $escaped_categories); OC_Preferences::setValue($this->user, $this->app, self::PREF_CATEGORIES_LABEL, $escaped_categories);
OC_Log::write('core','OC_VCategories::save: '.print_r($this->categories, true), OC_Log::DEBUG);
} else {
OC_Log::write('core','OC_VCategories::save: $this->categories is not an array! '.print_r($this->categories, true), OC_Log::ERROR);
}
} }
/** /**
@ -199,7 +203,7 @@ class OC_VCategories {
// case-insensitive in_array // case-insensitive in_array
private function in_arrayi($needle, $haystack) { private function in_arrayi($needle, $haystack) {
return in_array(strtolower($needle), @array_map('strtolower', $haystack)); return in_array(strtolower($needle), array_map('strtolower', $haystack));
} }
// case-insensitive array_search // case-insensitive array_search