5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * Copyright 2010 (c) Franck Villaume
8 * http://fusionforge.org/
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once('../env.inc.php');
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfwww.'people/people_utils.php';
30 if (!forge_get_config('use_people')) {
31 exit_disabled('home');
34 $group_id = getIntFromRequest('group_id');
36 if ($group_id && (user_ismember($group_id, 'A'))) {
37 $title = getStringFromRequest('title');
38 $description = getStringFromRequest('description');
39 $category_id = getIntFromRequest('category_id');
40 $status_id = getIntFromRequest('status_id');
41 $job_id = getIntFromRequest('job_id');
42 $job_inventory_id = getIntFromRequest('job_inventory_id');
43 $skill_id = getIntFromRequest('skill_id');
44 $skill_level_id = getIntFromRequest('skill_level_id');
45 $skill_year_id = getIntFromRequest('skill_year_id');
47 if (getStringFromRequest('add_job')) {
51 if (!$title || !$description || $category_id==100) {
52 exit_missing_param('',array(_('Title'),_('Description'),_('Category')),'admin');
54 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
55 exit_form_double_submit('admin');
57 $result=db_query_params("INSERT INTO people_job (group_id,created_by,title,description,post_date,status_id,category_id)
58 VALUES ($1, $2, $3, $4, $5, $6, $7)",
59 array($group_id, user_getid(), htmlspecialchars($title), htmlspecialchars($description), time(), '1',$category_id));
60 if (!$result || db_affected_rows($result) < 1) {
61 $error_msg .= sprintf(_('JOB insert FAILED: %s'),db_error());
62 form_release_key(getStringFromRequest("form_key"));
64 $job_id=db_insertid($result,'people_job','job_id');
65 $feedback .= _('JOB inserted successfully');
68 } else if (getStringFromRequest('update_job')) {
70 update the job's description, status, etc
72 if (!$title || !$description || $category_id==100 || $status_id==100 || !$job_id) {
74 exit_missing_param('',array(_('Title'),_('Description'),_('Category'),_('Status'),_('Job')),'admin');
77 $result=db_query_params("UPDATE people_job SET title=$1,description=$2,status_id=$3,category_id=$4 WHERE job_id=$5 AND group_id=$6",
78 array(htmlspecialchars($title), htmlspecialchars($description), $status_id, $category_id, $job_id, $group_id));
79 if (!$result || db_affected_rows($result) < 1) {
80 $error_msg = sprintf(_('JOB update FAILED : %s'),db_error());
82 $feedback = _('JOB updated successfully');
85 } else if (getStringFromRequest('add_to_job_inventory')) {
87 add item to job inventory
89 if ($skill_id == "xyxy" || $skill_level_id==100 || $skill_year_id==100 || !$job_id) {
91 exit_missing_param('',array(_('Skill'),_('Skill Level'),_('Skill Year'),_('Job')),'admin');
94 if (people_verify_job_group($job_id,$group_id)) {
95 people_add_to_job_inventory($job_id,$skill_id,$skill_level_id,$skill_year_id);
96 $feedback .= _('JOB updated successfully');
98 $error_msg .= _('JOB update failed - wrong project_id');
101 } else if (getStringFromRequest('update_job_inventory')) {
103 Change Skill level, experience etc.
105 if ($skill_level_id==100 || $skill_year_id==100 || !$job_id || !$job_inventory_id) {
107 exit_missing_param('',array(_('Skill Level'),_('Skill Year'),_('Job'),_('Job Inventory')),'admin');
110 if (people_verify_job_group($job_id,$group_id)) {
111 $result=db_query_params("UPDATE people_job_inventory SET skill_level_id=$1,skill_year_id=$2 WHERE job_id=$3 AND job_inventory_id=$4",
112 array($skill_level_id, $skill_year_id, $job_id, $job_inventory_id));
113 if (!$result || db_affected_rows($result) < 1) {
114 $error_msg .= sprintf(_('JOB skill update FAILED: %s'), db_error());
116 $feedback .= _('JOB skill updated successfully');
119 $error_msg .= _('JOB skill update failed - wrong project_id');
122 } else if (getStringFromRequest('delete_from_job_inventory')) {
124 remove this skill from this job
128 exit_missing_param('',array(_('Job ID')),'admin');
131 if (people_verify_job_group($job_id,$group_id)) {
132 $result = db_query_params("DELETE FROM people_job_inventory WHERE job_id=$1 AND job_inventory_id=$2", array($job_id, $job_inventory_id));
133 if (!$result || db_affected_rows($result) < 1) {
134 $error_msg .= sprintf(_('JOB skill delete FAILED : %s'),db_error());
136 $feedback .= _('JOB skill deleted successfully');
139 $error_msg .= _('JOB skill delete failed - wrong project_id');
145 Fill in the info to create a job
147 people_header(array('title'=>_('Edit Job')));
149 //for security, include group_id
150 $result=db_query_params("SELECT * FROM people_job WHERE job_id=$1 AND group_id=$2", array($job_id, $group_id));
151 if (!$result || db_numrows($result) < 1) {
152 $error_msg .= sprintf(_('POSTING fetch FAILED: %s'),db_error());
153 echo '<h2>'._('No such posting for this project').'</h2>';
157 . _('Now you can edit/change the list of skills attached to this posting. Developers will be able to match their skills with your requirements.')
159 . _('All postings are automatically closed after two weeks.').'
160 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
161 <input type="hidden" name="group_id" value="'.$group_id.'" />
162 <input type="hidden" name="job_id" value="'.$job_id.'" />
163 <strong>'._('Category').'</strong><br />
164 '. people_job_category_box('category_id',db_result($result,0,'category_id')) .'
166 <strong>'._('Status').'</strong><br />
167 '. people_job_status_box('status_id',db_result($result,0,'status_id')) .'</p>
169 <strong>'._('Short Description').':</strong><br />
170 <input type="text" name="title" value="'. db_result($result,0,'title') .'" size="40" maxlength="60" /></p>
172 <strong>'._('Long Description').':</strong><br />
173 <textarea name="description" rows="10" cols="60">'. db_result($result,0,'description') .'</textarea></p>
175 <input type="submit" name="update_job" value="'._('Update Descriptions').'" /></p>
178 //now show the list of desired skills
179 echo '<p>'.people_edit_job_inventory($job_id,$group_id).'</p>';
180 echo '<form action="/people/" method="post"><input type="submit" name="submit" value="'._('Finished').'" /></form>';
184 people_footer(array());
188 Not logged in or insufficient privileges
193 exit_permission_denied('home');
199 // c-file-style: "bsd"