function processView()
 {
     $this->_search_params = array();
     if (!empty($_REQUEST['name'])) {
         $_REQUEST['family_name'] = $_REQUEST['name'];
     }
     foreach ($this->_search_terms as $term) {
         if (!empty($_REQUEST[$term])) {
             $this->_search_params[$term] = $_REQUEST[$term];
         }
     }
     if (!empty($this->_search_params)) {
         $this->_family_data = $GLOBALS['system']->getDBObjectData('family', $this->_search_params, 'AND', 'family_name');
     }
     if (empty($this->_family_data) && !empty($this->_search_params['family_name'])) {
         $this->_search_params['family_name'] = '%' . $this->_search_params['family_name'] . '%';
         $this->_family_data = $GLOBALS['system']->getDBObjectData('family', $this->_search_params, 'AND', 'family_name');
     }
     if (count($this->_family_data) == 1) {
         add_message('One matching family found');
         redirect('families', array('familyid' => key($this->_family_data), 'name' => NULL));
         //exits
     }
     // Put all the archived ones last
     $archiveds = array();
     foreach ($this->_family_data as $k => $v) {
         if ($v['status'] == 'archived') {
             $archiveds[$k] = $v;
             unset($this->_family_data[$k]);
         }
     }
     foreach ($archiveds as $k => $v) {
         $this->_family_data[$k] = $v;
     }
 }
 public function index($assignment_id)
 {
     require_capability('servicequotes:writesqs');
     if (!($assignment = $this->assignment_model->get($assignment_id))) {
         die("The assignment ID {$assignment_id} could not be found!");
     }
     $this->assignment = $this->assignment_model->get($assignment_id);
     if (empty($this->assignment)) {
         add_message('This job is no longer on record.', 'warning');
         redirect(base_url());
     }
     $order = $this->order_model->get($this->assignment->order_id);
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     parent::update_time($order->id);
     $diagnostics = $this->diagnostic_model->get_for_technician($this->assignment, $this->session->userdata('technician_id'), $order->senior_technician_id);
     $diagnostic = reset($diagnostics);
     $tasks = $this->order_model->get_tasks($order->id);
     $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager');
     $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'postjob_checklist', 'param' => $assignment_id, 'module' => 'miniant'));
     $title_options = array('title' => $order_type . ' post-job checklist', 'help' => 'You must complete these tasks before obtaining the client\'s signature', 'icons' => array());
     $complete = $this->order_model->has_statuses($order->id, array('POST-JOB COMPLETE'));
     if (!$complete) {
         add_message('You must complete all the tasks below before moving to the next section', 'warning');
     }
     $this->load_stage_view(array('tasks' => $tasks, 'completed' => $complete));
 }
 /**
  * Load up a template object and save its details if applicable.
  */
 function processView()
 {
     if (isset($_REQUEST['templateid'])) {
         $this->_template = new Note_Template((int) $_REQUEST['templateid']);
         if ($this->_template->id) {
             $this->_template->acquireLock();
         }
     }
     if (!empty($_POST['delete'])) {
         $this->_template->delete();
         add_message("Template deleted");
         redirect($_REQUEST['view'], array('*' => NULL));
         // exits
     }
     if (!empty($_REQUEST['template_submitted'])) {
         $this->_template->processForm();
         if ($this->_template->id) {
             if ($this->_template->save()) {
                 add_message("Template saved");
                 redirect($_REQUEST['view'], array('*' => NULL));
             }
         } else {
             if ($this->_template->create()) {
                 add_message("Template added");
                 redirect($_REQUEST['view'], array('*' => NULL));
             }
         }
     }
 }
 function processView()
 {
     if ($_REQUEST['personid']) {
         $this->_person = new Person((int) $_REQUEST['personid']);
     }
     if (empty($this->_person)) {
         trigger_error("Person not found", E_USER_ERROR);
     }
     // exits
     $this->_staff_member = $GLOBALS['system']->getDBObject('staff_member', $this->_person->id);
     if (empty($this->_staff_member) && !empty($_POST['confirm_delete'])) {
         // delete the person altogether
         $this->_person->delete();
     } else {
         if (!empty($_POST['confirm_archiveclean'])) {
             // archive and anononmize the person
             if (!$this->_person->aquireLock()) {
                 add_message('This person cannot be deleted because somebody else holds the lock.  Try again later.', 'error');
                 redirect('persons', array('personid' => $this->_person->id));
                 // exits
             }
             $this->_person->archiveAndClean();
             add_message($this->_person->toString() . ' has been archived and cleaned', 'success');
             redirect('persons', array('personid' => $this->_person->id));
             // exits
         }
     }
 }
 function processView()
 {
     if (empty($_REQUEST['familyid'])) {
         trigger_error("Cannot add note, no family ID specified", E_USER_WARNING);
         return;
     }
     $this->_family =& $GLOBALS['system']->getDBObject('family', $_REQUEST['familyid']);
     $GLOBALS['system']->includeDBClass('family_note');
     $this->_note = new Family_Note();
     if (array_get($_REQUEST, 'new_note_submitted')) {
         $this->_note->processForm();
         $this->_note->setValue('familyid', $this->_family->id);
         if ($this->_note->create()) {
             add_message('Note added');
             redirect('families', array('familyid' => $this->_family->id), 'note_' . $this->_note->id);
             // exits
         }
     } else {
         $members = $this->_family->getMemberData();
         if (count($members) == 1) {
             add_message('Family has only one member, so adding note to that person instead');
             redirect('_add_note_to_person', array('personid' => key($members)));
             // exits
         }
     }
 }
 function processView()
 {
     $this->_loadPerson();
     if (array_get($_POST, 'action')) {
         if (!$this->person->acquireLock()) {
             add_message("Could not adjust iCal feed at this time; please try again later", 'error');
             return;
         }
         if ($_POST['action'] == 'enable') {
             $this->person->setFeedUUID();
             $message = 'iCal feed enabled';
         } else {
             if ($_POST['action'] == 'change') {
                 $this->person->setFeedUUID();
                 $message = 'iCal URL changed';
             } else {
                 if ($_POST['action'] == 'disable') {
                     $this->person->setValue('feed_uuid', NULL);
                     $message = 'iCal feed disabled';
                 } else {
                     $message = 'Invalid action';
                 }
             }
         }
         if (!$this->person->save(FALSE)) {
             add_message("Could not adjust iCal feed at this time; please try again later", 'error');
             return;
         }
         $this->person->releaseLock();
         add_message($message);
     }
 }
 public function process()
 {
     $assignment_id = $this->input->post('assignment_id');
     $assignment = $this->assignment_model->get($assignment_id);
     $unit = $this->unit_model->get($assignment->unit_id);
     $order = (object) $this->order_model->get_values($assignment->order_id);
     $form_data = $this->get_form_data($this->input->post('unit_type_id'), $assignment_id, $this->input->post(), true);
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager');
     $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'unit_serial', 'param' => $assignment_id, 'module' => 'miniant'));
     foreach ($form_data['required'] as $field => $description) {
         $this->form_validation->set_rules($field, $description, 'trim|required');
     }
     $success = $this->form_validation->run();
     if (!$success) {
         add_message('The form could not be submitted. Please check the errors below', 'danger');
         return $this->index($assignment_id);
     }
     $unit_id = $this->unit_model->merge_if_serial_exists($form_data['fields'], $assignment_id);
     if ($unit_id != $assignment->unit_id) {
         add_message('The serial number you entered matches an existing unit. Please review the details below and answer the questions at the bottom of the form', 'warning');
     }
     trigger_event('unit_serial_entered', 'assignment', $assignment_id, false, 'miniant');
     redirect($this->workflow_manager->get_next_url());
 }
 function processView()
 {
     if (empty($_REQUEST['planid'])) {
         add_message('No plans selected for execution', 'error');
         return;
     }
     if (empty($_REQUEST['personid'])) {
         add_message('No persons selected for plan execution', 'error');
         return;
     }
     $plans = array();
     foreach ($_REQUEST['planid'] as $planid) {
         $plans[] = $GLOBALS['system']->getDBObject('action_plan', $planid);
     }
     $refdate = process_widget('plan_reference_date', array('type' => 'date'));
     foreach ($_REQUEST['personid'] as $personid) {
         foreach ($plans as $plan) {
             $plan->execute('person', (int) $personid, $refdate);
         }
     }
     foreach ($plans as $plan) {
         add_message('"' . $plan->getValue('name') . '" plan executed for ' . count($_REQUEST['personid']) . ' person(s)', 'success');
     }
     if (count($_REQUEST['personid']) == 1) {
         redirect('persons', array('personid' => (int) reset($_REQUEST['personid'])));
     }
 }
 function processView()
 {
     $GLOBALS['system']->includeDBClass('person');
     $this->_search_params = array();
     $search = trim(array_get($_REQUEST, 'search', array_get($_REQUEST, 'tel', '')));
     $tel = preg_replace('/[^0-9]/', '', $search);
     if ($search == '') {
         return;
     }
     if (!empty($tel)) {
         // Look for phone number matches
         $this->_family_data = $GLOBALS['system']->getDBObjectData('family', array('home_tel' => $tel));
         $this->_person_data = $GLOBALS['system']->getDBObjectData('person', array('mobile_tel' => $tel, 'work_tel' => $tel));
     }
     if (empty($tel) || empty($this->_family_data) && empty($this->_person_data)) {
         // Look for family name, person name, group name or person email
         $this->_family_data = $GLOBALS['system']->getDBObjectData('family', array('family_name' => $search . '%'));
         $this->_person_data = Person::getPersonsByName($search);
         $this->_group_data = $GLOBALS['system']->getDBObjectData('person_group', array('name' => $search . '%'), 'OR', 'name');
         if (FALSE !== strpos($search, '@')) {
             // Add email search
             $this->_person_data += $GLOBALS['system']->getDBObjectData('person', array('email' => $search));
         }
         if (empty($this->_group_data)) {
             $this->_group_data = $GLOBALS['system']->getDBObjectData('person_group', array('name' => '%' . $search . '%'), 'OR', 'name');
         }
     }
     $numResults = count($this->_family_data) + count($this->_group_data) + count($this->_person_data);
     if ($numResults == 1) {
         // For a single result, just redirect to its detail view, don't show a list
         if (!empty($this->_person_data)) {
             add_message("One matching person found");
             redirect('persons', array('search' => NULL, 'personid' => key($this->_person_data)));
         } else {
             if (!empty($this->_family_data)) {
                 add_message("One matching family found");
                 redirect('families', array('search' => NULL, 'familyid' => key($this->_family_data)));
             } else {
                 if (!empty($this->_group_data)) {
                     add_message("One matching group found");
                     redirect('groups', array('search' => NULL, 'groupid' => key($this->_group_data)));
                 }
             }
         }
     }
     // Put all archived results at the end of the list
     foreach (array('_person_data', '_family_data', '_group_data') as $var) {
         $archiveds = array();
         $ref =& $this->{$var};
         foreach ($ref as $k => $v) {
             if (array_get($v, 'status') == 'archived' || array_get($v, 'is_archived')) {
                 $archiveds[$k] = $v;
                 unset($ref[$k]);
             }
         }
         foreach ($archiveds as $k => $v) {
             $ref[$k] = $v;
         }
     }
 }
