/** * @brief Creates a category/object relation. * @param int $objid The id of the object * @param int|string $category The id or name of the category * @param string $type The type of object (event/contact/task/journal). * Defaults to the type set in the instance * @returns boolean Returns false on database error. */ public function addToCategory($objid, $category, $type = null) { $type = is_null($type) ? $this->type : $type; if (is_string($category) && !is_numeric($category)) { if (!$this->hasCategory($category)) { $this->add($category, true); } $categoryid = $this->array_searchi($category, $this->categories); } else { $categoryid = $category; } try { OCP\DB::insertIfNotExist(self::RELATION_TABLE, array('objid' => $objid, 'categoryid' => $categoryid, 'type' => $type)); } catch (Exception $e) { OCP\Util::writeLog('core', __METHOD__ . ', exception: ' . $e->getMessage(), OCP\Util::ERROR); return false; } return true; }