More trimming
This commit is contained in:
parent
200e9691de
commit
5ca181eb23
|
@ -179,6 +179,7 @@ class OC_VCategories {
|
||||||
if(is_numeric($category)) {
|
if(is_numeric($category)) {
|
||||||
$catid = $category;
|
$catid = $category;
|
||||||
} elseif(is_string($category)) {
|
} elseif(is_string($category)) {
|
||||||
|
$category = trim($category);
|
||||||
$catid = $this->array_searchi($category, $this->categories);
|
$catid = $this->array_searchi($category, $this->categories);
|
||||||
}
|
}
|
||||||
OCP\Util::writeLog('core', __METHOD__.', category: '.$catid.' '.$category, OCP\Util::DEBUG);
|
OCP\Util::writeLog('core', __METHOD__.', category: '.$catid.' '.$category, OCP\Util::DEBUG);
|
||||||
|
@ -240,6 +241,7 @@ class OC_VCategories {
|
||||||
if(is_numeric($category)) {
|
if(is_numeric($category)) {
|
||||||
$catid = $category;
|
$catid = $category;
|
||||||
} elseif(is_string($category)) {
|
} elseif(is_string($category)) {
|
||||||
|
$category = trim($category);
|
||||||
$catid = $this->array_searchi($category, $this->categories);
|
$catid = $this->array_searchi($category, $this->categories);
|
||||||
}
|
}
|
||||||
OCP\Util::writeLog('core', __METHOD__.', category: '.$catid.' '.$category, OCP\Util::DEBUG);
|
OCP\Util::writeLog('core', __METHOD__.', category: '.$catid.' '.$category, OCP\Util::DEBUG);
|
||||||
|
@ -301,6 +303,7 @@ class OC_VCategories {
|
||||||
* @returns int the id of the added category or false if it already exists.
|
* @returns int the id of the added category or false if it already exists.
|
||||||
*/
|
*/
|
||||||
public function add($name) {
|
public function add($name) {
|
||||||
|
$name = trim($name);
|
||||||
OCP\Util::writeLog('core', __METHOD__.', name: ' . $name, OCP\Util::DEBUG);
|
OCP\Util::writeLog('core', __METHOD__.', name: ' . $name, OCP\Util::DEBUG);
|
||||||
if($this->hasCategory($name)) {
|
if($this->hasCategory($name)) {
|
||||||
OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', OCP\Util::DEBUG);
|
OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', OCP\Util::DEBUG);
|
||||||
|
@ -331,6 +334,8 @@ class OC_VCategories {
|
||||||
* @returns bool
|
* @returns bool
|
||||||
*/
|
*/
|
||||||
public function rename($from, $to) {
|
public function rename($from, $to) {
|
||||||
|
$from = trim($from);
|
||||||
|
$to = trim($to);
|
||||||
$id = $this->array_searchi($from, $this->categories);
|
$id = $this->array_searchi($from, $this->categories);
|
||||||
if($id === false) {
|
if($id === false) {
|
||||||
OCP\Util::writeLog('core', __METHOD__.', category: ' . $from. ' does not exist', OCP\Util::DEBUG);
|
OCP\Util::writeLog('core', __METHOD__.', category: ' . $from. ' does not exist', OCP\Util::DEBUG);
|
||||||
|
@ -656,6 +661,7 @@ class OC_VCategories {
|
||||||
public function addToCategory($objid, $category, $type = null) {
|
public function addToCategory($objid, $category, $type = null) {
|
||||||
$type = is_null($type) ? $this->type : $type;
|
$type = is_null($type) ? $this->type : $type;
|
||||||
if(is_string($category) && !is_numeric($category)) {
|
if(is_string($category) && !is_numeric($category)) {
|
||||||
|
$category = trim($category);
|
||||||
if(!$this->hasCategory($category)) {
|
if(!$this->hasCategory($category)) {
|
||||||
$this->add($category, true);
|
$this->add($category, true);
|
||||||
}
|
}
|
||||||
|
@ -688,9 +694,13 @@ class OC_VCategories {
|
||||||
*/
|
*/
|
||||||
public function removeFromCategory($objid, $category, $type = null) {
|
public function removeFromCategory($objid, $category, $type = null) {
|
||||||
$type = is_null($type) ? $this->type : $type;
|
$type = is_null($type) ? $this->type : $type;
|
||||||
$categoryid = (is_string($category) && !is_numeric($category))
|
if(is_string($category) && !is_numeric($category)) {
|
||||||
? $this->array_searchi($category, $this->categories)
|
$category = trim($category);
|
||||||
: $category;
|
$categoryid = $this->array_searchi($category, $this->categories);
|
||||||
|
} else {
|
||||||
|
$categoryid = $category;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
|
$sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
|
||||||
. 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?';
|
. 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?';
|
||||||
|
@ -716,6 +726,8 @@ class OC_VCategories {
|
||||||
$names = array($names);
|
$names = array($names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$names = array_map('trim', $names);
|
||||||
|
|
||||||
OC_Log::write('core', __METHOD__ . ', before: '
|
OC_Log::write('core', __METHOD__ . ', before: '
|
||||||
. print_r($this->categories, true), OC_Log::DEBUG);
|
. print_r($this->categories, true), OC_Log::DEBUG);
|
||||||
foreach($names as $name) {
|
foreach($names as $name) {
|
||||||
|
|
Loading…
Reference in New Issue