Exemple #10
0
 public function delete_attachment($attachment_id, $unit_id, $field_name, $assignment_id)
 {
     $this->unit_attachment_model->delete($attachment_id);
     $this->unit_model->edit($unit_id, array($field_name => null));
     add_message('The attachment was successfully deleted');
     return $this->index($assignment_id);
 }
 function processView()
 {
     $params = array();
     if (!empty($_REQUEST['name'])) {
         $GLOBALS['system']->includeDBClass('person');
         $this->_person_data = Person::getPersonsByName($_REQUEST['name']);
     } else {
         foreach ($this->_search_terms as $term) {
             if (!empty($_REQUEST[$term])) {
                 $params[$term] = $_REQUEST[$term];
             }
         }
         if (!empty($params)) {
             $this->_person_data = $GLOBALS['system']->getDBObjectData('person', $params, 'AND', 'last_name');
         }
     }
     if (count($this->_person_data) == 1) {
         add_message('One matching person found');
         redirect('persons', array('name' => NULL, 'personid' => key($this->_person_data)));
     }
     $archiveds = array();
     foreach ($this->_person_data as $k => $v) {
         if ($v['status'] == 'archived') {
             $archiveds[$k] = $v;
             unset($this->_person_data[$k]);
         }
     }
     foreach ($archiveds as $k => $v) {
         $this->_person_data[$k] = $v;
     }
 }
 function processView()
 {
     $this->_family =& $GLOBALS['system']->getDBObject('family', $_REQUEST['familyid']);
     $GLOBALS['system']->includeDBClass('person');
     $this->_person = new Person();
     if (array_get($_REQUEST, 'new_person_submitted')) {
         $GLOBALS['system']->doTransaction('begin');
         $this->_person = new Person();
         $this->_person->processForm();
         $this->_person->setValue('familyid', $this->_family->id);
         if ($this->_person->create()) {
             if (!empty($_POST['execute_plan'])) {
                 foreach ($_POST['execute_plan'] as $planid) {
                     $plan = $GLOBALS['system']->getDBObject('action_plan', $planid);
                     $plan->execute('person', $this->_person->id, process_widget('plan_reference_date', array('type' => 'date')));
                 }
             }
             $GLOBALS['system']->doTransaction('commit');
             add_message('New family member added');
             redirect('families', array('familyid' => $this->_family->id));
             // exits
         } else {
             $GLOBALS['system']->doTransaction('rollback');
         }
     } else {
         $this->_person->setValue('last_name', $this->_family->getValue('family_name'));
     }
 }
 function processView()
 {
     if (empty($_POST['personid'])) {
         trigger_error("Cannot update persons, no person ID specified", E_USER_WARNING);
         return;
     }
     $customValues = array();
     $customFields = $GLOBALS['system']->getDBObjectData('custom_field', array(), 'OR', 'rank');
     $dummyField = new Custom_Field();
     foreach ($customFields as $fieldid => $fieldDetails) {
         $dummyField->populate($fieldid, $fieldDetails);
         if ($val = $dummyField->processWidget()) {
             $customValues[$fieldid] = $val;
         }
     }
     foreach ($this->_allowedFields as $field) {
         if (array_get($_POST, $field, '') == '') {
             unset($_POST[$field]);
         }
     }
     if (empty($customValues) && count(array_intersect(array_keys($_POST), $this->_allowedFields)) == 0) {
         add_message("Cannot update; no new values were specified", 'error');
         if (!empty($_REQUEST['backto'])) {
             parse_str($_REQUEST['backto'], $back);
             unset($back['backto']);
             redirect($back['view'], $back);
         }
         return;
     }
     $success = 0;
     $GLOBALS['system']->setFriendlyErrors(TRUE);
     foreach ((array) $_REQUEST['personid'] as $personid) {
         $this->_person = new Person((int) $personid);
         foreach ($this->_allowedFields as $field) {
             if (isset($_POST[$field])) {
                 $this->_person->setValue($field, $_POST[$field]);
             }
         }
         foreach ($customValues as $fieldid => $val) {
             $this->_person->setCustomValue($fieldid, $val, array_get($_POST, 'custom_' . $fieldid . '_add', FALSE));
         }
         if ($this->_person->validateFields() && $this->_person->save()) {
             $success++;
         }
     }
     if ($success == count($_REQUEST['personid'])) {
         add_message('Fields updated for ' . count($_REQUEST['personid']) . ' persons');
     } else {
         if ($success > 0) {
             add_message("Fields updated for {$success} persons; some persons could not be updated");
         } else {
             add_message('There was a problem updating the fields. Check your selected persons.');
         }
     }
     if (!empty($_REQUEST['backto'])) {
         parse_str($_REQUEST['backto'], $back);
         unset($back['backto']);
         redirect($back['view'], $back);
     }
 }
 function processView()
 {
     if (empty($_REQUEST['personid'])) {
         trigger_error("Cannot add note, no person ID specified", E_USER_WARNING);
         return;
     }
     if (!is_array($_REQUEST['personid'])) {
         $this->_person =& $GLOBALS['system']->getDBObject('person', $_REQUEST['personid']);
         $_REQUEST['personid'] = array($_REQUEST['personid']);
     }
     $GLOBALS['system']->includeDBClass('person_note');
     $this->_note = new Person_Note();
     if (array_get($_REQUEST, 'new_note_submitted')) {
         $this->_note->processForm();
         $success = TRUE;
         foreach ($_REQUEST['personid'] as $personid) {
             $this->_note->id = 0;
             $this->_note->setValue('personid', $personid);
             $success = $success && $this->_note->create();
         }
         if ($success) {
             if ($this->_person) {
                 add_message('Note added');
                 redirect('persons', array('personid' => $this->_person->id), 'note_' . $this->_note->id);
                 // exits
             } else {
                 add_message('Note added to ' . count($_REQUEST['personid']) . ' persons');
                 redirect('home');
             }
         }
     }
 }
    function processView()
    {
        if (!empty($_POST['datetypename'])) {
            $to_add = $to_delete = $to_update = array();
            foreach ($_POST['datetypename'] as $id => $name) {
                if ($id == '_new_') {
                    foreach ($name as $n) {
                        if ($n) {
                            $to_add[] = $n;
                        }
                    }
                } else {
                    if ($name) {
                        $to_update[$id] = $name;
                    }
                }
            }
            foreach ($to_update as $id => $name) {
                $SQL = 'UPDATE date_type
						SET name = ' . $GLOBALS['db']->quote($name) . '
						WHERE id = ' . (int) $id;
                $res = $GLOBALS['db']->query($SQL);
                check_db_result($res);
            }
            $res = $GLOBALS['db']->query('DELETE FROM date_type WHERE id NOT IN (' . implode(',', array_merge(array_keys($to_update))) . ')');
            foreach ($to_add as $name) {
                $SQL = 'INSERT INTO date_type (name)
						VALUES (' . $GLOBALS['db']->quote($name) . ')';
                $res = $GLOBALS['db']->query($SQL);
                check_db_result($res);
            }
            add_message("Date types updated");
        }
    }
 public function index($assignment_id)
 {
     $this->assignment = (object) $this->assignment_model->get_values($assignment_id);
     if (empty($this->assignment)) {
         add_message('This job is no longer on record.', 'warning');
         redirect(base_url());
     }
     $order = (object) $this->order_model->get_values($this->assignment->order_id);
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     $technician_id = $this->session->userdata('user_id');
     parent::update_time($order->id);
     $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager');
     $this->workflow_manager->initialise(array('workflow' => 'repair', 'stage' => 'repair_checklist', 'param' => $assignment_id, 'module' => 'miniant'));
     $unit = (object) $this->unit_model->get_values($this->assignment->unit_id);
     $tasks = $this->repair_task_model->get(array('assignment_id' => $assignment_id));
     $is_required_set = $this->assignment->diagnostic_required === '0' || $this->assignment->diagnostic_required === '1';
     $is_authorised_set = $this->assignment->diagnostic_required === '0' || ($this->assignment->diagnostic_authorised === '0' || $this->assignment->diagnostic_authorised === '1');
     $this->load->library('Dialog');
     $this->dialog->initialise(array('id' => 'dialog'));
     $this->dialog->add_question(array('id' => 'repairs_completed', 'shown' => !$this->order_model->has_statuses($order->id, array('REPAIR TASKS COMPLETED')), 'text' => 'Have you completed all needed repairs on this unit?', 'answers' => array(array('text' => 'Yes', 'ids_to_show' => array('diagnostic_required'), 'ajax_callback' => 'miniant/stages/repair_checklist/set_diagnostic_not_required/' . $this->assignment->id, 'triggers' => array(array('system' => 'order', 'document_id' => $this->assignment->order_id, 'event_name' => 'repair_tasks_completed', 'module' => 'miniant'))))));
     $this->dialog->add_question(array('id' => 'diagnostic_required', 'shown' => !$is_required_set && $this->order_model->has_statuses($order->id, array('REPAIR TASKS COMPLETED')), 'text' => 'Is this unit now functioning properly?', 'answers' => array(array('text' => 'Yes', 'ids_to_show' => array('continue'), 'ajax_callback' => 'miniant/stages/repair_checklist/set_diagnostic_not_required/' . $this->assignment->id), array('text' => 'No', 'ids_to_show' => array('diagnostic_authorised'), 'ajax_callback' => 'miniant/stages/repair_checklist/set_diagnostic_required/' . $this->assignment->id))));
     $this->dialog->add_question(array('id' => 'diagnostic_authorised', 'shown' => $this->order_model->has_statuses($order->id, array('REPAIR TASKS COMPLETED')) && !$is_authorised_set && $this->assignment->diagnostic_required === '1', 'text' => 'Have you been authorised to perform a diagnostic on this unit?', 'answers' => array(array('text' => 'Yes', 'ids_to_show' => array('continue'), 'ajax_callback' => 'miniant/stages/repair_checklist/set_diagnostic_authorised/' . $this->assignment->id), array('text' => 'No', 'ids_to_show' => array('continue'), 'ajax_callback' => 'miniant/stages/repair_checklist/set_diagnostic_not_authorised/' . $this->assignment->id))));
     $this->dialog->add_question(array('id' => 'continue', 'shown' => $this->order_model->has_statuses($order->id, array('REPAIR TASKS COMPLETED')) && $is_required_set && $is_authorised_set, 'text' => ' ', 'answers' => array(array('text' => 'Continue', 'url' => 'miniant/stages/repair_checklist/process/' . $this->assignment->id))));
     $dialog = $this->dialog->output();
     $this->load_stage_view(array('tasks' => $tasks, 'unit' => $unit, 'dialog' => $dialog, 'title' => 'Repair checklist: Unit ' . $unit->id, 'is_senior_technician' => $technician_id == $order->senior_technician_id));
 }
 public function get_value($name_or_id)
 {
     $setting = $this->get(array('name' => $name_or_id), true);
     if (empty($setting)) {
         $setting = $this->get($name_or_id);
     }
     if (empty($setting)) {
         return null;
     }
     if (empty($setting->value)) {
         add_message("The setting '{$name}' doesn't exist!", 'danger');
         return null;
     } else {
         if ($this->setting_field_type_model->has_options($setting->field_type_id)) {
             $value = explode(',', $setting->value);
             if (strstr($setting->value, ',')) {
                 $values = array();
                 foreach ($value as $value_id) {
                     $values[] = $this->setting_value_model->get($value_id)->value;
                 }
                 return $values;
             } else {
                 return $this->setting_value_model->get($setting->value)->value;
             }
         } else {
             return $setting->value;
         }
     }
 }
