parent::preProcess();
- // make sure the gid is set and valid
- if (!$this->_gid) {
- CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled, OR there is no Profile with that ID, OR a valid \'gid=\' integer value is missing from the URL. Contact the site administrator if you need assistance.',
- array(1 => $this->_gid)
- ));
- }
-
- // and also the profile is of type 'Profile'
- $query = "
+ // and also the profile is of type 'Profile'
+ $query = "
SELECT module,is_reserved
FROM civicrm_uf_group
LEFT JOIN civicrm_uf_join ON uf_group_id = civicrm_uf_group.id
WHERE civicrm_uf_group.id = %1
";
- $params = array(1 => array($this->_gid, 'Integer'));
- $dao = CRM_Core_DAO::executeQuery($query, $params);
-
- $isProfile = false;
- while ($dao->fetch()) {
- $isProfile = ($isProfile || ($dao->module == "Profile"));
- }
+ $params = array(1 => array($this->_gid, 'Integer'));
+ $dao = CRM_Core_DAO::executeQuery($query, $params);
+ $isProfile = FALSE;
+ while ($dao->fetch()) {
+ $isProfile = ($isProfile || ($dao->module == "Profile"));
+ }
- //Check that the user has the "add contacts" Permission
- $canAdd = CRM_Core_Permission::check("add contacts");
+ //Check that the user has the "add contacts" Permission
+ $canAdd = CRM_Core_Permission::check("add contacts");
- //Remove need for Profile module type when using reserved profiles [CRM-14488]
- if( !$dao->N || (!$isProfile && !($dao->is_reserved && $canAdd))) {
+ //Remove need for Profile module type when using reserved profiles [CRM-14488]
+ if (!$dao->N || (!$isProfile && !($dao->is_reserved && $canAdd))) {
CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is not configured to be used for \'Profile\' edit and view forms in its Settings. Contact the site administrator if you need assistance.',
- array(1 => $this->_gid)
- ));
+ array(1 => $this->_gid)
+ ));
}
}
* @access public
*/
public function buildQuickForm() {
- // add the hidden field to redirect the postProcess from
- $ufGroup = new CRM_Core_DAO_UFGroup();
-
- $ufGroup->id = $this->_gid;
- if (!$ufGroup->find(TRUE)) {
+ if (empty($this->_ufGroup['id'])) {
CRM_Core_Error::fatal();
}
'Edit ' . $this->_customGroupTitle . ' Record' : $this->_customGroupTitle;
} else {
- $groupTitle = $ufGroup->title;
+ $groupTitle = $this->_ufGroup['title'];
}
CRM_Utils_System::setTitle($groupTitle);
$this->assign('recentlyViewed', FALSE);
if ($this->_context != 'dialog') {
- $this->_postURL = CRM_Utils_Array::value('postURL', $_POST);
- $this->_cancelURL = CRM_Utils_Array::value('cancelURL', $_POST);
+ $this->_postURL = $this->_ufGroup['post_URL'];
+ $this->_cancelURL = $this->_ufGroup['cancel_URL'];
$gidString = $this->_gid;
if (!empty($this->_profileIds)) {
$gidString = implode(',', $this->_profileIds);
}
- if (!$this->_postURL) {
- $this->_postURL = $ufGroup->post_URL;
- }
-
if (!$this->_postURL) {
if ($this->_context == 'Search') {
$this->_postURL = CRM_Utils_System::url('civicrm/contact/search');
}
if (!$this->_cancelURL) {
- if ($ufGroup->cancel_URL) {
- $this->_cancelURL = $ufGroup->cancel_URL;
- }
- else {
- $this->_cancelURL = CRM_Utils_System::url('civicrm/profile',
- "reset=1&gid={$gidString}"
- );
- }
+ $this->_cancelURL = CRM_Utils_System::url('civicrm/profile',
+ "reset=1&gid={$gidString}"
+ );
}
// we do this gross hack since qf also does entity replacement
$this->_postURL = str_replace('&', '&', $this->_postURL);
$this->_cancelURL = str_replace('&', '&', $this->_cancelURL);
- $this->addElement('hidden', 'postURL', $this->_postURL);
- if ($this->_cancelURL) {
- $this->addElement('hidden', 'cancelURL', $this->_cancelURL);
- }
-
// also retain error URL if set
$this->_errorURL = CRM_Utils_Array::value('errorURL', $_POST);
if ($this->_errorURL) {
'type' => 'cancel',
'name' => ts('Cancel'),
'isDefault' => TRUE,
+ 'js' => array('onclick' => "location.href='{$this->_cancelURL}'; return false;"),
);
$this->addButtons($buttons);
return;
'type' => 'cancel',
'name' => ts('Cancel'),
'isDefault' => TRUE,
+ 'js' => array('onclick' => "location.href='{$this->_cancelURL}'; return false;"),
);
$this->addButtons($buttons);