示例#1
0
 function save($data, $options = array())
 {
     $options = array_merge($this->getOptions(), $options);
     if (!(isset($options['related_form_id']) && $options['related_form_id'])) {
         trigger_error(sprintf(AMP_TEXT_ERROR_NOT_DEFINED, get_class($this), 'related_form_id'));
         return;
     }
     foreach ($this->_included_fieldnames as $fieldname) {
         if ($this->fields[$fieldname]['type'] == 'select') {
             $data[$fieldname] = $_POST[$this->addPrefix($fieldname)];
         }
     }
     # this is weak, but deep within quickform our shit is getting
     # overridden with values from the original udm (constant vs default vs submit values)
     $temp_post = $_POST;
     unset($_POST['modin']);
     $data_sets = $this->convert_to_sets($data);
     foreach ($data_sets as $values) {
         if (isset($options['related_form_owner_field']) && $options['related_form_owner_field']) {
             $values[$options['related_form_owner_field']] = $this->udm->uid;
         }
         $udm = new UserDataInput($this->dbcon, $options['related_form_id'], $this->udm->admin);
         # here's where the lameness comes in
         foreach (array_keys($values) as $key) {
             unset($_POST[$key]);
             # we also have to make everything public, or it won't save
             $udm->fields[$key]['public'] = 1;
         }
         $udm->setData($values);
         $results[] = $udm->saveUser();
         unset($udm);
     }
     $_POST = $temp_post;
     return true;
 }