summaryrefslogtreecommitdiffstats
path: root/lib/vcategories.php
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-10-20 13:45:18 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-10-20 13:45:18 +0200
commit26618704a924723505be7b723e90c63055017658 (patch)
treef70f4bc3ca8965fa01cb002b95740a7484d0deae /lib/vcategories.php
parentab167c3e2c55895fddac50cd1c9d8d5d92b10845 (diff)
downloadnextcloud-server-26618704a924723505be7b723e90c63055017658.tar.gz
nextcloud-server-26618704a924723505be7b723e90c63055017658.zip
Fix accidentally creating new categories with the id as name.
Diffstat (limited to 'lib/vcategories.php')
-rw-r--r--lib/vcategories.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 2ea70d167fd..c220821ecae 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -149,7 +149,7 @@ class OC_VCategories {
}
return $catmap;
}
-
+
// Don't add favorites to normal categories.
$favpos = array_search(self::CATEGORY_FAVORITE, $categories);
if($favpos !== false) {
@@ -569,12 +569,14 @@ class OC_VCategories {
*/
public function addToCategory($objid, $category, $type = null) {
$type = is_null($type) ? $this->type : $type;
- if(is_string($category) && !$this->hasCategory($category)) {
- $this->add($category, true);
+ if(is_string($category) && !is_numeric($category)) {
+ if(!$this->hasCategory($category)) {
+ $this->add($category, true);
+ }
+ $categoryid = $this->array_searchi($category, self::$categories);
+ } else {
+ $categoryid = $category;
}
- $categoryid = (is_string($category) && !is_numeric($category))
- ? $this->array_searchi($category, self::$categories)
- : $category;
try {
OCP\DB::insertIfNotExist(self::RELATION_TABLE,
array(
@@ -711,3 +713,4 @@ class OC_VCategories {
}
}
+