]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.8.x' into deleteuser
authorEvan Prodromou <evan@status.net>
Fri, 2 Oct 2009 19:27:55 +0000 (15:27 -0400)
committerEvan Prodromou <evan@status.net>
Fri, 2 Oct 2009 19:27:55 +0000 (15:27 -0400)
1  2 
classes/Profile.php
classes/User.php

diff --combined classes/Profile.php
index 0ee6fa657fdee3eca628d0ae9766fc414fa83bc7,6ad0e7a3a3b3f3884fbe221466cb034938550551..463802b4ee1a8dbbac008b21c9b3d349aaa4d542
@@@ -1,7 -1,7 +1,7 @@@
  <?php
  /*
-  * Laconica - a distributed open-source microblogging tool
-  * Copyright (C) 2008, 2009, Control Yourself, Inc.
+  * StatusNet - the distributed open-source microblogging tool
+  * Copyright (C) 2008, 2009, StatusNet, 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
@@@ -17,7 -17,7 +17,7 @@@
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  
- if (!defined('LACONICA')) { exit(1); }
+ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
  
  /**
   * Table Definition for profile
@@@ -461,79 -461,4 +461,79 @@@ class Profile extends Memcached_DataObj
              $c->delete(common_cache_key('profile:notice_count:'.$this->id));
          }
      }
 +
 +    function delete()
 +    {
 +        $this->_deleteNotices();
 +        $this->_deleteSubscriptions();
 +        $this->_deleteMessages();
 +        $this->_deleteTags();
 +        $this->_deleteBlocks();
 +
 +        $related = array('Avatar',
 +                         'Reply',
 +                         'Group_member',
 +                         );
 +
 +        foreach ($related as $cls) {
 +            $inst = new $cls();
 +            $inst->profile_id = $this->id;
 +            $inst->delete();
 +        }
 +
 +        parent::delete();
 +    }
 +
 +    function _deleteNotices()
 +    {
 +        $notice = new Notice();
 +        $notice->profile_id = $this->id;
 +
 +        if ($notice->find()) {
 +            while ($notice->fetch()) {
 +                $other = clone($notice);
 +                $other->delete();
 +            }
 +        }
 +    }
 +
 +    function _deleteSubscriptions()
 +    {
 +        $sub = new Subscription();
 +        $sub->subscriber = $this->id;
 +        $sub->delete();
 +
 +        $subd = new Subscription();
 +        $subd->subscribed = $this->id;
 +        $subd->delete();
 +    }
 +
 +    function _deleteMessages()
 +    {
 +        $msg = new Message();
 +        $msg->from_profile = $this->id;
 +        $msg->delete();
 +
 +        $msg = new Message();
 +        $msg->to_profile = $this->id;
 +        $msg->delete();
 +    }
 +
 +    function _deleteTags()
 +    {
 +        $tag = new Profile_tag();
 +        $tag->tagged = $this->id;
 +        $msg->delete();
 +    }
 +
 +    function _deleteBlocks()
 +    {
 +        $block = new Profile_block();
 +        $block->blocked = $this->id;
 +        $block->delete();
 +
 +        $block = new Group_block();
 +        $block->blocked = $this->id;
 +        $block->delete();
 +    }
  }
diff --combined classes/User.php
index 991e9c18fbab1a35a028222cf8de9d25b3dbe171,8386f1e185bb7e41bbf4191e4a504bb195b9b848..ef843429222dac09fb9dccfa3df9dcae2c682b0a
@@@ -1,7 -1,7 +1,7 @@@
  <?php
  /*
-  * Laconica - a distributed open-source microblogging tool
-  * Copyright (C) 2008, 2009, Control Yourself, Inc.
+  * StatusNet - the distributed open-source microblogging tool
+  * Copyright (C) 2008, 2009, StatusNet, 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
@@@ -17,7 -17,7 +17,7 @@@
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  
- if (!defined('LACONICA')) {
+ if (!defined('STATUSNET') && !defined('LACONICA')) {
      exit(1);
  }
  
@@@ -120,11 -120,15 +120,15 @@@ class User extends Memcached_DataObjec
      function allowed_nickname($nickname)
      {
          // XXX: should already be validated for size, content, etc.
-         static $blacklist = array('rss', 'xrds', 'doc', 'main',
-                                   'settings', 'notice', 'user',
-                                   'search', 'avatar', 'tag', 'tags',
-                                   'api', 'message', 'group', 'groups',
-                                   'local');
+         $blacklist = array();
+         //all directory and file names should be blacklisted
+         $d = dir(INSTALLDIR);
+         while (false !== ($entry = $d->read())) {
+             $blacklist[]=$entry;
+         }
+         $d->close();
          $merged = array_merge($blacklist, common_config('nickname', 'blacklist'));
          return !in_array($nickname, $merged);
      }
      {
          return Design::staticGet('id', $this->design_id);
      }
 +
 +    function delete()
 +    {
 +        $profile = $this->getProfile();
 +        $profile->delete();
 +
 +        $related = array('Fave',
 +                         'User_openid',
 +                         'Confirm_address',
 +                         'Remember_me',
 +                         'Foreign_link',
 +                         'Invitation',
 +                         );
 +
 +        if (common_config('inboxes', 'enabled')) {
 +            $related[] = 'Notice_inbox';
 +        }
 +
 +        foreach ($related as $cls) {
 +            $inst = new $cls();
 +            $inst->user_id = $this->id;
 +            $inst->delete();
 +        }
 +
 +        $this->_deleteTags();
 +
 +        parent::delete();
 +    }
 +
 +    function _deleteTags()
 +    {
 +        $tag = new Profile_tag();
 +        $tag->tagger = $this->id;
 +        $tag->delete();
 +    }
 +
 +    function _deleteBlocks()
 +    {
 +        $block = new Profile_block();
 +        $block->blocker = $this->id;
 +        $block->delete();
 +        // XXX delete group block? Reset blocker?
 +    }
  }