function getAvailableGroups($id) { // get the group of this profile $db = JFactory::getDBO(); $query = 'select gid from #__joomla_flash_uploader where id=' . $id; $db->setQuery($query); $options = $db->loadObjectList(); $group_id = $options[0]->gid; // select the joomla groups that are assigned to a different jfu group $db->setQuery('select jgroup from #__joomla_flash_uploader_user where location=\'site\' and profile in (SELECT id FROM #__joomla_flash_uploader where id <> ' . $id . ' and jgroup IS NOT NULL and gid = \'' . $group_id . '\')'); $jgroups = $db->loadObjectList(); if (count($jgroups) > 0) { $assigned_groups = array(); foreach ($jgroups as $jg) { $assigned_groups[] = $jg->jgroup; } $filter = "a.id NOT in (" . implode(",", $assigned_groups) . ")"; } else { $filter = ' 1=1 '; } $av_groups = JFUHelper::getUserGroups($filter); // echo '<br>'print_r(mixed expression, [bool return])print_r($av_groups); // select the ones which are assigned to this jfu group to mark them $db->setQuery('select jgroup from #__joomla_flash_uploader_user where location=\'site\' and profile in (SELECT id FROM #__joomla_flash_uploader where id = ' . $id . ' and gid = \'' . $group_id . '\')'); $jgroups_res = $db->loadObjectList(); $jgroups = array(); // extract the hits foreach ($jgroups_res as $key => $value) { $jgroups[] = $value->jgroup; } // set the hits in the available joomla groups foreach ($av_groups as $av_group) { if (in_array($av_group->value, $jgroups)) { $av_group->jselected = 'true'; } else { $av_group->jselected = 'false'; } } return $av_groups; }
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(); } }