Changeset 4873
- Timestamp:
- 09/02/08 22:34:06 (10 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/docs/cookbook/en/record-based-retrieval-security-template.txt
r4871 r4873 7 7 We have a list of accounts, their related sales and all sorts of sensitive information for each account. Each logged in user should be allowed 8 8 to only view the accounts and related information based off their credentials + either the division, district, branch or salesperson they are allowed to view. 9 9 10 So a division manager can view all info for all accounts within his division. A salesperson can only view the accounts they are assign. 10 11 … … 332 333 333 334 <code type="php"> 334 $accounts = Doctrine_Query::create()->from('Account a')->leftJoin('a.Branches b')->where('a.company_name LIKE ?','A%')->execute();335 $accounts = Doctrine_Query::create()->from('Account a')->leftJoin('a.Branches b')->where('a.company_name LIKE ?','A%')->execute(); 335 336 </code> 336 337 … … 339 340 <code> 340 341 SELECT ... FROM accounts a2 LEFT JOIN branches b2 ON a2.branch_id = b2.id LEFT JOIN divisions d2 ON a2.division_id = d2.id LEFT JOIN user_divisions u2 ON d2.id = u2.division_id WHERE a2.company_name LIKE ? AND u2.user_id = ? ORDER BY a2.company_name 341 < code>342 </code> 342 343 343 344 The results you get back will always be restricted to the division you have been assigned. Since in our schema we've defined restrictions on the Branch and Districts as well