@@ 1141-1171 (lines=31) @@ | ||
1138 | * @param string $needle |
|
1139 | * @return XajaxResponse |
|
1140 | */ |
|
1141 | public static function searchCourseCategoryAjax($needle) |
|
1142 | { |
|
1143 | $response = new xajaxResponse(); |
|
1144 | $return = ''; |
|
1145 | ||
1146 | if (!empty($needle)) { |
|
1147 | // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
1148 | $charset = api_get_system_encoding(); |
|
1149 | $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
1150 | $needle = Database::escape_string($needle); |
|
1151 | // search courses where username or firstname or lastname begins likes $needle |
|
1152 | $sql = 'SELECT id, name FROM '.Database::get_main_table(TABLE_MAIN_CATEGORY).' u |
|
1153 | WHERE name LIKE "'.$needle.'%" AND (parent_id IS NULL or parent_id = 0) |
|
1154 | ORDER BY name |
|
1155 | LIMIT 11'; |
|
1156 | $result = Database::query($sql); |
|
1157 | $i = 0; |
|
1158 | while ($data = Database::fetch_array($result)) { |
|
1159 | $i++; |
|
1160 | if ($i <= 10) { |
|
1161 | $return .= '<a |
|
1162 | href="javascript: void(0);" |
|
1163 | onclick="javascript: add_user_to_url(\''.addslashes($data['id']).'\',\''.addslashes($data['name']).' \')">'.$data['name'].' </a><br />'; |
|
1164 | } else { |
|
1165 | $return .= '...<br />'; |
|
1166 | } |
|
1167 | } |
|
1168 | } |
|
1169 | $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return)); |
|
1170 | return $response; |
|
1171 | } |
|
1172 | } |
|
1173 |
@@ 1235-1266 (lines=32) @@ | ||
1232 | * @param $needle |
|
1233 | * @return xajaxResponse |
|
1234 | */ |
|
1235 | public static function searchUserGroupAjax($needle) |
|
1236 | { |
|
1237 | $response = new xajaxResponse(); |
|
1238 | $return = ''; |
|
1239 | ||
1240 | if (!empty($needle)) { |
|
1241 | // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
1242 | $charset = api_get_system_encoding(); |
|
1243 | $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
1244 | $needle = Database::escape_string($needle); |
|
1245 | // search courses where username or firstname or lastname begins likes $needle |
|
1246 | $sql = 'SELECT id, name FROM '.Database::get_main_table(TABLE_USERGROUP).' u |
|
1247 | WHERE name LIKE "'.$needle.'%" |
|
1248 | ORDER BY name |
|
1249 | LIMIT 11'; |
|
1250 | $result = Database::query($sql); |
|
1251 | $i = 0; |
|
1252 | while ($data = Database::fetch_array($result)) { |
|
1253 | $i++; |
|
1254 | if ($i <= 10) { |
|
1255 | $return .= '<a |
|
1256 | href="javascript: void(0);" |
|
1257 | onclick="javascript: add_user_to_url(\''.addslashes($data['id']).'\',\''.addslashes($data['name']).' \')">'.$data['name'].' </a><br />'; |
|
1258 | } else { |
|
1259 | $return .= '...<br />'; |
|
1260 | } |
|
1261 | } |
|
1262 | } |
|
1263 | $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return)); |
|
1264 | ||
1265 | return $response; |
|
1266 | } |
|
1267 | ||
1268 | /** |
|
1269 | * Get user list by usergroup |