Skip to content

Commit

Permalink
*6017* Fixed user interests from disappearing when form doesn't validate
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrider committed Oct 5, 2010
1 parent 0db0d21 commit ae61b09
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
32 changes: 16 additions & 16 deletions classes/manager/form/UserManagementForm.inc.php
Expand Up @@ -157,7 +157,7 @@ function initData(&$args, &$request) {
'country' => $user->getCountry(),
'biography' => $user->getBiography(null), // Localized
'existingInterests' => $existingInterests,
'currentInterests' => $currentInterests,
'interestsKeywords' => $currentInterests,
'gossip' => $user->getGossip(null), // Localized
'userLocales' => $user->getLocales()
);
Expand Down Expand Up @@ -331,21 +331,6 @@ function execute(&$args, &$request) {
}
}

// Add reviewing interests to interests table
$interestDao =& DAORegistry::getDAO('InterestDAO');
$interests = Request::getUserVar('interestsKeywords');
$interestTextOnly = Request::getUserVar('interests');
if(!empty($interestsTextOnly)) {
// If JS is disabled, this will be the input to read
$interestsTextOnly = explode(",", $interestTextOnly);
} else $interestsTextOnly = null;
if ($interestsTextOnly && !isset($interests)) {
$interests = $interestsTextOnly;
} elseif (isset($interests) && !is_array($interests)) {
$interests = array($interests);
}
$interestDao->insertInterests($interests, $user->getId(), true);

if ($sendNotify) {
// Send welcome email to user
import('classes.mail.MailTemplate');
Expand All @@ -356,6 +341,21 @@ function execute(&$args, &$request) {
$mail->send();
}
}

// Add reviewing interests to interests table
$interestDao =& DAORegistry::getDAO('InterestDAO');
$interests = Request::getUserVar('interestsKeywords');
$interestTextOnly = Request::getUserVar('interests');
if(!empty($interestsTextOnly)) {
// If JS is disabled, this will be the input to read
$interestsTextOnly = explode(",", $interestTextOnly);
} else $interestsTextOnly = null;
if ($interestsTextOnly && !isset($interests)) {
$interests = $interestsTextOnly;
} elseif (isset($interests) && !is_array($interests)) {
$interests = array($interests);
}
$interestDao->insertInterests($interests, $userId, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion classes/user/form/ProfileForm.inc.php
Expand Up @@ -193,7 +193,7 @@ function initData(&$args, &$request) {
'biography' => $user->getBiography(null), // Localized
'userLocales' => $user->getLocales(),
'existingInterests' => $existingInterests,
'currentInterests' => $currentInterests
'interestsKeywords' => $currentInterests
);
}

