PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Project/faci-qsoft/wp-content/themes/noo-jobmonster/framework/admin/noo_job.php

https://gitlab.com/hop23typhu/list-theme
PHP | 338 lines | 243 code | 69 blank | 26 comment | 27 complexity | d7e08694307328f8c76abf203b88bd64 MD5 | raw file
  1. <?php
  2. if(!class_exists('Noo_Job')) :
  3. class Noo_Job {
  4. protected static $_instance = null;
  5. public function __construct() {
  6. // add_action( 'init', array( $this, 'register_post_type' ), 0 );
  7. // add_action('noo_job_check_expired_jobs', array($this,'check_expired_jobs'));
  8. // add_action('noo_job_reset_job_counter', array($this,'reset_job_counter'));
  9. // schema
  10. }
  11. protected function _get_job_map_data(){
  12. return jm_build_job_map_data();
  13. }
  14. public static function get_setting($group, $id = null ,$default = null){
  15. return jm_get_setting( $group, $id, $default );
  16. }
  17. public static function get_default_fields( $include_tax_fields = true ) {
  18. return jm_get_job_default_fields( $include_tax_fields );
  19. }
  20. public static function get_custom_fields_option($key = '', $default = null){
  21. return jm_get_job_custom_fields_option( $key, $default );
  22. }
  23. public static function advanced_search_field($field_val='', $is_resume = false, $tag_id = 'search-custom-field', $show_label = false ){
  24. if( $is_resume ) {
  25. return jm_resume_advanced_search_field( $field_val );
  26. } else {
  27. return jm_job_advanced_search_field( $field_val );
  28. }
  29. }
  30. /**
  31. * Check use job package
  32. * @return boolean
  33. */
  34. public static function use_woocommerce_package(){
  35. return jm_is_woo_job_posting();
  36. }
  37. public static function get_application_method($post = null){
  38. $post = get_post( $post );
  39. if ( $post->post_type !== 'noo_job' )
  40. return;
  41. $method = new stdClass();
  42. $apply = get_post_meta($post->ID,'_application_email',true);
  43. if ( empty( $apply ) )
  44. return false;
  45. if ( strstr( $apply, '@' ) && is_email( $apply ) ) {
  46. $method->type = 'email';
  47. $method->raw_email = $apply;
  48. $method->email = antispambot( $apply );
  49. $method->subject = apply_filters( 'noo_job_application_email_subject', sprintf( __( 'Application via "%s" on %s', 'noo' ), $post->post_title, home_url() ), $post );
  50. } else {
  51. if ( strpos( $apply, 'http' ) !== 0 )
  52. $apply = 'http://' . $apply;
  53. $method->type = 'url';
  54. $method->url = $apply;
  55. }
  56. return apply_filters( 'noo_job_get_application_method', $method, $post );
  57. }
  58. public static function get_job_locations($search_name = ''){
  59. return jm_search_job_location( $search_name );
  60. }
  61. public static function jobpackage_handler() {
  62. if( jm_is_woo_job_posting() ) {
  63. if( isset( $_GET['package_id'] ) || jm_get_job_posting_remain() > 0 ) {
  64. wp_safe_redirect(esc_url_raw(add_query_arg( 'action', 'post_job')));
  65. }
  66. }
  67. return;
  68. }
  69. public static function login_handler(){
  70. if(Noo_Member::is_logged_in()) {
  71. if(jm_is_woo_job_posting()) {
  72. wp_safe_redirect(esc_url_raw(add_query_arg( 'action', 'job_package')));
  73. }
  74. else {
  75. wp_safe_redirect(esc_url_raw(add_query_arg( 'action', 'post_job')));
  76. }
  77. }
  78. return;
  79. }
  80. public static function get_employer_package($employer_id=''){
  81. return jm_get_job_posting_info( $employer_id );
  82. }
  83. public static function get_job_remain( $employer_id = '' ) {
  84. return jm_get_job_posting_remain($employer_id);
  85. }
  86. public static function get_job_added( $employer_id = '' ) {
  87. return jm_get_job_posting_added( $employer_id );
  88. }
  89. public static function increase_job_count($employer_id='') {
  90. jm_increase_job_posting_count( $employer_id );
  91. }
  92. public static function decrease_job_count($employer_id='') {
  93. jm_decrease_job_posting_count( $employer_id );
  94. }
  95. public static function set_job_expires($job_id='') {
  96. jm_set_job_expired( $job_id );
  97. }
  98. /**
  99. *
  100. * @param int $employer_id
  101. * @param bool $is_paged
  102. * @param bool $only_publish
  103. * @return WP_Query
  104. */
  105. public static function get_job_by_employer($employer_id='',$is_paged = true,$only_publish = false){
  106. return jm_user_job_query( $employer_id, $is_paged, $only_publish );
  107. }
  108. public static function get_employer_company($employer_id=''){
  109. return jm_get_employer_company( $employer_id );
  110. }
  111. public static function can_add_job($employer_id = ''){
  112. return jm_can_post_job( $employer_id );
  113. }
  114. /**
  115. * Retrieve get feature job by employer
  116. *
  117. * @param string $employer_id
  118. * @return WP_Query
  119. */
  120. public static function get_count_feature_job_by_employer($employer_id=''){
  121. return jm_get_feature_job_added($employer_id);
  122. }
  123. public static function can_set_job_feature($employer_id = ''){
  124. return jm_can_set_feature_job( $employer_id );
  125. }
  126. public static function get_remain_job_feature($employer_id = '') {
  127. return jm_get_feature_job_remain( $employer_id );
  128. }
  129. public static function send_notification($job_id = null, $user_id = 0) {
  130. if( empty( $job_id ) ) {
  131. return false;
  132. }
  133. if( empty( $user_id ) ) $user_id = get_current_user_id();
  134. $job = get_post($job_id);
  135. if( empty( $job ) ) return;
  136. $current_user = get_userdata( $user_id );
  137. if( $current_user->ID != $job->post_author ) {
  138. return false;
  139. }
  140. $emailed = noo_get_post_meta( $job_id, '_new_job_emailed', 0 );
  141. if( $emailed ) {
  142. return false;
  143. }
  144. if ( is_multisite() )
  145. $blogname = $GLOBALS['current_site']->site_name;
  146. else
  147. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  148. $company = get_post(absint(jm_get_employer_company($current_user->ID)));
  149. $job_need_approve = jm_get_job_setting( 'job_approve','yes' ) == 'yes';
  150. if( $job_need_approve ) {
  151. $job_link = esc_url( add_query_arg( 'job_id', get_the_ID(), Noo_Member::get_endpoint_url('preview-job') ) );
  152. //admin email
  153. $subject = sprintf(__('[%1$s] New job submitted: %2$s','noo'),$blogname,$job->post_title);
  154. $to = get_option('admin_email');
  155. $message = __('%1$s has just submitted a job for review.<br/><br/>
  156. <a href="%2$s">View Job Detail</a>.<br/><br/>
  157. Best regards,<br/>
  158. %3$s','noo');
  159. noo_mail($to, $subject, sprintf($message,$company->post_title,get_permalink($job_id),$blogname),array(),'noo_notify_job_submitted_admin');
  160. // employer email
  161. $subject = sprintf(__('[%1$s] You\'ve submitted job %2$s','noo'),$blogname,$job->post_title);
  162. $to = $current_user->user_email;
  163. $message = __('Hi %1$s,<br/><br/>
  164. You\'ve submitted a new job:<br/>
  165. <a href="%2$s">View Job Detail</a>.
  166. <br/><br/>
  167. We will review your job and replied back to you soon.<br/>
  168. You can manage and follow sattus of your jobs in <a href="%3$s">Manage Jobs</a><br/><br/>
  169. Best regards,<br/>
  170. %4$s','noo');
  171. noo_mail($to, $subject, sprintf($message,$current_user->display_name,$job_link,Noo_Member::get_endpoint_url('manage-job'),$blogname),array(),'noo_notify_job_submitted_employer');
  172. } else {
  173. $job_link = get_permalink($job_id);
  174. //admin email
  175. $subject = sprintf(__('[%1$s] New job posted: %2$s','noo'),$blogname,$job->post_title);
  176. $to = get_option('admin_email');
  177. $message = __('%1$s has just posted a job:<br/><br/>
  178. <a href="%2$s">View Job Detail</a>.
  179. <br/><br/>
  180. Best regards,<br/>
  181. %3$s','noo');
  182. noo_mail($to, $subject, sprintf($message,$company->post_title,$job_link,$blogname),array(),'noo_notify_job_submitted_admin');
  183. // employer email
  184. $subject = sprintf(__('[%1$s] You\'ve successfully post job %2$s','noo'),$blogname,$job->post_title);
  185. $to = $current_user->user_email;
  186. $message = __('Hi %1$s,<br/><br/>
  187. You\'ve successfully post a new job:<br/>
  188. <a href="%2$s">View Job Detail</a>.
  189. <br/><br/>
  190. You can manage your jobs in <a href="%3$s">Manage Jobs</a><br/><br/>
  191. Best regards,<br/>
  192. %4$s','noo');
  193. noo_mail($to, $subject, sprintf($message,$current_user->display_name,get_permalink($job_id),Noo_Member::get_endpoint_url('manage-job'),$blogname),array(),'noo_notify_job_submitted_employer');
  194. }
  195. update_post_meta( $job_id, '_new_job_emailed', 1 );
  196. }
  197. public static function get_job_type($job = null ) {
  198. return jm_get_job_type($job);
  199. }
  200. public static function get_job_status(){
  201. return jm_get_job_status();
  202. }
  203. public static function is_page_post_job(){
  204. return jm_is_job_posting_page();
  205. }
  206. public static function need_login(){
  207. return !Noo_Member::is_logged_in();
  208. }
  209. private static $linkedin_script_loaded;
  210. public static function load_linkedin_script() {
  211. static $linkedin_script_loaded = false;
  212. if( $linkedin_script_loaded ) return;
  213. $linkedin_script_loaded = true;
  214. $protocol = is_ssl() ? 'https' : 'http';
  215. ?>
  216. <script type="text/javascript" src="<?php echo $protocol; ?>://platform.linkedin.com/in.js">
  217. <?php
  218. echo 'api_key: ' . jm_get_setting('noo_job_linkedin','api_key') . "\n";
  219. echo 'authorize: true' . "\n";
  220. if( is_ssl() )
  221. echo 'credentials_cookie: true';
  222. ?>
  223. </script>
  224. <?php
  225. }
  226. public static function social_share( $post_id = null, $title = '' ) {
  227. jm_the_job_social( $post_id, $title );
  228. }
  229. public static function the_job_meta($args = '', $job = null) {
  230. jm_the_job_meta( $args, $job );
  231. }
  232. // backward compatible
  233. public static function noo_contentjob_meta($args = '', $job = null) {
  234. jm_the_job_meta( $args, $job );
  235. }
  236. public static function the_job_tag($job = null) {
  237. jm_the_job_tag( $job );
  238. }
  239. public static function display_detail($query=null,$in_preview=false){
  240. jm_job_detail( $query, $in_preview );
  241. }
  242. public static function loop_display( $args = '' ) {
  243. jm_job_loop( $args );
  244. }
  245. public static function get_bookmarked_job_ids( $user_id = 0 ) {
  246. return jm_get_candidate_bookmarked_job( $user_id );
  247. }
  248. public static function set_bookmark_job( $user_id = 0, $job_id = 0 ) {
  249. return jm_job_set_bookmarked( $user_id, $job_id );
  250. }
  251. public static function clear_bookmark_job( $user_id = 0, $job_id = 0 ) {
  252. return jm_job_clear_bookmarked( $user_id, $job_id );
  253. }
  254. public static function is_bookmarked( $user_id = 0, $job_id = 0 ) {
  255. return jm_is_job_bookmarked( $user_id, $job_id );
  256. }
  257. public static function geolocation_enabled(){
  258. return jm_geolocation_enabled();
  259. }
  260. public static function get_job_geolocation($raw_address){
  261. return jm_get_geolocation($raw_address);
  262. }
  263. public static function related_jobs( $job_id, $title ) {
  264. jm_related_jobs( $job_id, $title );
  265. }
  266. }
  267. new Noo_Job();
  268. endif;