Exemple #1
0
 public function actionEdit_status()
 {
     $user = new User();
     $user->find()->where(['id' => $_POST['userID']])->one();
     $user->status = $_POST['status'];
     $user->save();
 }
 /**
  * Override the get_avatar by default from WP
  */
 protected static function getAvatar()
 {
     /*
      * We will get the avatar from our models
      */
     add_filter('get_avatar', function ($avatar = '', $id_or_email, $size = User::AVATAR_SIZE_DEFAULT, $default = '', $alt = '') {
         if (is_numeric($id_or_email)) {
             $user_id = (int) $id_or_email;
         } elseif (is_string($id_or_email) && ($user = get_user_by('email', $id_or_email))) {
             $user_id = $user->ID;
         } elseif (is_object($id_or_email) && !empty($id_or_email->user_id)) {
             $user_id = (int) $id_or_email->user_id;
         }
         $user = User::find($user_id);
         if (!$user) {
             return Utils::getUrlAvatarDefault($size);
         }
         if (!Utils::isValidStr($alt)) {
             $alt = $user->getDisplayName() . ' avatar';
         }
         $img = '<img alt="' . esc_attr($alt) . '" src="' . $user->getAvatar($size) . '" ';
         $img .= 'class="avatar photo" height="' . $size . '" width="' . $size . '">';
         return $img;
     }, 10, 5);
 }
 public function postUserSettings()
 {
     $error = false;
     if (Request::has('user_id')) {
         $user_id = (int) Auth::user()->user_id;
         $input_id = (int) Request::input('user_id');
         if (Request::input('roles') === null) {
             $roles = [];
         } else {
             $roles = Request::input('roles');
         }
         if ($user_id === $input_id && !in_array(env('ROLE_ADMIN'), $roles, false)) {
             $roles[] = env('ROLE_ADMIN');
             $error = true;
         }
         $editUser = User::find(Request::input('user_id'));
         $editUser->roles()->sync($roles);
         $editUser->save();
         $this->streamingUser->update();
     }
     if ($error) {
         return redirect()->back()->with('error', 'Vous ne pouvez pas enlever le droit admin de votre compte!');
     }
     return redirect()->back();
 }
Exemple #4
0
 /**
  * Return the instance of the current user, or null if they're not logged
  *
  * @return User
  */
 public static function getCurrentUser()
 {
     $user = wp_get_current_user();
     if ($user->ID) {
         return User::find($user->ID);
     }
     return null;
 }
Exemple #5
0
 /**
  * Get the author of the comment
  *
  * @return User
  */
 public function getUser()
 {
     // In case the user is a non registered User we need the default values from one User object
     if (!$this->user_id) {
         return new AppUser();
     }
     return AppUser::find($this->user_id);
 }
Exemple #6
0
 public function actionReg()
 {
     $vk_id = $this->app->cookie->get('vk_id');
     $user = new User();
     $user->find()->where(['vk_id' => $vk_id])->one();
     $user->status = $_GET['status'] == 1 ? 2 : 1;
     $user->save();
     $this->app->parser->render('profile', ['user' => $user]);
 }
 /**
  * author.php
  */
 public function getAuthor()
 {
     $author = get_queried_object();
     $user = User::find($author->ID);
     if (!$user) {
         return $this->getError();
     }
     $args = ['user' => $user];
     return $this->renderPage('user', $args);
 }
 /**
  * author.php
  */
 public function getAuthor()
 {
     $author = get_queried_object();
     $user = User::find($author->ID);
     if (!$user) {
         return $this->get404();
     }
     $args = ['postsWhereKey' => Ajax::AUTHOR, 'postsWhereValue' => $user->ID, 'user' => $user];
     return $this->renderPage('base/author', $args);
 }
Exemple #9
0
 public function start()
 {
     if ($this->user) {
         return $this->app->parser->renderW('main_menu', ['user' => $this->user], false);
     } else {
         $user = new User();
         $user->find()->where(['vk_id' => Cookie::get('vk_id')])->one();
         return $this->app->parser->renderW('main_menu', ['user' => $user], false);
     }
 }
Exemple #10
0
 public function actionMy()
 {
     $vk_id = Cookie::get('vk_id');
     $user = new User();
     $user->find()->where(['vk_id' => $vk_id])->one();
     $user->status = $_GET['status'] == 1 ? 2 : 1;
     $user->save();
     $region = new GeobaseRegion();
     $city = new GeobaseCity();
     $regionAll = $region->find()->orderBy('name', 'ASC')->all();
     $this->app->parser->render('profile', ['user' => $user, 'regionAll' => $regionAll]);
 }