Exemple #18
0
function spam_receive()
{
    //`spam_id``user``IP``type`
    if (isset($_POST['this_is_spam'])) {
        //KOlla om det är admin som säger
        if (isset($_SESSION[PREFIX . 'user_id']) && user_get_admin($_SESSION[PREFIX . 'user_id']) > 1) {
            foreach ($_POST['id'] as $s_id) {
                $sql = "UPDATE " . PREFIX . sql_safe($_POST['type']) . " SET is_spam=2 WHERE id=" . sql_safe($s_id) . ";";
                echo "<br />DEBUG1827: {$sql}";
                if (mysql_query($sql)) {
                    add_message($_POST['type'] . " " . $s_id . " marked as spam.");
                } else {
                    add_error("There was some kind of error... (errorcode 1726)");
                }
            }
        } else {
            $sql = "INSERT INTO " . PREFIX . "spam SET type='" . sql_safe($_POST['type']) . "', spam_id=" . sql_safe($_POST['id']) . ", ";
            //Om man är inloggad
            if (isset($_SESSION[PREFIX . 'user_id'])) {
                $sql .= "user="******";";
            } else {
                $sql .= "IP='" . sql_safe($_SERVER['REMOTE_ADDR']) . "';";
            }
            // echo "<br />DEBUG1012: $sql";
            if (mysql_query($sql)) {
                add_message("Thank you for helping us keep the site spam-free!");
            } else {
                add_error("There was some kind of error... (errorcode 1727)");
            }
        }
    }
    if (isset($_POST['this_is_not_spam'])) {
        //KOlla om det är admin som säger
        if (isset($_SESSION[PREFIX . 'user_id']) && user_get_admin($_SESSION[PREFIX . 'user_id']) > 1) {
            foreach ($_POST['id'] as $s_id) {
                $sql = "UPDATE " . PREFIX . sql_safe($_POST['type']) . " SET is_spam=-2 WHERE id=" . sql_safe($s_id) . ";";
                echo "<br />DEBUG1827: {$sql}";
                if (mysql_query($sql)) {
                    add_message($_POST['type'] . " " . $s_id . " marked as not spam.");
                } else {
                    add_error("There was some kind of error... (errorcode 1728)");
                }
            }
        } else {
            $sql = "DELETE FROM " . PREFIX . "spam WHERE type='" . sql_safe($_POST['type']) . "' AND spam_id=" . sql_safe($_POST['id']) . " AND ";
            //Om man är inloggad
            if (isset($_SESSION[PREFIX . 'user_id'])) {
                $sql .= "user="******";";
            } else {
                $sql .= "IP='" . sql_safe($_SERVER['REMOTE_ADDR']) . "';";
            }
            if (mysql_query($sql)) {
                add_message("Thank you for helping us keep the site spam-free!");
            } else {
                add_error("There was some kind of error... (errorcode 1729)");
            }
        }
    }
}
 function processView()
 {
     if (empty($_REQUEST['personid'])) {
         trigger_error("Cannot add note, no person ID specified", E_USER_WARNING);
         return;
     }
     if (!is_array($_REQUEST['personid'])) {
         $this->_person =& $GLOBALS['system']->getDBObject('person', $_REQUEST['personid']);
         $_REQUEST['personid'] = array($_REQUEST['personid']);
     }
     if ($templateID = array_get($_REQUEST, 'note_template_id')) {
         $this->_note_template = new Note_Template($templateID);
     }
     $GLOBALS['system']->includeDBClass('person_note');
     $this->_note = new Person_Note();
     $this->_note->processForm();
     if (array_get($_REQUEST, 'new_note_submitted')) {
         if ($this->_note_template) {
             $this->_note_template->processNoteFieldWidgets();
             $this->_note_template->applyDataBlock($this->_note);
         }
         $success = $failure = 0;
         foreach ($_REQUEST['personid'] as $personid) {
             if ($this->_note_template && $this->_note_template->usesCustomFields()) {
                 $person = new Person($personid);
                 if (!$person->acquireLock()) {
                     add_message("Could not acquire lock on " . $person->toString() . ' - note not saved', 'error');
                     continue;
                     // don't save the note if can't apply the values
                 }
                 $this->_note_template->applyFieldValues($person);
                 if (!$person->save()) {
                     add_message("Could not save values on " . $person->toString() . ' - note not saved', 'error');
                     continue;
                     // don't save the note if can't apply the values
                 }
             }
             $this->_note->id = 0;
             $this->_note->setValue('personid', $personid);
             if ($this->_note->create()) {
                 $success++;
             }
         }
         if ($success) {
             if ($this->_person) {
                 add_message('Note added');
                 redirect('persons', array('personid' => $this->_person->id), 'note_' . $this->_note->id);
                 // exits
             } else {
                 if ($success == count($_REQUEST['personid'])) {
                     add_message('Note added to ' . count($_REQUEST['personid']) . ' persons');
                 } else {
                     add_message('Note successfully added to ' . $success . ' of the ' . count($_REQUEST['personid']) . ' selected persons');
                 }
                 redirect(-1);
             }
         }
     }
 }
 function check_auth()
 {
     if (!$this->login_model->check_session()) {
         $this->session->set_userdata(array('previous_url' => base_url() . $this->uri->uri_string()));
         add_message('Your session has expired. Please login again', 'warning');
         redirect(base_url() . 'login');
     }
 }
 function index()
 {
     add_message('You have been successfully logged out.', 'success');
     $this->login_model->logout();
     $user_login = $this->user_login_model->get(array('session_id' => session_id()), true);
     $this->user_login_model->edit($user_login->id, array('status' => 'Suspended'));
     $this->session->sess_destroy();
     redirect(base_url() . 'login');
 }
 function processView()
 {
     $this->_note =& $GLOBALS['system']->getDBObject($_REQUEST['note_type'] . '_note', (int) $_REQUEST['noteid']);
     if (!empty($_POST['delete_note']) && $this->_note->canBeDeleted()) {
         if ($this->_note->delete()) {
             add_message('Note deleted', 'success');
             $this->redirectAfterEdit();
         } else {
             add_message('Failed to delete note', 'failure');
         }
         return;
     }
     $note_type = $_REQUEST['note_type'] == 'family' ? 'family_note' : 'person_note';
     $this->_note =& $GLOBALS['system']->getDBObject($note_type, $_REQUEST['noteid']);
     if ($_REQUEST['note_type'] == 'family') {
         $this->_family =& $GLOBALS['system']->getDBObject('family', $this->_note->getValue('familyid'));
     } else {
         $this->_person =& $GLOBALS['system']->getDBObject('person', $this->_note->getValue('personid'));
     }
     if (!empty($_POST['update_note_submitted'])) {
         $GLOBALS['system']->doTransaction('begin');
         $success = TRUE;
         if ($this->_note->haveLock()) {
             $fieldsToSave = array_keys($this->_note->fields);
             if (!$this->_note->canEditOriginal()) {
                 $fieldsToSave = array_diff($fieldsToSave, array('subject', 'details'));
             }
             $this->_note->processForm('', $fieldsToSave);
             if (!$this->_note->save()) {
                 $success = FALSE;
             }
             if ($success) {
                 $GLOBALS['system']->includeDBClass('note_comment');
                 $comment = new Note_Comment();
                 $comment->processForm();
                 if (trim($comment->getValue('contents')) != '') {
                     $comment->setValue('noteid', $this->_note->id);
                     if (!$comment->create()) {
                         $success = FALSE;
                     }
                 }
             }
         } else {
             add_message('Lock on note object not held', 'failure');
             $success = FALSE;
         }
         if ($success) {
             $this->_note->releaseLock();
             $GLOBALS['system']->doTransaction('commit');
             add_message('Note Updated');
             $this->redirectAfterEdit();
         } else {
             add_message('Errors while processing, could not save changes', 'failure');
             $GLOBALS['system']->doTransaction('rollback');
         }
     }
 }
 function processView()
 {
     if (!empty($_POST['delete_category_id'])) {
         $cat = $GLOBALS['system']->getDBObject('person_group_category', (int) $_POST['delete_category_id']);
         $cat->delete();
         add_message(_('Category deleted'));
     }
     $this->_all_categories = $GLOBALS['system']->getDBObjectData('person_group_category', array(), 'OR', 'name');
 }
 function processView()
 {
     if (!empty($_REQUEST['roster_view'])) {
         if (defined('PUBLIC_ROSTER_SECRET') && strlen(PUBLIC_ROSTER_SECRET) && array_get($_REQUEST, 'secret') != PUBLIC_ROSTER_SECRET) {
             add_message("Sorry, this roster URL is not valid because it does not contain the secret key.  Please contact your church administrator for assistance.", 'error');
         } else {
             $this->_roster_view =& $GLOBALS['system']->getDBObject('roster_view', (int) $_REQUEST['roster_view']);
         }
     }
 }
 function processView()
 {
     if (!$this->_initEditedObject()) {
         return false;
     }
     if ($this->_processObjectEditing()) {
         add_message($this->getEditingTypeFriendly() . ' Updated');
         $this->_doSuccessRedirect();
     }
 }
 public static function get_instance($jslibrary)
 {
     $classname = 'DatagridJSDriver' . ucfirst($jslibrary);
     if (class_exists($classname)) {
         return new $classname();
     } else {
         add_message("Class {$classname} doesn't exist, please check the \$jslibrary param in your datagrid instantiation.", 'danger');
         return false;
     }
 }
