Esempio n. 1
0
 public function view($query)
 {
     $blog = new Blog();
     $params = array('blog' => $blog->find($query[0]));
     $this->setParams('params', $params);
     $this->render();
 }
Esempio n. 2
0
 public function index()
 {
     $Blog = new Blog($this->table_name, $this->action);
     $sql = $Blog->find('all');
     $blogs = mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
     return $blogs;
 }
Esempio n. 3
0
 /**
  * Add a new post
  *
  * @param Request $request
  * @param string $params
  * @return void
  */
 protected static function post($request, $params)
 {
     static::authorize($request);
     try {
         $data = array('categoryID' => $request->get('categoryID'), 'blogID' => Blog::find(array('id' => $request->user->id))->get('id'), 'title' => $request->get('title'), 'content' => $request->get('content'), 'created' => time());
         $post = new Post($data);
         static::response($post->save(), 201, '');
     } catch (Exception $e) {
         static::response(array(), 400, $e->getMessage());
     }
 }
Esempio n. 4
0
 public function update($id)
 {
     $blog = Blog::find($id);
     if (FEUsersHelper::isCurrentUser($blog->user->id)) {
         $blog->title = Input::get('title');
         $blog->content = Input::get('content');
         $blog->privacy = Input::get('privacy');
         $blog->save();
         FEEntriesHelper::updatePrivacy($blog->id, 2, $blog->privacy);
         return Redirect::back();
     } else {
         return Redirect::to('/');
     }
 }
Esempio n. 5
0
 /**
  * Update a blog
  *
  * @param Request $request
  * @param string $params
  * @return void
  */
 protected static function put($request, $params)
 {
     static::authorize($request);
     try {
         $blog = Blog::find(array('id' => $params));
         if ($blog->userID === $request->user->id) {
             $blog->set('name', $request->get('blogname'));
             static::response($blog->save(), 200, '');
         } else {
             static::response(array(), 403, 'No Permission');
         }
     } catch (Exception $e) {
         static::response(array(), 400, $e->getMessage());
     }
 }
Esempio n. 6
0
 /**
  * Log a user in
  *
  * @param Request $request
  * @param string $params
  * @return void
  */
 protected static function post($request, $params)
 {
     try {
         $user = User::find(array('username' => $request->get('username')));
         if (!is_a($user, 'User')) {
             static::response(array(), 400, 'No user found');
         } elseif (password_verify($request->get('password'), $user->get('password'))) {
             $user->blog = Blog::find(array('userID' => $user->id));
             static::response($user, 200);
         } else {
             static::response(array(), 400, 'Wrong password');
         }
     } catch (Exception $e) {
         static::response(array(), 500, $e->getMessage());
     }
 }
Esempio n. 7
0
 public function index()
 {
     if (!empty($this->request->data['Admin']['icon'])) {
         $this->_saveFavicon();
     }
     if (!empty($this->request->data['Admin']['export'])) {
         $this->SiteExport->_exportSite($this->request->data['Admin']['export']);
     }
     if (!empty($this->request->data['Upgrade']['all'])) {
         $this->SiteUpdate->_runUpdates();
         $this->set('runUpdates', true);
     }
     if (!empty($this->request->data['Update']['index'])) {
         $this->view = 'index_upgrade';
     }
     if (!empty($this->request->data['Alias']['update'])) {
         App::uses('Alias', 'Model');
         $Alias = new Alias();
         $this->set('syncd', $Alias->sync());
         $this->view = 'index_upgrade';
     }
     $complete = $this->Session->read('Updates.complete');
     if (!empty($complete)) {
         $this->Session->delete('Updates');
         $this->Session->setFlash(__('Update check complete!!!'), 'flash_success');
     }
     $this->set('title_for_layout', 'Admin Dashboard');
     $this->set('page_title_for_layout', 'Admin Dashboard');
     $this->layout = 'default';
     // this is here so we can show "Add Post" links foreach Blog on the dashboard
     if (CakePlugin::loaded('Blogs')) {
         App::uses('Blog', 'Blogs.Model');
         $Blog = new Blog();
         $this->set('blogs', $Blog->find('all'));
     }
 }
