Beispiel #1
0
 function prepareItem($item)
 {
     if (get_post_type($item) != $this->post_type) {
         return false;
     }
     $item->excerpt = $item->post_title;
     $item->userid = $item->post_parent;
     $item->content = $item->post_content;
     $item->rating = get_field('rating', $item->ID);
     $item->reviewer = $item->post_author;
     $item->reviewer_name = JS_User::getUser($item->post_author)->name;
     $item->reviewed_date = $item->post_date;
     $this->items[] = $item;
     return $item;
 }
Beispiel #2
0
 function __construct()
 {
     global $wp;
     parent::__construct();
     add_action('wp_enqueue_scripts', array($this, 'add_scripts'));
     $this->user_name = isset($wp->query_vars['snap_user']) ? $wp->query_vars['snap_user'] : $this->user_name;
     if ($this->user_name !== false) {
         $this->user = get_user_by('login', $this->user_name);
     } else {
         if (is_user_logged_in()) {
             $this->user = wp_get_current_user();
         } else {
             wp_redirect(site_url());
             exit;
         }
     }
     $this->user = JS_User::getUser($this->user);
 }
Beispiel #3
0
 static function getJobslistUrl($user_id)
 {
     if (!$user_id || !intval($user_id)) {
         return false;
     }
     $user = JS_User::getUser($user_id);
     $current_user = wp_get_current_user();
     if ($current_user->ID == $user_id) {
         return site_url('jobsshopper/my-timesnaps');
     } else {
         return site_url('timesnaps/' . $user->user_login);
     }
 }
Beispiel #4
0
 function _snap_job($job_id, $applicant_id = 0)
 {
     if (!$job_id || !intval($job_id)) {
         throw new Exception('Invalid jobs id.');
     }
     $jobs = get_post($job_id);
     $jobsboss_id = $jobs->post_author;
     if (!$applicant_id) {
         $applicant_id = get_current_user_id();
     }
     $applicant = JS_User::getUser($applicant_id);
     $data = array('job_id' => $job_id, 'applicant_id' => $applicant_id, 'jobsboss_id' => $jobsboss_id, 'snap_date' => date('Y-m-d H:i:s'), 'snap_status' => 'pending');
     if ($this->table->store($data) !== false) {
         $message_model = SnapJobs::getModel('message');
         $message = $message_model->createMessage(array('post_title' => 'Applicant of ' . $jobs->post_title, 'post_content' => sprintf("%s has just snapped your job.", $applicant->name)));
         $message_model->sendMessage($message, $jobsboss_id);
         return true;
     }
     return false;
 }
Beispiel #5
0
<?php

global $_js_helper;
$item = $this->item;
$user = JS_User::getUser($item->applicant_id);
$job = $this->getJob($item->job_id);
?>
<div class="col-md-4">
    <div class="item <?php 
echo implode($item->classes);
?>
"
         id="job-item-<?php 
echo $item->ID;
?>
" <?php 
echo $is_saved ? 'data-saved="1"' : '';
?>
>
        <div class="item-description">
            <h2><?php 
echo $job->post_title;
?>
</h2>
        </div>
        <!-- /.item-description -->
        <div class="item-info-date">
            <div class="row">
                <div class="col-xs-12">
                    Closed date:<br/>
                        <?php 
Beispiel #6
0
 /**
  * API get Saved Jobsshopper
  *
  * return array | null
  */
 function getSavedJobsShopper()
 {
     $this->checkTokenValidation();
     global $_js_helper;
     // check and return error if current user is not jobsboss
     if (!$_js_helper->is_jobsboss($this->user->ID)) {
         $this->setError('E403', 'You are not jobsboss');
         return null;
     }
     $saved_jobsshopper_ids = (array) get_user_meta($this->user->ID, 'snap_saved_jobsshopper', true);
     $saved_jobsshoppers = array();
     foreach ($saved_jobsshopper_ids as $key => $jid) {
         $profile = JS_User::getUser($jid)->data;
         unset($profile->user_pass);
         unset($profile->user_activation_key);
         unset($profile->user_status);
         $saved_jobsshoppers[] = $profile;
     }
     if (empty($saved_jobsshoppers)) {
         $this->setSuccess('You have saved no profile.');
     } else {
         $this->setSuccess(sprintf("You have saved %'.02d jobsshopper profiles", count($saved_jobsshoppers)));
     }
     return $saved_jobsshoppers;
 }
