Ejemplo n.º 1
0
 public function shareAction()
 {
     $request = $this->getRequest();
     $post_id = $request->getParam('post_id');
     $user_id = get_user_id();
     $share_mapper = new Application_Model_ShareMapper();
     $is_shared = $share_mapper->share($user_id, $post_id);
     if ($is_shared) {
         $notification_mapper = new Application_Model_NotificationMapper();
         $notification_model = new Application_Model_Notification();
         $post_mapper = new Application_Model_PostMapper();
         $post = $post_mapper->find($post_id);
         $notification_model->_fields['user_id'] = $post['user_id'];
         $notification_model->_fields['is_seen'] = 0;
         $notification_model->_fields['content'] = get_username() . " Likes your post with id = {$post_id}";
         $notification_mapper->save($notification_model);
     }
     $this->_redirect('/post/home');
 }