コード例 #1
0
ファイル: admin.php プロジェクト: linniepinski/perssistant
 /**
  * update user avatar
  */
 public function ae_upload_image($attach_data, $data)
 {
     if (isset($data["method"]) && $data["method"] == "change_avatar") {
         if (!isset($data['author'])) {
             return;
         }
         $ae_users = AE_Users::get_instance();
         //update user avatar
         $user = $ae_users->update(array('ID' => $data['author'], 'et_avatar' => $attach_data['attach_id'], 'et_avatar_url' => $attach_data['thumbnail'][0]));
     }
     switch ($data) {
         case 'site_logo_black':
         case 'site_logo_white':
             $options = AE_Options::get_instance();
             // save this setting to theme options
             $options->{$data} = $attach_data;
             if ($data == 'site_logo_black') {
                 $options->site_logo = $attach_data;
             }
             $options->save();
             break;
         default:
             // code...
             break;
     }
 }
コード例 #2
0
 /**
  * return class $instance
  */
 public static function get_instance()
 {
     if (self::$instance == null) {
         self::$instance = new AE_Users();
     }
     return self::$instance;
 }
コード例 #3
0
 /**
  * update user avatar
  */
 public function change_avatar($attach_data, $data)
 {
     //if no author ID return false;
     if (!isset($data['author'])) {
         return;
     }
     //update user avatar only
     if ($data['method'] == "change_avatar") {
         $ae_users = AE_Users::get_instance();
         //update user avatar
         $user = $ae_users->update(array('ID' => $data['author'], 'et_avatar' => $attach_data['attach_id'], 'et_avatar_url' => $attach_data['thumbnail'][0]));
     }
 }
コード例 #4
0
<?php

global $wp_query, $ae_post_factory, $post, $current_user;
//convert current user
$ae_users = AE_Users::get_instance();
$user_data = $ae_users->convert($current_user->data);
$user_data = $ae_users->convert($current_user->data);
$user_role = ae_user_role($current_user->ID);
//convert current profile
$post_object = $ae_post_factory->get(PROFILE);
$profile_id = get_user_meta($current_user->ID, 'user_profile_id', true);
$user_mobile = get_user_meta($current_user->ID, 'phone', true);
#get country list
$country_list = ae_country_list();
$profile = array('id' => 0, 'ID' => 0);
if ($profile_id) {
    $profile_post = get_post($profile_id);
    if ($profile_post && !is_wp_error($profile_post)) {
        $profile = $post_object->convert($profile_post);
    }
}
//get profile skills
$current_skills = get_the_terms($profile, 'skill');
//define variables:
$skills = isset($profile->tax_input['skill']) ? $profile->tax_input['skill'] : array();
$job_title = isset($profile->et_professional_title) ? $profile->et_professional_title : '';
$hour_rate = isset($profile->hour_rate) ? $profile->hour_rate : '';
$currency = isset($profile->currency) ? $profile->currency : '';
$experience = isset($profile->experience) ? explode(' ', $profile->experience)[0] : '';
$hour_rate = isset($profile->hour_rate) ? $profile->hour_rate : '';
$about = isset($profile->post_content) ? $profile->post_content : '';
コード例 #5
0
    /**
     *
     */
    function render()
    {
        global $wp_roles, $user;
        $number = get_option('posts_per_page');
        $args = array('number' => $number, 'count_total' => true, 'orderby' => 'user_registered', 'order' => 'DESC');
        $users_query = new WP_User_Query($args);
        $total = $users_query->total_users;
        $users = $users_query->results;
        $pages = ceil($total / $number);
        $user_data = array();
        $role_names = $wp_roles->role_names;
        $ae_users = AE_Users::get_instance();
        ?>
		<div class="et-main-content user-container" id="<?php 
        echo $this->args['id'];
        ?>
">

			<div class="search-box et-member-search">
				<div id="search_users" >
					<span class="et-search-role">
						<select name="role" id="" class="et-input" >
							<option value="" ><?php 
        _e("All", ET_DOMAIN);
        ?>
</option>
							<?php 
        foreach ($role_names as $role_name => $role_label) {
            echo '<option value="' . $role_name . '" >' . $role_label . '</option>';
        }
        ?>
						</select>
					</span>
					<span class="et-search-input">
						<input type="text" class="et-input user-search" name="keyword" placeholder="<?php 
        _e("Search users...", ET_DOMAIN);
        ?>
">
						<span class="icon" data-icon="s"></span>
					</span>
				</div>
			</div>
			<!-- // user search box -->

			<div class="et-main-main no-margin clearfix overview list">
				<div class="title font-quicksand"><?php 
        _e('All Users', ET_DOMAIN);
        ?>
</div>
				<ul class="list-inner list-payment users-list">
					<?php 
        foreach ($users as $user) {
            $user_data[] = $ae_users->convert($user);
            ae_get_template_part('user', 'item');
        }
        ?>
				</ul>
				<script type="application/json" id="ae_users_list">
					<?php 
        echo json_encode(array('users' => $user_data, 'pages' => $pages, 'query' => $args));
        ?>
				</script>
				<?php 
        if ($pages > 1) {
            ?>
					<button class="et-button btn-button load-more" >
						<?php 
            _e('More Users', ET_DOMAIN);
            ?>
					</button>
				<?php 
        }
        ?>
			</div>
			<!-- //user list -->

			<!-- ban modal -->
			<div class="modal fade" id="ban_modal">
				<div class="modal-dialog">
					<div class="modal-content">
						<form id="form_ban_user" action="">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title"><?php 
        _e('Ban user', ET_DOMAIN);
        ?>
 <span class="display-name"></span></h4>
							</div>
							<div class="modal-body">
									<input type="hidden" name="id" value="">
									<div class="dialog-form-item">
										<label for=""><?php 
        _e('Ban for', ET_DOMAIN);
        ?>
</label> <br>
										<select name="expired" id="">
											<?php 
        $expired = et_get_ban_expired_period();
        foreach ($expired as $day) {
            echo '<option value="' . $day['value'] . '">' . $day['label'] . '</option>';
        }
        ?>
										</select>
									</div>
									<div class="dialog-form-item">
										<label for=""><?php 
        _e('Reason', ET_DOMAIN);
        ?>
</label> <br>
										<textarea name="reason" id="" cols="30" rows="10"></textarea>
									</div>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal"><?php 
        _e('Close', ET_DOMAIN);
        ?>
</button>
								<button type="submit" class="btn btn-primary"><?php 
        _e('Submit', ET_DOMAIN);
        ?>
</button>
							</div>
						</form>
					</div><!-- /.modal-content -->
				</div><!-- /.modal-dialog -->
			</div><!-- /.modal -->
			<!-- /ban modal -->
		</div>
    <?php 
        $this->render_js_template();
    }
