@author Leo Fajardo (@leorw)
@since  1.1.2

@param string $user_type

@return array The uninstall reasons for the specified user type.
515425
function _get_uninstall_reasons( $user_type = 'long-term' ) {
            $module_type = $this->_module_type;

            $internal_message_template_var = array(
                'id' => $this->_module_id
            );

            $plan = $this->get_plan();

            if ( $this->is_registered() && is_object( $plan ) && $plan->has_technical_support() ) {
                $contact_support_template = fs_get_template( 'forms/deactivation/contact.php', $internal_message_template_var );
            } else {
                $contact_support_template = '';
            }

            $reason_found_better_plugin = array(
                'id'                => self::REASON_FOUND_A_BETTER_PLUGIN,
                'text'              => sprintf( $this->get_text_inline( 'I found a better %s', 'reason-found-a-better-plugin' ), $module_type ),
                'input_type'        => 'textfield',
                'input_placeholder' => sprintf( $this->get_text_inline( "What's the %s's name?", 'placeholder-plugin-name' ), $module_type ),
            );

            $reason_temporary_deactivation = array(
                'id'                => self::REASON_TEMPORARY_DEACTIVATION,
                'text'              => sprintf(
                    $this->get_text_inline( "It's a temporary %s. I'm just debugging an issue.", 'reason-temporary-x' ),
                    strtolower( $this->is_plugin() ?
                        $this->get_text_inline( 'Deactivation', 'deactivation' ) :
                        $this->get_text_inline( 'Theme Switch', 'theme-switch' )
                    )
                ),
                'input_type'        => '',
                'input_placeholder' => ''
            );

            $reason_other = array(
                'id'                => self::REASON_OTHER,
                'text'              => $this->get_text_inline( 'Other', 'reason-other' ),
                'input_type'        => 'textfield',
                'input_placeholder' => ''
            );

            $long_term_user_reasons = array(
                array(
                    'id'                => self::REASON_NO_LONGER_NEEDED,
                    'text'              => sprintf( $this->get_text_inline( 'I no longer need the %s', 'reason-no-longer-needed' ), $module_type ),
                    'input_type'        => '',
                    'input_placeholder' => ''
                ),
                $reason_found_better_plugin,
                array(
                    'id'                => self::REASON_NEEDED_FOR_A_SHORT_PERIOD,
                    'text'              => sprintf( $this->get_text_inline( 'I only needed the %s for a short period', 'reason-needed-for-a-short-period' ), $module_type ),
                    'input_type'        => '',
                    'input_placeholder' => ''
                ),
                array(
                    'id'                => self::REASON_BROKE_MY_SITE,
                    'text'              => sprintf( $this->get_text_inline( 'The %s broke my site', 'reason-broke-my-site' ), $module_type ),
                    'input_type'        => '',
                    'input_placeholder' => '',
                    'internal_message'  => $contact_support_template
                ),
                array(
                    'id'                => self::REASON_SUDDENLY_STOPPED_WORKING,
                    'text'              => sprintf( $this->get_text_inline( 'The %s suddenly stopped working', 'reason-suddenly-stopped-working' ), $module_type ),
                    'input_type'        => '',
                    'input_placeholder' => '',
                    'internal_message'  => $contact_support_template
                )
            );

            if ( $this->is_paying() ) {
                $long_term_user_reasons[] = array(
                    'id'                => self::REASON_CANT_PAY_ANYMORE,
                    'text'              => $this->get_text_inline( "I can't pay for it anymore", 'reason-cant-pay-anymore' ),
                    'input_type'        => 'textfield',
                    'input_placeholder' => $this->get_text_inline( 'What price would you feel comfortable paying?', 'placeholder-comfortable-price' )
                );
            }

            $reason_dont_share_info = array(
                'id'                => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
                'text'              => $this->get_text_inline( "I don't like to share my information with you", 'reason-dont-like-to-share-my-information' ),
                'input_type'        => '',
                'input_placeholder' => ''
            );

            /**
             * If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
             * user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
             * (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
             * enabled and the user's account is currently not in pending activation state (similar to the way the Skip
             * button in the opt-in form is shown/hidden).
             */
            if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
                $reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
            }

            $uninstall_reasons = array(
                'long-term'                                   => $long_term_user_reasons,
                'non-registered-and-non-anonymous-short-term' => array(
                    array(
                        'id'                => self::REASON_DIDNT_WORK,
                        'text'              => sprintf( $this->get_text_inline( "The %s didn't work", 'reason-didnt-work' ), $module_type ),
                        'input_type'        => '',
                        'input_placeholder' => ''
                    ),
                    $reason_dont_share_info,
                    $reason_found_better_plugin
                ),
                'short-term'                                  => array(
                    array(
                        'id'                => self::REASON_COULDNT_MAKE_IT_WORK,
                        'text'              => $this->get_text_inline( "I couldn't understand how to make it work", 'reason-couldnt-make-it-work' ),
                        'input_type'        => '',
                        'input_placeholder' => '',
                        'internal_message'  => $contact_support_template
                    ),
                    $reason_found_better_plugin,
                    array(
                        'id'                => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
                        'text'              => sprintf( $this->get_text_inline( "The %s is great, but I need specific feature that you don't support", 'reason-great-but-need-specific-feature' ), $module_type ),
                        'input_type'        => 'textarea',
                        'input_placeholder' => $this->get_text_inline( 'What feature?', 'placeholder-feature' )
                    ),
                    array(
                        'id'                => self::REASON_NOT_WORKING,
                        'text'              => sprintf( $this->get_text_inline( 'The %s is not working', 'reason-not-working' ), $module_type ),
                        'input_type'        => 'textarea',
                        'input_placeholder' => $this->get_text_inline( "Kindly share what didn't work so we can fix it for future users...", 'placeholder-share-what-didnt-work' )
                    ),
                    array(
                        'id'                => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
                        'text'              => $this->get_text_inline( "It's not what I was looking for", 'reason-not-what-i-was-looking-for' ),
                        'input_type'        => 'textarea',
                        'input_placeholder' => $this->get_text_inline( "What you've been looking for?", 'placeholder-what-youve-been-looking-for' )
                    ),
                    array(
                        'id'                => self::REASON_DIDNT_WORK_AS_EXPECTED,
                        'text'              => sprintf( $this->get_text_inline( "The %s didn't work as expected", 'reason-didnt-work-as-expected' ), $module_type ),
                        'input_type'        => 'textarea',
                        'input_placeholder' => $this->get_text_inline( 'What did you expect?', 'placeholder-what-did-you-expect' )
                    )
                )
            );

            // Randomize the reasons for the current user type.
            shuffle( $uninstall_reasons[ $user_type ] );

            // Keep the following reasons as the last items in the list.
            $uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
            $uninstall_reasons[ $user_type ][] = $reason_other;

            $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );

            return $uninstall_reasons[ $user_type ];
        }
