Пример #1
0
 /**
  * Star/unstar an entry
  *
  * @return  string
  */
 protected function starAction()
 {
     if (User::isGuest()) {
         return $this->loginAction();
     }
     if (User::get('id') != $this->member->get('id')) {
         App::abort(403, Lang::txt('PLG_MEMBERS_ACTIVITY_NOTAUTH'));
     }
     $id = Request::getInt('activity', 0);
     $no_html = Request::getInt('no_html', 0);
     $action = Request::getVar('action', 'star');
     $entry = Hubzero\Activity\Recipient::oneOrFail($id);
     $entry->set('starred', $action == 'star' ? 1 : 0);
     if (!$entry->save()) {
         $this->setError($entry->getError());
     }
     $success = $action == 'star' ? Lang::txt('PLG_MEMBERS_ACTIVITY_RECORD_STARRED') : Lang::txt('PLG_MEMBERS_ACTIVITY_RECORD_UNSTARRED');
     if ($no_html) {
         $response = new stdClass();
         $response->success = true;
         $response->message = $success;
         if ($err = $this->getError()) {
             $response->success = false;
             $response->message = $err;
         }
         ob_clean();
         header('Content-type: text/plain');
         echo json_encode($response);
         exit;
     }
     if ($err = $this->getError()) {
         Notify::error($err);
     } else {
         Notify::success($success);
     }
     // Redirect
     App::redirect(Route::url($this->member->link() . '&active=activity', false));
 }
Пример #2
0
 /**
  * Star/unstar an entry
  *
  * @return  string
  */
 protected function starAction()
 {
     $id = Request::getInt('activity', 0);
     $no_html = Request::getInt('no_html', 0);
     $action = Request::getVar('action', 'star');
     $entry = Hubzero\Activity\Recipient::oneOrFail($id);
     $entry->set('starred', $action == 'star' ? 1 : 0);
     if (!$entry->save()) {
         $this->setError($entry->getError());
     }
     $success = $action == 'star' ? Lang::txt('PLG_GROUPS_ACTIVITY_RECORD_STARRED') : Lang::txt('PLG_GROUPS_ACTIVITY_RECORD_UNSTARRED');
     if ($no_html) {
         $response = new stdClass();
         $response->success = true;
         $response->message = $success;
         if ($err = $this->getError()) {
             $response->success = false;
             $response->message = $err;
         }
         ob_clean();
         header('Content-type: text/plain');
         echo json_encode($response);
         exit;
     }
     if ($err = $this->getError()) {
         Notify::error($err);
     } else {
         Notify::success($success);
     }
     // Redirect
     App::redirect(Route::url($this->base . '&active=' . $this->_name, false));
 }