forked from wallabag/wallabag
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cdee5e6570 | |||
| 467503fb2a |
@ -411,12 +411,14 @@ class Database {
|
||||
|
||||
return $count;
|
||||
}
|
||||
public function getRandomId($row, $user_id) {
|
||||
$sql = "SELECT id FROM entries WHERE user_id=? LIMIT 1 OFFSET ? ";
|
||||
$params = array($user_id, $row);
|
||||
$query = $this->executeQuery($sql, $params);
|
||||
public function getRandomId($user_id) {
|
||||
$random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()';
|
||||
$sql = "SELECT id FROM entries WHERE user_id=? ORDER BY ". $random . " LIMIT 1";
|
||||
$params = array($user_id);
|
||||
$query = $this->executeQuery($sql, $params);
|
||||
$id = $query->fetchAll();
|
||||
|
||||
return $query->fetchAll();
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -393,13 +393,12 @@ class Poche
|
||||
|
||||
/* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
|
||||
case 'random':
|
||||
$count = $this->store->getEntriesByViewCount($view, $this->user->getId());
|
||||
$id_query = $this->store->getRandomId(rand(1,$count)-1, $this->user->getId());
|
||||
$id = $id_query[0];
|
||||
Tools::logm('get a random article');
|
||||
Tools::redirect('?view=view&id=' . $id[0]);
|
||||
|
||||
//$this->displayView('view', $id);
|
||||
if ($this->store->getRandomId($this->user->getId())) {
|
||||
$id = $this->store->getRandomId($this->user->getId())[0];
|
||||
Tools::redirect('?view=view&id=' . $id[0]);
|
||||
Tools::logm('got the article with id ' . $id[0]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@ -68,7 +68,7 @@ else if (isset($_POST['install'])) {
|
||||
|
||||
if ($_POST['db_engine'] == 'sqlite') {
|
||||
if (!copy('install/poche.sqlite', 'db/poche.sqlite')) {
|
||||
$errors[] = 'Impossible to create the SQLite database file.';
|
||||
$errors[] = 'Impossible to create the SQLite database file. Please check your file permissions.';
|
||||
}
|
||||
else {
|
||||
$db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite';
|
||||
@ -160,7 +160,7 @@ else if (isset($_POST['install'])) {
|
||||
|
||||
|
||||
if (!copy('inc/poche/config.inc.default.php', 'inc/poche/config.inc.php')) {
|
||||
$errors[] = 'Installation aborted, impossible to create inc/poche/config.inc.php file. Maybe you don\'t have write access to create it.';
|
||||
$errors[] = 'Installation aborted, impossible to create inc/poche/config.inc.php file. Maybe you don\'t have write access to create it. Check your file permissions.';
|
||||
} else {
|
||||
if ($_POST['db_engine'] != 'sqlite') {
|
||||
$content = str_replace("define ('STORAGE', 'sqlite');", "define ('STORAGE', '".$_POST['db_engine']."');", $content);
|
||||
@ -407,7 +407,7 @@ border: 1px solid #000;
|
||||
<div class='messages success install'>
|
||||
<p>
|
||||
<a href="index.php?clean=0">Click here to finish update.</a><br>
|
||||
If it fails, just delete the install directory.
|
||||
If it fails, check your file permissions or just delete the install directory.
|
||||
</p>
|
||||
<p>You may have to clear cache (by going into config screen) after update.</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user