Esempio n. 1
0
 public function checkActive()
 {
     if (Session::get('active') !== 1) {
         header("Location: {$this->location}/");
         exit;
     }
 }
Esempio n. 2
0
 public function report($params)
 {
     $this->resetStatus();
     $inputs = array('height' => array('name' => 'height', 'required' => true, 'number' => true), 'weight' => array('name' => 'weight', 'required' => true, 'number' => true), 'neck' => array('name' => 'neck', 'required' => true, 'number' => true), 'waist' => array('name' => 'waist', 'required' => true, 'number' => true), 'extras' => array('name' => 'extras', 'alfanum' => true));
     Session::get('gender') == 2 ? $inputs['hip'] = array('required' => true, 'numeric' => true) : ($params['hip'] = '');
     $v = Validation::check($inputs);
     if ($v == false) {
         $this->status['errors'] = Flash::showMessages();
         $this->return_json($this->status);
         return false;
     } else {
         $r = new MfrUserReport();
         $r->last_updated = time();
         $r->user_id = Session::get('id');
         $r->height = $params['height'];
         $r->weight = $params['weight'];
         $r->neck_measurement = $params['neck'];
         $r->waist_measurement = $params['waist'];
         $r->waist_measurement = $params['waist'];
         $r->hip_measurement = $params['hip'];
         $r->waist_measurement = $params['waist'];
         $r->observations = $params['extras'];
         $r->save();
         $this->status['success'] = 'ok';
     }
     return $this->return_json($this->status);
 }
Esempio n. 3
0
 public function setSession($last_checked_message)
 {
     Session::set('last_chat_message', $last_checked_message);
     $u = new MfrUsers();
     $u->id = Session::get('id');
     $u->last_chat_message = $last_checked_message;
     $u->save();
 }
Esempio n. 4
0
 private static function setLanguage()
 {
     if (!Session::get('application-language')) {
         $lang = get_browser_language();
         # Set the language
         in_array($lang, Config::get('language')['allowed-languages']) ? Session::set('application-language', $lang) : Session::set('application-language', Config::get('language')['default-language']);
     }
     include_once ROOT . DS . 'app' . DS . 'languages' . DS . Session::get('application-language') . '.php';
     Lang::set($marianaFrameworkLanguageArray);
 }
 public function check_first_not_exists()
 {
     if (Session::get('level') < 2) {
         $r = $this->r();
         # Se estiver feito redireciona para inicio
         if ($r > 0) {
             header("location:javascript://history.go(-1)");
             die;
         }
     }
     return true;
 }
Esempio n. 6
0
 public function newRecipe()
 {
     $return = array();
     $return['success'] = 'fail';
     $return['errors'] = array();
     if (!isset($this->params['title']) || strlen($this->params['title']) < 10) {
         array_push($return['errors'], Lang::get('at-least-10-characters-title'));
     }
     if (!isset($this->params['question-body']) || strlen($this->params['question-body']) < 30) {
         array_push($return['errors'], Lang::get('at-least-30-characters-body'));
     }
     if (!isset($this->params['quantity']) || sizeof($this->params['quantity']) < 3) {
         array_push($return['errors'], Lang::get('at-least-3-ingredients'));
     }
     if (sizeof($return['errors']) > 0) {
         return $this->return_json($return);
     }
     // if everything passes:
     $user_id = Session::get('id');
     $thumbnail = '';
     if (isset($_FILES)) {
         $file = $_FILES['file'];
         $path = UPLOAD_PATH . DS . $user_id . DS;
         $u = new Framework\Upload\Upload();
         $thumbnail = $u->single($file, $path);
         $thumbnail = '/app/files/uploads/' . $user_id . '/' . $thumbnail;
     }
     $recipe = new MfrUserRecipes();
     $recipe->user_id = Session::get('id');
     $recipe->date_created = time();
     $recipe->last_updated = time();
     $recipe->name = $this->params['title'];
     $recipe->instructions = $this->params['question-body'];
     $recipe->lang = 'pt';
     $recipe->thumbnail = $thumbnail;
     $recipe_id = $recipe->saveGetId();
     foreach ($this->params['ingredient'] as $key => $value) {
         $ingredient = MfrAlimentos::where('name_pt', trim($value))->first();
         if (isset($ingredient->id) && $ingredient->id > 0) {
             $addIngredient = new MfrUserRecipesAlimentos();
             $addIngredient->recipe_id = $recipe_id;
             $addIngredient->alimento_id = $ingredient->id;
             $addIngredient->date_created = time();
             $addIngredient->last_updated = time();
             $addIngredient->save();
         }
     }
     $return['success'] = 'ok';
     return $this->return_json($return);
 }
 public static function getNewChatMessages($conversation_id)
 {
     $last_message = Session::get('last-chat-message');
     $messages = MfrChatMessages::where('conversation_id', $conversation_id)->also('id', '>', $last_message)->desc()->as_array()->get();
     $last_message = $messages[0]['id'];
     $messages = array_reverse($messages);
     $i = 0;
     foreach ($messages as $message) {
         $u = MfrUsers::find($message['user_id'])[0];
         if ($u->avatar == '' || ($u->avatar = null)) {
             $u->avatar = DEFAULT_IMAGE;
         }
         $messages[$i]['user-info'] = $u;
         $i++;
     }
     Session::set('last-chat-message', $last_message);
     return $messages;
 }
