aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rwxr-xr-xinc/poche/Database.class.php8
-rwxr-xr-xinc/poche/Poche.class.php11
-rw-r--r--inc/poche/global.inc.php2
3 files changed, 18 insertions, 3 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 5b51b507..6aad16c1 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -388,6 +388,14 @@ class Database {
388 public function getLastId($column = '') { 388 public function getLastId($column = '') {
389 return $this->getHandle()->lastInsertId($column); 389 return $this->getHandle()->lastInsertId($column);
390 } 390 }
391
392 public function search($term){
393 $search = '%'.$term.'%';
394 $query = $this->getHandle()->prepare("SELECT * FROM entries WHERE content LIKE ?");
395 $query->execute(array($search));
396 $entries = $query->fetchAll();
397 return $entries;
398 }
391 399
392 public function retrieveAllTags($user_id, $term = null) { 400 public function retrieveAllTags($user_id, $term = null) {
393 $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags 401 $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index b1143d0b..c7aa71e8 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -603,6 +603,14 @@ class Poche
603 'tags' => $tags, 603 'tags' => $tags,
604 ); 604 );
605 break; 605 break;
606
607 case 'search':
608 if (isset($_GET['search'])){
609 $search = $_GET['search'];
610 $tpl_vars['entries'] = $this->store->search($search);
611 $tpl_vars['nb_results'] = count($tpl_vars['entries']);
612 }
613 break;
606 case 'view': 614 case 'view':
607 $entry = $this->store->retrieveOneById($id, $this->user->getId()); 615 $entry = $this->store->retrieveOneById($id, $this->user->getId());
608 if ($entry != NULL) { 616 if ($entry != NULL) {
@@ -772,8 +780,7 @@ class Poche
772 $this->emptyCache(); 780 $this->emptyCache();
773 781
774 Tools::redirect('?view=config'); 782 Tools::redirect('?view=config');
775 } 783 }
776
777 /** 784 /**
778 * get credentials from differents sources 785 * get credentials from differents sources
779 * it redirects the user to the $referer link 786 * it redirects the user to the $referer link
diff --git a/inc/poche/global.inc.php b/inc/poche/global.inc.php
index d22b0588..15091387 100644
--- a/inc/poche/global.inc.php
+++ b/inc/poche/global.inc.php
@@ -38,7 +38,7 @@ if (! file_exists(ROOT . '/vendor/autoload.php')) {
38 require_once ROOT . '/vendor/autoload.php'; 38 require_once ROOT . '/vendor/autoload.php';
39} 39}
40 40
41# system configuration; database credentials et cetera 41# system configuration; database credentials et caetera
42if (! file_exists(INCLUDES . '/poche/config.inc.php')) { 42if (! file_exists(INCLUDES . '/poche/config.inc.php')) {
43 Poche::$configFileAvailable = false; 43 Poche::$configFileAvailable = false;
44} else { 44} else {