Ejemplo n.º 1
0
<?php

/**
 * Template: BLOG LISTING AUTHOR
 * version 1.0
 * @author: ThaiNT
 **/
et_get_mobile_header();
global $wp_query, $wp_rewrite, $current_user;
$user = get_user_by('id', get_query_var('author'));
$user = QA_Member::convert($user);
?>
<!-- CONTAINER -->
<div class="wrapper-mobile">
	<!-- TOP BAR -->
	<section class="profile-user-wrapper">
    	<div class="container">
            <div class="row">
                <div class="col-md-3 col-xs-3 padding-right-0">
                    <a href="javascript:void(0);" class="profile-avatar">
                        <?php 
echo et_get_avatar($user->ID, 65);
?>
                    </a>
                </div>
                <div class="col-md-9 col-xs-9">
                    <div class="profile-wrapper">
                    	<span class="user-name-profile"><?php 
echo esc_attr($user->display_name);
?>
</span>
Ejemplo n.º 2
0
    public function add_user_actions_backend($user)
    {
        $user = QA_Member::convert($user);
        if ($user->register_status == "unconfirm") {
            ?>
		<a class="action et-act-confirm" data-act="confirm" href="javascript:void(0)" title="<?php 
            _e('Confirm this user', ET_DOMAIN);
            ?>
">
			<span class="icon" data-icon="3"></span>
		</a>
		<?php 
        }
    }
