Exemplo n.º 1
0
 /**
  * Store a newly created timeline in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Timeline::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Timeline::create($data);
     return Redirect::route('timelines.index');
 }
Exemplo n.º 2
0
 public function discuss($content, User $user)
 {
     $info = compact('content', 'user');
     $info['comment'] = $this;
     $d = Discuss::create($info);
     // generate activity
     $info = array('user' => $user, 'action' => 'discuss', 'object' => $this, 'link' => $d);
     $act = Activity::create($info);
     // inform all stack holders
     $info = array('activity' => $act, 'user' => $this->user);
     Timeline::create($info);
 }
Exemplo n.º 3
0
 public function comment($title, $content, User $user)
 {
     $c = parent::comment($title, $content, $user);
     // generate activity
     $info = array('user' => $user, 'action' => 'comment', 'object' => $this, 'link' => $c);
     $act = Activity::create($info);
     // inform all stack holders
     $users = Sdb::fetch('user', Comment::table(), array('teacher=?' => array($this->id)));
     $info = array('activity' => $act);
     foreach ($users as $u) {
         $info['user'] = $u;
         Timeline::create($info);
     }
 }
Exemplo n.º 4
0
/**
 * @author  ryan <*****@*****.**>
 */
function attitude($type)
{
    if (!$GLOBALS['has_login']) {
        return;
    }
    $class = camel2under($type);
    $map = array('like' => 1, 'hate' => 0);
    $target = _req('target');
    $action = _req('action');
    $info = array($type => $target, 'user' => $GLOBALS['user'], '`like`' => $map[$action]);
    $at = Attitude::create($info);
    if ($at) {
        $info = array('user' => $GLOBALS['user'], 'action' => $action, 'object' => $target);
        $act = Activity::create($info);
        // inform author
        $comment = new $class($target);
        $info = array('user' => $comment->user, 'activity' => $act);
        Timeline::create($info);
    }
    $o = new $class($target);
    echo $o->{$action . 'Count'}();
}