からからCreateQueryで働いていない:解決 - いいえ、再現もうsfContextのは::のgetInstance() - > getUserメソッド()今、バリ
いくつかの特定のアプリケーションのセキュリティのために、私は、テーブルの上に次からCreateQuery機能を持っていることができます。すなわち「管理者」資格情報を持っている場合、またはMembershipDelegate関係に格納されているユーザーの場合にのみ、テーブルレコードにアクセスします。
class OrganisationTable extends Doctrine_Table
function createQuery($alias = ''){
if (!$alias){
$alias = 'o';
}
$query = parent::createQuery($alias);
try {
$user = sfContext::getInstance()->getUser();
}catch(Exception $e){
if ($e->getMessage() == 'The "default" context does not exist.'){
return $query;
}else{
throw $e;
}
}
if ($user->hasCredential('Administrator')){
//all good
}else{
$userId = $user->getAttribute('userId');
print "<!--testaa ".print_r($user->getCredentials(),1).'-->';
$query->
leftJoin("$alias.MembershipDelegate mdelsec")->
addWhere ("mdelsec.joomla_user_id=$userId");
}
return $query;
}
これは、すべてのレベルで正常に動作するようですが、しかし、$ユーザーオブジェクトが空
/**
* Person form base class.
*
*/
...
abstract class BasePersonForm extends BaseFormDoctrine
{
public function setup()
{
$this->setWidgets(array(
...
'organisation_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Organisation'), 'add_empty' => true)),
class PersonForm extends BasePersonForm{
public function configure(){
$this->widgetSchema['organisation_id']->setOption('renderer_class', 'sfWidgetFormDoctrineJQueryAutocompleter');
$this->widgetSchema['organisation_id']->setOption('renderer_options', array(
'model' => 'Organisation',
'url' => NZGBCTools::makeUriJoomlaCompatible(
sfContext::getInstance()->getController()->genUrl('organisation/jsonList'))
));
$this->validatorSchema['organisation_id']->setOption('required',false);
を戻ってくるように思われる選択肢のバリデータは、ユーザーオブジェクトを取得する他の方法は、そこにあるさモデルで?レベルのセキュリティを行に
このアプローチは、MVCことによって、ブックが、アクションで同じセキュリティの概念を実装するよりもIMO安全で優れていないことがあります。
- それは外で使用することができますボックス管理者・ジェネレータ・モジュール
- 私が気づいていないんだ
私の質問は、なぜそれがほとんどのアクションで動作するのですが、バリデータではないと思いますか? – jdog