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(); }
public function first_report($params = array()) { $this->resetStatus(); $inputs = array('objective' => array('name' => 'objective', 'required' => true, 'number' => true), 'gender' => array('name' => 'gender', 'required' => true, 'number' => 3), '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), 'improvaments' => array('name' => 'improvements', 'alfanum' => true), 'extras' => array('name' => 'extras', 'alfanum' => true)); if ($_POST['gender'] == 2) { $inputs['hip'] = array('required' => true, 'numeric' => true); } $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(); $u = new MfrUsers(); $u->id = Session::get('id'); $u->gender = $params['gender']; $u->last_updated = time(); $u->objective = $params['objective']; $u->weak_points = $params['improvements']; $u->other_requirements = $params['extras']; $u->save(); Session::set('gender', $params['gender']); $this->status['success'] = 'ok'; } return $this->return_json($this->status); }
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; }
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); }
public function signup($params = array()) { # Requirements $this->load(); $this->status['status'] = 'fail'; # Params $user_login = $params['username']; $user_name = $params['name']; $user_email = $params['email']; $user_password = $params['password']; $user_password_2 = $params['password_confirm']; $brought_by = $params['code']; $brought_by = str_replace('#mfr_', '', strtolower($brought_by)); # Validation if (!Session::csrf($params['mariana-csrf'])) { $this->status['errors'] = array(Lang::get('csrf-check-fail')); $this->return_json($this->status); return header('HTTP/1.0 200 OK'); } $inputs = array('username' => array('name' => 'username', 'required' => true, 'alfanum' => true), 'password' => array('name' => 'password', 'required' => true, 'alfanum' => true, 'min' => 3, 'max' => 32), 'password_confirm' => array('name' => 'password_confirm', 'matches' => 'password', 'required' => true), 'email' => array('required' => true, 'email' => true)); if (Validation::check($inputs) === false) { $this->status['errors'] = Framework\Session\Flash::showMessages(); $this->return_json($this->status); return header('HTTP/1.0 200 OK'); } $check_if_username_exists = WpUsers::wp_unique_user($user_login, $user_email); if ($check_if_username_exists) { $this->status['errors'] = $check_if_username_exists; $this->return_json($this->status); return header('HTTP/1.0 200 OK'); } # Create entry on both databases $user_id = wp_create_user($user_login, $user_password, $user_email); MfrUsers::wp_create_user($user_id, $user_name, $brought_by); # Notify wp_new_user_notification($user_id, $user_password); # Sign the user in $params = array(); $params['username'] = $user_login; $params['password'] = $user_password; $this->login($params); $this->return_json($this->status); # Forcing code 200 - Dunno why but keeps failing on this specific function return header('HTTP/1.0 200 OK'); }
public static function users_i_called() { return MfrUsers::where('brought_by', Session::get('id'))->count()->get()[0]->count; }