Example #1
0
 /**
  * @method afterRemoveExcecute
  * @param {Db_Result} $result
  * @param {Db_Query} $query
  * @return {Db_Result}
  */
 function afterRemoveExecute($result, $query)
 {
     $stream = $this;
     // if the above call threw an exception, then we will not be doing the following.
     Q_Utils::sendToNode(array("Q/method" => "Streams/Stream/remove", "stream" => Q::json_encode($stream->toArray())));
     /**
      * @event Streams/remove/$streamType {after}
      * @param {Streams_Stream} stream
      * @param {string} asUserId
      */
     Q::event("Streams/remove/{$stream->type}", compact('stream', 'result'), 'after');
     if ($this->name !== 'Streams/user/firstName' and $this->name !== 'Streams/user/lastName') {
         return $result;
     }
     // Update all avatars corresponding to access rows for this stream
     $taintedAccess = Streams_Access::select('*')->where(array('publisherId' => $this->publisherId, 'streamName' => $this->name))->fetchDbRows();
     Streams::updateAvatars($this->publisherId, $taintedAccess, $this, true);
     return $result;
 }
Example #2
0
 /**
  * Keeps Access table consistent on row deletion and update avatar
  * @method afterRemoveExecute
  * @param {Db_Result} $result
  *	Query result
  * @param {array} $query
  *	The query which has been excecuted
  * @return {Db_Result}
  */
 function afterRemoveExecute($result, $query)
 {
     if (!empty($this->ofUserId)) {
         // Removed an access for a specific user
         Streams::updateAvatar($this->ofUserId, $this->publisherId);
         return $result;
     }
     if (empty($this->ofContactLabel)) {
         return $result;
     }
     // Update all avatars corresponding to access rows for this stream
     $tainted_access = Streams_Access::select('*')->where(array('publisherId' => $this->publisherId, 'streamName' => $this->streamName))->fetchDbRows();
     $found = false;
     foreach ($tainted_access as $ca) {
         if ($ca->ofContactLabel === $this->ofContactLabel) {
             // this should never really happen, since the row was just deleted
             $found = true;
             $ca->set('removed', true);
         }
     }
     if (!$found) {
         $this->set('removed', true);
         $tainted_access[] = $this;
     }
     Streams::updateAvatars($this->publisherId, $tainted_access, $this->streamName);
     return $result;
 }