Esempio n. 8
0
 public function indexAction()
 {
     // view all blog posts
     $blog = new Blog($this->_db);
     $this->_template->posts = $blog->find();
 }
 public function hide_blog($id)
 {
     $blog = Blog::find($id);
     $blog->is_published = 0;
     $blog->save();
     return Redirect::to('/blogs')->with('message', $blog->topic . 'is successfully hidden');
 }
Esempio n. 10
0
 public function view($id)
 {
     // get our post, identified by the route
     // parameter
     $blog = Blog::find($id);
     $blog->views += 1;
     $blog->save();
     // show the full view, and pass the post
     // we just aquired
     return View::make('blog.view')->with('blog', $blog);
 }
Esempio n. 11
0
 public function deleteAction()
 {
     // make sure they own it
     $Blog = new Blog($this->_db, new User($this->_db, $_SESSION['user']['id']));
     $post = $Blog->find(array('id' => abs($_GET['id'])));
     if (empty($post[0]) || $post[0]['users_id'] != $_SESSION['user']['id']) {
         $this->_template->hud = array('class' => 'error', 'message' => 'You do not own this post!');
         return false;
     }
     if ($Blog->destroy($_GET['id'])) {
         $this->forward('index', array('class' => 'success', 'message' => 'The post was removed!'));
     } else {
         $this->_template->hud = array('class' => 'error', 'message' => 'There was a problem removing the post!');
     }
 }
Esempio n. 12
0
 /**
  * Remove the specified resource from storage.
  *
  * DELETE /{id}
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $res = Blog::find($id)->delete();
     $text = $res ? 'Запись удалена' : 'Запись не удалена';
     session()->flash('global', $text);
     return redirect('/blog');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function mostrarPost($id)
 {
     $bannersizquierda = Banner::where('seccion', '=', 'BLOG-IZQUIERDA')->where('habilitar', '=', '1')->orderBy('id', 'asc')->get();
     $bannersderecha = Banner::where('seccion', '=', 'BLOG-DERECHA')->where('habilitar', '=', '1')->orderBy('id', 'asc')->get();
     $bannersindexarriba = Banner::where('seccion', '=', 'INDEX-ARRIBA')->where('habilitar', '=', 1)->orderBy('id', 'asc')->get();
     $anuncios = Anuncio::all();
     $rolusuarioLogueado = '';
     $mailusuarioLogueado = '';
     $nombreusuarioLogueado = '';
     if (Auth::check()) {
         $authuser = Auth::user();
         $usu = Usuario::find($authuser->id);
         $mailusuarioLogueado = $authuser->email;
         $nombreusuarioLogueado = $authuser->nombre;
         $rolusuarioLogueado = DB::table('usuario_tiene_rol2')->where('usuario_id', '=', $authuser->id)->first();
         $rolusuarioLogueado = UsuarioRol::find($rolusuarioLogueado->rol_id)->rol;
     }
     $post = Blog::find($id);
     return View::make('index.blogPost')->with(array('bannersizquierda' => $bannersizquierda, 'bannersderecha' => $bannersderecha, 'post' => $post, 'anuncios' => $anuncios, 'username' => $mailusuarioLogueado, 'nameuser' => $nombreusuarioLogueado, 'roluser' => $rolusuarioLogueado, 'bannersindexarriba' => $bannersindexarriba));
     //
 }
 /**
  * Form for POST doDelete the specified resource.
  *
  * @return Response
  */
 public function doDelete()
 {
     $aData = Input::all();
     if (isset($aData['id'])) {
         $blog = Blog::find($aData['id']);
         $blog->delete();
         return Redirect::route('blog-list')->with('message', 'Блог успешно удален');
     }
     return Redirect::route('blog-list')->with('message', 'Произошла ошибка удаления');
 }