if ($form->duration == 1) {
$form->timeduration = make_timestamp($form->endyr, $form->endmon, $form->endday, $form->endhr, $form->endmin) - $form->timestart;
if ($form->timeduration < 0) {
$form->timeduration = 0;
}
} else {
if ($form->duration == 2) {
$form->timeduration = $form->minutes * MINSECS;
} else {
$form->timeduration = 0;
}
}
if (!calendar_add_event_allowed($form)) {
error('You are not authorized to do this');
}
validate_form($form, $err);
if (count($err) == 0) {
$form->timemodified = time();
/// Get the event id for the log record.
$eventid = insert_record('event', $form, true);
/// Use the event id as the repeatid to link repeat entries together
if ($form->repeat) {
$form->repeatid = $form->id = $eventid;
update_record('event', $form);
// update the row, to set its repeatid
}
/// Log the event entry.
add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&id=' . $eventid, stripslashes($form->name));
if ($form->repeat) {
for ($i = 1; $i < $form->repeats; $i++) {
// What's the DST offset for the previous repeat?
function add_document()
{
# Get the passed details into the url data array if any
$urldata = $this->uri->uri_to_assoc(3, array('m', 'i'));
# Pick all assigned data
$data = assign_to_data($urldata);
$this->session->set_userdata('local_allowed_extensions', array('.doc', '.docx', '.pdf', '.ppt', '.pptx'));
if (!empty($data['i'])) {
$_POST['editid'] = decryptValue($data['i']);
}
if ($this->input->post('editid')) {
$data['formdata'] = $this->Query_reader->get_row_as_array('get_document_by_id', array('id' => $_POST['editid']));
}
#Get the document details
if ($this->input->post('adddocument')) {
$_POST['documenturl'] = !empty($_FILES['documenturlupload']['name']) ? $this->sysfile->local_file_upload($_FILES['documenturlupload'], 'Upload_' . strtotime('now'), 'documents', 'filename') : '';
$required_fields = array('documentname', 'description', 'section');
if (!$this->input->post('editid')) {
array_push($required_fields, 'documenturl');
}
$_POST = clean_form_data($_POST);
$validation_results = validate_form('', $_POST, $required_fields);
#Only proceed if the validation for required fields passes
if ($validation_results['bool']) {
#First remove the document record and file from the system
if (!empty($data['formdata']) && $this->input->post('editid')) {
if (!empty($data['formdata']['documenturl']) && !empty($_POST['documenturl'])) {
@unlink(UPLOAD_DIRECTORY . "documents/" . $data['formdata']['documenturl']);
}
#Only update the document if the user uploaded a new document
if (!empty($_POST['documenturl'])) {
$_POST['urlscript'] = ", documenturl='" . $_POST['documenturl'] . "'";
} else {
$_POST['urlscript'] = "";
}
$save_result = $this->db->query($this->Query_reader->get_query_by_code('update_document', $_POST));
} else {
$save_result = $this->db->query($this->Query_reader->get_query_by_code('save_new_document', $_POST));
}
if ($save_result) {
$data['msg'] = "The document has been saved.";
$this->session->set_userdata('sres', $data['msg']);
redirect(base_url() . "documents/manage_documents/m/sres");
} else {
$data['msg'] = "ERROR: The document was not saved. Please contact your administrator.";
}
}
#VALIDATION end
if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
$data['msg'] = "WARNING: The highlighted fields are required.";
}
$data['requiredfields'] = $validation_results['requiredfields'];
$data['formdata'] = $_POST;
}
#Get tabs and active links if given
$data = get_tab_data_if_any($data);
$this->load->view('documents/add_document_view', $data);
}
function save_incident()
{
access_control($this);
# Get the passed details into the url data array if any
$urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 's', 't'));
# Pick all assigned data
$data = assign_to_data($urldata);
$data = restore_bad_chars($data);
if ($_POST['save_incident']) {
$data['formdata'] = $_POST;
$required_fields = array('incidentdate', 'student', 'reportedby', 'response', 'incidentdetails', 'actiontaken');
$_POST = clean_form_data($_POST);
$validation_results = validate_form('', $_POST, $required_fields);
#set status as editing on destination if updating
if ($this->input->post('editid')) {
$data['editid'] = $_POST['editid'];
}
#Only proceed if the validation for required fields passes
if ($validation_results['bool'] && !(empty($data['editid']) && !empty($user_details))) {
if (!empty($_POST['editid'])) {
#Add the school id and author to the data array
$_POST = array_merge($_POST, array('author' => $this->session->userdata('userid')));
$result = $this->disciplineobj->update_incident(array_merge($_POST, array('id' => $data['editid'])));
} else {
#Add the school id and author to the data array
$_POST = array_merge($_POST, array('author' => $this->session->userdata('userid')));
#decrypt student and reported by values
$_POST['student'] = decryptValue($_POST['student']);
$_POST['reportedby'] = decryptValue($_POST['reportedby']);
$result = $this->disciplineobj->add_incident($_POST);
}
#Format and send the errors
if (!empty($result) && $result) {
$data['msg'] = "The incident data has been successfully saved.";
$data['formdata'] = array();
} else {
if (empty($data['msg'])) {
$data['msg'] = "ERROR: The incident could not be saved or was not saved correctly." . $classname_error . $rank_error;
}
}
} else {
if (empty($data['editid']) && !empty($class_details)) {
#$addn_msg = (!empty($user_details['isactive']) && $user_details['isactive'] == 'N')? "<a href='".base_url()."admin/load_user_form/i/".encryptValue($user_details['id'])."/a/".encryptValue("reactivate")."' style='text-decoration:underline;font-size:17px;'>Click here to activate and edit</a>": "<a href='".base_url()."admin/load_user_form/i/".encryptValue($user_details['id'])."' style='text-decoration:underline;font-size:17px;'>Click here to edit</a>";
$data['msg'] = "WARNING: A class with the same name already exists.<br />";
}
}
if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
$data['msg'] = "WARNING: The highlighted fields are required.";
}
$data['requiredfields'] = $validation_results['requiredfields'];
}
#get the student info
if (!empty($data['s'])) {
$data['student_details'] = $this->Query_reader->get_row_as_array('get_students_list', array('isactive' => 'Y', 'searchstring' => ' AND id=\'' . decryptValue($data['s']) . '\'', 'limittext' => ''));
}
$this->load->view('discipline/incident_form_view', $data);
}
function save_sponsor()
{
access_control($this);
# Get the passed details into the url data array if any
$urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a', 't'));
# Pick all assigned data
$data = assign_to_data($urldata);
if ($data['save']) {
$data['formdata'] = $data;
$required_fields = array('firstname', 'lastname');
foreach ($data as $key => $data_value) {
$data[$key] = restore_bad_chars($data_value);
}
$_POST = clean_form_data($data);
$validation_results = validate_form('', $_POST, $required_fields);
$feename_error = '';
#Only proceed if the validation for required fields passes
if ($validation_results['bool']) {
#check if sponsor photo has changed
if (!empty($_POST['photo'])) {
#move photo to designated folder and add value to query string
if (copy(UPLOAD_DIRECTORY . "temp/" . $_POST['photo'], UPLOAD_DIRECTORY . "sponsors/" . $_POST['photo'])) {
#move the thumb nail as well
$temp_photo_arr = explode('.', $_POST['photo']);
if (copy(UPLOAD_DIRECTORY . "temp/" . $temp_photo_arr[0] . '_thumb.' . $temp_photo_arr[1], UPLOAD_DIRECTORY . "sponsors/" . $temp_photo_arr[0] . '_thumb.' . $temp_photo_arr[1])) {
if (!empty($data['editid'])) {
$_POST['UPDATESTRING'] = ',photo ="' . $_POST['photo'] . '"';
}
}
}
} else {
$_POST['UPDATESTRING'] = '';
}
if (!empty($data['editid'])) {
$result = $this->sponsorobj->update_sponsor(array_merge($_POST, array('editid' => decryptValue($data['editid']))));
} else {
#Add the school id and author to the data array
$_POST = array_merge($_POST, array('school' => $this->myschool['id'], 'author' => $this->session->userdata('userid')));
$result = $this->sponsorobj->add_sponsor($_POST);
}
#Format and send the errors
if (!empty($result) && $result) {
$data['msg'] = empty($data['editid']) ? $data['firstname'] . ' ' . $data['lastname'] . ' has been added to the sponsors list' : $data['firstname'] . '\'s details have been updated.';
$data['formdata'] = array();
} else {
if (empty($data['msg'])) {
$data['msg'] = "ERROR: The sponsor could not be saved or was not saved correctly.";
}
}
}
$data['requiredfields'] = $validation_results['requiredfields'];
}
$this->load->view('sponsors/sponsor_form_view', $data);
}
function save_term()
{
access_control($this);
# Get the passed details into the url data array if any
$urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a', 't'));
# Pick all assigned data
$data = assign_to_data($urldata);
$data = restore_bad_chars($data);
if ($data['save']) {
$data['termdetails'] = $data;
$required_fields = array('term', 'year', 'startdate', 'enddate');
$_POST = clean_form_data($data);
$validation_results = validate_form('', $_POST, $required_fields);
#set status as editing on destination if updating
//if($this->input->post('editid') || $data['editid']) $data['editid'] = $_POST['editid'];
#Only proceed if the validation for required fields passes
if ($validation_results['bool']) {
if (!empty($data['editid'])) {
#Check if another term other than the current one exists with the same name and year
$term_details = $this->Query_reader->get_row_as_array('search_terms_list', array('limittext' => '', 'searchstring' => ' AND term = "' . $data['termdetails']['term'] . '" AND id != ' . $data['editid'] . ' AND school =' . $this->myschool->cur_school_details['id'] . ' AND year = "' . $data['termdetails']['year'] . '"'));
if (!count($term_details)) {
$result = $this->db->query($this->Query_reader->get_query_by_code('update_term', $_POST));
} else {
$termname_error = "WARNING: A term with the same name and year already exists.";
}
} else {
$term_details = $this->Query_reader->get_row_as_array('search_terms_list', array('limittext' => '', 'searchstring' => ' AND isactive ="Y" AND term = "' . $data['termdetails']['term'] . '" AND school =' . $this->myschool->cur_school_details['id'] . ' AND year = "' . $data['termdetails']['year'] . '"'));
if (empty($term_details)) {
#Add the school id
$_POST = array_merge($_POST, array('school' => $this->myschool->cur_school_details['id']));
$result = $this->terms->add_term($_POST);
}
}
#Format and send the errors
if (!empty($result) && $result) {
$data['msg'] = "The term data has been successfully saved";
$data['termdetails'] = array();
} elseif (empty($data['editid']) && !empty($term_details)) {
$data['msg'] = "WARNING: A term with the same name and year already exists.<br />";
} else {
if (empty($data['msg'])) {
$data['msg'] = "ERROR: The term could not be saved or was not saved correctly.";
}
}
}
if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
$data['msg'] = "WARNING: The highlighted fields are required.";
}
$data['requiredfields'] = $validation_results['requiredfields'];
}
$this->load->view('incl/term_form', $data);
}
开发者ID:nwtug,项目名称:academia,代码行数:52,代码来源:terms.php
示例12: change_password
/**
* Submission of Change Password form
*/
public function change_password()
{
$form_url = 'account';
if (validate_form($form_url)) {
// update db
$password = $this->input->post('password');
$update_data = ['password' => hash_pw($password)];
$result = $this->backend_users->update($this->mUser['id'], $update_data);
// success
set_alert('success', 'Mot de passe changé.');
}
// back to form
redirect($form_url);
}
function save_exam()
{
access_control($this);
# Get the passed details into the url data array if any
$urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a', 't'));
# Pick all assigned data
$data = assign_to_data($urldata);
if ($data['save'] || $data['saveandnew']) {
$data['formdata'] = $data;
$required_fields = array('exam', 'term', 'contribution', 'classes');
foreach ($data as $key => $data_value) {
$data[$key] = restore_bad_chars($data_value);
}
$_POST = clean_form_data($data);
$validation_results = validate_form('', $_POST, $required_fields);
$feename_error = '';
#Only proceed if the validation for required fields passes
if ($validation_results['bool']) {
#Convert classes into strings
if (is_array($_POST['classes'])) {
$_POST['classes'] = stringify_array($_POST['classes'], '|');
} else {
$_POST['classes'] = '|' . $_POST['classes'] . '|';
}
if (!empty($data['editid'])) {
$result = $this->db->query($this->Query_reader->get_query_by_code('update_exam', array_merge($_POST, array('id' => $data['editid']))));
} else {
#Add the school id and author to the data array
$_POST = array_merge($_POST, array('school' => $this->myschool['id'], 'author' => $this->session->userdata('userid')));
$result = $this->db->query($this->Query_reader->get_query_by_code('add_exam', $_POST));
}
#Format and send the errors
if (!empty($result) && $result) {
$data['msg'] = empty($data['editid']) ? $data['exam'] . ' has been added.' : 'Details for ' . $data['exam'] . ' have been updated.';
$data['formdata'] = array();
} else {
if (empty($data['msg'])) {
$data['msg'] = "ERROR: The exam could not be saved or was not saved correctly.";
}
}
}
$data['requiredfields'] = $validation_results['requiredfields'];
}
$data['classes'] = $this->classobj->get_classes();
$data['terms'] = $this->terms->get_terms();
$this->load->view('incl/exam_form', $data);
}
开发者ID:nwtug,项目名称:academia,代码行数:47,代码来源:exams.php
示例14: reset_password
/**
* Reset password for backend users
*/
public function reset_password($user_id)
{
$this->mTitle = "Backend Users";
$this->mViewFile = 'admin/reset_password';
$this->mViewData['target'] = $this->backend_users->get($user_id);
if (validate_form('', 'admin/reset_password')) {
// update db
$password = $this->input->post('password');
$result = $this->backend_users->update($user_id, ['password' => hash_pw($password)]);
// success or failed
if ($result) {
set_alert('success', 'Successfully updated.');
} else {
set_alert('danger', 'Database error.');
}
// refresh page to show alert msg
redirect(current_url());
}
}
请发表评论