Hi all.
I know it might seam slightly strange to user the admin generator.yml in the frontend but every page is either a list or an edit page and it's definitely the easiest things to do.
After struggling with writing a log in module i have installed sfDoctrineGuardPlugin and used the relations to link them to my main user table. Everything in the database relies on this one table, and the data has been building up on the current live site for little over 8 months now and i need to keep it.
My current problem is that once someone logs in and it stores there ID in the guard system, i need all the pages to filter all results by it, including lists, and edits.
Is there a simple method of doing this or do i need to use the table_method for every list?
The only problem with the above is that the ID appears in the address and i need it to make sure people can not view data that that shouldn't.
Also, and this is likely to change soon, at the moment the tables are MyISAM for the use of better auto increment, can have it increment by user so each person starts at one. However it appears to not do foreign keys so when i write the code to convert it to INNOBDB the ID in the address becomes inven more important for people not to be able to change.
Owner:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
slname: { type: string(64), notnull: true }
uuid: { type: string(36), notnull: true }
e_mail: { type: string(64) }
user: { type: string(16) }
pass: { type: string(40), notnull: true }
subscription: { type: integer(4), default: '0', notnull: true }
registered: { type: integer(1), default: '0', notnull: true }
relations:
Subscription: { local: subscription, foreign: id }
User: { class: sfGuardUser, foreign: id, local: id, type: one, onDelete: cascade, foreignType: one, foreignAlias: Owner }
Once the plug in works properly i am planning on removing the password from the above table and using the default one and forcing everyone to make new passes.
EDIT:
Thank Ben i have the template working i think. It's adding in the column anyway to the database.
class Doctrine_Template_Owned extends Doctrine_Template
{
protected $_options = array(
'name' => 'owner_id',
'type' => 'integer',
'length' => 11,
'options' => array(
'default' => 0,
'notnull' => true
)
);
public function setTableDefinition()
{
$this->hasColumn($this->_options['name'], $this->_options['type'], $this->_options['length'], $this->_options['options']);
$this->addListener(new Doctrine_Template_Listener_Owned($this->_options));
}
}
However the listener doesn't seam to be getting called.
class Doctrine_Template_Listener_Owned extends Doctrine_Record_Listener
{
protected $_options = array();
public function __construct(array $options)
{
$this->_options = $options;
}
public function preDqlSelect(Doctrine_Event $event)
{
$params = $event->getParams();
$field = $params['alias'] . '.' . $this->_options['name'];
$query = $event->getQuery();
if (( ! $query->isSubquery() || ($query->isSubquery() && $query->contains(' ' . $params['alias'] . ' '))) && ! $query->contains($field)) {
$query->addPendingJoinCondition(
$params['alias'], $field . ' = ' . sfContext::getInstance()->getUser()->getGuardUser()->getId()
);
}
}
}
The code for the listener is that of soft delete with the timetable and boolean check removed. The line doesn't seam to appear in the dev bar though.