浏览代码

deprecate AutoLogin
use better (short) calls

Mark Scherer 10 年之前
父节点
当前提交
4c702220df

+ 1 - 0
Controller/Component/AutoLoginComponent.php

@@ -14,6 +14,7 @@ App::uses('Component', 'Controller');
  * @modified Mark Scherer - 2012-01-08 ms
  * @modified Mark Scherer - 2012-01-08 ms
  * - now works with Controller::beforeFilter() modifications to allow username/email login switch
  * - now works with Controller::beforeFilter() modifications to allow username/email login switch
  * - can be disabled dynamically and will skip on CakeError view
  * - can be disabled dynamically and will skip on CakeError view
+ *  @deprecated Use CookieAuthenticate from https://github.com/FriendsOfCake/Authenticate/
  */
  */
 class AutoLoginComponent extends Component {
 class AutoLoginComponent extends Component {
 
 

+ 2 - 2
Controller/Component/CalendarComponent.php

@@ -62,7 +62,7 @@ class CalendarComponent extends Component {
 		$current = date('Y');
 		$current = date('Y');
 
 
 		if (empty($month) || $year < $current - $span || $year > $current + $span) {
 		if (empty($month) || $year < $current - $span || $year > $current + $span) {
-			$this->Controller->Flash->message(__d('tools', 'invalid date'), 'error');
+			$this->Controller->Flash->error(__d('tools', 'invalid date'));
 			$this->Controller->redirect(['action' => 'index']);
 			$this->Controller->redirect(['action' => 'index']);
 		}
 		}
 
 
@@ -74,7 +74,7 @@ class CalendarComponent extends Component {
 		}
 		}
 
 
 		if ($month < 1 || $month > 12) {
 		if ($month < 1 || $month > 12) {
-			$this->Controller->Flash->message(__d('tools', 'invalid date'), 'error');
+			$this->Controller->Flash->error(__d('tools', 'invalid date'));
 			$this->Controller->redirect(['action' => 'index']);
 			$this->Controller->redirect(['action' => 'index']);
 		}
 		}
 		return true;
 		return true;

+ 5 - 5
Controller/QloginController.php

@@ -35,7 +35,7 @@ class QloginController extends ToolsAppController {
 		}
 		}
 
 
 		if (empty($entry)) {
 		if (empty($entry)) {
-			$this->Flash->message(__d('tools', 'Invalid Key'), 'error');
+			$this->Flash->error(__d('tools', 'Invalid Key'));
 			return $this->Common->autoRedirect($default);
 			return $this->Common->autoRedirect($default);
 		}
 		}
 
 
@@ -47,10 +47,10 @@ class QloginController extends ToolsAppController {
 			if ($this->Common->manualLogin($uid)) {
 			if ($this->Common->manualLogin($uid)) {
 				$this->Session->write('Auth.User.Login.qlogin', true);
 				$this->Session->write('Auth.User.Login.qlogin', true);
 				if (!Configure::read('Qlogin.suppressMessage')) {
 				if (!Configure::read('Qlogin.suppressMessage')) {
-					$this->Flash->message(__d('tools', 'You successfully logged in via qlogin'), 'success');
+					$this->Flash->success(__d('tools', 'You successfully logged in via qlogin'));
 				}
 				}
 			} else {
 			} else {
-				$this->Flash->message($this->Auth->loginError, 'error');
+				$this->Flash->error($this->Auth->loginError);
 				$url = $default;
 				$url = $default;
 				trigger_error($this->Auth->loginError . ' - uid ' . $uid);
 				trigger_error($this->Auth->loginError . ' - uid ' . $uid);
 			}
 			}
@@ -70,7 +70,7 @@ class QloginController extends ToolsAppController {
 			$this->Qlogin->set($this->request->data);
 			$this->Qlogin->set($this->request->data);
 			if ($this->Qlogin->validates()) {
 			if ($this->Qlogin->validates()) {
 				$id = $this->Qlogin->generate($this->Qlogin->data['Qlogin']['url'], $this->Qlogin->data['Qlogin']['user_id']);
 				$id = $this->Qlogin->generate($this->Qlogin->data['Qlogin']['url'], $this->Qlogin->data['Qlogin']['user_id']);
-				$this->Flash->message('New Key: ' . h($id), 'success');
+				$this->Flash->success('New Key: ' . h($id));
 				$url = $this->Qlogin->urlByKey($id);
 				$url = $this->Qlogin->urlByKey($id);
 				$this->set(compact('url'));
 				$this->set(compact('url'));
 				$this->request->data = [];
 				$this->request->data = [];
@@ -105,7 +105,7 @@ class QloginController extends ToolsAppController {
 		$this->request->allowMethod(['post', 'delete']);
 		$this->request->allowMethod(['post', 'delete']);
 		$this->Token = ClassRegistry::init('Tools.Token');
 		$this->Token = ClassRegistry::init('Tools.Token');
 		$this->Token->deleteAll(['type' => 'qlogin']);
 		$this->Token->deleteAll(['type' => 'qlogin']);
-		$this->Flash->message(__d('tools', 'Success'), 'success');
+		$this->Flash->success(__d('tools', 'Success'));
 		return $this->Common->autoRedirect(['action' => 'index']);
 		return $this->Common->autoRedirect(['action' => 'index']);
 	}
 	}
 
 

+ 10 - 10
Controller/QurlsController.php

@@ -32,7 +32,7 @@ class QurlsController extends ToolsAppController {
 		$url = $entry['Qurl']['url'];
 		$url = $entry['Qurl']['url'];
 
 
 		if ($note) {
 		if ($note) {
-			$this->Flash->message(nl2br($note), 'info');
+			$this->Flash->info(nl2br($note));
 		}
 		}
 		$this->Qurl->markAsUsed($entry['Qurl']['id']);
 		$this->Qurl->markAsUsed($entry['Qurl']['id']);
 		return $this->redirect($url);
 		return $this->redirect($url);
@@ -53,7 +53,7 @@ class QurlsController extends ToolsAppController {
 	public function admin_view($id = null) {
 	public function admin_view($id = null) {
 		$this->Qurl->recursive = 0;
 		$this->Qurl->recursive = 0;
 		if (empty($id) || !($qurl = $this->Qurl->find('first', ['conditions' => ['Qurl.id' => $id]]))) {
 		if (empty($id) || !($qurl = $this->Qurl->find('first', ['conditions' => ['Qurl.id' => $id]]))) {
-			$this->Flash->message(__('invalidRecord'), 'error');
+			$this->Flash->error(__('invalidRecord'));
 			return $this->Common->autoRedirect(['action' => 'index']);
 			return $this->Common->autoRedirect(['action' => 'index']);
 		}
 		}
 		$this->set(compact('qurl'));
 		$this->set(compact('qurl'));
@@ -69,10 +69,10 @@ class QurlsController extends ToolsAppController {
 			if ($res = $this->Qurl->save($this->request->data)) {
 			if ($res = $this->Qurl->save($this->request->data)) {
 				$var = $this->Qurl->urlByKey($res['Qurl']['key'], $res['Qurl']['title']);
 				$var = $this->Qurl->urlByKey($res['Qurl']['key'], $res['Qurl']['title']);
 
 
-				$this->Flash->message(__('Qurl: %s', $var), 'success');
+				$this->Flash->success(__('Qurl: %s', $var));
 				return $this->Common->postRedirect(['action' => 'index']);
 				return $this->Common->postRedirect(['action' => 'index']);
 			} else {
 			} else {
-				$this->Flash->message(__('formContainsErrors'), 'error');
+				$this->Flash->error(__('formContainsErrors'));
 			}
 			}
 		} else {
 		} else {
 			$this->request->data['Qurl']['active'] = 1;
 			$this->request->data['Qurl']['active'] = 1;
@@ -88,16 +88,16 @@ class QurlsController extends ToolsAppController {
 	 */
 	 */
 	public function admin_edit($id = null) {
 	public function admin_edit($id = null) {
 		if (empty($id) || !($qurl = $this->Qurl->find('first', ['conditions' => ['Qurl.id' => $id]]))) {
 		if (empty($id) || !($qurl = $this->Qurl->find('first', ['conditions' => ['Qurl.id' => $id]]))) {
-			$this->Flash->message(__('invalidRecord'), 'error');
+			$this->Flash->error(__('invalidRecord'));
 			return $this->Common->autoRedirect(['action' => 'index']);
 			return $this->Common->autoRedirect(['action' => 'index']);
 		}
 		}
 		if ($this->Common->isPosted()) {
 		if ($this->Common->isPosted()) {
 			if ($this->Qurl->save($this->request->data)) {
 			if ($this->Qurl->save($this->request->data)) {
 				$var = $this->request->data['Qurl']['key'];
 				$var = $this->request->data['Qurl']['key'];
-				$this->Flash->message(__('record edit %s saved', h($var)), 'success');
+				$this->Flash->success(__('record edit %s saved', h($var)));
 				return $this->Common->postRedirect(['action' => 'index']);
 				return $this->Common->postRedirect(['action' => 'index']);
 			} else {
 			} else {
-				$this->Flash->message(__('formContainsErrors'), 'error');
+				$this->Flash->error(__('formContainsErrors'));
 			}
 			}
 		}
 		}
 		if (empty($this->request->data)) {
 		if (empty($this->request->data)) {
@@ -111,16 +111,16 @@ class QurlsController extends ToolsAppController {
 	public function admin_delete($id = null) {
 	public function admin_delete($id = null) {
 		$this->request->allowMethod('post');
 		$this->request->allowMethod('post');
 		if (empty($id) || !($qurl = $this->Qurl->find('first', ['conditions' => ['Qurl.id' => $id], 'fields' => ['id', 'key']]))) {
 		if (empty($id) || !($qurl = $this->Qurl->find('first', ['conditions' => ['Qurl.id' => $id], 'fields' => ['id', 'key']]))) {
-			$this->Flash->message(__('invalidRecord'), 'error');
+			$this->Flash->error(__('invalidRecord'));
 			return $this->Common->autoRedirect(['action' => 'index']);
 			return $this->Common->autoRedirect(['action' => 'index']);
 		}
 		}
 		$var = $qurl['Qurl']['key'];
 		$var = $qurl['Qurl']['key'];
 
 
 		if ($this->Qurl->delete($id)) {
 		if ($this->Qurl->delete($id)) {
-			$this->Flash->message(__('record del %s done', h($var)), 'success');
+			$this->Flash->success(__('record del %s done', h($var)));
 			return $this->redirect(['action' => 'index']);
 			return $this->redirect(['action' => 'index']);
 		}
 		}
-		$this->Flash->message(__('record del %s not done exception', h($var)), 'error');
+		$this->Flash->error(__('record del %s not done exception', h($var)));
 		return $this->Common->autoRedirect(['action' => 'index']);
 		return $this->Common->autoRedirect(['action' => 'index']);
 	}
 	}
 
 

+ 2 - 2
Controller/TinyUrlsController.php

@@ -67,7 +67,7 @@ class TinyUrlsController extends ToolsAppController {
 			$this->TinyUrl->set($this->request->data);
 			$this->TinyUrl->set($this->request->data);
 			if ($this->TinyUrl->validates()) {
 			if ($this->TinyUrl->validates()) {
 				$id = $this->TinyUrl->generate($this->TinyUrl->data['TinyUrl']['url']);
 				$id = $this->TinyUrl->generate($this->TinyUrl->data['TinyUrl']['url']);
-				$this->Flash->message('New Key: ' . h($id), 'success');
+				$this->Flash->success('New Key: ' . h($id));
 				$url = $this->TinyUrl->urlByKey($id);
 				$url = $this->TinyUrl->urlByKey($id);
 				$this->set(compact('url'));
 				$this->set(compact('url'));
 				$this->request->data = [];
 				$this->request->data = [];
@@ -95,7 +95,7 @@ class TinyUrlsController extends ToolsAppController {
 	public function admin_reset() {
 	public function admin_reset() {
 		$this->request->allowMethod('post');
 		$this->request->allowMethod('post');
 		$this->TinyUrl->truncate();
 		$this->TinyUrl->truncate();
-		$this->Flash->message(__d('tools', 'Done'), 'success');
+		$this->Flash->success(__d('tools', 'Done'));
 		return $this->Common->autoRedirect(['action' => 'index']);
 		return $this->Common->autoRedirect(['action' => 'index']);
 	}
 	}