Reads data for an event.
@param [String => Mixed] $opts
@return [String => Mixed]
@override ModuleViewed
348910
public function read(array $opts) {

        $sessionName = 'Session '.$opts['session']->id.' of '.$opts['module']->name;
        return [array_merge(parent::read($opts)[0], [
            'recipe' => 'training_session_enrol',
            'session_url' => $opts['session']->url,
            'session_name' => $sessionName,
            'session_description' => $sessionName,
            'session_type' => 'http://activitystrea.ms/schema/1.0/event',
        ])];
    }
792196
public function generate(array $opts = array())
    {
        $this->_guid = date('YmdHis')
            . '.'
            . (isset($opts['prefix']) ? $opts['prefix'] . '.' : '')
            . strval(new Horde_Support_Randomid())
            . '@'
            . (isset($opts['server']) ? $opts['server'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'));
    }
149043
public static function upcoming($params = null, $opts = null)
    {
        $url = static::classUrl() . '/upcoming';
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
        $obj = Util\Util::convertToStripeObject($response->json, $opts);
        $obj->setLastResponse($response);
        return $obj;
    }
905501
public static function curl(array $opts = [])
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        foreach ($opts as $key => $value) {
            curl_setopt($ch, $key, $value);
        }

        $response = curl_exec($ch);
        $request = $response !== false;
        if (!$request) {
            $response = curl_getinfo($ch);
        }
        curl_close($ch);

        return compact('request', 'response');
    }
605667
function readStream(opts) {
    return db.createReadStream(ns.encodeRange(opts)).pipe(decodeStream(opts))
  }
366771
public function parseFeedback($opts){
        $parsedQuestions = [];
        $scoreMax = 0;
        $scoreRaw = 0;

        foreach ($opts['questions'] as $item => $question) {
            // Find the response to the current question
            $currentResponse = null;
            foreach ($opts['attempt']->responses as $responseId => $response) {
                if (!empty($response->item) && $response->item == $item) {
                    $currentResponse = $response;
                }
            }

            if (is_null($currentResponse)) {
                // Perhaps a label or the learner did not answer this question - don't add to the array.
                break;
            }

            // Parse the current question
            $parsedQuestion = (object)[
                'question' => $question,
                'options' => $this->parseQuestionPresentation($question->presentation, $question->typ),
                'score' => (object) [
                    'max' => 0,
                    'raw' => 0
                ],
                'response' => null
            ];

            $parsedQuestion->response = $currentResponse->id;

            // Add scores and response
            foreach ($parsedQuestion->options as $optionIndex => $option) {
                if (isset($option->value) && $option->value > $parsedQuestion->score->max) {
                    $parsedQuestion->score->max = $option->value;
                }

                // Find the option the learner selected
                if ($optionIndex == $currentResponse->id){
                    if (isset($option->value)) {
                        $parsedQuestion->score->raw = $option->value;
                    }
                }
            }

            $scoreMax += $parsedQuestion->score->max;
            $scoreRaw += $parsedQuestion->score->raw;

            if ($parsedQuestion->score->max == 0) {
                $parsedQuestion->score->max = null;
                $parsedQuestion->score->raw = null;
            }
            else {
                $parsedQuestion->score->min = 0;
                $parsedQuestion->score->scaled = $parsedQuestion->score->raw / $parsedQuestion->score->max;
            }

            array_push(
                $parsedQuestions, 
                $parsedQuestion
            );
        }

        $scoreMin = null;
        $scoreScaled = null;
        if ($scoreMax == 0){
            $scoreMax = null;
            $scoreRaw = null;
        }
        else {
            $scoreScaled = $scoreRaw / $scoreMax;
            $scoreMin = 0;
        }

        return (object)[
            'questions' => $parsedQuestions,
            'score' => (object) [
                'max' => $scoreMax,
                'raw' => $scoreRaw,
                'min' => $scoreMin,
                'scaled' => $scoreScaled
            ] 
        ];
    }
298738
private function getInfo( $opt = false )
   {

      if ( $opt )
      {
         $info = \curl_getinfo( $this->_handle, $opt );
      }
      else
      {
         $info = \curl_getinfo( $this->_handle );
      }

      return $info;

   }
453103
public function render($opts = []) {
		if ($this->options['render'] && method_exists($this->form, $this->options['render'])) {
			return $this->form->{$this->options['render']}($this, $opts);
		} else {
			$html = $this->renderWidget($opts);
			if ($this->options['wrapper'] && method_exists($this->form, $this->options['wrapper'])) {
				$html = $this->form->{$this->options['wrapper']}($html, $this, $opts);
			}

			return $html;
		}
	}
1322240
public static function parse($opts)
    {
        if ($opts instanceof self) {
            return $opts;
        }
        if (is_null($opts)) {
            return new Options(null, array());
        }
        if (is_array($opts)) {
            $key = null;
            if (array_key_exists('api_key', $opts)) {
                $key = $opts['api_key'];
                unset($opts['api_key']);
            }
            return new Options($key, $opts);
        } else {
            throw new Error\InvalidOption('Options have to be array.');
        }
    }
1361718
public function getError($error, $opts=array()) {
		if (is_array($error) && isset($error['filter'])) {
			return $this->getErrorMessage($error['filter'], $error+$opts);
		} elseif (is_int($error)) {
			return $this->getErrorMessage($error, $opts);
		} else {
			return $this->getErrorMessage(0, $opts);
		}
	}
1102213
public function select($opts)
    {
        $objs = array();
        
        if (is_array($opts)) {
            foreach ($this as $obj) {
                foreach ($opts as $prop => $cond) {
                    if (!$obj->$prop || $obj->$prop != $cond)
                        continue;
                    $objs[] = $obj;
                }
            }
        } elseif ($opts instanceof Closure) {
            foreach ($this->members() as $obj) {
                $opts($obj) && $objs[] = $obj;
            }
        }
        
        return new self($objs);
    }
257422
public static function readSafe($message = null, bool $nl = false, array $opts = []): string
    {
        if ($message) {
            self::write($message, $nl);
        }

        $opts = \array_merge([
            'length' => 1024,
            'stream' => \STDIN,
            'allowTags' => null,
        ], $opts);

        return \trim(\fgetss($opts['stream'], $opts['length'], $opts['allowTags']));
    }
727852
function _Options($opts)
	{
		if (!is_array($opts)) return array();
		$newopts = array();
		foreach($opts as $k => $v) {
			if (is_numeric($k)) $newopts[strtoupper($v)] = $v;
			else $newopts[strtoupper($k)] = $v;
		}
		return $newopts;
	}
743675
protected function curl_raw ( $opts = array() )
	{
		if (isset($opts[CURLOPT_HTTPHEADER]))
		{
			$header = $opts[CURLOPT_HTTPHEADER];
		}
		else
		{
			$header = array();
		}

		$ch 		= curl_init();
		$method		= $this->getMethod();
		$url		= $this->getRequestUrl();
		$header[]	= $this->getAuthorizationHeader();
		$query		= $this->getQueryString();
		$body		= $this->getBody();

		$has_content_type = false;
		foreach ($header as $h)
		{
			if (strncasecmp($h, 'Content-Type:', 13) == 0)
			{
				$has_content_type = true;
			}
		}

		if (!is_null($body))
		{
			if ($method == 'TRACE')
			{
				throw new OAuthException2('A body can not be sent with a TRACE operation');
			}

			// PUT and POST allow a request body
			if (!empty($query))
			{
				$url .= '?'.$query;
			}

			// Make sure that the content type of the request is ok
			if (!$has_content_type)
			{
				$header[]         = 'Content-Type: application/octet-stream';
				$has_content_type = true;
			}

			// When PUTting, we need to use an intermediate file (because of the curl implementation)
			if ($method == 'PUT')
			{
				/*
				if (version_compare(phpversion(), '5.2.0') >= 0)
				{
					// Use the data wrapper to create the file expected by the put method
					$put_file = fopen('data://application/octet-stream;base64,'.base64_encode($body));
				}
				*/

				$put_file = @tmpfile();
				if (!$put_file)
				{
					throw new OAuthException2('Could not create tmpfile for PUT operation');
				}
				fwrite($put_file, $body);
				fseek($put_file, 0);

				curl_setopt($ch, CURLOPT_PUT, 		  true);
  				curl_setopt($ch, CURLOPT_INFILE, 	  $put_file);
  				curl_setopt($ch, CURLOPT_INFILESIZE,  strlen($body));
			}
			else
			{
				curl_setopt($ch, CURLOPT_POST,		  true);
				curl_setopt($ch, CURLOPT_POSTFIELDS,  $body);
  			}
		}
		else
		{
			// a 'normal' request, no body to be send
			if ($method == 'POST')
			{
				if (!$has_content_type)
				{
					$header[]         = 'Content-Type: application/x-www-form-urlencoded';
					$has_content_type = true;
				}

				curl_setopt($ch, CURLOPT_POST, 		  true);
				curl_setopt($ch, CURLOPT_POSTFIELDS,  $query);
			}
			else
			{
				if (!empty($query))
				{
					$url .= '?'.$query;
				}
				if ($method != 'GET')
				{
					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
				}
			}
		}

		curl_setopt($ch, CURLOPT_HTTPHEADER,	 $header);
		curl_setopt($ch, CURLOPT_USERAGENT,		 'anyMeta/OAuth 1.0 - ($LastChangedRevision: 174 $)');
		curl_setopt($ch, CURLOPT_URL, 			 $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_HEADER, 		 true);
		curl_setopt($ch, CURLOPT_TIMEOUT, 		 30);

		foreach ($opts as $k => $v)
		{
			if ($k != CURLOPT_HTTPHEADER)
			{
				curl_setopt($ch, $k, $v);
			}
		}

		$txt = curl_exec($ch);
		if ($txt === false) {
			$error = curl_error($ch);
			curl_close($ch);
			throw new OAuthException2('CURL error: ' . $error);
		}
		curl_close($ch);

		if (!empty($put_file))
		{
			fclose($put_file);
		}

		// Tell the logger what we requested and what we received back
		$data = $method . " $url\n".implode("\n",$header);
		if (is_string($body))
		{
			$data .= "\n\n".$body;
		}
		else if ($method == 'POST')
		{
			$data .= "\n\n".$query;
		}

		OAuthRequestLogger::setSent($data, $body);
		OAuthRequestLogger::setReceived($txt);

		return $txt;
	}
549156
protected static function all($params, $opts)
    {
        $url = self::classUrl();
        list($resp, $usedOpts) = self::request(self::METHOD_GET, $url, $params, $opts);
        $resp = Util\Util::arrayToObject($resp, $usedOpts);
        // Check the class name of the result because all feature must get the instance of Collection class.
        if (!is_a($resp, 'RpayLite\\Collection')) {
            $class = get_class($resp);
            $msg =  "'RpayLite\\Collection' is expected but '$class' is returned.";
            throw new Error\Api($msg);
        }
        return $resp;
    }
568924
public function mount(array $opts) {
		if (!isset($opts['path']) || $opts['path'] === '') {
			return $this->setError('Path undefined.');;
		}
		
		$this->options = array_merge($this->options, $opts);
		$this->id = $this->driverId.(!empty($this->options['id']) ? $this->options['id'] : elFinder::$volumesCnt++).'_';
		$this->root = $this->normpathCE($this->options['path']);
		$this->separator = isset($this->options['separator']) ? $this->options['separator'] : DIRECTORY_SEPARATOR;
		
		// set server encoding
		if (!empty($this->options['encoding']) && strtoupper($this->options['encoding']) !== 'UTF-8') {
			$this->encoding = $this->options['encoding'];
		} else {
			$this->encoding = null;
		}
		
		$argInit = ($_SERVER['REQUEST_METHOD'] === 'POST')? !empty($_POST['init']) : !empty($_GET['init']);
		
		// session cache
		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
		}
		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
		
		// default file attribute
		$this->defaults = array(
			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
		);

		// root attributes
		$this->attributes[] = array(
			'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR).'$~',
			'locked'  => true,
			'hidden'  => false
		);
		// set files attributes
		if (!empty($this->options['attributes']) && is_array($this->options['attributes'])) {
			
			foreach ($this->options['attributes'] as $a) {
				// attributes must contain pattern and at least one rule
				if (!empty($a['pattern']) || count($a) > 1) {
					$this->attributes[] = $a;
				}
			}
		}

		if (!empty($this->options['accessControl']) && is_callable($this->options['accessControl'])) {
			$this->access = $this->options['accessControl'];
		}
		
		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
		$this->yesterday = $this->today-86400;
		
		// debug($this->attributes);
		if (!$this->init()) {
			return false;
		}
		
		// check some options is arrays
		$this->uploadAllow = isset($this->options['uploadAllow']) && is_array($this->options['uploadAllow'])
			? $this->options['uploadAllow']
			: array();
			
		$this->uploadDeny = isset($this->options['uploadDeny']) && is_array($this->options['uploadDeny'])
			? $this->options['uploadDeny']
			: array();

		if (is_string($this->options['uploadOrder'])) { // telephat_mode on, compatibility with 1.x
			$parts = explode(',', isset($this->options['uploadOrder']) ? $this->options['uploadOrder'] : 'deny,allow');
			$this->uploadOrder = array(trim($parts[0]), trim($parts[1]));
		} else { // telephat_mode off
			$this->uploadOrder = $this->options['uploadOrder'];
		}
			
		if (!empty($this->options['uploadMaxSize'])) {
			$size = ''.$this->options['uploadMaxSize'];
			$unit = strtolower(substr($size, strlen($size) - 1));
			$n = 1;
			switch ($unit) {
				case 'k':
					$n = 1024;
					break;
				case 'm':
					$n = 1048576;
					break;
				case 'g':
					$n = 1073741824;
			}
			$this->uploadMaxSize = intval($size)*$n;
		}
			
		$this->disabled = isset($this->options['disabled']) && is_array($this->options['disabled'])
			? $this->options['disabled']
			: array();
		
		$this->cryptLib   = $this->options['cryptLib'];
		$this->mimeDetect = $this->options['mimeDetect'];

		// find available mimetype detect method
		$type = strtolower($this->options['mimeDetect']);
		$type = preg_match('/^(finfo|mime_content_type|internal|auto)$/i', $type) ? $type : 'auto';
		$regexp = '/text\/x\-(php|c\+\+)/';
	
		if (($type == 'finfo' || $type == 'auto') 
		&& class_exists('finfo')) {
			$tmpFileInfo = @explode(';', @finfo_file(finfo_open(FILEINFO_MIME), __FILE__));
		} else {
			$tmpFileInfo = false;
		}
	
		if ($tmpFileInfo && preg_match($regexp, array_shift($tmpFileInfo))) {
			$type = 'finfo';
			$this->finfo = finfo_open(FILEINFO_MIME);
		} elseif (($type == 'mime_content_type' || $type == 'auto') 
		&& function_exists('mime_content_type')
		&& preg_match($regexp, array_shift(explode(';', mime_content_type(__FILE__))))) {
			$type = 'mime_content_type';
		} else {
			$type = 'internal';
		}
		$this->mimeDetect = $type;

		// load mimes from external file for mimeDetect == 'internal'
		// based on Alexey Sukhotin idea and patch: http://elrte.org/redmine/issues/163
		// file must be in file directory or in parent one 
		if ($this->mimeDetect == 'internal' && !self::$mimetypesLoaded) {
			self::$mimetypesLoaded = true;
			$this->mimeDetect = 'internal';
			$file = false;
			if (!empty($this->options['mimefile']) && file_exists($this->options['mimefile'])) {
				$file = $this->options['mimefile'];
			} elseif (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'mime.types')) {
				$file = dirname(__FILE__).DIRECTORY_SEPARATOR.'mime.types';
			} elseif (file_exists(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'mime.types')) {
				$file = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'mime.types';
			}

			if ($file && file_exists($file)) {
				$mimecf = file($file);

				foreach ($mimecf as $line_num => $line) {
					if (!preg_match('/^\s*#/', $line)) {
						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
							if (!isset(self::$mimetypes[$mime[$i]])) {
								self::$mimetypes[$mime[$i]] = $mime[0];
							}
						}
					}
				}
			}
		}

		$this->rootName = empty($this->options['alias']) ? $this->basenameCE($this->root) : $this->options['alias'];

		// This get's triggered if $this->root == '/' and alias is empty.
		// Maybe modify _basename instead?
		if ($this->rootName === '') $this->rootName = $this->separator;

		$root = $this->stat($this->root);
		
		if (!$root) {
			return $this->setError('Root folder does not exists.');
		}
		if (!$root['read'] && !$root['write']) {
			return $this->setError('Root folder has not read and write permissions.');
		}
		
		// debug($root);
		
		if ($root['read']) {
			// check startPath - path to open by default instead of root
			if ($this->options['startPath']) {
				$start = $this->stat($this->options['startPath']);
				if (!empty($start)
				&& $start['mime'] == 'directory'
				&& $start['read']
				&& empty($start['hidden'])
				&& $this->inpathCE($this->options['startPath'], $this->root)) {
					$this->startPath = $this->options['startPath'];
					if (substr($this->startPath, -1, 1) == $this->options['separator']) {
						$this->startPath = substr($this->startPath, 0, -1);
					}
				}
			}
		} else {
			$this->options['URL']     = '';
			$this->options['tmbURL']  = '';
			$this->options['tmbPath'] = '';
			// read only volume
			array_unshift($this->attributes, array(
				'pattern' => '/.*/',
				'read'    => false
			));
		}
		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
		$this->URL      = $this->options['URL'];
		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
			$this->URL .= '/';
		}

		$this->tmbURL   = !empty($this->options['tmbURL']) ? $this->options['tmbURL'] : '';
		if ($this->tmbURL && preg_match("|[^/?&=]$|", $this->tmbURL)) {
			$this->tmbURL .= '/';
		}
		
		$this->nameValidator = !empty($this->options['acceptedName']) && (is_string($this->options['acceptedName']) || is_callable($this->options['acceptedName']))
			? $this->options['acceptedName']
			: '';

		$this->_checkArchivers();
		// manual control archive types to create
		if (!empty($this->options['archiveMimes']) && is_array($this->options['archiveMimes'])) {
			foreach ($this->archivers['create'] as $mime => $v) {
				if (!in_array($mime, $this->options['archiveMimes'])) {
					unset($this->archivers['create'][$mime]);
				}
			}
		}
		
		// manualy add archivers
		if (!empty($this->options['archivers']['create']) && is_array($this->options['archivers']['create'])) {
			foreach ($this->options['archivers']['create'] as $mime => $conf) {
				if (strpos($mime, 'application/') === 0 
				&& !empty($conf['cmd']) 
				&& isset($conf['argc']) 
				&& !empty($conf['ext'])
				&& !isset($this->archivers['create'][$mime])) {
					$this->archivers['create'][$mime] = $conf;
				}
			}
		}
		
		if (!empty($this->options['archivers']['extract']) && is_array($this->options['archivers']['extract'])) {
			foreach ($this->options['archivers']['extract'] as $mime => $conf) {
				if (strpos($mime, 'application/') === 0
				&& !empty($conf['cmd']) 
				&& isset($conf['argc']) 
				&& !empty($conf['ext'])
				&& !isset($this->archivers['extract'][$mime])) {
					$this->archivers['extract'][$mime] = $conf;
				}
			}
		}

		$this->configure();
		// echo $this->uploadMaxSize;
		// echo $this->options['uploadMaxSize'];
		return $this->mounted = true;
	}
1305592
private function extract($opts) {
    if (!empty($opts) && is_array($opts)) {
      isset($opts['query']) && $this->setQueryString($opts['query']);
      isset($opts['indexes']) && $this->addIndex($opts['indexes']);
      isset($opts['fetch_field']) && $this->addFetchFields($opts['fetch_field']);
      isset($opts['format']) && $this->setFormat($opts['format']);
      isset($opts['formula_name']) && $this->setFormulaName($opts['formula_name']);
      isset($opts['summary']) && $this->summary = $opts['summary'];
      isset($opts['start']) && $this->setStartHit($opts['start']);
      isset($opts['hits']) && $this->setHits((int) $opts['hits']);
      isset($opts['sort']) && $this->sort = $opts['sort'];
      isset($opts['filter']) && $this->addFilter($opts['filter']);
      isset($opts['aggregate']) && $this->aggregate = $opts['aggregate'];
      isset($opts['distinct']) && $this->distinct = $opts['distinct'];
      isset($opts['kvpair']) && $this->setPair($opts['kvpair']);
      isset($opts['rerankSize']) && $this->addRerankSize($opts['rerankSize']);
    }
  }