--- FreeBSD/tinderbox/webui/module/moduleUsers.php 2007/11/02 20:55:00 1.1 +++ FreeBSD/tinderbox/webui/module/moduleUsers.php 2007/11/15 15:31:35 1.1.1.1.2.2 @@ -24,26 +24,23 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # +# $Paefchen: FreeBSD/tinderbox/webui/module/moduleUsers.php,v 1.1.1.1.2.1 2007/11/13 07:36:19 as Exp $ # $MCom: portstools/tinderbox/webui/module/moduleUsers.php,v 1.18 2007/10/13 02:28:48 ade Exp $ # -require_once 'module/module.php'; -require_once 'module/moduleBuilds.php'; +class moduleUsers extends moduleSession { -class moduleUsers extends module { + private $permissions = null; + private $moduleBuilds = null; - var $permissions; - - function moduleUsers() { - $this->module(); - $this->moduleBuilds = new moduleBuilds(); + public function __construct() { + parent::__construct(); + $this->moduleBuilds = new moduleBuilds; } - function display_login() { - global $moduleSession; - + public function display_login() { if( $this->is_logged_in() ) { - $user = $moduleSession->getAttribute( 'user' ); + $user = $this->getAttribute( 'user' ); $this->template_assign( 'user_name', $user->getName() ); $this->template_assign( 'user_id', $user->getId() ); if( $this->checkWwwAdmin() ) { @@ -59,7 +56,7 @@ class moduleUsers extends module { return $this->template_parse( 'display_login.tpl' ); } - function display_add_user( $user_name, $user_email, $user_password, $www_enabled ) { + public function display_add_user( $user_name, $user_email, $user_password, $www_enabled ) { if( !$this->is_logged_in() ) { return $this->template_parse( 'please_login.tpl' ); } elseif ( $this->checkWwwAdmin() ) { @@ -75,7 +72,7 @@ class moduleUsers extends module { return $this->template_parse( 'user_admin.tpl' ); } - function display_modify_user( $first, $user_id, $user_name, $user_email, $user_password, $www_enabled ) { + public function display_modify_user( $first, $user_id, $user_name, $user_email, $user_password, $www_enabled ) { if( !$this->is_logged_in() ) { return $this->template_parse( 'please_login.tpl' ); } @@ -101,7 +98,7 @@ class moduleUsers extends module { return $this->template_parse( 'user_admin.tpl' ); } - function display_properties( $user_id, $user_name, $user_email, $user_password, $www_enabled ) { + public function display_properties( $user_id, $user_name, $user_email, $user_password, $www_enabled ) { $this->template_assign( 'user_id', $user_id ); $this->template_assign( 'user_name', $user_name ); $this->template_assign( 'user_email', $user_email ); @@ -111,7 +108,7 @@ class moduleUsers extends module { return $this->template_parse( 'user_properties.tpl' ); } - function action_user( $action, $user_id, $user_name, $user_email, $user_password, $www_enabled ) { + public function action_user( $action, $user_id, $user_name, $user_email, $user_password, $www_enabled ) { if( !$this->is_logged_in() ) { return $this->template_parse( 'please_login.tpl' ); } elseif( empty( $user_name ) ) { @@ -207,13 +204,11 @@ class moduleUsers extends module { return '1'; } - function do_login( $username, $password ) { - global $moduleSession; - + public function do_login( $username, $password ) { $user = $this->TinderboxDS->getUserByLogin( $username, $password ); if( $user ) { if( $user->getWwwEnabled() ) { - $moduleSession->setAttribute( 'user', $user ); + $this->setAttribute( 'user', $user ); return true; } else { $this->TinderboxDS->addError( user_login_not_enabled ); @@ -225,29 +220,24 @@ class moduleUsers extends module { return false; } - function do_logout() { - global $moduleSession; + public function do_logout() { + $this->removeAttribute( 'user' ); + $this->destroy(); - $moduleSession->removeAttribute( 'user' ); - $moduleSession->destroy(); - return true; } - function is_logged_in() { - global $moduleSession; + public function is_logged_in() { + $user = $this->getAttribute( 'user' ); - $user = $moduleSession->getAttribute( 'user' ); - if( is_object( $user ) && $user->getWwwEnabled() == 1 ) { return true; } return false; } - function get_www_enabled() { - global $moduleSession; - $user = $moduleSession->getAttribute( 'user' ); + public function get_www_enabled() { + $user = $this->getAttribute( 'user' ); $userobj = $this->TinderboxDS->getUserById( $user->getId() ); if( is_object( $userobj ) ) { @@ -257,14 +247,13 @@ class moduleUsers extends module { return false; } - function get_id() { - global $moduleSession; - $user = $moduleSession->getAttribute( 'user' ); + public function get_id() { + $user = $this->getAttribute( 'user' ); return $user->getId(); } - function get_all_users() { + public function get_all_users() { $all_users_raw = $this->TinderboxDS->getAllUsers(); $all_users = array(); foreach( $all_users_raw as $user ) { @@ -273,11 +262,10 @@ class moduleUsers extends module { return $all_users; } - function fetch_permissions( $object_type, $object_id ) { - global $moduleSession; + public function fetch_permissions( $object_type, $object_id ) { if( $this->is_logged_in() ) { - $user = $moduleSession->getAttribute( 'user' ); + $user = $this->getAttribute( 'user' ); foreach( $this->TinderboxDS->getUserPermissions( $user->getId(), $object_type, $object_id ) as $perm ) { $this->permissions[$object_type][$object_id][$perm['user_permission']] = 1; } @@ -288,7 +276,7 @@ class moduleUsers extends module { } } - function get_permission( $object_type, $object_id, $permission ) { + public function get_permission( $object_type, $object_id, $permission ) { if( !is_array( $this->permissions[$object_type][$object_id] ) && !isset( $this->permissions[$object_type][$object_id]['set'] ) ) { $this->fetch_permissions( $object_type, $object_id ); } @@ -299,11 +287,12 @@ class moduleUsers extends module { } } - function checkWwwAdmin() { + public function checkWwwAdmin() { return $this->get_permission( 'users', $this->get_id(), 'IS_WWW_ADMIN' ); } } +/* old? function checkPermAddQueue( $object_type, $object_id ) { return $this->get_permission( $object_type, $object_id, 'PERM_ADD_QUEUE' ); } @@ -329,5 +318,6 @@ class moduleUsers extends module { { return $this->get_permission( $object_type, $object_id, 'PERM_DELETE_OTHER_QUEUE' ); } +*/ ?>