| @@ 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 |
|
| @@ 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 | ||