38    private static $LTI_VERSIONS = array(self::LTI_VERSION1, self::LTI_VERSION2);
 
   42    private static $MESSAGE_TYPES = array(
'basic-lti-launch-request' => 
'onLaunch',
 
   43                                          'ContentItemSelectionRequest' => 
'onContentItem',
 
   44                                          'ToolProxyRegistrationRequest' => 
'register');
 
   50    private static $METHOD_NAMES = array(
'basic-lti-launch-request' => 
'onLaunch',
 
   51                                         'ContentItemSelectionRequest' => 
'onContentItem',
 
   52                                         'ToolProxyRegistrationRequest' => 
'onRegister');
 
   65                                                      'custom_lineitems_url', 
'custom_results_url',
 
   66                                                      'custom_context_memberships_url');
 
   73                                                            'ext_ims_lis_basic_outcome_url', 
'ext_ims_lis_resultvalue_sourcedids',
 
   74                                                            'ext_ims_lis_memberships_id', 
'ext_ims_lis_memberships_url',
 
   75                                                            'ext_ims_lti_tool_setting', 
'ext_ims_lti_tool_setting_id', 
'ext_ims_lti_tool_setting_url',
 
   76                                                            'custom_link_setting_url',
 
   77                                                            'custom_lineitem_url', 
'custom_result_url');
 
   84                                                          'User.image' => 
'user_image',
 
   85                                                          'User.username' => 
'username',
 
   86                                                          'User.scope.mentor' => 
'role_scope_mentor',
 
   87                                                          'Membership.role' => 
'roles',
 
   88                                                          'Person.sourcedId' => 
'lis_person_sourcedid',
 
   89                                                          'Person.name.full' => 
'lis_person_name_full',
 
   90                                                          'Person.name.family' => 
'lis_person_name_family',
 
   91                                                          'Person.name.given' => 
'lis_person_name_given',
 
   92                                                          'Person.email.primary' => 
'lis_person_contact_email_primary',
 
   93                                                          'Context.id' => 
'context_id',
 
   94                                                          'Context.type' => 
'context_type',
 
   95                                                          'Context.title' => 
'context_title',
 
   96                                                          'Context.label' => 
'context_label',
 
   97                                                          'CourseOffering.sourcedId' => 
'lis_course_offering_sourcedid',
 
   98                                                          'CourseSection.sourcedId' => 
'lis_course_section_sourcedid',
 
   99                                                          'CourseSection.label' => 
'context_label',
 
  100                                                          'CourseSection.title' => 
'context_title',
 
  101                                                          'ResourceLink.id' => 
'resource_link_id',
 
  102                                                          'ResourceLink.title' => 
'resource_link_title',
 
  103                                                          'ResourceLink.description' => 
'resource_link_description',
 
  104                                                          'Result.sourcedId' => 
'lis_result_sourcedid',
 
  105                                                          'BasicOutcome.url' => 
'lis_outcome_service_url',
 
  106                                                          'ToolConsumerProfile.url' => 
'custom_tc_profile_url',
 
  107                                                          'ToolProxy.url' => 
'tool_proxy_url',
 
  108                                                          'ToolProxy.custom.url' => 
'custom_system_setting_url',
 
  109                                                          'ToolProxyBinding.custom.url' => 
'custom_context_setting_url',
 
  110                                                          'LtiLink.custom.url' => 
'custom_link_setting_url',
 
  111                                                          'LineItems.url' => 
'custom_lineitems_url',
 
  112                                                          'LineItem.url' => 
'custom_lineitem_url',
 
  113                                                          'Results.url' => 
'custom_results_url',
 
  114                                                          'Result.url' => 
'custom_result_url',
 
  115                                                          'ToolProxyBinding.memberships.url' => 
'custom_context_memberships_url');
 
  126        $this->logger = 
