Fetches a resource link record that is associated with a ToolConsumer.

@param ToolConsumer $consumer
@return ResourceLink
320906
public function get_resourcelink_from_consumer(ToolConsumer $consumer) {
        global $DB;

        $resourcelink = null;
        if ($resourcelinkrecord = $DB->get_record($this->resourcelinktable, ['consumerid' => $consumer->getRecordId()],
            'ltiresourcelinkkey')) {
            $resourcelink = ResourceLink::fromConsumer($consumer, $resourcelinkrecord->ltiresourcelinkkey);
        }

        return $resourcelink;
    }
715615
public function get(Builder $builder)
    {
        return $this->map(
            $builder, $this->search($builder), $builder->model
        );
    }
425985
private function interactiveConsumersControlPanel_loadConsumer($key = null)
    {
        /*
         * load an existing consumer (if we have a consumer_key) or create a blank
         * that we will fill in
         */
        $consumer = new LTI_Tool_Consumer(
            (empty($key) ? LTI_Data_Connector::getRandomString(32) : $key),
            $this->getToolProvider()->data_connector,
            true // wicked confusing _not_ to autoenable
        );

        /* pre-fill secret if not editing an existing consumer */
        if (empty($key)) {
            $consumer->secret = LTI_Data_Connector::getRandomString(32);
        }

        return $consumer;
    }
1123864
public function getResource():ResourceInterface
    {
        $this->manager->parseIncludes($this->relations);
        $transformer = $this->resource->getTransformer();

        if ($transformer instanceof Transformer && $transformer->allRelationsAllowed()) {
            $this->resource->setTransformer($transformer->setRelations($this->manager->getRequestedIncludes()));
        }

        return $this->resource->setMeta($this->meta);
    }
678105
public function findOauthConsumerResource($consumer_key)
	{
		$returnValue = null;

		$class = $this->getClass(self::CLASS_URI_OAUTH_CONSUMER);
		$instances = $class->searchInstances(array(self::PROPERTY_OAUTH_KEY => $consumer_key), array('like' => false, 'recursive' => true));
		if (count($instances) == 0) {
			throw new \tao_models_classes_oauth_Exception('No Credentials for consumer key '.$consumer_key);
		}
		if (count($instances) > 1) {
			throw new \tao_models_classes_oauth_Exception('Multiple Credentials for consumer key '.$consumer_key);
		}
		$returnValue	= current($instances);

		return $returnValue;
	}
409721
public Link<S, T> to(Consumer<S, T> consumer) {
		this.consumer = consumer;
		return this;
	}
211347
public function get_resourcelink_from_context(Context $context) {
        global $DB;

        $resourcelink = null;
        if ($resourcelinkrecord = $DB->get_record($this->resourcelinktable, ['contextid' => $context->getRecordId()],
            'ltiresourcelinkkey')) {
            $resourcelink = ResourceLink::fromContext($context, $resourcelinkrecord->ltiresourcelinkkey);
        }

        return $resourcelink;
    }
655704
private function get_consumer(&$request) {
    $consumer_key = @$request->get_parameter("oauth_consumer_key");
    if (!$consumer_key) {
      throw new OAuthException("Invalid consumer key");
    }

    $consumer = $this->data_store->lookup_consumer($consumer_key);
    if (!$consumer) {
      throw new OAuthException("Invalid consumer");
    }

    return $consumer;
  }
440637
public function saveToolConsumer($consumer) {
        global $DB;

        $key = $consumer->getKey();
        $key256 = DataConnector::getConsumerKey($key);
        if ($key === $key256) {
            $key = null;
        }
        $protected = ($consumer->protected) ? 1 : 0;
        $enabled = ($consumer->enabled) ? 1 : 0;
        $profile = (!empty($consumer->profile)) ? json_encode($consumer->profile) : null;
        $settingsvalue = serialize($consumer->getSettings());
        $now = time();
        $consumer->updated = $now;
        $data = [
            'consumerkey256' => $key256,
            'consumerkey' => $key,
            'name' => $consumer->name,
            'secret' => $consumer->secret,
            'ltiversion' => $consumer->ltiVersion,
            'consumername' => $consumer->consumerName,
            'consumerversion' => $consumer->consumerVersion,
            'consumerguid' => $consumer->consumerGuid,
            'profile' => $profile,
            'toolproxy' => $consumer->toolProxy,
            'settings' => $settingsvalue,
            'protected' => $protected,
            'enabled' => $enabled,
            'enablefrom' => $consumer->enableFrom,
            'enableuntil' => $consumer->enableUntil,
            'lastaccess' => $consumer->lastAccess,
            'updated' => $consumer->updated,
        ];

        $id = $consumer->getRecordId();

        if (empty($id)) {
            $consumer->created = $now;
            $data['created'] = $consumer->created;
            $id = $DB->insert_record($this->consumertable, (object) $data);
            if ($id) {
                $consumer->setRecordId($id);
                return true;
            }
        } else {
            $data['id'] = $id;
            return $DB->update_record($this->consumertable, (object) $data);
        }

        return false;
    }
815841
@Override
    public String getConsumerSetLabel()
    {
        String consumerSetLabel = null;
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "getConsumerSetLabel");
        }

        consumerSetLabel = _consumerKey.getConsumerSet().getLabel();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.exit(tc, "getConsumerSetLabel", consumerSetLabel);
        }

        return consumerSetLabel;
    }
1087358
public ConsumerDispatcher getConsumerDispatcher() 
  {
    if (tc.isEntryEnabled()) 
    {
      SibTr.entry(tc, "getConsumerDispatcher");
      SibTr.exit(tc, "getConsumerDispatcher", consumerDispatcher);	
    }
    return consumerDispatcher;
  }
