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