Patch to extend funcionality
| Project: | Job Search |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | needs work |
- List of changes:
- A confirmation page to clear/confirm a job
- Anocher state of job: rejected/waiting/accepted
- A new link in resume's node: apply that resume to last job seen
Sponsored by http://www.ingenia.es
Sorry for my english (i am spanish & i have not too time in work)
--- job.module.orig 2009-06-09 11:52:24.000000000 +0200
+++ job.module 2009-06-09 11:49:58.000000000 +0200
@@ -55,12 +55,20 @@
);
$items['job/clear'] = array(
- 'page callback' => 'job_clear',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('job_clear_confirm', 2, 3),
'type' => MENU_CALLBACK,
'access arguments' => array(JOB_PERM_MANAGE),
);
- $items['job/applications'] = array(
+ $items['job/accept'] = array(
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('job_accept_confirm', 2, 3),
+ 'type' => MENU_CALLBACK,
+ 'access arguments' => array(JOB_PERM_MANAGE),
+ );
+
+ $items['job/applications'] = array(
'page callback' => 'job_view',
'title' => t('Job applications'),
'type' => MENU_SUGGESTED_ITEM,
@@ -96,6 +104,14 @@
function job_link($type, $node = null, $teaser = FALSE) {
global $user;
$links = array();
+
+// Incluyo comprobación para que las empresas no vean enlaces "presentarse a esta oferta"
+ if (in_array('administrador', $user->roles) or in_array('empresa', $user->roles)) {
+ //
+ return $links;
+ }
+//
+
if ($type == 'node') {
// We are viewing a node
if (variable_get(JOB_NODE_TYPE . $node->type, 0)) {
@@ -152,6 +168,8 @@
$job_nid = (int)arg(2);
$resume_nid = (int)arg(3);
+ drupal_set_title(t('Select you resume'));
+
if (!$user->uid) {
drupal_set_message(t('Please !login or !register to apply',
array(
@@ -178,38 +196,50 @@
$job = node_load(array('nid' => $job_nid));
- $resume_list = job_resume_list($user->uid);
+ $_SESSION['ultima_oferta_vista'] = $job_nid;
+
+ $resume_list = job_resume_list($user->uid);
if (!$resume_list) {
- $msg = t('Please !create to apply', array('!create' => l(t('create a resume'), 'node/add')));
+ $msg = t('Please !create to apply', array('!create' => l(t('create a resume'), 'node/add/resume')));
drupal_set_message($msg);
drupal_goto("node/$job_nid");
}
-
- if(count($resume_list) == 1) {
- drupal_goto("job/apply/$job_nid/$resume_nid{$resume_list[0]['nid']}");
- }
- $output .= '
' . t('Position: ') . $job->title . '
';
+ // We show resumes: the user can create a new resume
+
+ // if(count($resume_list) == 1) {
+ // drupal_goto("job/apply/$job_nid/$resume_nid{$resume_list[0]['nid']}");
+ // }
+
+ $_SESSION['ultima_oferta_vista'] = $job_nid;
+
+ $output .= '';
+ $output .= '
' . t('Position: ') . ''.$job->title . ''.'
';
$output .= '
' . t('Select from your resumes below, or !create',
- array('!create' => l(t('create a new resume'), "node/add")));
+ array('!create' => l(t('create a new resume'), "node/add".'/resume' //.'?destination='.urlencode('/job/apply/'.$job_nid)
+)));
$output .= '
';
+ $output .= '';
foreach($resume_list as $resume) {
$view = l(t('view'), 'node/' . $resume['nid']);
- $apply = l(t('apply'), "job/apply/$job_nid/$resume_nid" . $resume['nid']);
+ $apply = l(t('presentar'), "job/apply/$job_nid/$resume_nid" . $resume['nid']);
$edit = l(t('edit'), 'node/' . $resume['nid'] . '/edit');
$rows[] = array(
$resume['title'],
- format_interval(time() - $resume['changed']),
- $view . ' ' . $apply . ' ' . $edit
+ format_interval(time() - $resume['changed']),
+ $view . ' | ' . $apply . ' | ' . $edit
);
}
$headers = array(t('Resume Title'), t('Last Changed'), t('Operations'));
$output .= theme('table', $headers, $rows);
- print theme('page', $output);
+
+ $output = ''.$output.'';
+
+ print theme('page', $output);
}
function job_resume_list($uid) {
@@ -262,10 +292,96 @@
}
}
+/**
+ * Menu callback -- ask for confirmation of clear resume
+ */
+function job_clear_confirm(&$form_state, $nid, $uid) {
+
+ $form['nid'] = array(
+ '#type' => 'value',
+ '#value' => $nid,
+ );
+ $form['uid'] = array(
+ '#type' => 'value',
+ '#value' => $uid,
+ );
+
+ return confirm_form($form,
+ t('Are you sure to reject this resume %title for this job?',
+ array('%title' => node_load($nid)->title)),
+ /*isset($_GET['destination']) ? $_GET['destination'] : */'job/applications',
+ t('This action cannot be undone.'),
+ t('Reject'),
+ t('Cancel')
+ );
+}
+
+/**
+ * Menu callback -- confirmation of clear resume
+ */
+function job_clear_confirm_submit($form, &$form_state) {
+ job_clear($form_state['values']['nid'], $form_state['values']['uid']);
+
+ drupal_goto('job/applications');
+}
+
+/**
+ * Menu callback -- clear resume
+ */
function job_clear($nid, $uid) {
if ($nid && $uid) {
db_query("UPDATE {job} SET status = 0 WHERE nid = %d AND uid = %d", $nid, $uid);
- drupal_set_message(t('Job application #@nid has been cleared.', array('@nid' => $nid)));
+ drupal_set_message(t('Job application %name has been cleared.', array('%name' => node_load($nid)->title)));
+ }
+
+// Enviar un correo-e al profesional informándole de que su carta de presentación ha sido rechazada
+// drupal_mail()
+
+ drupal_goto('job/applications');
+}
+
+/**
+ * Form -- ask for confirmation of accept resume
+ */
+function job_accept_confirm(&$form_state, $nid, $uid) {
+
+ $form['nid'] = array(
+ '#type' => 'value',
+ '#value' => $nid,
+ );
+ $form['uid'] = array(
+ '#type' => 'value',
+ '#value' => $uid,
+ );
+
+ return confirm_form($form,
+ t('Are you sure to accept this resume %title for this job?',
+ array('%title' => node_load($nid)->title)),
+ /*isset($_GET['destination']) ? $_GET['destination'] : */'job/applications',
+ t('That professional will be notified by e-mail.'),
+ t('Accept'),
+ t('Cancel')
+ );
+}
+
+/**
+ * Menu callback -- confirmation of clear resume
+ */
+function job_accept_confirm_submit($form, &$form_state) {
+ job_accept($form_state['values']['nid'], $form_state['values']['uid']);
+
+// drupal_mail();
+
+ drupal_goto('job/applications');
+}
+
+/**
+ * Menu callback -- clear resume
+ */
+function job_accept($nid, $uid) {
+ if ($nid && $uid) {
+ db_query("UPDATE {job} SET status = 2 WHERE nid = %d AND uid = %d", $nid, $uid);
+ drupal_set_message(t('Job application %name has been accepted.', array('%name' => node_load($nid)->title)));
}
drupal_goto('job/applications');
}
@@ -277,11 +393,11 @@
function job_get_list($uid = NULL) {
$rows = array();
- $sql = "SELECT n.nid, j.uid, j.resume_nid, j.timestamp
+ $sql = "SELECT n.nid, j.uid, j.resume_nid, j.timestamp, j.status
FROM {node} n INNER JOIN {job} j USING(nid)
- WHERE n.uid = %d
- AND j.status = 1
- ORDER by j.timestamp ASC";
+ WHERE n.uid = %d ".
+// AND j.status > 0
+" ORDER by j.timestamp ASC";
$result = db_query($sql, $uid);
while ($data = db_fetch_object($result)) {
$resume = node_load(array('nid' => $data->resume_nid));
@@ -291,6 +407,7 @@
'resume' => $resume,
'job' => $job,
'timestamp' => $data->timestamp,
+ 'status' => $data->status,
);
}
return $rows;
@@ -308,18 +425,41 @@
$title = l($job->title, "node/$job->nid");
$resume = l($resume->title, "node/" . $resume->nid);
$user = l($applicant->name, "user/$applicant->uid");
- $ops = l(t('Clear'), "job/clear/$job->nid/" . $applicant->uid);
+
+ $ops = '';
+ // Waiting or rejected: it can be accept.
+ if ($data['status'] == '0' or $data['status'] == '1' ) {
+ $ops .= l(t('Accept'), "job/accept/$job->nid/" . $applicant->uid);
+ }
+ // Wainting: insert separator (two optiones min.)
+ if ($data['status'] == '1' ) {
+ $ops .= ' | ';
+ }
+ // Accepted or waiting: it can be reject.
+ if ($data['status'] == '2' or $data['status'] == '1' ) {
+ $ops .= l(t('Reject'), "job/clear/$job->nid/" . $applicant->uid);
+ }
+
+ if ($data['status'] == '1') {
+ $row_attribute = 'rejected_resume';
+ }
+ if ($data['status'] == '2') {
+ $row_attribute = 'accepted_resume';
+ }
+
$timestamp = format_date($data['timestamp'], 'custom', 'Y-m-d H:i');
$rows[] = array(
- 'data' => array_merge(
- array($title),
- array($user),
- array($resume),
- array($timestamp),
- array($ops)
- )
- );
+ 'data' => array_merge(
+ array($title),
+ array($user),
+ array($resume),
+ array($timestamp),
+ array($ops)
+ ),
+ 'class' => $row_attribute,
+ );
+ $row_attribute = '';
}
}
else {
@@ -337,16 +477,16 @@
'job_view' => array(
'arguments' => array('list' => NULL),
),
-
+
'job_mail' => array(
- 'arguments' => array(
- 'job_node' => NULL,
- 'job_user' => NULL,
- 'resume_node' => NULL,
- 'resume_user' => NULL,
- ),
+ 'arguments' => array(
+ 'job_node' => NULL,
+ 'job_user' => NULL,
+ 'resume_node' => NULL,
+ 'resume_user' => NULL,
+ ),
),
-
+
'job_search_item' => array(
'arguments' => array(
'item' => NULL,
@@ -398,7 +538,7 @@
function theme_job_mail($job_node, $job_user, $resume_node, $resume_user) {
global $base_url;
-
+
$site = variable_get('site_name', 'drupal site');
$subject = t("[$site] [Job application] for [$job_node->title] by [$resume_user->name]");
$body = t("The following user has applied for the above job.\n");
@@ -508,7 +648,7 @@
),
),
);
-
+
return $tables;
}

#1
arg, uploaded
#2
This doesnt seem to be compatible with the most recent dev build.
Hunk #1 succeeded at 53 with fuzz 2 (offset -2 lines).
Hunk #2 succeeded at 110 with fuzz 1 (offset 6 lines).
Hunk #3 succeeded at 205 (offset 37 lines).
Hunk #4 FAILED at 233.
Hunk #5 succeeded at 306 (offset 14 lines).
Hunk #6 succeeded at 430 (offset 37 lines).
Hunk #7 succeeded at 421 (offset 14 lines).
Hunk #8 succeeded at 490 (offset 65 lines).
Hunk #9 FAILED at 542.
Hunk #10 succeeded at 596 (offset 58 lines).
Hunk #11 FAILED at 706.
3 out of 11 hunks FAILED -- saving rejects to file job.module.rej
#3
#4
I don't think Status should be part of the Job Search module. The combination of the Workflow and Rules modules allows for much richer functionality. Here are some examples:
For Status (Accepted, Rejected, Expired, Pending), I use the Workflow module. This allows Workflow transitions by user Role, so I have it setup that Job Postings are initially put in the Pending state until an Admin reviews it and marks it as Accepted. The Admin gets to see a list of Pending items to approve. I also have the Rules module in place so that if an Admin marks a Posting as Rejected, the Posting author gets an email notifying them of the rejection so they can fix it. Only Job Postings marked as Accepted are visible to non-admin users. When a user's account becomes expired (they no longer pay the monthly membership fee), a Rule fires that marks all of their Job Postings and/or Resumes as Expired and they are no longer visible to other users. If the user later re-subscribes and pays the membership fee, their Job Postings/Resumes are marked to their last Status.