]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
done delete own profile (see other settings)
authormillette <millette@controlyourself.ca>
Thu, 4 Dec 2008 18:02:33 +0000 (13:02 -0500)
committermillette <millette@controlyourself.ca>
Thu, 4 Dec 2008 18:02:33 +0000 (13:02 -0500)
darcs-hash:20081204180233-099f7-7728ee57876b789278aa1cc35f54e0a422593e5d.gz

actions/deleteprofile.php
actions/othersettings.php
htaccess.sample
lib/deleteprofileaction.php [deleted file]
lib/util.php

index 4328dfc2ce7aea97a728b7df2eb5ed3e3fb6ae8f..99e65ceb7bcea76db33d252c27d7d6ceafb0a2a3 100644 (file)
 
 if (!defined('LACONICA')) { exit(1); }
 
-require_once(INSTALLDIR.'/lib/settingsaction.php');
-
-class DeleteprofileAction extends Action { // was SettingsAction...
+class DeleteprofileAction extends Action {
+    function handle($args) {
+        parent::handle($args);
+        if ('POST' === $_SERVER['REQUEST_METHOD']) {
+            $this->handle_post();
+        }
+        else if ('GET' === $_SERVER['REQUEST_METHOD']) {
+            $this->show_form();
+        }
+    }
 
        function get_instructions() {
-               return _('You can update your personal profile info here '.
-                                 'so people know more about you.');
+               return _('Export and delete your user information.');
        }
 
-       function show_form($msg=NULL, $success=false) {
-               $this->form_header(_('Delete my account'), $msg, $success);
-               common_element('h2', NULL, _('Delete my account'));
-               $this->show_delete_form();
-               common_show_footer();
-       }
-
-       function handle_post() {
-
-               # CSRF protection
-
-               $token = $this->trimmed('token');
-               if (!$token || $token != common_session_token()) {
-                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
-                       return;
-               }
-
-               if ($this->arg('deleteaccount')) {
-                       $this->delete_account_confirmation();
-               }
-
+       function form_header($title, $msg=NULL, $success=false) {
+               common_show_header($title,
+                                  NULL,
+                                  array($msg, $success),
+                                                  array($this, 'show_top'));
        }
 
        function show_feeds_list($feeds) {
@@ -92,7 +82,14 @@ class DeleteprofileAction extends Action { // was SettingsAction...
                common_element_end('li');
        }
 
-       function show_delete_form() {
+       function show_form($msg=NULL, $success=false) {
+               $this->form_header(_('Delete my account'), $msg, $success);
+               common_element('h2', NULL, _('Delete my account confirmation'));
+               $this->show_confirm_delete_form();
+               common_show_footer();
+       }
+
+       function show_confirm_delete_form() {
                $user = common_current_user();
         $notices = DB_DataObject::factory('notice');
         $notices->profile_id = $user->id;
@@ -101,10 +98,10 @@ class DeleteprofileAction extends Action { // was SettingsAction...
                common_element_start('form', array('method' => 'POST',
                                                                                   'id' => 'delete',
                                                                                   'action' =>
-                                                                                  common_local_url('profilesettings')));
+                                                                                  common_local_url('deleteprofile')));
 
                common_hidden('token', common_session_token());
-        common_element('p', null, "You can copy your notices and contacts by saving the two links belowxbefore deleting your account. Be careful, this operation cannot be undone.");
+        common_element('p', null, "Last chance to copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone.");
 
 
                $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)), 
@@ -116,13 +113,24 @@ class DeleteprofileAction extends Action { // was SettingsAction...
                                                                                          'version' => 'FOAF',
                                                                                          'item' => 'foaf')));
 
+        common_checkbox('confirmation', _('Check if you are sure you want to delete your account.'));
+
                common_submit('deleteaccount', _('Delete my account'));
                common_element_end('form');
-       }
+    }
+
+       function handle_post() {
+               # CSRF protection
+               $token = $this->trimmed('token');
+               if (!$token || $token != common_session_token()) {
+                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
+                       return;
+               }
 
-    function delete_account_confirmation() {
-        // ask confirmation then
-        $this->delete_account();
+        if ($this->arg('deleteaccount') && $this->arg('confirmation')) {
+            $this->delete_account();
+        }
+        $this->show_form();
     }
 
        function delete_account() {
@@ -209,4 +217,60 @@ class DeleteprofileAction extends Action { // was SettingsAction...
         common_forgetme(); # don't log back in!
         common_redirect(common_local_url('public'));
     }
+
+       function show_top($arr) {
+               $msg = $arr[0];
+               $success = $arr[1];
+               if ($msg) {
+                       $this->message($msg, $success);
+               } else {
+                       $inst = $this->get_instructions();
+                       $output = common_markup_to_html($inst);
+                       common_element_start('div', 'instructions');
+                       common_raw($output);
+                       common_element_end('div');
+               }
+               $this->settings_menu();
+       }
+
+    function settings_menu() {
+        # action => array('prompt', 'title')
+               $menu =
+                 array('profilesettings' =>
+                               array(_('Profile'),
+                                         _('Change your profile settings')),
+                               'emailsettings' =>
+                               array(_('Email'),
+                                         _('Change email handling')),
+                               'openidsettings' =>
+                               array(_('OpenID'),
+                                         _('Add or remove OpenIDs')),
+                               'smssettings' =>
+                               array(_('SMS'),
+                                         _('Updates by SMS')),
+                               'imsettings' =>
+                               array(_('IM'),
+                                         _('Updates by instant messenger (IM)')),
+                               'twittersettings' =>
+                               array(_('Twitter'),
+                                         _('Twitter integration options')),
+                               'othersettings' =>
+                               array(_('Other'),
+                                         _('Other options')));
+               
+        $action = $this->trimmed('action');
+        common_element_start('ul', array('id' => 'nav_views'));
+        foreach ($menu as $menuaction => $menudesc) {
+                       if ($menuaction == 'imsettings' &&
+                               !common_config('xmpp', 'enabled')) {
+                               continue;
+                       }
+            common_menu_item(common_local_url($menuaction),
+                    $menudesc[0],
+                    $menudesc[1],
+                    $action == $menuaction);
+        }
+        common_element_end('ul');
+    }
 }
+
index 42502f828f9094efb37f3cdba4d3ddac25b03eaf..d956320d898ae2061c51d1cadd0dfdcbedd5f61f 100644 (file)
@@ -32,13 +32,13 @@ class OthersettingsAction extends SettingsAction {
                
                $this->form_header(_('Other Settings'), $msg, $success);
                
+               common_element('h2', NULL, _('URL Auto-shortening'));
                common_element_start('form', array('method' => 'post',
                                                                                   'id' => 'othersettings',
                                                                                   'action' =>
                                                                                   common_local_url('othersettings')));
                common_hidden('token', common_session_token());
 
-               common_element('h2', NULL, _('URL Auto-shortening'));
                $services = array(
                        '' => 'None',
             'ur1.ca' => 'ur1.ca (free service)',
@@ -56,9 +56,83 @@ class OthersettingsAction extends SettingsAction {
                common_submit('save', _('Save'));
                
                common_element_end('form');
+
+               common_element('h2', NULL, _('Delete my account'));
+               $this->show_delete_form();
+
                common_show_footer();
        }
 
+       function show_feeds_list($feeds) {
+               common_element_start('div', array('class' => 'feedsdel'));
+               common_element('p', null, 'Feeds:');
+               common_element_start('ul', array('class' => 'xoxo'));
+
+               foreach ($feeds as $key => $value) {
+                       $this->common_feed_item($feeds[$key]);
+               }
+               common_element_end('ul');
+               common_element_end('div');
+       }
+
+    //TODO move to common.php (and retrace its origin)
+       function common_feed_item($feed) {
+        $user = common_current_user();
+               $nickname = $user->nickname;
+
+               switch($feed['item']) {
+                       case 'notices': default:
+                               $feed_classname = $feed['type'];
+                               $feed_mimetype = "application/".$feed['type']."+xml";
+                               $feed_title = "$nickname's ".$feed['version']." notice feed";
+                               $feed['textContent'] = "RSS";
+                               break;
+
+                       case 'foaf':
+                               $feed_classname = "foaf";
+                               $feed_mimetype = "application/".$feed['type']."+xml";
+                               $feed_title = "$nickname's FOAF file";
+                               $feed['textContent'] = "FOAF";
+                               break;
+               }
+               common_element_start('li');
+               common_element('a', array('href' => $feed['href'],
+                                                                 'class' => $feed_classname,
+                                                                 'type' => $feed_mimetype,
+                                                                 'title' => $feed_title),
+                                                       $feed['textContent']);
+               common_element_end('li');
+       }
+
+       function show_delete_form() {
+               $user = common_current_user();
+        $notices = DB_DataObject::factory('notice');
+        $notices->profile_id = $user->id;
+        $notice_count = (int) $notices->count();
+
+               common_element_start('form', array('method' => 'POST',
+                                                                                  'id' => 'delete',
+                                                                                  'action' =>
+                                                                                  common_local_url('deleteprofile')));
+
+               common_hidden('token', common_session_token());
+        common_element('p', null, "You can copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone.");
+
+
+               $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)), 
+                                                                                         'type' => 'rss',
+                                                                                         'version' => 'RSS 1.0',
+                                                                                         'item' => 'notices'),
+                                                                        1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
+                                                                                         'type' => 'rdf',
+                                                                                         'version' => 'FOAF',
+                                                                                         'item' => 'foaf')));
+
+               common_submit('deleteaccount', _('Delete my account'));
+               common_element_end('form');
+       }
+
+
        function handle_post() {
 
                # CSRF protection
index c3198209ecfe2e5bc8e9da1838ecec3e51fde0a4..b0e89b9f27e1057f53c3cb1a8c3784b05abbbcc5 100644 (file)
@@ -44,6 +44,7 @@ RewriteRule ^main/sup$ index.php?action=sup [L,QSA]
 
 RewriteRule ^main/tagother$ index.php?action=tagother [L,QSA]
 
+RewriteRule ^settings/delete$ index.php?action=deleteprofile [L,QSA]
 RewriteRule ^settings/profile$ index.php?action=profilesettings [L,QSA]
 RewriteRule ^settings/openid$ index.php?action=openidsettings [L,QSA]
 RewriteRule ^settings/im$ index.php?action=imsettings [L,QSA]
diff --git a/lib/deleteprofileaction.php b/lib/deleteprofileaction.php
deleted file mode 100644 (file)
index 5ba0e7e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-if (!defined('LACONICA')) { exit(1); }
-
-class DeleteAction extends Action {
-
-       function handle($args) {
-               parent::handle($args);
-               $user = common_current_user();
-               $notice_id = $this->trimmed('notice');
-               $notice = Notice::staticGet($notice_id);
-               if (!$notice) {
-                       common_user_error(_('No such notice.'));
-                       exit;
-               }
-
-               $profile = $notice->getProfile();
-               $user_profile = $user->getProfile();
-
-               if (!common_logged_in()) {
-                       common_user_error(_('Not logged in.'));
-                       exit;
-               } else if ($notice->profile_id != $user_profile->id) {
-                       common_user_error(_('Can\'t delete this notice.'));
-                       exit;
-               }
-       }
-
-       function show_top($arr=NULL) {
-               $instr = $this->get_instructions();
-               $output = common_markup_to_html($instr);
-               common_element_start('div', 'instructions');
-               common_raw($output);
-               common_element_end('div');
-       }
-
-       function get_title() {
-               return NULL;
-       }
-
-       function show_header() {
-               return;
-       }
-}
index eb5667f6a9572cafcea3b1578e76d01b4be3c92f..204ad511ca85b96ab833c4b752b572ca7bda8ea2 100644 (file)
@@ -1107,6 +1107,8 @@ function common_fancy_url($action, $args=NULL) {
                return common_path('settings/twitter');
         case 'othersettings':
                return common_path('settings/other');
+     case 'deleteprofile':
+        return common_path('settings/delete');
         case 'newnotice':
                if ($args && $args['replyto']) {
                        return common_path('notice/new?replyto='.$args['replyto']);
@@ -2160,4 +2162,4 @@ function common_memcache() {
 function common_compatible_license($from, $to) {
        # XXX: better compatibility check needed here!
        return ($from == $to);
-}
\ No newline at end of file
+}