File modules/cms/action/object/ObjectBookmarkAction.class.php
Last commit: Sun Dec 8 20:56:47 2024 +0100 Jan Dankert New: Users are now able to store bookmarks.
1 <?php 2 namespace cms\action\object; 3 use cms\action\Method; 4 use cms\action\ObjectAction; 5 use cms\model\Bookmark; 6 use language\Messages; 7 8 class ObjectBookmarkAction extends ObjectAction implements Method { 9 10 public function view() { 11 12 $bookmark = new Bookmark(); 13 $bookmark->objectId = $this->baseObject->getId(); 14 $bookmark->userId = $this->currentUser->getId(); 15 $bookmark->load(); 16 17 $this->setTemplateVar( 'bookmark',$bookmark->isPersistent() ); 18 } 19 20 21 public function post() { 22 23 $bookmark = new Bookmark(); 24 $bookmark->objectId = $this->baseObject->getId(); 25 $bookmark->userId = $this->currentUser->getId(); 26 $bookmark->load(); 27 28 if ( $this->request->getRequiredNumber("bookmark") ) { 29 // Save the bookmark 30 $bookmark->persist(); 31 $this->addNoticeFor( $bookmark, Messages::SAVED); 32 } 33 else 34 // Delete it if it exists 35 if ( $bookmark->isPersistent() ) { 36 37 $bookmark->delete(); 38 $this->addNoticeFor( $bookmark, Messages::DELETED); 39 } 40 41 } 42 }
Downloadmodules/cms/action/object/ObjectBookmarkAction.class.php
History Sun, 8 Dec 2024 20:56:47 +0100 Jan Dankert New: Users are now able to store bookmarks.