コード例 #6
0
ファイル: projects.php プロジェクト: linniepinski/perssistant
 /**
  * ajax callback sync post details
  * - update
  * - insert
  * - delete
  */
 function post_sync()
 {
     $request = $_REQUEST;
     global $ae_post_factory, $user_ID;
     if (!AE_Users::is_activate($user_ID)) {
         wp_send_json(array('success' => false, 'msg' => __("Your account is pending. You have to activate your account to continue this step.", 'projects-backend')));
     }
     if (check_existing_post_name($request['post_title']) && $request['method'] != 'update') {
         wp_send_json(array('success' => false, 'msg' => __("Current title name already exists", 'projects-backend')));
     }
     // prevent freelancer submit project
     if (!fre_share_role() && ae_user_role() == FREELANCER) {
         wp_send_json(array('success' => false, 'msg' => __("You need an employer account to post a project.", 'projects-backend')));
     }
     // unset package data when edit place if user can edit others post
     if (isset($request['ID']) && !isset($request['renew'])) {
         unset($request['et_payment_package']);
     }
     if (isset($request['archive'])) {
         $request['post_status'] = 'archive';
     }
     if (isset($request['publish'])) {
         $request['post_status'] = 'publish';
     }
     if (isset($request['delete'])) {
         $request['post_status'] = 'trash';
     }
     if (isset($request['disputed'])) {
         $request['post_status'] = 'disputed';
     }
     if (isset($request['close_disput'])) {
         $request['post_status'] = get_post_meta($request['ID'], 'post_status_before_disput', true);
     }
     if (isset($request['project_type'])) {
         unset($request['project_type']);
     }
     $place = $ae_post_factory->get($this->post_type);
     // sync place
     $result = $place->sync($request);
     if (!is_wp_error($result)) {
         // update place carousels
         if (isset($request['et_carousels'])) {
             // loop request carousel id
             foreach ($request['et_carousels'] as $key => $value) {
                 $att = get_post($value);
                 // just admin and the owner can add carousel
                 if (current_user_can('manage_options') || $att->post_author == $user_ID) {
                     wp_update_post(array('ID' => $value, 'post_parent' => $result->ID));
                 }
             }
         }
         /**
          * check payment package and check free or use package to send redirect link
          */
         if (isset($request['et_payment_package'])) {
             // check seller use package or not
             $check = AE_Package::package_or_free($request['et_payment_package'], $result);
             // check use package or free to return url
             if ($check['success']) {
                 $result->redirect_url = $check['url'];
             }
             $result->response = $check;
             // check seller have reached limit free plan
             $check = AE_Package::limit_free_plan($request['et_payment_package']);
             if ($check['success']) {
                 // false user have reached maximum free plan
                 $response['success'] = false;
                 $response['msg'] = $check['msg'];
                 // send response to client
                 wp_send_json($response);
             }
         }
         // check payment package
         /**
          * check disable plan and submit place to view details
          */
         if ($this->disable_plan && $request['method'] == 'create') {
             if (ICL_LANGUAGE_CODE != 'en') {
                 $redirect = apply_filters('wpml_permalink', $result->permalink, ICL_LANGUAGE_CODE);
             } else {
                 $redirect = $result->permalink;
             }
             // disable plan, free to post place
             $response = array('success' => true, 'data' => array('ID' => $result->ID, 'redirect_url' => $redirect), 'msg' => __("Submit place successfull.", 'projects-backend'));
             // send response
             wp_send_json($response);
         }
         // send json data to client
         wp_send_json(array('success' => true, 'data' => $result, 'msg' => __("Update project successful!", 'projects-backend')));
     } else {
         // update false
         wp_send_json(array('success' => false, 'data' => $result, 'msg' => $result->get_error_message()));
     }
 }
