/** * @param Resource $resource * @param User_list $list * @param string[] $tagArray * @param string $notes * @param bool $updateSolr * @return bool */ function addResource($resource, $list, $tagArray, $notes, $updateSolr = true) { require_once 'User_resource.php'; require_once 'Tags.php'; $join = new User_resource(); $join->user_id = $this->id; $join->resource_id = $resource->id; $join->list_id = $list->id; if ($join->find(true)) { if ($notes) { $join->notes = $notes; $join->update(); } $result = true; } else { if ($notes) { $join->notes = $notes; } $result = $join->insert(); } if ($result) { if (is_array($tagArray) && count($tagArray)) { require_once 'Resource_tags.php'; $join = new Resource_tags(); $join->resource_id = $resource->id; $join->user_id = $this->id; $join->list_id = $list->id; $join->delete(); foreach ($tagArray as $value) { $value = trim(strtolower(str_replace('"', '', $value))); $tag = new Tags(); $tag->tag = $value; if (!$tag->find(true)) { $tag->insert(); } $join->tag_id = $tag->id; $join->insert(); } } if ($updateSolr) { $list->updateDetailed(true); } //Make a call to strands to update that the item was added to the list global $configArray; if (isset($configArray['Strands']['APID'])) { if ($resource->source == 'eContent') { $strandsUrl = "http://bizsolutions.strands.com/api2/event/addtofavorites.sbs?apid={$configArray['Strands']['APID']}&item={$resource->record_id}&user={$this->id}"; } else { $strandsUrl = "http://bizsolutions.strands.com/api2/event/addtofavorites.sbs?apid={$configArray['Strands']['APID']}&item=econtentRecord{$resource->record_id}&user={$this->id}"; } file_get_contents($strandsUrl); } return true; } else { return false; } }