Пример #1
0
 /**
  * Show the add/edit group form
  *
  * @param 	string		'add' or 'edit'
  * @return	@e void		[Outputs to screen]
  * @todo	_initTab doesn't seem to work anymore with the new tabs, need to update each app to have a unique name/id
  */
 protected function _groupForm($type = 'edit')
 {
     //-----------------------------------------
     // Grab group data and start us off
     //-----------------------------------------
     if ($type == 'edit') {
         if ($this->request['id'] == "") {
             $this->registry->output->showError($this->lang->words['g_whichgroup'], 11210);
         }
         $group = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'groups', 'where' => "g_id=" . intval($this->request['id'])));
         $group = IPSMember::unpackGroup($group, FALSE, TRUE);
         //-----------------------------------------
         // Check restrictions.
         //-----------------------------------------
         if ($group['g_access_cp']) {
             $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('groups_edit_admin');
         }
     } else {
         $group = array();
         if ($this->request['id']) {
             $group = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'groups', 'where' => "g_id=" . intval($this->request['id'])));
             $group = IPSMember::unpackGroup($group, FALSE, TRUE);
         }
         $group['g_title'] = 'New Group';
     }
     //-----------------------------------------
     // Grab permission masks
     //-----------------------------------------
     $perm_masks = array();
     $this->DB->build(array('select' => '*', 'from' => 'forum_perms', 'order' => 'perm_name ASC'));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $perm_masks[] = array($r['perm_id'], $r['perm_name']);
     }
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     $blocks = array('tabs' => array(), 'area' => array());
     IPSLib::loadInterface('admin/group_form.php');
     $tabsUsed = 5;
     $firstTab = empty($this->request['_initTab']) ? false : trim($this->request['_initTab']);
     foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
         if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/group_form.php')) {
             $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/group_form.php', 'admin_group_form__' . $app_dir, $app_dir);
             if (class_exists($_class)) {
                 $_object = new $_class($this->registry);
                 $data = $_object->getDisplayContent($group, $tabsUsed);
                 $blocks['area'][$app_dir] = $data['content'];
                 $blocks['tabs'][$app_dir] = $data['tabs'];
                 $tabsUsed = $data['tabsUsed'] ? $tabsUsed + $data['tabsUsed'] : $tabsUsed + 1;
                 if (!empty($this->request['_initTab']) && $this->request['_initTab'] == $app_dir) {
                     $firstTab = $tabsUsed;
                 }
             }
         }
     }
     //-----------------------------------------
     // And output to form
     //-----------------------------------------
     $this->registry->output->extra_nav[] = array("{$this->settings['base_url']}&{$this->form_code}", $this->lang->words['menu__manage_groups']);
     $this->registry->output->html .= $this->html->groupsForm($type, $group, $perm_masks, $blocks, $firstTab);
 }