コード例 #7
0
ファイル: profiles.php プロジェクト: linniepinski/perssistant
 /**
  * hanlde portfolio action
  * @package FreelanceEngine
  */
 function sync_post()
 {
     global $ae_post_factory, $user_ID, $current_user, $post;
     // echo 1; exit;
     $request = $_REQUEST;
     $ae_users = new AE_Users();
     $user_data = $ae_users->convert($current_user);
     $portfolio = $ae_post_factory->get($this->post_type);
     // var_dump($request);
     //var_dump($portfolio);
     if (!isset($request['id'])) {
         unset($request['id']);
     } else {
         $request['ID'] = $request['id'];
         unset($request['id']);
     }
     // $request['post_content'] = strip_tags($request['post_content']);
     // set status for profile
     if (!isset($request['post_status'])) {
         $request['post_status'] = 'publish';
     }
     // set default post content
     //$request['post_content'] = '';
     // sync place
     //var_dump($request);
     $result = $portfolio->sync($request);
     //var_dump($result);
     if (!is_wp_error($result)) {
         //update post thumbnail
         if (isset($request['post_thumbnail'])) {
             $thumb_id = $request['post_thumbnail'];
             set_post_thumbnail($result, $thumb_id);
             $result = $portfolio->get($result->ID);
         }
         // action create profile
         if ($request['method'] == 'create') {
             $convert = $portfolio->convert($result);
             $response = array('success' => true, 'data' => $convert, 'msg' => __("Portfolio has been created successfully.", 'profiles-backend'));
             wp_send_json($response);
         } else {
             if ($request['method'] == 'delete' || $request['method'] == 'remove') {
                 $response = array('success' => true, 'msg' => __("Portfolio has been deleted successfully.", 'profiles-backend'));
                 wp_send_json($response);
                 //action update profile
             } else {
                 if ($request['method'] == 'update') {
                     $response = array('success' => true, 'data' => array('redirect_url' => $result->permalink, 'post_title' => $result->post_title, 'post_content' => $result->post_content, 'the_post_thumnail' => $result->the_post_thumnail, 'the_post_thumbnail' => $result->the_post_thumbnail, 'the_post_thumbnail_full' => $result->the_post_thumbnail_full, 'featured_image' => $result->featured_image), 'msg' => __("Portfolio has been updated successfully.", 'profiles-backend'));
                     wp_send_json($response);
                 }
             }
         }
     } else {
         wp_send_json(array('success' => false, 'data' => $result, 'msg' => $result->get_error_message()));
     }
 }