Esempio n. 8
0
 public static function getAnswer($id, $topic_id)
 {
     $user_id = Session::get('id');
     $sql = "\n        Select\n          DISTINCT (makefitreal.mfr_forum_answers.id),\n          makefitreal.mfr_forum_answers.topic_id as subject_id,\n          makefitreal.mfr_forum_answers.date_created,\n          makefitreal.mfr_forum_answers.last_updated,\n          makefitreal.mfr_forum_answers.content,\n          makefitreal.mfr_forum_answers.accepted,\n          makefitreal.mfr_forum_answers.user_id,\n          makefitreal.mfr_users.level,\n          makefitreal.mfr_users.avatar,\n          makefitreal.mfr_forum_likes.subject_id,\n          makefitreal.wp_users.ID As ID1,\n          makefitreal.mfr_forum_topics.user_id As owner_id,\n          (SELECT count(makefitreal.mfr_forum_likes.id) FROM makefitreal.mfr_forum_likes WHERE makefitreal.mfr_forum_likes.subject_id = :topicId AND makefitreal.mfr_forum_likes.type = 'answer') as likes,\n          (SELECT count(makefitreal.mfr_forum_likes.id) FROM makefitreal.mfr_forum_likes WHERE makefitreal.mfr_forum_likes.subject_id = :topicId AND makefitreal.mfr_forum_likes.type = 'answer' AND makefitreal.mfr_forum_likes.user_id = :sessionId ) as i_like,\n         makefitreal.wp_users.user_nicename\n        From\n          makefitreal.mfr_forum_likes ,\n          makefitreal.mfr_forum_answers\n          Inner Join\n          makefitreal.mfr_users\n            On makefitreal.mfr_forum_answers.user_id = makefitreal.mfr_users.id\n          Inner Join\n          makefitreal.wp_users\n            On makefitreal.mfr_users.id = makefitreal.wp_users.ID Inner Join\n          makefitreal.mfr_forum_topics\n            On makefitreal.mfr_forum_answers.topic_id = makefitreal.mfr_forum_topics.id\n        Where\n             makefitreal.mfr_forum_answers.id = :id";
     $stmt = Mariana\Framework\Database::getConnection()->prepare($sql);
     $stmt->bindParam(':sessionId', $user_id);
     $stmt->bindParam(':id', $id);
     $stmt->bindParam(':topicId', $topic_id);
     $stmt->execute();
     return $stmt->fetch(PDO::FETCH_ASSOC);
 }
Esempio n. 9
0
    <!-- Forum List Item template -->


    <script>
        // Render the last posts
        var $$scope2 = <?php 
