/application/modules/qualification/controllers/qualifications.php
PHP | 132 lines | 90 code | 24 blank | 18 comment | 7 complexity | dd98015645aa60e2f6f453e77db90bc0 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
- <?php
- if (!defined('BASEPATH'))
- exit('No direct script access allowed');
- class Qualifications extends Base_Controller
- {
- /**
- * Constructor for profile page
- *
- */
- function __construct()
- {
- $this->load->library('form_validation');
- $this->load->helper(array(
- 'form',
- 'url'
- ));
- parent::__construct('Qualification');
- }
- public function edit($userID)
- {
- // Load the email helper
- $this->load->helper('url');
- $this->load->helper('form');
- $this->load->helper('upload');
- $this->load->library('form_validation');
- $this->load->library('session');
- //log_message('error', 'hello edit quallys');
- $qualification = $this->model;
- $formdata = $this->xml_forms->loadXML(APPPATH . 'modules/qualification/forms', 'qualifications');
- //$formdropdowns['qualification'] = qualificationtype::getOptions($currentFlag = NULL);
- //var_dump($_POST);
- if ($this->input->post() && $userID)
- {
- if ($this->form_validation->run() == TRUE)
- {
- $data = $this->input->post();
- $userid = $this->session->userdata('userid');
- $saved = DMZ_Array::from_array($qualification, $data, NULL, TRUE);
- // Save the job
- if ($saved)
- {
-
- // relate to qualifcation type
- $qt = new Qualificationtype($data['qualification']);
- $qualification->save($qt);
- $u = new User($userID);
- $qualification->save($u);
-
- // delete this users cache for qualifcations
- $this->model->removeCachedObject('qualification', null, $u, false, null, '', '');
-
- // Save Files
- $this->teamleaf->checkpath($userID . '/qualifications');
- $config['upload_path'] = UPLOAD_PATH . $userID . '/qualifications/';
- $config['allowed_types'] = '*'; // ONLY WORKS ON THE WILDCARD - UNKNOWN REASON!
- $config['max_size'] = '100000';
- $this->load->library('upload', $config);
- multifile_array(); // HELPER SORTS OUT THE FILE ARRAY SO DO_UPLOAD CAN RUN
- foreach ($_FILES as $file => $file_data)
- {
- $this->upload->initialize($config);
- if(!$this->upload->do_upload($file))
- {
- echo $this->upload->display_errors('<p>', '</p>');
- echo 'Upload Path is: '.$config['upload_path'];
- }
- else
- {
- // save file into DB
- $uploaded = new File();
- $filedata = $this->upload->data();
- //print_r($filedata);
- $saved = DMZ_Array::from_array($uploaded, $filedata, NULL, TRUE);
- // and relate to qually
- $uploaded->save($qualification);
- }
- }
- $errors = '';
- //------- Upload the potential 4 files
-
-
- $clearCache = true;
- echo $qualification->getQualifications($userID, $clearCache);
- }
- else
- {
- echo 'Save Error<hr>';
- echo validation_errors();
- }
- }
- else
- {
- echo 'Failed validation: '.validation_errors();
- }
- }
- else
- {
- // Load the view
- $form = $this->xml_forms->createform($formdata['xml'], $this->user, $formdropdowns, array(
- 'nosheet' => 1,
- 'grid' => ''
- ));
- echo $form;
- }
- }
- public function delete($id, $userID)
- {
- $qualification = new Qualification();
- $qualification->deleteQualification($id, $userID);
- redirect('admin/user/profile/display/'.$userID);
- }
- }
- //end class