Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

Author Topic: How to integrate custom registration form with Coppermine's functionality  (Read 12642 times)

0 Members and 1 Guest are viewing this topic.

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91

Is it possible to use a custom form for registration, essentially replacing Coppermine's visual portion, but leaving its functions intact?

The form I'm trying to implement can be found in a demo (with code) in the link below. For example, it shows HTML code for the e-mail field as being

Code: [Select]
<input type="text" name="email" placeholder="Email" />
How would I get the email into Coppermine's code to be sent to my database? I've attached a screenshot that shows what I mean, the info will be transfered from my custom form to Coppermine.
I understand it wouldn't be literally inputted in the form, but instead it'd be happening via code. The second page of my custom form could have its info sent into the lower fields of the registration form (shown in screenshot).

Custom Form Link:
http://codepen.io/atakan/pen/gqbIz


So, would I have to refer to register.php's code within my custom form???  Perhaps the line:

Code: [Select]
line array('input', 'email', $icon_array['email'] . $lang_register_php['email'], 255),
for the email, for example...


Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #1 on: December 30, 2014, 01:42:10 am »

You can customise the registration form to have fields and look exactly like your pic.
No need for a new one.

You can start with changing Config - Custom fields for user profile, then on register.php I can help you change the fields at the desired position (only if you want the fields in a diffrent order).
Last step: style it with css:

Open register.php then wrapp only the table from register.php in a div like this:


add
Code: [Select]
echo '<div id="customStyle">'; before starttable and
Code: [Select]
echo '</div>'; after  endtable();

You will find starttable and entable twice. One is for I agree page, one is for the registration form.

Proabibly works even before form (also found twice)
Code: [Select]
<form name="cpgform" id="cpgform" method="post" action="$CPG_PHP_SELF" onsubmit="return checkRegisterFormSubmit();">
EOT;
and after
Code: [Select]
print '</form>';. I don't know. I did not test it. 

then you can add in your themes/you_theme_name/your_style.css #customStyle {background: ........} or #cpg_main_block_outer #customStyle  {}

You can also inspect all the form with firefox inspect to see all the css.
Example: the td of the form has:

Code: [Select]
.tableb_alternate {
    background: none repeat scroll 0% 0% #E7EAEF;
}

You can not delete it because this class is used even for other pages, so add to style.css (to overpower the form css with your style):

Code: [Select]
#customStyle .tableb_alternate {
    background: .............;
}

BETTER SOLUTION (this way you don't edit register.php. Everytime you update coppermine you will need to edit register.php again)

1) Open your theme's template.html file, find

Code: [Select]
<div id="cpg_main_block_outer">
(just this line!) and replace with

Code: [Select]
<div id="cpg_main_block_outer {REGISTER_STYLE}">

Now, open your theme's theme.php file and add the following code to the pageheader function (if you don't have pageheader function in your theme, then copy it from themes/sample/theme.php) :

Code: [Select]
    global $CPG_PHP_SELF;
    $superCage = Inspekt::makeSuperCage();
    if ($CPG_PHP_SELF == 'register.php') {
        $template_vars['{REGISTER_STYLE}'] = 'customStyle';
    } else {
        $template_vars['{REGISTER_STYLE}'] = '';
    }

before:
Code: [Select]
$template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars);
This way only on register.php the container div (cpg_main_block_outer) will have an extra id.
Now you can add in themes/theme/your_theme/your_style.css:

Code: [Select]
#customStyle .tableb_alternate {
    background: .............;
}


Code made by Andre here: Custom Sidebar only on the homepage  http://forum.coppermine-gallery.net/index.php/topic,76722.0.html

Is just a suggestion.
« Last Edit: January 02, 2015, 01:45:04 pm by allvip »
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #2 on: December 30, 2014, 02:41:18 am »

Appreciate it, but I'm confused as to how to style Coppermine's fields. For example, when looking at register.php, I don't see any HTML for which I can then apply CSS to. I understand basic HTML/CSS and how to style HTML code, but the only code in register.php that I can see resembling the form fields is shown below. Can you direct me to where I can see the relevant CSS to customize. I'm confused.. Thanks!

Code: [Select]
$form_data = array(
        array('label', $lang_register_php['required_info']),
        array('input', 'username', $icon_array['username'] . $lang_register_php['username'], 25),
        !empty($CONFIG['global_registration_pw']) ? array('password', 'global_registration_pw', $icon_array['password'] . $lang_register_php['global_registration_pw'], 25) : '',
        array('password', 'password', $icon_array['password'] . $lang_register_php['password']),
        array('password', 'password_verification', $icon_array['password'] . $lang_register_php['password_again']),
        array('input', 'email', $icon_array['email'] . $lang_register_php['email'], 255),
        array('label', $lang_register_php['optional_info'])
    );
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #3 on: December 30, 2014, 04:00:10 am »

HTML for the fields in register.php

For I agree page (if you enabled it in config):

Code: [Select]
    echo <<< EOT
        <form name="cpgform" id="cpgform" method="post" action="$CPG_PHP_SELF">

EOT;

    starttable(-1, cpg_fetch_icon('add_user', 2) . $lang_register_php['term_cond']);

    echo <<< EOT
    <tr>
        <td class="tableb" style="padding: 10px;">

EOT;
    echo str_replace('{SITE_NAME}', $CONFIG['gallery_name'], $lang_register_php['disclamer']);

    echo <<< EOT
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center" class="tablef">
            <button type="submit" class="button" name="agree" id="agree" value="{$lang_register_php['i_agree']}">{$icon_array['ok']}{$lang_register_php['i_agree']}</button>
        </td>
    </tr>

EOT;
    endtable();

For Input registration information and Optional information titles.

Code: [Select]
        case 'label':

              echo <<< EOT
    <tr>
        <td colspan="2" class="tableh2">
            {$element[1]}
        </td>
    </tr>


For password:

Code: [Select]
            echo <<< EOT
    <tr>
        <td width="40%" class="{$row_style}">
            {$element[2]}
        </td>
        <td width="60%" class="{$row_style}" valign="top">
            <input type="password" style="width: 100%" name="{$element[1]}" id="{$element[1]}" value="" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>

EOT;

For all other fields:

