function Streams_after_Users_Contact_removeExecute($params) { // Update avatar as viewed by everyone who was in that contacts list $contacts = Streams::$cache['contacts_removed']; foreach ($contacts as $contact) { Streams::updateAvatar($contact->contactUserId, $contact->userId); } }
function Streams_after_Users_Contact_removeExecute($params) { // Update avatar as viewed by everyone who was in that contacts list $contacts = Streams::$cache['contacts_removed']; foreach ($contacts as $contact) { Streams::updateAvatar($contact->contactUserId, $contact->userId); } Streams_Message::post(null, $contact->userId, 'Streams/contacts', array('type' => 'Streams/contacts/removed', 'instructions' => array('contacts' => Db::exportArray($contacts))), true); }
function Streams_before_Users_Contact_saveExecute($params) { $contacts = array($params['row']); // the new values about to be written if ($params['query']->type === Db_Query::TYPE_UPDATE) { // we are updating an existing contact $contacts = array_merge($contacts, Users_Contact::select('*')->where($params['where'])->limit(1)->fetchDbRows()); } // Update avatar as viewed by everyone who was in that contacts list foreach ($contacts as $contact) { Streams::updateAvatar($contact->contactUserId, $contact->userId); } }
/** * 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; }