Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set default settings when retrieving openpne_member_config (fixes #4034) #382

Open
wants to merge 3 commits into
base: old-master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions lib/form/doctrine/MemberConfigForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,34 @@ public function setMemberConfigSettings()
$categories = sfConfig::get('openpne_member_category');
$configs = sfConfig::get('openpne_member_config');

if (!$this->category) {
if (!$this->category)
{
$this->memberConfigSettings = $configs;
return true;
}
else
{
foreach ($categories[$this->category] as $value)
{
$this->memberConfigSettings[$value] = $configs[$value];
}
}

foreach ($categories[$this->category] as $value)
foreach ($this->memberConfigSettings as $configName => $configSettings)
{
$this->memberConfigSettings[$value] = $configs[$value];
if (null === $configSettings)
{
continue;
}

// Set default values if key not in array
$this->memberConfigSettings[$configName] = $configSettings + array(
'IsRegist' => false,
'IsConfig' => false,
'IsRequired' => false,
'IsUnique' => false,
'IsConfirm' => false,
'Info' => '',
);
}
}

Expand All @@ -117,7 +137,7 @@ public function setMemberConfigWidget($name)
}
$this->validatorSchema[$name] = opFormItemGenerator::generateValidator($config);

if (!empty($config['IsUnique']))
if ($config['IsUnique'])
{
$uniqueValidator = new sfValidatorCallback(array(
'callback' => array($this, 'isUnique'),
Expand All @@ -135,7 +155,7 @@ public function setMemberConfigWidget($name)
));
}

if (!empty($config['IsConfirm']))
if ($config['IsConfirm'])
{
$this->validatorSchema[$name.'_confirm'] = $this->validatorSchema[$name];
$this->widgetSchema[$name.'_confirm'] = $this->widgetSchema[$name];
Expand All @@ -151,7 +171,7 @@ public function setMemberConfigWidget($name)
)));
}

if (!empty($config['Info']))
if ($config['Info'])
{
$this->widgetSchema->setHelp($name, $config['Info']);
}
Expand Down Expand Up @@ -243,7 +263,7 @@ public function isValid()

foreach ($this->getValues() as $key => $value)
{
if (!empty($this->memberConfigSettings[$key]['IsUnique']))
if ($this->memberConfigSettings[$key]['IsUnique'])
{
$memberConfig = Doctrine::getTable('MemberConfig')->retrieveByNameAndValue($key.'_pre', $value);
if ($memberConfig)
Expand Down