コード例 #8
0
ファイル: twitter.php プロジェクト: rinodung/wp-question
 /**
  * Redirect and auth twitter account
  */
 public function redirect()
 {
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'twitterauth') {
         // request token
         if (!isset($_SESSION)) {
             ob_start();
             @session_start();
         }
         require_once dirname(__FILE__) . '/twitteroauth/twitteroauth.php';
         // create connection
         $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret);
         // request token
         $request_token = $connection->getRequestToken($this->oath_callback);
         //
         if ($request_token) {
             // var_dump($request_token);
             // exit;
             if (isset($request_token['oauth_token']) && $request_token['oauth_token_secret']) {
                 $token = $request_token['oauth_token'];
                 $_SESSION['oauth_token'] = $token;
                 $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
                 // try et session
                 et_write_session('oauth_token', $token);
                 et_write_session('oauth_token_secret', $request_token['oauth_token_secret']);
             }
             // redirect to twitter
             switch ($connection->http_code) {
                 case 200:
                     $url = $connection->getAuthorizeURL($request_token);
                     //redirect to Twitter .
                     header('Location: ' . $url);
                     exit;
                     break;
                 default:
                     _e("Conection with twitter Failed", ET_DOMAIN);
                     exit;
                     break;
             }
         } else {
             echo __("Error Receiving Request Token", ET_DOMAIN);
             exit;
         }
     } else {
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'twitterauth_callback' && $_GET['oauth_token']) {
             // request access token and
             // create account here
             if (!isset($_SESSION)) {
                 ob_start();
                 @session_start();
             }
             require_once dirname(__FILE__) . '/twitteroauth/twitteroauth.php';
             $et_session = et_read_session();
             if (isset($et_session['oauth_token'])) {
                 $oauth_token = $et_session['oauth_token'];
                 $oauth_token_secret = $et_session['oauth_token_secret'];
             } else {
                 $oauth_token = $_SESSION['oauth_token'];
                 $oauth_token_secret = $_SESSION['oauth_token_secret'];
             }
             // create connection
             $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $oauth_token, $oauth_token_secret);
             // request access token
             $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
             //
             if ($access_token && isset($access_token['oauth_token'])) {
                 // recreate connection
                 $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $access_token['oauth_token'], $access_token['oauth_token_secret']);
                 $account = $connection->get('account/verify_credentials');
                 // create account
                 if ($account && isset($account->screen_name) && isset($account->name)) {
                     // find
                     $users = get_users(array('meta_key' => 'et_twitter_id', 'meta_value' => $account->id));
                     if (!empty($users) && is_array($users)) {
                         $ae_user = $users[0];
                         wp_set_auth_cookie($ae_user->ID, 1);
                         wp_redirect(home_url());
                         exit;
                     }
                     $avatars = array();
                     $sizes = get_intermediate_image_sizes();
                     foreach ($sizes as $size) {
                         $avatars[$size] = array($account->profile_image_url);
                     }
                     $params = array('user_login' => $account->screen_name, 'display_name' => $account->name, 'user_location' => $account->location, 'description' => $account->description, 'et_avatar' => $avatars);
                     // save user info for saving later
                     $_SESSION['user_login'] = $account->screen_name;
                     $_SESSION['display_name'] = $account->name;
                     $_SESSION['et_twitter_id'] = $account->id;
                     $_SESSION['user_location'] = $account->location;
                     $_SESSION['description'] = $account->description;
                     $_SESSION['profile_image_url'] = $account->profile_image_url;
                     $_SESSION['et_auth'] = serialize(array('user_login' => $account->screen_name, 'display_name' => $account->name, 'user_location' => $account->location, 'description' => $account->description, 'et_avatar' => $avatars));
                     $_SESSION['et_social_id'] = $account->id;
                     $_SESSION['et_auth_type'] = 'twitter';
                     // try to user et session
                     et_write_session('et_auth', serialize($params));
                     et_write_session('et_social_id', $account->id);
                     et_write_session('et_auth_type', 'twitter');
                     wp_redirect($this->auth_url);
                     exit;
                 }
             }
             exit;
         } else {
             if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'twitterauth_login') {
                 if (!isset($_SESSION)) {
                     ob_start();
                     @session_start();
                 }
                 if (!empty($_POST['user_email'])) {
                     $password = wp_generate_password();
                     $new_account = array('user_login' => $_SESSION['user_login'], 'display_name' => $_SESSION['display_name'], 'et_twitter_id' => $_SESSION['et_twitter_id'], 'user_location' => $_SESSION['user_location'], 'description' => $_SESSION['description'], 'user_email' => $_POST['user_email'], 'user_pass' => $password, 'et_avatar' => array('thumbnail' => array($_SESSION['profile_image_url'])));
                     $ae_user = get_user_by('login', $new_account['user_login']);
                     if ($ae_user != false) {
                         $new_account['user_login'] = str_replace('@', '', $_POST['user_email']);
                     }
                     $ae_user = AE_Users::get_instance();
                     $result = $ae_user->insert($new_account);
                     if (!is_wp_error($result)) {
                         // send email here
                         //
                         do_action('et_after_register', $result);
                         // wp_mail( $_POST['user_email'],
                         //  __("You have been logged in via Twitter", ET_DOMAIN),
                         //  "Hi, <br/> your pasword on our site is {$password}");
                         // login
                         $ae_user = wp_signon(array('user_login' => $new_account['user_login'], 'user_password' => $new_account['user_pass']));
                         if (is_wp_error($ae_user)) {
                             global $et_error;
                             $et_error = $ae_user->get_error_message();
                             //echo $user->get_error_message();
                         } else {
                             wp_redirect(home_url());
                             exit;
                         }
                     } else {
                         global $et_error;
                         $et_error = $result->get_error_message();
                     }
                 }
                 // ask people for password
                 include TEMPLATEPATH . '/page-twitter-auth.php';
                 exit;
             }
         }
     }
 }
コード例 #9
0
ファイル: social_auth.php プロジェクト: rinodung/wp-question
 public function confirm_username()
 {
     try {
         if (!isset($_SESSION)) {
             ob_start();
             @session_start();
         }
         // get data
         $data = $_POST['content'];
         $auth_info = unserialize($_SESSION['et_auth']);
         $username = $data['user_login'];
         if (isset($data['user_role']) && $data['user_role'] != '') {
             $user_roles = ae_get_option('social_user_role', false);
             if (!$user_roles) {
                 $user_roles = ae_get_social_login_user_roles_default();
             }
             if ($user_roles && in_array($data['user_role'], $user_roles) && $data['user_role'] != 'Administrator') {
                 $auth_info['role'] = $data['user_role'];
             }
         }
         $et_session = et_read_session();
         if ($et_session['et_social_id']) {
             $social_id = $et_session['et_social_id'];
         } else {
             $social_id = $_SESSION['et_social_id'];
         }
         // verify username
         $ae_user = get_user_by('login', $username);
         $return = array();
         if ($ae_user != false) {
             throw new Exception(__('Username is existed, please choose another one', ET_DOMAIN));
         } else {
             $auth_info['user_login'] = $username;
             // create user
             $ae_user = AE_Users::get_instance();
             $result = $ae_user->insert($auth_info);
             if (is_wp_error($result)) {
                 throw new Exception($result->get_error_message());
             } else {
                 if (empty($social_id)) {
                     throw new Exception(__("Can't find Social ID", ET_DOMAIN));
                 } else {
                     // creating user successfully
                     update_user_meta((int) $result->ID, $this->social_option, $social_id);
                     do_action('et_after_register', $result);
                     wp_set_auth_cookie((int) $result->ID, 1);
                     unset($_SESSION['et_auth']);
                     $return = array('user_id' => $result, 'redirect_url' => home_url());
                 }
             }
         }
         $resp = array('success' => true, 'msg' => '', 'data' => $return);
     } catch (Exception $e) {
         $resp = array('success' => false, 'msg' => $e->getMessage());
     }
     wp_send_json($resp);
 }
