Hi,
In my country, there are always a file with the job information. With your extension, we can upload a resume file but not a job file.
I\'m trying to develop this funtionality. You can find the files I changed here.
Attachment js_jobs_jobfile.zip not found
I\'ve only work at the front office. Now, I can upload and download a file. I\'ve just a problem : js jobs don\'t update the MySQL data (\"filename\" in the js_job_jobs table). I don\'t understand where is the function to update MySQL.
Can you help me ?
##
##SQL
##
ALTER TABLE `jos_js_job_jobs` ADD `filename` varchar(50) default NULL;
ALTER TABLE `jos_js_job_jobs` ADD `filetype` varchar(50) default NULL;
ALTER TABLE `jos_js_job_jobs` ADD `filesize` int(11) default NULL;
ALTER TABLE `jos_js_job_jobs` ADD `filecontent` mediumblob default NULL;
#########################################
# views/jobposting/tmpl/formjob.php #
#########################################
##--------------------
## LINE 175 - SEARCH
##
<form action=\"index.php?Itemid=2\" method=\"post\" name=\"adminForm\" id=\"adminForm\" class=\"form-validate\" onSubmit=\"return myValidate(this)\";>
##
## REPLACE WITH
##
<!-- begin job file -->
<form action=\"index.php?Itemid=2\" method=\"post\" name=\"adminForm\" id=\"adminForm\" enctype=\"multipart/form-data\" class=\"form-validate\" onSubmit=\"return myValidate(this)\";>
<!-- end job file -->
##
## LINE 307
##
##
## ADD AFTER
##
//begin job file
<tr height=\"21\"><td colspan=\"2\"></td></tr>
<tr><td></td><td><strong><?php echo JText::_(\'JP_ALSO_JOB_FILE\'); ?></strong></td></tr>
<?php if (isset($this->application))
if($this->application->filename != \'\') {?>
<tr><td></td><td><input type=\'checkbox\' name=\'deletejobfile\' value=\'1\'><?php echo JText::_(\'JP_DELETE_RESUME_FILE\') .\'[\'.$this->application->filename.\']\'; ?></td></tr>
<?php } ?>
<tr>
<td width=\"100\" align=\"right\" class=\"textfieldtitle\">
<?php echo JText::_(\'JP_JOB_FILE\'); ?>:
</td>
<td>
<input type=\"file\" class=\"inputbox\" name=\"jobfile\" size=\"20\" maxlenght=\'30\'/>
<input type=\'hidden\' maxlenght=\'\'/>
</td>
</tr>
//end job file
#######################################
# views/jobposting/tmpl/wiewjob.php #
#######################################
##
## SEARCH LINE 191
##
<?php echo $this->application->contactemail; ?>
</td>
</tr>
##
## AFTER ADD
##
<!-- begin job file -->
<?php if($this->application->filename != \'\'){ ?>
<tr class=\"<?php echo $this->theme[\'even\']; ?>\"><td></td>
<td class=\"maintext\"><b><?php echo JText::_(\'JP_JOB_FILE\'); ?></b></td>
<td class=\"maintext\">
<?php
if($this->application->filecontent == \'\')
$link = $mainframe->getBasePath().\'components/com_jsjobs/jobs/\'.$this->application->uid.\'/\'.$this->application->filename;
else
$link = \'index2.php?option=com_jsjobs&c=jsjobs&view=jobposting&layout=jobdownload&rq=\'.$this->application->id.\'&Itemid=\'.$this->Itemid; ?>
<a href=\"<?php echo $link ?>\"><?php echo JText::_(\'JP_DOWNLOAD\'); ?></a>
</td>
</tr>
<?php } ?>
<!-- end job file -->
#######################
# models/jsjobs.php #
#######################
##
## SEARCH
##
function storejob() //store job
##
## REPLACE THE FUNCTION WITH
##
// begin job file
function storejob() //store job
{
$row = &$this->getTable(\'jobposting\');
$jobdata = JRequest :: get(\'post\');
if ( !$this->_config )
$this->getConfig();
foreach ($this->_config as $conf){
if ($conf->configname == \'jobautoapprove\')
$jobdata[\'status\'] = $conf->configvalue;
}
$jobdata[\'job\'] = JRequest::getVar(\'job\', \'\', \'post\', \'string\', JREQUEST_ALLOWRAW);
$returnvalue = $this->uploadJob($jobdata[\'uid\']);
if ($returnvalue != 1)
return $returnvalue;
//++++++++++++++++++++++++++++++++++++++++
if ($jobdata[\'applyinfo\'] == \'\')
$jobdata[\'applyinfo\'] = \"0\";
//++++++++++++++++++++++++++++++++++++++++
if (!$row->bind($jobdata))
{
$this->setError($this->_db->getErrorMsg());
return false;
}
if (!$row->check())
{
$this->setError($this->_db->getErrorMsg());
return 2;
}
if (!$row->store())
{
$this->setError($this->_db->getErrorMsg());
return false;
}
return true;
}
// end job file
##
## SEARCH
##
function uploadResume($u_id)
##
## BEFORE ADD
##
// begin job file
function uploadJob($u_id)
{
global $jobdata ;
$db =& JFactory::getDBO();
$jobquery = \"SELECT * FROM \".$db->nameQuote(\'#__js_job_jobs\') .\"
WHERE uid = \".$db->Quote($u_id);
//echo \'<br>sql \'.$jobquery;
if($_FILES[\'jobfile\'][\'size\'] > 0){
$file_name = $_FILES[\'jobfile\'][\'name\']; // file name
$file_tmp = $_FILES[\'jobfile\'][\'tmp_name\']; // actual location
$file_size = $_FILES[\'jobfile\'][\'size\']; // file size
$file_type = $_FILES[\'jobfile\'][\'type\']; // mime type of file determined by php
$file_error = $_FILES[\'jobfile\'][\'error\']; // any error!. get reason here
if( !empty($file_tmp)){ // only MS office, text file and adobe pdf is accepted.
if( !(($file_type==\"application/msword\") || ($file_type==\"text/plain\") || ($file_type==\"application/pdf\")) )
{
return 6; //file type mistmatch
}
}
$path =JPATH_BASE.\'/components/com_jsjobs/jobs\';
if (!file_exists($path)){ // creating jobs directory
mkdir($path, 0777);
}
$userpath= $path . \'/\'.$u_id;
if (!file_exists($userpath)){ // create user directory
mkdir($userpath, 0777);
}
$files = glob($userpath.\'/*.*\');
array_map(\'unlink\', $files); //delete all file in user directory
move_uploaded_file($file_tmp, $userpath.\'/\' . $file_name);
//unlink($file_tmp);
$jobdata[\'filename\'] = $file_name;
$jobdata[\'filecontent\'] = \'\';
return 1;
}else {
if ($jobdata[\'deletejobfile\'] == 1){
$path =JPATH_BASE.\'/components/com_jsjobs/jobs\';
$userpath= $path . \'/\'.$u_id;
$files = glob($userpath.\'/*.*\');
array_map(\'unlink\', $files);
$jobdata[\'filename\'] = \'\';
$jobdata[\'filecontent\'] = \'\';
}else{
$db->setQuery( $jobquery );
$job = $db->loadObject();
if ( isset($job) ){ // if already file upload then pick the path
$jobdata[\'filename\'] = $job->filename;
$jobdata[\'filecontent\'] = \'\';
}
}
return 1;
}
}
// begin job file
############################
# controllers/jsjobs.php #
############################
##
## SEARCH
##
}else if ($return_value == 2){
$msg = JText :: _(\'JP_FILL_REQ_FIELDS\');
$link = \'index.php?option=com_jsjobs&c=jsjobs&view=jobposting&layout=formjob&Itemid=\'.$Itemid;
##
## AFTER ADD
##
// begin job file
}else if ($return_value == 6){ // file type mismatch
$msg = JText :: _(\'JP_FILE_TYPE_ERROR\');
$link = \'index.php?option=com_jsjobs&c=jsjobs&view=jobposting&layout=formjob&Itemid=\'.$Itemid;
// end job file