Пример #2
0
 /**
  * Save the forum
  *
  * @param	string		$type		[new|edit]
  * @return	@e void
  */
 public function forumSave($type = 'new')
 {
     /* If this is not a redirect forum anymore empty the redirect url - #35126 */
     if ($this->request['forum_type'] != 'redirect') {
         $this->request['redirect_url'] = '';
     }
     //-----------------------------------------
     // Converting the type?
     //-----------------------------------------
     if ($this->request['convert']) {
         $this->forumForm($type, 1);
         return;
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['name'] = trim($this->request['name']);
     $this->request['f'] = intval($this->request['f']);
     $this->request['parent_id'] = !empty($this->request['parent_id']) ? intval($this->request['parent_id']) : -1;
     $forum_cat_lang = intval($this->request['parent_id']) == -1 ? $this->lang->words['for_iscat_y'] : $this->lang->words['for_iscat_n'];
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     $this->registry->adminFunctions->checkSecurityKey();
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if ($this->request['name'] == "") {
         $this->registry->output->global_message = sprintf($this->lang->words['for_entertitle'], mb_strtolower($forum_cat_lang));
         $this->forumForm($type);
         return;
     }
     //-----------------------------------------
     // Are we trying to do something stupid
     // like running with scissors or moving
     // the parent of a forum into itself
     // spot?
     //-----------------------------------------
     if ($this->request['parent_id'] != $this->registry->getClass('class_forums')->forum_by_id[$this->request['f']]['parent_id']) {
         $ids = $this->registry->getClass('class_forums')->forumsGetChildren($this->request['f']);
         $ids[] = $this->request['f'];
         if (in_array($this->request['parent_id'], $ids)) {
             $this->registry->output->global_error = $this->lang->words['for_whymovethere'];
             $this->forumForm($type);
             return;
         }
     }
     //if( $this->request['parent_id'] < 1 )
     //{
     //	$this->request['sub_can_post'] = 1;
     //}
     //-----------------------------------------
     // Save array
     //-----------------------------------------
     $save = array('name' => IPSText::getTextClass('bbcode')->xssHtmlClean(nl2br(IPSText::stripslashes($_POST['name']))), 'name_seo' => IPSText::makeSeoTitle(strip_tags(IPSText::UNhtmlspecialchars($this->request['name']))), 'description' => IPSText::getTextClass('bbcode')->xssHtmlClean(nl2br(IPSText::stripslashes($_POST['description']))), 'use_ibc' => isset($this->request['use_ibc']) ? intval($this->request['use_ibc']) : 1, 'use_html' => intval($this->request['use_html']), 'password' => $this->request['password'], 'password_override' => is_array($this->request['password_override']) ? implode(",", $this->request['password_override']) : '', 'sort_key' => $this->request['sort_key'], 'sort_order' => $this->request['sort_order'], 'prune' => intval($this->request['prune']), 'topicfilter' => $this->request['topicfilter'], 'preview_posts' => intval($this->request['preview_posts']), 'allow_poll' => intval($this->request['allow_poll']), 'allow_pollbump' => intval($this->request['allow_pollbump']), 'forum_allow_rating' => intval($this->request['forum_allow_rating']), 'inc_postcount' => intval($this->request['inc_postcount']), 'parent_id' => intval($this->request['parent_id']), 'sub_can_post' => intval($this->request['sub_can_post']), 'redirect_on' => intval($this->request['redirect_on']), 'redirect_hits' => intval($this->request['redirect_hits']), 'redirect_url' => $this->request['redirect_url'], 'notify_modq_emails' => $this->request['notify_modq_emails'], 'permission_showtopic' => $this->request['parent_id'] == -1 ? 1 : intval($this->request['permission_showtopic']), 'min_posts_post' => intval($this->request['min_posts_post']), 'min_posts_view' => intval($this->request['min_posts_view']), 'can_view_others' => intval($this->request['can_view_others']), 'hide_last_info' => intval($this->request['hide_last_info']), 'disable_sharelinks' => intval($this->request['disable_sharelinks']), 'tag_predefined' => $this->request['tag_predefined'], 'forums_bitoptions' => IPSBWOPtions::freeze($this->request, 'forums', 'forums'), 'permission_custom_error' => nl2br(IPSText::stripslashes($_POST['permission_custom_error'])), 'ipseo_priority' => $this->request['ipseo_priority'], 'viglink' => intval($this->request['viglink']));
     /* Save data from application tabs */
     IPSLib::loadInterface('admin/forum_form.php');
     $_forumPlugins = array();
     foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
         if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/forum_form.php')) {
             $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/forum_form.php', 'admin_forum_form__' . $app_dir, $app_dir);
             $_forumPlugins[$_class] = new $_class($this->registry);
             $remote = $_forumPlugins[$_class]->getForSave();
             $save = array_merge($save, $remote);
         }
     }
     //-----------------------------------------
     // ADD
     //-----------------------------------------
     if ($type == 'new') {
         $this->DB->build(array('select' => 'MAX(id) as top_forum', 'from' => 'forums'));
         $this->DB->execute();
         $row = $this->DB->fetch();
         if ($row['top_forum'] < 1) {
             $row['top_forum'] = 0;
         }
         $row['top_forum']++;
         /* Forum Information */
         //$save['id']               = $row['top_forum'];
         $save['position'] = $row['top_forum'];
         $save['topics'] = 0;
         $save['posts'] = 0;
         $save['last_post'] = 0;
         $save['last_poster_id'] = 0;
         $save['last_poster_name'] = "";
         /* Insert the record */
         $this->DB->insert('forums', $save);
         $forum_id = $this->DB->getInsertId();
         /* Permissions */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions');
         $permissions = new $classToLoad(ipsRegistry::instance());
         $permissions->savePermMatrix($this->request['perms'], $forum_id, 'forum');
         if (!$save['can_view_others']) {
             $this->DB->update('permission_index', array('owner_only' => 1), "app='forums' AND perm_type='forum' AND perm_type_id={$forum_id}");
         }
         /* Done */
         $this->registry->output->global_message = $forum_cat_lang . $this->lang->words['for__created'];
         $this->registry->adminFunctions->saveAdminLog($forum_cat_lang . " '" . $this->request['name'] . "'" . mb_strtolower($this->lang->words['for__created']));
     } else {
         $forumData = $this->registry->class_forums->getForumById($this->request['f']);
         if ($this->request['parent_id'] == -1) {
             $save['can_view_others'] = 1;
             /* Permissions */
             //$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions' );
             //$permissions = new $classToLoad( ipsRegistry::instance() );
             //$permissions->savePermMatrix( $this->request['perms'], $this->request['f'], 'forum' );
             if (!$save['can_view_others']) {
                 $this->DB->update('permission_index', array('owner_only' => 1), "app='forums' AND perm_type='forum' AND perm_type_id={$this->request['f']}");
             } else {
                 $this->DB->update('permission_index', array('owner_only' => 0), "app='forums' AND perm_type='forum' AND perm_type_id={$this->request['f']}");
             }
         }
         $this->DB->update('forums', $save, "id=" . $this->request['f']);
         $forum_id = $this->request['f'];
         /* Tags */
         $this->registry->getClass('class_forums')->forumsInit();
         $this->registry->tags->updatePermssionsByParentId($this->request['f']);
         /* Did we enable/disable tagging? @todo find a better way to do this. Perhaps another field in tags? */
         if (isset($this->request['bw_disable_tagging'])) {
             if ($forumData['bw_disable_tagging'] != $this->request['bw_disable_tagging']) {
                 $toggle = $this->request['bw_disable_tagging'] ? 0 : 1;
                 $this->registry->tags->updateVisibilityByParentId($this->request['f'], $toggle);
                 if ($this->request['bw_disable_tagging'] == 0) {
                     /* We just restored all tags, so lets return hidden topics back to 0 */
                     $this->DB->build(array('select' => 'tid', 'from' => 'topics', 'where' => 'forum_id=' . $this->request['f'] . ' AND ' . $this->registry->class_forums->fetchTopicHiddenQuery(array('sdeleted', 'hidden', 'pdelete', 'oktoremove')), 'order' => 'last_post DESC', 'limit' => array(0, 500)));
                     $this->DB->execute();
                     $topics = array();
                     while ($row = $this->DB->fetch()) {
                         $topics[] = $row['tid'];
                     }
                     if (count($topics)) {
                         $this->registry->tags->updateVisibilityByMetaId($topics, 0);
                     }
                 }
             }
         }
         $this->registry->output->global_message = $forum_cat_lang . $this->lang->words['for__edited'];
         $this->registry->adminFunctions->saveAdminLog($forum_cat_lang . " '" . $this->request['name'] . "' " . mb_strtolower($this->lang->words['for__edited']));
     }
     $this->request['f'] = '';
     if ($save['parent_id'] > 0) {
         $this->request['f'] = $save['parent_id'];
     }
     //-----------------------------------------
     // Post save callbacks
     //-----------------------------------------
     if (count($_forumPlugins)) {
         foreach ($_forumPlugins as $_className => $_object) {
             if (method_exists($_object, 'postSave')) {
                 $_object->postSave($forum_id);
             }
         }
     }
     $this->registry->getClass('class_forums')->forumsInit();
     $this->showForums();
 }
 /**
  * Edit a member [process]
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _memberDoEdit()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['member_id'] = intval($this->request['member_id']);
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
     //-----------------------------------------
     // Load and config the std/rte editors
     //-----------------------------------------
     IPSText::getTextClass('editor')->from_acp = 1;
     //-----------------------------------------
     // Get member
     //-----------------------------------------
     $member = IPSMember::load($this->request['member_id'], 'all');
     //-----------------------------------------
     // Allowed to edit administrators?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id'] and $member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_editadmin'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Allowed to change an admin's groups?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin1')) {
         $same = false;
         if ($this->request['member_group_id'] == $member['member_group_id']) {
             $omgroups = explode(',', IPSText::cleanPermString($member['mgroup_others']));
             $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
             if (!count(array_diff($omgroups, $groups))) {
                 $same = true;
             }
         }
         if (!$same) {
             $this->registry->output->global_message = $this->lang->words['m_admindemote'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // What about promoting to admin?
     //-----------------------------------------
     if (!$member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) {
         $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
         $groups[] = intval($this->request['member_group_id']);
         foreach ($groups as $group_id) {
             if ($this->caches['group_cache'][$group_id]['g_access_cp']) {
                 $this->registry->output->global_message = $this->lang->words['m_adminpromote'];
                 $this->_memberView();
                 return;
             }
         }
     }
     if ($this->request['identity_url']) {
         $account = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "identity_url='" . trim($this->request['identity_url']) . "' AND member_id<>" . $member['member_id']));
         if ($account['member_id']) {
             $this->registry->output->global_message = $this->lang->words['identity_url_inuse'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // Convert sig
     //-----------------------------------------
     $signature = IPSText::getTextClass('editor')->processRawPost('signature');
     IPSText::getTextClass('bbcode')->parse_smilies = 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['sig_allow_ibc'];
     IPSText::getTextClass('bbcode')->parse_html = $this->settings['sig_allow_html'];
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
     $signature = IPSText::getTextClass('bbcode')->preDbParse($signature);
     $cacheSignature = IPSText::getTextClass('bbcode')->preDisplayParse($signature);
     //-----------------------------------------
     // And 'About Me'
     //-----------------------------------------
     $aboutme = IPSText::getTextClass('editor')->processRawPost('aboutme');
     IPSText::getTextClass('bbcode')->parse_smilies = $this->settings['aboutme_emoticons'];
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['aboutme_bbcode'];
     IPSText::getTextClass('bbcode')->parse_html = $this->settings['aboutme_html'];
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'aboutme';
     $aboutme = IPSText::getTextClass('bbcode')->preDbParse($aboutme);
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     $additionalCore = array();
     $additionalExtended = array();
     IPSLib::loadInterface('admin/member_form.php');
     foreach (ipsRegistry::$applications as $app_dir => $app_data) {
         if (!IPSLib::appIsInstalled($app_dir)) {
             continue;
         }
         if (file_exists(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php')) {
             require_once IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php';
             $_class = 'admin_member_form__' . $app_dir;
             $_object = new $_class($this->registry);
             $remote = $_object->getForSave();
             $additionalCore = array_merge($remote['core'], $additionalCore);
             $additionalExtended = array_merge($remote['extendedProfile'], $additionalExtended);
         }
     }
     //-----------------------------------------
     // Fix custom title
     // @see	http://forums./index.php?app=tracker&showissue=17383
     //-----------------------------------------
     $memberTitle = $this->request['title'];
     $rankCache = ipsRegistry::cache()->getCache('ranks');
     if (is_array($rankCache) && count($rankCache)) {
         foreach ($rankCache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 /* If this is the title passed to us from the form, we didn't have a custom title */
                 if ($v['TITLE'] == $memberTitle) {
                     $memberTitle = '';
                 }
                 break;
             }
         }
     }
     $newMember = array('member_group_id' => intval($this->request['member_group_id']), 'title' => $memberTitle, 'time_offset' => floatval($this->request['time_offset']), 'language' => $this->request['language'], 'skin' => intval($this->request['skin']), 'hide_email' => intval($this->request['hide_email']), 'allow_admin_mails' => intval($this->request['allow_admin_mails']), 'view_sigs' => intval($this->request['view_sigs']), 'view_pop' => intval($this->request['view_pop']), 'email_pm' => intval($this->request['email_pm']), 'posts' => intval($this->request['posts']), 'bday_day' => intval($this->request['bday_day']), 'bday_month' => intval($this->request['bday_month']), 'bday_year' => intval($this->request['bday_year']), 'warn_level' => intval($this->request['warn_level']), 'members_disable_pm' => intval($this->request['members_disable_pm']), 'mgroup_others' => $_POST['mgroup_others'] ? ',' . implode(",", $_POST['mgroup_others']) . ',' : '', 'identity_url' => trim($this->request['identity_url']));
     //-----------------------------------------
     // Throw to the DB
     //-----------------------------------------
     IPSMember::save($this->request['member_id'], array('core' => array_merge($newMember, $additionalCore), 'extendedProfile' => array_merge(array('pp_gender' => $this->request['pp_gender'] == 'male' ? 'male' : ($this->request['pp_gender'] == 'female' ? 'female' : ''), 'pp_bio_content' => IPSText::mbsubstr(nl2br($this->request['pp_bio_content']), 0, 300), 'pp_about_me' => $aboutme, 'signature' => $signature, 'pp_reputation_points' => intval($this->request['pp_reputation_points']), 'pp_status' => $this->request['pp_status'], 'pp_setting_count_visitors' => intval($this->request['pp_setting_count_visitors']), 'pp_setting_count_comments' => intval($this->request['pp_setting_count_comments']), 'pp_setting_count_friends' => intval($this->request['pp_setting_count_friends']), 'pp_setting_notify_comments' => $this->request['pp_setting_notify_comments'], 'pp_setting_notify_friend' => $this->request['pp_setting_notify_friend'], 'pp_setting_moderate_comments' => intval($this->request['pp_setting_moderate_comments']), 'pp_setting_moderate_friends' => intval($this->request['pp_setting_moderate_friends'])), $additionalExtended)));
     if ($member['member_group_id'] != $newMember['member_group_id']) {
         IPSLib::runMemberSync('onGroupChange', $this->request['member_id'], $newMember['member_group_id']);
         //-----------------------------------------
         // Remove restrictions if member demoted
         // Commenting out as this may cause more problems than it's worth
         // e.g. if you had accidentally changed their group, you'd need to reconfigure all restrictions
         //-----------------------------------------
         /*if( !$this->caches['group_cache'][ $newMember['member_group_id'] ]['g_access_cp'] )
         		{
         			$this->DB->delete( 'admin_permission_rows', 'row_id=' . $member['member_id'] . " AND row_id_type='member'" );
         		}*/
     }
     //-----------------------------------------
     // Restriction permissions stuff
     //-----------------------------------------
     if (is_array($this->registry->getClass('class_permissions')->restrictions_row) and count($this->registry->getClass('class_permissions')->restrictions_row)) {
         $is_admin = 0;
         $groups = ipsRegistry::cache()->getCache('group_cache');
         if (is_array($this->request['mgroup_others']) and count($this->request['mgroup_others'])) {
             foreach ($this->request['mgroup_others'] as $omg) {
                 if ($groups[intval($omg)]['g_access_cp']) {
                     $is_admin = 1;
                     break;
                 }
             }
         }
         if ($groups[intval($this->request['member_group_id'])]['g_access_cp']) {
             $is_admin = 1;
         }
         if ($is_admin) {
             //-------------------------------------------------
             // Copy restrictions if they do not have any yet...
             //-------------------------------------------------
             $check = $this->DB->buildAndFetch(array('select' => 'row_updated', 'from' => 'admin_permission_rows', 'where' => "row_id_type='member' AND row_id=" . $this->request['member_id']));
             if (!$check['row_updated']) {
                 $this->DB->replace('admin_permission_rows', array('row_id' => $this->request['member_id'], 'row_id_type' => 'member', 'row_perm_cache' => serialize($this->registry->getClass('class_permissions')->restrictions_row), 'row_updated' => time()), array('row_id', 'row_id_type'));
             }
         }
     }
     //-----------------------------------------
     // Moved from validating group?
     //-----------------------------------------
     if ($member['member_group_id'] == $this->settings['auth_group']) {
         if ($this->request['member_group_id'] != $this->settings['auth_group']) {
             //-----------------------------------------
             // Yes...
             //-----------------------------------------
             $this->DB->delete('validating', "member_id=" . $this->request['member_id']);
         }
     }
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $fields = new customProfileFields();
     $fields->initData('edit');
     $fields->parseToSave($_POST);
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     if (count($fields->out_fields)) {
         //-----------------------------------------
         // Do we already have an entry in
         // the content table?
         //-----------------------------------------
         $test = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'pfields_content', 'where' => 'member_id=' . $this->request['member_id']));
         if ($test['member_id']) {
             //-----------------------------------------
             // We have it, so simply update
             //-----------------------------------------
             $this->DB->force_data_type = array();
             foreach ($fields->out_fields as $_field => $_data) {
                 $this->DB->force_data_type[$_field] = 'string';
             }
             $this->DB->update('pfields_content', $fields->out_fields, 'member_id=' . $this->request['member_id']);
         } else {
             $this->DB->force_data_type = array();
             foreach ($fields->out_fields as $_field => $_data) {
                 $this->DB->force_data_type[$_field] = 'string';
             }
             $fields->out_fields['member_id'] = $this->request['member_id'];
             $this->DB->insert('pfields_content', $fields->out_fields);
         }
     }
     /* Update cache */
     IPSContentCache::update($this->request['member_id'], 'sig', $cacheSignature);
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_editedlog'], $member['members_display_name']));
     $this->registry->output->global_message = $this->lang->words['m_edited'];
     $newMember['member_id'] = $this->request['member_id'];
     $newMember['members_display_name'] = $member['members_display_name'];
     $triggerGroups = $member['mgroup_others'] ? implode(',', array_merge(is_array($member['mgroup_others']) ? $member['mgroup_others'] : array(), array($member['member_group_id']))) : $member['member_group_id'];
     //$this->_memberView();
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&trigger=' . $triggerGroups . '&member_id=' . $this->request['member_id']);
 }
