aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php8
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php17
2 files changed, 21 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index de2eedcb..9097810c 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -51,15 +51,15 @@ class EntryController extends Controller
51 if ($form->isValid()) { 51 if ($form->isValid()) {
52 $existingEntry = $em 52 $existingEntry = $em
53 ->getRepository('WallabagCoreBundle:Entry') 53 ->getRepository('WallabagCoreBundle:Entry')
54 ->findOneByUrl($entry->getUrl()); 54 ->findOneByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
55 55
56 if (!is_null($existingEntry)) { 56 if (count($existingEntry) > 0) {
57 $this->get('session')->getFlashBag()->add( 57 $this->get('session')->getFlashBag()->add(
58 'notice', 58 'notice',
59 'Entry already saved on '.$existingEntry->getCreatedAt()->format('d-m-Y') 59 'Entry already saved on '.$existingEntry[0]->getCreatedAt()->format('d-m-Y')
60 ); 60 );
61 61
62 return $this->redirect($this->generateUrl('view', array('id' => $existingEntry->getId()))); 62 return $this->redirect($this->generateUrl('view', array('id' => $existingEntry[0]->getId())));
63 } 63 }
64 64
65 $this->updateEntry($entry); 65 $this->updateEntry($entry);
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index ca71970b..502e9da0 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -223,4 +223,21 @@ class EntryRepository extends EntityRepository
223 ->getQuery() 223 ->getQuery()
224 ->getResult(); 224 ->getResult();
225 } 225 }
226
227 /**
228 * Find an entry by its url and its owner.
229 *
230 * @param $url
231 * @param $userId
232 *
233 * @return array
234 */
235 public function findOneByUrlAndUserId($url, $userId)
236 {
237 return $this->createQueryBuilder('e')
238 ->where('e.url = :url')->setParameter('url', $url)
239 ->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
240 ->getQuery()
241 ->getResult();
242 }
226} 243}