1: <?php
2: /**
3: *
4: * @package Legacy
5: * @version $Id: Legacy_Identity.class.php,v 1.3 2008/09/25 15:12:02 kilica Exp $
6: * @copyright Copyright 2005-2007 XOOPS Cube Project <https://github.com/xoopscube/legacy>
7: * @license https://github.com/xoopscube/legacy/blob/master/docs/GPL_V2.txt GNU GENERAL PUBLIC LICENSE Version 2
8: *
9: */
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: class Legacy_Identity extends XCube_Identity
14: {
15: function Legacy_Identity(&$xoopsUser)
16: {
17: parent::XCube_Identity();
18:
19: if (!is_object($xoopsUser)) {
20: die('Exception');
21: }
22:
23: $this->mName = $xoopsUser->get('uname');
24: }
25:
26: function isAuthenticated()
27: {
28: return true;
29: }
30: }
31:
32: class Legacy_AnonymousIdentity extends XCube_Identity
33: {
34: function isAuthenticated()
35: {
36: return false;
37: }
38: }
39:
40: /**
41: * This principal is free to add roles. And, this is also an interface, because
42: * addRole() is used as a common interface in Legacy. Therefore, the dev team
43: * may add the interface class to this file.
44: *
45: * [Role Naming Convention]
46: * Module.{dirname}.Visitor is 'module_read'.
47: * Module.{dirname}.Admin is 'module_admin'.
48: */
49: class Legacy_GenericPrincipal extends XCube_Principal
50: {
51: /**
52: * Adds a role to this object.
53: * @param $roleName string
54: */
55: function addRole($roleName)
56: {
57: if (!$this->isInRole($roleName)) {
58: $this->_mRoles[] = $roleName;
59: }
60: }
61:
62: function isInRole($roleName)
63: {
64: return in_array($roleName, $this->_mRoles);
65: }
66: }
67:
68: ?>
69: