示例#1
0
 /**
  * Fetch admin IDs
  */
 public static function get_admin_ids()
 {
     if (!Container::get('cache')->isCached('admin_ids')) {
         Container::get('cache')->store('admin_ids', \FeatherBB\Model\Cache::get_admin_ids());
     }
     return Container::get('cache')->retrieve('admin_ids');
 }
示例#2
0
 /**
  * Fetch admin IDs
  */
 public static function get_admin_ids()
 {
     self::$feather = \Slim\Slim::getInstance();
     if (!self::$feather->cache->isCached('admin_ids')) {
         self::$feather->cache->store('admin_ids', \FeatherBB\Model\Cache::get_admin_ids());
     }
     return self::$feather->cache->retrieve('admin_ids');
 }
示例#3
0
 public static function get_admin_ids()
 {
     // Get Slim current session
     $feather = \Slim\Slim::getInstance();
     if (!$feather->cache->isCached('admin_ids')) {
         $feather->cache->store('admin_ids', Cache::get_admin_ids());
     }
     return $feather->cache->retrieve('admin_ids');
 }
示例#4
0
 public function delete_user($id)
 {
     $id = Container::get('hooks')->fire('model.profile.delete_user_start', $id);
     // Get the username and group of the user we are deleting
     $result['select'] = array('group_id', 'username');
     $result = DB::for_table('users')->where('id', $id)->select_many($result['select']);
     $result = Container::get('hooks')->fireDB('model.profile.delete_user_username', $result);
     $result = $result->find_one();
     $group_id = $result['group_id'];
     $username = $result['username'];
     if ($group_id == ForumEnv::get('FEATHER_ADMIN')) {
         throw new Error(__('No delete admin message'));
     }
     if (Input::post('delete_user_comply')) {
         // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well
         $group_mod = DB::for_table('groups')->where('g_id', $group_id);
         $group_mod = Container::get('hooks')->fireDB('model.profile.delete_user_group_mod', $group_mod);
         $group_mod = $group_mod->find_one_col('g_moderator');
         if ($group_id == ForumEnv::get('FEATHER_ADMIN') || $group_mod == '1') {
             // Loop through all forums
             $result = $this->loop_mod_forums();
             foreach ($result as $cur_forum) {
                 $cur_moderators = $cur_forum['moderators'] != '' ? unserialize($cur_forum['moderators']) : array();
                 if (in_array($id, $cur_moderators)) {
                     unset($cur_moderators[$username]);
                     $update_forums = DB::for_table('forums')->where('id', $cur_forum['id'])->find_one();
                     if (!empty($cur_moderators)) {
                         $update_forums = $update_forums->set('moderators', serialize($cur_moderators));
                     } else {
                         $update_forums = $update_forums->set_expr('moderators', 'NULL');
                     }
                     $update_forums = Container::get('hooks')->fireDB('model.profile.update_mod_forums_query', $update_forums);
                     $update_forums = $update_forums->save();
                 }
             }
         }
         // Delete any subscriptions
         $delete_subscriptions = DB::for_table('topic_subscriptions')->where('user_id', $id);
         $delete_subscriptions = Container::get('hooks')->fireDB('model.profile.delete_user_subscriptions_topic', $delete_subscriptions);
         $delete_subscriptions = $delete_subscriptions->delete_many();
         unset($delete_subscriptions);
         $delete_subscriptions = DB::for_table('forum_subscriptions')->where('user_id', $id);
         $delete_subscriptions = Container::get('hooks')->fireDB('model.profile.delete_user_subscriptions_forum', $delete_subscriptions);
         $delete_subscriptions = $delete_subscriptions->delete_many();
         // Remove him/her from the online list (if they happen to be logged in)
         $delete_online = DB::for_table('online')->where('user_id', $id);
         $delete_online = Container::get('hooks')->fireDB('model.profile.delete_user_online', $delete_online);
         $delete_online = $delete_online->delete_many();
         // Should we delete all posts made by this user?
         if (Input::post('delete_posts')) {
             // Hold on, this could take some time!
             @set_time_limit(0);
             Container::get('hooks')->fire('model.profile.delete_user_posts');
             // Find all posts made by this user
             unset($result);
             $result['select'] = array('p.id', 'p.topic_id', 't.forum_id');
             $result = DB::for_table('posts')->table_alias('p')->select_many($result['select'])->inner_join('topics', array('t.id', '=', 'p.topic_id'), 't')->inner_join('forums', array('f.id', '=', 't.forum_id'), 'f')->where('p.poster_id', $id);
             $result = Container::get('hooks')->fireDB('model.profile.delete_user_posts_first_query', $result);
             $result = $result->find_many();
             if ($result) {
                 foreach ($result as $cur_post) {
                     // Determine whether this post is the "topic post" or not
                     $result2 = DB::for_table('posts')->where('topic_id', $cur_post['topic_id'])->order_by('posted');
                     $result2 = Container::get('hooks')->fireDB('model.profile.delete_user_posts_second_query', $result2);
                     $result2 = $result2->find_one_col('id');
                     if ($result2 == $cur_post['id']) {
                         Delete::topic($cur_post['topic_id']);
                     } else {
                         Delete::post($cur_post['id'], $cur_post['topic_id']);
                     }
                     Forum::update($cur_post['forum_id']);
                 }
             }
         } else {
             // Set all his/her posts to guest
             $update_guest = DB::for_table('posts')->where_in('poster_id', '1');
             $update_guest = Container::get('hooks')->fireDB('model.profile.delete_user_posts_guest_query', $update_guest);
             $update_guest = $update_guest->update_many('poster_id', $id);
         }
         // Delete the user
         $delete_user = DB::for_table('users')->where('id', $id);
         $delete_user = $delete_user->delete_many();
         // Delete user avatar
         $this->delete_avatar($id);
         // Regenerate the users info cache
         Container::get('cache')->store('users_info', Cache::get_users_info());
         $stats = Container::get('cache')->retrieve('users_info');
         if ($group_id == ForumEnv::get('FEATHER_ADMIN')) {
             Container::get('cache')->store('admin_ids', Cache::get_admin_ids());
         }
         Container::get('hooks')->fire('model.profile.delete_user');
         return Router::redirect(Router::pathFor('home'), __('User delete redirect'));
     }
 }
示例#5
0
 public static function get_admin_ids()
 {
     // Get Slim current session
     if (!Container::get('cache')->isCached('admin_ids')) {
         Container::get('cache')->store('admin_ids', Cache::get_admin_ids());
     }
     return Container::get('cache')->retrieve('admin_ids');
 }