Exemple #11
0
 public function actionReg()
 {
     $vk_id = Cookie::get('vk_id');
     $user = new User();
     $user->find()->where(['vk_id' => $vk_id])->one();
     $user->status = $_GET['status'] == 1 ? 2 : 1;
     $user->save();
     Header::redirect('/vk2/profile/my', true, 302);
     /*$this->app->parser->render('profile',
       [
           'user' =>$user,
       ]);*/
 }
 /**
  *
  * @param string $user_ID
  */
 public function getRenderLanguage($user_ID = false)
 {
     if (!$user_ID) {
         global $user_ID;
     }
     $user = User::find($user_ID);
     // Format the list
     $userLang = $user->getLang();
     foreach (I18n::getAllLangAvailable() as $t) {
         $languages[] = ['value' => $t, 'text' => I18n::transu('lang_' . $t), 'selected' => $userLang == $t];
     }
     $args = ['user' => $user, 'KEY_LANGUAGE' => User::KEY_LANGUAGE, 'languages' => $languages];
     return $this->render('backend/user/_lang', $args);
 }
 /**
  * @param int $currentPage
  * @param int $limit
  */
 public function modelAction($currentPage = 10, $limit = 10)
 {
     $startMemoryUsage = memory_get_peak_usage();
     $startTime = microtime(true);
     $currentPage = max(1, (int) $currentPage);
     $limit = max(1, (int) $limit);
     $users = \Models\User::find();
     $paginator = new \Phalcon\Paginator\Adapter\Model(["data" => $users, "limit" => $limit, "page" => $currentPage]);
     $paginator->getPaginate();
     $finishTime = microtime(true);
     $finishMemoryUsage = memory_get_peak_usage();
     echo "Memory peak usage: ";
     echo $finishMemoryUsage - $startMemoryUsage . "\n";
     echo "Time: ";
     echo $finishTime - $startTime . "\n";
 }
 /**
  * Authenticats the user 
  * @param 	Request Object - contains email and password
  *
  * @return Nothing
  */
 public function authenticate(Application $app, Request $request)
 {
     $email = $request->get('email');
     $password = $app->escape($request->get('password'));
     if ($email && $password) {
         $user = new User($app);
         $user_info = $user->find('user', array('email' => $email, 'password' => md5($password)));
         if ($user_info) {
             $app['session']->set('user', array('id' => $user_info[0]));
             return $app->redirect($request->getBaseUrl() . '/message/tweets');
         } else {
             return $app->render('index.php.twig', array('error_message' => "Invalid Credentials. Please try again!"));
         }
     } else {
         return $app->render('index.php.twig', array('error_message' => "Valid Email and password are required!"));
     }
 }
 protected function runUpdate()
 {
     $user = User::find(1);
     Auth::login($user);
     $fakeNow = Carbon::createFromFormat('Y-m-d H:i:s', '2015-01-01 01:00:00');
     Carbon::setTestNow($fakeNow);
     $user->name = "Shifra";
     $user->save();
     $user = $user->fresh();
     $fakeNow = Carbon::createFromFormat('Y-m-d H:i:s', '2015-01-02 00:00:00');
     Carbon::setTestNow($fakeNow);
     $user->email = '*****@*****.**';
     $user->save();
     return $user;
 }
Exemple #16
0
 /**
  * Return the author
  *
  * @return User
  */
 public function getAuthor()
 {
     return User::find($this->post_author);
 }