Expand Down
4 changes: 2 additions & 2 deletions templates/manager/people/userProfileForm.tpl
Expand Up @@ -20,7 +20,7 @@
$("#interestsTextOnly").hide();
$("#interests").tagit({
{/literal}{if $existingInterests}{literal} availableTags: [{/literal}{foreach name=existingInterests from=$existingInterests item=interest}"{$interest|escape|escape:"javascript"}"{if !$smarty.foreach.existingInterests.last}, {/if}{/foreach}{literal}],{/literal}{/if}
{if $currentInterests}{literal}currentTags: [{/literal}{foreach name=currentInterests from=$currentInterests item=interest}"{$interest|escape|escape:"javascript"}"{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}{literal}]{/literal}
{if $interestsKeywords}{literal}currentTags: [{/literal}{foreach name=currentInterests from=$interestsKeywords item=interest}"{$interest|escape|escape:"javascript"}"{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}{literal}]{/literal}
{else}{literal}currentTags: []{/literal}{/if}{literal}
});
});
Expand Down Expand Up @@ -230,7 +230,7 @@
<td class="label">{fieldLabel key="user.interests"}</td>
<td class="value"><ul id="interests"></ul><br />
<textarea name="interests" id="interestsTextOnly" rows="5" cols="40" class="textArea">
{foreach name=currentInterests from=$currentInterests item=interest}{$interest|urldecode}{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}
{foreach name=currentInterests from=$interestsKeywords item=interest}{$interest|urldecode}{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}
</textarea>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion templates/seriesEditor/createReviewerForm.tpl
Expand Up @@ -110,7 +110,7 @@
{/fbvFormSection}
{fbvFormSection title="user.interests" for="interests"}
+ <ul id="interests"></ul><br /><textarea name="interests" id="interestsTextOnly" rows="5" cols="40" class="textArea"></textarea>
<ul id="interests"></ul><br /><textarea name="interests" id="interestsTextOnly" rows="5" cols="40" class="textArea">{foreach name=currentInterests from=$interestsKeywords item=interest}{$interest|urldecode}{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}</textarea>
{/fbvFormSection}
{fbvFormSection title="common.country" for="country"}
Expand Down
4 changes: 2 additions & 2 deletions templates/user/profile.tpl
Expand Up @@ -21,7 +21,7 @@
$("#interestsTextOnly").hide();
$("#interests").tagit({
{/literal}{if $existingInterests}{literal} availableTags: [{/literal}{foreach name=existingInterests from=$existingInterests item=interest}"{$interest|escape|escape:"javascript"}"{if !$smarty.foreach.existingInterests.last}, {/if}{/foreach}{literal}],{/literal}{/if}
{if $currentInterests}{literal}currentTags: [{/literal}{foreach name=currentInterests from=$currentInterests item=interest}"{$interest|escape|escape:"javascript"}"{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}{literal}]{/literal}
{if $interestsKeywords}{literal}currentTags: [{/literal}{foreach name=currentInterests from=$interestsKeywords item=interest}"{$interest|escape|escape:"javascript"}"{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}{literal}]{/literal}
{else}{literal}currentTags: []{/literal}{/if}{literal}
});
});
Expand Down Expand Up @@ -141,7 +141,7 @@
<td class="label">{fieldLabel key="user.interests"}</td>
<td class="value"><ul id="interests"></ul><br />
<textarea name="interests" id="interestsTextOnly" rows="5" cols="40" class="textArea">
{foreach name=currentInterests from=$currentInterests item=interest}{$interest|urldecode}{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}
{foreach name=currentInterests from=$interestsKeywords item=interest}{$interest|urldecode}{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}
</textarea>
</td>
</tr>
Expand Down
5 changes: 3 additions & 2 deletions templates/user/register.tpl
Expand Up @@ -19,7 +19,8 @@
$("#interestsTextOnly").hide();
$("#interests").tagit({
{/literal}{if $existingInterests}{literal} availableTags: [{/literal}{foreach name=existingInterests from=$existingInterests item=interest}"{$interest|escape:"javascript"}"{if !$smarty.foreach.existingInterests.last}, {/if}{/foreach}{literal}],{/literal}{/if}
{literal}currentTags: []
{if $interestsKeywords}{literal}currentTags: [{/literal}{foreach name=currentInterests from=$interestsKeywords item=interest}"{$interest|escape|escape:"javascript"}"{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}{literal}]{/literal}
{else}{literal}currentTags: []{/literal}{/if}{literal}
});
});
</script>
Expand Down Expand Up @@ -184,7 +185,7 @@
<div id="reviewerInterestsContainer" style="margin-left:40px;">
<label class="desc">{translate key="user.register.reviewerInterests"}</label>
<ul id="interests"></ul>
<textarea name="interests" id="interestsTextOnly" rows="5" cols="40" class="textArea"></textarea>
<textarea name="interests" id="interestsTextOnly" rows="5" cols="40" class="textArea">{foreach name=currentInterests from=$interestsKeywords item=interest}{$interest|urldecode}{if !$smarty.foreach.currentInterests.last}, {/if}{/foreach}</textarea>
</div>
<br />
{/if}
Expand Down

0 comments on commit ae61b09

Please sign in to comment.