static function getNotJoomdleUsers($limitstart, $limit, $order, $order_dir, $search) { $lang = JFactory::getLanguage(); $db = JFactory::getDBO(); $searchEscaped = $db->Quote('%' . $db->escape($search, true) . '%', false); if ($search) { $query = 'SELECT *' . ' FROM #__users' . ' WHERE (username LIKE ' . $searchEscaped . ' OR email LIKE ' . $searchEscaped . ' OR name LIKE ' . $searchEscaped . ')'; } else { $query = 'SELECT *' . ' FROM #__users'; } $db->setQuery($query); $jusers = $db->loadObjectList(); $ju_by_usernames = array(); foreach ($jusers as $user) { $ju_by_usernames[$user->username] = $user; } $musers = JoomdleHelperContent::call_method('get_moodle_users', $limitstart, $limit, $order, $order_dir, $search); $mu_by_usernames = array(); foreach ($musers as $user) { $mu_by_usernames[$user['username']] = $user; } $rdo = array(); foreach ($jusers as $user) { $item = array(); $item = get_object_vars($user); $item['j_account'] = 1; if (!array_key_exists($user->username, $mu_by_usernames)) { // User not found in Moodle -> not a Joomdle user $item['m_account'] = 0; if (JoomdleHelperContent::is_admin($user->id)) { $item['admin'] = 1; } else { $item['admin'] = 0; } $item['auth'] = 'N/A'; } else { // User in Joomla and Moodle $item['m_account'] = 1; if (!$mu_by_usernames[$user->username]['admin']) { if (JoomdleHelperContent::is_admin($user->id)) { $item['admin'] = 1; } else { $item['admin'] = 0; } } else { $item['admin'] = 1; } $item['auth'] = $mu_by_usernames[$user->username]['auth']; } if ($item['m_account'] == 1 && $item['auth'] == 'joomdle') { continue; } $rdo[] = $item; } // Get Moodle only users: those without a Joomla account $rdo2 = array(); foreach ($musers as $user) { $item = array(); $item = $user; $item['m_account'] = 1; if (!array_key_exists($user['username'], $ju_by_usernames)) { // User not found in Joomla -> not a Joomdle user $item['j_account'] = 0; $item['m_account'] = 1; $item['id'] = -$user['id']; $rdo2[] = $item; } } $merged = array_merge($rdo, $rdo2); $all = JoomdleHelperContent::multisort($merged, $order_dir, $order, 'id', 'name', 'username', 'email', 'm_account', 'j_account', 'auth', 'admin'); if ($limit) { return array_slice($all, $limitstart, $limit); } else { return $all; } }
static function getNotJoomdleUsers($limitstart, $limit, $order, $order_dir, $search) { $lang = JFactory::getLanguage(); $db = JFactory::getDBO(); $searchEscaped = $db->Quote('%' . $db->escape($search, true) . '%', false); if ($search) { $query = 'SELECT *' . ' FROM #__users' . ' WHERE (username LIKE ' . $searchEscaped . ' OR email LIKE ' . $searchEscaped . ' OR name LIKE ' . $searchEscaped . ')'; } else { $query = 'SELECT *' . ' FROM #__users'; } $db->setQuery($query); $users = $db->loadObjectList(); $u = array(); foreach ($users as $user) { $u[]['username'] = $user->username; } $u_usernames = $u; $u = JoomdleHelperContent::call_method('check_moodle_users', $u); // print_r ($users); $rdo = array(); $i = 0; foreach ($users as $user) { if ($u[$i]['m_account'] == 1 && $u[$i]['auth'] == 'joomdle') { $i++; continue; } $rdo[$i] = get_object_vars($user); if (!$u[$i]['admin']) { if (JoomdleHelperContent::is_admin($user->id)) { $rdo[$i]['admin'] = 1; } else { $rdo[$i]['admin'] = 0; } } else { $rdo[$i]['admin'] = 1; } $rdo[$i]['j_account'] = 1; $rdo[$i]['m_account'] = $u[$i]['m_account']; if ($rdo[$i]['m_account']) { $rdo[$i]['auth'] = $u[$i]['auth']; } else { $rdo[$i]['auth'] = 'N/A'; } $i++; } $u = JoomdleHelperContent::call_method('get_moodle_only_users', $u_usernames, $search); if (!is_array($u)) { $u = array(); } $i = 0; foreach ($u as $user) { $u[$i]['m_account'] = 1; $u[$i]['j_account'] = 0; $u[$i]['id'] = -$u[$i]['id']; $i++; } $merged = array_merge($rdo, $u); $all = JoomdleHelperContent::multisort($merged, $order_dir, $order, 'id', 'name', 'username', 'email', 'm_account', 'j_account', 'auth', 'admin'); if ($limit) { return array_slice($all, $limitstart, $limit); } else { return $all; } }