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