static function addNew($user, $notice) { $fave = new Fave(); $fave->user_id = $user->id; $fave->notice_id = $notice->id; if (!$fave->insert()) { common_log_db_error($fave, 'INSERT', __FILE__); return false; } return $fave; }
/** * Save a favorite record. * @fixme post-author notification should be moved here * * @param Profile $profile the local or remote user who likes * @param Notice $notice the notice that is liked * @return mixed false on failure, or Fave record on success */ static function addNew(Profile $profile, Notice $notice) { $fave = null; if (Event::handle('StartFavorNotice', array($profile, $notice, &$fave))) { $fave = new Fave(); $fave->user_id = $profile->id; $fave->notice_id = $notice->id; if (!$fave->insert()) { common_log_db_error($fave, 'INSERT', __FILE__); return false; } Event::handle('EndFavorNotice', array($profile, $notice)); } return $fave; }
/** * Save a favorite record. * @fixme post-author notification should be moved here * * @param Profile $profile the local or remote user who likes * @param Notice $notice the notice that is liked * @return mixed false on failure, or Fave record on success */ static function addNew(Profile $profile, Notice $notice) { $fave = null; if (Event::handle('StartFavorNotice', array($profile, $notice, &$fave))) { $fave = new Fave(); $fave->user_id = $profile->id; $fave->notice_id = $notice->id; $fave->modified = common_sql_now(); $fave->uri = self::newURI($fave->user_id, $fave->notice_id, $fave->modified); if (!$fave->insert()) { common_log_db_error($fave, 'INSERT', __FILE__); return false; } self::blow('fave:list-ids:notice_id:%d', $fave->notice_id); self::blow('popular'); Event::handle('EndFavorNotice', array($profile, $notice)); } return $fave; }