]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/favor.php
moving delete profile to its own space.
[quix0rs-gnu-social.git] / actions / favor.php
index a5163efed66fb32cd103eacdc91d89550845c6e3..82b70a35b2fce14122c41d228cbe97b177b9d80e 100644 (file)
@@ -38,16 +38,17 @@ class FavorAction extends Action {
                        return;
                }
 
+               $id = $this->trimmed('notice');
+
+               $notice = Notice::staticGet($id);
+
                # CSRF protection
 
-               $token = $this->trimmed('token');
+               $token = $this->trimmed('token-'.$notice->id);
                if (!$token || $token != common_session_token()) {
-                       $this->client_error(_('There was a problem with your session token. Try again, please.'));
+                       $this->client_error(_("There was a problem with your session token. Try again, please."));
                        return;
                }
-               $id = $this->trimmed('notice');
-
-               $notice = Notice::staticGet($id);
 
                if ($user->hasFave($notice)) {
                        $this->client_error(_('This notice is already a favorite!'));
@@ -62,11 +63,12 @@ class FavorAction extends Action {
                }
 
                $this->notify($fave, $notice, $user);
-
+               $user->blowFavesCache();
+               
                if ($this->boolean('ajax')) {
                        common_start_html('text/xml');
                        common_element_start('head');
-                       common_element('title', _('Disfavor'));
+                       common_element('title', null, _('Disfavor favorite'));
                        common_element_end('head');
                        common_element_start('body');
                        common_disfavor_form($notice);
@@ -82,30 +84,11 @@ class FavorAction extends Action {
            $other = User::staticGet('id', $notice->profile_id);
                if ($other && $other->id != $user->id) {
                        if ($other->email && $other->emailnotifyfav) {
-                               $this->notify_mail($other, $user, $notice);
+                               mail_notify_fave($other, $user, $notice);
                        }
                        # XXX: notify by IM
                        # XXX: notify by SMS
                }
        }
 
-       function notify_mail($other, $user, $notice) {
-               $profile = $user->getProfile();
-               $bestname = $profile->getBestName();
-               $subject = sprintf(_('%s added your notice as a favorite'), $bestname);
-               $body = sprintf(_('%1$s just added your notice from %2$s as one of their favorites.\n\n' .
-                                                 'In case you forgot, you can see the text of your notice here:\n\n' .
-                                                 '%3$s\n\n' .
-                                                 'You can see the list of %1$s\'s favorites here:\n\n' .
-                                                 '%4$s\n\n' .
-                                                 'Faithfully yours,\n' .
-                                                 '%5$s\n'),
-                                               $bestname,
-                                               common_exact_date($notice->created),
-                                               common_local_url('shownotice', array('notice' => $notice->id)),
-                                               common_local_url('showfavorites', array('nickname' => $user->nickname)),
-                                               common_config('site', 'name'));
-
-               mail_to_user($other, $subject, $body);
-       }
 }
\ No newline at end of file