Exemple #27
0
function delete_task($user_id, $task_id)
{
    $result = DB::getInstance()->query("DELETE FROM tasks WHERE task_uid = :user_id AND task_id = :task_id", array("user_id" => $user_id, "task_id" => $task_id));
    if (!$result) {
        add_message("Somewhere is some wild error.");
        return false;
    }
    add_message("Task has been deleted.");
    return true;
}
 function processView()
 {
     if (!empty($_REQUEST['delete_viewid'])) {
         $view =& $GLOBALS['system']->getDBOBject('roster_view', (int) $_REQUEST['delete_viewid']);
         if ($view) {
             $view->delete();
             add_message('View Deleted');
             redirect('rosters__define_roster_views', array());
         }
     }
 }
Exemple #29
0
function module_info_main()
{
    switch (post('cmd')) {
        case 'add_message':
            add_message();
            break;
        case 'add_comment':
            add_comment();
            break;
    }
}
 public function index()
 {
     if (has_capability('site:doanything')) {
         // Create the archive
         chdir('/srv/www/miniant');
         $result = exec('hg archive miniant.tar.bz2', $output);
         add_message($result);
         $data = file_get_contents('/srv/www/miniant/miniant.tar.bz2');
         $this->load->helper('download');
         force_download('miniant.tar.bz2', $data);
     }
 }