function processForm($prefix = '', $fields = NULL) { $res = parent::processForm($prefix, $fields); foreach ($this->getCustomFields() as $fieldid => $fieldDetails) { $field = $GLOBALS['system']->getDBObject('custom_field', $fieldid); $this->setCustomValue($fieldid, $field->processWidget()); } $this->_photo_data = Photo_Handler::getUploadedPhotoData('photo'); return $res; }
function processForm($prefix = '', $fields = NULL) { $res = parent::processForm($prefix, $fields); $this->_dates_to_save = self::processDatesInterface($prefix); if (!empty($_FILES['photo']) && !$_FILES['photo']['error']) { if (!in_array($_FILES['photo']['type'], array('image/jpeg', 'image/gif', 'image/png', 'image/jpg'))) { add_message("The uploaded photo was not of a permitted type and has not been saved. Photos must be JPEG, GIF or PNG", 'error'); } else { if (!is_uploaded_file($_FILES['photo']['tmp_name'])) { trigger_error("Security error with file upload", E_USER_ERROR); } else { $ext = strtolower(end(explode('.', $_FILES['photo']['name']))); if ($ext == 'jpg') { $ext = 'jpeg'; } if (!in_array($ext, array('jpeg', 'gif', 'png'))) { add_message("The uploaded photo was not of a permitted type and has not been saved. Photos must be JPEG, GIF or PNG", 'error'); return $res; } if (function_exists('imagepng')) { $fn = 'imagecreatefrom' . $ext; list($orig_width, $orig_height) = getimagesize($_FILES['photo']['tmp_name']); $input_img = $fn($_FILES['photo']['tmp_name']); if (!$input_img) { exit; } $orig_ratio = $orig_width / $orig_height; if ($orig_width > self::MAX_PHOTO_WIDTH || $orig_height > self::MAX_PHOTO_HEIGHT) { if (self::MAX_PHOTO_WIDTH > self::MAX_PHOTO_HEIGHT) { // resize to fit width then crop to fit height $new_width = self::MAX_PHOTO_WIDTH; $new_height = min(self::MAX_PHOTO_HEIGHT, $new_width / $orig_ratio); $src_x = 0; $src_w = $orig_width; $src_h = $new_height * ($orig_width / $new_width); $src_y = (int) max(0, ($orig_height - $src_h) / 2); } else { // resize to fit height then crop to fit width $new_height = self::MAX_PHOTO_HEIGHT; $new_width = min(self::MAX_PHOTO_WIDTH, $new_height * $orig_ratio); $src_y = 0; $src_h = $orig_height; $src_w = $new_width * ($orig_height / $new_height); $src_x = (int) max(0, ($orig_width - $src_w) / 2); } $output_img = imagecreatetruecolor($new_width, $new_height); imagecopyresized($output_img, $input_img, 0, 0, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h); imagedestroy($input_img); } else { $output_img = $input_img; } $fn = 'image' . $ext; $fn($output_img, $_FILES['photo']['tmp_name']); } $this->_photo_data = file_get_contents($_FILES['photo']['tmp_name']); unlink($_FILES['photo']['tmp_name']); } } } return $res; }
function processForm() { parent::processForm(); $actions = array('notes' => array(), 'groups' => array(), 'groups_remove' => array(), 'dates' => array()); $i = 0; while ($note = $this->_processNoteForm($i)) { $actions['notes'][] = $note; $i++; } $i = 0; while (isset($_POST['groups'][$i])) { if ($groupid = (int) $_POST['groups'][$i]) { $actions['groups'][] = $groupid; } $i++; } $i = 0; while (isset($_POST['groups_remove'][$i])) { if ($groupid = (int) $_POST['groups_remove'][$i]) { $actions['groups_remove'][] = $groupid; } $i++; } if (isset($_POST['datetypes'])) { $i = 0; while (isset($_POST['datetypes'][$i])) { if ($_POST['datetypes'][$i]) { $actions['dates'][$_POST['datetypes'][$i]] = $_POST['datenotes'][$i]; } $i++; } } $actions['dates'] = array(); foreach ($_REQUEST['datetypes'] as $i => $customFieldID) { if ($customFieldID) { $actions['dates'][$customFieldID] = $_REQUEST['datenotes'][$i]; } } $this->setValue('actions', $actions); }
function processForm() { parent::processForm(); $actions = array('notes' => array(), 'groups' => array(), 'groups_remove' => array(), 'dates' => array(), 'attendance' => NULL); $i = 0; while ($note = $this->_processNoteForm($i)) { $actions['notes'][] = $note; $i++; } $i = 0; while (isset($_POST['groups'][$i])) { if ($groupid = (int) $_POST['groups'][$i]) { $actions['groups'][] = $groupid; } $i++; } $i = 0; while (isset($_POST['groups_remove'][$i])) { if ($groupid = (int) $_POST['groups_remove'][$i]) { $actions['groups_remove'][] = $groupid; } $i++; } $addValue = array_get($_POST, 'fields_addvalue', array()); foreach (array_get($_POST, 'fields_enabled', array()) as $k => $v) { if (0 === strpos($k, 'custom_')) { $fieldID = substr($k, 7); $field = new Custom_Field($fieldID); if ($field->getValue('type') == 'date') { // FUture expansion: allow static dates here; for now we just support // the reference date, represented by magic number -1. $val = '-1===' . $_POST['custom_' . $fieldID . '_note']; } else { $val = $field->processWidget(); $val = reset($val); // it comes wrapped in an array } } else { $val = $_POST[$k]; } $actions['fields'][$k] = array('value' => $val, 'add' => array_get($addValue, $k, FALSE)); } $actions['attendance'] = $_POST['mark_present']; $this->setValue('actions', $actions); }
function processForm() { parent::processForm(); $actions = array('notes' => array(), 'groups' => array(), 'groups_remove' => array(), 'dates' => array()); $i = 0; while ($note = $this->_processNoteForm($i)) { $actions['notes'][] = $note; $i++; } $i = 0; while (isset($_POST['groups'][$i])) { if ($groupid = (int) $_POST['groups'][$i]) { $actions['groups'][] = $groupid; } $i++; } $i = 0; while (isset($_POST['groups_remove'][$i])) { if ($groupid = (int) $_POST['groups_remove'][$i]) { $actions['groups_remove'][] = $groupid; } $i++; } if (isset($_POST['datetypes'])) { $i = 0; while (isset($_POST['datetypes'][$i])) { if ($_POST['datetypes'][$i]) { $actions['dates'][$_POST['datetypes'][$i]] = $_POST['datenotes'][$i]; } $i++; } } $GLOBALS['system']->includeDBClass('person'); $dates = Person::processDatesInterface(''); if (!is_null($dates)) { $actions['dates'] = $dates; } $this->setValue('actions', $actions); }