Only in cvbuilder-4.7.0: cvbuilder.install diff -ura cvbuilder-cvs/cvbuilder.module cvbuilder-4.7.0/cvbuilder.module --- cvbuilder-cvs/cvbuilder.module 2006-05-20 18:01:46.000000000 -0700 +++ cvbuilder-4.7.0/cvbuilder.module 2006-06-30 00:09:59.046875000 -0700 @@ -42,7 +42,6 @@ } } - /** * Implementation of hook_node_name(). * @@ -81,6 +80,22 @@ /** + * node_info hook to return this module's name and description for wishlist nodes + * + * @return + * Name of the node type created by this module + */ +function cvbuilder_node_info() { + return array( + 'cvbuilder_address' => array('name' => 'cvbuilder_address', 'base' => 'cvbuilder_address'), + 'cvbuilder_experience' => array('name' => 'cvbuilder_experience', 'base' => 'cvbuilder_experience'), + 'cvbuilder_schoolcollege' => array('name' => 'cvbuilder_schoolcollege', 'base' => 'cvbuilder_schoolcollege'), + 'cvbuilder_skills' => array('name' => 'cvbuilder_skills', 'base' => 'cvbuilder_skills'), + 'cvbuilder_referee' => array('name' => 'cvbuilder_referee', 'base' => 'cvbuilder_referee') + ); +} + +/** * Implementation of hook_access(). * * Node modules may implement node_access() to determine the operations @@ -222,8 +237,8 @@ */ function cvbuilder_menu($may_cache) { $items = array(); - drupal_set_html_head(theme('stylesheet_import', drupal_get_path('module', 'cvbuilder') .'/cvbuilder.css')); - + theme_add_style(drupal_get_path('module', 'cvbuilder') .'/cvbuilder.css'); + if ($may_cache) { $items[] = array('path' => 'node/add/cvbuilder_referee', 'title' => t('CVBuilder: referee'), 'access' => user_access('create CV')); $items[] = array('path' => 'node/add/cvbuilder_schoolcollege', 'title' => t('CVBuilder: place of education'), 'access' => user_access('create CV')); @@ -245,6 +260,19 @@ function cvbuilder_referee_form(&$node) { $output = ''; + + $form['title'] = array( + '#type' => 'textfield', + '#title' => t('Title'), + '#default_value' => $node->title, + '#size' => 60, + '#maxlength' => 128, + '#description' => NULL, + '#attributes' => NULL, + '#required' => TRUE, + ); + + // In order to be able to attach taxonomy terms to this node, we need // to display the appropriate form elements. if (function_exists('taxonomy_node_form')) { @@ -254,96 +282,321 @@ // Now we define the form elements specific to our node type. // $output .= form_textarea(t('Body'), 'body', $node->body, 60, 20); // $output .= filter_form('format', $node->format); - $output .= form_textfield(t('Position'), 'position', $node->position, 60, 128, 'Enter a description for this referee. For example: a former employer may be described as "Managing Director, The Widget Company Ltd."'); - $output .= form_textfield(t('Contact details'), 'address', $node->address, 60, 128, 'Enter contact details for this referee. For example: "123 Fake Street, Springfield. Tel: 020 0000 0000"'); - $output .= form_textfield(t('Relationship to you'), 'relationship', $node->relationship, 60, 128, 'How do you know this referee? Examples: "Previous employer","School teacher","College lecturer"'); - $output .= form_checkbox(t('Tick this box if you don\'t mind employers contacting this referee without asking you first'), 'maycontact', 1, $node->maycontact); - return $output; + $form["position"] = array( + '#type' => 'textfield', + '#title' => t("Position"), + '#default_value' => $node->position, + '#size' => 60, + '#maxlength' => 128, + '#description' => t('Enter a description for this referee. For example: a former employer may be described as "Managing Director, The Widget Company Ltd."'), + ); + $form["address"] = array( + '#type' => 'textfield', + '#title' => t("Contact details"), + '#default_value' => $node->address, + '#size' => 60, + '#maxlength' => 128, + '#description' => t('Enter contact details for this referee. For example: "123 Fake Street, Springfield. Tel: 020 0000 0000"'), + ); + $form["relationship"] = array( + '#type' => 'textfield', + '#title' => t('Relationship to you'), + '#default_value' => $node->relationship, + '#size' => 60, + '#maxlength' => 128, + '#description' => t('How do you know this referee? Examples: "Previous employer","School teacher","College lecturer"'), + ); + $form["maycontact"] = array( + '#type' => 'checkbox', + '#title' => t('Tick this box if you don\'t mind employers contacting this referee without asking you first'), + '#return_value' => TRUE, + '#default_value' => $node->maycontact, + ); + return $form; } function cvbuilder_skills_form(&$node) { $output = ''; + $form['title'] = array( + '#type' => 'textfield', + '#title' => t('Title'), + '#default_value' => $node->title, + '#size' => 60, + '#maxlength' => 128, + '#description' => NULL, + '#attributes' => NULL, + '#required' => TRUE, + ); + // In order to be able to attach taxonomy terms to this node, we need // to display the appropriate form elements. if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('cvbuilder_skills', $node)); } - $output .= form_textarea(t('Details'), 'description', $node->description, 60, 10, 'Enter details of these job skills in this box.'); - return $output; + $form["description"] = array( + '#type' => 'textarea', + '#title' => t('Details'), + '#default_value' => $node->description, + '#cols' => 60, + '#rows' => 10, + '#description' => t("Enter details of these job skills in this box."), + ); + + return $form; } function cvbuilder_schoolcollege_form(&$node) { // Creating array of calendar months $months = array(1 => t('January'), 2 => t('February'), 3 => t('March'), 4 => t('April'), 5 => t('May'), 6 => t('June'), 7 => t('July'), 8 => t('August'), 9 => t('September'), 10 => t('October'), 11 => t('November'), 12 => t('December')); - // Creating array of years between 1950 and now + // Creating array of years between 1930 and now $years =array(); - for ($i = intval(date('Y'))+5; $i >= 1930; $i--) { + for ($i = intval(date('Y')); $i >= 1930; $i--) { $years[$i] = $i; } $output = ''; + + $form['title'] = array( + '#type' => 'textfield', + '#title' => t('Title'), + '#default_value' => $node->title, + '#size' => 60, + '#maxlength' => 128, + '#description' => NULL, + '#attributes' => NULL, + '#required' => TRUE, + ); + + + // In order to be able to attach taxonomy terms to this node, we need // to display the appropriate form elements. if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('cvbuilder_referee', $node)); } + + $form["startdate_month"] = array( + '#type' => 'select', + '#title' => t('Start month'), + '#default_value' => $node->startdate_month, + '#options' => $months, + ); + + $form["startdate_year"] = array( + '#type' => 'select', + '#title' => t('Start year'), + '#default_value' => $node->startdate_year, + '#options' => $years, + ); + + $form["enddate_month"] = array( + '#type' => 'select', + '#title' => t('End month'), + '#default_value' => $node->enddate_month, + '#options' => $months, + ); + + $form["enddate_year"] = array( + '#type' => 'select', + '#title' => t('End year'), + '#default_value' => $node->enddate_year, + '#options' => $years, + ); + + $form["address"] = array( + '#type' => 'textfield', + '#title' => t('Address'), + '#default_value' => $node->address, + '#size' => 60, + '#maxlength' => 128, + '#description' => t('Tell us where this school or college is. For example: "Education Street, Anytown AN1 7OW"'), + ); + + $form["quals"] = array( + '#type' => 'textarea', + '#title' => t('Qualifications gained'), + '#default_value' => $node->quals, + '#cols' => 60, + '#rows' => 10, + '#description' => t("Describe what qualifications you acquired at this place of education."), + ); - $output .= form_select(t('Start month'), 'startdate_month', $node->startdate_month, $months); - $output .= form_select(t('Start year'), 'startdate_year', $node->startdate_year, $years); - $output .= form_select(t('End month'), 'enddate_month', $node->enddate_month, $months); - $output .= form_select(t('End year'), 'enddate_year', $node->enddate_year, $years); - $output .= form_textfield(t('Address'), 'address', $node->address, 60, 128, 'Tell us where this school or college is. For example: "Education Street, Anytown AN1 7OW"'); - $output .= form_textarea(t('Qualifications gained'), 'quals', $node->quals, 60, 10, 'Describe what qualifications you acquired at this place of education.'); - return $output; + return $form; } function cvbuilder_address_form(&$node) { $output = ''; + + $form['title'] = array( + '#type' => 'textfield', + '#title' => t('Title'), + '#default_value' => $node->title, + '#size' => 60, + '#maxlength' => 128, + '#description' => NULL, + '#attributes' => NULL, + '#required' => TRUE, + ); + // In order to be able to attach taxonomy terms to this node, we need // to display the appropriate form elements. if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('cvbuilder_referee', $node)); } - $output .= form_textfield(t('Address line 1'), 'address1', $node->address1, 60, 255, 'Enter your address.'); - $output .= form_textfield(t('Address line 2'), 'address2', $node->address2, 60, 255); - $output .= form_textfield(t('Town'), 'town', $node->town, 60, 255); - $output .= form_textfield(t('County'), 'county', $node->county, 60, 255); - $output .= form_textfield(t('Postcode'), 'postcode', $node->postcode, 20, 20); - $output .= form_textfield(t('Phone number'), 'phone', $node->phone, 20, 20, 'If you can be contacted by telephone, enter your contact phone number here.'); - $output .= form_textfield(t('Email address'), 'email', $node->email, 20, 50, 'If you can be contacted by email, enter your email address here.'); - $output .= form_textfield(t('Web site'), 'web', $node->web, 30, 255, 'If you have a web site you\'d like to include, enter the address here.'); - return $output; + $form['address1'] = array( + '#type' => 'textfield', + '#title' => t('Address line 1'), + '#default_value' => $node->address1, + '#size' => 60, + '#maxlength' => 255, + '#description' => t('Enter your address.'), + ); + $form['address2'] = array( + '#type' => 'textfield', + '#title' => t('Address line 2'), + '#default_value' => $node->address2, + '#size' => 60, + '#maxlength' => 255, + ); + $form['town'] = array( + '#type' => 'textfield', + '#title' => t('Town'), + '#default_value' => $node->town, + '#size' => 60, + '#maxlength' => 255, + ); + $form['county'] = array( + '#type' => 'textfield', + '#title' => t('County'), + '#default_value' => $node->county, + '#size' => 60, + '#maxlength' => 255, + ); + $form['postcode'] = array( + '#type' => 'textfield', + '#title' => t('Postcode'), + '#default_value' => $node->postcode, + '#size' => 20, + '#maxlength' => 20, + ); + $form['phone'] = array( + '#type' => 'textfield', + '#title' => t('Phone number'), + '#default_value' => $node->phone, + '#size' => 20, + '#maxlength' => 20, + '#description' => t('If you can be contacted by telephone, enter your contact phone number here.'), + ); + $form['email'] = array( + '#type' => 'textfield', + '#title' => t('Email address'), + '#default_value' => $node->email, + '#size' => 20, + '#maxlength' => 50, + '#description' => t('If you can be contacted by email, enter your email address here.'), + ); + $form['web'] = array( + '#type' => 'textfield', + '#title' => t('Web site'), + '#default_value' => $node->web, + '#size' => 30, + '#maxlength' => 255, + '#description' =>t('If you have a web site you\'d like to include, enter the address here.'), + ); + + return $form; } function cvbuilder_experience_form(&$node) { // Creating array of calendar months $months = array(1 => t('January'), 2 => t('February'), 3 => t('March'), 4 => t('April'), 5 => t('May'), 6 => t('June'), 7 => t('July'), 8 => t('August'), 9 => t('September'), 10 => t('October'), 11 => t('November'), 12 => t('December')); - // Creating array of years between 1950 and now + // Creating array of years between 1930 and now $years =array(); - for ($i = intval(date('Y')) +5; $i >= 1950; $i--) { + for ($i = intval(date('Y')); $i >= 1930; $i--) { //$years[] = $i; $years[$i] = $i; } $output = ''; + + $form['title'] = array( + '#type' => 'textfield', + '#title' => t('Job Title'), + '#default_value' => $node->title, + '#size' => 60, + '#maxlength' => 128, + '#description' => NULL, + '#attributes' => NULL, + '#required' => TRUE, + ); + + // In order to be able to attach taxonomy terms to this node, we need // to display the appropriate form elements. if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('cvbuilder_experience', $node)); } - $output .= form_select(t('Start month'), 'startdate_month', $node->startdate_month, $months); - $output .= form_select(t('Start year'), 'startdate_year', $node->startdate_year, $years); - $output .= form_select(t('End month'), 'enddate_month', $node->enddate_month, $months); - $output .= form_select(t('End year'), 'enddate_year', $node->enddate_year, $years); - $output .= form_textfield(t('Address'), 'employeraddress', $node->employeraddress, 60, 128, 'Tell us where this employer is. For example: "Widget Street, Anytown AN1 7OW"'); - $output .= form_textarea(t('Duties'), 'duties', $node->duties, 60, 10, 'Describe what you did here, and what your responsibilities were.'); - $output .= form_textarea(t('Achievements'), 'achievements', $node->achievements, 60, 10, 'Use this space to say what you think you accomplished here, or what new things you learned.'); - return $output; + $form["startdate_month"] = array( + '#type' => 'select', + '#title' => t('Start month'), + '#default_value' => $node->startdate_month, + '#options' => $months, + ); + + $form["startdate_year"] = array( + '#type' => 'select', + '#title' => t('Start year'), + '#default_value' => $node->startdate_year, + '#options' => $years, + ); + + $form["enddate_month"] = array( + '#type' => 'select', + '#title' => t('End month'), + '#default_value' => $node->enddate_month, + '#options' => $months, + ); + + $form["enddate_year"] = array( + '#type' => 'select', + '#title' => t('End year'), + '#default_value' => $node->enddate_year, + '#options' => $years, + ); + + $form['employeraddress'] = array( + '#type' => 'textfield', + '#title' => t('Address'), + '#default_value' => $node->employeraddress, + '#size' => 60, + '#maxlength' => 128, + '#description' => t('Tell us where this employer is. For example: "Widget Street, Anytown AN1 7OW"'), + ); + + $form["duties"] = array( + '#type' => 'textarea', + '#title' => t('Duties'), + '#default_value' => $node->duties, + '#cols' => 60, + '#rows' => 10, + '#description' => t("Describe what you did here, and what your responsibilities were."), + ); + + $form["achievements"] = array( + '#type' => 'textarea', + '#title' => t('Achievements'), + '#default_value' => $node->achievements, + '#cols' => 60, + '#rows' => 10, + '#description' => t("Use this space to say what you think you accomplished here, or what new things you learned."), + ); + + return $form; } @@ -384,7 +637,7 @@ } function cvbuilder_address_update($node) { - db_query("UPDATE {cvbuilder_address} SET address1 = '%s', address2 = '%s', town = '%s', county = '%s', postcode = '%s', phone = '%s', email = '%s', web = '%s' WHERE nid = %d", $node->address1, $node->address2, $node->town, $node->county, $node->postcode, $node->phone, $node->email, $node->web, $node->nid); + db_query("UPDATE {cvbuilder_address} SET address1 = '%s', address2 = '%s', town = '%s', county = '%s', postcode = '%s', phone = '%s', email = '%s', web = '%s' WHERE nid = %d", $node->position, $node->address1, $node->address2, $node->town, $node->county, $node->postcode, $node->phone, $node->email, $node->web); } function cvbuilder_schoolcollege_update($node) { @@ -583,24 +836,10 @@ if ($showname == 1) { $output .= '
' . $node->address1 . '
';
- if ($node->address2 != '') {
- $output .= $node->address2 . '
';
- }
- $output .= $node->town . '
';
- if ($node->address2 != '') {
- $output .= $node->county . '
';
- }
- $output .= $node->postcode . '
Telephone: ' . $node->phone . '
'; - } - if ($node->email != '') { - $output .= 'Email address: ' . $node->email . '
'; - } - if ($node->web != '') { - $output .= 'Web site: ' . $node->web . '
'; - } + $output .= '' . $node->address1 . '
' . $node->address2 . '
' . $node->town . '
' . $node->county . '
' . $node->postcode . '
Telephone: ' . $node->phone . '
'; + $output .= 'Email address: ' . $node->email . '
'; + $output .= 'Web site: ' . $node->web . '
'; $output .= ''; return $output; } @@ -712,7 +951,7 @@ global $user; $owner = $uid; $viewer = $user->uid; - $addresses = db_query('SELECT nid FROM {node} WHERE type="cvbuilder_address" AND uid="' . $owner .' ORDER BY nid DESC"'); + $addresses = db_query('SELECT nid FROM {node} WHERE type="cvbuilder_address" AND uid="' . $uid .' ORDER BY nid DESC"'); $address = ''; switch ($op) { case 'print': @@ -731,9 +970,8 @@ if (db_num_rows($addresses) > 0) { while ($loop = db_fetch_array($addresses)) { $loopline = node_load(array('nid' => $loop['nid'])); -# if ((user_access('edit own CV') && ($user->uid == $node->uid)) || user_access('administer nodes')) { - if ((user_access('edit own CV') && ($user->uid == $owner)) || user_access('administer nodes')) { - $address .= t(''.l(t('Click here to add a new entry.'), "node/add/cvbuilder_skills") . '
'; } while ($loop = db_fetch_array($skillses)) { $loopline = node_load(array('nid' => $loop['nid'])); $skills .= '%name [ Edit this entry | Remove this entry ]
', array('%name' => $loopline->title, '%nid' => $loopline->nid)); + if ((user_access('edit own CV') && ($user->uid == $node->uid)) || user_access('administer nodes')) { + $skills .= t('%name [ %edit | %delete ]
', array('%name' => $loopline->title, '%edit' => l('Edit this entry', "node/$loopline->nid/edit"), '%delete' => l('Remove this entry', "node/$loopline->nid/delete"))); } else { - $skills .= t("%name :
", array('%name' => $loopline->title)); + $skills .= t("%name
", array('%name' => $loopline->title)); } $skills .= t("%description
",array('%description' => str_replace("\n","%url
', array('%url' => l('Click here to add a new entry.', "node/add/cvbuilder_experience"))); } while ($loop = db_fetch_array($schools)) { $school .= '%name [ Edit this entry | Remove this entry ]
', array('%name' => $loopline->title, '%nid' => $loopline->nid)); + if ((user_access('edit own CV') && ($user->uid == $node->uid)) || user_access('administer nodes')) { + $school .= t('%name [ %edit | %delete ]
', array('%name' => $loopline->title, '%edit' => l('Edit this entry', "node/$loopline->nid/edit"), '%delete' => l('Remove this entry', "node/$loopline->nid/delete"))); } else { $school .= t("%name
", array('%name' => $loopline->title)); } @@ -887,14 +1125,14 @@ default: if (db_num_rows($jobses) > 0) { $jobs .= t('%url
', array('%url', l('Click here to add a new entry.', "node/add/cvbuilder_experience"))); } while ($loop = db_fetch_array($jobses)) { $jobs .= '%name [ %edit | %delete ]
', array('%name' => $loopline->title, '%edit' => l('Edit this entry', "node/$loopline->nid/edit"), '%delete' => l('Remove this entry', "node/$loopline->nid/delete"))); } else { $jobs .= t("%name
", array('%name' => $loopline->title)); } @@ -914,7 +1152,7 @@ if ($owner == $viewer) { $jobs .= t('You haven\'t entered any work experience yet. Click here to add a new entry.
'); + $jobs .= t('You haven\'t entered any work experience yet. %url
', array('%url' => l('Click here to add a new entry.', "node/add/cvbuilder_experience"))); $jobs .= '%url
', array('%url', l('Click here to add a new entry.', "node/add/cvbuilder_referee"))); } while ($loop = db_fetch_array($referees)) { $loopline = node_load(array('nid' => $loop['nid'])); $refs .= '%name [ %edit | %delete ]
', array('%name' => $loopline->title, '%edit' => l('Edit this entry', "node/$loopline->nid/edit"), '%delete' => l('Remove this entry', "node/$loopline->nid/delete"))); } else { $refs .= t("