133878
@Override
    public ConsumerManager getConsumerManager()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getConsumerManager");

        ConsumerManager manager = (ConsumerManager) getOutputHandler();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "getConsumerManager", manager);
        return manager;
    }
850520
public function getConsumer()
    {

        if (is_null($this->consumer)) {
            $this->consumer = ToolConsumer::fromRecordId($this->consumerId, $this->getDataConnector());
        }

        return $this->consumer;

    }
411446
public function saveToolConsumer($consumer)
    {

        $id = $consumer->getRecordId();
        $key = $consumer->getKey();
        $key256 = DataConnector::getConsumerKey($key);
        if ($key === $key256) {
            $key = null;
        }
        $protected = ($consumer->protected) ? 1 : 0;
        $enabled = ($consumer->enabled)? 1 : 0;
        $profile = (!empty($consumer->profile)) ? json_encode($consumer->profile) : null;
        $settingsValue = serialize($consumer->getSettings());
        $time = time();
        $now = date("{$this->dateFormat} {$this->timeFormat}", $time);
        $from = null;
        if (!is_null($consumer->enableFrom)) {
            $from = date("{$this->dateFormat} {$this->timeFormat}", $consumer->enableFrom);
        }
        $until = null;
        if (!is_null($consumer->enableUntil)) {
            $until = date("{$this->dateFormat} {$this->timeFormat}", $consumer->enableUntil);
        }
        $last = null;
        if (!is_null($consumer->lastAccess)) {
            $last = date($this->dateFormat, $consumer->lastAccess);
        }
        if (empty($id)) {
            $sql = sprintf("INSERT INTO {$this->dbTableNamePrefix}" . DataConnector::CONSUMER_TABLE_NAME . ' (consumer_key256, consumer_key, name, ' .
                           'secret, lti_version, consumer_name, consumer_version, consumer_guid, profile, tool_proxy, settings, protected, enabled, ' .
                           'enable_from, enable_until, last_access, created, updated) ' .
                           'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, %s, %s, %s, %s, %s)',
                           DataConnector::quoted($key256), DataConnector::quoted($key), DataConnector::quoted($consumer->name),
                           DataConnector::quoted($consumer->secret), DataConnector::quoted($consumer->ltiVersion),
                           DataConnector::quoted($consumer->consumerName), DataConnector::quoted($consumer->consumerVersion), DataConnector::quoted($consumer->consumerGuid),
                           DataConnector::quoted($profile), DataConnector::quoted($consumer->toolProxy), DataConnector::quoted($settingsValue),
                           $protected, $enabled, DataConnector::quoted($from), DataConnector::quoted($until), DataConnector::quoted($last),
                           DataConnector::quoted($now), DataConnector::quoted($now));
        } else {
            $sql = sprintf("UPDATE {$this->dbTableNamePrefix}" . DataConnector::CONSUMER_TABLE_NAME . ' SET ' .
                           'consumer_key256 = %s, consumer_key = %s, ' .
                           'name = %s, secret= %s, lti_version = %s, consumer_name = %s, consumer_version = %s, consumer_guid = %s, ' .
                           'profile = %s, tool_proxy = %s, settings = %s, ' .
                           'protected = %d, enabled = %d, enable_from = %s, enable_until = %s, last_access = %s, updated = %s ' .
                           'WHERE consumer_pk = %d',
                           DataConnector::quoted($key256), DataConnector::quoted($key),
                           DataConnector::quoted($consumer->name),
                           DataConnector::quoted($consumer->secret), DataConnector::quoted($consumer->ltiVersion),
                           DataConnector::quoted($consumer->consumerName), DataConnector::quoted($consumer->consumerVersion), DataConnector::quoted($consumer->consumerGuid),
                           DataConnector::quoted($profile), DataConnector::quoted($consumer->toolProxy), DataConnector::quoted($settingsValue),
                           $protected, $enabled,
                           DataConnector::quoted($from), DataConnector::quoted($until), DataConnector::quoted($last),
                           DataConnector::quoted($now), $consumer->getRecordId());
        }
        $ok = mysql_query($sql);
        if ($ok) {
            if (empty($id)) {
                $consumer->setRecordId(mysql_insert_id());
                $consumer->created = $time;
            }
            $consumer->updated = $time;
        }

        return $ok;

    }
775795
public function getPagination(LengthAwarePaginator $paginator, $transformer = null, $resourceKey = null)
    {
        // Append existing query parameter to pagination link
        // @see http://fractal.thephpleague.com/pagination/#including-existing-query-string-values-in-pagination-links
        $queryParams = array_diff_key($_GET, array_flip(['page']));

        foreach ($queryParams as $key => $value) {
            $paginator->appends($key, $value);
        }

        $collection = $paginator->getCollection();

        $resource = new FractalCollection(
            $collection,
            $this->getTransformer($transformer),
            $this->getResourceKey($resourceKey)
        );
        $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));

        if ($meta = $this->getMeta()) {
            $resource->setMeta($meta);
            $this->meta = [];
        }

        return $this->fractal->createData($resource)->toArray();
    }
980726
private function getResourceFileSerializer()
    {
        if ($this->resourceFileSerializer === null) {
            $this->resourceFileSerializer = new ResourceFileSerializer();
            $this->resourceFileSerializer->setServiceLocator($this->getServiceLocator());
        }

        return $this->resourceFileSerializer;
    }
549631
public function getConsumers()
    {
        // Initialise data connector
        $this->storage = AbstractStorage::getStorage($this->storage);

        return $this->storage->toolConsumerList();
    }