Takeover a Drupal users account.

@param array $opts
@option string $user The account username (default to user 1).
@option string $path The path to redirect to.

@throws \Exception
16302
public function drupalLetmein($opts = [
        'user' => null,
        'path' => null
    ])
    {
        $this->executeCommandHook(__FUNCTION__, 'before');
        /** @var DrupalProjectType $instance */
        $instance = $this->getProjectInstance();
        $instance->createDrupalLoginLink($opts['user'], $opts['path']);
        $this->executeCommandHook(__FUNCTION__, 'after');
    }
742260
public function delete($project, $user, $optParams = array())
  {
    $params = array('project' => $project, 'user' => $user);
    $params = array_merge($params, $optParams);
    return $this->call('delete', array($params), "Computeaccounts_Operation");
  }
1371882
public function createUser(User $user)
    {
        if ($this->userStorage->getUserByField("email", $user->email)) {
            throw new Exception("E-postadress används redan.");
        }
        if ($this->userStorage->getUserByField("username", $user->username)) {
            throw new Exception("Användarnamn redan taget.");
        }
        $this->userStorage->createUser($user);
    }
1139166
function(opts){
  //defaults
  opts = opts || {};
  this.username           = opts.username    || '';
  this.password           = opts.password    || '';
  // oAuth Token
  this.accessToken        = opts.accessToken || '';
  // API Rate Limit Details
  this.rateLimit          = 5000;
  this.rateLimitRemaining = this.rateLimit;  //rateLimitRemaining starts as rateLimit
}
1322984
private function checkOptions($options)
    {
        if (empty($options['username'])) {
            throw new \Exception('Username is not set', 2301);
        }
        if (empty($options['password'])) {
            throw new \Exception('Password or hash is not set', 2302);
        }
        if (empty($options['host'])) {
            throw new \Exception('CPanel Host is not set', 2303);
        }

        return $this;
    }
927201
protected function init($dsn, $username, $password, array $options = [])
    {
        try {
            //With parameters of method scope, because if there is a exception, this object is destroyed
            parent::__construct($dsn, $username, $password, $options);
            $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['\cordillera\middlewares\db\Statement', [$this]]);
        } catch (\PDOException $e) {
            logger()->critical('DB connection failed', [
                    'dsn' => $dsn,
                    'username' => $username,
                    'password' => $password,
                    'options' => $options,
                ]);
            throw new Exception($e->getMessage(), 500, Exception::DBCONNECTION);
        }
    }
1045775
public static function create($params, $opts = null)
    {
        $type = Util\Util::classType($params['type']);
        $url = self::classUrl() . "/$type";
        list($resp, $usedOpts) = self::request(self::METHOD_POST, $url, $params, $opts);
        return Util\Util::arrayToObject($resp, $usedOpts);
    }
6579
public function read(array $opts) {
        $statement = array_merge_recursive(parent::read($opts), [
            'verb' => [
                'id' => 'http://adlnet.gov/expapi/verbs/attended',
                'display' => $this->readVerbDisplay($opts),
            ],
            'object' => [
                'id' => $opts['session_url'],
                'definition' => [
                    'type' => $opts['session_type'],
                    'name' => [
                        $opts['context_lang'] => $opts['session_name'],
                    ],
                    'description' => [
                        $opts['context_lang'] => $opts['session_description'],
                    ]
                ],
            ],
            'result' => [
                'duration' => $opts['attempt_duration'],
                'completion' => $opts['attempt_completion']
            ],
            'context' => [
                'instructor' => $this->readUser($opts, 'user'),
                'contextActivities' => [
                    'grouping' => [
                        $this->readCourse($opts),
                    ],
                    'parent' => [
                        $this->readModule($opts),
                    ],
                    'category' => [
                        [
                            'id' => 'http://xapi.trainingevidencesystems.com/recipes/attendance/0_0_1#simple',
                            'definition' => [
                                'type' => 'http://id.tincanapi.com/activitytype/recipe'
                            ]
                        ]
                    ],
                ],
            ],
        ]);

        // Overwrite actor, don't merge it. 
        $statement['actor'] = $this->readUser($opts, 'attendee');

        return $statement;
    }
1216044
private static function set_header_into_opt($header, $value, &$opt) {
		if (isset ( $opt [self::HEADERS] )) {
			if (! is_array ( $opt [self::HEADERS] )) {
				trigger_error ( 'Invalid $opt[\'headers\'], please check.' );
				throw new BCS_Exception ( 'Invalid $opt[\'headers\'], please check.', - 1 );
			}
		} else {
			$opt [self::HEADERS] = array ();
		}
		$opt [self::HEADERS] [$header] = $value;
	}
