/** * Add a job posting to the database. * @param string job title * @param string description * @param Array categories id * @param int 1 if public; 0 otherwise. * @param string Closing date for this job post, mysql TIMESTAMP format * @precondition ATutor Mailer class imported. */ function addJob($title, $description, $categories, $is_public, $closing_date) { require AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php'; global $addslashes, $db, $msg, $_config, $_base_href; if ($_SESSION['jb_employer_id'] < 1) { $msg->addError(); //authentication error exit; } else { include AT_JB_INCLUDE . 'Employer.class.php'; $employer = new Employer($_SESSION['jb_employer_id']); $employer_id = $employer->getId(); } $title = $addslashes($title); $description = $addslashes($description); $is_public = isset($is_public) ? 1 : 0; $closing_date = $addslashes($closing_date); $approval_state = $_config['jb_posting_approval'] == 1 ? AT_JB_POSTING_STATUS_UNCONFIRMED : AT_JB_POSTING_STATUS_CONFIRMED; $sql = 'INSERT INTO ' . TABLE_PREFIX . "jb_postings (employer_id, title, description, is_public, closing_date, created_date, revised_date, approval_state) VALUES ({$employer_id}, '{$title}', '{$description}', {$is_public}, '{$closing_date}', NOW(), NOW(), {$approval_state})"; $result = mysql_query($sql, $db); $posting_id = mysql_insert_id(); //add to posting category table if (!empty($categories)) { foreach ($categories as $id => $category) { $category = intval($category); $sql = 'INSERT INTO ' . TABLE_PREFIX . "jb_posting_categories (posting_id, category_id) VALUES ({$posting_id}, {$category})"; mysql_query($sql, $db); //send out notification if the person is subscribed to the category. $sql = 'SELECT m.member_id, m.email FROM ' . TABLE_PREFIX . 'jb_category_subscribes cs LEFT JOIN ' . TABLE_PREFIX . "members m ON cs.member_id=m.member_id WHERE category_id={$category}"; $result = mysql_query($sql, $db); $post_link = $_base_href . AT_JB_BASENAME . 'view_post.php?jid=' . $posting_id; if ($result) { while ($row = mysql_fetch_assoc($result)) { $mail = new ATutorMailer(); $mail->AddAddress($row['email'], get_display_name($row['member_id'])); $body = _AT('jb_subscription_msg', $title, $this->getCategoryNameById($category), $post_link); $body .= "\n\n"; $body .= _AT('jb_posted_by') . ": " . htmlentities_utf8($employer->getCompany()) . "\n"; $mail->FromName = $_config['site_name']; $mail->From = $_config['contact_email']; $mail->Subject = _AT('jb_subscription_mail_subject'); $mail->Body = $body; if (!$mail->Send()) { $msg->addError('SENDING_ERROR'); } unset($mail); } } } } if (!$result) { //TODO: db error message $msg->addError(); } }
echo $bookmark_icon . $row['id']; ?> </a></td> <td><a href="<?php echo AT_JB_BASENAME . 'view_post.php?jid=' . $row['id']; ?> " title="<?php echo $row['title']; ?> "><?php echo $row['title']; ?> </a></td> <td><?php $employer = new Employer($row['employer_id']); echo htmlentities_utf8($employer->getCompany()); ?> </td> <td> <?php if (is_array($row['categories'])) { $category_str = ''; foreach ($row['categories'] as $category) { $category_str .= $this->job_obj->getCategoryNameById($category) . ', '; } $category_str = substr($category_str, 0, -2); ?> <span><?php echo $category_str; ?> </span>
if (sizeof($errors) > 0) { foreach ($errors as $err) { $msg->addError($err); } } header('Location: edit_employer.php?eid=' . intval($_GET['eid'])); exit; } //update password if ($pass != '' && strlen($pass) == 40) { $employer->updatePassword($pass); } //set approval state $employer->setApprovalState($approval_state); if ($employer->updateProfile($name, $company, $email, $website, $description)) { $msg->addFeedback('JB_PROFILE_UPDATED'); } else { $msg->addError('DB_NOT_UPDATED'); } header('Location: employers.php'); exit; } include AT_INCLUDE_PATH . 'header.inc.php'; $savant->assign('name', $employer->getName()); $savant->assign('company', $employer->getCompany()); $savant->assign('email', $employer->getEmail()); $savant->assign('website', $employer->getWebsite()); $savant->assign('description', $employer->getDescription()); $savant->assign('approval_state', $employer->getApprovalState()); $savant->display('admin/jb_edit_employer.tmpl.php'); include AT_INCLUDE_PATH . 'footer.inc.php';