echo json_encode($scope['topics']['topics']);
?>
;

        var Template = new Template();
        Template.render('forum-list','topics_container',$$scope2);

        var array_of_stuff = {
            user_id: '<?php 
echo \Mariana\Framework\Session\Session::get("id") ? \Mariana\Framework\Session\Session::get("id") : 0;
?>
',
            fail: '<?php 
echo $scope['navbar-stuff']['fail'];
?>
'
        };

        var Forum = new Forum('<?php 
echo COACHING_URL;
?>
',array_of_stuff);

        $('input[name="answer-filter"]').on('change',function(){
            filter();
Esempio n. 10
0
 public function myRecipes()
 {
     $scope = array('title' => 'Make Fit Real User Area', 'website' => $this->website, 'csrf' => $this->csrf, 'intro-title' => Lang::get('intro-title-diet'));
     $navbar_stuff = $this->navbar_stuff();
     $scope['navbar-stuff'] = $navbar_stuff['stuff'];
     $scope['navbar-links'] = $navbar_stuff['links'];
     $scope['coaching-status'] = MfrUsers::current_status();
     $scope['average-status']['kcals'] = $scope['coaching-status'][2]['value'] / 4;
     $scope['average-status']['protein'] = $scope['coaching-status'][3]['value'] / 4;
     $scope['average-status']['carbs'] = $scope['coaching-status'][4]['value'] / 4;
     $scope['average-status']['fat'] = $scope['coaching-status'][5]['value'] / 4;
     $scope['average-status']['macros'] = $scope['coaching-status'][6]['value'];
     $scope['recipes'] = MfrUserRecipes::allRecipes(Session::get('id'));
     View::render('coaching/user/diet/adapt-from-blog/index.php', $scope);
 }
Esempio n. 11
0
<!-- // RIGHT PANEL -->
<div class="col-lg-8">
    <?php 
foreach ($scope['recipes'] as $key => $value) {
    ?>
        <a class="undercover-a">
            <form class="login list-panel pointer" onclick="adaptRecipe(<?php 
    echo $value->id;
    ?>
)">
                <div class="row">
                    <div class="col-lg-8">
                        <h4 class="p-0-20 text-pink ">
                            <small  class="pull-right">
                                    <?php 
    if ($value->ID === \Mariana\Framework\Session\Session::get('id')) {
        echo '<i class="fa fa-times pink-text rotate-on-hover" onclick="deleteRecipe(event); " data-id="<?= $value->id ; ?>">   </i>';
    }
    ?>
                            </small><span class="text-capitalize-first">
                                <?php 
    echo $value->name;
    ?>
                            </span>
                        </h4>
                        <p><?php 
    echo mfr_excerpt($value->instructions, 250);
    ?>
</p>
                        <p>
                            <small class="pull-right pink-text">Clicar para adaptar.</small>
Esempio n. 12
0
 /**
  * Default method;
  */
 public function tracking($request = array())
 {
     $user_id = Session::get('id');
     $time = time();
     /**
     * @recieved:
     * POST http://localhost:8000/coaching/workout-tracking/
              array(4) {
                   ["workout-id"]=>string(1) "1"
                   ["workout-day"]=>string(1) "1"
                   ["weight"]=>array(3) {
                        [11]=>string(1) "0"
                        [1]=>string(1) "0"
                        [16]=>string(1) "0"
                   }
                   ["exercise-complete"]=>array(3) {
                        [11]=>string(5) "false"
                        [1]=>string(5) "false"
                        [16]=>string(5) "false"
                   }
              }
     * @objective: update into mfr-treinos-progresso if ( ['exercise-complete'][id] = "true"
     */
     foreach ($request['exercise-complete'] as $key => $pair) {
         $exercise_id = $key;
         if ($pair == 'true') {
             $sql = 'UPDATE `mfr_treinos_progresso`
                         SET `weight` = ?,
                         `last_updated` = ?,
                         `attempts` = 0
                         WHERE `mfr_treinos_progresso`.`user_id` = ?
                         AND `mfr_treinos_progresso`.`exercise_id` = ?
                         AND `mfr_treinos_progresso`.`workout_id` = ?;';
             $stmt = Database::getConnection()->prepare($sql);
             $stmt->bindParam(1, $request['weight'][$key]);
             $stmt->bindParam(2, $time);
             $stmt->bindParam(3, $user_id);
             $stmt->bindParam(4, $key);
             $stmt->bindParam(5, $request['workout-id']);
             $stmt->execute();
         }
         if ($pair == 'false') {
             if ($request['attempts'][$key] + 1 > 3) {
                 array_push($this->errors, Lang::get('maximum-attemps-at-exercise'));
                 (double) ($new_weight = (double) $request['weight'][$key] * 0.75);
                 $sql = 'UPDATE `mfr_treinos_progresso`
                         SET `weight` = ?,
                         `last_updated` = ?,
                         `attempts` = 0
                         WHERE `mfr_treinos_progresso`.`user_id` = ?
                         AND `mfr_treinos_progresso`.`exercise_id` = ?
                         AND `mfr_treinos_progresso`.`workout_id` = ?;';
                 $stmt = Database::getConnection()->prepare($sql);
                 $stmt->bindParam(1, $new_weight);
                 $stmt->bindParam(2, $time);
                 $stmt->bindParam(3, $user_id);
                 $stmt->bindParam(4, $key);
                 $stmt->bindParam(5, $request['workout-id']);
                 $stmt->execute();
             } else {
                 $attempts = $request['attempts'][$key] + 1;
                 $sql = 'UPDATE `mfr_treinos_progresso`
                         SET `last_updated` = ?,
                         `attempts` = ?
                         WHERE `user_id` = ?
                         AND `mfr_treinos_progresso`.`exercise_id` = ?
                         AND `workout_id` = ?;';
                 $stmt = Database::getConnection()->prepare($sql);
                 $stmt->bindParam(1, $time);
                 $stmt->bindParam(2, $attempts);
                 $stmt->bindParam(3, $user_id);
                 $stmt->bindParam(4, $key);
                 $stmt->bindParam(5, $request['workout-id']);
                 $stmt->execute();
             }
         }
     }
     echo json_encode(array('success' => 'ok', 'errors' => $this->errors));
 }
Esempio n. 13
0
                    &nbsp Favorito(s): &nbsp
                </div>
                {{ if ( this.accepted == 1){ }}
                <div style="width: 100%; text-align: center">
                    <b><i class="fa fa-check text-green fa-2x"></i></b>
                </div>
                {{ } }}
            </td>
            <td class="talk-it" style="padding:10px;">
                <small id="reply-content-{{ this.id }}">
                    {{ this.content }}
                </small>
                <footer style="display: inline-block; width:100%; margin-top:10px">
                    <span><small class="undercover-a pink-text pointer" onclick="editAnswer( {{this.id}})">Editar &nbsp&nbsp</small></span>
                     {{ if ( this.owner_id == <?php 
echo \Mariana\Framework\Session\Session::get('id');
?>
 || this.level > 1 ) { }}
                        <span><small class="undercover-a pink-text pointer" onclick="deleteAnswer( {{this.id}} )">Apagar &nbsp&nbsp</small></span>
                        <span><small class="undercover-a pink-text pointer" onclick="acceptAnswer({{ this.id }} , {{ this.subject_id }})">Aceitar resposta &nbsp&nbsp</small></span>
                    {{ } }}
                       <span><small class="undercover-a pink-text pointer "><a class="undercover-a" href="http://www.facebook.com/sharer.php?u=<?php 
echo COACHING_URL;
?>
/forum/topic/{{ this.subject_id }}"> Partilhar &nbsp&nbsp</a></small></span>

                </footer>
                <footer>
                    <div class="reply-author">
                        <p class="pull-right">{{ timeConverter(this.date_created) }}</p>
                        <table>
Esempio n. 14
0
 private function navbar_stuff()
 {
     Session::get('nice_name') ? $nice_name = Session::get('nice_name') : ($nice_name = Lang::get('guest'));
     Session::get('id') ? $logout = Lang::get('logout') : ($logout = Lang::get('sign-in'));
     switch (Session::get('level')) {
         case 1:
             // Make Fit Real Manager
             $links = $this->user_links;
             break;
         case 2:
             // Make Fit Real Coach
             $links = $this->coach_links;
             break;
         default:
             // Make Fit Real User
             $links = $this->manager_links;
     }
     return array('stuff' => array('welcome' => Lang::get('hello'), 'user_nice_name' => $nice_name, 'logout' => $logout, 'please-contact-admin' => Lang::get('please-contact-admin'), 'unable-to-preform-action' => Lang::get('unable-to-preform-action'), 'fail' => Lang::get('fail'), 'success' => Lang::get('success')), 'links' => $links);
 }
Esempio n. 15
0
 public static function user_files($user_id = false)
 {
     $user_id !== false ?: ($user_id = Session::get('id'));
     $files = MfrUserFiles::where('user_id', $user_id)->get();
     return $files;
 }