Ejemplo n.º 3
0
 public function auth_google()
 {
     try {
         // turn on session
         if (!isset($_SESSION)) {
             ob_start();
             @session_start();
         }
         $data = $_POST['content'];
         // find usser
         $user = false;
         $return = array('redirect_url' => home_url());
         $gplus_client_id = ae_get_option('gplus_client_id');
         $gplus_secret_id = ae_get_option('gplus_secret_id');
         // if user is already authenticated before
         if (isset($_POST['gplus_token']) && isset($_POST['gplus_code'])) {
             $userinfor = wp_remote_get('https://www.googleapis.com/oauth2/v1/userinfo?access_token=' . $_POST['gplus_token']);
             $userinfor = json_decode($userinfor['body']);
             if ($userinfor->id !== $data['id']) {
                 $resp = array('success' => false, 'msg' => __('Please login by using your Google plus account again!', ET_DOMAIN));
             }
         } else {
             $resp = array('success' => false, 'msg' => __('Please login by using your Google plus account again!', ET_DOMAIN));
         }
         // if user is already authenticated before
         if (isset($data['id']) && ($user = $this->get_user($data['id']))) {
             //
             $result = $this->logged_user_in($data['id']);
             $userdata = QA_Member::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 = isset($data['picture']) ? $data['picture'] : '';
             $sizes = get_intermediate_image_sizes();
             $avatars = array();
             if ($ava_response) {
                 foreach ($sizes as $size) {
                     $avatars[$size] = array($ava_response);
                 }
             } else {
                 $avatars = false;
             }
             // username
             //$username 	= $data['displayName'];
             $username = $data['name'];
             $params = array('user_login' => $username, 'user_email' => isset($data['email']) ? $data['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'] = $data['id'];
             $_SESSION['et_auth_type'] = 'google';
             $return['params'] = $params;
             $return['redirect_url'] = $this->auth_url;
             // et_get_page_link('social-connect');
         }
         $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);
 }
Ejemplo n.º 4
0
?>
  href="javascript:void(0)" data-name="vote_down"
                class="<?php 
echo $vote_down_class;
?>
">
        		<i class="fa fa-chevron-down"></i>
        	</a>
        </li>
        <!--// vote down -->
		<?php 
if (is_singular('question')) {
    if ($post->post_type == 'answer') {
        $active = $qa_question->et_best_answer == $qa_answer->ID ? 'active' : '';
        // Get user point
        $user = QA_Member::convert($current_user);
        $user_point = $user->qa_point;
        // Get badges
        $levels = qa_get_privileges();
        $approve_answer = $levels->approve_answer;
        //if( $user_point > $approve_answer || $current_user->ID == $qa_question->post_author || $active != '' ){
        $answer_authorname = get_the_author_meta('display_name', $qa_answer->post_author);
        $data_name = 'data-name="' . ($qa_question->et_best_answer == $qa_answer->ID ? 'un-accept-answer' : 'accept-answer') . '"';
        ?>
                    <li title="<?php 
        _e('Mark as best answer', ET_DOMAIN);
        //printf(__("Agree with %s", ET_DOMAIN), $answer_authorname );
        ?>
" >
                    	<a  href="javascript:void(0)"
                    	   <?php 
Ejemplo n.º 5
0
 public function forgot()
 {
     $errors = new WP_Error();
     $args = $_POST['content'];
     if (empty($args['user_login'])) {
         $errors->add('empty_username', __('<strong>ERROR</strong>: Enter username or email address.', ET_DOMAIN));
     } else {
         if (strpos($args['user_login'], '@')) {
             $user_data = get_user_by('email', trim($args['user_login']));
             if (empty($user_data)) {
                 $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', ET_DOMAIN));
             }
         } else {
             $login = trim($args['user_login']);
             $user_data = get_user_by('login', $login);
         }
     }
     // call the retrieve password request
     $result = et_retrieve_password($user_data, $errors);
     $user = QA_Member::convert($user_data);
     if (is_wp_error($result)) {
         $response = array('success' => false, 'msg' => $result->get_error_message());
     } else {
         $response = array('success' => true, 'msg' => __('Please check your email inbox to reset password.', ET_DOMAIN), 'data' => array('ID' => $user->ID, 'id' => $user->ID));
     }
     return $response;
 }
Ejemplo n.º 6
0
    public function scripts_in_footer()
    {
        global $current_user;
        ?>
		<script type="text/javascript">
            _.templateSettings = {
                evaluate: /\<\#(.+?)\#\>/g,
                interpolate: /\{\{=(.+?)\}\}/g,
                escape: /\{\{-(.+?)\}\}/g
            };
        </script>
		<script type="text/javascript" id="frontend_scripts">
			(function ($) {
				$(document).ready(function(){

					<?php 
        if (!et_load_mobile()) {
            ?>

					if(typeof QAEngine.Views.Front != 'undefined') {
						QAEngine.App = new QAEngine.Views.Front();
					}

					if(typeof QAEngine.Views.Intro != 'undefined') {
						QAEngine.Intro = new QAEngine.Views.Intro();
					}

					if(typeof QAEngine.Views.UserProfile != 'undefined') {
						QAEngine.UserProfile = new QAEngine.Views.UserProfile();
					}

					if(typeof QAEngine.Views.Single_Question != 'undefined') {
						QAEngine.Single_Question = new QAEngine.Views.Single_Question();
					}

					<?php 
            if (is_page_template('page-pending.php')) {
                ?>
					if(typeof QAEngine.Views.PendingQuestions != 'undefined') {
						QAEngine.PendingQuestions = new QAEngine.Views.PendingQuestions();
					}
					<?php 
            }
            ?>

					/*======= Open Reset Password Form ======= */
					<?php 
            if (isset($_GET['user_login']) && isset($_GET['key']) && !is_user_logged_in()) {
                ?>
						var resetPassModal = new QAEngine.Views.ResetPassModal({ el: $("#reset_password") });
						resetPassModal.openModal();
					<?php 
            }
            ?>

					/*======= Open Reset Password Form ======= */
					<?php 
            if (isset($_GET['confirm']) && $_GET['confirm'] == 0) {
                ?>
						AE.pubsub.trigger('ae:notification', {
							msg: "<?php 
                _e("You need to verify your account to view the content.", ET_DOMAIN);
                ?>
",
							notice_type: 'error',
						});
					<?php 
            }
            ?>

					/*======= Open Confirmation Message Modal ======= */
					<?php 
            global $qa_confirm;
            if ($qa_confirm) {
                ?>
						AE.pubsub.trigger('ae:notification', {
							msg: "<?php 
                _e("Your account has been confirmed successfully!", ET_DOMAIN);
                ?>
",
							notice_type: 'success',
						});
					<?php 
            }
            ?>

					<?php 
        }
        ?>
				});
			})(jQuery);
		</script>
		<script type="text/javascript" id="current_user">
		 	currentUser = <?php 
        if ($current_user->ID) {
            echo json_encode(QA_Member::convert($current_user));
        } else {
            echo json_encode(array('id' => 0, 'ID' => 0));
        }
        ?>
		</script>
		<?php 
        echo '<!-- GOOGLE ANALYTICS CODE -->';
        $google = ae_get_option('google_analytics');
        $google = implode("", explode("\\", $google));
        echo stripslashes(trim($google));
        echo '<!-- END GOOGLE ANALYTICS CODE -->';
    }
Ejemplo n.º 7
0
 public function update_post()
 {
     try {
         global $current_user;
         if (!isset($_POST['do_action'])) {
             throw new Exception(__("Invalid action", ET_DOMAIN));
         }
         if (isset($_POST['content']['post_title']) && $_POST['content']['post_title'] != strip_tags($_POST['content']['post_title'])) {
             throw new Exception(__("Post title should not contain any HTML Tag.", ET_DOMAIN));
         }
         $action = $_POST['do_action'];
         switch ($action) {
             case 'vote_down':
                 if (!qa_user_can('vote_down')) {
                     throw new Exception(__("You don't have enough point to vote up.", ET_DOMAIN));
                 }
             case 'vote_up':
                 if (!qa_user_can('vote_up')) {
                     throw new Exception(__("You don't have enough point to vote down.", ET_DOMAIN));
                 }
                 QA_Questions::vote($_POST['ID'], $action);
                 $post = QA_Questions::convert(get_post($_POST['ID']));
                 $resp = array('success' => true, 'data' => $post);
                 break;
             case 'accept-answer':
             case 'un-accept-answer':
                 $question = QA_Questions::convert(get_post($_POST['post_parent']));
                 $answerID = $action == "accept-answer" ? $_POST['ID'] : 0;
                 // Get user point
                 $user = QA_Member::convert($current_user);
                 $user_point = $user->qa_point;
                 // Get badges
                 $levels = qa_get_privileges();
                 $approve_answer = $levels->approve_answer;
                 if ($question->et_best_answer == "0") {
                     if ($current_user->ID == $question->post_author || $user_point > $approve_answer) {
                         QA_Questions::mark_answer($_POST['post_parent'], $answerID);
                         do_action('qa_accept_answer', $answerID, $action);
                         $resp = array('success' => true);
                     } else {
                         throw new Exception(__("You don't have enough point to approve answer.", ET_DOMAIN));
                         return false;
                     }
                 } elseif ($question->et_best_answer != "0") {
                     if ($current_user->ID == $question->post_author) {
                         QA_Questions::mark_answer($_POST['post_parent'], $answerID);
                         do_action('qa_accept_answer', $answerID, $action);
                         $resp = array('success' => true);
                     } else {
                         throw new Exception(__("Only author has right to change the best answer.", ET_DOMAIN));
                         return false;
                     }
                 } else {
                     // throw new Exception(__("Only author has right to change the best answer.", ET_DOMAIN));
                     // return false;
                 }
                 break;
             case 'saveComment':
                 $data = array();
                 $data['comment_ID'] = $_POST['comment_ID'];
                 $data['comment_content'] = $_POST['comment_content'];
                 $success = QA_Comments::update($data);
                 $comment = QA_Comments::convert(get_comment($_POST['comment_ID']));
                 $resp = array('success' => true, 'data' => $comment);
                 break;
             case 'savePost':
                 $data = array();
                 $data['ID'] = $_POST['ID'];
                 $data['post_content'] = $_POST['post_content'];
                 $data['post_author'] = $_POST['post_author'];
                 $success = QA_Answers::update($data);
                 $post = QA_Answers::convert(get_post($_POST['ID']));
                 if ($success && !is_wp_error($success)) {
                     $resp = array('success' => true, 'data' => $post);
                 } else {
                     $resp = array('success' => false, 'data' => $post, 'msg' => $success->get_error_message());
                 }
                 break;
             case 'saveQuestion':
                 $data = $_POST['content'];
                 $data['ID'] = $_POST['ID'];
                 $data['qa_tag'] = isset($data['tags']) ? $data['tags'] : array();
                 $data['post_author'] = $_POST['post_author'];
                 unset($data['tags']);
                 do_action('qa_before_save_question', $data);
                 $success = QA_Questions::update($data);
                 $post = QA_Questions::convert(get_post($_POST['ID']));
                 if ($success && !is_wp_error($success)) {
                     $resp = array('success' => true, 'data' => $post, 'msg' => __('Question has been saved successfully.', ET_DOMAIN), 'redirect' => get_permalink($_POST['ID']));
                 } else {
                     $resp = array('success' => false, 'data' => $post, 'msg' => $success->get_error_message());
                 }
                 break;
             case 'approve':
                 $id = $_POST['ID'];
                 $success = QA_Questions::change_status($id, "publish");
                 $post = QA_Questions::convert(get_post($id));
                 $point = qa_get_badge_point();
                 //store question id to data for send mail
                 QA_Engine::qa_questions_new_answer($id);
                 if ($success && !is_wp_error($success)) {
                     if ($post->post_type == "question") {
                         //add points to user
                         if (!empty($point->create_question)) {
                             qa_update_user_point($post->post_author, $point->create_question);
                         }
                         // set transient for new question
                         set_transient('qa_notify_' . mt_rand(100000, 999999), array('title' => __('New Question', ET_DOMAIN), 'content' => __("There's a new post, why don't you give a look at", ET_DOMAIN) . ' <a href ="' . get_permalink($id) . '">' . get_the_title($id) . '</a>', 'type' => 'update', 'user' => md5($current_user->user_login)), 20);
                         $resp = array('success' => true, 'data' => $post, 'msg' => __("You've just successfully approved a question.", ET_DOMAIN), 'redirect' => get_permalink($id));
                     } else {
                         if ($post->post_type == "answer") {
                             //add point to user
                             if (!empty($point->post_answer)) {
                                 qa_update_user_point($post->post_author, $point->post_answer);
                             }
                             $resp = array('success' => true, 'data' => $post, 'msg' => __("You've just successfully approved an answer.", ET_DOMAIN), 'redirect' => get_permalink($id));
                         }
                     }
                 } else {
                     $resp = array('success' => false, 'data' => $post, 'msg' => $success->get_error_message());
                 }
                 break;
             case 'follow':
             case 'unfollow':
                 if (!$current_user->ID) {
                     throw new Exception(__('Login required', ET_DOMAIN));
                 }
                 $result = QA_Questions::toggle_follow($_POST['ID'], $current_user->ID);
                 if (!is_array($result)) {
                     throw new Exception(__('Error occurred', ET_DOMAIN));
                 }
                 if (in_array($current_user->ID, $result)) {
                     $msg = __('You have started following this question.', ET_DOMAIN);
                 } else {
                     $msg = __('You have stopped following this question.', ET_DOMAIN);
                 }
                 $resp = array('success' => true, 'msg' => $msg, 'data' => array('isFollow' => in_array($current_user->ID, $result), 'following' => $result));
                 break;
             case 'report':
                 $id = $_POST['ID'];
                 if (!isset($_POST) || !$id) {
                     throw new Exception(__("Invalid post", ET_DOMAIN));
                 } else {
                     $fl = $this->report($id, $_POST['data']['message']);
                     if ($fl) {
                         $resp = array('success' => true, 'msg' => __("You have reported successfully", ET_DOMAIN));
                     } else {
                         $resp = array('success' => false, 'msg' => __("Error when reported!", ET_DOMAIN));
                     }
                 }
                 break;
             default:
                 throw new Exception(__("Invalid action", ET_DOMAIN));
                 break;
         }
     } catch (Exception $e) {
         $resp = array('success' => false, 'msg' => $e->getMessage());
     }
     return $resp;
 }