public function testClear() { FlashMessage::set('Foo'); FlashMessage::clear(); $result = Session::read('FlashMessage.default', array('name' => 'flash_message')); $this->assertNull($result); FlashMessage::set('Foo 2', array(), 'TestKey'); FlashMessage::clear('TestKey'); $result = Session::read('FlashMessage.TestKey', array('name' => 'flash_message')); $this->assertNull($result); FlashMessage::set('Foo 3', array(), 'TestKey2'); FlashMessage::set('Foo 4', array(), 'TestKey3'); FlashMessage::clear(null); $result = Session::read('FlashMessage', array('name' => 'flash_message')); $this->assertNull($result); }
/** * Read a page (like "view()" but retrieves page data from the database). * Also, like other methods, extra data is bridged in from an optional associated page type library on the record itself. */ public function read($url=null) { // We can get the URL from the named parameter or from the arg passed if((isset($this->request->params['url'])) && (empty($url))) { $url = $this->request->params['url']; } $document = $this->getDocument(array( 'action' => __METHOD__, 'request' => $this->request, 'find_type' => 'first', 'conditions' => array('url' => $url) )); if(!$document) { FlashMessage::set('Page not found.', array('options' => array('type' => 'error', 'pnotify_title' => 'Error', 'pnotify_opacity' => '.8'))); $this->redirect(array('controller' => 'pages', 'action' => 'index')); } $this->set(compact('document')); }
public function logout() { Auth::clear('minerva_user'); FlashMessage::set('You\'ve successfully logged out.'); $this->redirect(array('action' => 'login')); }
/** * Generic delete() action. * The trick here is that $this->calling_class and $this->calling_method will hold a string * reference for which extended class called this delete() method. We need that in order to * get the proper records and access. */ public function delete() { // get the "_type" ... page_type, user_type, or block_type $model = Inflector::classify(Inflector::singularize($this->request->params['controller'])); $modelClass = 'minerva\models\\'.$model; $conditions = array(); if(isset($this->request->params['id'])) { $conditions = array('id' => $this->request->params['id']); } if(isset($this->request->params['url'])) { $conditions = array('url' => $this->request->params['url']); } if(empty($conditions)) { $this->redirect(array('controller' => $this->request->params['controller'], 'action' => 'index')); } $document = $this->getDocument(array( 'action' => __METHOD__, 'request' => $this->request, 'find_type' => 'first', 'conditions' => $conditions )); if($document->delete()) { FlashMessage::set('The content has been deleted.', array('options' => array('type' => 'success', 'pnotify_title' => 'Success', 'pnotify_opacity' => .8))); $this->redirect(array('controller' => $this->request->params['controller'], 'action' => 'index')); } else { FlashMessage::set('The content could not be deleted, please try again.', array('options' => array('type' => 'error', 'pnotify_title' => 'Error', 'pnotify_opacity' => .8))); $this->redirect(array('controller' => $this->request->params['controller'], 'action' => 'index')); } }