Пример #1
0
     if (!empty($_REQUEST['return_url'])) {
         $redirect_params['return_url'] = urlencode($_REQUEST['return_url']);
     }
     return array(CONTROLLER_STATUS_OK, 'profiles' . (!empty($user_id) ? '.update' : '.add') . '?' . http_build_query($redirect_params));
 }
 if ($mode == 'delete') {
     $user_type = fn_get_request_user_type($_REQUEST);
     fn_delete_user($_REQUEST['user_id']);
     return array(CONTROLLER_STATUS_REDIRECT, 'profiles.manage?user_type=' . $user_type);
 }
 if ($mode == 'delete_profile') {
     if (fn_is_restricted_admin($_REQUEST)) {
         return array(CONTROLLER_STATUS_DENIED);
     }
     $user_id = empty($_REQUEST['user_id']) ? $auth['user_id'] : $_REQUEST['user_id'];
     fn_delete_user_profile($user_id, $_REQUEST['profile_id']);
     return array(CONTROLLER_STATUS_OK, 'profiles.update?user_id=' . $user_id);
 }
 if ($mode == 'update_status') {
     $condition = fn_get_company_condition('?:users.company_id');
     $user_data = db_get_row("SELECT * FROM ?:users WHERE user_id = ?i {$condition}", $_REQUEST['id']);
     if (!empty($user_data)) {
         $result = db_query("UPDATE ?:users SET status = ?s WHERE user_id = ?i", $_REQUEST['status'], $_REQUEST['id']);
         if ($result && $_REQUEST['id'] != 1) {
             fn_set_notification('N', __('notice'), __('status_changed'));
             $force_notification = fn_get_notification_rules($_REQUEST);
             if (!empty($force_notification['C']) && $_REQUEST['status'] == 'A' && $user_data['status'] == 'D') {
                 Mailer::sendMail(array('to' => $user_data['email'], 'from' => 'company_users_department', 'data' => array('user_data' => $user_data), 'tpl' => 'profiles/profile_activated.tpl', 'company_id' => $user_data['company_id']), fn_check_user_type_admin_area($user_data['user_type']) ? 'A' : 'C', $user_data['lang_code']);
             }
         } else {
             fn_set_notification('E', __('error'), __('error_status_not_changed'));
Пример #2
0
    if (file_exists($target_file)) {
        $ls_user_image = 'file exists';
        //  $view->assign('ls_user_image', $ls_user_image);
        Registry::get('view')->assign('ls_user_profile_image', $ls_user_image);
    }
    Registry::get('view')->assign('profile_fields', $profile_fields);
    Registry::get('view')->assign('user_data', $user_data);
    Registry::get('view')->assign('ship_to_another', fn_check_shipping_billing($user_data, $profile_fields));
    Registry::get('view')->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
    Registry::get('view')->assign('states', fn_get_all_states());
    if (Registry::get('settings.General.user_multiple_profiles') == 'Y') {
        Registry::get('view')->assign('user_profiles', fn_get_user_profiles($auth['user_id']));
    }
    // Delete profile
} elseif ($mode == 'delete_profile') {
    fn_delete_user_profile($auth['user_id'], $_REQUEST['profile_id']);
    return array(CONTROLLER_STATUS_OK, "profiles.update");
} elseif ($mode == 'usergroups') {
    if (empty($auth['user_id']) || empty($_REQUEST['type']) || empty($_REQUEST['usergroup_id'])) {
        return array(CONTROLLER_STATUS_DENIED);
    }
    if (fn_request_usergroup($auth['user_id'], $_REQUEST['usergroup_id'], $_REQUEST['type'])) {
        $user_data = fn_get_user_info($auth['user_id']);
        Mailer::sendMail(array('to' => 'default_company_users_department', 'from' => 'default_company_users_department', 'reply_to' => $user_data['email'], 'data' => array('user_data' => $user_data, 'usergroups' => fn_get_usergroups('F', Registry::get('settings.Appearance.backend_default_language')), 'usergroup_id' => $_REQUEST['usergroup_id']), 'tpl' => 'profiles/usergroup_request.tpl', 'company_id' => $user_data['company_id']), 'A', Registry::get('settings.Appearance.backend_default_language'));
    }
    return array(CONTROLLER_STATUS_OK, "profiles.update");
} elseif ($mode == 'success_add') {
    if (empty($auth['user_id'])) {
        return array(CONTROLLER_STATUS_REDIRECT, "profiles.add");
    }
    fn_add_breadcrumb(__('registration'));
Пример #3
0
/**
 * Deletes user and all related data
 *
 * @param int $user_id User identificator
 * @return boolean False, if user can not be deleted, true if user was successfully deleted
 */
function fn_delete_user($user_id)
{
    fn_set_hook('pre_delete_user', $user_id);
    $condition = fn_get_company_condition('?:users.company_id');
    $user_data = db_get_row("SELECT user_id, is_root, company_id FROM ?:users WHERE user_id = ?i {$condition}", $user_id);
    if (empty($user_data)) {
        return false;
    }
    $auth = $_SESSION['auth'];
    if (!fn_check_rights_delete_user($user_data, $auth)) {
        fn_set_notification('W', __('warning'), __('user_cannot_be_deleted', array('[user_id]' => $user_id)), '', 'user_delete_no_permissions');
        return false;
    }
    // Log user deletion
    fn_log_event('users', 'delete', array('user_id' => $user_id));
    fn_set_hook('delete_user', $user_id, $user_data);
    $result = db_query("DELETE FROM ?:users WHERE user_id = ?i", $user_id);
    db_query('DELETE FROM ?:profile_fields_data WHERE object_id = ?i AND object_type = ?s', $user_id, 'U');
    db_query('DELETE FROM ?:user_session_products WHERE user_id = ?i', $user_id);
    db_query('DELETE FROM ?:user_data WHERE user_id = ?i', $user_id);
    db_query('UPDATE ?:orders SET user_id = 0 WHERE user_id = ?i', $user_id);
    $profile_ids = db_get_fields('SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i', $user_id);
    foreach ($profile_ids as $profile_id) {
        fn_delete_user_profile($user_id, $profile_id, true);
    }
    if (!fn_allowed_for('ULTIMATE:FREE')) {
        db_query('DELETE FROM ?:usergroup_links WHERE user_id = ?i', $user_id);
    }
    /**
     * Hook for deleting related user data in addons
     *
     * @param int   $user_id   User identificator
     * @param array $user_data Array with user data (contains user_id, is_root and company_id fields)
     * @param int count of affected rows
     */
    fn_set_hook('post_delete_user', $user_id, $user_data, $result);
    return $result;
}