Code: [Select]
    <tr>
        <td width="40%" class="{$row_style}">
            {$element[2]}
        </td>
        <td width="60%" class="{$row_style}" valign="top">
            <input type="text" style="width: 100%" name="{$element[1]}" id="{$element[1]}" maxlength="{$element[3]}" value="$value" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>

For Biography field:

Code: [Select]
                echo <<< EOT
    <tr>
        <td width="40%" class="{$row_style}">
            {$element[2]}
        </td>
        <td width="60%" class="{$row_style}" valign="top">
            <textarea name="{$element[1]}" rows="7" cols="60" class="textinput" style="width:100%">$value</textarea>
        </td>
    </tr>


EOT;

Captcha:

Code: [Select]
    <tr>
        <td align="right" class="tablef">
            {$lang_common['confirm']}&nbsp;{$help}
        </td>
        <td class="tablef">
            <input type="text" name="confirmCode" id="confirmCode" size="5" maxlength="5" class="textinput" />
            <img src="captcha.php" align="middle" border="0" alt="" />
        </td>
    </tr>

For submit:

Code: [Select]
    echo <<< EOT
    <tr>
        <td colspan="2" align="center" class="tablef">
            <button type="submit" class="button" name="submit" id="submit" value="{$lang_register_php['submit']}">{$icon_array['ok']}{$lang_register_php['submit']}</button>
        </td>
    </tr>
    <tr>
        <td class="tablef" colspan="2">
            <div id="form_not_submit_bottom" class="formFieldWarning" style="display:none;">
                {$lang_register_php['form_not_submit']}
            </div>
        </td>
    </tr>

EOT;
« Last Edit: January 02, 2015, 11:22:46 am by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #4 on: December 30, 2014, 04:32:44 am »

For diffrent styles for every field or changing the structure:
Ex:

    <tr>
        <td width="40%" class="{$row_style}">
            {$element[2]}
        </td>
        <td width="60%" class="{$row_style}" valign="top">
            <input type="password" style="width: 100%" name="{$element[1]}" id="{$element[1]}" value="" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>



change to:

    <tr>
        <td width="40%" class="myCustomStyles">
            {$element[2]}
        </td>
        <td width="60%" class="myCustomStyles" valign="top">
            <input type="password" style="width: 100%" name="{$element[1]}" id="{$element[1]}" value="" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>


then add to themes/your_theme_name/style.css:

.myCustomStyle {background-color: etc etc}


If you want to move them to be all in one row, then I think is ok to change

    <tr>
        <td width="40%" class="{$row_style}">
            {$element[2]}
        </td>
        <td width="60%" class="{$row_style}" valign="top">
            <input type="password" style="width: 100%" name="{$element[1]}" id="{$element[1]}" value="" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>

to:

    <tr>
        <td width="40%" class="{$row_style}">
            {$element[2]}
        </td>
    </tr>
    <tr>
        <td width="60%" class="{$row_style}" valign="top">
            <input type="password" style="width: 100%" name="{$element[1]}" id="{$element[1]}" value="" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>

or like this:

    <tr>
        <td width="40%" class="{$row_style}">
            {$element[2]}
            <input type="password" style="width: 100%" name="{$element[1]}" id="{$element[1]}" value="" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>

I am sure about adding your custom class, but not sure if removing tr,td will effect the form.
Try it.
« Last Edit: January 02, 2015, 11:24:27 am by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #5 on: December 30, 2014, 04:42:13 am »

The text on top of the form :Input registration information is in lang/english.php and lang/french.php etc
I think you want to change that to CREATE YOUR ACCOUNT.
If you have detect user language (something like that) in Config ON then, all languages must be edited.

This can also help you edit register.php even if is not about register.php:
Move profile custom fields http://forum.coppermine-gallery.net/index.php/topic,77677.0.html

Search even the forum. Maybe there is already moved the fields on register.php topic or custom fields.
« Last Edit: December 30, 2014, 04:48:10 am by allvip »
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #6 on: December 30, 2014, 05:08:41 am »

Ok, I'm starting to understand what you're saying. But I don't see how I'm suppose use the exact design I want, found here http://codepen.io/atakan/pen/gqbIz

The HTML in the custom form shows (for example):

Code: [Select]
<form id="msform">
<!-- progressbar -->
<ul id="progressbar">
<li class="active">Account Setup</li>
<li>Social Profiles</li>
<li>Personal Details</li>
</ul>
<!-- fieldsets -->
<fieldset>
<h2 class="fs-title">Create your account</h2>
<h3 class="fs-subtitle">This is step 1</h3>
<input type="text" name="email" placeholder="Email" />
<input type="password" name="pass" placeholder="Password" />
<input type="password" name="cpass" placeholder="Confirm Password" />

 I don't see how that code can be incorporated into this code:

 [code]<tr>
        <td width="40%" class="[b]myCustomStyles[/b]">
            {$element[2]}
        </td>
        <td width="60%" class="myCustomStyles" valign="top">
            <input type="password" style="width: 100%" name="{$element[1]}" id="{$element[1]}" value="" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>

I can add a custom style called myCustomStyles, but how can that fully incorporate all the styles from the custom form I want to use. This seems like it's going to be a massive project just to have a custom form in place of Coppermine's. I don't want to have to start from scratch and *build* the style around Coppermine's fields, that seems so redundant.
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #7 on: December 30, 2014, 05:10:39 am »

I've love to just delete Coppermine's registration page and use my own, but when user's click submit, it uses Coppermine's functionality to register the user. Having to build like you're saying seems very time consuming.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #8 on: December 30, 2014, 05:16:26 am »

I can do it for you in 15 min, but I can not do the Step 1, Step 2.
All steps on the same page.

YES or NO?
Maybe the coppermine dev team can help use your code.
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #9 on: December 30, 2014, 06:13:32 am »

I don't know what you mean by you can't do the Step 1, Step 2.

But yes, if you're willing to do it for me I'd be incredibly happy. You don't have to explain to me how you did it, if that's what you mean. I can always figure out how it's done afterward.

Thank you!
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #10 on: December 30, 2014, 06:15:01 am »

Oh I see what you mean by Step 1, Step 2.

Yeah, all on one page is fine.