1050433
public static function delete_data_for_users(approved_userlist $userlist) {
        global $DB;

        $context = $userlist->get_context();
        $lessonid = static::get_lesson_id_from_context($context);
        $userids = $userlist->get_userids();

        if (empty($lessonid)) {
            return;
        }

        // Prepare the SQL we'll need below.
        list($insql, $inparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
        $sql = "lessonid = :lessonid AND userid {$insql}";
        $params = array_merge($inparams, ['lessonid' => $lessonid]);

        // Delete the attempt files.
        $fs = get_file_storage();
        $recordset = $DB->get_recordset_select('lesson_attempts', $sql, $params, '', 'id, lessonid');
        foreach ($recordset as $record) {
            $fs->delete_area_files($context->id, 'mod_lesson', 'essay_responses', $record->id);
            $fs->delete_area_files($context->id, 'mod_lesson', 'essay_answers', $record->id);
        }
        $recordset->close();

        // Delete all the things.
        $DB->delete_records_select('lesson_attempts', $sql, $params);
        $DB->delete_records_select('lesson_branch', $sql, $params);
        $DB->delete_records_select('lesson_grades', $sql, $params);
        $DB->delete_records_select('lesson_timer', $sql, $params);
        $DB->delete_records_select('lesson_overrides', $sql, $params);
    }
127426
public function removeUser( core_kernel_classes_Resource $user)
    {
        $returnValue = (bool) false;

        if(!is_null($user)) {
            $this->checkCurrentUserAccess($this->getUserRoles($user));
			$returnValue = $this->generisUserService->removeUser($user);
            $this->getEventManager()->trigger(new UserRemovedEvent($user->getUri()));
		}

        return (bool) $returnValue;
    }
1152448
public function canDelete($user_guid = 0) {
		
		$user_guid = (int) $user_guid;
		if (empty($user_guid)) {
			$user_guid = elgg_get_logged_in_user_guid();
		}
		
		return elgg_is_admin_user($user_guid);
	}
441679
public function getWidgets(User $user, $widgetType = null)
    {
        /** @var \Icap\PortfolioBundle\Repository\Widget\AbstractWidgetRepository $abstractWidgetRepository */
        $abstractWidgetRepository = $this->entityManager->getRepository("IcapPortfolioBundle:Widget\AbstractWidget");

        if ($widgetType !== null) {
            $widgets = $abstractWidgetRepository->findByWidgetTypeAndUser($widgetType, $user);
        } else {
            $widgets = $abstractWidgetRepository->findByUser($user);
        }

        return $widgets;
    }
1264018
public function destroy(UserPolicy $user, Comment $comment)
    {
        return $comment->user_id == user_id() && $comment->user_type == user_type();
    }
460338
function _submit_uninstall_reason_action() {
            $this->_logger->entrance();

            $this->check_ajax_referer( 'submit_uninstall_reason' );

            $reason_id = fs_request_get( 'reason_id' );

            // Check if the given reason ID is an unsigned integer.
            if ( ! ctype_digit( $reason_id ) ) {
                exit;
            }

            $reason_info = trim( fs_request_get( 'reason_info', '' ) );
            if ( ! empty( $reason_info ) ) {
                $reason_info = substr( $reason_info, 0, 128 );
            }

            $reason = (object) array(
                'id'           => $reason_id,
                'info'         => $reason_info,
                'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
            );

            $this->_storage->store( 'uninstall_reason', $reason );

            /**
             * If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do
             * not support uninstall hook.
             *
             * @author Leo Fajardo (@leorw)
             * @since  1.2.2
             */
            if ( $this->is_theme() ) {
                if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
                    FS_Plugin_Updater::instance( $this )->delete_update_data();
                }

                $this->_uninstall_plugin_event( false );
                $this->remove_sdk_reference();
            }

            // Print '1' for successful operation.
            echo 1;
            exit;
        }
