FavoritePlugin.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <?php
  2. /*
  3. * GNU Social - a federating social network
  4. * Copyright (C) 2014, Free Software Foundation, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. if (!defined('GNUSOCIAL')) { exit(1); }
  20. /**
  21. * @package Activity
  22. * @maintainer Mikael Nordfeldth <mmn@hethane.se>
  23. */
  24. class FavoritePlugin extends ActivityVerbHandlerPlugin
  25. {
  26. const PLUGIN_VERSION = '2.0.0';
  27. protected $email_notify_fave = 1;
  28. public function tag()
  29. {
  30. return 'favorite';
  31. }
  32. public function types()
  33. {
  34. return array();
  35. }
  36. public function verbs()
  37. {
  38. return array(ActivityVerb::FAVORITE, ActivityVerb::LIKE,
  39. ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE);
  40. }
  41. public function onCheckSchema()
  42. {
  43. $schema = Schema::get();
  44. $schema->ensureTable('fave', Fave::schemaDef());
  45. return true;
  46. }
  47. public function initialize()
  48. {
  49. common_config_set('email', 'notify_fave', $this->email_notify_fave);
  50. }
  51. public function onStartUpgrade()
  52. {
  53. // This is a migration feature that will make sure we move
  54. // certain User preferences to the Profile_prefs table.
  55. // Introduced after commit b5fd2a048fc621ea05d756caba17275ab3dd0af4
  56. // on Sun Jul 13 16:30:37 2014 +0200
  57. $user = new User();
  58. $user->whereAdd('emailnotifyfav IS NOT NULL');
  59. if ($user->find()) {
  60. printfnq("Detected old User table (emailnotifyfav IS NOT NULL). Moving 'emailnotifyfav' property to Profile_prefs...");
  61. // First we'll make sure Profile_prefs exists
  62. $schema = Schema::get();
  63. $schema->ensureTable('profile_prefs', Profile_prefs::schemaDef());
  64. // Make sure we have our own tables setup properly
  65. while ($user->fetch()) {
  66. $user->setPref('email', 'notify_fave', $user->emailnotifyfav);
  67. $orig = clone($user);
  68. $user->emailnotifyfav = 'null'; // flag this preference as migrated
  69. $user->update($orig);
  70. }
  71. printfnq("DONE.\n");
  72. }
  73. }
  74. public function onEndUpgrade()
  75. {
  76. printfnq("Ensuring all faves have a URI...");
  77. $fave = new Fave();
  78. $fave->whereAdd('uri IS NULL');
  79. if ($fave->find()) {
  80. while ($fave->fetch()) {
  81. try {
  82. $fave->decache();
  83. $fave->query(sprintf('UPDATE fave '.
  84. 'SET uri = "%s", '.
  85. ' modified = "%s" '.
  86. 'WHERE user_id = %d '.
  87. 'AND notice_id = %d',
  88. Fave::newUri($fave->getActor(), $fave->getTarget(), $fave->modified),
  89. common_sql_date(strtotime($fave->modified)),
  90. $fave->user_id,
  91. $fave->notice_id));
  92. } catch (Exception $e) {
  93. common_log(LOG_ERR, "Error updating fave URI: " . $e->getMessage());
  94. }
  95. }
  96. }
  97. printfnq("DONE.\n");
  98. }
  99. public function onRouterInitialized(URLMapper $m)
  100. {
  101. // Web UI actions
  102. $m->connect('main/favor', array('action' => 'favor'));
  103. $m->connect('main/disfavor', array('action' => 'disfavor'));
  104. if (common_config('singleuser', 'enabled')) {
  105. $nickname = User::singleUserNickname();
  106. $m->connect('favorites',
  107. array('action' => 'showfavorites',
  108. 'nickname' => $nickname));
  109. $m->connect('favoritesrss',
  110. array('action' => 'favoritesrss',
  111. 'nickname' => $nickname));
  112. } else {
  113. $m->connect('favoritedrss', array('action' => 'favoritedrss'));
  114. $m->connect('favorited/', array('action' => 'favorited'));
  115. $m->connect('favorited', array('action' => 'favorited'));
  116. $m->connect(':nickname/favorites',
  117. array('action' => 'showfavorites'),
  118. array('nickname' => Nickname::DISPLAY_FMT));
  119. $m->connect(':nickname/favorites/rss',
  120. array('action' => 'favoritesrss'),
  121. array('nickname' => Nickname::DISPLAY_FMT));
  122. }
  123. // Favorites for API
  124. $m->connect('api/favorites/create.:format',
  125. array('action' => 'ApiFavoriteCreate'),
  126. array('format' => '(xml|json)'));
  127. $m->connect('api/favorites/destroy.:format',
  128. array('action' => 'ApiFavoriteDestroy'),
  129. array('format' => '(xml|json)'));
  130. $m->connect('api/favorites/list.:format',
  131. array('action' => 'ApiTimelineFavorites'),
  132. array('format' => '(xml|json|rss|atom|as)'));
  133. $m->connect('api/favorites/:id.:format',
  134. array('action' => 'ApiTimelineFavorites'),
  135. array('id' => Nickname::INPUT_FMT,
  136. 'format' => '(xml|json|rss|atom|as)'));
  137. $m->connect('api/favorites.:format',
  138. array('action' => 'ApiTimelineFavorites'),
  139. array('format' => '(xml|json|rss|atom|as)'));
  140. $m->connect('api/favorites/create/:id.:format',
  141. array('action' => 'ApiFavoriteCreate'),
  142. array('id' => '[0-9]+',
  143. 'format' => '(xml|json)'));
  144. $m->connect('api/favorites/destroy/:id.:format',
  145. array('action' => 'ApiFavoriteDestroy'),
  146. array('id' => '[0-9]+',
  147. 'format' => '(xml|json)'));
  148. // AtomPub API
  149. $m->connect('api/statusnet/app/favorites/:profile/:notice.atom',
  150. array('action' => 'AtomPubShowFavorite'),
  151. array('profile' => '[0-9]+',
  152. 'notice' => '[0-9]+'));
  153. $m->connect('api/statusnet/app/favorites/:profile.atom',
  154. array('action' => 'AtomPubFavoriteFeed'),
  155. array('profile' => '[0-9]+'));
  156. // Required for qvitter API
  157. $m->connect('api/statuses/favs/:id.:format',
  158. array('action' => 'ApiStatusesFavs'),
  159. array('id' => '[0-9]+',
  160. 'format' => '(xml|json)'));
  161. }
  162. // FIXME: Set this to abstract public in lib/activityhandlerplugin.php ddwhen all plugins have migrated!
  163. protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array())
  164. {
  165. assert($this->isMyActivity($act));
  166. // We must have an objects[0] here because in isMyActivity we require the count to be == 1
  167. $actobj = $act->objects[0];
  168. $object = Fave::saveActivityObject($actobj, $stored);
  169. return $object;
  170. }
  171. // FIXME: Put this in lib/activityhandlerplugin.php when we're ready
  172. // with the other microapps/activityhandlers as well.
  173. // Also it should be StartNoticeAsActivity (with a prepped Activity, including ->context etc.)
  174. public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null)
  175. {
  176. if (!$this->isMyNotice($stored)) {
  177. return true;
  178. }
  179. $this->extendActivity($stored, $act, $scoped);
  180. return false;
  181. }
  182. public function extendActivity(Notice $stored, Activity $act, Profile $scoped=null)
  183. {
  184. Fave::extendActivity($stored, $act, $scoped);
  185. }
  186. public function activityObjectFromNotice(Notice $notice)
  187. {
  188. $fave = Fave::fromStored($notice);
  189. return $fave->asActivityObject();
  190. }
  191. public function deleteRelated(Notice $notice)
  192. {
  193. try {
  194. $fave = Fave::fromStored($notice);
  195. $fave->delete();
  196. } catch (NoResultException $e) {
  197. // Cool, no problem. We wanted to get rid of it anyway.
  198. }
  199. }
  200. // API stuff
  201. /**
  202. * Typically just used to fill out Twitter-compatible API status data.
  203. *
  204. * FIXME: Make all the calls before this end up with a Notice instead of ArrayWrapper please...
  205. */
  206. public function onNoticeSimpleStatusArray($notice, array &$status, Profile $scoped=null, array $args=array())
  207. {
  208. if ($scoped instanceof Profile) {
  209. $status['favorited'] = Fave::existsForProfile($notice, $scoped);
  210. } else {
  211. $status['favorited'] = false;
  212. }
  213. return true;
  214. }
  215. public function onTwitterUserArray(Profile $profile, array &$userdata, Profile $scoped=null, array $args=array())
  216. {
  217. $userdata['favourites_count'] = Fave::countByProfile($profile);
  218. }
  219. /**
  220. * Typically just used to fill out StatusNet specific data in API calls in the referenced $info array.
  221. */
  222. public function onStatusNetApiNoticeInfo(Notice $notice, array &$info, Profile $scoped=null, array $args=array())
  223. {
  224. if ($scoped instanceof Profile) {
  225. $info['favorite'] = Fave::existsForProfile($notice, $scoped) ? 'true' : 'false';
  226. }
  227. return true;
  228. }
  229. public function onNoticeDeleteRelated(Notice $notice)
  230. {
  231. parent::onNoticeDeleteRelated($notice);
  232. // The below algorithm is because we want to delete fave
  233. // activities on any notice which _has_ faves, and not as
  234. // in the parent function only ones that _are_ faves.
  235. $fave = new Fave();
  236. $fave->notice_id = $notice->id;
  237. if ($fave->find()) {
  238. while ($fave->fetch()) {
  239. $fave->delete();
  240. }
  241. }
  242. $fave->free();
  243. }
  244. public function onProfileDeleteRelated(Profile $profile, array &$related)
  245. {
  246. $fave = new Fave();
  247. $fave->user_id = $profile->id;
  248. $fave->delete(); // Will perform a DELETE matching "user_id = {$user->id}"
  249. $fave->free();
  250. Fave::blowCacheForProfileId($profile->id);
  251. return true;
  252. }
  253. public function onStartNoticeListPrefill(array &$notices, array $notice_ids, Profile $scoped=null)
  254. {
  255. // prefill array of objects, before pluginfication it was Notice::fillFaves($notices)
  256. Fave::fillFaves($notice_ids);
  257. // DB caching
  258. if ($scoped instanceof Profile) {
  259. Fave::pivotGet('notice_id', $notice_ids, array('user_id' => $scoped->id));
  260. }
  261. }
  262. /**
  263. * show the "favorite" form in the notice options element
  264. * FIXME: Don't let a NoticeListItemAdapter slip in here (or extend that from NoticeListItem)
  265. *
  266. * @return void
  267. */
  268. public function onStartShowNoticeOptionItems($nli)
  269. {
  270. if (Event::handle('StartShowFaveForm', array($nli))) {
  271. $scoped = Profile::current();
  272. if ($scoped instanceof Profile) {
  273. if (Fave::existsForProfile($nli->notice, $scoped)) {
  274. $disfavor = new DisfavorForm($nli->out, $nli->notice);
  275. $disfavor->show();
  276. } else {
  277. $favor = new FavorForm($nli->out, $nli->notice);
  278. $favor->show();
  279. }
  280. }
  281. Event::handle('EndShowFaveForm', array($nli));
  282. }
  283. }
  284. protected function showNoticeListItem(NoticeListItem $nli)
  285. {
  286. // pass
  287. }
  288. public function openNoticeListItemElement(NoticeListItem $nli)
  289. {
  290. // pass
  291. }
  292. public function closeNoticeListItemElement(NoticeListItem $nli)
  293. {
  294. // pass
  295. }
  296. public function onAppendUserActivityStreamObjects(UserActivityStream $uas, array &$objs)
  297. {
  298. $fave = new Fave();
  299. $fave->user_id = $uas->getUser()->id;
  300. if (!empty($uas->after)) {
  301. $fave->whereAdd("modified > '" . common_sql_date($uas->after) . "'");
  302. }
  303. if ($fave->find()) {
  304. while ($fave->fetch()) {
  305. $objs[] = clone($fave);
  306. }
  307. }
  308. return true;
  309. }
  310. public function onEndShowThreadedNoticeTailItems(NoticeListItem $nli, Notice $notice, &$threadActive)
  311. {
  312. if ($nli instanceof ThreadedNoticeListSubItem) {
  313. // The sub-items are replies to a conversation, thus we use different HTML elements etc.
  314. $item = new ThreadedNoticeListInlineFavesItem($notice, $nli->out);
  315. } else {
  316. $item = new ThreadedNoticeListFavesItem($notice, $nli->out);
  317. }
  318. $threadActive = $item->show() || $threadActive;
  319. return true;
  320. }
  321. public function onEndFavorNotice(Profile $actor, Notice $target)
  322. {
  323. try {
  324. $notice_author = $target->getProfile();
  325. // Don't notify ourselves of our own favorite on our own notice,
  326. // or if it's a remote user (since we don't know their email addresses etc.)
  327. if ($notice_author->id == $actor->id || !$notice_author->isLocal()) {
  328. return true;
  329. }
  330. $local_user = $notice_author->getUser();
  331. mail_notify_fave($local_user, $actor, $target);
  332. } catch (Exception $e) {
  333. // Mm'kay, probably not a local user. Let's skip this favor notification.
  334. }
  335. }
  336. /**
  337. * EndInterpretCommand for FavoritePlugin will handle the 'fav' command
  338. * using the class FavCommand.
  339. *
  340. * @param string $cmd Command being run
  341. * @param string $arg Rest of the message (including address)
  342. * @param User $user User sending the message
  343. * @param Command &$result The resulting command object to be run.
  344. *
  345. * @return boolean hook value
  346. */
  347. public function onStartInterpretCommand($cmd, $arg, $user, &$result)
  348. {
  349. if ($result === false && $cmd == 'fav') {
  350. if (empty($arg)) {
  351. $result = null;
  352. } else {
  353. list($other, $extra) = CommandInterpreter::split_arg($arg);
  354. if (!empty($extra)) {
  355. $result = null;
  356. } else {
  357. $result = new FavCommand($user, $other);
  358. }
  359. }
  360. return false;
  361. }
  362. return true;
  363. }
  364. public function onHelpCommandMessages(HelpCommand $help, array &$commands)
  365. {
  366. // TRANS: Help message for IM/SMS command "fav <nickname>".
  367. $commands['fav <nickname>'] = _m('COMMANDHELP', "add user's last notice as a 'fave'");
  368. // TRANS: Help message for IM/SMS command "fav #<notice_id>".
  369. $commands['fav #<notice_id>'] = _m('COMMANDHELP', "add notice with the given id as a 'fave'");
  370. }
  371. /**
  372. * Are we allowed to perform a certain command over the API?
  373. */
  374. public function onCommandSupportedAPI(Command $cmd, &$supported)
  375. {
  376. $supported = $supported || $cmd instanceof FavCommand;
  377. }
  378. // Form stuff (settings etc.)
  379. public function onEndEmailFormData(Action $action, Profile $scoped)
  380. {
  381. $emailfave = $scoped->getConfigPref('email', 'notify_fave') ? 1 : 0;
  382. $action->elementStart('li');
  383. $action->checkbox('email-notify_fave',
  384. // TRANS: Checkbox label in e-mail preferences form.
  385. _('Send me email when someone adds my notice as a favorite.'),
  386. $emailfave);
  387. $action->elementEnd('li');
  388. return true;
  389. }
  390. public function onStartEmailSaveForm(Action $action, Profile $scoped)
  391. {
  392. $emailfave = $action->booleanintstring('email-notify_fave');
  393. try {
  394. if ($emailfave == $scoped->getPref('email', 'notify_fave')) {
  395. // No need to update setting
  396. return true;
  397. }
  398. } catch (NoResultException $e) {
  399. // Apparently there's no previously stored setting, then continue to save it as it is now.
  400. }
  401. $scoped->setPref('email', 'notify_fave', $emailfave);
  402. return true;
  403. }
  404. // Layout stuff
  405. public function onEndPersonalGroupNav(Menu $menu, Profile $target, Profile $scoped=null)
  406. {
  407. $menu->out->menuItem(common_local_url('showfavorites', array('nickname' => $target->getNickname())),
  408. // TRANS: Menu item in personal group navigation menu.
  409. _m('MENU','Favorites'),
  410. // @todo i18n FIXME: Need to make this two messages.
  411. // TRANS: Menu item title in personal group navigation menu.
  412. // TRANS: %s is a username.
  413. sprintf(_('%s\'s favorite notices'), $target->getBestName()),
  414. $scoped instanceof Profile && $target->id === $scoped->id && $menu->actionName =='showfavorites',
  415. 'nav_timeline_favorites');
  416. }
  417. public function onEndPublicGroupNav(Menu $menu)
  418. {
  419. if (!common_config('singleuser', 'enabled')) {
  420. // TRANS: Menu item in search group navigation panel.
  421. $menu->out->menuItem(common_local_url('favorited'), _m('MENU','Popular'),
  422. // TRANS: Menu item title in search group navigation panel.
  423. _('Popular notices'), $menu->actionName == 'favorited', 'nav_timeline_favorited');
  424. }
  425. }
  426. public function onEndShowSections(Action $action)
  427. {
  428. if (!$action->isAction(array('all', 'public'))) {
  429. return true;
  430. }
  431. if (!common_config('performance', 'high')) {
  432. $section = new PopularNoticeSection($action, $action->getScoped());
  433. $section->show();
  434. }
  435. }
  436. protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  437. {
  438. return Fave::existsForProfile($target, $scoped)
  439. // TRANS: Page/dialog box title when a notice is marked as favorite already
  440. ? _m('TITLE', 'Unmark notice as favorite')
  441. // TRANS: Page/dialog box title when a notice is not marked as favorite
  442. : _m('TITLE', 'Mark notice as favorite');
  443. }
  444. protected function doActionPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  445. {
  446. if ($action->isPost()) {
  447. // The below tests are only for presenting to the user. POSTs which inflict
  448. // duplicate favorite entries are handled with AlreadyFulfilledException.
  449. return false;
  450. }
  451. $exists = Fave::existsForProfile($target, $scoped);
  452. $expected_verb = $exists ? ActivityVerb::UNFAVORITE : ActivityVerb::FAVORITE;
  453. switch (true) {
  454. case $exists && ActivityUtils::compareVerbs($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
  455. case !$exists && ActivityUtils::compareVerbs($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
  456. common_redirect(common_local_url('activityverb',
  457. array('id' => $target->getID(),
  458. 'verb' => ActivityUtils::resolveUri($expected_verb, true))));
  459. break;
  460. default:
  461. // No need to redirect as we are on the correct action already.
  462. }
  463. return false;
  464. }
  465. protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  466. {
  467. switch (true) {
  468. case ActivityUtils::compareVerbs($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
  469. Fave::addNew($scoped, $target);
  470. break;
  471. case ActivityUtils::compareVerbs($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
  472. Fave::removeEntry($scoped, $target);
  473. break;
  474. default:
  475. throw new ServerException('ActivityVerb POST not handled by plugin that was supposed to do it.');
  476. }
  477. return false;
  478. }
  479. protected function getActivityForm(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  480. {
  481. return Fave::existsForProfile($target, $scoped)
  482. ? new DisfavorForm($action, $target)
  483. : new FavorForm($action, $target);
  484. }
  485. public function onPluginVersion(array &$versions)
  486. {
  487. $versions[] = array('name' => 'Favorite',
  488. 'version' => self::PLUGIN_VERSION,
  489. 'author' => 'Mikael Nordfeldth',
  490. 'homepage' => 'http://gnu.io/',
  491. 'rawdescription' =>
  492. // TRANS: Plugin description.
  493. _m('Favorites (likes) using ActivityStreams.'));
  494. return true;
  495. }
  496. }
  497. /**
  498. * Notify a user that one of their notices has been chosen as a 'fave'
  499. *
  500. * @param User $rcpt The user whose notice was faved
  501. * @param Profile $sender The user who faved the notice
  502. * @param Notice $notice The notice that was faved
  503. *
  504. * @return void
  505. */
  506. function mail_notify_fave(User $rcpt, Profile $sender, Notice $notice)
  507. {
  508. if (!$rcpt->receivesEmailNotifications() || !$rcpt->getConfigPref('email', 'notify_fave')) {
  509. return;
  510. }
  511. // This test is actually "if the sender is sandboxed"
  512. if (!$sender->hasRight(Right::EMAILONFAVE)) {
  513. return;
  514. }
  515. if ($rcpt->hasBlocked($sender)) {
  516. // If the author has blocked us, don't spam them with a notification.
  517. return;
  518. }
  519. // We need the global mail.php for various mail related functions below.
  520. require_once INSTALLDIR.'/lib/mail.php';
  521. $bestname = $sender->getBestName();
  522. common_switch_locale($rcpt->language);
  523. // TRANS: Subject for favorite notification e-mail.
  524. // TRANS: %1$s is the adding user's long name, %2$s is the adding user's nickname.
  525. $subject = sprintf(_('%1$s (@%2$s) added your notice as a favorite'), $bestname, $sender->getNickname());
  526. // TRANS: Body for favorite notification e-mail.
  527. // TRANS: %1$s is the adding user's long name, $2$s is the date the notice was created,
  528. // TRANS: %3$s is a URL to the faved notice, %4$s is the faved notice text,
  529. // TRANS: %5$s is a URL to all faves of the adding user, %6$s is the StatusNet sitename,
  530. // TRANS: %7$s is the adding user's nickname.
  531. $body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s".
  532. " as one of their favorites.\n\n" .
  533. "The URL of your notice is:\n\n" .
  534. "%3\$s\n\n" .
  535. "The text of your notice is:\n\n" .
  536. "%4\$s\n\n" .
  537. "You can see the list of %1\$s's favorites here:\n\n" .
  538. "%5\$s"),
  539. $bestname,
  540. common_exact_date($notice->created),
  541. common_local_url('shownotice',
  542. array('notice' => $notice->id)),
  543. $notice->content,
  544. common_local_url('showfavorites',
  545. array('nickname' => $sender->getNickname())),
  546. common_config('site', 'name'),
  547. $sender->getNickname()) .
  548. mail_footer_block();
  549. $headers = _mail_prepare_headers('fave', $rcpt->getNickname(), $sender->getNickname());
  550. common_switch_locale();
  551. mail_to_user($rcpt, $subject, $body, $headers);
  552. }