diff options
Diffstat (limited to 'inc/poche/Database.class.php')
-rwxr-xr-x | inc/poche/Database.class.php | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 036c9d1b..ba2d1d94 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -229,12 +229,49 @@ class Database { | |||
229 | return FALSE; | 229 | return FALSE; |
230 | } | 230 | } |
231 | } | 231 | } |
232 | |||
233 | public function listUsers($username=null) { | ||
234 | $sql = 'SELECT count(*) FROM users'.( $username ? ' WHERE username=?' : ''); | ||
235 | $query = $this->executeQuery($sql, ( $username ? array($username) : array())); | ||
236 | list($count) = $query->fetch(); | ||
237 | return $count; | ||
238 | } | ||
239 | |||
240 | public function getUserPassword($userID) { | ||
241 | $sql = "SELECT * FROM users WHERE id=?"; | ||
242 | $query = $this->executeQuery($sql, array($userID)); | ||
243 | $password = $query->fetchAll(); | ||
244 | return isset($password[0]['password']) ? $password[0]['password'] : null; | ||
245 | } | ||
246 | |||
247 | public function deleteUserConfig($userID) { | ||
248 | $sql_action = 'DELETE from users_config WHERE user_id=?'; | ||
249 | $params_action = array($userID); | ||
250 | $query = $this->executeQuery($sql_action, $params_action); | ||
251 | return $query; | ||
252 | } | ||
253 | |||
254 | public function deleteTagsEntriesAndEntries($userID) { | ||
255 | $entries = $this->retrieveAll($userID); | ||
256 | foreach($entries as $entryid) { | ||
257 | $tags = $this->retrieveTagsByEntry($entryid); | ||
258 | foreach($tags as $tag) { | ||
259 | $this->removeTagForEntry($entryid,$tags); | ||
260 | } | ||
261 | $this->deleteById($entryid,$userID); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | public function deleteUser($userID) { | ||
266 | $sql_action = 'DELETE from users WHERE id=?'; | ||
267 | $params_action = array($userID); | ||
268 | $query = $this->executeQuery($sql_action, $params_action); | ||
269 | } | ||
232 | 270 | ||
233 | public function updateContentAndTitle($id, $title, $body, $user_id) { | 271 | public function updateContentAndTitle($id, $title, $body, $user_id) { |
234 | $sql_action = 'UPDATE entries SET content = ?, title = ? WHERE id=? AND user_id=?'; | 272 | $sql_action = 'UPDATE entries SET content = ?, title = ? WHERE id=? AND user_id=?'; |
235 | $params_action = array($body, $title, $id, $user_id); | 273 | $params_action = array($body, $title, $id, $user_id); |
236 | $query = $this->executeQuery($sql_action, $params_action); | 274 | $query = $this->executeQuery($sql_action, $params_action); |
237 | |||
238 | return $query; | 275 | return $query; |
239 | } | 276 | } |
240 | 277 | ||