Jump to content

Help for specifying an external url link for a job board


arts99

Recommended Posts

Hi,

 

I have a job board which allows the employers to post vacancies and the seekers to apply for these vacancies, before they apply the system checks if they are logged in or not and if they are logged in then they can apply for the job.

 

Certain employers want to be able to specify their specific url for people to go to and then apply for the job on that url.

 

I think I can easily add the column in the database table to accomodate for the custom apply url but i need help as to how to program the system so that in case of a custom url provided for a job then on pressing the apply button the user is taken to the external url to apply for the vacancy.

 

I am pasting the php code to give you an insight as to how the system is configured at the moment: I have marked in red the lines which I think are directly related to apply link.

 

Any guidance will be highly appreciated.

 

Thank you.

 

<?php

 

require_once "/lib/base_classes.lib";

require_once "/lib/form_xml.lib";

require_once "/lib/util.lib";

 

class view_job extends _page

{

  var $footer = true;

var $user_id;

var $is_admin = false;

  function view_job(){

    $application = & application ();

    $this->set_name('view_job');

    $this->_need_login = false;

    $application->output['job'] = '';

$this->user_id = $application->clean_cookie('id', 'intval'); // Get user id in case we need to check permissions on a suspended job

 

// If logged into smartway, show any job id they want

$bd3auth = $application->cookie('bd3Auth');

if ($bd3auth == md5($application->config('admin_login') . chr(0) . base64_decode($application->config('admin_pswd')))){

$this->is_admin = true;

  }

  }

 

  function set_footer($bool)

  {

      $this->footer = $bool;

  }

 

  function display()

  {

$application =& application();

$status = $application->clean_cookie('status', 'basename'); // Get value of cookie- either 'seeker' or 'employer'

if($application->show_header()){

if($status == 'seeker'){

$this->load_page('seeker_area');

}

else if($status=='employer'){

$this->load_page('employer_area');

}

else{

$this->load_page('no_login');

}

}

$this->prepare_errors();

    parent::display();

  } // display

 

  function default_action()

  {

    $application =& application();

    $text = $application->text();

    $post_id = $application->clean_input('post_id', 'intval');

    if (!$post_id){ // No job post given or its not a number, so dont bother checking

      $this->generate_error($text['post_id_invalid']);

      $this->prepare_errors();

      _page::default_action();

      return;

    }

    else{

      $sql =& sql();

      $hash = $application->input('hash');

      $sql_query = "SELECT jb.id, jb.employer_id, jb.job_title, jb.city, jb.state, jb.country, jb.job_type, jb.position_type, jb.req_education, jb.req_experience, jb.short_description, jb.long_description, jb.salary_type, jb.approx_salary, jb.approx_salary_range, u.company_name, e.logo_filename FROM jb_jobs AS jb LEFT JOIN jb_users AS u ON u.id = jb.employer_id LEFT JOIN jb_employers AS e ON e.employer_id = jb.employer_id  WHERE jb.id = $post_id";

if(!$this->is_admin && $hash == ''){

$sql_query .= " AND (jb.status = 'active' OR ((jb.status='suspended' OR jb.status='waiting') AND jb.employer_id ='{$this->user_id}'))";

}

else if($hash){

$sql_query .= " AND (MD5(jb.time) = \"".$hash."\")";

}

$sql->query($sql_query);

      if ($sql->is_empty()){ // No job found

        $sql->free_result();

        $this->generate_error("job_post_nonexistent");

      }

      else{

        $f = $sql->fetch(MYSQL_ASSOC);

        $sql->free_result();

      $this->increment_field($post_id, "num_viewed"); // Increment num_viewed statistic

// Query table for contact info

$sql->query("SELECT j.id, u.first_name AS f_contact, u.last_name AS l_contact, e.email, fnum.phone AS fax,  pnum.phone AS phone, addr.street AS addr1, addr.city AS addr2, addr.state AS addr3 FROM jb_jobs AS j INNER JOIN jb_privacy AS p ON (p.id=j.employer_id) LEFT JOIN jb_emails AS e ON (j.employer_id = e.user_id AND e.is_default = 1 AND p.show_email = 1)LEFT JOIN jb_phone_numbers AS pnum ON (j.employer_id = pnum.user_id AND pnum.is_default = 1 AND p.show_phone=1) LEFT JOIN jb_users AS u ON (j.employer_id=u.id AND p.show_name = 1) LEFT JOIN jb_phone_numbers as fnum ON (j.employer_id = fnum.user_id AND fnum.name='FAX' AND p.show_fax=1) LEFT JOIN jb_addresses AS addr ON (j.employer_id = addr.user_id AND p.show_address = 1) WHERE j.id = $post_id");

$g = $sql->fetch(MYSQL_ASSOC);

$sql->free_result();

if($f['logo_filename']!='&no_logo..jpg'){

$application->output['company_image'] = $f['logo_filename'];

  $dims = $this->get_new_image_dims('uploads/'.$f['logo_filename']);

    $application->output['img_constraints'] = " width=\"{$dims['width']}\" height=\"{$dims['height']}\"";

 

}

$application->output['job_title'] = $f['job_title'];

$application->output['job_table'] = $this->generate_table($f);

$application->output['short_description'] =$f['short_description'];

$allowable_tags='<br>';

$allowable_tags .=  str_replace(',', '>, <', $application->config('allowable_tags'));

$application->output['long_description'] = strip_tags(html_entity_decode(preg_replace("/\n/", "<br>", $f['long_description'])), $allowable_tags);

$application->output['apply_link'] = $this->apply_link($g);

$application->output['save_job_link'] =$this->save_link($g);

$g['contact'] = $g['f_contact'] . ' '.$g['l_contact'];

unset($g['f_contact']);

unset($g['l_contact']);

ksort($g);

$application->output['contact_table'] = $this->generate_contact_table($g);

      }

    }

    parent::default_action();

  } // default_action

 

function apply_link($row){ // Only show link if they haven't applied for job yet

$application =& application();

$user_id = $application->clean_cookie('id', 'intval');

if($user_id==0){

return '';

}

$status = $application->clean_cookie('status', 'basename');

$sql =& sql();

$sql->query("SELECT COUNT(0) as count FROM jb_apply_job_log WHERE post_id = {$row['id']} AND user_id = $user_id");

$result = $sql->fetch();

$sql->free_result();

if($result['count'] == 0 && $status == 'seeker' ){

return "<a href=\"?page=apply_for_job&post_id={$row['id']}\">" .  $application->text('apply_job') . "</a>";

}

else{

return '';

}

} // apply_link

 

function save_link($row){ // Only show link if they're a seeker

$application =& application();

if($application->clean_cookie('status', 'basename') == 'seeker'){

return  "<a href=\"?page=saved_jobs&action=save&post_id={$row['id']}\">" . $application->text('save_job') . "</a>";

}

else{

return '';

} } // save_link

