Exemplo n.º 1
0
function showUser($id)
{
    $database = JFactory::getDBO();
    /*
      $database->setQuery("SELECT u.id as myid, config_name, us.username, ug.title, u.location, u.jgroup FROM #__joomla_flash_uploader f, #__joomla_flash_uploader_user u left outer join #__users us on u.user=us.id left outer join #__usergroups ug on u.jgroup=ug.id  where  u.profile=f.id ORDER BY u.profile,username,ug.title");	
      $rows = $database->loadObjectList();
      $backendgroups = JFUHelper::getBackendGroups($rows, JFUHelper::getUserGroups()); 
    
     // now we insert an admin profile for all backend groups
      foreach ($backendgroups AS $groups) {
           $rowuser = new joomla_flash_uploader_user($database);
           $rowuser->profile = 1;   
           $rowuser->jgroup  = $groups->value;
           $rowuser->location = 'admin';
           $rowuser->store();
      }
    */
    if (checkAccess($database, 'core.edit.state') && checkAccess($database, 'core.admin')) {
        // all mappings
        $query = "SELECT u.id as myid, concat(config_name, ' (id:', f.id ,')') as config_name, us.username, ug.title, u.location, u.jgroup FROM #__joomla_flash_uploader f, #__joomla_flash_uploader_user u left outer join #__users us on u.user=us.id left outer join #__usergroups ug on u.jgroup=ug.id  where  u.profile=f.id ORDER BY u.location,u.profile,username,ug.title";
        $database->setQuery($query);
        $rows = $database->loadObjectList();
        // check if mappings are still vaild and if not they are removed.
        foreach ($rows as $row) {
            if ($row->username == null && $row->title == null) {
                $database->setQuery("DELETE FROM #__joomla_flash_uploader_user WHERE id IN ({$row->myid})");
                $database->query();
            }
        }
        // reload
        $database->setQuery($query);
        $rows = $database->loadObjectList();
        // now I create the dropdowns for users and for profiles!
        $database->setQuery("SELECT * FROM #__users u order by username");
        $users = $database->loadObjectList();
        $num_users = count($users);
        if ($num_users > 10) {
            $num_users = 10;
        }
        $data['users'] = JHTML::_('select.genericlist', $users, 'user[]', 'size="' . $num_users . '" multiple="multiple" ', 'id', 'username', 0);
        // $database->setQuery("SELECT * FROM #__joomla_flash_uploader WHERE id != 1 AND gid!='' ");
        $database->setQuery("SELECT id, concat(config_name, ' (id:', id ,')') as config_name, gid FROM #__joomla_flash_uploader WHERE id != 1 AND gid!='' ");
        $profiles = $database->loadObjectList();
        $last_profile = 0;
        if (isset($_SESSION['LAST_PROFILE'])) {
            $last_profile = $_SESSION['LAST_PROFILE'];
        }
        if (count($profiles) != 0) {
            $data['profiles'] = JHTML::_('select.genericlist', $profiles, 'profile', 'size="1"', 'id', 'config_name', $last_profile) . '<div style="clear:both"></div><p>' . JText::_('U_AVAILABLE_LIST') . '.</p>';
            $data['profilesgroup'] = JHTML::_('select.genericlist', $profiles, 'profilegroup', 'size="1"', 'id', 'config_name', $last_profile) . '<div style="clear:both"></div><p>' . JText::_('U_AVAILABLE_LIST') . '.</p>';
            $data['showAdd'] = true;
        } else {
            $data['profiles'] = $data['profilesgroup'] = '<div class="message fade">' . JText::_('U_NO_PROFILE') . '.</div>';
            $data['showAdd'] = false;
        }
        $database->setQuery("SELECT id, concat(config_name, ' (id:', id ,')') as config_name, gid FROM #__joomla_flash_uploader");
        $profiles = $database->loadObjectList();
        $data['allprofiles'] = JHTML::_('select.genericlist', $profiles, 'allprofile', 'size="1"', 'id', 'config_name', $last_profile) . '<div style="clear:both"></div><p>' . JText::_('U_AVAILABLE_LIST_ALL_PROFILES') . '.</p>';
        $data['groups'] = JFUHelper::getUserGroups();
        $data['backendgroups'] = JFUHelper::getBackendGroups($rows, $data['groups']);
        $data['showAddAdmin'] = count($data['backendgroups']) > 0;
        HTML_joomla_flash_uploader::listUsers($rows, $data);
    } else {
        HTML_joomla_flash_uploader::errorRights();
    }
}