Fix accidentally creating new categories with the id as name.

This commit is contained in:
Thomas Tanghus 2012-10-20 13:45:18 +02:00
parent ab167c3e2c
commit 26618704a9
1 changed files with 9 additions and 6 deletions

View File

@ -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 {
}
}