public function rejectUser($id) { $data['user_id'] = User::getPublicUserId(Input::post('username')); $data['group_id'] = $id; $data['status'] = 0; DB::deleteIf('group_user', $data); return TRUE; }
public function request($post) { $user_id = User::getPublicUserId($post['username']); if ($user_id === Session::get('user_id')) { return 'Sorry you cannot Request to your own profile'; } else { $follow_id = DB::fetch(array('request' => 'request_id'), array('user_id' => Session::get('user_id'), 'other_user_id' => $user_id)); if (empty($follow_id)) { DB::insert('request', array('user_id' => Session::get('user_id'), 'other_user_id' => $user_id, 'type' => $post['type'], 'time' => time())); Notif::raiseNotif($user_id, 'R' . $post['type']); return TRUE; } else { return 'Request already sent'; } } }
public function display($url) { if (empty($url[0])) { $url[0] = User::getUserData('username')[0]['username']; } $username = $url[0]; $user_id = User::getPublicUserId($username); $data = User::getPublicUserData($user_id); if ($data) { if ($user_id === Session::get('user_id')) { self::init('ProfileModel', 'profile', $username); } else { self::init('ProfileModel', 'profile', $username); } } else { echo 'Sorry User not found or Private User'; } }
public function __construct($username) { $user_id = Session::get('user_id'); $user_data = User::getPublicUserData($user_id)[0]; $this->data['title'] = ucwords($username); $this->data['username'] = $user_data['username']; $this->data['token'] = Token::generate(); $this->data['side_active']['profile'] = ' active'; require_once 'include/header.php'; $this->data['first_name'] = ucwords($user_data['first_name']); $this->data['last_name'] = ucwords($user_data['last_name']); $this->data['email'] = $user_data['email']; $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']); $profile_id = User::getPublicUserId($username); $profile_data = User::getPublicUserData($profile_id)[0]; $this->data['profile_data']['username'] = $username; $this->data['profile_data']['first_name'] = ucwords($profile_data['first_name']); $this->data['profile_data']['last_name'] = ucwords($profile_data['last_name']); $this->data['profile_data']['email'] = $profile_data['email']; $this->data['profile_data']['profile_pic'] = User::getProfilePic($profile_data['profile_pic']); $this->data['profile_data']['follow'] = User::checkFollow($username); $this->data['profile_data']['dob'] = $profile_data['dob']; //date in mm/dd/yyyy format; or it can be in other formats as well $birthDate = $profile_data['dob']; //explode the date to get month, day and year $birthDate = explode("-", $birthDate); //get age from date or birthdate $this->data['profile_data']['age'] = date("md", date("U", mktime(0, 0, 0, $birthDate[2], $birthDate[1], $birthDate[0]))) > date("md") ? date("Y") - $birthDate[0] - 1 : date("Y") - $birthDate[0]; $this->data['profile_data']['country'] = $profile_data['country']; switch ($profile_data['gender']) { case 'M': $this->data['profile_data']['gender'] = 'Male'; break; case 'F': $this->data['profile_data']['gender'] = 'Female'; break; case 'O': $this->data['profile_data']['gender'] = 'Others'; break; default: break; } }
public function send() { new Protect('ajax'); if (Input::exists()) { if (Token::ajaxCheck(Input::post('token'))) { // TODO: Check for empty messages, Validate messages $username = Input::post('username'); $msg = Input::post('msg'); if (!empty($username)) { Message::sendMessage($username, $msg); Notif::raiseMsgNotif(User::getPublicUserId($username)); } else { return 'Username Required'; } } else { return 'Security Token Missing'; } } return FALSE; }
public function getMessages($username) { $id = User::getPublicUserId($username); $user_id = Session::get('user_id'); $data1 = (array) DB::fetch(array('msg' => ['msg', 'time']), array('from_id' => $id, 'to_id' => $user_id)); $data2 = (array) DB::fetch(array('msg' => ['msg', 'time']), array('from_id' => $user_id, 'to_id' => $id)); foreach ($data1 as $key => $value) { $data1[$key] = (array) $value; $data1[$key]['type'] = 'sent'; } foreach ($data2 as $key => $value) { $data2[$key] = (array) $value; $data2[$key]['type'] = 'received'; } $data = array_merge($data1, $data2); usort($data, function ($a, $b) { return $a['time'] - $b['time']; }); return PhpConvert::toArray($data); }
<h3><?php echo $data['profile_data']['first_name']; ?> <?php echo $data['profile_data']['last_name']; ?> </h3> <h4 style="color: gray">@ <?php echo $data['profile_data']['username']; ?> </h4> <a style="color: black">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam varius tellus vulputate sapien pellentesque scelerisque. Interdum et malesuada fames ac ante ipsum primis in faucibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vivamus sodales tortor in pharetra convallis.</a> </div> <br> <?php if (User::getPublicUserId($data['profile_data']['username']) !== Session::get('user_id')) { echo '<div class="row">'; echo '<div class="col-md-4" id="follow-btn">'; if ($data['profile_data']['follow'] === TRUE) { echo '<a class="btn btn-error m-t-20" id="unfollow"><i class="fa fa-times"></i> Unfollow</a>'; } else { echo '<a class="btn btn-success m-t-20" id="follow"><i class="fa fa-check"></i> Follow</a>'; } echo ' </div> <div class="col-md-3"> <form action="request" method="post"> <input type="hidden" name="username" value="' . $data['profile_data']['username'] . '"> <input type="hidden" name="token" value="' . $data['token'] . '"> <button type="submit" class="btn btn-success m-t-20"> <i class="fa fa-plus"></i> Add</button> </form>