Esempio n. 1
0
 public static function get_user_logged_in()
 {
     if (isset($_SESSION['user'])) {
         $user_id = $_SESSION['user'];
         $user = Chef::find($user_id);
         return $user;
     }
     return null;
 }
 /**
  * @param $id
  * @return array
  */
 protected static function collect_content_for_show_recipe($id)
 {
     $recipe = Recipe::find($id);
     $comments = Comment::find_by_recipe_id($id);
     $commentators = array();
     foreach ($comments as $comment) {
         $commentators[$comment->chef_id] = Chef::find($comment->chef_id);
     }
     $ingredients = Ingredient::find_by_recipe_id($id);
     $keywords = Keyword::find_by_recipe_id($id);
     $chef = Chef::find($recipe->chef_id);
     $content = array('chef' => $chef, 'recipe' => $recipe, 'comments' => $comments, 'commentators' => $commentators, 'ingredients' => $ingredients, 'keywords' => $keywords);
     return $content;
 }
Esempio n. 3
0
 public static function toggle_admin_status($id)
 {
     $chef = Chef::find($id);
     if ($chef) {
         if ($chef->name == 'admin') {
             Redirect::to('/', array('Tältä ylläpitäjältä ei voi poistaa ylläpito-oikeuksia'));
         } else {
             $chef->toggle_admin_status();
             if ($chef->admin) {
                 Redirect::to('/chef/' . $id, array('message' => 'Käyttäjällä on nyt ylläpito-oikeudet'));
             } else {
                 Redirect::to('/chef/' . $id, array('message' => 'Käyttäjän oikeudet poistettu'));
             }
         }
     } else {
         Redirect::to('/', array('error' => 'Käyttäjää ei ole'));
     }
 }