481534
public function getFavouriteWorkspacesByUser(User $user)
    {
        $workspaces = [];

        /** @var WorkspaceFavourite[] $favourites */
        $favourites = $this->om
            ->getRepository('ClarolineCoreBundle:Workspace\WorkspaceFavourite')
            ->findBy([
                'user' => $user,
            ]);

        foreach ($favourites as $favourite) {
            $workspace = $favourite->getWorkspace();
            $workspaces[$workspace->getId()] = $workspace;
        }

        return $workspaces;
    }
802944
public function deactivate($id_user){
    $update = [
      $this->class_cfg['arch']['users']['active'] => 0,
      $this->class_cfg['arch']['users']['email'] => null,
    ];
    if ( !empty($this->class_cfg['arch']['users']['login']) ){
      $update[$this->class_cfg['arch']['users']['login']] = null;
    }

    return $this->db->update($this->class_cfg['tables']['users'], $update, [
      $this->class_cfg['arch']['users']['id'] => $id_user
    ]);
	}
1066674
public function deleteServer ( $consumer_key, $user_id, $user_is_admin = false )
	{
		if ($user_is_admin)
		{
			$this->query('
					DELETE FROM oauth_consumer_registry
					WHERE ocr_consumer_key = \'%s\'
					  AND (ocr_usa_id_ref = %d OR ocr_usa_id_ref IS NULL)
					', $consumer_key, $user_id);
		}
		else
		{
			$this->query('
					DELETE FROM oauth_consumer_registry
					WHERE ocr_consumer_key = \'%s\'
					  AND ocr_usa_id_ref   = %d
					', $consumer_key, $user_id);
		}
	}
637496
public function deactivateUser(User $user)
    {
        /** @var Account $account */
        foreach ($user->getAccounts() as $account) {
            $account->setExpirationDate($this->now);
            $this->accountRepository->update($account);
        }
        $this->emitUserDeactivated($user);
    }
681171
public function removeUser($userUri, core_kernel_classes_Resource $group) {
        $user = new \core_kernel_classes_Resource($userUri);
        return $user->removePropertyValue(new core_kernel_classes_Property(self::PROPERTY_MEMBERS_URI), $group);
    }
706166
public function getDisplayedDesktopOrderedTools(
        User $user,
        $type = 0,
        array $excludedTools = []
    ) {
        return 0 === count($excludedTools) ?
            $this->toolRepo->findDesktopDisplayedToolsByUser($user, $type) :
            $this->toolRepo->findDesktopDisplayedToolsWithExclusionByUser(
                $user,
                $excludedTools,
                $type
            );
    }
265199
public static function delete_by_user_id($user_id = null)
	{
		if (empty($user_id))
		{
			return true;
		}

		$results = self::all()
			->whereEquals('user_id', $user_id)
			->rows();

		foreach ($results as $result)
		{
			if (!$result->destroy())
			{
				return false;
			}
		}

		return true;
	}
1374867
public function removeClientUser($client_id, $user_id)
    {
        $sql    = 'DELETE from %s where client_id = :client_id and user_id = :user_id';
        $sql    = sprintf($sql, $this->config['client_user_table']);
        $params = array_map('trim', compact('client_id', 'user_id'));

        return $this->db->prepare($sql)->execute($params);
    }
1310093
public function userGet(int $user_id)
    {
        $value = get_user_meta($user_id, $this->getName(), ! $this->getOption('multiple', false));

        if (! empty($value)) {
            $this->setValue($value);
        }
    }
894260
public function actionDeregister($user)
    {
        $user = $this->getUser($user);
        if ($user->deregister()) {
            echo "User (" . $user->getID() . ") Deregistered.\n";
            return static::EXIT_CODE_NORMAL;
        }
        return static::EXIT_CODE_ERROR;
    }