951818
public function read(array $opts) {
        $instructor = parent::read($opts)['actor'];
        $statement =  array_merge_recursive(parent::read($opts), [
            'verb' => [
                'id' => 'http://adlnet.gov/expapi/verbs/scored',
                'display' => $this->readVerbDisplay($opts),
            ],
            'result' => [
                'score' => [
                    'raw' => $opts['grade_score_raw'],
                    'min' => $opts['grade_score_min'],
                    'max' => $opts['grade_score_max'],
                    'scaled' => $opts['grade_score_scaled']
                ],
                'completion' => $opts['grade_completed'],
                'response' => $opts['grade_comment']
            ],
            'object' => $this->readModule($opts),
            'context' => [
                'contextActivities' => [
                    'parent' => [
                        $this->readCourse($opts),
                    ],
                ],
                'instructor' => $instructor
            ],
        ]);

        //Excluded from array merge to make sure that the actor is overwritten e.g. if a different IFI is used. 
        $statement['actor'] = [
            'objectType' => 'Agent',
            'name' => $opts['graded_user_name'],
            'account' => [
                'homePage' => $opts['graded_user_url'],
                'name' => $opts['graded_user_id'],
            ],
        ];

        if (!is_null($opts['grade_success'])) {
            $statement['result']['success'] = $opts['grade_success'];
        }

        return $statement;
    }
792315
public function createData($path, $body = "", array $opts = array())
    {
        $headers = array('Content-Type' => 'application/json');
        return empty($body)
            ? $this->_processResponse($this->http->post($this->_getApiPath($opts) . $path, $headers))
            : $this->_processResponse(
                $this->http->post(
                    $this->_getApiPath($opts) . $path,
                    $headers,
                    $body
                )
            );
    }
1325740
protected function loadCliOptions(array $opts)
    {
        $map = [
            'c' => 'conf_file',   // config file
            's' => 'servers', // server address

            'n' => 'workerNum',  // worker number do all tasks
            'u' => 'user',
            'g' => 'group',

            'l' => 'logFile',
            'p' => 'pidFile',

            'r' => 'maxRunTasks', // max run tasks for a worker
            'x' => 'maxLifetime',// max lifetime for a worker
            't' => 'timeout',
        ];

        // show help
        if (isset($opts['h']) || isset($opts['help'])) {
            $this->showHelp();
        }
        // show version
        if (isset($opts['V']) || isset($opts['version'])) {
            $this->showVersion();
        }

        // load opts values to config
        foreach ($map as $k => $v) {
            if (isset($opts[$k]) && $opts[$k]) {
                $this->config[$v] = $opts[$k];
            }
        }

        // load Custom Config File
        if ($file = $this->config['conf_file']) {
            if (!file_exists($file)) {
                $this->showHelp("Custom config file {$file} not found.");
            }

            $config = require $file;
            $this->setConfig($config);
        }

        // watch modify
        if (isset($opts['w']) || isset($opts['watch'])) {
            $this->config['watch_modify'] = $opts['w'];
        }

        // run as daemon
        if (isset($opts['d']) || isset($opts['daemon'])) {
            $this->config['daemon'] = true;
        }

        // no test
        if (isset($opts['no-test'])) {
            $this->config['no_test'] = true;
        }

        // only added tasks
        if (isset($opts['tasks']) && ($added = trim($opts['tasks'], ','))) {
            $this->config['added_tasks'] = strpos($added, ',') ? explode(',', $added) : [$added];
        }

        if (isset($opts['v'])) {
            $opts['v'] = $opts['v'] === true ? '' : $opts['v'];

            switch ($opts['v']) {
                case '':
                    $this->config['logLevel'] = self::LOG_INFO;
                    break;
                case 'v':
                    $this->config['logLevel'] = self::LOG_PROC_INFO;
                    break;
                case 'vv':
                    $this->config['logLevel'] = self::LOG_WORKER_INFO;
                    break;
                case 'vvv':
                    $this->config['logLevel'] = self::LOG_DEBUG;
                    break;
                case 'vvvv':
                    $this->config['logLevel'] = self::LOG_CRAZY;
                    break;
                default:
                    // $this->config['logLevel'] = self::LOG_INFO;
                    break;
            }
        }
    }
1221497
private function setUserOptions($options)
    {
        if (is_array($options)) {
            foreach ($options as $property => $value) {
                $this->$property = $value;
            }
        }
    }
772896
function isOwner($user) {
        if($user instanceof \CharlotteDunois\Yasmin\Models\User || $user instanceof \CharlotteDunois\Yasmin\Models\GuildMember) {
            $user = $user->id;
        }
        
        return (\in_array($user, $this->options['owners']));
    }
362148
public function getUser($accessToken = null, array $options = [])
    {
        if (null === $accessToken) {
            $options['access_token'] = $this->blizzardClient->getAccessToken();
        } else {
            $options['access_token'] = $accessToken;
        }

        return $this->request('/account/user', $options);
    }
1058020
public function retrieveData($path, array $params = array(), array $opts = array())
    {
        return empty($params)
            ? $this->_processResponse($this->http->get($this->_getApiPath($opts) . $path))
            : $this->_processResponse(
                $this->http->get($this->_getApiPath($opts) . $path . "?" . http_build_query($params, '', '&'))
            );
    }
418887
public function defineOptions(array $defaults, array $userOptions = null, $recursive = false)
    {

        $this->options = $defaults;

        if ($userOptions)
            $this->mergeOptions($userOptions, $recursive);
    }