Skip to content

Commit

Permalink
Fixes some forms issues relating to unserializing [#897]
Browse files Browse the repository at this point in the history
  • Loading branch information
dleffler committed Mar 19, 2013
1 parent 28a074b commit 801292f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
3 changes: 3 additions & 0 deletions framework/core/forms/controls/uploadcontrol.php
Expand Up @@ -27,6 +27,8 @@
*/
class uploadcontrol extends formcontrol {

var $accept = "";

static function name() { return "File Upload Field"; }
static function isSimpleControl() { return true; }
static function getFieldDefinition() {
Expand Down Expand Up @@ -66,6 +68,7 @@ static function form($object) {
$object->caption = "";
$object->description = "";
$object->default = "";
$object->accept = "";
}
if (empty($object->description)) $object->description = "";
$form->register("identifier",gt('Identifier/Field'),new textcontrol($object->identifier));
Expand Down
33 changes: 22 additions & 11 deletions framework/modules/forms/controllers/formsController.php
Expand Up @@ -123,8 +123,9 @@ public function showall() {
} else {
$control = $fc->find('first', "name='" . $column_name . "' and forms_id=" . $f->id,'rank');
if ($control) {
$ctl = unserialize($control->data);
// $ctl = unserialize($control->data);
$control_type = get_class($ctl);
$ctl = expUnserialize($control->data);
foreach ($items as $key => $item) {
//We have to add special sorting for date time columns!!!
// $item->$column_name = @call_user_func(array($control_type, 'templateFormat'), $item->$column_name, $ctl);
Expand Down Expand Up @@ -188,7 +189,8 @@ public function show() {
$captions = array();
if ($controls && $data) {
foreach ($controls as $c) {
$ctl = unserialize($c->data);
// $ctl = unserialize($c->data);
$ctl = expUnserialize($c->data);
$control_type = get_class($ctl);
$name = $c->name;
$fields[$name] = call_user_func(array($control_type, 'templateFormat'), $data->$name, $ctl);
Expand Down Expand Up @@ -292,7 +294,8 @@ public function enterdata() {
$form->register('email_dest', gt('Send Response to'), new radiogroupcontrol('', $emaillist));
}
foreach ($controls as $c) {
$ctl = unserialize($c->data);
// $ctl = unserialize($c->data);
$ctl = expUnserialize($c->data);
$ctl->_id = $c->id;
$ctl->_readonly = $c->is_readonly;
if (!empty($this->params['id'])) {
Expand Down Expand Up @@ -385,7 +388,8 @@ public function confirm_data() {
$responses = array();

foreach ($cols as $col) {
$coldef = unserialize($col->data);
// $coldef = unserialize($col->data);
$coldef = expUnserialize($col->data);
$coldata = new ReflectionClass($coldef);
$coltype = $coldata->getName();
if ($coltype == 'uploadcontrol') {
Expand Down Expand Up @@ -455,7 +459,8 @@ public function submit_data() {
$captions = array();
$attachments = array();
foreach ($controls as $c) {
$ctl = unserialize($c->data);
// $ctl = unserialize($c->data);
$ctl = expUnserialize($c->data);
$control_type = get_class($ctl);
$def = call_user_func(array($control_type, "getFieldDefinition"));
if ($def != null) {
Expand Down Expand Up @@ -708,7 +713,8 @@ public function edit_form() {
}
$fc = new forms_control();
foreach ($fc->find('all', 'forms_id=' . $f->id . ' and is_readonly=0','rank') as $control) {
$ctl = unserialize($control->data);
// $ctl = unserialize($control->data);
$ctl = expUnserialize($control->data);
$control_type = get_class($ctl);
$def = call_user_func(array($control_type, 'getFieldDefinition'));
if ($def != null) {
Expand Down Expand Up @@ -789,7 +795,8 @@ public function design_form() {

$form = new fakeform();
foreach ($controls as $c) {
$ctl = unserialize($c->data);
// $ctl = unserialize($c->data);
$ctl = expUnserialize($c->data);
$ctl->_id = $c->id;
$ctl->_readonly = $c->is_readonly;
$ctl->_controltype = get_class($ctl);
Expand Down Expand Up @@ -854,7 +861,8 @@ public function edit_control() {
if (isset($this->params['id'])) {
$control = new forms_control($this->params['id']);
if ($control) {
$ctl = unserialize($control->data);
// $ctl = unserialize($control->data);
$ctl = expUnserialize($control->data);
$ctl->identifier = $control->name;
$ctl->caption = $control->caption;
$ctl->id = $control->id;
Expand Down Expand Up @@ -894,7 +902,8 @@ public function save_control() {
if (isset($this->params['id'])) {
$control = new forms_control($this->params['id']);
if ($control) {
$ctl = unserialize($control->data);
// $ctl = unserialize($control->data);
$ctl = expUnserialize($control->data);
$ctl->identifier = $control->name;
$ctl->caption = $control->caption;
}
Expand Down Expand Up @@ -987,7 +996,8 @@ function configure() {
if (isset($this->config['forms_id'])) {
$fc = new forms_control();
foreach ($fc->find('all', 'forms_id=' . $this->config['forms_id'] . ' and is_readonly=0','rank') as $control) {
$ctl = unserialize($control->data);
// $ctl = unserialize($control->data);
$ctl = expUnserialize($control->data);
$control_type = get_class($ctl);
$def = call_user_func(array($control_type, 'getFieldDefinition'));
if ($def != null) {
Expand Down Expand Up @@ -1111,7 +1121,8 @@ public function export_csv() {
} else {
$control = $fc->find('first', "name='" . $column_name . "' and forms_id=" . $this->params['id'],'rank');
if ($control) {
$ctl = unserialize($control->data);
// $ctl = unserialize($control->data);
$ctl = expUnserialize($control->data);
$control_type = get_class($ctl);
// $srt = $column_name . "_srt";
// $datadef = call_user_func(array($control_type, 'getFieldDefinition'));
Expand Down

0 comments on commit 801292f

Please sign in to comment.