I only need:    email, password, confirm password, keyword 1, keyword 2, keyword 3, and submit button.

Only email,password and confirm password are required.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #11 on: December 30, 2014, 06:27:38 am »

OK. Max 30 minutes, then check back the forum.
Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #12 on: December 30, 2014, 06:47:51 am »

It's 1:47am so I'm going to sleep soon, but I'll check back first thing tomorrow!

Thanks vip, talk soon.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #13 on: December 30, 2014, 09:24:57 am »

Finished.

For Andre. I used placeholder="Password", but for username and optional fields I can not do that.
They all have the same:

Code: [Select]
    <tr>
        <td width="40%" class="{$row_style}">
            {$element[2]}
        </td>
        <td width="60%" class="{$row_style}" valign="top">
            <input type="text" style="width: 100%" name="{$element[1]}" id="{$element[1]}" maxlength="{$element[3]}" value="$value" class="textinput" />
            {$warning1}
            {$warning2}
        </td>
    </tr>

Is there a way to do it.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #14 on: December 30, 2014, 10:03:30 am »

Should be possible by passing an additional parameter to the function. But I think it should also be possible to pass the values of the custom registration form to register.php. I'd need to check this later when I've access to a computer, as I'm currently writing from my mobile phone.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #15 on: December 30, 2014, 10:17:57 am »

For @Andre:

This is his form (to make faster for you when you will have access to a PC):

Just two files:
form.html

Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Site Title</title>
<link href="form.css" rel="stylesheet" type="text/css" media="all" />
</head>

<body>
<!-- multistep form -->
<form id="msform">
<!-- progressbar -->
<ul id="progressbar">
<li class="active">Account Setup</li>
<li>Social Profiles</li>
<li>Personal Details</li>
</ul>
<!-- fieldsets -->
<fieldset>
<h2 class="fs-title">Create your account</h2>
<h3 class="fs-subtitle">This is step 1</h3>
<input type="text" name="email" placeholder="Email" />
<input type="password" name="pass" placeholder="Password" />
<input type="password" name="cpass" placeholder="Confirm Password" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
<input type="text" name="twitter" placeholder="Twitter" />
<input type="text" name="facebook" placeholder="Facebook" />
<input type="text" name="gplus" placeholder="Google Plus" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Personal Details</h2>
<h3 class="fs-subtitle">We will never sell it</h3>
<input type="text" name="fname" placeholder="First Name" />
<input type="text" name="lname" placeholder="Last Name" />
<input type="text" name="phone" placeholder="Phone" />
<textarea name="address" placeholder="Address"></textarea>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="submit" name="submit" class="submit action-button" value="Submit" />
</fieldset>
</form>

<!-- jQuery -->
<script src="http://thecodeplayer.com/uploads/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<!-- jQuery easing plugin -->
<script src="http://thecodeplayer.com/uploads/js/jquery.easing.min.js" type="text/javascript"></script>
<script>
//jQuery time
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches

$(".next").click(function(){
if(animating) return false;
animating = true;

current_fs = $(this).parent();
next_fs = $(this).parent().next();

//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");

//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50)+"%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'transform': 'scale('+scale+')'});
next_fs.css({'left': left, 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});

$(".previous").click(function(){
if(animating) return false;
animating = true;

current_fs = $(this).parent();
previous_fs = $(this).parent().prev();

//de-activate current step on progressbar
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");

//show the previous fieldset
previous_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale previous_fs from 80% to 100%
scale = 0.8 + (1 - now) * 0.2;
//2. take current_fs to the right(50%) - from 0%
left = ((1-now) * 50)+"%";
//3. increase opacity of previous_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'left': left});
previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});

$(".submit").click(function(){
return false;
})

</script>
</body>
</html>


form.css

Code: [Select]
@charset "utf-8";
/* CSS Document */

/*custom font*/
@import url(http://fonts.googleapis.com/css?family=Montserrat);

/*basic reset*/
* {margin: 0; padding: 0;}

html {
height: 100%;
/*Image only BG fallback*/
background: url('http://thecodeplayer.com/uploads/media/gs.png');
/*background = gradient + image pattern combo*/
background:
linear-gradient(rgba(196, 102, 0, 0.2), rgba(155, 89, 182, 0.2)),
url('http://thecodeplayer.com/uploads/media/gs.png');
}

body {
font-family: montserrat, arial, verdana;
}
/*form styles*/
#msform {
width: 400px;
margin: 50px auto;
text-align: center;
position: relative;
}
#msform fieldset {
background: white;
border: 0 none;
border-radius: 3px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
padding: 20px 30px;

box-sizing: border-box;
width: 80%;
margin: 0 10%;

/*stacking fieldsets above each other*/
position: absolute;
}
/*Hide all except first fieldset*/
#msform fieldset:not(:first-of-type) {
display: none;
}
/*inputs*/
#msform input, #msform textarea {
padding: 15px;
border: 1px solid #ccc;
border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
/*buttons*/
#msform .action-button {
width: 100px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#msform .action-button:hover, #msform .action-button:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
}
/*headings*/
.fs-title {
font-size: 15px;
text-transform: uppercase;
color: #2C3E50;
margin-bottom: 10px;
}
.fs-subtitle {
font-weight: normal;
font-size: 13px;
color: #666;
margin-bottom: 20px;
}
/*progressbar*/
#progressbar {
margin-bottom: 30px;
overflow: hidden;
/*CSS counters to number the steps*/
counter-reset: step;
}
#progressbar li {
list-style-type: none;
color: white;
text-transform: uppercase;
font-size: 9px;
width: 33.33%;
float: left;
position: relative;
}
#progressbar li:before {
content: counter(step);
counter-increment: step;
width: 20px;
line-height: 20px;
display: block;
font-size: 10px;
color: #333;
background: white;
border-radius: 3px;
margin: 0 auto 5px auto;
}
/*progressbar connectors*/
#progressbar li:after {
content: '';
width: 100%;
height: 2px;
background: white;
position: absolute;
left: -50%;
top: 9px;
z-index: -1; /*put it behind the numbers*/
}
#progressbar li:first-child:after {
/*connector not needed before the first step*/
content: none;
}
/*marking active/completed steps green*/
/*The number of the step and the connector before it = green*/
#progressbar li.active:before,  #progressbar li.active:after{
background: #27AE60;
color: white;
}
« Last Edit: December 30, 2014, 12:08:32 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #16 on: December 30, 2014, 10:23:06 am »