Пример #4
0
 /**
  * Edit a member [process]
  *
  * @return	@e void
  */
 protected function _memberDoEdit()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['member_id'] = intval($this->request['member_id']);
     //-----------------------------------------
     // Send to form if this isn't a POST request
     //-----------------------------------------
     if ($this->request['request_method'] != 'post') {
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
     //-----------------------------------------
     // Load and config the std/rte editors
     //-----------------------------------------
     IPSText::getTextClass('editor')->from_acp = 1;
     //-----------------------------------------
     // Get member
     //-----------------------------------------
     $member = IPSMember::load($this->request['member_id'], 'all');
     //-----------------------------------------
     // Allowed to edit administrators?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id'] and $member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_editadmin'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Allowed to change an admin's groups?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin1')) {
         $same = false;
         if ($this->request['member_group_id'] == $member['member_group_id']) {
             $member['mgroup_others'] = IPSText::cleanPermString($member['mgroup_others']);
             $omgroups = $member['mgroup_others'] ? explode(',', $member['mgroup_others']) : array();
             $groups = $this->request['mgroup_others'] ? $this->request['mgroup_others'] : array();
             if (!count(array_diff($omgroups, $groups)) and !count(array_diff($groups, $omgroups))) {
                 $same = true;
             }
         }
         if (!$same) {
             $this->registry->output->global_message = $this->lang->words['m_admindemote'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // What about promoting to admin?
     //-----------------------------------------
     if (!$member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) {
         $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
         $groups[] = intval($this->request['member_group_id']);
         foreach ($groups as $group_id) {
             if ($this->caches['group_cache'][$group_id]['g_access_cp']) {
                 $this->registry->output->global_message = $this->lang->words['m_adminpromote'];
                 $this->_memberView();
                 return;
             }
         }
     }
     //-----------------------------------------
     // What about moving member in general?
     //-----------------------------------------
     if ($this->request['member_group_id'] != $member['member_group_id'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move')) {
         $this->registry->output->global_message = $this->lang->words['m_movemembers'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Restricted?
     //-----------------------------------------
     $restricted = (is_array($this->registry->getClass('class_permissions')->restrictions_row) and count($this->registry->getClass('class_permissions')->restrictions_row)) ? true : false;
     /* Load editor stuff */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
     $_editor = new $classToLoad();
     /* Load parser */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     /* Get signature */
     $_editor->setAllowBbcode(true);
     $_editor->setAllowSmilies(false);
     $_editor->setIsHtml($this->request['bw_html_sig'] && $member['g_dohtml']);
     $_editor->setAllowHtml($member['g_dohtml']);
     $_editor->setBbcodeSection('signatures');
     $signature = $_editor->process($_POST['signature']);
     $cacheSignature = $parser->display($signature);
     /* About me editor */
     $_editor->setAllowBbcode(true);
     $_editor->setAllowSmilies(true);
     $_editor->setAllowHtml($member['g_dohtml']);
     $_editor->setBbcodeSection('aboutme');
     $aboutme = $_editor->process($_POST['aboutme']);
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     $additionalCore = array();
     $additionalExtended = array();
     $additionalMCache = array();
     IPSLib::loadInterface('admin/member_form.php');
     foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
         if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php')) {
             $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php', 'admin_member_form__' . $app_dir, $app_dir);
             $_object = new $_class($this->registry);
             $remote = $_object->getForSave();
             $additionalCore = is_array($remote['core']) ? array_merge($remote['core'], $additionalCore) : $additionalCore;
             $additionalExtended = is_array($remote['extendedProfile']) ? array_merge($remote['extendedProfile'], $additionalExtended) : $additionalExtended;
             $additionalMCache = is_array($remote['member_cache']) ? array_merge($remote['member_cache'], $additionalMCache) : $additionalMCache;
         }
     }
     //-----------------------------------------
     // Fix custom title
     // @see	http://forums.invisionpower.com/index.php?app=tracker&showissue=17383
     //-----------------------------------------
     $memberTitle = $this->request['title'];
     $rankCache = ipsRegistry::cache()->getCache('ranks');
     if (is_array($rankCache) && count($rankCache)) {
         foreach ($rankCache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 /* If this is the title passed to us from the form, we didn't have a custom title */
                 if ($v['TITLE'] == $memberTitle) {
                     $memberTitle = '';
                 }
                 break;
             }
         }
     }
     //-----------------------------------------
     // Start array
     //-----------------------------------------
     $newMember = array('member_group_id' => intval($this->request['member_group_id']), 'title' => $memberTitle, 'time_offset' => floatval($this->request['time_offset']), 'members_auto_dst' => intval($this->request['dstCheck']), 'dst_in_use' => intval($this->request['dstOption']), 'language' => $this->request['language'], 'skin' => intval($this->request['skin']), 'allow_admin_mails' => intval($this->request['allow_admin_mails']), 'view_sigs' => intval($this->request['view_sigs']), 'posts' => intval($this->request['posts']), 'bday_day' => intval($this->request['bday_day']), 'bday_month' => intval($this->request['bday_month']), 'bday_year' => intval($this->request['bday_year']), 'warn_level' => intval($this->request['warn_level']), 'members_disable_pm' => intval($this->request['members_disable_pm']), 'mgroup_others' => $this->request['mgroup_others'] ? ',' . implode(",", $this->request['mgroup_others']) . ',' : '', 'members_bitoptions' => IPSBWOPtions::freeze($this->request, 'members', 'global'), 'member_uploader' => $this->request['member_uploader']);
     //-----------------------------------------
     // Notifications library
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications');
     $notifyLibrary = new $classToLoad($this->registry);
     $notifyLibrary->setMember($member);
     //-----------------------------------------
     // Show the form
     //-----------------------------------------
     $_basicOptions = array(array('email', $this->lang->words['notopt__email']), array('inline', $this->lang->words['notopt__inline']), array('mobile', $this->lang->words['notopt__mobile']));
     $_configOptions = $notifyLibrary->getNotificationData();
     $_notifyConfig = $notifyLibrary->getMemberNotificationConfig($newMember);
     $_defaultConfig = $notifyLibrary->getDefaultNotificationConfig();
     $_saveConfig = array();
     foreach ($_configOptions as $option) {
         $_saveConfig[$option['key']] = array();
         $_saveConfig[$option['key']]['selected'] = array();
         //-----------------------------------------
         // Loop through and mark what we selected.
         // Do not allow changing of stuff from disable_override
         //	and disabled, however
         //-----------------------------------------
         if (is_array($this->request['config_' . $option['key']]) and count($this->request['config_' . $option['key']])) {
             foreach ($this->request['config_' . $option['key']] as $_selected) {
                 if (!is_array($_defaultConfig[$option['key']]['disabled']) or !in_array($_selected, $_defaultConfig[$option['key']]['disabled'])) {
                     $_saveConfig[$option['key']]['selected'][] = $_selected;
                 }
             }
         }
         if ($_defaultConfig[$option['key']]['disable_override']) {
             $_saveConfig[$option['key']]['selected'] = $_defaultConfig[$option['key']]['selected'];
         }
     }
     //-----------------------------------------
     // Save
     //-----------------------------------------
     IPSMember::packMemberCache($member['member_id'], array_merge($additionalMCache, array('notifications' => $_saveConfig, 'show_notification_popup' => intval($this->request['show_notification_popup']))), $member['members_cache']);
     //-----------------------------------------
     // Topic preferences
     //-----------------------------------------
     $_trackChoice = '';
     if ($this->request['auto_track']) {
         if (in_array($this->request['auto_track_method'], array('none', 'immediate', 'offline', 'daily', 'weekly'))) {
             $_trackChoice = $this->request['auto_track_method'];
         }
     }
     $newMember['auto_track'] = $_trackChoice;
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $fields = new $classToLoad();
     $fields->initData('edit');
     $fields->parseToSave($_POST);
     /* Check the website url field */
     $website_field = $fields->getFieldIDByKey('website');
     if ($website_field && $fields->out_fields['field_' . $website_field]) {
         if (stristr($fields->out_fields['field_' . $website_field], 'http://') === FALSE && stristr($fields->out_fields['field_' . $website_field], 'https://') === FALSE) {
             $fields->out_fields['field_' . $website_field] = 'http://' . $fields->out_fields['field_' . $website_field];
         }
     }
     //-----------------------------------------
     // Throw to the DB
     //-----------------------------------------
     IPSMember::save($this->request['member_id'], array('core' => array_merge($newMember, $additionalCore), 'extendedProfile' => array_merge(array('pp_about_me' => $aboutme, 'signature' => $signature, 'pp_reputation_points' => intval($this->request['pp_reputation_points']), 'pp_setting_count_visitors' => intval($this->request['pp_setting_count_visitors']), 'pp_setting_count_comments' => intval($this->request['pp_setting_count_comments']), 'pp_setting_count_friends' => intval($this->request['pp_setting_count_friends']), 'pp_setting_moderate_comments' => intval($this->request['pp_setting_moderate_comments']), 'pp_setting_moderate_friends' => intval($this->request['pp_setting_moderate_friends']), 'pp_customization' => $this->request['removeCustomization'] ? serialize(array()) : $member['pp_customization']), $additionalExtended), 'customFields' => count($fields->out_fields) ? $fields->out_fields : array()));
     if ($member['member_group_id'] != $newMember['member_group_id']) {
         IPSLib::runMemberSync('onGroupChange', $this->request['member_id'], $newMember['member_group_id'], $member['member_group_id']);
         //-----------------------------------------
         // Remove restrictions if member demoted
         // Commenting out as this may cause more problems than it's worth
         // e.g. if you had accidentally changed their group, you'd need to reconfigure all restrictions
         //-----------------------------------------
         /*if( !$this->caches['group_cache'][ $newMember['member_group_id'] ]['g_access_cp'] )
         		{
         			$this->DB->delete( 'admin_permission_rows', 'row_id=' . $member['member_id'] . " AND row_id_type='member'" );
         		}*/
         //-----------------------------------------
         // Restriction permissions stuff
         //-----------------------------------------
         $is_admin = 0;
         $groups = ipsRegistry::cache()->getCache('group_cache');
         if (is_array($this->request['mgroup_others']) and count($this->request['mgroup_others'])) {
             foreach ($this->request['mgroup_others'] as $omg) {
                 if ($groups[intval($omg)]['g_access_cp']) {
                     $is_admin = 1;
                     break;
                 }
             }
         }
         if ($groups[intval($this->request['member_group_id'])]['g_access_cp']) {
             $is_admin = 1;
         }
         if ($is_admin && $restricted) {
             //-------------------------------------------------
             // Copy restrictions if they do not have any yet...
             //-------------------------------------------------
             $check = $this->DB->buildAndFetch(array('select' => 'row_updated', 'from' => 'admin_permission_rows', 'where' => "row_id_type='member' AND row_id=" . $this->request['member_id']));
             if (!$check['row_updated']) {
                 $this->DB->replace('admin_permission_rows', array('row_id' => $this->request['member_id'], 'row_id_type' => 'member', 'row_perm_cache' => serialize($this->registry->getClass('class_permissions')->restrictions_row), 'row_updated' => time()), array('row_id', 'row_id_type'));
             }
         }
     }
     //-----------------------------------------
     // Moved from validating group?
     //-----------------------------------------
     if ($member['member_group_id'] == $this->settings['auth_group']) {
         if ($this->request['member_group_id'] != $this->settings['auth_group']) {
             //-----------------------------------------
             // Yes...
             //-----------------------------------------
             $this->DB->delete('validating', "member_id=" . $this->request['member_id']);
         }
     }
     /* Update cache */
     IPSContentCache::update($this->request['member_id'], 'sig', $cacheSignature);
     /* Rebuild birthday cache */
     $this->cache->rebuildCache('birthdays', 'calendar');
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_editedlog'], $member['members_display_name']));
     $this->registry->output->global_message = $this->lang->words['m_edited'];
     if ($is_admin) {
         if (!$restricted) {
             $member = IPSMember::load($member['member_id']);
             $this->_showAdminForm($member, array());
             $this->_memberView();
         } else {
             $this->registry->output->global_message = $this->lang->words['m_edited_restricted'];
             $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&member_id=' . $this->request['member_id']);
         }
     } else {
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&member_id=' . $this->request['member_id']);
     }
 }
Пример #5
0
 /**
  * Main class entry point
  *
  * @param	object		ipsRegistry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $_thisNav = array();
     //-----------------------------------------
     // Load language
     //-----------------------------------------
     $this->registry->getClass('class_localization')->loadLanguageFile(array('public_usercp'));
     //-----------------------------------------
     // Logged in?
     //-----------------------------------------
     if (!$this->memberData['member_id']) {
         $this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . '&app=core&module=global&section=login&do=form');
         exit;
     }
     //-----------------------------------------
     // Make sure they're clean
     //-----------------------------------------
     $this->request['tab'] = IPSText::alphanumericalClean($this->request['tab']);
     $this->request['area'] = IPSText::alphanumericalClean($this->request['area']);
     //-----------------------------------------
     // Set up some basics...
     //-----------------------------------------
     $_TAB = $this->request['tab'] ? $this->request['tab'] : 'core';
     $_AREA = $this->request['area'] ? $this->request['area'] : 'settings';
     $_DO = $this->request['do'] ? $this->request['do'] : 'show';
     $_FUNC = $_DO == 'show' ? 'showForm' : ($_DO == 'save' ? 'saveForm' : $_DO);
     $tabs = array();
     $errors = array();
     //-----------------------------------------
     // Got a plug in?
     //-----------------------------------------
     IPSLib::loadInterface('interface_usercp.php');
     $EXT_DIR = IPSLib::getAppDir($_TAB) . '/extensions';
     if (!is_file($EXT_DIR . '/usercpForms.php')) {
         $this->registry->getClass('output')->showError('usercp_bad_tab', 10147);
         exit;
     }
     //-----------------------------------------
     // Cycle through applications and load
     // usercpForm extensions
     //-----------------------------------------
     foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
         $ext_dir = IPSLib::getAppDir($app_dir) . '/extensions';
         // Make sure the extension exists
         if (!is_file($ext_dir . '/usercpForms.php')) {
             continue;
         }
         $__class = IPSLib::loadLibrary($ext_dir . '/usercpForms.php', 'usercpForms_' . $app_dir, $app_dir);
         if (!class_exists($__class)) {
             continue;
         }
         $_usercp_module = new $__class();
         /* Block based on version to prevent old files showing up/causing an error */
         if (!$_usercp_module->version or $_usercp_module->version < 32) {
             continue;
         }
         $_usercp_module->makeRegistryShortcuts($this->registry);
         if (is_callable(array($_usercp_module, 'init'))) {
             $_usercp_module->init();
             /* Set default area? */
             if ($_TAB == $app_dir and !isset($_REQUEST['area'])) {
                 if (isset($_usercp_module->defaultAreaCode)) {
                     $this->request['area'] = $_AREA = $_usercp_module->defaultAreaCode;
                 }
             }
         }
         if (is_callable(array($_usercp_module, 'getLinks'))) {
             $tabs[$app_dir]['_menu'] = $_usercp_module->getLinks();
             /* Got any links? */
             if (!is_array($tabs[$app_dir]['_menu']) || !count($tabs[$app_dir]['_menu'])) {
                 unset($tabs[$app_dir]);
                 continue;
             }
             /* Get title */
             $tabs[$app_dir]['_name'] = $_usercp_module->tab_name ? $_usercp_module->tab_name : IPSLib::getAppTitle($app_dir);
             /* Add in 'last' element */
             $tabs[$app_dir]['_menu'][count($tabs[$app_dir]['_menu']) - 1]['last'] = 1;
             /* This nav? */
             if (!count($_thisNav) and $app_dir == $_TAB) {
                 foreach ($tabs[$app_dir]['_menu'] as $_navData) {
                     if ($_navData['url'] == 'area=' . $_AREA) {
                         $_thisNav = array('app=core&amp;module=usercp&amp;tab=' . $_TAB . '&amp;area=' . $_AREA, $_navData['title']);
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Set up basic navigation
     //-----------------------------------------
     $this->_nav[] = array($this->lang->words['t_title'], '&amp;app=core&amp;module=usercp');
     $this->_nav[] = array($this->lang->words['tab__' . $_TAB] ? $this->lang->words['tab__' . $_TAB] : IPSLib::getAppTitle($_TAB), '&amp;app=core&amp;module=usercp&amp;tab=' . $_TAB);
     if (isset($_thisNav[0])) {
         $this->_nav[] = array($_thisNav[1], $_thisNav[0]);
     }
     //-----------------------------------------
     // Begin initilization routine for extension
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary($EXT_DIR . '/usercpForms.php', 'usercpForms_' . $_TAB, $_TAB);
     $usercp_module = new $classToLoad();
     $usercp_module->makeRegistryShortcuts($this->registry);
     $usercp_module->init();
     if ($_DO == 'saveForm' || $_DO == 'showForm' and !is_callable(array($usercp_module, $_FUNC))) {
         $this->registry->getClass('output')->showError('usercp_bad_tab', 10148, true);
         exit;
     }
     //-----------------------------------------
     // Run it...
     //-----------------------------------------
     if ($_FUNC == 'showForm') {
         //-----------------------------------------
         // Facebook email
         //-----------------------------------------
         $html = $usercp_module->showForm($_AREA);
     } else {
         if ($_FUNC == 'saveForm') {
             //-----------------------------------------
             // Check secure key...
             //-----------------------------------------
             if ($this->request['secure_hash'] != $this->member->form_hash) {
                 $html = $usercp_module->showForm($_AREA);
                 $errors[] = $this->lang->words['securehash_not_secure'];
             } else {
                 $errors = $usercp_module->saveForm($_AREA);
                 $do = $usercp_module->do_url ? $usercp_module->do_url : 'show';
                 if (is_array($errors) and count($errors)) {
                     $html = $usercp_module->showForm($_AREA, $errors);
                 } else {
                     if ($usercp_module->ok_message) {
                         $this->registry->getClass('output')->redirectScreen($usercp_module->ok_message, $this->settings['base_url'] . 'app=' . IPS_APP_COMPONENT . '&module=usercp&tab=' . $_TAB . '&area=' . $_AREA . '&do=' . $do . '&saved=1', 1);
                     } else {
                         $this->registry->getClass('output')->silentRedirect($this->settings['base_url_with_app'] . 'module=usercp&tab=' . $_TAB . '&area=' . $_AREA . '&do=' . $do . '&saved=1' . '&_r=' . time());
                     }
                 }
             }
         } else {
             if (!is_callable(array($usercp_module, 'runCustomEvent'))) {
                 $html = $usercp_module->showForm($_AREA);
                 $errors[] = $this->lang->words['called_invalid_function'];
             } else {
                 $html = $usercp_module->runCustomEvent($_AREA);
             }
         }
     }
     //-----------------------------------------
     // If you've run a custom event, may need to
     // reset the "area" to highlight the menu correctly
     //-----------------------------------------
     if (is_callable(array($usercp_module, 'resetArea'))) {
         $_AREA = $usercp_module->resetArea($_AREA);
     }
     //-----------------------------------------
     // Wrap form and show
     //-----------------------------------------
     $template = $this->registry->getClass('output')->getTemplate('ucp')->userCPTemplate($_TAB, $html, $tabs, $_AREA, $errors, $usercp_module->hide_form_and_save_button, $usercp_module->uploadFormMax);
     //-----------------------------------------
     // Pass to CP output hander
     //-----------------------------------------
     $this->registry->getClass('output')->setTitle($this->_pageTitle ? "{$this->lang->words['pagetitle_bit']} : " . $this->_pageTitle . ' - ' . $this->settings['board_name'] : "{$this->lang->words['pagetitle_bit']} - " . $this->settings['board_name']);
     $this->registry->getClass('output')->addContent($template);
     if (is_array($this->_nav) and count($this->_nav)) {
         foreach ($this->_nav as $_nav) {
             $this->registry->getClass('output')->addNavigation($_nav[0], $_nav[1]);
         }
     }
     if (is_array($usercp_module->_nav) and count($usercp_module->_nav)) {
         foreach ($usercp_module->_nav as $_nav) {
             $this->registry->getClass('output')->addNavigation($_nav[0], $_nav[1]);
         }
     }
     $this->registry->getClass('output')->sendOutput();
 }
 /**
  * Show the add/edit group form
  *
  * @access	private
  * @param 	string		'add' or 'edit'
  * @return	void		[Outputs to screen]
  */
 private function _groupForm($type = 'edit')
 {
     //-----------------------------------------
     // Grab group data and start us off
     //-----------------------------------------
     if ($type == 'edit') {
         if ($this->request['id'] == "") {
             $this->registry->output->showError($this->lang->words['g_whichgroup'], 11210);
         }
         $group = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'groups', 'where' => "g_id=" . intval($this->request['id'])));
         $group = IPSLib::unpackGroup($group);
         //-----------------------------------------
         // Check restrictions.
         //-----------------------------------------
         if ($group['g_access_cp']) {
             $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('groups_edit_admin');
         }
     } else {
         $group = array();
         if ($this->request['id']) {
             $group = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'groups', 'where' => "g_id=" . intval($this->request['id'])));
             $group = IPSLib::unpackGroup($group);
         }
         $group['g_title'] = 'New Group';
     }
     //-----------------------------------------
     // Grab permission masks
     //-----------------------------------------
     $perm_masks = array();
     $this->DB->build(array('select' => '*', 'from' => 'forum_perms'));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $perm_masks[] = array($r['perm_id'], $r['perm_name']);
     }
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     $blocks = array('tabs' => array(), 'area' => array());
     IPSLib::loadInterface('admin/group_form.php');
     $tabsUsed = 2;
     foreach (ipsRegistry::$applications as $app_dir => $app_data) {
         if (!IPSLib::appIsInstalled($app_dir)) {
             continue;
         }
         if (file_exists(IPSLib::getAppDir($app_dir) . '/extensions/admin/group_form.php')) {
             require_once IPSLib::getAppDir($app_dir) . '/extensions/admin/group_form.php';
             $_class = 'admin_group_form__' . $app_dir;
             if (class_exists($_class)) {
                 $_object = new $_class($this->registry);
                 $data = $_object->getDisplayContent($group, $tabsUsed);
                 $blocks['area'][$app_dir] = $data['content'];
                 $blocks['tabs'][$app_dir] = $data['tabs'];
                 $tabsUsed = $data['tabsUsed'] ? $tabsUsed + $data['tabsUsed'] : $tabsUsed + 1;
             }
         }
     }
     //-----------------------------------------
     // And output to form
     //-----------------------------------------
     $this->registry->output->html .= $this->html->groupsForm($type, $group, $perm_masks, $blocks);
 }