diff --git a/oss/joomla/trunk/administrator/components/com_users/config.xml b/oss/joomla/trunk/administrator/components/com_users/config.xml new file mode 100644 index 00000000..09da3b00 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/config.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/components/com_users/controller.php b/oss/joomla/trunk/administrator/components/com_users/controller.php new file mode 100644 index 00000000..8836312b --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/controller.php @@ -0,0 +1,464 @@ +registerTask( 'add' , 'display' ); + $this->registerTask( 'edit' , 'display' ); + $this->registerTask( 'apply', 'save' ); + $this->registerTask( 'flogout', 'logout'); + $this->registerTask( 'unblock', 'block' ); + } + + /** + * Displays a view + */ + function display( ) + { + switch($this->getTask()) + { + case 'add' : + { JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'user' ); + JRequest::setVar( 'edit', false ); + } break; + case 'edit' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'user' ); + JRequest::setVar( 'edit', true ); + } break; + } + + parent::display(); + } + + /** + * Saves the record + */ + function save() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $option = JRequest::getCmd( 'option'); + + // Initialize some variables + $db = & JFactory::getDBO(); + $me = & JFactory::getUser(); + $acl =& JFactory::getACL(); + $MailFrom = $mainframe->getCfg('mailfrom'); + $FromName = $mainframe->getCfg('fromname'); + $SiteName = $mainframe->getCfg('sitename'); + + // Create a new JUser object + $user = new JUser(JRequest::getVar( 'id', 0, 'post', 'int')); + $original_gid = $user->get('gid'); + + $post = JRequest::get('post'); + $post['username'] = JRequest::getVar('username', '', 'post', 'username'); + $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW); + $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW); + + if (!$user->bind($post)) + { + $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message'); + $mainframe->enqueueMessage($user->getError(), 'error'); + //$mainframe->redirect( 'index.php?option=com_users', $user->getError() ); + //return false; + return $this->execute('edit'); + } + + $objectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' ); + $groups = $acl->get_object_groups( $objectID, 'ARO' ); + $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); + + + if ( $user->get('id') == $me->get( 'id' ) && $user->get('block') == 1 ) + { + $msg = JText::_( 'You cannot block Yourself!' ); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('edit'); + } + else if ( ( $this_group == 'super administrator' ) && $user->get('block') == 1 ) { + $msg = JText::_( 'You cannot block a Super Administrator' ); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('edit'); + } + else if ( ( $this_group == 'administrator' ) && ( $me->get( 'gid' ) == 24 ) && $user->get('block') == 1 ) + { + $msg = JText::_( 'WARNBLOCK' ); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('edit'); + } + else if ( ( $this_group == 'super administrator' ) && ( $me->get( 'gid' ) != 25 ) ) + { + $msg = JText::_( 'You cannot edit a super administrator account' ); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('edit'); + } + // Are we dealing with a new user which we need to create? + $isNew = ($user->get('id') < 1); + if (!$isNew) + { + // if group has been changed and where original group was a Super Admin + if ( $user->get('gid') != $original_gid && $original_gid == 25 ) + { + // count number of active super admins + $query = 'SELECT COUNT( id )' + . ' FROM #__users' + . ' WHERE gid = 25' + . ' AND block = 0' + ; + $db->setQuery( $query ); + $count = $db->loadResult(); + + if ( $count <= 1 ) + { + // disallow change if only one Super Admin exists + $this->setRedirect( 'index.php?option=com_users', JText::_('WARN_ONLY_SUPER') ); + return false; + } + } + } + + /* + * Lets save the JUser object + */ + if (!$user->save()) + { + + $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message'); + $mainframe->enqueueMessage($user->getError(), 'error'); + return $this->execute('edit'); + } + + /* + * Time for the email magic so get ready to sprinkle the magic dust... + */ + if ($isNew) + { + $adminEmail = $me->get('email'); + $adminName = $me->get('name'); + + $subject = JText::_('NEW_USER_MESSAGE_SUBJECT'); + $message = sprintf ( JText::_('NEW_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear ); + + if ($MailFrom != '' && $FromName != '') + { + $adminName = $FromName; + $adminEmail = $MailFrom; + } + JUtility::sendMail( $adminEmail, $adminName, $user->get('email'), $subject, $message ); + } + + // If updating self, load the new user object into the session + if ($user->get('id') == $me->get('id')) + { + // Get an ACL object + $acl = &JFactory::getACL(); + + // Get the user group from the ACL + $grp = $acl->getAroGroup($user->get('id')); + + // Mark the user as logged in + $user->set('guest', 0); + $user->set('aid', 1); + + // Fudge Authors, Editors, Publishers and Super Administrators into the special access group + if ($acl->is_group_child_of($grp->name, 'Registered') || + $acl->is_group_child_of($grp->name, 'Public Backend')) { + $user->set('aid', 2); + } + + // Set the usertype based on the ACL group name + $user->set('usertype', $grp->name); + + $session = &JFactory::getSession(); + $session->set('user', $user); + } + + switch ( $this->getTask() ) + { + case 'apply': + $msg = JText::sprintf( 'Successfully Saved changes to User', $user->get('name') ); + $this->setRedirect( 'index.php?option=com_users&view=user&task=edit&cid[]='. $user->get('id'), $msg ); + break; + + case 'save': + default: + $msg = JText::sprintf( 'Successfully Saved User', $user->get('name') ); + $this->setRedirect( 'index.php?option=com_users', $msg ); + break; + } + } + + /** + * Removes the record(s) from the database + */ + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $currentUser =& JFactory::getUser(); + $acl =& JFactory::getACL(); + $cid = JRequest::getVar( 'cid', array(), '', 'array' ); + + JArrayHelper::toInteger( $cid ); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select a User to delete', true ) ); + } + + foreach ($cid as $id) + { + // check for a super admin ... can't delete them + $objectID = $acl->get_object_id( 'users', $id, 'ARO' ); + $groups = $acl->get_object_groups( $objectID, 'ARO' ); + $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); + + $success = false; + if ( $this_group == 'super administrator' ) + { + $msg = JText::_( 'You cannot delete a Super Administrator' ); + } + else if ( $id == $currentUser->get( 'id' ) ) + { + $msg = JText::_( 'You cannot delete Yourself!' ); + } + else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) ) + { + $msg = JText::_( 'WARNDELETE' ); + } + else + { + $user =& JUser::getInstance((int)$id); + $count = 2; + + if ( $user->get( 'gid' ) == 25 ) + { + // count number of active super admins + $query = 'SELECT COUNT( id )' + . ' FROM #__users' + . ' WHERE gid = 25' + . ' AND block = 0' + ; + $db->setQuery( $query ); + $count = $db->loadResult(); + } + + if ( $count <= 1 && $user->get( 'gid' ) == 25 ) + { + // cannot delete Super Admin where it is the only one that exists + $msg = "You cannot delete this Super Administrator as it is the only active Super Administrator for your site"; + } + else + { + // delete user + $user->delete(); + $msg = ''; + + JRequest::setVar( 'task', 'remove' ); + JRequest::setVar( 'cid', $id ); + + // delete user acounts active sessions + $this->logout(); + } + } + } + + $this->setRedirect( 'index.php?option=com_users', $msg); + } + + /** + * Cancels an edit operation + */ + function cancel( ) + { + $this->setRedirect( 'index.php?option=com_users' ); + } + + /** + * Disables the user account + */ + function block( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $acl =& JFactory::getACL(); + $currentUser =& JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(), '', 'array' ); + $block = $this->getTask() == 'block' ? 1 : 0; + + JArrayHelper::toInteger( $cid ); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select a User to '.$this->getTask(), true ) ); + } + foreach ($cid as $id) + { + // check for a super admin ... can't delete them + $objectID = $acl->get_object_id( 'users', $id, 'ARO' ); + $groups = $acl->get_object_groups( $objectID, 'ARO' ); + $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); + + $success = false; + if ( $this_group == 'super administrator' ) + { + $msg = JText::_( 'You cannot block a Super Administrator' ); + } + else if ( $id == $currentUser->get( 'id' ) ) + { + $msg = JText::_( 'You cannot block Yourself!' ); + } + else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) ) + { + $msg = JText::_( 'WARNBLOCK' ); + } + else + { + $user =& JUser::getInstance((int)$id); + $count = 2; + + if ( $user->get( 'gid' ) == 25 ) + { + // count number of active super admins + $query = 'SELECT COUNT( id )' + . ' FROM #__users' + . ' WHERE gid = 25' + . ' AND block = 0' + ; + $db->setQuery( $query ); + $count = $db->loadResult(); + } + + if ( $count <= 1 && $user->get( 'gid' ) == 25 ) + { + // cannot delete Super Admin where it is the only one that exists + $msg = "You cannot block this Super Administrator as it is the only active Super Administrator for your site"; + } + else + { + $user =& JUser::getInstance((int)$id); + $user->block = $block; + $user->save(); + + if($block) + { + JRequest::setVar( 'task', 'block' ); + JRequest::setVar( 'cid', array($id) ); + + // delete user acounts active sessions + $this->logout(); + } + } + } + } + + $this->setRedirect( 'index.php?option=com_users', $msg); + } + + /** + * Force log out a user + */ + function logout( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + global $mainframe; + + $db =& JFactory::getDBO(); + $task = $this->getTask(); + $cids = JRequest::getVar( 'cid', array(), '', 'array' ); + $client = JRequest::getVar( 'client', 0, '', 'int' ); + $id = JRequest::getVar( 'id', 0, '', 'int' ); + + JArrayHelper::toInteger($cids); + + if ( count( $cids ) < 1 ) { + $this->setRedirect( 'index.php?option=com_users', JText::_( 'User Deleted' ) ); + return false; + } + + foreach($cids as $cid) + { + $options = array(); + + if ($task == 'logout' || $task == 'block') { + $options['clientid'][] = 0; //site + $options['clientid'][] = 1; //administrator + } else if ($task == 'flogout') { + $options['clientid'][] = $client; + } + + $mainframe->logout((int)$cid, $options); + } + + + $msg = JText::_( 'User Session Ended' ); + switch ( $task ) + { + case 'flogout': + $this->setRedirect( 'index.php', $msg ); + break; + + case 'remove': + case 'block': + return; + break; + + default: + $this->setRedirect( 'index.php?option=com_users', $msg ); + break; + } + } + + function contact() + { + $contact_id = JRequest::getVar( 'contact_id', '', 'post', 'int' ); + $this->setRedirect( 'index.php?option=com_contact&task=edit&cid[]='. $contact_id ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_users/index.html b/oss/joomla/trunk/administrator/components/com_users/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/models/author.xml b/oss/joomla/trunk/administrator/components/com_users/models/author.xml new file mode 100644 index 00000000..bc901691 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/models/author.xml @@ -0,0 +1,10 @@ + +
+ Author User Type + + + + + + +
diff --git a/oss/joomla/trunk/administrator/components/com_users/models/index.html b/oss/joomla/trunk/administrator/components/com_users/models/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/models/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/models/registered.xml b/oss/joomla/trunk/administrator/components/com_users/models/registered.xml new file mode 100644 index 00000000..684e739f --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/models/registered.xml @@ -0,0 +1,8 @@ + +
+ Registered User Type + + + + +
diff --git a/oss/joomla/trunk/administrator/components/com_users/models/user.xml b/oss/joomla/trunk/administrator/components/com_users/models/user.xml new file mode 100644 index 00000000..4f103fa8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/models/user.xml @@ -0,0 +1,10 @@ + +
+ + + + + + + +
diff --git a/oss/joomla/trunk/administrator/components/com_users/users.class.php b/oss/joomla/trunk/administrator/components/com_users/users.class.php new file mode 100644 index 00000000..1caa821f --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/users.class.php @@ -0,0 +1,30 @@ +authorize( 'com_users', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +// Create the controller +$controller = new UsersController( ); + +// Perform the Request task +$controller->execute( JRequest::getCmd('task')); +$controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/users.xml b/oss/joomla/trunk/administrator/components/com_users/users.xml new file mode 100644 index 00000000..310edb4c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/users.xml @@ -0,0 +1,12 @@ + + + User Manager + Joomla! Project + April 2006 + (C) 2005 - 2008 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + User Manager + diff --git a/oss/joomla/trunk/administrator/components/com_users/views/index.html b/oss/joomla/trunk/administrator/components/com_users/views/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/views/user/index.html b/oss/joomla/trunk/administrator/components/com_users/views/user/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/user/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/views/user/tmpl/form.php b/oss/joomla/trunk/administrator/components/com_users/views/user/tmpl/form.php new file mode 100644 index 00000000..1eb29df5 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/user/tmpl/form.php @@ -0,0 +1,302 @@ + + + + +[ '. $text .' ]' , 'user.png' ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ( $edit ) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.users.edit' ); + $cparams = JComponentHelper::getParams ('com_media'); +?> + +user, ENT_QUOTES, '' ); + + if ($this->user->get('lastvisitDate') == "0000-00-00 00:00:00") { + $lvisit = JText::_( 'Never' ); + } else { + $lvisit = JHTML::_('date', $this->user->get('lastvisitDate'), '%Y-%m-%d %H:%M:%S'); + } +?> + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + me->authorize( 'com_users', 'block user' )) { ?> + + + + + me->authorize( 'com_users', 'email_events' )) { ?> + + + + + user->get('id') ) { ?> + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + user->get('password')) : ?> + + + + +
+ + + user->get('password')) : ?> + + + + +
+ + + lists['gid']; ?> +
+ + + lists['block']; ?> +
+ + + lists['sendEmail']; ?> +
+ + + user->get('registerDate'), '%Y-%m-%d %H:%M:%S');?> +
+ + + +
+
+
+
+
+ + + + + +
+ user->getParameters(true); + echo $params->render( 'params' ); + ?> +
+
+
+ + contact ) { ?> + + + + +
+
+ + : +
+ . +
+

+
+ + + + + + + + + + + + + + + + + + + + + + + contact[0]->image) { ?> + + + + + + + + + +
+ + + + contact[0]->name;?> + +
+ + + + contact[0]->con_position;?> + +
+ + + + contact[0]->telephone;?> + +
+ + + + contact[0]->fax;?> + +
+ + + + contact[0]->misc;?> + +
+ + + <?php echo JText::_( 'Contact' ); ?> +
  +
+
+ + +

+ ' Contact -> Manage Contacts' ); ?>' +
+
+
+ +
+
+
+ + + + + + + me->authorize( 'com_users', 'email_events' )) { ?> + + + +
diff --git a/oss/joomla/trunk/administrator/components/com_users/views/user/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_users/views/user/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/user/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php b/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php new file mode 100644 index 00000000..bddb38ba --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php @@ -0,0 +1,141 @@ +bind($post); + } + + if ( $user->get('id')) + { + $query = 'SELECT *' + . ' FROM #__contact_details' + . ' WHERE user_id = '.(int) $cid[0] + ; + $db->setQuery( $query ); + $contact = $db->loadObjectList(); + } + else + { + $contact = NULL; + // Get the default group id for a new user + $config = &JComponentHelper::getParams( 'com_users' ); + $newGrp = $config->get( 'new_usertype' ); + $user->set( 'gid', $acl->get_group_id( $newGrp, null, 'ARO' ) ); + } + + $userObjectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' ); + $userGroups = $acl->get_object_groups( $userObjectID, 'ARO' ); + $userGroupName = strtolower( $acl->get_group_name( $userGroups[0], 'ARO' ) ); + + $myObjectID = $acl->get_object_id( 'users', $myuser->get('id'), 'ARO' ); + $myGroups = $acl->get_object_groups( $myObjectID, 'ARO' ); + $myGroupName = strtolower( $acl->get_group_name( $myGroups[0], 'ARO' ) );; + + // ensure user can't add/edit group higher than themselves + /* NOTE : This check doesn't work commented out for the time being + if ( is_array( $myGroups ) && count( $myGroups ) > 0 ) + { + $excludeGroups = (array) $acl->get_group_children( $myGroups[0], 'ARO', 'RECURSE' ); + } + else + { + $excludeGroups = array(); + } + + if ( in_array( $userGroups[0], $excludeGroups ) ) + { + echo 'not auth'; + $mainframe->redirect( 'index.php?option=com_users', JText::_('NOT_AUTH') ); + } + */ + + /* + if ( $userGroupName == 'super administrator' ) + { + // super administrators can't change + $lists['gid'] = ''. JText::_( 'Super Administrator' ) .''; + } + else if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) { + */ + + if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) + { + // administrators can't change each other + $lists['gid'] = ''. JText::_( 'Administrator' ) .''; + } + else + { + $gtree = $acl->get_group_children_tree( null, 'USERS', false ); + + // remove users 'above' me + //$i = 0; + //while ($i < count( $gtree )) { + // if ( in_array( $gtree[$i]->value, (array)$excludeGroups ) ) { + // array_splice( $gtree, $i, 1 ); + // } else { + // $i++; + // } + //} + + $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'gid', 'size="10"', 'value', 'text', $user->get('gid') ); + } + + // build the html select list + $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user->get('block') ); + + // build the html select list + $lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail') ); + + $this->assignRef('me', $me); + $this->assignRef('lists', $lists); + $this->assignRef('user', $user); + $this->assignRef('contact', $contact); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_users/views/users/index.html b/oss/joomla/trunk/administrator/components/com_users/views/users/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/users/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php new file mode 100644 index 00000000..5a67726a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php @@ -0,0 +1,138 @@ + + + + + + +
+ + + + + +
+ : + + + + + lists['type'];?> + lists['logged'];?> +
+ + + + + + + + + + + + + + + + + + + + + + + items ); $i < $n; $i++) + { + $row =& $this->items[$i]; + + $img = $row->block ? 'publish_x.png' : 'tick.png'; + $task = $row->block ? 'unblock' : 'block'; + $alt = $row->block ? JText::_( 'Enabled' ) : JText::_( 'Blocked' ); + $link = 'index.php?option=com_users&view=user&task=edit&cid[]='. $row->id. ''; + + if ($row->lastvisitDate == "0000-00-00 00:00:00") { + $lvisit = JText::_( 'Never' ); + } else { + $lvisit = JHTML::_('date', $row->lastvisitDate, '%Y-%m-%d %H:%M:%S'); + } + ?> + "> + + + + + + + + + + + + + +
+ + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> +
+ pagination->getListFooter(); ?> +
+ pagination->limitstart;?> + + id ); ?> + + + name; ?> + + username; ?> + + loggedin ? '': ''; ?> + + + <?php echo $alt; ?> + + groupname ); ?> + + + email; ?> + + + + id; ?> +
+ + + + + + + +
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php b/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php new file mode 100644 index 00000000..182b1cab --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php @@ -0,0 +1,165 @@ +getUserStateFromRequest( "$option.filter_order", 'filter_order', 'a.name', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_type = $mainframe->getUserStateFromRequest( "$option.filter_type", 'filter_type', 0, 'string' ); + $filter_logged = $mainframe->getUserStateFromRequest( "$option.filter_logged", 'filter_logged', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + if (isset( $search ) && $search!= '') + { + $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + $where[] = 'a.username LIKE '.$searchEscaped.' OR a.email LIKE '.$searchEscaped.' OR a.name LIKE '.$searchEscaped; + } + if ( $filter_type ) + { + if ( $filter_type == 'Public Frontend' ) + { + $where[] = ' a.usertype = \'Registered\' OR a.usertype = \'Author\' OR a.usertype = \'Editor\' OR a.usertype = \'Publisher\' '; + } + else if ( $filter_type == 'Public Backend' ) + { + $where[] = 'a.usertype = \'Manager\' OR a.usertype = \'Administrator\' OR a.usertype = \'Super Administrator\' '; + } + else + { + $where[] = 'a.usertype = LOWER( '.$db->Quote($filter_type).' ) '; + } + } + if ( $filter_logged == 1 ) + { + $where[] = 's.userid = a.id'; + } + else if ($filter_logged == 2) + { + $where[] = 's.userid IS NULL'; + } + + // exclude any child group id's for this user + $pgids = $acl->get_group_children( $currentUser->get('gid'), 'ARO', 'RECURSE' ); + + if (is_array( $pgids ) && count( $pgids ) > 0) + { + JArrayHelper::toInteger($pgids); + $where[] = 'a.gid NOT IN (' . implode( ',', $pgids ) . ')'; + } + $filter = ''; + if ($filter_logged == 1 || $filter_logged == 2) + { + $filter = ' INNER JOIN #__session AS s ON s.userid = a.id'; + } + + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir; + $where = ( count( $where ) ? ' WHERE (' . implode( ') AND (', $where ) . ')' : '' ); + + $query = 'SELECT COUNT(a.id)' + . ' FROM #__users AS a' + . $filter + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pagination = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT a.*, g.name AS groupname' + . ' FROM #__users AS a' + . ' INNER JOIN #__core_acl_aro AS aro ON aro.value = a.id' + . ' INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id' + . ' INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id' + . $filter + . $where + . ' GROUP BY a.id' + . $orderby + ; + $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); + $rows = $db->loadObjectList(); + + $n = count( $rows ); + $template = 'SELECT COUNT(s.userid)' + . ' FROM #__session AS s' + . ' WHERE s.userid = %d' + ; + for ($i = 0; $i < $n; $i++) + { + $row = &$rows[$i]; + $query = sprintf( $template, intval( $row->id ) ); + $db->setQuery( $query ); + $row->loggedin = $db->loadResult(); + } + + // get list of Groups for dropdown filter + $query = 'SELECT name AS value, name AS text' + . ' FROM #__core_acl_aro_groups' + . ' WHERE name != "ROOT"' + . ' AND name != "USERS"' + ; + $db->setQuery( $query ); + $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Group' ) .' -' ); + foreach( $db->loadObjectList() as $obj ) + { + $types[] = JHTML::_('select.option', $obj->value, JText::_( $obj->text ) ); + } + $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_type" ); + + // get list of Log Status for dropdown filter + $logged[] = JHTML::_('select.option', 0, '- '. JText::_( 'Select Log Status' ) .' -'); + $logged[] = JHTML::_('select.option', 1, JText::_( 'Logged In' ) ); + $lists['logged'] = JHTML::_('select.genericlist', $logged, 'filter_logged', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_logged" ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + $this->assignRef('user', JFactory::getUser()); + $this->assignRef('lists', $lists); + $this->assignRef('items', $rows); + $this->assignRef('pagination', $pagination); + + parent::display($tpl); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/index.html b/oss/joomla/trunk/administrator/components/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/index.html @@ -0,0 +1 @@ + \ No newline at end of file