2008-09-29 05:18:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Data received from a UserDefinedForm submission
|
2009-04-15 06:23:43 +02:00
|
|
|
*
|
|
|
|
* @package userforms
|
2008-09-29 05:18:23 +02:00
|
|
|
*/
|
2009-12-07 03:04:20 +01:00
|
|
|
|
2008-09-29 05:18:23 +02:00
|
|
|
class SubmittedFormField extends DataObject {
|
|
|
|
|
2013-04-03 03:34:43 +02:00
|
|
|
private static $db = array(
|
2008-09-29 05:18:23 +02:00
|
|
|
"Name" => "Varchar",
|
|
|
|
"Value" => "Text",
|
2009-11-24 21:11:50 +01:00
|
|
|
"Title" => "Varchar(255)"
|
2008-09-29 05:18:23 +02:00
|
|
|
);
|
|
|
|
|
2013-04-03 03:34:43 +02:00
|
|
|
private static $has_one = array(
|
2008-09-29 05:18:23 +02:00
|
|
|
"Parent" => "SubmittedForm"
|
|
|
|
);
|
2013-03-04 22:45:54 +01:00
|
|
|
|
2013-04-03 03:34:43 +02:00
|
|
|
private static $summary_fields = array(
|
2013-09-04 23:46:38 +02:00
|
|
|
'Title' => 'Title',
|
2013-03-04 22:45:54 +01:00
|
|
|
'FormattedValue' => 'Value'
|
|
|
|
);
|
|
|
|
|
2013-05-13 04:32:41 +02:00
|
|
|
/**
|
|
|
|
* @param Member
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function canCreate($member = null) {
|
|
|
|
return $this->Parent()->canCreate();
|
|
|
|
}
|
|
|
|
|
2013-05-01 00:49:57 +02:00
|
|
|
/**
|
|
|
|
* @param Member
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function canView($member = null) {
|
|
|
|
return $this->Parent()->canView();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Member
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function canEdit($member = null) {
|
|
|
|
return $this->Parent()->canEdit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Member
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function canDelete($member = null) {
|
|
|
|
return $this->Parent()->canDelete();
|
|
|
|
}
|
|
|
|
|
2010-05-16 05:55:03 +02:00
|
|
|
/**
|
|
|
|
* Generate a formatted value for the reports and email notifications.
|
|
|
|
* Converts new lines (which are stored in the database text field) as
|
|
|
|
* <brs> so they will output as newlines in the reports
|
|
|
|
*
|
2012-05-07 11:19:16 +02:00
|
|
|
* @return string
|
2010-05-16 05:55:03 +02:00
|
|
|
*/
|
2012-05-04 03:39:08 +02:00
|
|
|
public function getFormattedValue() {
|
2011-12-05 11:19:20 +01:00
|
|
|
return nl2br($this->dbObject('Value')->ATT());
|
2010-05-16 05:55:03 +02:00
|
|
|
}
|
2012-05-07 11:19:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the value of this submitted form field suitable for inclusion
|
|
|
|
* into the CSV
|
|
|
|
*
|
|
|
|
* @return Text
|
|
|
|
*/
|
|
|
|
public function getExportValue() {
|
|
|
|
return $this->Value;
|
|
|
|
}
|
2014-08-11 01:12:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find equivalent editable field for this submission.
|
|
|
|
*
|
|
|
|
* Note the field may have been modified or deleted from the original form
|
|
|
|
* so this may not always return the data you expect. If you need to save
|
|
|
|
* a particular state of editable form field at time of submission, copy
|
|
|
|
* that value to the submission.
|
|
|
|
*
|
|
|
|
* @return EditableFormField
|
|
|
|
*/
|
|
|
|
public function getEditableField() {
|
|
|
|
return $this->Parent()->Parent()->Fields()->filter(array(
|
|
|
|
'Name' => $this->Name
|
|
|
|
))->First();
|
|
|
|
}
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|