It will be your luck if Andre helps you integrate custom registration.
Anyway if could be of any use to someone, here is my way:

This way is with custom styles added for every field. No need for that. I edited reply #1 with the simple solution.
Add in themes/your_theme/your_style.css :

Code: [Select]
.regisAgree {
   font-family: Arial, sans-serif;
}
#regisWrapper {
     background-image: url(images/gs.png);
     background-repeat: repeat;
     font-family: 'Montserrat', sans-serif;
     font-weight: 400;
     margin: 0px;
     padding: 40px 0 40px 0;
}
#regis {
       background: none repeat scroll 0% 0% #FFF;
border: 0px none;
border-radius: 3px;
box-shadow: 0px 0px 15px 1px rgba(0, 0, 0, 0.4);
padding: 20px 30px;
box-sizing: border-box;
width: 50%;
margin: 0px auto 0px auto;
}
#regis .cpg_starttable_inner {
       font-size: 15px;
       font-weight: 700;
       text-transform: uppercase;
   text-align: center;
       color: #2C3E50;
}
.regisTitle {
    font-size: 13px;
text-align: center;
    color: #666;
    padding: 5px 0px 15px 0px;
}
.regisPassTitle,
.regisFieldsTitle,
.regisBioTitle,
.regisCaptchaTitle,
.regisSubmitTitle {
    color: #CCCCCC;
}
.regisSubmitTitle img{
       display: none;
}
.regis {
       background-color: #FFFFFF;
}
.regis .textinput {
    padding: 15px;
    border: 1px solid #CCC;
 border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
.regis .button,.regis .admin_menu {
       background-color: #27AE60;
       border: 2px solid #27AE60;
       font-family: 'Montserrat', sans-serif;
       font-size: 13px;
       padding: 10px;
   margin: 10px 0px 0px 0px;
       border-radius: 0px;
}
.regis:hover .button,.regis:hover .admin_menu {
       background-color: #27AE60;
       border: 2px solid #FFFFFF;
       outline: 2px solid #27AE60;
       padding: 10px;
}




If you want to use Montserrat font for the form, then open themes/your_theme/template.html and add in the head:

Code: [Select]
<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
« Last Edit: January 02, 2015, 11:35:13 am by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #17 on: December 30, 2014, 11:34:25 am »

part 2

Rename register.php to register_copp.php (just to have the original if you will need it)

Make a new blank file, name it register.php and copy:

Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2014 Coppermine Dev Team
  v1.0 originally written by Gregory Demar

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.

  ********************************************
  Coppermine version: 1.5.34
  $HeadURL: https://svn.code.sf.net/p/coppermine/code/trunk/cpg1.5.x/register.php $
  $Revision: 8753 $
**********************************************/

define('IN_COPPERMINE'true);
define('REGISTER_PHP'true);

require(
'include/init.inc.php');
require(
'include/mailer.inc.php');

if (!
$CONFIG['allow_user_registration']) {
    
cpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);
}

if (
defined('UDB_INTEGRATION')) {
    
$cpg_udb->register_page();
}

js_include('js/register.js');
js_include('js/thumbnails.js');

$icon_array = array(
    
'ok'       => cpg_fetch_icon('ok'0),
    
'username' => cpg_fetch_icon('my_profile'2),
    
'password' => cpg_fetch_icon('key_enter'2),
    
'email'    => cpg_fetch_icon('contact'2),
    
'blank'    => cpg_fetch_icon('blank'2),
);

/*****************************
* function definitions start *
*****************************/

/**
* display_disclaimer()
*
* Display the disclaimer
*
* @param void
* @return void
**/
function display_disclaimer()
{
    global 
$CONFIG$CPG_PHP_SELF$lang_register_php$icon_array;

    echo <<< EOT
        <form name="cpgform" id="cpgform" method="post" action="$CPG_PHP_SELF">

EOT;
    echo 
'<div id="regisWrapper">';
    echo 
'<div id="regis" class="regisAgree">';
    
starttable(-1cpg_fetch_icon('add_user'2) . $lang_register_php['term_cond']);

    echo <<< EOT
    <tr>
        <td class="tableb" style="padding: 10px;">

EOT;
    echo 
str_replace('{SITE_NAME}'$CONFIG['gallery_name'], $lang_register_php['disclamer']);

    echo <<< EOT
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center" class="tablef">
            <button type="submit" class="button" name="agree" id="agree" value="
{$lang_register_php['i_agree']}">{$icon_array['ok']}{$lang_register_php['i_agree']}</button>
        </td>
    </tr>

EOT;
    
endtable();
    echo 
'</div>';
echo '</div>';
    print 
'</form>';
}