コード例 #10
0
ファイル: google.php プロジェクト: maratdev/alllancer
 public function auth_google()
 {
     if (isset($_REQUEST['code']) && !empty($_REQUEST['code']) && (isset($_REQUEST['state']) || $_REQUEST['state'] == $this->state)) {
         try {
             // turn on session
             if (!isset($_SESSION)) {
                 ob_start();
                 @session_start();
             }
             /**
              * Exchange authorization code for tokens
              */
             $redirect_uri = home_url('?action=gplus_auth_callback');
             $args = array('method' => 'POST', 'body' => array('grant_type' => 'authorization_code', 'code' => $_REQUEST['code'], 'redirect_uri' => $redirect_uri, 'client_id' => $this->gplus_client_id, 'client_secret' => $this->gplus_secret_key));
             $remote_post = wp_remote_post($this->gplus_exchange_url, $args);
             if (isset($remote_post['body'])) {
                 $data = json_decode($remote_post['body']);
                 if (isset($data->refresh_token)) {
                     $secure = 'https' === parse_url(site_url(), PHP_URL_SCHEME) && 'https' === parse_url(home_url(), PHP_URL_SCHEME);
                     setcookie('refresh_token', $data->refresh_token, time() + 3600 * 24 * 7, SITECOOKIEPATH, COOKIE_DOMAIN, $secure);
                 }
                 if (isset($data->error) && $data->error == 'invalid_grant') {
                     $args = array('method' => 'POST', 'body' => array('grant_type' => 'refresh_token', 'code' => $_REQUEST['code'], 'redirect_uri' => $redirect_uri, 'client_id' => $this->gplus_client_id, 'client_secret' => $this->gplus_secret_key, 'refresh_token' => $_COOKIE['refresh_token']));
                     $remote_post = wp_remote_post($this->gplus_exchange_url, $args);
                     $data = json_decode($remote_post['body']);
                 }
             } else {
                 _e('Error to connect to Google Server!', ET_DOMAIN);
                 exit;
             }
             /**
              * Get user information
              */
             if (isset($data->access_token)) {
                 $userinfor = wp_remote_get($this->gplus_token_info_url . '?access_token=' . $data->access_token);
                 $userinfor = json_decode($userinfor['body']);
             } else {
                 _e('Error to connect to Google', ET_DOMAIN);
                 exit;
             }
             if (!isset($userinfor->id) || empty($userinfor->id)) {
                 _e('Error to connect to Google Server!', ET_DOMAIN);
                 exit;
             }
             // if user is already authenticated before
             if ($this->get_user($userinfor->id)) {
                 $user = $this->get_user($userinfor->id);
                 $result = $this->logged_user_in($userinfor->id);
                 $ae_user = AE_Users::get_instance();
                 $userdata = $ae_user->convert($user);
                 $nonce = array('reply_thread' => wp_create_nonce('insert_reply'), 'upload_img' => wp_create_nonce('et_upload_images'));
             } else {
                 // avatar
                 $ava_response = isset($userinfor->picture) ? $userinfor->picture : '';
                 $sizes = get_intermediate_image_sizes();
                 $avatars = array();
                 if ($ava_response) {
                     foreach ($sizes as $size) {
                         $avatars[$size] = array($ava_response);
                     }
                 } else {
                     $avatars = false;
                 }
                 $userinfor->name = str_replace(' ', '', sanitize_user($userinfor->name));
                 $username = $userinfor->name;
                 $params = array('user_login' => $username, 'user_email' => isset($userinfor->email) ? $userinfor->email : false, 'et_avatar' => $avatars);
                 //remove avatar if cant fetch avatar
                 foreach ($params as $key => $param) {
                     if ($param == false) {
                         unset($params[$key]);
                     }
                 }
                 $_SESSION['et_auth'] = serialize($params);
                 $_SESSION['et_social_id'] = $userinfor->id;
                 $_SESSION['et_auth_type'] = 'google';
                 et_write_session('et_auth', serialize($params));
                 et_write_session('et_social_id', $userinfor->id);
                 et_write_session('et_auth_type', 'google');
             }
             header('Location: ' . $this->auth_url);
             exit;
         } catch (Exception $e) {
             _e('Error to connect to Google Server', ET_DOMAIN);
             exit;
         }
     }
 }
