FavoritePlugin.php 24 KB

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