UserCP & Join a Group Upon Registration

Forum_easyUCP_Desc

UserCP & Join a Group Upon Registration

Beitragvon Viper » 21. Mär 2006 06:04

Hi, AmigaLink.

I need your help installing "Join a Group Upon Registration" mod with your UserCP mod.

This is the code in have to put in: includes/usercp_register.php
Code: Alles auswählen
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_register.php
#
#-----[ FIND ]------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//// Group Registration Mod

#
#-----[ FIND ]------------------------------------------
#
         $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user, group_moderator)
            VALUES ('', 'Personal User', 1, 0)";
         if ( !($result = $db->sql_query($sql)) )
         {
            message_die(GENERAL_ERROR, 'Could not insert data into groups table', '', __LINE__, __FILE__, $sql);
         }

         $group_id = $db->sql_nextid();
#
#-----[ AFTER, ADD ]------------------------------------------
#
// START ADD- Group Registration MOD
         $check_group_id = intval($HTTP_POST_VARS['group_id']);
         if ( !empty ($check_group_id) || $check_group_id > 0)
         {
            // Check to make sure that the group can be joined)   
            $sql = "SELECT * FROM " . GROUPS_TABLE . "
               WHERE group_id = $check_group_id and group_allow_reg = " . GROUP_REG;
            if ( !($result = $db->sql_query($sql)) )
            {
               message_die(GENERAL_ERROR, 'Could not select data from groups table', '', __LINE__, __FILE__, $sql);
            }
            if ( $db->sql_numrows($result) > 0 )
            {
               $sql = "SELECT group_disable_pending
                  FROM " . GROUPS_TABLE . "
                  WHERE group_id = $check_group_id";
               if ( !($result = $db->sql_query($sql)) )
               {
                  message_die(GENERAL_ERROR, 'Could not select group pending settings', '', __LINE__, __FILE__, $sql);
               }
               if ( !($row = $db->sql_fetchrow($result)) )
               {
                  message_die(GENERAL_ERROR, 'Could not fetchrow group pending settings', '', __LINE__, __FILE__, $sql);
               }
               // Check to see if pending status is enabled for this group
               if ( $row['group_disable_pending'] == GROUP_PEND )
               {
                  $pending = 0;
               } else {
                  $pending = 1;
               }
               $group_sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
                     VALUES ($user_id, $check_group_id, $pending)";
               if( !($result = $db->sql_query($group_sql, END_TRANSACTION)) )
               {
                  message_die(GENERAL_ERROR, 'Could not insert data into user_group table', '', __LINE__, __FILE__, $sql);
               }
            }
         } else {
            // Check to see if users have to join a group (only necessary if a hacker has devised a work-around: security check)
            if ( $board_config['group_force_reg'] == GROUP_FORCE )
            {
               message_die(GENERAL_MESSAGE, $lang['No_group_specified']);
            }
         }
// END ADD- Group Registration MOD

#
#-----[ FIND ]------------------------------------------
#
   $smilies_status = ( $userdata['user_allowsmile'] && $board_config['allow_smilies']  ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
// START ADD- Group Registration MOD
   if ( $mode == 'register' )
   {
      $ignore_group_sql =   ( count($in_group) ) ? "AND group_id NOT IN (" . implode(', ', $in_group) . ")" : '';
      $sql = "SELECT group_id, group_name, group_type
         FROM " . GROUPS_TABLE . " g
         WHERE group_single_user <> " . TRUE . "
         $ignore_group_sql and
         group_allow_reg = " . GROUP_REG . "
         ORDER BY g.group_name";

      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
      }

      $s_group_list_opt = '';

      // If there are no joinable usergroups
      if ( $db->sql_numrows($result) <= 0 )
      {
         $s_group_list_opt .='<option value="0">' . $lang['No_usergroups_reg'] . '</option>';
      }

      // If usergroup registration is not forced
      if ( $board_config['group_force_reg'] == GROUP_NO_FORCE && $db->sql_numrows($result) > 0 )
      {
         $s_group_list_opt .='<option value="0">' . $board_config['group_default_none'] . '</option>';
      }

      // Create loop
      while( $row = $db->sql_fetchrow($result) )
      {
         if  ( $row['group_type'] != GROUP_HIDDEN || $userdata['user_level'] == ADMIN )
         {
            $s_group_list_opt .='<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
         }
      }

      $s_group_list = '<select name="group_id">' . $s_group_list_opt . '</select>';
      $template->assign_var('L_USERGROUP_SELECT' , $s_group_list );
      $template->assign_block_vars('switch_select_usergroup',array());
   }
// END ADD- Group Registration MOD

#
#-----[ FIND ]------------------------------------------
#
      'CONFIRM_IMG' => $confirm_image,
#
#-----[ AFTER, ADD ]------------------------------------------
#
// START ADD- Group Registration MOD
      'USERGROUP_SELECT' => $s_group_list,
// END ADD- Group Registration MOD

#
#-----[ FIND ]------------------------------------------
#
      'L_RESET' => $lang['Reset'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
// START ADD- Group Registration MOD
      'L_USERGROUP' => $lang['Usergroup'],
// END ADD- Group Registration MOD

#
#-----[ OPEN ]------------------------------------------
#
# Already Added
templates/subSilver/profile_add_body.tpl
#
#-----[ FIND ]------------------------------------------
#
   <tr>
     <td class="row2" colspan="2"><span class="gensmall">{L_PROFILE_INFO_NOTICE}</span></td>
   </tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
   <!-- BEGIN switch_select_usergroup -->
   <tr>
     <td class="row1"><span class="gen">{L_USERGROUP}:</span></td>
     <td class="row2">
      {USERGROUP_SELECT}
     </td>
   </tr>
   <!-- END switch_select_usergroup -->

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#


Where would I add these changes for the userCP mod.

Thanks for your time and a great mod.
Link to text file: ( Join a Group Upon Registration )
Viper
 
Beiträge: 1
Registriert: 21. Mär 2006 05:50

Beitragvon AmigaLink » 22. Mär 2006 11:02

Install the MOD like the guide and then attach me the usercp_register.php and the profile_add_body.tpl in a zip file.
Then I can look at this whitout install the MOD myself and change some little things for you. :)
Die deutsche Sprache ist Freeware, du kannst sie benutzen, ohne dafür zu bezahlen. Sie ist aber nicht Open Source, also darfst du sie nicht verändern, wie es dir gerade passt.
Benutzeravatar
AmigaLink
Administrator
 
Beiträge: 3987
Registriert: 11. Aug 2004 01:06
Wohnort: NRW


Zurück zu easy UCP



Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 4 Gäste

cron