コード例 #11
0
    /**
     * 
     */
    function render()
    {
        global $wp_roles, $user;
        $number = get_option('posts_per_page');
        $users_query = new WP_User_Query(array('number' => $number, 'count_total' => true));
        $total = $users_query->total_users;
        $users = $users_query->results;
        $pages = ceil($total / $number);
        $user_data = array();
        $role_names = $wp_roles->role_names;
        $ae_users = AE_Users::get_instance();
        ?>
		<div class="et-main-content user-container" id="<?php 
        echo $this->args['id'];
        ?>
">

			<div class="search-box et-member-search">
				<form action="">
					<span class="et-search-role">
						<select name="role" id="" class="et-input" >
							<option value="" ><?php 
        _e("All", ET_DOMAIN);
        ?>
</option>
							<?php 
        foreach ($role_names as $role_name => $role_label) {
            echo '<option value="' . $role_name . '" >' . $role_label . '</option>';
        }
        ?>
						</select>
					</span>
					<span class="et-search-input">
						<input type="text" class="et-input user-search" name="keyword" placeholder="<?php 
        _e("Search users...", ET_DOMAIN);
        ?>
">
						<span class="icon" data-icon="s"></span>
					</span>
				</form>				
			</div>
			<!-- // user search box -->

			<div class="et-main-main no-margin clearfix overview list">			
				<div class="title font-quicksand"><?php 
        _e('All Users', ET_DOMAIN);
        ?>
</div>
				<ul class="list-inner list-payment users-list">
					<?php 
        foreach ($users as $user) {
            $user_data[] = $ae_users->convert($user);
            ae_get_template_part('user', 'item');
        }
        ?>
				</ul>
				<script type="application/json" id="ae_users_list">
					<?php 
        echo json_encode(array('users' => $user_data, 'pages' => $pages));
        ?>
 
				</script>
				<?php 
        if ($pages > 1) {
            ?>
					<button class="et-button btn-button load-more" >
						<?php 
            _e('More Users', ET_DOMAIN);
            ?>
					</button>
				<?php 
        }
        ?>
	        			
			</div>
			<!-- //user list -->
		</div>
    <?php 
        $this->render_js_template();
    }
コード例 #12
0
ファイル: facebook.php プロジェクト: rinodung/wp-question
 public function auth_facebook()
 {
     try {
         // turn on session
         if (!isset($_SESSION)) {
             ob_start();
             @session_start();
         }
         $fb_appID = ae_get_option('et_facebook_key', false);
         $fb_secret_key = ae_get_option('et_facebook_secret_key', false);
         if (!$this->fb_app_id || !$this->fb_secret_key) {
             $resp = array('success' => false, 'msg' => __('Social login is invalid. Please contact administrator for help.', ET_DOMAIN));
             wp_send_json($resp);
             return;
         }
         if (!isset($_POST['fb_token']) || $_POST['fb_token'] == '') {
             $resp = array('success' => false, 'msg' => __('Social login is invalid. Please contact administrator for help.', ET_DOMAIN));
             wp_send_json($resp);
             return;
         }
         /**
          * check user id with a access token
          */
         $token_url = $this->fb_token_url;
         $token_url .= '?fields=id&access_token=' . $_POST['fb_token'];
         $check_userid = wp_remote_get($token_url);
         $check_userid = json_decode($check_userid['body']);
         if (!isset($check_userid->id) || $check_userid->id == '') {
             $resp = array('success' => false, 'msg' => __('Social login is invalid. Please contact administrator for help.', ET_DOMAIN));
             wp_send_json($resp);
             return;
         }
         $check_userid = $check_userid->id;
         /**
          * check user vefified app
          *
          */
         $fb_exchange_token = $this->fb_exchange_token;
         $fb_exchange_token .= '?grant_type=fb_exchange_token&';
         $fb_exchange_token .= 'client_id=' . $this->fb_app_id . '&';
         $fb_exchange_token .= 'client_secret=' . $this->fb_secret_key . '&';
         $fb_exchange_token .= 'fb_exchange_token=' . $_POST['fb_token'];
         // $fb_app_token = wp_remote_get('https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id='.$this->fb_app_id.'&client_secret='.$this->fb_secret_key.'&fb_exchange_token=' . $_POST['fb_token']);
         $fb_app_token = wp_remote_get($fb_exchange_token);
         if (!isset($_POST['content']) || empty($_POST['content'])) {
             $resp = array('success' => false, 'msg' => __('Social login is invalid. Please contact administrator for help.', ET_DOMAIN));
             wp_send_json($resp);
             return;
         }
         $data = $_POST['content'];
         if (!isset($data['id']) || $data['id'] == '') {
             $resp = array('success' => false, 'msg' => __('Social login is invalid. Please contact administrator for help.', ET_DOMAIN));
             wp_send_json($resp);
             return;
         }
         if (isset($fb_app_token['body']) && $fb_app_token['body'] != '') {
             $fb_app_token = explode('&', $fb_app_token['body']);
             $fb_token = explode('=', $fb_app_token['0']);
             if ($check_userid != $data['id'] || !isset($fb_token[1]) || $fb_token[1] == '') {
                 $fb_token = $fb_token['1'];
                 $resp = array('success' => false, 'msg' => __('Please login by using your Facebook account again!'));
                 wp_send_json($resp);
                 return;
             }
         } else {
             $resp = array('success' => false, 'msg' => __('Please login by using your Facebook account again!'));
             wp_send_json($resp);
             return;
         }
         // find usser
         $return = array('redirect_url' => home_url());
         $user = $this->get_user($data['id']);
         // if user is already authenticated before
         if ($user) {
             $result = $this->logged_user_in($data['id']);
             $ae_user = AE_Users::get_instance();
             $userdata = $ae_user->convert($user);
             $nonce = array('reply_thread' => wp_create_nonce('insert_reply'), 'upload_img' => wp_create_nonce('et_upload_images'));
             $return = array('user' => $userdata, 'nonce' => $nonce);
         } else {
             // avatar
             $ava_response = wp_remote_get('http://graph.facebook.com/' . $data['id'] . '/picture?type=large&redirect=false');
             if (!is_wp_error($ava_response)) {
                 $ava_response = json_decode($ava_response['body']);
             } else {
                 $ava_response = false;
             }
             $sizes = get_intermediate_image_sizes();
             $avatars = array();
             if ($ava_response) {
                 foreach ($sizes as $size) {
                     $avatars[$size] = array($ava_response->data->url);
                 }
             } else {
                 $avatars = false;
             }
             $data['name'] = str_replace(' ', '', sanitize_user($data['name']));
             $username = $data['name'];
             $params = array('user_login' => $username, 'user_email' => isset($data['email']) ? $data['email'] : false, 'description' => isset($data['bio']) ? $data['bio'] : false, 'user_location' => isset($data['location']) ? $data['location']['name'] : false, 'et_avatar' => $avatars);
             //remove avatar if cant fetch avatar
             foreach ($params as $key => $param) {
                 if ($param == false) {
                     unset($params[$key]);
                 }
             }
             $_SESSION['et_auth'] = serialize($params);
             $_SESSION['et_social_id'] = $data['id'];
             $_SESSION['et_auth_type'] = 'facebook';
             // try to use et session
             et_write_session('et_auth', serialize($params));
             et_write_session('et_social_id', $data['id']);
             et_write_session('et_auth_type', 'facebook');
             $return['params'] = $params;
             $return['redirect_url'] = $this->auth_url;
         }
         $resp = array('success' => true, 'msg' => __('You have logged in successfully', ET_DOMAIN), 'redirect' => home_url(), 'data' => $return);
     } catch (Exception $e) {
         $resp = array('success' => false, 'msg' => $e->getMessage());
     }
     wp_send_json($resp);
 }