Exemple #17
0
 public function resetpassword($param)
 {
     $slug = $param[0];
     $hash = new \models\hash();
     $user = new User();
     $this->data['title'] = 'Reset Password';
     $row = $hash->get_row(array('hash' => $slug));
     if ($row->status == 'active') {
         $user_id = $row->user_id;
         $this->data['userDetails'] = $user->find($user_id);
         if (isset($_POST) && !empty($_POST)) {
             $user_details = $user->get_row(array('email' => $_POST['email']));
             if ($_POST['password'] == $_POST['password2']) {
                 //UPDATE USER  PASSWORD
                 $user->update(array("password" => md5($_POST['password'])), array("id" => $user_id));
                 $this->data['success'] = "Password reset successful!.";
             } else {
                 $this->data['error'] = 'This email does not exist in our records!';
             }
         }
     } else {
         $this->data['error'] = 'Reset record not found!';
     }
     View::rendertemplate('header', $this->data);
     View::render('account/resetpassword', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Exemple #18
0
 public function getUserNick()
 {
     $user = new User();
     return $user->find($this->getUserId())->nick;
 }
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('user')->truncate();
     DB::table('role')->truncate();
     DB::table('role_user')->truncate();
     DB::table('event')->truncate();
     DB::table('exp_level')->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $faker = Factory::create();
     $uQ = new User();
     $uQ->login = '******';
     $uQ->pseudo = 'QsAnakrose';
     $uQ->password = Hash::make('quentin');
     $uQ->email = '*****@*****.**';
     $uQ->streaming = 1;
     $uQ->twitch_channel = 'riotgames';
     $uQ->save();
     $data = [];
     for ($i = 0; $i < 110; $i++) {
         $username = $faker->unique()->username;
         $data[] = ['login' => $username, 'pseudo' => $username, 'email' => $faker->unique()->freeEmail, 'password' => Hash::make($username)];
     }
     User::insert($data);
     $this->command->info('Users created');
     $admin = new Role();
     $admin->title = 'admin';
     $admin->save();
     $streamer = new Role();
     $streamer->title = 'streamer';
     $streamer->save();
     $this->command->info('Roles created');
     $uQ->becomeAdmin();
     $uQ->becomeStreamer();
     for ($i = 2; $i < 13; $i++) {
         $u = User::find($i);
         $u->becomeStreamer();
         $u->twitch_channel = $i;
         $u->description = $u->login . 'lorem ipsum dolor. Lol.';
         $rand = rand(0, 2);
         if ($rand == 0) {
             $u->streaming = 1;
         } else {
             $u->streaming = 0;
         }
         /*
         $avatarManager = new AvatarManager();
         $intervManager = $avatarManager->getImgManager();
         $width = $avatarManager->getAvatarWidth();
         $color = substr(md5(rand()), 0, 6);
         $intervManager->canvas($width, $width, $color);
         */
         $u->save();
     }
     $su = new StreamingUserService();
     $su->update();
     $this->command->info('Roles attached');
     $event = new Event();
     $event->title = 'Hugo';
     $event->start = '2015-06-26T12:30:00+02:00';
     $event->end = '2015-06-26T15:30:00+02:00';
     $event->allDay = 'false';
     $event->color = '#FF0000';
     $event->timezone = '+02:00';
     $event->save();
     $this->command->info('Test event created');
     $expManager = new ExperienceManager();
     $data = $expManager->generateExperienceSystem();
     ExpLevel::insert($data);
     $this->command->info('Experience system initialized');
 }
Exemple #20
0
 public function actionIndex()
 {
     $user = new User();
     $u = $user->find()->all();
     $this->app->parser->render('index', ['user' => $u[0]], true);
 }
Exemple #21
0
 public function editprofile()
 {
     $this->data['title'] = 'Edit Profile';
     $user_model = new \Models\User();
     $this->data['user'] = Session::get('user');
     $this->data['user'] = $user_model->find(Session::get('user')->user_id);
     if (isset($_POST['user_firstname']) && !empty($_POST['user_firstname'])) {
         if (count($_POST['dance_category']) > 3) {
             $this->data['error'] = 'Dance category cannot exceed 3, Please correct';
         } else {
             $user_firstname = $_POST['user_firstname'];
             $user_lastname = $_POST['user_lastname'];
             $user_email = $_POST['user_email'];
             $user_phone = $_POST['user_phone'];
             $user_gender = $_POST['user_gender'];
             $user_bio = $_POST['user_bio'];
             $dance_category = $_POST['dance_category'];
             $user_slug = Url::generateSafeSlug($user_firstname . $this->data['user']->user_id . $user_lastname);
             //delete all user's dancer's category first
             $delete = $userdance_model->delete(array('user_dance_user_id' => $this->data['user']->user_id), 5);
             //insert dance category
             if (count($_POST['dance_category']) > 0) {
                 foreach ($dance_category as $value) {
                     $dance_category_count = 0;
                     $insert_dance_category = $userdance_model->create(array('user_dance_user_id' => $this->data['user']->user_id, 'user_dance_category_id' => $value));
                     $dance_category_count++;
                 }
             }
             //update user db
             $update_array = array('user_firstname' => $user_firstname, 'user_lastname' => $user_lastname, 'user_email' => $user_email, 'user_bio' => $user_bio, 'user_gender' => $user_gender, 'user_slug' => $user_slug, 'user_phone' => $user_phone);
             $update_array = Gump::xss_clean($update_array);
             $update_array = Gump::sanitize($update_array);
             $update_id = $user_model->updateId($update_array, $this->data['user']->user_id);
             //UPLOAD ATTACHMENT
             if ($_FILES["image"]["tmp_name"] != '') {
                 //upload image into uploads folder
                 Upload::setName($slug . uniqid());
                 Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
                 $image_name = Upload::getFileName('images');
                 $update_data = array('user_image' => $image_name);
                 $update_img = $this->user_model->updateId($update_data, $this->data['user']->user_id);
                 if ($update_img > 0) {
                     Session::set('success', 'Profile Updated!');
                     Url::redirect('user');
                 } else {
                     $this->data['error'] = 'Operation Fails!';
                 }
             }
             if ($update_id > 0) {
                 Session::set('success', 'Profile Updated!');
                 Url::redirect('user');
             } else {
                 $this->data['error'] = 'Operation Fails!';
             }
             if (isset($dance_category_count) && $dance_category_count > 0) {
                 Session::set('success', 'Dance Category Updated!');
                 Url::redirect('user');
             } else {
                 $this->data['error'] = 'Operation Fails!';
             }
         }
     }
     $this->data['dance_category'] = \models\category::section('dance');
     $user_dance_category = \models\userdance::category($this->data['user']->user_id);
     foreach ($user_dance_category as $item) {
         $this->data['user_dance_category'][] = $item->category_id;
     }
     View::rendertemplate('header', $this->data);
     View::render('workspace/workspace.editprofile', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Exemple #22
0
 public function edit($param)
 {
     $edit_id = $param[0];
     $user_model = new User();
     if (isset($_POST) && !empty($_POST)) {
         $artistArray = array('user_firstname' => $_POST['firstname'], 'user_stagename' => $_POST['stagename'], 'user_bio' => $_POST['bio'], 'twitter_handle' => $_POST['twitter_handle'], 'user_modified' => time());
         $artistArray = Gump::xss_clean($artistArray);
         $artistArray = Gump::sanitize($artistArray);
         $update_id = $user_model->updateId($artistArray, $edit_id);
         //UPLOAD ATTACHMENT
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload image into uploads folder
             Upload::setName($slug . time());
             Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px');
             $update_data = array('user_image' => Upload::getFileName('images'));
             if ($this->user_model->updateId($update_data, $edit_id)) {
                 Session::set('success', 'Artist record edited');
             } else {
                 Session::set('error', 'operation fails');
             }
         }
         if ($update_id > 0) {
             Session::set('success', 'Artist record edited');
             Url::redirect('artist');
         } else {
             Session::set('error', 'operation fails');
         }
     }
     $this->data['user_data'] = $user_model->find($edit_id);
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('artist/artist.add', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Exemple #23
0
 public function actionGet_master()
 {
     $master = new User();
     $master->find()->where(['id' => $_POST['user_id']])->one();
     $this->app->parser->renderCode('get_master', ['master' => $master]);
 }
Exemple #24
0
 public function actionMy()
 {
     $user = new User();
     $user->find()->where(['vk_id' => Cookie::get('vk_id')])->one();
     $this->app->parser->render('index', ['user' => $user], true);
 }
Exemple #25
0
 /**
  * Add language to user profile
  */
 public static function userProfileAddLanguage()
 {
     $addLang = function ($user) {
         $c = new BackendController();
         echo $c->getRenderLanguage($user->ID);
     };
     add_action('show_user_profile', $addLang);
     add_action('edit_user_profile', $addLang);
     $updateLang = function ($user_ID) {
         if (current_user_can('edit_user', $user_ID)) {
             $user = User::find($user_ID);
             $user->setLang($_POST[User::KEY_LANGUAGE]);
         }
     };
     add_action('personal_options_update', $updateLang);
     add_action('edit_user_profile_update', $updateLang);
 }
Exemple #26
0
 public function actionSearching()
 {
     $user = new User();
     $res = $user->find('`user`.*')->leftJoin('user_services', '`user_services`.`user_id` = `user`.`id`')->where(['status' => 2, 'region_id' => $_POST['regionId'], 'city_id' => $_POST['cityId'], 'service_id' => $_POST['serviceId']])->all();
     $this->app->parser->render('searching_result', ['result' => $res], true);
 }
Exemple #27
0
 /**
  * Delete the specified user
  *
  * @param
  *        	MongoId user's $id
  * @return boolean true if the user was deleted, false otherwise.
  */
 public static function deleteUser($id)
 {
     $user = User::find($id);
     if (!$user instanceof User) {
         return false;
     }
     return $user->delete();
 }
Exemple #28
0
 /**
  * Get the author of the comment
  *
  * @return User
  */
 public function getUser()
 {
     return User::find($this->user_id);
 }
 public function deletesAction()
 {
     if ($this->request->isPost()) {
         $ids = $this->request->getPost('cid');
         if (count($ids) > 0) {
             $users = User::find('id IN (' . implode(',', $ids) . ')');
             $userDeleted = [];
             foreach ($users as $user) {
                 if ($user->delete()) {
                     $userDeleted[] = $user->name;
                 }
             }
             if (count($userDeleted) > 0) {
                 $this->flashSession->success('Users ' . implode(', ', $userDeleted) . ' deleted.');
             } else {
                 $this->flashSession->error('Users need delete not found.');
             }
         }
     }
     return $this->response->redirect('admin/user');
 }