Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Mar 18th, 2012  |  syntax: PHP  |  size: 0.98 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     public function flagComment() {
  2.         if (!$this->request->is('ajax')) {
  3.             $this->redirect('/');
  4.         } else {
  5.             $userId = $this->Session->read('Auth.User.id');
  6.             $this->autoRender = $this->layout = false;
  7.  
  8.             if (!empty($this->request->data)) {
  9.                 $commentId = $this->request->data['commentId'];
  10.  
  11.                 $this->CommentsFlag->set($this->data);
  12.                 $this->CommentsFlag->set('user_id', $userId);
  13.                 $this->CommentsFlag->set('comment_id', $commentId);
  14.  
  15.                 if (!$this->CommentsFlag->userAlreadyFlagged($userId, $commentId)) {
  16.                     if ($this->CommentsFlag->save($this->request->data)) {
  17.                         $message = array('response' => 'success');
  18.                     }
  19.                 } else {
  20.                     $message = array('response' => 'alreadyFlagged');
  21.                 }
  22.  
  23.                 return json_encode($message);
  24.             }
  25.         }
  26.     }