Reads data for an event.
@param [String => Mixed] $opts
@return [String => Mixed]
@override Event
5847
public function read(array $opts) {
        return array_merge(parent::read($opts), [
            'object' => $this->readModule($opts),
            'context' => [
                'contextActivities' => [
                    'grouping' => [
                        $this->readCourse($opts),
                        $this->readScormScoes($opts),
                    ],
                ],
            ],
        ]);
    }
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);
    }
978083
public function get($userid = null, $opts = array())
	{
		$this->debug->groupCollapsed(__METHOD__, $userid);
		$opts = array_merge(array(
			'localtime' => true,	// true: return formatted date/time string for user's timezone
		), $opts);
		$vals_datetime = array('createdon','lastactivity','previousactivity');
		if (is_null($userid) || $userid == $this->userid) {
			$this->debug->log('use current user');
			$user = $this->user;
		} else {
			$ignore = array( 'password' );
			$joins = array();
			foreach ($this->cfg['userForeignKeys'] as $fka) {
				if (!empty($fka['getJoin'])) {
					$joins[] = $fka['getJoin'];
				}
				if (!empty($fka['ignoreKey'])) {
					$ignore[] = $fka['userCol'];
				}
			}
			$joins = !empty($joins)
				? ' '.implode(' ', $joins)
				: '';
			$query = 'SELECT * FROM `user`'
				.' LEFT JOIN `user_auth` USING (`userid`)'
				.$joins
				.' WHERE `user`.`userid` = '.$this->db->quoteValue($userid);
			$users = $this->db->query($query)[0];
			$this->debug->table($users, 'users');
			$user = $users[0];
			foreach ($vals_datetime as $k) {
				if (isset($user[$k])) {
					$user[$k] = strtotime($user[$k]);
				}
			}
			$query = 'SELECT `right` FROM `user_rights` WHERE `userid` = '.$this->db->quoteValue($userid);
			$rights = $this->db->query($query)[0];
			foreach ($rights as $k => $a) {
				$rights[$k] = $a['right'];
			}
			$user['previousactivity'] = $user['lastactivity'];
			$user['rights'] = $rights;
			foreach ($ignore as $k) {
				unset($user[$k]);
			}
		}
		if ($opts['localtime']) {
			foreach ($vals_datetime as $k) {
				$user[$k] = $this->datetimeLocal($user[$k]);
			}
		}
		$this->debug->log('user', $user);
		$this->debug->groupEnd();
		return $user;
	}
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']);
    }
  }
362603
public static function all($params, $opts = null)
    {
        $list = parent::all($params, $opts);
        $ntList = new NotificationCollection();
        $ntList->install($list->values, $list->opts);
        return $ntList;
    }
1221905
public function read($offset = null, $limit = 10)
    {
        if ($offset === null) {
            $offset = (((int) (($this->getLastRowId() - 1) / $limit)) * $limit) + 1;
        }

        $sql = 'SELECT * FROM ' . $this->table
            . ' WHERE id >= ?'
            . ' ORDER BY id ASC'
            . ' LIMIT ?';

        $events = [];

        $stmt = $this->connection->prepare($sql);
        $stmt->bindValue(1, $offset, Type::INTEGER);
        $stmt->bindValue(2, $limit, Type::INTEGER);
        $stmt->execute();

        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $events[$row['id']] = $this->fromArray($row);
        }

        return $events;
    }
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;
    }
598824
public function cakephpPlugins($opts = ['format' => 'table', 'fields' => ''])
    {
        $result = $this->taskCakephpPlugins()
            ->run();
        if (!$result->wasSuccessful()) {
            $this->exitError("Failed to run the command");
        }

        return new PropertyList($result->getData()['data']);
    }
113489
public static function retrieve($id = null, $opts = null)
    {
        if (!$opts && is_string($id) && substr($id, 0, 3) === 'sk_') {
            $opts = $id;
            $id = null;
        }
        return self::_retrieve($id, $opts);
    }
295404
public function insertEvent($event, $optParams = []): Google_Service_Calendar_Event
    {
        if ($event instanceof Event) {
            $event = $event->googleEvent;
        }

        return $this->calendarService->events->insert($this->calendarId, $event, $optParams);
    }
29343
final protected function curlFilterOpts(array &$opts = array())
	{
		$keys = array_keys($opts);
		$values = array_values($opts);
		array_filter($keys, [$this, 'curlFilterOpt']);
		foreach (array_diff(array_keys($opts), $keys) as $key) {
			unset($values[array_search($key, array_keys($opts))]);
		}
		$opts = array_combine($keys, $values);
	}
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;
	}
675347
private function getFillOpts($opts)
	{
		$this->debug->group(__CLASS__.'->'.__FUNCTION__);
		$arrayUtil = new ArrayUtil();
		$opts = $arrayUtil->mergeDeep(array(
			'output_file'	=> 'temporary',	// if null is passed, raw pdf will be returned
			'fillcolor'		=> null,		// font-color
			'checkbox_opts'	=> array(
				'fontname'		=> 'ZapfDingbats',
				'textformat'	=> 'utf16be',
				'encoding'		=> 'unicode',
				'position'		=> 'center',
				'bordercolor'	=> '#C0C0C0',	// or null
				// 'fontsize'	=> 12,
			),
			'checkbox_value'	=> "\x27\x18",
			'radio_opts'	=> array(
				'fontname'		=> 'ZapfDingbats',
				'textformat'	=> 'utf16be',
				'encoding'		=> 'unicode',
				'position'		=> 'center',
				'bordercolor'	=> '#C0C0C0',	// or null
				// 'fontsize'	=> 12,
			),
			'radio_value'	=> "\x25\xCF",
			'text_opts'		=> array(
				'bordercolor'	=> 'none',
			),
			'name_trans_func'	=> array(),			// function and parameters to transform block name
			'info' => array(),
		), $opts);
		if ($opts['output_file'] == 'temporary') {
			$temp_dir = sys_get_temp_dir();
			$opts['output_file'] = tempnam($temp_dir, 'pdf');
		}
		$this->debug->groupEnd();
		return $opts;
	}
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, '', '&'))
            );
    }
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;
    }
124761
public static function constructFrom($val, $opts = null)
    {
        $obj = new static(isset($val['id']) ? $val['id'] : null);
        $obj->install($val, $opts);
        return $obj;
    }
970118
private function parseCliOptions(array $opts = [])
    {
        $cliOpts = getopt('chvrs:', [
            'help',
            'version',
            'random',
            'suite:',
            'coverage',
        ]);

        if (isset($cliOpts['help']) || isset($cliOpts['h'])) {
            $this->runner->output->help();
            exit;
        }

        if (isset($cliOpts['version']) || isset($cliOpts['v'])) {
            $this->runner->output->version();
            exit;
        }

        if (isset($cliOpts['random']) || isset($cliOpts['r'])) {
            $opts['random'] = true;
        }

        if (isset($cliOpts['suite']) || isset($cliOpts['s'])) {
            $opts['suite'] = $cliOpts['suite'] ?: $cliOpts['s'];
        }

        if (isset($cliOpts['coverage']) || isset($cliOpts['c'])) {
            $opts['coverage']['enable'] = true;
        }

        return $opts;
    }