Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/098.heraldruletypemigration.php
| <?php | <?php | ||||
| echo "Checking for rules that can be converted to 'personal'. "; | echo pht("Checking for rules that can be converted to 'personal'.")."\n"; | ||||
| $table = new HeraldRule(); | $table = new HeraldRule(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| $table->beginReadLocking(); | $table->beginReadLocking(); | ||||
| $rules = $table->loadAll(); | $rules = $table->loadAll(); | ||||
| foreach ($rules as $rule) { | foreach ($rules as $rule) { | ||||
| if ($rule->getRuleType() !== HeraldRuleTypeConfig::RULE_TYPE_PERSONAL) { | if ($rule->getRuleType() !== HeraldRuleTypeConfig::RULE_TYPE_PERSONAL) { | ||||
| Show All 24 Lines | if ($can_be_personal) { | ||||
| $rule->setRuleType(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); | $rule->setRuleType(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL); | ||||
| queryfx( | queryfx( | ||||
| $rule->establishConnection('w'), | $rule->establishConnection('w'), | ||||
| 'UPDATE %T SET ruleType = %s WHERE id = %d', | 'UPDATE %T SET ruleType = %s WHERE id = %d', | ||||
| $rule->getTableName(), | $rule->getTableName(), | ||||
| $rule->getRuleType(), | $rule->getRuleType(), | ||||
| $rule->getID()); | $rule->getID()); | ||||
| echo "Setting rule '".$rule->getName()."' to personal. "; | echo pht("Setting rule '%s' to personal.", $rule->getName())."\n"; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| $table->endReadLocking(); | $table->endReadLocking(); | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||