  function increment_field($post_id, $field_name){

    $sql =& sql();

    $sql->update(array('`jb_jobs`' =>

      array($field_name => $field_name . ' + 1')),

    "id = $post_id", 'LIMIT 1');

  }

 

  function generate_contact_table($f){ // Create table containing contact information for job

$application =& application();

    $text = $application->text();

$job_id = sprintf("%06d", $f['id']);

$html = "<table class='view_contact'>";

$side = 0;

foreach($f as $key => $value){

if($side == 0&&($value!=''&&$value!=' ')){

$html.="<tr>";

$html .= "<td class='left1'>{$text[$key]}</td><td class='left2'>$value</td>";

$side = ($side+1)%2;

}

else if($value!=''&&$value!=' '){

$html .= "<td class='right1'>{$text[$key]}</td><td class='right2'>$value</td>";

$html.="</tr>";

$side = ($side+1)%2;

}

}

if($side==1){

$html.="<td class='right1'></td><td class='right2'>".$application->output['apply_link']."</tr></table>";

}

else{

$html.="</tr><tr><td colspan='3'></td><td class='right2'>".$application->output['apply_link']."</tr></table>";

}

return $html;

  }

 

function generate_table($f){// Create table containing overview of job details

$application =& application();

$text = $application->text();

 

if($f['approx_salary_range'] != 0.00){

        $f['approx_salary'] = $f['approx_salary'] . " - " . $f['approx_salary_range'];       

        }

 

$html = "<table class='view_job'>";

$html .= "<tr><td class='left'>{$text['company_name']}</td><td class='right'><a href='?page=view_employer&employer_id={$f['employer_id']}'>{$f['company_name']}</a></td>\n";

$html .= "    <td class='left'>{$text['approx_salary']}</td><td class='right'>";

$html .= ($f['approx_salary']!=0) ? "{$f['approx_salary']} {$f['salary_type']}":$text['not_specified'];

$html .= "</td></tr>\n<tr><td class='left'>{$text['location']}</td><td class='right'>{$f['city']}, {$f['state']}</td>\n";

$html .= "    <td class='left'>{$text['country']}</td><td class='right'>{$f['country']}</td></tr>\n";

$html .= "<tr><td class='left'>{$text['job_type']}</td><td class='right'>{$f['job_type']}</td>\n";

$html .= "    <td class='left'>{$text['position_type']}</td><td class='right'>{$f['position_type']}</td></tr>\n";

$html .= "<tr><td class='left'>{$text['req_experience']}</td><td class='right'>{$f['req_experience']}</td>\n";

$html .= "    <td class='left'>{$text['req_education']}</td><td class='right'>{$f['req_education']}</td></tr>\n";

$html .= "</table>";

return $html;

  }

  function get_new_image_dims($file){

  $application =& application();

  $max_height = $application->config('image_display_height');

  $max_width = $application->config('image_display_width');

  list($width, $height) = getimagesize($file);

 

  if($width > $max_width || $height > $max_height){

$width_mod = $width/$max_width;

$height_mod = $height/$max_height;

if ($width_mod>$height_mod)

{

$new_width = $max_width;

$new_height = $height/$width_mod;

}

else

{

$new_height = $max_height;

$new_width = $width/$height_mod;

}

 

return array("height"=>$new_height, "width"=>$new_width);

 

  }

 

  return array("height"=>$height, "width"=>$width);

 

  }

}; // post_single_job

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.