summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Service
diff options
context:
space:
mode:
Diffstat (limited to 'src/SemanticScuttle/Service')
-rw-r--r--src/SemanticScuttle/Service/Tag2Tag.php45
-rw-r--r--src/SemanticScuttle/Service/User.php20
2 files changed, 52 insertions, 13 deletions
diff --git a/src/SemanticScuttle/Service/Tag2Tag.php b/src/SemanticScuttle/Service/Tag2Tag.php
index 8666209..33d211b 100644
--- a/src/SemanticScuttle/Service/Tag2Tag.php
+++ b/src/SemanticScuttle/Service/Tag2Tag.php
@@ -14,7 +14,7 @@
*/
/**
- * SemanticScuttle tag-to-tag service.
+ * SemanticScuttle tag-to-tag service which works with tag relations.
*
* @category Bookmarking
* @package SemanticScuttle
@@ -102,18 +102,49 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
return true;
}
- // Return linked tags just for admin users
- function getAdminLinkedTags($tag, $relationType, $inverseRelation = false, $stopList = array()) {
+
+
+ /**
+ * Same as getLinkedTags(), but only tags that have been created
+ * by admin users are returned.
+ *
+ * @param string $tag Tag to get related tags for
+ * @param string $relationType Type of tag-to-tag relation: >, < or =
+ * @param boolean $inverseRelation Reverse relation (parent -> child)
+ * @param array $stopList Array of tags that shall not be returned
+ *
+ * @return array Array of tag names
+ *
+ * @see getLinkedTags()
+ */
+ public function getAdminLinkedTags(
+ $tag, $relationType, $inverseRelation = false, $stopList = array()
+ ) {
// look for admin ids
$userservice = SemanticScuttle_Service_Factory :: get('User');
- $adminIds = $userservice->getAdminIds();
+ $adminIds = $userservice->getAdminIds();
//ask for their linked tags
- return $this->getLinkedTags($tag, $relationType, $adminIds, $inverseRelation, $stopList);
+ return $this->getLinkedTags(
+ $tag, $relationType, $adminIds, $inverseRelation, $stopList
+ );
}
- // Return the target linked tags. If inverseRelation is true, return the source linked tags.
- function getLinkedTags($tag, $relationType, $uId = null, $inverseRelation = false, $stopList = array()) {
+
+
+ /**
+ * Returns an array of tags that are in relation to the given $tag.
+ *
+ * @param string $tag Tag to get related tags for
+ * @param string $relationType Type of tag-to-tag relation: >, < or =
+ * @param boolean $inverseRelation Reverse relation (parent -> child)
+ * @param array $stopList Array of tags that shall not be returned
+ *
+ * @return array Array of tag names
+ */
+ public function getLinkedTags(
+ $tag, $relationType, $uId = null, $inverseRelation = false, $stopList = array()
+ ) {
// Set up the SQL query.
if($inverseRelation) {
$queriedTag = "tag1";
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php
index 091ea4d..9ef8430 100644
--- a/src/SemanticScuttle/Service/User.php
+++ b/src/SemanticScuttle/Service/User.php
@@ -203,18 +203,26 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
}
}
- /* Takes an numerical "id" or a string "username"
- and returns the numerical "id" if the user exists else returns NULL */
- function getIdFromUser($user) {
+ /**
+ * Obtains the ID of the given user name.
+ * If a user ID is passed, it is returned.
+ * In case the user does not exist, NULL is returned.
+ *
+ * @param string|integer $user User name or user ID
+ *
+ * @return integer NULL if not found or the user ID
+ */
+ public function getIdFromUser($user)
+ {
if (is_int($user)) {
return intval($user);
} else {
$objectUser = $this->getObjectUserByUsername($user);
- if($objectUser != NULL) {
+ if ($objectUser != null) {
return $objectUser->getId();
}
}
- return NULL;
+ return null;
}
/**
@@ -359,7 +367,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
return (int)$_SESSION[$this->getSessionKey()];
} else if (isset($_COOKIE[$this->getCookieKey()])) {
- $cook = split(':', $_COOKIE[$this->getCookieKey()]);
+ $cook = explode(':', $_COOKIE[$this->getCookieKey()]);
//cookie looks like this: 'id:md5(username+password)'
$query = 'SELECT * FROM '. $this->getTableName() .
' WHERE MD5(CONCAT('.$this->getFieldName('username') .