/**
  * Class constructor.
  *
  * @param LTI_Resource_Link $resource_link  Resource_Link object
  * @param string      $id      Value of share key (optional, default is null)
  */
 public function __construct($resource_link, $id = NULL)
 {
     $this->initialise();
     $this->data_connector = $resource_link->getConsumer()->getDataConnector();
     $this->id = $id;
     $this->primary_context_id =& $this->primary_resource_link_id;
     if (!empty($id)) {
         $this->load();
     } else {
         $this->primary_consumer_key = $resource_link->getKey();
         $this->primary_resource_link_id = $resource_link->getId();
     }
 }
 /**
  * Get an array of LTI_Resource_Link_Share objects for each resource link which is sharing this resource link
  *
  * @param LTI_Resource_Link $resource_link
  * @return array
  */
 public function Resource_Link_getShares($resource_link)
 {
     $shares = array();
     $key = $resource_link->getKey();
     $id = $resource_link->getId();
     $sql = 'SELECT consumer_key, context_id, title, share_approved ' . 'FROM ' . $this->dbTableNamePrefix . LTI_Data_Connector::RESOURCE_LINK_TABLE_NAME . ' ' . 'WHERE (primary_consumer_key = :key) AND (primary_context_id = :id) ' . 'ORDER BY consumer_key';
     $query = $this->db->prepare($sql);
     $query->bindValue('key', $key, PDO::PARAM_STR);
     $query->bindValue('id', $id, PDO::PARAM_STR);
     if ($query->execute()) {
         while ($row = $query->fetch()) {
             $share = new LTI_Resource_Link_Share();
             $share->consumer_key = $row['consumer_key'];
             $share->resource_link_id = $row['context_id'];
             $share->title = $row['title'];
             $share->approved = $row['share_approved'] == 1;
             $shares[] = $share;
         }
     }
     return $shares;
 }