コード例 #13
0
                            </span>
                                </div>
                                <div class="clearfix"></div>
                                <div class="form-group">
                            <span class="text-small">
                                <?php 
    _e('Select "Yes" to display a "Hire me" button on your profile allowing potential clients and employers to contact you.', 'page-profile');
    ?>
                            </span>
                                </div>
                                <div class="clearfix"></div>

                                <?php 
}
// display a link for user to request a confirm email
if (!AE_Users::is_activate($user_ID)) {
    ?>

                                <div class="form-group confirm-request">
                            <span class="text-small">
                                <?php 
    _e('You have not confirmed your email yet, please check out your mailbox.', 'page-profile');
    echo '<br/>';
    echo ' <a class="request-confirm" href="#">' . __('Request confirm email.', 'page-profile') . '</a>';
    ?>
                            </span>
                                </div>
                            <?php 
} else {
    ?>
コード例 #14
0
 /**
  * filter wp avatar use AE_Users return a image tag with user setting avatar url
  * @param $avatar
  * @param $id_or_email
  * @param $size
  * @author Dakachi
  * @version 1.0
  */
 function get_avatar($avatar, $id_or_email, $size, $default, $alt)
 {
     $seller = AE_Users::get_instance();
     $profile_picture = $seller->get_avatar($id_or_email, $size);
     /**
      * overide $default by profile picture
      */
     if ($profile_picture != '') {
         $default = $profile_picture;
         if (false === $alt) {
             $safe_alt = '';
         } else {
             $safe_alt = esc_attr($alt);
         }
         $avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
     }
     return $avatar;
 }
コード例 #15
0
ファイル: functions.php プロジェクト: maratdev/alllancer
 function filter_link_redirect_register($result)
 {
     if (!is_wp_error($result)) {
         // $user_info = get_userdata($result->ID);
         $role = ae_user_role($result->ID);
     } else {
         $role = '';
     }
     $redirect_url = $role == "employer" && AE_Users::is_activate($result->ID) ? et_get_page_link('submit-project') : et_get_page_link('profile');
     $result->redirect_url = apply_filters('ae_after_register_link', $redirect_url);
     $result->do = "register";
     return $result;
 }
コード例 #16
0
ファイル: linkedin.php プロジェクト: maratdev/alllancer
 /**
  * function handle after linkedin callback
  */
 public function linked_auth()
 {
     if (isset($_REQUEST['code']) && !empty($_REQUEST['code']) && (isset($_REQUEST['state']) || $_REQUEST['state'] == $this->state)) {
         try {
             /**
              * Step2: Exchange Authorization Code for a Request Token
              */
             $request = $_REQUEST;
             $redirect_uri = home_url('?action=linked_auth_callback');
             $args = array('method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => array('grant_type' => 'authorization_code', 'code' => $request['code'], 'redirect_uri' => $redirect_uri, 'client_id' => $this->linkedin_api_key, 'client_secret' => $this->linkedin_secret_key), 'cookies' => array());
             $remote_post = wp_remote_post($this->linkedin_token_url, $args);
             if (isset($remote_post['body']) && !empty($remote_post['body'])) {
                 $data = json_decode($remote_post['body']);
             } else {
                 _e('Error to connect to Linkedin server!', ET_DOMAIN);
                 exit;
             }
             if (!isset($data->access_token) || empty($data->access_token)) {
                 _e('Can not get the access token from Linkedin server!', ET_DOMAIN);
                 exit;
             }
             /**
              * Step3: Make authenticated requests and get user's informations
              */
             $args1 = array('timeout' => 120, 'httpversion' => '1.1', 'headers' => array('Authorization' => 'Bearer ' . $data->access_token));
             $remote_get = wp_remote_get($this->linkedin_people_url, $args1);
             if (isset($remote_get['body']) && !empty($remote_get['body'])) {
                 $data_user = json_decode($remote_get['body']);
             } else {
                 _e('Error to connect to Linkedin server2!', ET_DOMAIN);
                 exit;
             }
             if (!isset($data_user->id) || empty($data_user->id)) {
                 _e('Can not get user information from Linkedin server!', ET_DOMAIN);
                 exit;
             }
             // if user is already authenticated before
             if ($this->get_user($data_user->id)) {
                 $user = $this->get_user($data_user->id);
                 $result = $this->logged_user_in($data_user->id);
                 $ae_user = AE_Users::get_instance();
                 $userdata = $ae_user->convert($user);
                 $nonce = array('reply_thread' => wp_create_nonce('insert_reply'), 'upload_img' => wp_create_nonce('et_upload_images'));
             } else {
                 // avatar
                 $ava_response = isset($data_user->pictureUrl) ? $data_user->pictureUrl : '';
                 $sizes = get_intermediate_image_sizes();
                 $avatars = array();
                 if ($ava_response) {
                     foreach ($sizes as $size) {
                         $avatars[$size] = array($ava_response);
                     }
                 } else {
                     $avatars = false;
                 }
                 $data_user->formattedName = str_replace(' ', '', sanitize_user($data_user->formattedName));
                 $username = $data_user->formattedName;
                 $params = array('user_login' => $username, 'user_email' => isset($data_user->emailAddress) ? $data_user->emailAddress : false, 'et_avatar' => $avatars);
                 //remove avatar if cant fetch avatar
                 foreach ($params as $key => $param) {
                     if ($param == false) {
                         unset($params[$key]);
                     }
                 }
                 // turn on session
                 if (!isset($_SESSION)) {
                     ob_start();
                     @session_start();
                 }
                 /**
                  * set value into session for save later
                  *
                  */
                 $_SESSION['et_auth'] = serialize($params);
                 $_SESSION['et_social_id'] = $data_user->id;
                 $_SESSION['et_auth_type'] = 'linkedin';
                 et_write_session('et_auth', serialize($params));
                 et_write_session('et_social_id', $data_user->id);
                 et_write_session('et_auth_type', 'linkedin');
             }
             header('Location: ' . $this->auth_url);
             exit;
         } catch (Exception $e) {
             _e('Error to connect to Linkedin server', ET_DOMAIN);
             exit;
         }
     }
 }
コード例 #17
0
 /**
  * convert comments
  */
 function convert($comment, $thumb = 'thumbnail', $merge_post = true, $merge_author = true)
 {
     global $ae_post_factory;
     /**
      * add comment meta 
      */
     if (!empty($this->meta)) {
         foreach ($this->meta as $key => $value) {
             $comment->{$value} = get_comment_meta($comment->comment_ID, $value, true);
         }
     }
     // comment link
     $comment->comment_link = get_comment_link($comment->comment_ID);
     $comment->ID = $comment->comment_ID;
     $comment->id = $comment->comment_ID;
     // caculate date ago
     $comment->date_ago = et_the_time(strtotime($comment->comment_date));
     if ($merge_post) {
         /**
          * add post data to comment
          */
         if (!isset($this->post_arr[$comment->comment_post_ID])) {
             // check post exist or not
             $post = get_post($comment->comment_post_ID);
             if ($post && !is_wp_error($post)) {
                 // get register post object by post factory
                 $post_object = $ae_post_factory->get($post->post_type);
                 // if not null convert post
                 if ($post_object) {
                     $comment->post_data = $post_object->convert($post, $thumb, false);
                 } else {
                     // keep the simple post
                     $comment->post_data = $post;
                 }
                 // add post data to post_arr
                 $this->post_arr[$post->ID] = $comment->post_data;
             }
         } else {
             // post data already exist
             $comment->post_data = $this->post_arr[$comment->comment_post_ID];
         }
     }
     if ($merge_author) {
         /**
          * add author data to comment
          */
         if (!isset($this->author_arr[$comment->user_id])) {
             // user_id not existed in author_arr
             $author = get_userdata($comment->user_id);
             if ($author) {
                 $users = AE_Users::get_instance();
                 $comment->author_data = $users->convert($author);
                 // add author_data to author_arr
                 $this->author_arr[$comment->user_id] = $comment->author_data;
             }
         } else {
             // author data already exist
             $comment->author_data = $this->author_arr[$comment->user_id];
         }
     }
     $this->current_comment = $comment;
     return apply_filters('ae_convert_comment', $this->current_comment);
 }
コード例 #18
0
ファイル: functions.php プロジェクト: rinodung/wp-question
 function et_unban_expired_users()
 {
     global $wpdb;
     $user = AE_Users::get_instance();
     $user_query = new WP_User_Query(array('meta_key' => $user->meta_ban_expired, 'meta_value' => date(get_option('date_format')), 'meta_compare' => '<'));
     $users = $user_query->get_results();
     foreach ($users as $user) {
         AE_Users::unban($user->id);
     }
 }