PageRenderTime 59ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/application/modules/qualification/controllers/qualifications.php

https://bitbucket.org/matyhaty/senses-designertravelv3
PHP | 132 lines | 90 code | 24 blank | 18 comment | 7 complexity | dd98015645aa60e2f6f453e77db90bc0 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. if (!defined('BASEPATH'))
  3. exit('No direct script access allowed');
  4. class Qualifications extends Base_Controller
  5. {
  6. /**
  7. * Constructor for profile page
  8. *
  9. */
  10. function __construct()
  11. {
  12. $this->load->library('form_validation');
  13. $this->load->helper(array(
  14. 'form',
  15. 'url'
  16. ));
  17. parent::__construct('Qualification');
  18. }
  19. public function edit($userID)
  20. {
  21. // Load the email helper
  22. $this->load->helper('url');
  23. $this->load->helper('form');
  24. $this->load->helper('upload');
  25. $this->load->library('form_validation');
  26. $this->load->library('session');
  27. //log_message('error', 'hello edit quallys');
  28. $qualification = $this->model;
  29. $formdata = $this->xml_forms->loadXML(APPPATH . 'modules/qualification/forms', 'qualifications');
  30. //$formdropdowns['qualification'] = qualificationtype::getOptions($currentFlag = NULL);
  31. //var_dump($_POST);
  32. if ($this->input->post() && $userID)
  33. {
  34. if ($this->form_validation->run() == TRUE)
  35. {
  36. $data = $this->input->post();
  37. $userid = $this->session->userdata('userid');
  38. $saved = DMZ_Array::from_array($qualification, $data, NULL, TRUE);
  39. // Save the job
  40. if ($saved)
  41. {
  42. // relate to qualifcation type
  43. $qt = new Qualificationtype($data['qualification']);
  44. $qualification->save($qt);
  45. $u = new User($userID);
  46. $qualification->save($u);
  47. // delete this users cache for qualifcations
  48. $this->model->removeCachedObject('qualification', null, $u, false, null, '', '');
  49. // Save Files
  50. $this->teamleaf->checkpath($userID . '/qualifications');
  51. $config['upload_path'] = UPLOAD_PATH . $userID . '/qualifications/';
  52. $config['allowed_types'] = '*'; // ONLY WORKS ON THE WILDCARD - UNKNOWN REASON!
  53. $config['max_size'] = '100000';
  54. $this->load->library('upload', $config);
  55. multifile_array(); // HELPER SORTS OUT THE FILE ARRAY SO DO_UPLOAD CAN RUN
  56. foreach ($_FILES as $file => $file_data)
  57. {
  58. $this->upload->initialize($config);
  59. if(!$this->upload->do_upload($file))
  60. {
  61. echo $this->upload->display_errors('<p>', '</p>');
  62. echo 'Upload Path is: '.$config['upload_path'];
  63. }
  64. else
  65. {
  66. // save file into DB
  67. $uploaded = new File();
  68. $filedata = $this->upload->data();
  69. //print_r($filedata);
  70. $saved = DMZ_Array::from_array($uploaded, $filedata, NULL, TRUE);
  71. // and relate to qually
  72. $uploaded->save($qualification);
  73. }
  74. }
  75. $errors = '';
  76. //------- Upload the potential 4 files
  77. $clearCache = true;
  78. echo $qualification->getQualifications($userID, $clearCache);
  79. }
  80. else
  81. {
  82. echo 'Save Error<hr>';
  83. echo validation_errors();
  84. }
  85. }
  86. else
  87. {
  88. echo 'Failed validation: '.validation_errors();
  89. }
  90. }
  91. else
  92. {
  93. // Load the view
  94. $form = $this->xml_forms->createform($formdata['xml'], $this->user, $formdropdowns, array(
  95. 'nosheet' => 1,
  96. 'grid' => ''
  97. ));
  98. echo $form;
  99. }
  100. }
  101. public function delete($id, $userID)
  102. {
  103. $qualification = new Qualification();
  104. $qualification->deleteQualification($id, $userID);
  105. redirect('admin/user/profile/display/'.$userID);
  106. }
  107. }
  108. //end class