function WSRemoveUserFromPortal($params) { if (!WSHelperVerifyKey($params['secret_key'])) { return return_error(WS_ERROR_SECRET_KEY); } $userId = $params['user_id']; $portalId = $params['portal_id']; UrlManager::delete_url_rel_user($userId, $portalId); $result = UrlManager::relation_url_user_exist($userId, $portalId); if (empty($result)) { return 1; } return 0; }
// checking if the admin is registered in all sites $url_string = ''; $my_user_url_list = api_get_access_url_from_user(api_get_user_id()); foreach ($url_list as $my_url) { if (!in_array($my_url['id'], $my_user_url_list)) { $url_string .= $my_url['url'] . ' <br />'; } } if (!empty($url_string)) { Display::display_warning_message(get_lang('AdminShouldBeRegisterInSite') . '<br />' . $url_string, false); } // checking the current installation if ($current_access_url_id == -1) { Display::display_warning_message(get_lang('URLNotConfiguredPleaseChangedTo') . ': ' . api_get_path(WEB_PATH)); } elseif (api_is_platform_admin()) { $quant = UrlManager::relation_url_user_exist(api_get_user_id(), $current_access_url_id); if ($quant == 0) { Display::display_warning_message('<a href="' . api_get_self() . '?action=register&sec_token=' . $parameters['sec_token'] . '">' . get_lang('ClickToRegisterAdmin') . '</a>', false); } } // action menu echo '<div class="actions">'; echo Display::url(Display::return_icon('new_link.png', get_lang('AddUrl'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit.php'); echo Display::url(Display::return_icon('user.png', get_lang('ManageUsers'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit_users_to_url.php'); echo Display::url(Display::return_icon('course.png', get_lang('ManageCourses'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit_courses_to_url.php'); //echo Display::url(Display::return_icon('session.png', get_lang('ManageSessions'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'admin/access_url_edit_sessions_to_url.php'); $userGroup = new UserGroup(); if ($userGroup->getUseMultipleUrl()) { echo Display::url(Display::return_icon('class.png', get_lang('ManageUserGroup'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit_usergroup_to_url.php'); } if (CourseCategoryManager::isMultipleUrlSupport()) {
/** * Add a user into a url * @author Julio Montoya * @param $user_id * @param $url_id * * @return boolean true if success * */ public static function add_user_to_url($user_id, $url_id = 1) { $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); if (empty($url_id)) { $url_id = 1; } $count = UrlManager::relation_url_user_exist($user_id, $url_id); $result = true; if (empty($count)) { $sql = "INSERT INTO {$table_url_rel_user} (user_id, access_url_id)\n VALUES ('" . intval($user_id) . "', '" . intval($url_id) . "') "; $result = Database::query($sql); } return $result; }