[#29] Prevent source profile be overwritten
This commit is contained in:
parent
7450704d63
commit
6971058ca0
2 changed files with 3 additions and 6 deletions
|
@ -171,16 +171,13 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
CRM_Utils_System::setTitle(E::ts('Edit Twingle API profile <em>%1</em>', array(1 => $this->profile->getName())));
|
CRM_Utils_System::setTitle(E::ts('Edit Twingle API profile <em>%1</em>', array(1 => $this->profile->getName())));
|
||||||
break;
|
break;
|
||||||
case 'copy':
|
case 'copy':
|
||||||
// This will be a 'create' actually.
|
|
||||||
$this->_op = 'create';
|
|
||||||
|
|
||||||
// Retrieve the source profile name.
|
// Retrieve the source profile name.
|
||||||
$profile_name = CRM_Utils_Request::retrieve('source_name', 'String', $this);
|
$profile_name = CRM_Utils_Request::retrieve('source_name', 'String', $this);
|
||||||
// When copying without a valid profile name, copy the default profile.
|
// When copying without a valid profile name, copy the default profile.
|
||||||
if (!$profile_name) {
|
if (!$profile_name) {
|
||||||
$profile_name = 'default';
|
$profile_name = 'default';
|
||||||
}
|
}
|
||||||
$this->profile = CRM_Twingle_Profile::getProfile($profile_name);
|
$this->profile = clone CRM_Twingle_Profile::getProfile($profile_name);
|
||||||
|
|
||||||
// Propose a new name for this profile.
|
// Propose a new name for this profile.
|
||||||
$profile_name = $profile_name . '_copy';
|
$profile_name = $profile_name . '_copy';
|
||||||
|
@ -528,7 +525,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
*/
|
*/
|
||||||
public function setDefaultValues() {
|
public function setDefaultValues() {
|
||||||
$defaults = parent::setDefaultValues();
|
$defaults = parent::setDefaultValues();
|
||||||
if (in_array($this->_op, array('create', 'edit'))) {
|
if (in_array($this->_op, array('create', 'edit', 'copy'))) {
|
||||||
$defaults['name'] = $this->profile->getName();
|
$defaults['name'] = $this->profile->getName();
|
||||||
$profile_data = $this->profile->getData();
|
$profile_data = $this->profile->getData();
|
||||||
foreach ($profile_data as $element_name => $value) {
|
foreach ($profile_data as $element_name => $value) {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<div class="crm-block crm-form-block">
|
<div class="crm-block crm-form-block">
|
||||||
|
|
||||||
{if $op == 'create' or $op == 'edit'}
|
{if $op == 'create' or $op == 'edit' or $op == 'copy'}
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue