Rebuild only Extensions.
@param     array      $modules       Rebuild only the specified modules
@param     string     $user_id       User id of the admin user
@return    array                     Messages
349719
public function rebuildExtensions(array $modules = array(), $user_id = '1')
    {
        $this->setUpQuickRepair($user_id);
        $repair = new \RepairAndClear();
        $repair->repairAndClearAll(
            array('rebuildExtensions'),
            $modules
        );
        return $this->getMessages();
    }
389813
public function reactivateModules()
    {
        foreach ($this->modules as $module) {
            $moduleProperties = $this->parseModuleJson($module->getDirectory());
            $version = $moduleProperties->module->version;

            $this->activateModule($moduleProperties->module->namespace, true);
            $module->activate($version, $version);
        }
    }
999175
private static function get_user_opted_in_module_ids_map( $fs_user_id ) {
            self::$_static_logger->entrance();

            if ( ! is_multisite() ) {
                $installs = array_merge(
                    self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN ),
                    self::get_all_sites( WP_FS__MODULE_TYPE_THEME )
                );
            } else {
                $sites = self::get_sites();

                $installs = array();
                foreach ( $sites as $site ) {
                    $blog_id = self::get_site_blog_id( $site );

                    $installs = array_merge(
                        $installs,
                        self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN, $blog_id ),
                        self::get_all_sites( WP_FS__MODULE_TYPE_THEME, $blog_id )
                    );
                }
            }

            $module_ids_map = array();
            foreach ( $installs as $install ) {
                if ( is_object( $install ) &&
                     FS_Site::is_valid_id( $install->id ) &&
                     FS_User::is_valid_id( $install->user_id ) &&
                     ( $install->user_id == $fs_user_id )
                ) {
                    $module_ids_map[ $install->plugin_id ] = true;
                }
            }

            return $module_ids_map;
        }
1079336
public function addAdministrators($user_ids)
    {
        $users = Agent::find($user_ids);
        foreach ($users as $user) {
            $user->ticketit_admin = true;
            $user->save();
            $users_list[] = $user->name;
        }

        return $users_list;
    }
445468
protected static function export_user_data_in_module_contexts($userid, array $contexts) {
        global $DB;

        $contexts = array_filter($contexts, function($context) {
            return $context->contextlevel == CONTEXT_MODULE;
        });
        if (empty($contexts)) {
            return;
        }

        $path = [get_string('competencies', 'core_competency')];
        $cmids = array_map(function($context) {
            return $context->instanceid;
        }, $contexts);

        // Fetch all the modules with associations we created or modified.
        $compfields = competency::get_sql_fields('c', 'c_');
        $cmcfields = course_module_competency::get_sql_fields('cmc', 'cmc_');
        $ctxfields = context_helper::get_preload_record_columns_sql('ctx');
        list($insql, $inparams) = $DB->get_in_or_equal($cmids, SQL_PARAMS_NAMED);
        $sql = "
            SELECT $compfields, $cmcfields, $ctxfields
              FROM {" . course_module_competency::TABLE . "} cmc
              JOIN {" . competency::TABLE . "} c
                ON c.id = cmc.competencyid
              JOIN {" . competency_framework::TABLE . "} f
                ON f.id = c.competencyframeworkid
              JOIN {context} ctx
                ON ctx.id = f.contextid
             WHERE cmc.usermodified = :userid
               AND cmc.cmid $insql
          ORDER BY cmc.cmid";
        $params = array_merge($inparams, ['userid' => $userid]);

        // Export the data.
        $recordset = $DB->get_recordset_sql($sql, $params);
        static::recordset_loop_and_export($recordset, 'cmc_cmid', [], function($carry, $record) {
            context_helper::preload_from_record($record);
            $competency = new competency(null, competency::extract_record($record, 'c_'));
            $cmc = new course_module_competency(null, course_module_competency::extract_record($record, 'cmc_'));
            $carry[] = array_merge(static::transform_competency_brief($competency), [
                'timecreated' => transform::datetime($cmc->get('timecreated')),
                'timemodified' => transform::datetime($cmc->get('timemodified')),
                'created_or_modified_by_you' => transform::yesno(true)
            ]);
            return $carry;

        }, function($cmid, $data) use ($path) {
            $context = context_module::instance($cmid);
            writer::with_context($context)->export_data($path, (object) ['associations' => $data]);
        });
    }
328863
public function getModuleIds()
    {
        $aModuleIdsFromExtensions = $this->_getModuleIdsFromExtensions($this->getModulesWithExtendedClass());
        $aModuleIdsFromFiles = array_keys($this->getModuleConfigParametersByKey(static::MODULE_KEY_FILES));

        return array_unique(array_merge($aModuleIdsFromExtensions, $aModuleIdsFromFiles));
    }
439215
private function restoreModuleInformation($module, $moduleId)
    {
        $this->_addExtensions($module);
        $metaDataVersion = $module->getMetaDataVersion();
        $metaDataVersion = $metaDataVersion == '' ? $metaDataVersion = "1.0" : $metaDataVersion; 
        if (version_compare($metaDataVersion, '2.0', '<')) {
            $this->_addModuleFiles($module->getInfo("files"), $moduleId);
        }
        $this->_addTemplateBlocks($module->getInfo("blocks"), $moduleId);
        $this->_addTemplateFiles($module->getInfo("templates"), $moduleId);
        $this->_addModuleSettings($module->getInfo("settings"), $moduleId);
        $this->_addModuleVersion($module->getInfo("version"), $moduleId);
        $this->_addModuleExtensions($module->getExtensions(), $moduleId);
        $this->_addModuleEvents($module->getInfo("events"), $moduleId);

        if (version_compare($metaDataVersion, '2.0', '>=')) {
            try {
                $this->setModuleControllers($module->getControllers(), $moduleId, $module);
            } catch (ModuleValidationException $exception) {
                print "[ERROR]: duplicate controllers:" . $exception->getMessage() ."\n";
            }
        }
    }
977310
public static function getDependencies(array $module_list, $only_dependencies = FALSE) {
    $module_list_orig = $module_list;
    $extension_config = \Drupal::configFactory()->getEditable('core.extension');
    // Get all module data so we can find dependencies and sort.
    $module_data = system_rebuild_module_data();
    $module_list = $module_list ? array_combine($module_list, $module_list) : [];
    if ($missing_modules = array_diff_key($module_list, $module_data)) {
      // One or more of the given modules doesn't exist.
      throw new MissingDependencyException(sprintf('Unable to install modules %s due to missing modules %s.', implode(', ', $module_list), implode(', ', $missing_modules)));
    }

    // Only process currently uninstalled modules.
    $installed_modules = $extension_config->get('module') ?: [];
    if (!$module_list = array_diff_key($module_list, $installed_modules)) {
      // Nothing to do. All modules already installed.
      return TRUE;
    }

    // Add dependencies to the list. The new modules will be processed as
    // the while loop continues.
    while (list($module) = each($module_list)) {
      foreach (array_keys($module_data[$module]->requires) as $dependency) {
        if (!isset($module_data[$dependency])) {
          // The dependency does not exist.
          throw new MissingDependencyException("Unable to install modules: module '$module' is missing its dependency module $dependency.");
        }

        // Skip already installed modules.
        if (!isset($module_list[$dependency]) && !isset($installed_modules[$dependency])) {
          $module_list[$dependency] = $dependency;
        }
      }
    }

    // Set the actual module weights.
    $module_list = array_map(function ($module) use ($module_data) {
      return $module_data[$module]->sort;
    }, $module_list);

    // Sort the module list by their weights (reverse).
    arsort($module_list);

    if ($only_dependencies) {
      foreach ($module_list_orig as $key => $value) {
        unset($module_list[$key]);
      }
    }

    $module_list = array_keys($module_list);

    return $module_list;
  }
1374990
public function enableModules($modules)
    {
        foreach ($modules as $moduleToEnable => $value) {
            $module = $this->module->get($moduleToEnable);
            $module->enable();
        }
    }
44625
private function userBlocks(int $user_id, string $location): Collection
    {
        $rows = DB::table('block')
            ->where('user_id', '=', $user_id)
            ->where('location', '=', $location)
            ->orderBy('block_order')
            ->pluck('module_name', 'block_id');

        return $this->filterActiveBlocks($rows, $this->availableUserBlocks());
    }
843394
public function save($user_id)
    {
        $validator = $this->validator->make(
            $this->getUserData(app('request')),
            $this->getUserRules(),
            $this->getUserMessages(),
            $this->getUserPlaceholders()
        );

        $validation = $validator->valid();

        foreach ($this->repository->all() as $field) {
            /** @var FieldTypeInterface|BaseType|CanHandleUsers $field */
            $field->setErrorMessageBag($validator->errors());

            if (method_exists($field, 'userSave')) {
                $field->userSave($validation[$field->getName()] ?? null, $user_id);
            } else {
                throw new UserException('Unable to save ['.$field->getName().']. The [userSave] method is missing.');
            }
        }
    }
532172
public function getInstalledModules()
    {
        $modules = $this->modules;

        if ($this->rootModule) {
            unset($modules[$this->rootModule->getName()]);
        }

        return $modules;
    }
1257742
protected function update_users_used() {
        global $DB;

        $this->userfullnames = array();
        $userids = array();

        // For each event cache full username.
        // Get list of userids which will be shown in log report.
        foreach ($this->rawdata as $event) {
            $logextra = $event->get_logextra();
            if (!empty($event->userid) && empty($userids[$event->userid])) {
                $userids[$event->userid] = $event->userid;
            }
            if (!empty($logextra['realuserid']) && empty($userids[$logextra['realuserid']])) {
                $userids[$logextra['realuserid']] = $logextra['realuserid'];
            }
            if (!empty($event->relateduserid) && empty($userids[$event->relateduserid])) {
                $userids[$event->relateduserid] = $event->relateduserid;
            }
        }
        $this->rawdata->close();

        // Get user fullname and put that in return list.
        if (!empty($userids)) {
            list($usql, $uparams) = $DB->get_in_or_equal($userids);
            $users = $DB->get_records_sql("SELECT id," . get_all_user_name_fields(true) . " FROM {user} WHERE id " . $usql,
                    $uparams);
            foreach ($users as $userid => $user) {
                $this->userfullnames[$userid] = fullname($user);
                unset($userids[$userid]);
            }

            // We fill the array with false values for the users that don't exist anymore
            // in the database so we don't need to query the db again later.
            foreach ($userids as $userid) {
                $this->userfullnames[$userid] = false;
            }
        }
    }
120669
protected function isEnabledModule($module_id)
    {
        $sql = 'SELECT module_id FROM module WHERE module_id=? AND status > 0';
        $result = $this->db->fetchColumn($sql, array($module_id));
        return !empty($result);
    }
366560
public function getResumableDeliveries(User $user)
    {
        $deliveryExecutionService = ServiceProxy::singleton();
        $resumable = array();
        foreach ($this->getResumableStates() as $state) {
            foreach ($deliveryExecutionService->getDeliveryExecutionsByStatus($user->getIdentifier(), $state) as $execution) {
                $delivery = $execution->getDelivery();
                if ($delivery->exists()) {
                    $resumable[] = $execution;
                }
            }
        }
        return $resumable;
    }
460684
public function index($userId)
    {
        try
        {
            $user = $this->users->findById($userId);
            $userPermissions = $user->getPermissions();
            $genericPermissions = $this->permissions->generic();
            $modulePermissions = $this->permissions->module();

            return View::make(Config::get('cpanel::views.users_permission'))
                ->with('user',$user)
                ->with('userPermissions',$userPermissions)
                ->with('genericPermissions',$genericPermissions)
                ->with('modulePermissions',$modulePermissions);
        }
        catch ( UserNotFoundException $e)
        {
            return Redirect::route('cpanel.users.index')
                ->with('error', $e->getMessage());
        }
    }
697932
public function fromUser ( $user_id ) {
		
	    $sites = $this->User->find('first', array(
	    		'conditions' => array(
	    			'User.id' => $user_id
	    			),
	    		'contain' => array(
	    			'Site',
	    		)
	    	));

		if (!empty( $sites['Site'] )) {
			return $sites['Site'];
		} else {
			return null;
		}
	}