$DIC->logger()->lti();
 
  127        parent::__construct($dataConnector);
 
  147    ###    PROTECTED METHODS 
  162        if ($this->context instanceof 
Context) {
 
  163            $this->context->save();
 
  167            $this->resourceLink->save();
 
  219        if (is_null($callback)) {
 
  220            $callback = self::$METHOD_NAMES[
$_POST[
'lti_message_type']];
 
  222        if (method_exists($this, $callback)) {
 
  224        } elseif (is_null($method) && $this->ok) {
 
  226            $this->reason = 
"Message type not supported: {$_POST['lti_message_type']}";
 
  228        if ($this->ok && (
$_POST[
'lti_message_type'] == 
'ToolProxyRegistrationRequest')) {
 
  229            $this->consumer->save();
 
  249                if (!empty($this->returnUrl)) {
 
  250                    $errorUrl = $this->returnUrl;
 
  251                    if (strpos($errorUrl, 
'?') === 
false) {
 
  256                    if ($this->debugMode && !is_null($this->reason)) {
 
  257                        $errorUrl .= 
'lti_errormsg=' . urlencode(
"Debug error: $this->reason");
 
  259                        $errorUrl .= 
'lti_errormsg=' . urlencode($this->message);
 
  260                        if (!is_null($this->reason)) {
 
  261                            $errorUrl .= 
'<i_errorlog=' . urlencode(
"Debug error: $this->reason");
 
  264                    if (!is_null($this->consumer) && isset(
$_POST[
'lti_message_type']) && (
$_POST[
'lti_message_type'] === 
'ContentItemSelectionRequest')) {
 
  265                        $formParams = array();
 
  266                        if (isset(
$_POST[
'data'])) {
 
  267                            $formParams[
'data'] = 
$_POST[
'data'];
 
  270                        $formParams = $this->consumer->signParameters($errorUrl, 
'ContentItemSelection', 
$version, $formParams);
 
  271                        $page = self::sendForm($errorUrl, $formParams);
 
  274                        header(
"Location: {$errorUrl}");
 
  278                    if (!is_null($this->errorOutput)) {
 
  279                        echo $this->errorOutput;
 
  280                    } elseif ($this->debugMode && !empty($this->reason)) {
 
  281                        echo 
"Debug error: {$this->reason}";
 
  283                        echo 
"Error: {$this->message}";
 
  286            } elseif (!is_null($this->redirectUrl)) {
 
  287                header(
"Location: {$this->redirectUrl}");
 
  289            } elseif (!is_null($this->output)) {
 
  306        $doSaveConsumer = 
false;
 
  308        $this->ok = isset(
$_POST[
'lti_message_type']) && array_key_exists(
$_POST[
'lti_message_type'], self::$MESSAGE_TYPES);
 
  310            $this->reason = 
'Invalid or missing lti_message_type parameter.';
 
  313            $this->ok = isset(
$_POST[
'lti_version']) && in_array(
$_POST[
'lti_version'], self::$LTI_VERSIONS);
 
  315                $this->reason = 
'Invalid or missing lti_version parameter.';
 
  319            if (
$_POST[
'lti_message_type'] === 
'basic-lti-launch-request') {
 
  320                $this->ok = isset(
$_POST[
'resource_link_id']) && (strlen(trim(
$_POST[
'resource_link_id'])) > 0);
 
  322                    $this->reason = 
'Missing resource link ID.';
 
  324            } elseif (
$_POST[
'lti_message_type'] === 
'ContentItemSelectionRequest') {
 
  325                if (isset(
$_POST[
'accept_media_types']) && (strlen(trim(
$_POST[
'accept_media_types'])) > 0)) {
 
  326                    $mediaTypes = array_filter(explode(
',', str_replace(
' ', 
'', 
$_POST[
'accept_media_types'])), 
'strlen');
 
  327                    $mediaTypes = array_unique($mediaTypes);
 
  328                    $this->ok = count($mediaTypes) > 0;
 
  330                        $this->reason = 
'No accept_media_types found.';
 
  332                        $this->mediaTypes = $mediaTypes;
 
  337                if ($this->ok && isset(
$_POST[
'accept_presentation_document_targets']) && (strlen(trim(
$_POST[
'accept_presentation_document_targets'])) > 0)) {
 
  338                    $documentTargets = array_filter(explode(
',', str_replace(
' ', 
'', 
$_POST[
'accept_presentation_document_targets'])), 
'strlen');
 
  339                    $documentTargets = array_unique($documentTargets);
 
  340                    $this->ok = count($documentTargets) > 0;
 
  342                        $this->reason = 
'Missing or empty accept_presentation_document_targets parameter.';
 
  344                        foreach ($documentTargets as $documentTarget) {
 
  347                                array(
'embed', 
'frame', 
'iframe', 
'window', 
'popup', 
'overlay', 
'none'),
 
  348                                'Invalid value in accept_presentation_document_targets parameter: %s.' 
  355                            $this->documentTargets = $documentTargets;
 
  362                    $this->ok = isset(
$_POST[
'content_item_return_url']) && (strlen(trim(
$_POST[
'content_item_return_url'])) > 0);
 
  364                        $this->reason = 
'Missing content_item_return_url parameter.';
 
  367            } elseif (
$_POST[
'lti_message_type'] == 
'ToolProxyRegistrationRequest') {
 
  368                $this->ok = ((isset(
$_POST[
'reg_key']) && (strlen(trim(
$_POST[
'reg_key'])) > 0)) &&
 
  369                             (isset(
$_POST[
'reg_password']) && (strlen(trim(
$_POST[
'reg_password'])) > 0)) &&
 
  370                             (isset(
$_POST[
'tc_profile_url']) && (strlen(trim(
$_POST[
'tc_profile_url'])) > 0)) &&
 
  371                             (isset(
$_POST[
'launch_presentation_return_url']) && (strlen(trim(
$_POST[
'launch_presentation_return_url'])) > 0)));
 
  372                if ($this->debugMode && !$this->ok) {
 
  373                    $this->reason = 
'Missing message parameters.';
 
  379        $this->logger->debug(
'Checking consumer key...');
 
  382        if ($this->ok && (
$_POST[
'lti_message_type'] != 
'ToolProxyRegistrationRequest')) {
 
  383            $this->ok = isset(
$_POST[
'oauth_consumer_key']);
 
  385                $this->reason = 
'Missing consumer key.';
 
  390                $this->ok = !is_null($this->consumer->created);
 
  392                    $this->reason = 
'Invalid consumer key.';
 
  396                $today = 
date(
'Y-m-d', $now);
 
  397                if (is_null($this->consumer->lastAccess)) {
 
  398                    $doSaveConsumer = 
true;
 
  400                    $last = 
date(
'Y-m-d', $this->consumer->lastAccess);
 
  401                    $doSaveConsumer = $doSaveConsumer || ($last !== $today);
 
  403                $this->consumer->last_access = $now;
 
  408                    $server->add_signature_method($method);
 
  409                    $request = OAuth\OAuthRequest::from_request();
 
  411                } 
catch (\Exception $e) {
 
  413                    if (empty($this->reason)) {
 
  414                        if ($this->debugMode) {
 
  416                            $signature = $request->build_signature($method, 
$consumer, 
false);
 
  417                            $this->reason = $e->getMessage();
 
  418                            if (empty($this->reason)) {
 
  419                                $this->reason = 
'OAuth exception';
 
  421                            $this->details[] = 
'Timestamp: ' . time();
 
  422                            $this->details[] = 
"Signature: {$signature}";
 
  423                            $this->details[] = 
"Base string: {$request->base_string}]";
 
  425                            $this->reason = 
'OAuth signature check failed - perhaps an incorrect secret or timestamp.';
 
  432                $today = 
date(
'Y-m-d', $now);
 
  433                if (is_null($this->consumer->lastAccess)) {
 
  434                    $doSaveConsumer = 
true;
 
  436                    $last = 
date(
'Y-m-d', $this->consumer->lastAccess);
 
  437                    $doSaveConsumer = $doSaveConsumer || ($last !== $today);
 
  439                $this->consumer->last_access = $now;
 
  440                if ($this->consumer->protected) {
 
  441                    if (!is_null($this->consumer->consumerGuid)) {
 
  442                        $this->ok = empty(
$_POST[
'tool_consumer_instance_guid']) ||
 
  443                             ($this->consumer->consumerGuid === 
$_POST[
'tool_consumer_instance_guid']);
 
  445                            $this->reason = 
'Request is from an invalid tool consumer.';
 
  448                        $this->ok = isset(
$_POST[
'tool_consumer_instance_guid']);
 
  450                            $this->reason = 
'A tool consumer GUID must be included in the launch request.';
 
  455                    $this->ok = $this->consumer->enabled;
 
  457                        $this->reason = 
'Tool consumer has not been enabled by the tool provider.';
 
  461                    $this->ok = is_null($this->consumer->enableFrom) || ($this->consumer->enableFrom <= $now);
 
  463                        $this->ok = is_null($this->consumer->enableUntil) || ($this->consumer->enableUntil > $now);
 
  465                            $this->reason = 
'Tool consumer access has expired.';
 
  468                        $this->reason = 
'Tool consumer access is not yet available.';
 
  474                if (
$_POST[
'lti_message_type'] === 
'ContentItemSelectionRequest') {
 
  475                    if (isset(
$_POST[
'accept_unsigned'])) {
 
  476                        $this->ok = $this->
checkValue(
$_POST[
'accept_unsigned'], array(
'true', 
'false'), 
'Invalid value for accept_unsigned parameter: %s.');
 
  478                    if ($this->ok && isset(
$_POST[
'accept_multiple'])) {
 
  479                        $this->ok = $this->
checkValue(
$_POST[
'accept_multiple'], array(
'true', 
'false'), 
'Invalid value for accept_multiple parameter: %s.');
 
  481                    if ($this->ok && isset(
$_POST[
'accept_copy_advice'])) {
 
  482                        $this->ok = $this->
checkValue(
$_POST[
'accept_copy_advice'], array(
'true', 
'false'), 
'Invalid value for accept_copy_advice parameter: %s.');
 
  484                    if ($this->ok && isset(
$_POST[
'auto_create'])) {
 
  485                        $this->ok = $this->
checkValue(
$_POST[
'auto_create'], array(
'true', 
'false'), 
'Invalid value for auto_create parameter: %s.');
 
  487                    if ($this->ok && isset(
$_POST[
'can_confirm'])) {
 
  488                        $this->ok = $this->
checkValue(
$_POST[
'can_confirm'], array(
'true', 
'false'), 
'Invalid value for can_confirm parameter: %s.');
 
  490                } elseif (isset(
$_POST[
'launch_presentation_document_target'])) {
 
  492                        $_POST[
'launch_presentation_document_target'],
 
  493                        array(
'embed', 
'frame', 
'iframe', 
'window', 
'popup', 
'overlay'),
 
  494                        'Invalid value for launch_presentation_document_target parameter: %s.' 
  500        if ($this->ok && (
$_POST[
'lti_message_type'] === 
'ToolProxyRegistrationRequest')) {
 
  501            $this->ok = 
$_POST[
'lti_version'] == self::LTI_VERSION2;
 
  503                $this->reason = 
'Invalid lti_version parameter';
 
  506                $http = 
new HTTPMessage(
$_POST[
'tc_profile_url'], 
'GET', 
null, 
'Accept: application/vnd.ims.lti.v2.toolconsumerprofile+json');
 
  507                $this->ok = 
$http->send();
 
  509                    $this->reason = 
'Tool consumer profile not accessible.';
 
  511                    $tcProfile = json_decode(
$http->response);
 
  512                    $this->ok = !is_null($tcProfile);
 
  514                        $this->reason = 
'Invalid JSON in tool consumer profile.';
 
  522                $this->consumer->profile = $tcProfile;
 
  523                $capabilities = $this->consumer->profile->capability_offered;
 
  525                foreach ($this->resourceHandlers as $resourceHandler) {
 
  526                    foreach ($resourceHandler->requiredMessages as 
$message) {
 
  527                        if (!in_array(
$message->type, $capabilities)) {
 
  550                foreach ($this->requiredServices as 
$service) {
 
  554                                $this->reason = 
'Required service(s) not offered - ';
 
  557                                $this->reason .= 
', ';
 
  559                            $this->reason .= 
"'{$format}' [" . implode(
', ', 
$service->actions) . 
']';
 
  565                if (
$_POST[
'lti_message_type'] === 
'ToolProxyRegistrationRequest') {
 
  566                    $this->consumer->profile = $tcProfile;
 
  567                    $this->consumer->secret = 
$_POST[
'reg_password'];
 
  568                    $this->consumer->ltiVersion = 
$_POST[
'lti_version'];
 
  569                    $this->consumer->name = $tcProfile->product_instance->service_owner->service_owner_name->default_value;
 
  570                    $this->consumer->consumerName = $this->consumer->name;
 
  571                    $this->consumer->consumerVersion = 
"{$tcProfile->product_instance->product_info->product_family->code}-{$tcProfile->product_instance->product_info->product_version}";
 
  572                    $this->consumer->consumerGuid = $tcProfile->product_instance->guid;
 
  573                    $this->consumer->enabled = 
true;
 
  574                    $this->consumer->protected = 
true;
 
  575                    $doSaveConsumer = 
true;
 
  578        } elseif ($this->ok && !empty(
$_POST[
'custom_tc_profile_url']) && empty($this->consumer->profile)) {
 
  579            $http = 
new HTTPMessage(
$_POST[
'custom_tc_profile_url'], 
'GET', 
null, 
'Accept: application/vnd.ims.lti.v2.toolconsumerprofile+json');
 
  581                $tcProfile = json_decode(
$http->response);
 
  582                if (!is_null($tcProfile)) {
 
  583                    $this->consumer->profile = $tcProfile;
 
  584                    $doSaveConsumer = 
true;
 
  616        $this->logger->debug(
'Still ok: ' . ($this->ok ? 
'1' : 
'0'));
 
  618            $this->logger->debug(
'Reason: ' . $this->reason);
 
  624            if (isset(
$_POST[
'context_id'])) {
 
  625                $this->context = Context::fromConsumer($this->consumer, trim(
$_POST[
'context_id']));
 
  627                if (isset(
$_POST[
'context_title'])) {
 
  631                    $title = 
"Course {$this->context->getId()}";
 
  633                $this->context->title = 
$title;
 
  637            if (isset(
$_POST[
'resource_link_id'])) {
 
  639                if (isset(
$_POST[
'custom_content_item_id'])) {
 
  640                    $contentItemId = 
$_POST[
'custom_content_item_id'];
 
  642                $this->resourceLink = ResourceLink::fromConsumer($this->consumer, trim(
$_POST[
'resource_link_id']), $contentItemId);
 
  643                if (!empty($this->context)) {
 
  644                    $this->resourceLink->setContextId($this->context->getRecordId());
 
  647                if (isset(
$_POST[
'resource_link_title'])) {
 
  651                    $title = 
"Resource {$this->resourceLink->getId()}";
 
  653                $this->resourceLink->title = 
$title;
 
  655                foreach ($this->consumer->getSettings() as 
$name => $value) {
 
  656                    if (strpos(
$name, 
'custom_') === 0) {
 
  657                        $this->consumer->setSetting(
$name);
 
  658                        $doSaveConsumer = 
true;
 
  661                if (!empty($this->context)) {
 
  662                    foreach ($this->context->getSettings() as 
$name => $value) {
 
  663                        if (strpos(
$name, 
'custom_') === 0) {
 
  664                            $this->context->setSetting(
$name);
 
  668                foreach ($this->resourceLink->getSettings() as 
$name => $value) {
 
  669                    if (strpos(
$name, 
'custom_') === 0) {
 
  670                        $this->resourceLink->setSetting(
$name);
 
  674                foreach (self::$LTI_CONSUMER_SETTING_NAMES as 
$name) {
 
  678                        $this->consumer->setSetting(
$name);
 
  681                if (!empty($this->context)) {
 
  682                    foreach (self::$LTI_CONTEXT_SETTING_NAMES as 
$name) {
 
  686                            $this->context->setSetting(
$name);
 
  690                foreach (self::$LTI_RESOURCE_LINK_SETTING_NAMES as 
$name) {
 
  694                        $this->resourceLink->setSetting(
$name);
 
  699                    if ((strpos(
$name, 
'custom_') === 0) &&
 
  700                        !in_array(
$name, array_merge(self::$LTI_CONSUMER_SETTING_NAMES, self::$LTI_CONTEXT_SETTING_NAMES, self::$LTI_RESOURCE_LINK_SETTING_NAMES))) {
 
  701                        $this->resourceLink->setSetting(
$name, $value);
 
  708            if (isset(
$_POST[
'user_id'])) {
 
  709                $userId = trim(
$_POST[
'user_id']);
 
  712            $this->
user = User::fromResourceLink($this->resourceLink, $userId);
 
  715            $firstname = (isset(
$_POST[
'lis_person_name_given'])) ? 
$_POST[
'lis_person_name_given'] : 
'';
 
  716            $lastname = (isset(
$_POST[
'lis_person_name_family'])) ? 
$_POST[
'lis_person_name_family'] : 
'';
 
  717            $fullname = (isset(
$_POST[
'lis_person_name_full'])) ? 
$_POST[
'lis_person_name_full'] : 
'';
 
  718            $this->
user->setNames($firstname, $lastname, $fullname);
 
  721            $email = (isset(
$_POST[
'lis_person_contact_email_primary'])) ? 
$_POST[
'lis_person_contact_email_primary'] : 
'';
 
  722            $this->
user->setEmail(
$email, $this->defaultEmail);
 
  725            if (isset(
$_POST[
'user_image'])) {
 
  730            if (isset(
$_POST[
'roles'])) {
 
  731                $this->
user->roles = self::parseRoles(
$_POST[
'roles']);
 
  735            $this->consumer->defaultEmail = $this->defaultEmail;
 
  736            if ($this->consumer->ltiVersion !== 
$_POST[
'lti_version']) {
 
  737                $this->consumer->ltiVersion = 
$_POST[
'lti_version'];
 
  738                $doSaveConsumer = 
true;
 
  740            if (isset(
$_POST[
'tool_consumer_instance_name'])) {
 
  741                if ($this->consumer->consumerName !== 
$_POST[
'tool_consumer_instance_name']) {
 
  742                    $this->consumer->consumerName = 
$_POST[
'tool_consumer_instance_name'];
 
  743                    $doSaveConsumer = 
true;
 
  746            if (isset(
$_POST[
'tool_consumer_info_product_family_code'])) {
 
  748                if (isset(
$_POST[
'tool_consumer_info_version'])) {
 
  749                    $version .= 
"-{$_POST['tool_consumer_info_version']}";
 
  752                if ($this->consumer->consumerVersion !== 
$version) {
 
  753                    $this->consumer->consumerVersion = 
$version;
 
  754                    $doSaveConsumer = 
true;
 
  756            } elseif (isset(
$_POST[
'ext_lms']) && ($this->consumer->consumerName !== 
$_POST[
'ext_lms'])) {
 
  757                $this->consumer->consumerVersion = 
$_POST[
'ext_lms'];
 
  758                $doSaveConsumer = 
true;
 
  760            if (isset(
$_POST[
'tool_consumer_instance_guid'])) {
 
  761                if (is_null($this->consumer->consumerGuid)) {
 
  762                    $this->consumer->consumerGuid = 
$_POST[
'tool_consumer_instance_guid'];
 
  763                    $doSaveConsumer = 
true;
 
  764                } elseif (!$this->consumer->protected) {
 
  765                    $doSaveConsumer = ($this->consumer->consumerGuid !== 
$_POST[
'tool_consumer_instance_guid']);
 
  766                    if ($doSaveConsumer) {
 
  767                        $this->consumer->consumerGuid = 
$_POST[
'tool_consumer_instance_guid'];
 
  771            if (isset(
$_POST[
'launch_presentation_css_url'])) {
 
  772                if ($this->consumer->cssPath !== 
$_POST[
'launch_presentation_css_url']) {
 
  773                    $this->consumer->cssPath = 
$_POST[
'launch_presentation_css_url'];
 
  774                    $doSaveConsumer = 
true;
 
  776            } elseif (isset(
$_POST[
'ext_launch_presentation_css_url']) &&
 
  777                 ($this->consumer->cssPath !== 
$_POST[
'ext_launch_presentation_css_url'])) {
 
  778                $this->consumer->cssPath = 
$_POST[
'ext_launch_presentation_css_url'];
 
  779                $doSaveConsumer = 
true;
 
  780            } elseif (!empty($this->consumer->cssPath)) {
 
  781                $this->consumer->cssPath = 
null;
 
  782                $doSaveConsumer = 
true;
 
  787        if ($doSaveConsumer) {
 
  788            $this->consumer->save();
 
  790        if ($this->ok && isset($this->context)) {
 
  791            $this->context->save();
 
  794        $this->logger->dump(get_class($this->context));
 
  797        if ($this->ok && isset($this->resourceLink)) {
 
  802            $this->resourceLink->save();
 
  805            if (isset(
$_POST[
'lis_result_sourcedid'])) {
 
  806                if ($this->
user->ltiResultSourcedId !== 
$_POST[
'lis_result_sourcedid']) {
 
  807                    $this->
user->ltiResultSourcedId = 
$_POST[
'lis_result_sourcedid'];
 
  810            } elseif (!empty($this->
user->ltiResultSourcedId)) {
 
  811                $this->
user->ltiResultSourcedId = 
'';
 
  827        $doSaveResourceLink = 
true;
 
  829        $id = $this->resourceLink->primaryResourceLinkId;
 
  831        $shareRequest = isset(
$_POST[
'custom_share_key']) && !empty(
$_POST[
'custom_share_key']);
 
  833            if (!$this->allowSharing) {
 
  835                $this->reason = 
'Your sharing request has been refused because sharing is not being permitted.';
 
  839                if (!is_null($shareKey->primaryConsumerKey) && !is_null($shareKey->primaryResourceLinkId)) {
 
  841                    $key = $shareKey->primaryConsumerKey;
 
  842                    $id = $shareKey->primaryResourceLinkId;
 
  843                    $ok = (
$key !== $this->consumer->getKey()) || (
$id != $this->resourceLink->getId());
 
  845                        $this->resourceLink->primaryConsumerKey = 
$key;
 
  846                        $this->resourceLink->primaryResourceLinkId = 
$id;
 
  847                        $this->resourceLink->shareApproved = $shareKey->autoApprove;
 
  848                        $ok = $this->resourceLink->save();
 
  850                            $doSaveResourceLink = 
false;
 
  851                            $this->
user->getResourceLink()->primaryConsumerKey = 
$key;
 
  852                            $this->
user->getResourceLink()->primaryResourceLinkId = 
$id;
 
  853                            $this->
user->getResourceLink()->shareApproved = $shareKey->autoApprove;
 
  854                            $this->
user->getResourceLink()->updated = time();
 
  858                            $this->reason = 
'An error occurred initialising your share arrangement.';
 
  861                        $this->reason = 
'It is not possible to share your resource link with yourself.';
 
  867                        $this->reason = 
'You have requested to share a resource link but none is available.';
 
  869                        $ok = (!is_null($this->
user->getResourceLink()->shareApproved) && $this->
user->getResourceLink()->shareApproved);
 
  871                            $this->reason = 
'Your share request is waiting to be approved.';
 
  880                $this->reason = 
'You have not requested to share a resource link but an arrangement is currently in place.';
 
  884        if (
$ok && !is_null(
$id)) {
 
  889                $resourceLink = ResourceLink::fromConsumer(
$consumer, 
$id);
 
  890                $ok = !is_null($resourceLink->created);
 
  893                if ($doSaveResourceLink) {
 
  894                    $this->resourceLink->save();
 
  896                $this->resourceLink = $resourceLink;
 
  898                $this->reason = 
'Unable to load resource link being shared.';
 
  911        $ok = in_array($value, $values);
 
  912        if (!
$ok && !empty($reason)) {
 
  913            $this->reason = 
sprintf($reason, $value);
 
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
Class to represent an HTTP message.
Class to represent an OAuth Consumer.
Class to represent an OAuth Data Store.
Class to represent an OAuth Server.
Class to represent an OAuth HMAC_SHA1 signature method.
Class to represent a generic item object.
Class to represent a tool consumer context.
if(!array_key_exists('StateId', $_REQUEST)) $id
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
catch(Exception $e) $message
foreach($_POST as $key=> $value) $res