aboutsummaryrefslogtreecommitdiff
path: root/www/ajax/getcontacttags.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/ajax/getcontacttags.php')
-rw-r--r--www/ajax/getcontacttags.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/www/ajax/getcontacttags.php b/www/ajax/getcontacttags.php
new file mode 100644
index 0000000..d353226
--- /dev/null
+++ b/www/ajax/getcontacttags.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Return a json file with list of tags according to current user
+ * and sorted by popularity.
+ *
+ * The following GET parameters are accepted:
+ * @param string $beginsWith The tag name shall start with that string.
+ * No default.
+ * @param integer $limit Number of tags to return. Defaults to 1000
+ *
+ * Part of SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @author Eric Dane <ericdane@users.sourceforge.net>
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+
+$httpContentType = 'application/json';
+require_once '../www-header.php';
+
+$limit = 30;
+$beginsWith = null;
+$currentUserId = $userservice->getCurrentUserId();
+
+if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
+ $limit = (int)$_GET['limit'];
+}
+if (isset($_GET['beginsWith']) && strlen(trim($_GET['beginsWith']))) {
+ $beginsWith = trim($_GET['beginsWith']);
+}
+
+$listTags = SemanticScuttle_Service_Factory::get('Bookmark2Tag')->getContactTags(
+ $currentUserId, $limit, $currentUserId, null, $beginsWith
+);
+$tags = array();
+foreach ($listTags as $t) {
+ $tags[] = $t['tag'];
+}
+
+echo json_encode($tags);
+?>