public function add() { $form = array('building_id' => '', 'name' => '', 'index' => '', 'img_uri' => '', 'active' => ''); $errors = $form; if ($_POST) { $post = new Validation($_POST); $post->pre_filter('trim', true); $post->add_rules('buildings_id', 'required', 'digit'); $post->add_rules('name', 'required'); $post->add_rules('index', 'required'); $post->add_rules('img_uri', 'required'); $post->add_rules('active', 'required'); if ($post->validate()) { // check for invilid $form = arr::overwrite($form, $post->as_array()); $people = new Person_Model(); $result = $people->save($this->input->get('person'), $person_id); } else { $form = arr::overwrite($form, $post->as_array()); client::validation_results(arr::overwrite($errors, $post->errors('hiring_employee_form_validations'))); client::messageSend("There were errors in some fields", E_USER_WARNING); } } $building = new Building_Model(); $buildings_list = $building->select_list(); $this->template->title = 'Seating::Spaces::Add'; $this->template->content = new View('pages/spaces_add'); $this->template->content->form = $form; $this->template->content->buildings_list = $buildings_list; }
public function action_delete($delete_id) { if (!$delete_id) { client::messageSend("Invalid Request", E_USER_WARNING); $this->request->redirect('markers'); } $marker = ORM::factory('marker')->find($delete_id); if ($marker->id) { $marker->delete($delete_id); client::messageSend('The Marker "' . HTML::chars($marker->email) . '" was removed', E_USER_NOTICE); } else { client::messageSend("Marker not found", E_USER_WARNING); } $this->request->redirect('admin/markers'); }
public function action_delete($delete_id) { if (!$delete_id) { client::messageSend("Invalid Request", E_USER_WARNING); $this->request->redirect('sites'); } $site = ORM::factory('site')->find($delete_id); if ($site->id) { $site->delete($delete_id); client::messageSend('The Site "' . HTML::chars($site->name) . '" was removed', E_USER_NOTICE); } else { client::messageSend("Site not found", E_USER_WARNING); } $this->request->redirect('admin/sites'); }
public function action_delete($delete_id) { if (!$delete_id) { client::messageSend("Invalid Request", E_USER_WARNING); $this->request->redirect('buildings'); } $building = ORM::factory('building')->find($delete_id); if ($building->id) { $building->delete($delete_id); client::messageSend('The Building "' . HTML::chars($building->name) . '" was removed', E_USER_NOTICE); } else { client::messageSend("Building not found", E_USER_WARNING); } $this->request->redirect('admin/buildings'); }
/** * note: Route set to /logout */ public function logout() { $this->bugzilla->logout(); client::messageSend("You have logged out", E_USER_NOTICE); url::redirect('login'); }
/** * Sends the email to notify the current emp that they are a buddy to this new * employee. * * @param array $form_input * @param Hiring_Model $hiring */ private function notify_buddy($form_input, Hiring_Model $hiring) { $template = kohana::config('workermgmt.buddy_email_template'); $email_info['from_address'] = kohana::config('workermgmt.buddy_email_from_address'); // make sure label is at least an empty string $email_info['from_label'] = kohana::config('workermgmt.buddy_email_from_label') ? kohana::config('workermgmt.buddy_email_from_label') : ''; $email_info['subject'] = kohana::config('workermgmt.buddy_email_subject'); $email_info['buddy_name'] = isset($form_input['buddy_name']) ? ucwords($form_input['buddy_name']) : null; $email_info['buddy_email'] = isset($form_input['buddy']) ? $form_input['buddy'] : null; $email_info['newhire_name'] = isset($form_input['fullname']) ? ucwords($form_input['fullname']) : null; $email_info['newhire_email'] = isset($form_input['email_address']) ? $form_input['email_address'] : null; $email_info['hiring_manager_name'] = isset($form_input['manager_name']) ? $form_input['manager_name'] : null; $email_info['hiring_manager_email'] = isset($form_input['manager']) ? $form_input['manager'] : null; if (!in_array(null, $email_info, true)) { if ($hiring->notify_buddy($template, $email_info)) { client::messageSend("The Buddy Notification Email was sent to {$email_info['buddy_email']}", E_USER_NOTICE); } else { client::messageSend("The Buddy Notification Email was not sent due to and error", E_USER_ERROR); } } else { client::messageSend("The Buddy Notification Email was not sent due to and error", E_USER_ERROR); kohana::log('error', "Requiered fields missing for \$email_info\n" . print_r($email_info, true)); } }
/** * * @todo This still needs A LOT of work. Need a much more elegant templated * solution (samkeen) * * @param array $input * @return array $result * array( * 'error_code' => null, * 'error_message' => null, * 'bug_id' => null, * 'success_message' => null * ); */ public function newhire_filing($request_type, array $input) { $result = array('error_code' => null, 'error_message' => null, 'bug_id' => null, 'success_message' => null); $filing_response = array(); switch ($request_type) { case self::BUG_EMAIL_SETUP: $new_hiring_info['product'] = "mozilla.org"; $new_hiring_info['component'] = "Server Operations: Account Requests"; $new_hiring_info['summary'] = "LDAP/Zimbra Account Request - {$input['fullname']} <{$input['username']}@mozilla.com> (" . $input['start_date'] . ")"; $new_hiring_info['description'] = "Name: {$input['fullname']}\n" . "Username: {$input['username']}\n" . "Type: " . $input['hire_type'] . "\n" . "Manager: {$input['manager_name']}\n" . "Start date: " . $input['start_date'] . "\n"; if ($input['hire_type'] == 'Intern') { $new_hiring_info['description'] .= "End of Internship: {$input['end_date']}\n"; } $location = $input['location'] == "other" ? $input['location_other'] : $input['location']; $new_hiring_info['description'] .= "\nLocation: {$location}"; if (!empty($input['mail_alias'])) { $new_hiring_info['description'] .= "\nAlias: {$input['mail_alias']}"; } if (!empty($input['mail_lists'])) { $new_hiring_info['description'] .= "\nMailing lists: {$input['mail_lists']}"; } if (!empty($input['other_comments'])) { $new_hiring_info['description'] .= "\nOther comments: {$input['other_comments']}"; } $new_hiring_info['ccs'][] = $input['bz_manager']; $new_hiring_info['groups'] = array(self::CODE_EMPLOYEE_HIRING_GROUP); $filing_response = $this->file_bug($new_hiring_info); break; case self::BUG_HARDWARE_REQUEST: $new_hiring_info['product'] = "mozilla.org"; $new_hiring_info['component'] = "Server Operations: Desktop Issues"; $new_hiring_info['summary'] = "Hardware Request - {$input['fullname']} ({$input['start_date']})"; $new_hiring_info['description'] = "Name: {$input['fullname']}\n" . "Username: {$input['username']}\n" . "Type: {$input['hire_type']}\n" . "Manager: {$input['manager_name']}\n" . "Start date: {$input['start_date']}\n"; if ($input['hire_type'] == 'Intern') { $new_hiring_info['description'] .= "End of Internship: {$input['end_date']}\n"; } $location = $input['location'] == "other" ? $input['location_other'] : $input['location']; $new_hiring_info['description'] .= "\nLocation: {$location}\n" . "Machine: " . $input['machine_type'] . "\n"; if (!empty($input['machine_special_requests'])) { $new_hiring_info['description'] .= "\nSpecial Requests: {$input['machine_special_requests']}"; } $new_hiring_info['ccs'][] = $input['bz_manager']; $new_hiring_info['groups'] = array(self::CODE_EMPLOYEE_HIRING_GROUP); $filing_response = $this->file_bug($new_hiring_info); break; case self::BUG_NEWHIRE_SETUP: $new_hiring_info['product'] = "Mozilla Corporation"; $new_hiring_info['component'] = "Facilities Management"; $new_hiring_info['summary'] = "New Hire Notification - {$input['fullname']} ({$input['start_date']})"; $new_hiring_info['description'] = "Name: {$input['fullname']}\n" . "E-mail: {$input['username']}@mozilla.com\n" . "Type: {$input['hire_type']}\n" . "Manager: {$input['manager_name']} ({$input['manager']})\n" . "Buddy: {$input['buddy_name']} ({$input['buddy']})\n" . "Start date: {$input['start_date']}\n"; if ($input['hire_type'] == 'Intern') { $new_hiring_info['description'] .= "End of Internship: {$input['end_date']}\n"; } $location = $input['location'] == "other" ? $input['location_other'] : $input['location']; $new_hiring_info['description'] .= "\nLocation: {$location}\n"; $new_hiring_info['ccs'][] = "*****@*****.**"; $new_hiring_info['ccs'][] = $input['bz_manager']; $new_hiring_info['groups'] = array(self::CODE_EMPLOYEE_HIRING_GROUP); $filing_response = $this->file_bug($new_hiring_info); break; case self::BUG_HR_CONTRACTOR: $new_hiring_info['product'] = "Mozilla Corporation"; $new_hiring_info['component'] = "Consulting"; $summary_2nd_half = $input['org_name'] !== null ? $input['org_name'] : $input['fullname']; $new_hiring_info['summary'] = "Contractor Request - {$summary_2nd_half} ({$input['start_date']})"; $org_string = $input['org_name'] !== null ? "Organization Name: {$input['org_name']}\n" : ""; $new_hiring_info['description'] = $org_string; $contact_string = !empty($input['org_name']) ? "Contact: {$input['fullname']}\n" : "Name: {$input['fullname']}\n"; $new_hiring_info['description'] .= $contact_string . "Address: " . $input['address'] . "\n" . "Phone: " . $input['phone_number'] . "\n" . "E-mail: " . $input['email_address'] . "\n" . "Start of contract: " . $input['start_date'] . "\n" . "End of contract: " . $input['end_date'] . "\n" . "Rate of pay: " . $input['pay_rate'] . "\n" . "Total payment limitation: " . $input['payment_limit'] . "\n" . "Manager: {$input['manager_name']}\n"; $location = $input['location'] == "other" ? $input['location_other'] : $input['location']; $new_hiring_info['description'] .= "\nLocation: {$location}\n" . "Type: " . $input['contract_type'] . "\n" . "Category: " . $input['contractor_category'] . "\n\n" . "Statement of work:\n" . $input['statement_of_work'] . "\n"; $new_hiring_info['ccs'][] = "*****@*****.**"; $new_hiring_info['ccs'][] = $input['bz_manager']; $new_hiring_info['groups'] = array(self::CODE_CONTRACTOR_HIRING_GROUP); $filing_response = $this->file_bug($new_hiring_info); break; default: Kohana::log('error', "Urecognized Filing reqest type [{$request_type}]", E_USER_ERROR); break; } kohana::log('debug', "\$filing_response:" . print_r($filing_response, 1)); $error_code = isset($filing_response['faultCode']) ? $filing_response['faultCode'] : null; $error_message = isset($filing_response['faultString']) ? $filing_response['faultString'] : null; if ($error_message) { $result['error_code'] = $error_code; $result['error_message'] = $error_message; } /** * if we get error code CODE_LOGIN_REQUIRED (login required), no need to try the * rest of these, just redrect to login.php */ if ($result['error_code'] && $result['error_code'] == self::CODE_LOGIN_REQUIRED) { client::messageSend($result['error_message'], E_USER_ERROR); url::redirect('login'); } if (isset($filing_response['id'])) { $result['bug_id'] = isset($filing_response['id']) ? $filing_response['id'] : null; $result['success_message'] = sprintf($this->bug_filing_types[$request_type]['success_message'], $this->config['bugzilla_url'], $result['bug_id'], $result['bug_id']); } return $result; }