summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-25 20:05:25 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-25 20:05:25 +0000
commit6fad03eb7a3ec3b2ef1c0737901bc46fcc35ca50 (patch)
tree1c482c62791f193cd616dbfd46f7578ddecff8c5 /src
parentedfefe3eeb90be3377590107a05b5e30174ff4c5 (diff)
downloadsemanticscuttle-6fad03eb7a3ec3b2ef1c0737901bc46fcc35ca50.tar.gz
semanticscuttle-6fad03eb7a3ec3b2ef1c0737901bc46fcc35ca50.tar.bz2
document attachlinkedtag
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@423 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src')
-rw-r--r--src/SemanticScuttle/Service/Tag2Tag.php43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/SemanticScuttle/Service/Tag2Tag.php b/src/SemanticScuttle/Service/Tag2Tag.php
index dcbcf2e..b78864a 100644
--- a/src/SemanticScuttle/Service/Tag2Tag.php
+++ b/src/SemanticScuttle/Service/Tag2Tag.php
@@ -24,24 +24,49 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$this->tablename = $GLOBALS['tableprefix'] .'tags2tags';
}
- function addLinkedTags($tag1, $tag2, $relationType, $uId) {
- $tagservice =SemanticScuttle_Service_Factory::get('Tag');
+ /**
+ * Add a tag-to-tag link relation
+ *
+ * @param string $tag1 First tag
+ * @param string $tag2 Second tag
+ * @param string $relationType Relation:
+ * "=" (both tags are equal)
+ * ">" (tag2 is part of tag1)
+ * @param integer $uId User ID
+ *
+ * @return boolean True when it was created, false in case of
+ * an error or when the link already existed.
+ */
+ public function addLinkedTags($tag1, $tag2, $relationType, $uId)
+ {
+ $tagservice = SemanticScuttle_Service_Factory::get('Tag');
$tag1 = $tagservice->normalize($tag1);
$tag2 = $tagservice->normalize($tag2);
- if($tag1 == $tag2 || strlen($tag1) == 0 || strlen($tag2) == 0
- || ($relationType != ">" && $relationType != "=")
- || !is_numeric($uId) || $uId<=0
- || ($this->existsLinkedTags($tag1, $tag2, $relationType, $uId))) {
+ if ($tag1 == $tag2 || strlen($tag1) == 0 || strlen($tag2) == 0
+ || ($relationType != '>' && $relationType != '=')
+ || !is_numeric($uId) || $uId<=0
+ || ($this->existsLinkedTags($tag1, $tag2, $relationType, $uId))
+ ) {
return false;
}
- $values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> $relationType, 'uId'=> $uId);
- $query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
+ $values = array(
+ 'tag1' => $tag1,
+ 'tag2' => $tag2,
+ 'relationType' => $relationType,
+ 'uId' => $uId
+ );
+ $query = 'INSERT INTO ' . $this->getTableName()
+ . ' ' . $this->db->sql_build_array('INSERT', $values);
+
//die($query);
if (!($dbresult = $this->db->sql_query($query))) {
$this->db->sql_transaction('rollback');
- message_die(GENERAL_ERROR, 'Could not attach tag to tag', '', __LINE__, __FILE__, $query, $this->db);
+ message_die(
+ GENERAL_ERROR, 'Could not attach tag to tag',
+ '', __LINE__, __FILE__, $query, $this->db
+ );
return false;
}
$this->db->sql_transaction('commit');