/**
* input_user_info()
*
* Display the form fields
*
* @param string $errors
* @return void
**/
function input_user_info($errors '')
{
    global 
$CONFIG$CPG_PHP_SELF$lang_register_php$lang_common$icon_array;

    
$superCage Inspekt::makeSuperCage();

    echo <<<EOT
    <form name="cpgform" id="cpgform" method="post" action="$CPG_PHP_SELF" onsubmit="return checkRegisterFormSubmit();">
EOT;
    echo 
'<div id="regisWrapper">';
    echo 
'<div id="regis">';
    
starttable(-1cpg_fetch_icon('add_user'2) . $lang_register_php['enter_info'], 2);

    echo <<< EOT
    <tr>
        <td class="regis" colspan="2">
            <div id="form_not_submit_top" class="formFieldWarning" style="display:none;">
                
{$lang_register_php['form_not_submit']}
            </div>
        </td>
    </tr>


EOT;

    
$inline_disclaimer str_replace('{SITE_NAME}'$CONFIG['gallery_name'], $lang_register_php['disclamer']);

    
$form_data = array(
        array(
'label'$lang_register_php['required_info']),
        array(
'input''username'$icon_array['username'] . $lang_register_php['username'], 25),
        !empty(
$CONFIG['global_registration_pw']) ? array('password''global_registration_pw'$icon_array['password'] . $lang_register_php['global_registration_pw'], 25) : '',
        array(
'password''password'$icon_array['password'] . $lang_register_php['password']),
        array(
'password''password_verification'$icon_array['password'] . $lang_register_php['password_again']),
        array(
'input''email'$icon_array['email'] . $lang_register_php['email'], 255),
        array(
'label'$lang_register_php['optional_info'])
    );
    
$optional_data 0;
    if (
$CONFIG['user_profile1_name'] != '') {
        
$form_data[] = array('input''user_profile1'$icon_array['blank'] . $CONFIG['user_profile1_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile2_name'] != '') {
        
$form_data[] = array('input''user_profile2'$icon_array['blank'] . $CONFIG['user_profile2_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile3_name'] != '') {
        
$form_data[] = array('input''user_profile3'$icon_array['blank'] . $CONFIG['user_profile3_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile4_name'] != '') {
        
$form_data[] = array('input''user_profile4'$icon_array['blank'] . $CONFIG['user_profile4_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile5_name'] != '') {
        
$form_data[] = array('input''user_profile5'$icon_array['blank'] . $CONFIG['user_profile5_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile6_name'] != '') {
        
$form_data[] = array('textarea''user_profile6'$icon_array['blank'] . $CONFIG['user_profile6_name'], 255);
        
$optional_data++;
    }
    if (
$optional_data == 0) {
        
$form_data array_slice($form_data0count($form_data)-1);
    }

    
$form_data CPGPluginAPI::filter('register_form_create'$form_data);

    if (
$CONFIG['user_registration_disclaimer'] == 2) {
        
$form_data[] = array('label'$lang_register_php['term_cond']);
        
$form_data[] = array('checkbox''agree'$inline_disclaimer$lang_register_php['i_agree'], 1);
    } else {
        
$form_data[] = array('hidden''agree'1);
    }

    
$loopCounter 0;

    foreach (
$form_data as $element) {

        if (empty(
$element)) {
            continue;
        }

        if (
$loopCounter == floor($loopCounter 2)) {
            
$row_style 'tableb';
        } else {
            
$row_style 'tableb tableb_alternate';
        }

        
$loopCounter++;

        switch (
$element[0]) {

        case 
'label':

              echo <<< EOT
    <tr>
        <td colspan="2" class="regisTitle">
            
{$element[1]}
        </td>
    </tr>

EOT;
            break;

        case 
'input':

            if (
$superCage->post->keyExists($element[1])) {
                
$value $superCage->post->getEscaped($element[1]);
            } else {
                
$value '';
            }

            if (isset(
$lang_register_php[$element[1].'_warning1'])) {
                
$warning1 '<div id="'.$element[1].'_warning1" class="cpg_message_validation formFieldWarning" style="display:none;">' $lang_register_php[$element[1].'_warning1'] . '</div>';
            } else {
                
$warning1 '';
            }

            if (isset(
$lang_register_php[$element[1].'_warning2']) == TRUE) {
                
$warning2 '<div id="'.$element[1].'_warning2" class="cpg_message_validation formFieldWarning" style="display:none;">' $lang_register_php[$element[1].'_warning2'] . '</div>';
            } else {
                
$warning2 '';
            }

            if (
$element[2]) {

                echo <<< EOT
    <tr>
        <td width="20%" class="regis regisFieldsTitle">
            
{$element[2]}
        </td>
        <td width="80%" class="regis regisFields" valign="top">
            <input type="text" style="width: 100%" name="
{$element[1]}" id="{$element[1]}" maxlength="{$element[3]}" value="$value" class="textinput" />
            
{$warning1}
            
{$warning2}
        </td>
    </tr>

EOT;
            }

            break;

        case 
'radio':

            
// added the radio option for possible future use. The array definition would have to look like this:
            // array('radio', 'user_var', 'Text label', 'option 1','option 2'),
            // enabling this option requires changes in profile.php and usermgr.php as well

            
if ($superCage->post->keyExists($element[1])) {
                
$value $superCage->post->getAlnum($element[1]);
            } else {
                
$value '';
            }

            if (
$element[2]) {

                echo <<< EOT
    <tr>
        <td width="20%" class="
{$row_style}"  height="25">
            
{$element[2]}
        </td>
        <td width="80%" class="
{$row_style}" valign="top">
            <input type="radio" name="
{$element[1]}" id="{$element[1]}1" value="{$element[3]}" class="radio" />
            <label for="
{$element[1]}1" class="clickable_option">{$element[3]}</label>
            <input type="radio" name="
{$element[1]}" id="{$element[1]}2" value="{$element[4]}" class="radio" />
            <label for="
{$element[1]}2" class="clickable_option">{$element[4]}</label>
        </td>
    </tr>

EOT;
            }

            break;

        case 
'checkbox':

            
// added the checkbox option for possible future use. The array definition would have to look like this:
            // array('checkbox', 'user_var', 'preceeding text', 'Text label', 'value', 'Number of columns', 'attribute'),
            // enabling this option requires changes in profile.php and usermgr.php as well
            // Number of columns can be 1 or 2, default is 1.
            // Attribute can be anything that you want to pass to the <input>-tag, e.g. the parameter 'checked="checked"'.
            // or an event handler.

            
if ($superCage->post->keyExists($element[1])) {
                
$value $superCage->post->getAlnum($element[1]);
            } else {
                
$value '';
            }

            if (
$element[3]) {

                if (
$element[5] == 2) {
                    echo <<<EOT
    <tr>
        <td width="20%" class="
{$row_style}">
            
{$element[2]}
        </td>
        <td width="80%" class="
{$row_style}" valign="top">
            <input type="checkbox" name="
{$element[1]}" id="{$element[1]}" value="{$element[4]}" class="checkbox" {$element[6]} />
            <label for="
{$element[1]}" class="clickable_option">{$element[3]}</label>
        </td>
    </tr>

EOT;
                } else {
                    echo <<<EOT
    <tr>
        <td class="
{$row_style}" colspan="2">
            
{$element[2]}
            <br />
            <input type="checkbox" name="
{$element[1]}" id="{$element[1]}" value="{$element[4]}" class="checkbox" />
            <label for="
{$element[1]}" class="clickable_option">{$element[3]}</label>
        </td>
    </tr>

EOT;
                }
            }

            break;

        case 
'textarea':

            if (
$superCage->post->keyExists($element[1])) {
                
$value $superCage->post->getEscaped($element[1]);
            } else {
                
$value '';
            }

            if (
$element[2]) {

                echo <<< EOT
    <tr>
        <td width="20%" class="regis regisBioTitle">
            
{$element[2]}
        </td>
        <td width="80%" class="regis regisBio" valign="top">
            <textarea name="
{$element[1]}" rows="7" cols="60" class="textinput" style="width:100%">$value</textarea>
        </td>
    </tr>


EOT;
            }
            break;

        case 
'password':

            if (isset(
$lang_register_php[$element[1].'_warning1'])) {
                
$warning1 '<div id="'.$element[1].'_warning1" class="cpg_message_validation formFieldWarning" style="display:none;">' $lang_register_php[$element[1].'_warning1'] . '</div>';
            } else {
                
$warning1 '';
            }

            if (isset(
$lang_register_php[$element[1].'_warning2'])) {
                
$warning2 '<div id="'.$element[1].'_warning2" class="cpg_message_validation formFieldWarning" style="display:none;">' $lang_register_php[$element[1].'_warning2'] . '</div>';
            } else {
                
$warning2 '';
            }

            echo <<< EOT
    <tr>
    <td width="20%" class="regisPassTitle">
            
{$element[2]}
        </td>
        <td width="80%" class="regis regisPass" valign="top">
            <input type="password" style="width: 100%" name="
{$element[1]}" id="{$element[1]}" value="" class="textinput" />
            
{$warning1}
            
{$warning2}
        </td>
    </tr>

EOT;

            break;

        case 
'hidden':

            echo <<< EOT
    <tr>
        <td colspan="2" class="regis">
            <input type="hidden" name="
{$element[1]}" id="{$element[1]}" value="{$element[2]}" />
        </td>
    </tr>

EOT;

            break;

        default:
            
cpg_die(CRITICAL_ERROR'Invalid action for form creation ' $element[0], __FILE____LINE__);
        }
    }

    if (
$errors) {

        echo <<< EOT
    <tr>
        <td colspan="2" class="tableh2">
            
{$lang_register_php['error']}
        </td>
    </tr>
    <tr>
        <td colspan="2" class="tablef">
                <ul>
$errors</ul>
        </td>
    </tr>

EOT;
    }
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #18 on: December 30, 2014, 11:40:29 am »

part 3

part 3 is still register.php, but can not post to much code in one post.

Paste this in register.php after the code in part 2:

Code: [Select]

    // captcha code
    if ($CONFIG['registration_captcha'] != 0) {

        $help = cpg_display_help('f=empty.htm&amp;h=lang_common[captcha_help_title]&amp;t=lang_common[captcha_help]', 470, 245);

        $captcha_print = <<< EOT
    <tr>
        <td align="right" class="regis regisCaptchaTitle">
            {$lang_common['confirm']}&nbsp;{$help}
        </td>
        <td class="regis regisCaptcha">
            <input type="text" name="confirmCode" id="confirmCode" size="5" maxlength="5" class="textinput" />
            <img src="captcha.php" align="middle" border="0" alt="" />
        </td>
    </tr>
EOT;

        $captcha_print = CPGPluginAPI::filter('captcha_register_print', $captcha_print);
        echo $captcha_print;
    }

    echo <<< EOT
    <tr>
        <td colspan="2" align="center" class="regis regisSubmitTitle">
            <button type="submit" class="button" name="submit" id="submit" value="{$lang_register_php['submit']}">{$icon_array['ok']}{$lang_register_php['submit']}</button>
        </td>
    </tr>
    <tr>
        <td class="regis regisSubmit" colspan="2">
            <div id="form_not_submit_bottom" class="formFieldWarning" style="display:none;">
                {$lang_register_php['form_not_submit']}
            </div>
        </td>
    </tr>

EOT;

    endtable();
    echo '</div>';
echo '</div>';
    print '</form>';
}
/**
* get_post_var()
*
* Check the posted data
*
* @param array $var
* @return array $var
**/
function get_post_var($var)
{
    global $lang_errors;

    $superCage = Inspekt::makeSuperCage();

    if (!$superCage->post->keyExists($var) || !trim($superCage->post->getEscaped($var))) {
        cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'] . " ($var)", __FILE__, __LINE__);
    }

    return $superCage->post->getEscaped($var);
}

function check_user_info(&$error)
{
    global $CONFIG;
    global $lang_register_php, $lang_common, $lang_register_approve_email;
    global $lang_register_user_login, $lang_errors;

    $superCage = Inspekt::makeSuperCage();

    $user_name = trim(get_post_var('username'));
    $password = trim(get_post_var('password'));
    $password_again = trim(get_post_var('password_verification'));
    $email = trim(get_post_var('email'));
    $profile1 = $superCage->post->getEscaped('user_profile1');
    $profile2 = $superCage->post->getEscaped('user_profile2');
    $profile3 = $superCage->post->getEscaped('user_profile3');
    $profile4 = $superCage->post->getEscaped('user_profile4');
    $profile5 = $superCage->post->getEscaped('user_profile5');
    $profile6 = $superCage->post->getEscaped('user_profile6');
    $agree_disclaimer = $superCage->post->getEscaped('agree');
    $captcha_confirmation = $superCage->post->getEscaped('confirmCode');

    $sql = "SELECT null FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '$user_name'";
    $result = cpg_db_query($sql);

    if (mysql_num_rows($result)) {
        $error = '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_user_exists'] . '</li>';
        return false;
    }

    mysql_free_result($result);

    if (utf_strlen($user_name) < 2) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['username_warning2'] . '</li>';
    }

    if (!empty($CONFIG['global_registration_pw'])) {

        $global_registration_pw = get_post_var('global_registration_pw');

        if ($global_registration_pw != $CONFIG['global_registration_pw']) {
            $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_global_pw'] . '</li>';
        } elseif ($password == $CONFIG['global_registration_pw']) {
            $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_global_pass_same'] . '</li>';
        }
    }

    if (utf_strlen($password) < 2) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['password_warning1'] . '</li>';
    }

    if ($password == $user_name) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['password_warning2'] . '</li>';
    }

    if ($password != $password_again) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['password_verification_warning1'] . '</li>';
    }

    if (!Inspekt::isEmail($email)) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['email_warning2'] . '</li>';
    }

    if ($CONFIG['user_registration_disclaimer'] == 2 && $agree_disclaimer != 1) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_disclaimer'] . '</li>';
    }

    // Perform the ban check against email address and username
    $result = cpg_db_query("SELECT null FROM {$CONFIG['TABLE_BANNED']} WHERE user_name = '$user_name' AND brute_force = 0 LIMIT 1");

    if (mysql_num_rows($result)) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['user_name_banned'] . '</li>';
    }

    mysql_free_result($result);

    $result = cpg_db_query("SELECT null FROM {$CONFIG['TABLE_BANNED']} WHERE email = '$email' AND brute_force = 0 LIMIT 1");

    if (mysql_num_rows($result)) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['email_address_banned'] . '</li>';
    }

    mysql_free_result($result);

    // check captcha
    if ($CONFIG['registration_captcha'] != 0) {

        if (!captcha_plugin_enabled('register')) {
            require("include/captcha.inc.php");
            if (!PhpCaptcha::Validate($captcha_confirmation)) {
                $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_errors['captcha_error'] . '</li>';
            }
        } else {
            $error = CPGPluginAPI::filter('captcha_register_validate', $error);
        }
    }

    if (!$CONFIG['allow_duplicate_emails_addr']) {

        $sql = "SELECT null FROM {$CONFIG['TABLE_USERS']} WHERE user_email = '$email'";
        $result = cpg_db_query($sql);

        if (mysql_num_rows($result)) {
            $error = '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_duplicate_email'] . '</li>';
        }

        mysql_free_result($result);
    }

    $error = CPGPluginAPI::filter('register_form_validate', $error);

    if ($error != '') {
        return false;
    }

    if ($CONFIG['reg_requires_valid_email'] || $CONFIG['admin_activation']) {
        $active = 'NO';
        list($usec, $sec) = explode(' ', microtime());
        $seed = (float) $sec + ((float) $usec * 100000);
        srand($seed);
        $act_key = md5(uniqid(rand(), 1));
    } else {
        $active = 'YES';
        $act_key = '';
    }

    $encpassword = md5($password);

    $user_language = $CONFIG['lang'];

    $sql = "INSERT INTO {$CONFIG['TABLE_USERS']} (user_regdate, user_active, user_actkey, user_name, user_password, user_email, user_profile1, user_profile2, user_profile3, user_profile4, user_profile5, user_profile6, user_language) VALUES (NOW(), '$active', '$act_key', '$user_name', '$encpassword', '$email', '$profile1', '$profile2', '$profile3', '$profile4', '$profile5', '$profile6', '$user_language')";
    $result = cpg_db_query($sql);
    $user_array = array();
    $user_array['user_id'] = mysql_insert_id();
    $user_array['user_name'] = $user_name;
    $user_array['user_email'] = $email;
    $user_array['user_active'] = $active;
    CPGPluginAPI::action('register_form_submit', $user_array);

    if ($CONFIG['log_mode']) {
        log_write('New user "'.$user_name.'" registered', CPG_ACCESS_LOG);
    }

    // Create a personal album if corresponding option is enabled
    if ($CONFIG['personal_album_on_registration'] == 1) {
        $user_id = mysql_insert_id();
        $catid = $user_id + FIRST_USER_CAT;
        cpg_db_query("INSERT INTO {$CONFIG['TABLE_ALBUMS']} (`title`, `category`, `owner`) VALUES ('$user_name', $catid, $user_id)");
    }

    // Registrations must be activated/verified by the user clicking a link in an email
    if ($CONFIG['reg_requires_valid_email']) {
        // Mail the user the activation/verification link
        $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key;

        $template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
        );

        if (!cpg_mail($email, sprintf($lang_register_php['confirm_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_php['confirm_email'], $template_vars)))) {
            cpg_die(CRITICAL_ERROR, $lang_register_php['failed_sending_email'], __FILE__, __LINE__);
        }
        msg_box($lang_register_php['information'], $lang_register_php['thank_you'], $lang_common['continue'], 'index.php');
    } else {
        if ($CONFIG['admin_activation']) {
            // We need admin activation only
            msg_box($lang_register_php['information'], $lang_register_php['thank_you_admin_activation'], $lang_common['continue'], 'index.php');
        } else {
            // No activation required, account is ready for login
            msg_box($lang_register_php['information'], $lang_register_php['acct_active'], $lang_common['continue'], 'index.php');
        }
    }

    // email notification or actication link to admin
    if ($CONFIG['reg_notify_admin_email'] || ($CONFIG['admin_activation'] && !$CONFIG['reg_requires_valid_email'])) {
        if (UDB_INTEGRATION == 'coppermine') {
            // get default language in which to inform the admins
            $result = cpg_db_query("SELECT user_id, user_email, user_language FROM {$CONFIG['TABLE_USERS']} WHERE user_group = 1");
            while ( ($row = mysql_fetch_assoc($result)) ) {
                if (!empty($row['user_email'])) {
                    $admins[$row['user_id']] = array('email' => $row['user_email'], 'lang' => $row['user_language']);
                }
            }
        } else {
            //@todo: is it possible to get the language from bridged installs?
            $admins[] = array('email' => $CONFIG['gallery_admin_email'], 'lang' => 'english');
        }
        foreach($admins as $admin) {
            //check if the admin language is available
            if (file_exists("lang/{$admin['lang']}.php")) {
                $lang_register_php_def = cpg_get_default_lang_var('lang_register_php', $admin['lang']);
                $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email', $admin['lang']);
            } else {
                $lang_register_php_def = cpg_get_default_lang_var('lang_register_php');
                $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email');
            }


            // if the admin has to activate the login, give them the link to do so; but only if users don't have to verify their email address
            if ($CONFIG['admin_activation'] && !$CONFIG['reg_requires_valid_email']) {

                $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key;

                $template_vars = array(
                    '{SITE_NAME}' => $CONFIG['gallery_name'],
                    '{USER_NAME}' => $user_name,
                    '{ACT_LINK}' => $act_link,
                );

                cpg_mail($admin['email'], sprintf($lang_register_php_def['notify_admin_request_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_approve_email_def, $template_vars)));

            } elseif ($CONFIG['reg_notify_admin_email']) {

                // otherwise, email is for information only
                cpg_mail($admin['email'], sprintf($lang_register_php_def['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_register_php_def['notify_admin_email_body'], $user_name));
            }
        }
    }

    return true;
}

/***************************
* function definitions end *
***************************/




/***************************
* main code start          *
***************************/

// Activate pending registration
if ($superCage->get->keyExists('activate')) {

    $act_key = $superCage->get->getAlnum('activate');

    if (strlen($act_key) != 32) {
        cpg_die(ERROR, $lang_register_php['acct_act_failed'], __FILE__, __LINE__);
    }

    $sql = "SELECT user_active, user_email, user_email_valid, user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_actkey = '$act_key' LIMIT 1";
    $result = cpg_db_query($sql);

    if (!mysql_num_rows($result)) {
        cpg_die(ERROR, $lang_register_php['acct_act_failed'], __FILE__, __LINE__);
    }

    $row = mysql_fetch_assoc($result);
    mysql_free_result($result);

    if ($row['user_active'] == 'YES') {
        cpg_die(ERROR, $lang_register_php['acct_already_act'], __FILE__, __LINE__);
    }

    pageheader($lang_register_php['page_title']);

    if ($CONFIG['reg_requires_valid_email'] && !$CONFIG['admin_activation']) {
         // activate user (by user)
        $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_active = 'YES', user_actkey = '' WHERE user_actkey = '$act_key' LIMIT 1";
        $user_status = 'active_user';
    } elseif ($CONFIG['admin_activation'] && !$CONFIG['reg_requires_valid_email']) {
        // activate user (by admin)
        $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_active = 'YES', user_actkey = '' WHERE user_actkey = '$act_key' LIMIT 1";
        $user_status = 'active_admin';
    } else {
        if ($row['user_email_valid'] == 'YES') {
            // activate user (by admin)
            if (GALLERY_ADMIN_MODE) {
                $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_active = 'YES', user_actkey = '' WHERE user_actkey = '$act_key' LIMIT 1";
                $user_status = 'active_admin';
            } else {
                msg_box($lang_register_php['information'], $lang_register_php['thank_you_admin_activation'], $lang_common['continue'], 'index.php');
                pagefooter();
                exit;
            }
        } else {
            // email validated by user, send activation link to admin
            $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_email_valid = 'YES' WHERE user_actkey = '$act_key' LIMIT 1";
            $user_status = 'valid';
        }
    }
    cpg_db_query($sql);
    CPGPluginAPI::action('register_user_activation', $act_key);

    //after admin approves, user receives email notification
    if ($user_status == 'active_admin') {

        msg_box($lang_register_php['information'], $lang_register_php['acct_active_admin_activation'], $lang_common['continue'], 'index.php');

        $template_vars = array(
            '{SITE_LINK}' => $CONFIG['site_url'],
            '{USER_NAME}' => $row['user_name'],
            '{SITE_NAME}' => $CONFIG['gallery_name'],
        );

        cpg_mail($row['user_email'], sprintf($lang_register_php['notify_user_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_php['activated_email'], $template_vars)));

    } elseif ($user_status == 'valid') {
        // send activation link to admin

        msg_box($lang_register_php['information'], $lang_register_php['thank_you_admin_activation'], $lang_common['continue'], 'index.php');

        if (UDB_INTEGRATION == 'coppermine') {
            // get default language in which to inform the admins
            $result = cpg_db_query("SELECT user_id, user_email, user_language FROM {$CONFIG['TABLE_USERS']} WHERE user_group = 1");
            while ($row2 = mysql_fetch_assoc($result)) {
                if (!empty($row2['user_email'])) {
                    $admins[$row2['user_id']] = array('email' => $row2['user_email'], 'lang' => $row2['user_language']);
                }
            }
            mysql_free_result($result);
        } else {
            //@todo: is it possible to get the language from bridged installs?
            $admins[] = array('email' => $CONFIG['gallery_admin_email'], 'lang' => 'english');
        }
        foreach($admins as $admin) {
            //check if the admin language is available
            if (file_exists("lang/{$admin['lang']}.php")) {
                $lang_register_php_def = cpg_get_default_lang_var('lang_register_php', $admin['lang']);
                $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email', $admin['lang']);
            } else {
                $lang_register_php_def = cpg_get_default_lang_var('lang_register_php');
                $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email');
            }

            $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key;

            $template_vars = array(
                '{SITE_NAME}' => $CONFIG['gallery_name'],
                '{USER_NAME}' => $row['user_name'],
                '{ACT_LINK}' => $act_link,
            );

            cpg_mail($admin['email'], sprintf($lang_register_php_def['notify_admin_request_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_approve_email_def, $template_vars)));
        }
    } else {
        //user self-activated, gets message box that account was activated
        msg_box($lang_register_php['information'], $lang_register_php['acct_active'], $lang_common['continue'], 'index.php');
    }

} else {

    pageheader($lang_register_php['page_title']);

    if ($CONFIG['user_registration_disclaimer'] == 1 && !$superCage->post->keyExists('submit') && !$superCage->post->keyExists('agree')) {

        // display the disclaimer page
        display_disclaimer();

    } else {

        if (!$superCage->post->keyExists('submit')) {
            input_user_info();
        } else {
            if (!check_user_info($errors)) {
                input_user_info($errors);
            }
        }
    }
}

pagefooter();

?>

Logged

matheso

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 91
Re: How to integrate custom registration form with Coppermine's functionality
« Reply #19 on: December 30, 2014, 04:27:31 pm »

Wow, thanks vip! I'll test it out.

However, if André knows how I can *replicate* the form entirely, that'd be great. Meaning I'd like to keep Steps 1 - 3 in the form, and not all on one page.
The code also has JS which I don't know how to implement.

I'll test out vip's solution in the meantime! 

Custom form URL: http://codepen.io/atakan/pen/gqbIz
Logged
Pages: [1] 2   Go Up
 

Page created in 0.04 seconds with 19 queries.