Render first rule criteria form and require at least one valid rule set to add or edit a badge
This commit is contained in:
parent
9d0e1c90a3
commit
154a5b6452
@ -122,7 +122,9 @@ class BadgesController extends DashboardController {
|
||||
$this->Form->SetModel($this->BadgeModel);
|
||||
|
||||
// Only allow editing if some rules exist
|
||||
|
||||
if(!$this->GetRules()) {
|
||||
throw ForbiddenException('add or edit badges without rules');
|
||||
}
|
||||
|
||||
$Edit = FALSE;
|
||||
if($BadgeID) {
|
||||
|
@ -11,7 +11,8 @@ interface YagaRule {
|
||||
* This performs the grunt work of an award rule. Given an expected criteria,
|
||||
* it determines if a specific user meets muster.
|
||||
*
|
||||
* @param Mixed $Criteria
|
||||
* @param string $Criteria This is a serialized array with key value pairs
|
||||
* that match the criteria that were previously rendered
|
||||
* @param int $UserID
|
||||
* @return bool True if the user meets the criteria, false otherwise
|
||||
*/
|
||||
|
@ -1,12 +1,17 @@
|
||||
<?php if(!defined('APPLICATION')) exit();
|
||||
/* Copyright 2013 Zachary Doll */
|
||||
|
||||
// Gnab the rules so we can render the first criteria form by default
|
||||
$Rules = $this->GetRules();
|
||||
|
||||
if(property_exists($this, 'Badge')) {
|
||||
echo Wrap(T('Edit Badge'), 'h1');
|
||||
$RuleClass = $this->Badge->RuleClass;
|
||||
}
|
||||
else {
|
||||
echo Wrap(T('Add Badge'), 'h1');
|
||||
$RuleClass = '';
|
||||
reset($Rules);
|
||||
$RuleClass = key($array);
|
||||
}
|
||||
|
||||
echo $this->Form->Open(array('enctype' => 'multipart/form-data', 'class' => 'Badge'));
|
||||
@ -41,12 +46,11 @@ echo $this->Form->Errors();
|
||||
<li>
|
||||
<?php
|
||||
echo $this->Form->Label('Rule', 'RuleClass');
|
||||
echo $this->Form->Dropdown('RuleClass', $this->GetRules());
|
||||
echo $this->Form->Dropdown('RuleClass', $Rules);
|
||||
?>
|
||||
</li>
|
||||
<li id="Rule-Criteria">
|
||||
<?php
|
||||
if($RuleClass) {
|
||||
// Save the Prefix for later
|
||||
$Prefix = $this->Form->InputPrefix;
|
||||
$this->Form->InputPrefix = $Prefix . '_Rules';
|
||||
@ -54,10 +58,6 @@ echo $this->Form->Errors();
|
||||
$Rule->RenderCriteriaInterface($this->Form);
|
||||
// Restore the prefix
|
||||
$this->Form->InputPrefix = $Prefix;
|
||||
}
|
||||
else {
|
||||
echo 'No rule criteria needed.';
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
<li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user