Beispiel #7
0
 function display($tmpl = null, $separator = false)
 {
     global $_js_helper;
     switch ($this->snap_task) {
         case 'save':
             $jobssnap_data = $_POST;
             $jobssnap_id = JS_Helper::get_input('id');
             $author = $jobssnap_data['author'];
             $title = $jobssnap_data['title'];
             $snap_tag = $jobssnap_data['snap_tag'];
             $content = $jobssnap_data['description'];
             unset($jobssnap_data['author']);
             unset($jobssnap_data['title']);
             unset($jobssnap_data['snap_tag']);
             unset($jobssnap_data['description']);
             unset($jobssnap_data['terms']);
             $args = array('ID' => $jobssnap_id, 'post_title' => $title, 'post_content' => $content, 'author' => $author, 'tax_input' => array('snap_tag' => $snap_tag));
             wp_update_post($args);
             foreach ($jobssnap_data as $meta_key => $meta_value) {
                 if ($meta_key == 'date') {
                     $meta_value = date('n/j/Y', strtotime($meta_value));
                 }
                 update_post_meta($jobssnap_id, $meta_key, $meta_value);
             }
             $hours_diff = JS_Helper::calc_total_hours($jobssnap_data['time_from'], $jobssnap_data['time_to']);
             update_post_meta($jobssnap_id, 'total_hour', $hours_diff);
             wp_redirect($_js_helper->getHomeUrl('my-jobssnaps'));
             exit;
             break;
         case 'edit':
             $this->item = $this->prepareItem(get_post(JS_Helper::get_input('id')));
             break;
         case 'add':
             $current_user = JS_User::getUser(get_current_user_id());
             $current_slot = $current_user->slots;
             $jobssnap_data = $_POST;
             if (empty($jobssnap_data)) {
                 break;
             }
             $author = $jobssnap_data['author'];
             $title = $jobssnap_data['title'];
             $snap_tag = $jobssnap_data['snap_tag'];
             $content = $jobssnap_data['description'];
             unset($jobssnap_data['author']);
             unset($jobssnap_data['title']);
             unset($jobssnap_data['snap_tag']);
             unset($jobssnap_data['description']);
             unset($jobssnap_data['terms']);
             $args = array('post_title' => $title, 'post_type' => 'jobssnap', 'post_content' => $content, 'author' => $author, 'tax_input' => array('snap_tag' => $snap_tag), 'post_status' => 'publish');
             $jobssnap = wp_insert_post($args, true);
             if (!is_wp_error($jobssnap)) {
                 foreach ($jobssnap_data as $meta_key => $meta_value) {
                     if ($meta_key == 'date') {
                         $meta_value = date('n/j/Y', strtotime($meta_value));
                     }
                     update_post_meta($jobssnap, $meta_key, $meta_value);
                 }
                 update_post_meta($jobssnap, 'snap_job_status', 'opened');
                 $hours_diff = JS_Helper::calc_total_hours($jobssnap_data['time_from'], $jobssnap_data['time_to']);
                 update_post_meta($jobssnap, 'total_hour', $hours_diff);
                 $slot = intval($current_slot) - 1;
                 update_user_meta($author, 'snap_package_post_jobs_slot', $slot);
                 wp_redirect($_js_helper->getHomeUrl('my-jobssnaps'));
                 exit;
             }
             break;
     }
     parent::display($tmpl, $separator);
 }
Beispiel #8
0
 function ajax_upload_cover_image()
 {
     foreach ($_FILES as $key => $uploadedfile) {
         $movefile = JS_User::uploadProfileImage($key);
     }
     echo json_encode(wp_get_attachment_url($movefile, 'cover'));
     exit;
 }