Skip to content
Snippets Groups Projects
Select Git revision
3 results Searching

search.html

Blame
  • class.RegisterUtils.php 5.30 KiB
    <?php
    class RegisterUtils {
    
      private static $spreadsheetName = '00spreadsheet.csv';
    
      public static $mandatoryKeys = array('last', 'first', 'email');
      public static $optionalKeys = array('affiliation','vat','invoice',
    				     'constraints');
      private $mealKeys = array();
      private $selectedBoxes = array();
      private $checkBoxes = array();
    
      public $errorString = '';
      private $directory = '';
      private $mandatory = array();
      private $optional = array();
      public $values = array();
     
    
      function __construct($directory = NULL) {
        clearstatcache();
        $this->errorString='';
        if (!$directory) {
          $this->errorString = 'No result directory specified';
          return;
        }
        //echo '<pre>'; print_r($directory); echo'</pre>';
        if (is_dir($directory) && is_writable($directory)) {
         } else {
          $this->errorString = sprintf('Directory %s not writable!',$directory);
          return;
        }
        $this->directory = $directory;
      }
    
      public function getMealKeys() {
        return $this->mealKeys;
      }
    
      public function getSelectedBoxes(){
        return $this->selectedBoxes;
      }
    
      public function getCheckBoxes() {
        return $this->checkBoxes;
      }
    
    
        
      public function valuesFromParams($params) {
        $mealString = trim($params['meals']);
        if ($mealString) {
          $this->mealKeys = explode('|',$mealString);
        }
        foreach (self::$mandatoryKeys as $key) {
          $this->values[$key] = '';
          if(isset($params[$key])) {
            $val = htmlspecialchars_decode(trim($params[$key]));
            $this->mandatory[$key] = $val;
            $this->values[$key] = $val;
          }
        }
        foreach (self::$optionalKeys as $key) {
          $this->values[$key] = '';
          if(isset($params[$key])) {
            $val = htmlspecialchars_decode(trim($params[$key]));
            $this->optional[$key] = $val;
            $this->values[$key] = $val;
          }
        }