*/
/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
+ * Class CRM_Report_Form_Instance
*/
class CRM_Report_Form_Instance {
/**
+ * Build form.
+ *
* @param CRM_Core_Form $form
*/
public static function buildForm(&$form) {
- // we should not build form elements in dashlet mode
+ // We should not build form elements in dashlet mode.
if ($form->_section) {
return;
}
- // check role based permission
+ // Check role based permission.
$instanceID = $form->getVar('_id');
if ($instanceID && !CRM_Report_Utils_Report::isInstanceGroupRoleAllowed($instanceID)) {
$url = CRM_Utils_System::url('civicrm/report/list', 'reset=1');
}
/**
- * @param $fields
- * @param $errors
- * @param $self
+ * Add form rules.
+ *
+ * @param array $fields
+ * @param array $errors
+ * @param CRM_Report_Form_Instance $self
*
* @return array|bool
*/
public static function formRule($fields, $errors, $self) {
- // Validate both the "next" and "save" buttons for creating/updating a report
+ // Validate both the "next" and "save" buttons for creating/updating a report.
$nextButton = $self->controller->getButtonName();
$saveButton = str_replace('_next', '_save', $nextButton);
$clickedButton = $self->getVar('_instanceButtonName');
}
/**
+ * Set default values.
+ *
* @param CRM_Core_Form $form
- * @param $defaults
+ * @param array $defaults
*/
public static function setDefaultValues(&$form, &$defaults) {
- // we should not build form elements in dashlet mode
+ // we should not build form elements in dashlet mode.
if ($form->_section) {
return;
}
if (!empty($defaults['grouprole'])) {
foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['grouprole']) as $value) {
- $grouproles[] = $value;
+ $groupRoles[] = $value;
}
- $defaults['grouprole'] = $grouproles;
+ $defaults['grouprole'] = $groupRoles;
}
}
elseif (property_exists($form, '_description')) {
}
/**
+ * Post process function.
+ *
* @param CRM_Core_Form $form
* @param bool $redirect
*/
// set the report_id since base template is going to be same, and we going to unset $instanceID
// which will make it difficult later on, to compute report_id
$params['report_id'] = CRM_Report_Utils_Report::getValueFromUrl($instanceID);
- $instanceID = NULL; //unset $instanceID so a new copy would be created
+ // Unset $instanceID so a new copy would be created.
+ $instanceID = NULL;
}
$params['instance_id'] = $instanceID;
if (!empty($params['is_navigation'])) {
$params['navigation'] = $form->_navigation;
}
elseif ($instanceID) {
- //delete navigation if exists
+ // Delete navigation if exists.
$navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceID, 'navigation_id', 'id');
if ($navId) {
CRM_Core_BAO_Navigation::processDelete($navId);