+
+ public function listUsers($username = NULL)
+ {
+ $sql = 'SELECT count(*) FROM users'.( $username ? ' WHERE username=?' : '');
+ $query = $this->executeQuery($sql, ( $username ? array($username) : array()));
+ list($count) = $query->fetch();
+ return $count;
+ }
+
+ public function getUserPassword($userID)
+ {
+ $sql = "SELECT * FROM users WHERE id=?";
+ $query = $this->executeQuery($sql, array($userID));
+ $password = $query->fetchAll();
+ return isset($password[0]['password']) ? $password[0]['password'] : null;
+ }
+
+ public function deleteUserConfig($userID)
+ {
+ $sql_action = 'DELETE from users_config WHERE user_id=?';
+ $params_action = array($userID);
+ $query = $this->executeQuery($sql_action, $params_action);
+ return $query;
+ }
+
+ public function deleteTagsEntriesAndEntries($userID)
+ {
+ $entries = $this->retrieveAll($userID);
+ foreach($entries as $entryid) {
+ $tags = $this->retrieveTagsByEntry($entryid);
+ foreach($tags as $tag) {
+ $this->removeTagForEntry($entryid,$tags);
+ }
+ $this->deleteById($entryid,$userID);
+ }
+ }
+
+ public function deleteUser($userID)
+ {
+ $sql_action = 'DELETE from users WHERE id=?';
+ $params_action = array($userID);
+ $query = $this->executeQuery($sql_action, $params_action);
+ }
+
+ public function updateContentAndTitle($id, $title, $body, $user_id)
+ {
+ $sql_action = 'UPDATE entries SET content = ?, title = ? WHERE id=? AND user_id=?';
+ $params_action = array($body, $title, $id, $user_id);
+ $query = $this->executeQuery($sql_action, $params_action);
+ return $query;
+ }
+
+ public function retrieveUnfetchedEntries($user_id, $limit)
+ {
+
+ $sql_limit = "LIMIT 0,".$limit;
+ if (STORAGE == 'postgres') {
+ $sql_limit = "LIMIT ".$limit." OFFSET 0";
+ }
+
+ $sql = "SELECT * FROM entries WHERE (content = '' OR content IS NULL) AND title LIKE '%Import%' AND user_id=? ORDER BY id " . $sql_limit;
+ $query = $this->executeQuery($sql, array($user_id));
+ $entries = $query->fetchAll();
+
+ return $entries;
+ }
+
+ public function retrieveUnfetchedEntriesCount($user_id)
+ {
+ $sql = "SELECT count(*) FROM entries WHERE (content = '' OR content IS NULL) AND title LIKE '%Import%' AND user_id=?";
+ $query = $this->executeQuery($sql, array($user_id));
+ list($count) = $query->fetch();
+
+ return $count;
+ }