Esempio n. 1
0
 function getTags($id = null)
 {
     require_once ROOT_DIR . '/sys/LocalEnrichment/UserTag.php';
     $tagList = array();
     $sql = "SELECT id, groupedRecordPermanentId, tag, COUNT(groupedRecordPermanentId) AS cnt " . "FROM user_tags WHERE " . "userId = '{$this->id}' ";
     $sql .= "GROUP BY tag ORDER BY tag ASC";
     $tag = new UserTag();
     $tag->query($sql);
     if ($tag->N) {
         while ($tag->fetch()) {
             $tagList[] = clone $tag;
         }
     }
     return $tagList;
 }
Esempio n. 2
0
 /**
  * Process a search for a particular tag.
  *
  * @access  private
  * @param   string  $lookfor    The tag to search for
  * @return  array   A revised searchTerms array to get matching Solr records
  *                  (empty if no tag matches found).
  */
 private function processTagSearch($lookfor)
 {
     // Include the app database objects
     require_once ROOT_DIR . '/sys/LocalEnrichment/UserTag.php';
     require_once ROOT_DIR . '/sys/Grouping/GroupedWork.php';
     // Find our tag in the database
     $tag = new UserTag();
     $tag->tag = $lookfor;
     $tag->selectAdd(null);
     $tag->selectAdd('DISTINCT(groupedRecordPermanentId) as groupedRecordPermanentId');
     $newSearch = array();
     $newSearch[0] = array('join' => 'OR', 'group' => array());
     $tag->find();
     while ($tag->fetch()) {
         // Grab the list of records tagged with this tag
         $id = $tag->groupedRecordPermanentId;
         $newSearch[0]['group'][] = array('field' => 'id', 'lookfor' => $id, 'bool' => 'OR');
     }
     return $newSearch;
 }
Esempio n. 3
0
 function removeTag()
 {
     global $user;
     if ($user === false) {
         return json_encode(array('success' => false, 'message' => 'Sorry, you must be logged in to remove tags.'));
     }
     require_once ROOT_DIR . '/sys/LocalEnrichment/UserTag.php';
     $id = $_REQUEST['id'];
     $tag = $_REQUEST['tag'];
     $userTag = new UserTag();
     $userTag->tag = $tag;
     $userTag->userId = $user->id;
     $userTag->groupedRecordPermanentId = $id;
     if ($userTag->find(true)) {
         //This is a new tag
         $userTag->delete();
         return json_encode(array('success' => true, 'message' => 'Removed your tag from the title.  Refresh to view updated tag list.'));
     } else {
         //This tag has already been added
         return json_encode(array('success' => true, 'message' => 'We could not find that tag for this record.'));
     }
 }
 public function getTags()
 {
     global $user;
     /** @var UserTag[] $tags */
     $tags = array();
     require_once ROOT_DIR . '/sys/LocalEnrichment/UserTag.php';
     $userTags = new UserTag();
     $userTags->groupedRecordPermanentId = $this->getPermanentId();
     $userTags->find();
     while ($userTags->fetch()) {
         if (!isset($tags[$userTags->tag])) {
             $tags[$userTags->tag] = clone $userTags;
             $tags[$userTags->tag]->userAddedThis = false;
         }
         $tags[$userTags->tag]->cnt++;
         if (!$user) {
             return false;
         } else {
             if ($user->id == $tags[$userTags->tag]->userId) {
                 $tags[$userTags->tag]->userAddedThis = true;
             }
         }
     }
     return $tags;
 }
Esempio n. 5
0
 function removeTag()
 {
     global $user;
     $tagToRemove = $_REQUEST['tag'];
     require_once ROOT_DIR . '/sys/LocalEnrichment/UserTag.php';
     $userTag = new UserTag();
     $userTag->tag = $tagToRemove;
     $userTag->userId = $user->id;
     $numDeleted = $userTag->delete();
     $result = array('result' => true, 'message' => "Removed tag '{$tagToRemove}' from {$numDeleted} titles.");
     return $result;
 }