Call reset password function after insert a record

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Call reset password function after insert a record

Post by RonP » 2018-07-25 09:20

Hi,
Maybe a strange subject, let me clarify this.
As new members of our volunteer organization can subscribe to us I wish to execute 2 things:
1. After saving the member fields I would like to send an email with a "Thank You" message, just like after registering as a "group member" by the procedure:

Code: Select all

membership_thankyou.php
2. As a new member you have to be able to modify your data, this could be done when I write a new record to the membership_users tabel and use that the newly given email address and name. After that the new member should be informed to change a password. With the help of:

Code: Select all

membership_passwordReset.php
I’ve setup a group in the

Code: Select all

membership-user table
to which the new member should be connected and this group has the “rights” to modify the only the “Owner-records”

I hope I'm clear enough in what I like to propose.
Ron

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-07-25 19:34

Hi Ron,

not sure, but are you asking on how to acheive this, or are u informing that this is the way you do it?

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-07-26 16:16

Hi,
Sorry that this was not clear enough.
It is indeed "How can I achieve this"?
Ron

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-04 16:56

Hi There,
Anyone a solution / hint for me/
Or shouldn’t I use the membership usertabel, instead of that a "logon function" direct on the "membership form"?

Ron

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-08-04 19:16

Hi Ron,

sorry to ask again.

to your 1'st question:
"volunteer organization can subscribe". How does this happen? Are the users already registered to the application and now they select somewhere the "subscribe to" option, or do the register to the system?

for point 2,
once you wrote the new record to the membership_users table you could need to call the membership_passwordReset.php as a "POST" with the form data

username:
email:
reset: Ok

where either the username, or the email is set to the newly created member. This would fire the mail to the new member and inform him to reset the password via the given link.

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-05 14:52

Hi PBöttcher,
Thanks for your reaction.
As for Q1.
Until now the process is as follows:
Someone becomes a "member" by filling out a form at our website.
An "administrator" of our organization copies (manually)the information and then fill out our "Appgini form".
So that is a strange way to make one a member.
According to the GDPR regulation one must be able to alter "its own personal data".
In the way we are doing this now, it won't work.

So I'm looking for a way to confirm to the GDPR.
Most suitable would be an "login" at my membership form AFTER one has become a member.

The email address is the "username" and a password has to be sent, just once, to that address, and of course one must have the ability to get a new password and to request for his email address in case it was forgotten

I hope this explanation is clear enough.

Ron

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-08-05 21:30

Hi Ron,

can you not just use the AppGini registration form (maybe limit it to the group for the user).
This would give you the option that the user registers himself, provides his password etc.
Through the AppGini Login, the user has the option to reset his password.

In order to provide the user with the abiliy to edit his data (which is the e-mail address and the 4 custom fields that you have for the user) you can create a view in your database pointing to the membership_users table.

e.g.

Code: Select all

CREATE VIEW `v_userinfo` AS select `membership_users`.`memberID` AS `memberID`,`membership_users`.`custom1` AS `custom1`,`membership_users`.`custom2` AS `custom2`,`membership_users`.`custom3` AS `custom3`,`membership_users`.`custom4` AS `custom4`,`membership_users`.`email` AS `email` from `membership_users`
In AppGini you create afterwards a new table in your application called v_userinfo and you add the fields that match the view definition with the datatypes of the membership_users table.
Then you select the memberID as primary key for this new table and set the checkbox to hide this field from the detailview to true.

Now you can create the application and you need to modify the hooks/v_userinfo.php -> v_userinfo_init funtion

Code: Select all

	function v_userinfo_init(&$options, $memberInfo, &$args){

	if ($memberInfo['group'] != 'Admins') {
	  	$options->QueryWhere = " where memberID = '".$memberInfo['username']."'";
	}
		return TRUE;
	}
You need to allow the group for your users to edit/update the v_userinfo table.
Like this the can go to the v_userinfo table and will see only their own record where they will be able to change the email and the 4 custom fields.

Hope that can help

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-06 18:00

Hi PBöttcher
Thanks again.
Later on this week I'll work on your suggestions. "I'll be back"
Ron

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-07 15:21

Hi PBöttcher
I've done what you've explained.
After making the changes I just wondered why I didn't think earlier to handle like this:
(so I don't work yet with your code, just with the "standard" Appgini functions (how blind can I be )

1. Every candidate new member has to login to Appgini, filling out the required fields.
2. I've set up a Group “Members", they automatically are "approved" and this group gets the rights for the "members-table" on bases of: his ownership to "View /Edit / Delete" his own record.
3. After getting an "approval" mail the new member can Login
So now I come to a fuzzy point for me:
4. After login the new member sees the "members table" with the option (after clicking on the table) "Add New"
What I wish is that an "empty" form is showed directly after the user has logged on
5. The user fills out the form and saves it.
6. The user logs out en after that he logs in again.
What the user now gets is again the "Members table", clicking on that he sees his own record, so he can modify however.....
He also sees the "Add New" button AND the "Save changes" button.

What goes fine now is:
  • New member creates an account, fills out an empty form, save this and logs out.
    New member logs in again and sees his "own information" to be modified.
What goes not that fine for me:
After login in the member first have to click on the table, instead of seeing an empty form ( after first time login)
You can create an new record, so one (the new member) can "blow up" the members table.

Questions:
1. Is it possible to show an empty form after first-time login?
2. Is it possible to show a form that is filled out by a member and hide the Add and Save as Copy buttons?
Ron

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-08-07 15:42

Hi Ron,

just to clarify. The "members-table" is a table that you created via AppGini. It has nothing to do with the internal membership_users table?

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-07 18:07

Yep,
See it as my own table, it actualy is called:"Leden" with our members of our organization.
Ron

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-15 08:27

Hi pböttcher
Do you have some suggestions to achieve my goal?
Ron

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-08-16 07:46

Hi Ron,

not sure what you mean by a blank page.
One idea that I can suggest would look like:

User who logs into the system will be redirected to the "User-Page" showing either his record, or an empty table with the ability to add his data, or his data with the ability to edit his data.

To acheive this you need to edit the index.php (will be overwritten when recreating your project).

in index.php replace:

Code: Select all

	}else{
		include("{$currDir}/home.php");
	}
with

Code: Select all

	}else{
		$mi = getMemberInfo();
		$group = $mi["group"];
		if ($group == 'YOURGROUPNAME') {
					include("{$currDir}/home.php");
		}
		else { 
					include("{$currDir}/Leden_view.php");
		}	
	}

in the hooks/Leden.php file you can
add to the Leden_header function: (replace the Leden-ID with a respective column name of your table, I assume here you have a column named ID).

Code: Select all

				$header="<%%HEADER%%><script type=\"text/javascript\">
						\$j(function(){
							if (\$j('td.Leden-ID').length > 0) \$j('#addNew').hide();
					        });
					</script>";
add to the Leden_dv function: (hide the buttons you do not want to display, I used addNew, save copy and delete here as sample)

Code: Select all

ob_start(); ?>
        <script type="text/javascript">

	$j(function(){
		$j('#addNew,#insert,#delete').hide();

	})
	</script>
<?php
	$new_layout = ob_get_contents();
	ob_end_clean();
		
	$html .= $new_layout;

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-17 15:41

Great,
I'm going to study and try it
Thank you so far.

Ron

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-19 15:03

Hi,
I've done your suggestions. (the table for the members is called: contacten)
I've changed the index.php and the ... .../hooks/contacten.php
I'm a bit confused about the result.
I've put the suggested code all at the bottom of the ../Templates/contacten_DV.html file

Code: Select all

						case 'view_parent_new_window':
							window.open(pt + '_view.php?SelectedID=' + encodeURIComponent(parent_id));
							break;
					}

				}
			});

		});
		// toegevoegd ivm AVR 19-8-19
						ob_start(); ?>
        <script type="text/javascript">

	$j(function(){
		$j('#addNew,#insert,#delete').hide();

	})
	</script>
<?php
	$new_layout = ob_get_contents();
	ob_end_clean();
		
	$html .= $new_layout;;
			
	</sript>
These are the lines 289-313
After this adjustment I don't see any difference.
The new member does see his "own" record, however he still cat Add / Copy records.
So..
I do something wrong.
Ron

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-08-19 18:17

Hi Ron,

all the changes suggested are either for the index.php (which you did)
and the hooks/contacten.php

in the hooks/contacten.php there are multiple functions:

one is called: contacten_header,
the other is called: contacten_dv

Those are the two functions you should put the code in. Of course you need to change in the code "Leden" to "contacten" where appropriate.

Templates/contacten_DV.html does not need to be changed.

Hope that clarifies

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-28 14:38

Hi,
Thanks for clarifying.
It is almost working.
2 thinks.
1. After a member has signed in he sees (in my case) the
contacten.php
window
In that window it still is possible to Add an record, That is not the purpose.
So do I miss some more code?

2 After signing in as a member <> a standard member, say administrator, I don't get the
index.php
, so there is something wrong with the code
Ron

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-08-30 12:21

Hi,
can you post your 2 files?

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-08-30 12:47

Sure,
As I can't send them as an attachments (.php forbidden) hereby the code.
Maybe good to know:
I (still) use Appgini 5.50 Revision 835
Index.php

Code: Select all

<?php
	error_reporting(E_ERROR | E_WARNING | E_PARSE);
	$currDir = dirname(__FILE__);
	include("{$currDir}/defaultLang.php");
	include("{$currDir}/language.php");
	include("{$currDir}/lib.php");

	$x = new DataList;
	$x->TableTitle = $Translation['homepage'];
	$tablesPerRow = 2;
	$arrTables = getTableList();

	// according to provided GET parameters, either log out, show login form (possibly with a failed login message), or show homepage
	if($_GET['signOut'] == 1){
		logOutMember();
	}elseif($_GET['loginFailed'] == 1 || $_GET['signIn'] == 1){
		if(!headers_sent() && $_GET['loginFailed'] == 1) header('HTTP/1.0 403 Forbidden');
		include("{$currDir}/login.php");
	  //} else                          - Originele code
	  //include("{$currDir}/home.php"); - Originele code
	  // adjusted code 2018-08-29
	  	}else{
		$mi = getMemberInfo();
		$group = $mi["group"];
		if ($group == 'Lid') {
					include("{$currDir}/home.php");
		}
		else { 
					include("{$currDir}/contacten_view.php");
		}	
	}
I've more groups:
  • 1 anonymous
    2 Admins
    3 Communicatie
    4 Penningmeester
    6 Support
    7 Bestuur
    8 Lid
contacten.php

Code: Select all

<?php

	/**
	 * @file
	 * This file contains hook functions that get called when data operations are performed on 'contacten' table. 
	 * For example, when a new record is added, when a record is edited, when a record is deleted, … etc.
	*/

	/**
	 * Called before rendering the page. This is a very powerful hook that allows you to control all aspects of how the page is rendered.
	 * 
	 * @param $options
	 * (passed by reference) a DataList object that sets options for rendering the page.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/DataList
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * True to render the page. False to cancel the operation (which could be useful for error handling to display 
	 * an error message to the user and stop displaying any data).
	*/

	function contacten_init(&$options, $memberInfo, &$args){

		return TRUE;
	}

	/**
	 * Called before displaying page content. Can be used to return a customized header template for the table.
	 * 
	 * @param $contentType
	 * specifies the type of view that will be displayed. Takes one the following values: 
	 * 'tableview', 'detailview', 'tableview+detailview', 'print-tableview', 'print-detailview', 'filters'
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * String containing the HTML header code. If empty, the default 'header.php' is used. If you want to include
	 * the default header besides your customized header, include the <%%HEADER%%> placeholder in the returned string.
	*/

	function contacten_header($contentType, $memberInfo, &$args){
		$header='';

		switch($contentType){
			case 'tableview':
				$header='';
				break;

			case 'detailview':
				$header='';
				break;

			case 'tableview+detailview':
				$header='';
				break;

			case 'print-tableview':
				$header='';
				break;

			case 'print-detailview':
				$header='';
				break;

			case 'filters':
				$header='';
				break;
		$header="<%%HEADER%%><script type=\"text/javascript\">
				\$j(function(){
					if (\$j('td.Id').length > 0) \$j('#addNew').hide();
					      });
					</script>";
		}
		return $header;
	}

	/**
	 * Called after displaying page content. Can be used to return a customized footer template for the table.
	 * 
	 * @param $contentType
	 * specifies the type of view that will be displayed. Takes one the following values: 
	 * 'tableview', 'detailview', 'tableview+detailview', 'print-tableview', 'print-detailview', 'filters'
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * String containing the HTML footer code. If empty, the default 'footer.php' is used. If you want to include 
	 * the default footer besides your customized footer, include the <%%FOOTER%%> placeholder in the returned string.
	*/

	function contacten_footer($contentType, $memberInfo, &$args){
		$footer='';

		switch($contentType){
			case 'tableview':
				$footer='';
				break;

			case 'detailview':
				$footer='';
				break;

			case 'tableview+detailview':
				$footer='';
				break;

			case 'print-tableview':
				$footer='';
				break;

			case 'print-detailview':
				$footer='';
				break;

			case 'filters':
				$footer='';
				break;
		}

		return $footer;
	}

	/**
	 * Called before executing the insert query.
	 * 
	 * @param $data
	 * An associative array where the keys are field names and the values are the field data values to be inserted into the new record.
	 * Note: if a field is set as read-only or hidden in detail view, it can't be modified through $data. You should use a direct SQL statement instead.
	 * For this table, the array items are: 
	 *     $data['LidNR'], $data['Factuurmaand'], $data['Achternaam'], $data['Voornaam'], $data['Adres'], $data['Woonplaats'], $data['Postcode'], $data['Tel_vast'], $data['Telmobiel'], $data['Email'], $data['Opmerkingen'], $data['Lid'], $data['Actief'], $data['Infrarood']
	 * $data array is passed by reference so that modifications to it apply to the insert query.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * A boolean TRUE to perform the insert operation, or FALSE to cancel it.
	*/

	function contacten_before_insert(&$data, $memberInfo, &$args){
	
		return TRUE;
	}

	/**
	 * Called after executing the insert query (but before executing the ownership insert query).
	 * 
	 * @param $data
	 * An associative array where the keys are field names and the values are the field data values that were inserted into the new record.
	 * For this table, the array items are: 
	 *     $data['LidNR'], $data['Factuurmaand'], $data['Achternaam'], $data['Voornaam'], $data['Adres'], $data['Woonplaats'], $data['Postcode'], $data['Tel_vast'], $data['Telmobiel'], $data['Email'], $data['Opmerkingen'], $data['Lid'], $data['Actief'], $data['Infrarood'], $data['Mutatiedatum'], $data['Mutator'], $data['Creatiedatum'], $data['Creator']
	 * Also includes the item $data['selectedID'] which stores the value of the primary key for the new record.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * A boolean TRUE to perform the ownership insert operation or FALSE to cancel it.
	 * Warning: if a FALSE is returned, the new record will have no ownership info.
	*/

	function contacten_after_insert($data, $memberInfo, &$args){
   // Bij een nieuw record mutator = creator.
   sql("update `contacten` set `Mutator`= '{$data['Creator']}' where `Id` = LAST_INSERT_ID()", $eo);
   sql("update `contacten` set `Mutatiedatum`= '{$data['Creatiedatum']}' where `Id` = LAST_INSERT_ID()", $eo);
   
   // Bij een nieuw record: Lidnr wordt met 1 verhoogd.
   
   $sql_string = "SELECT MAX(LidNr) + 1 FROM contacten;";
   $new_lidnr = sqlValue($sql_string, $o);
   $sql_string = "UPDATE contacten set LidNr = " . $new_lidnr . " WHERE id = " . $data['selectedID'] . ";";
   $result = sql($sql_string, $o);
   
// to compose a message containing the submitted data,
	// we need to iterate through the $data array
	foreach($data as $field => $value){
	$messageData .= "$field: $value \n";
	}
@mail(
		// mail recipient
		"ron@sunpage.nl",
		
		// subject
		"Een nieuwe inschrijving voor HE",
		
		// message
		"Nieuw inschrijving ingevoerd door: {$memberInfo['username']}: \n\n".
		$messageData,
		
		// sender address
		"From: info@heilooenergie.nl"
	);

		return TRUE;
	}

	/**
	 * Called before executing the update query.
	 * 
	 * @param $data
	 * An associative array where the keys are field names and the values are the field data values.
	 * Note: if a field is set as read-only or hidden in detail view, it can't be modified through $data. You should use a direct SQL statement instead.
	 * For this table, the array items are: 
	 *     $data['Id'], $data['LidNR'], $data['Factuurmaand'], $data['Achternaam'], $data['Voornaam'], $data['Adres'], $data['Woonplaats'], $data['Postcode'], $data['Tel_vast'], $data['Telmobiel'], $data['Email'], $data['Opmerkingen'], $data['Lid'], $data['Actief'], $data['Infrarood']
	 * Also includes the item $data['selectedID'] which stores the value of the primary key for the record to be updated.
	 * $data array is passed by reference so that modifications to it apply to the update query.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * True to perform the update operation or false to cancel it.
	*/

	function contacten_before_update(&$data, $memberInfo, &$args){

		return TRUE;
	}

	/**
	 * Called after executing the update query and before executing the ownership update query.
	 * 
	 * @param $data
	 * An associative array where the keys are field names and the values are the field data values.
	 * For this table, the array items are: 
	 *     $data['Id'], $data['LidNR'], $data['Factuurmaand'], $data['Achternaam'], $data['Voornaam'], $data['Adres'], $data['Woonplaats'], $data['Postcode'], $data['Tel_vast'], $data['Telmobiel'], $data['Email'], $data['Opmerkingen'], $data['Lid'], $data['Actief'], $data['Infrarood'], $data['Mutatiedatum'], $data['Mutator'], $data['Creatiedatum'], $data['Creator']
	 * Also includes the item $data['selectedID'] which stores the value of the primary key for the record.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * True to perform the ownership update operation or false to cancel it. 
	*/

	function contacten_after_update($data, $memberInfo, &$args){

		return TRUE;
	}

	/**
	 * Called before deleting a record (and before performing child records check).
	 * 
	 * @param $selectedID
	 * The primary key value of the record to be deleted.
	 * 
	 * @param $skipChecks
	 * A flag passed by reference that determines whether child records check should be performed or not.
	 * If you set $skipChecks to TRUE, no child records check will be made. If you set it to FALSE, the check will be performed.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * True to perform the delete operation or false to cancel it.
	*/

	function contacten_before_delete($selectedID, &$skipChecks, $memberInfo, &$args){

		return TRUE;
	}

	/**
	 * Called after deleting a record.
	 * 
	 * @param $selectedID
	 * The primary key value of the record to be deleted.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * None.
	*/

	function contacten_after_delete($selectedID, $memberInfo, &$args){

	}

	/**
	 * Called when a user requests to view the detail view (before displaying the detail view).
	 * 
	 * @param $selectedID
	 * The primary key value of the record selected. False if no record is selected (i.e. the detail view will be 
	 * displayed to enter a new record).
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $html
	 * (passed by reference) the HTML code of the form ready to be displayed. This could be useful for manipulating 
	 * the code before displaying it using regular expressions, … etc.
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * None.
	*/

	function contacten_dv($selectedID, $memberInfo, &$html, &$args){
	// aangepast 2018-08-29
ob_start(); ?>
        <script type="text/javascript">

	$j(function(){
		$j('#addNew,#insert,#delete').hide();

	})
	</script>
<?php
	$new_layout = ob_get_contents();
	ob_end_clean();
		
	$html .= $new_layout;
	}

	/**
	 * Called when a user requests to download table data as a CSV file (by clicking on the SAVE CSV button)
	 * 
	 * @param $query
	 * Contains the query that will be executed to return the data in the CSV file.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * A string containing the query to use for fetching the CSV data. If FALSE or empty is returned, the default query is used.
	*/

	function contacten_csv($query, $memberInfo, $args){

		return $query;
	}
Lines 342-356 are mofified
I really appreciate your help
Ron

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-08-30 18:56

Hi.
in the index.php only Users of the Lid group will go to the Homepage, all others will go to the contacten page. You need to set the correct group match to match the groups that should go to the honepage.

In the contacten.php you added the code to the filter, but it needs to go to the tableview (or tableview+detailview in you have this active).
Also put the code before the break statement, not after.

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-09-14 14:30

Hi,
I've been away for a while.
I've lost you. My knowledge of PHP is poor.
If I login as <> "Lid" than I get a blanc screen. See file: Member-no-Lid-01.png
If I login as == “Lid” then I do see “my record” but I still can “add” a new record. See files:
Member-Lid-page-01.png and Member-Lid-detail-01.png
I don't know what you mean by
Also put the code before the break statement, not after.
How can I go on?
Attachments
Member-Lid-page-01.PNG
Member-Lid-page-01.PNG (94.67 KiB) Viewed 70 times
Member-Lid-detail-01.PNG
Member-Lid-detail-01.PNG (83.28 KiB) Viewed 70 times
Member-no-Lid-01.PNG
Member-no-Lid-01.PNG (13.4 KiB) Viewed 70 times

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 236
Joined: 2018-04-01 10:12

Re: Call reset password function after insert a record

Post by pböttcher » 2018-09-16 08:47

Hi Ron,

can you please check if the php contacten_view.php exists. If you are not a member of the Lid group, this page should be loaded. As you are getting a blank page I think there is an error here. Can you check if you can call this page directly.
With the hint of Jan you can handle the add-button issue via the "after-insert" and "after-delete" function.

contacten.php should look like:

Code: Select all

<?php

	/**
	 * @file
	 * This file contains hook functions that get called when data operations are performed on 'contacten' table. 
	 * For example, when a new record is added, when a record is edited, when a record is deleted, … etc.
	*/

	/**
	 * Called before rendering the page. This is a very powerful hook that allows you to control all aspects of how the page is rendered.
	 * 
	 * @param $options
	 * (passed by reference) a DataList object that sets options for rendering the page.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/DataList
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * True to render the page. False to cancel the operation (which could be useful for error handling to display 
	 * an error message to the user and stop displaying any data).
	*/

	function contacten_init(&$options, $memberInfo, &$args){

		return TRUE;
	}

	/**
	 * Called before displaying page content. Can be used to return a customized header template for the table.
	 * 
	 * @param $contentType
	 * specifies the type of view that will be displayed. Takes one the following values: 
	 * 'tableview', 'detailview', 'tableview+detailview', 'print-tableview', 'print-detailview', 'filters'
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * String containing the HTML header code. If empty, the default 'header.php' is used. If you want to include
	 * the default header besides your customized header, include the <%%HEADER%%> placeholder in the returned string.
	*/

	function contacten_header($contentType, $memberInfo, &$args){
		$header='';

		switch($contentType){
			case 'tableview':
				$header='';
				break;

			case 'detailview':
				$header='';
				break;

			case 'tableview+detailview':
				$header='';
				break;

			case 'print-tableview':
				$header='';
				break;

			case 'print-detailview':
				$header='';
				break;

			case 'filters':
                		$header=""
				break;
		}
		return $header;
	}

	/**
	 * Called after displaying page content. Can be used to return a customized footer template for the table.
	 * 
	 * @param $contentType
	 * specifies the type of view that will be displayed. Takes one the following values: 
	 * 'tableview', 'detailview', 'tableview+detailview', 'print-tableview', 'print-detailview', 'filters'
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * String containing the HTML footer code. If empty, the default 'footer.php' is used. If you want to include 
	 * the default footer besides your customized footer, include the <%%FOOTER%%> placeholder in the returned string.
	*/

	function contacten_footer($contentType, $memberInfo, &$args){
		$footer='';

		switch($contentType){
			case 'tableview':
				$footer='';
				break;

			case 'detailview':
				$footer='';
				break;

			case 'tableview+detailview':
				$footer='';
				break;

			case 'print-tableview':
				$footer='';
				break;

			case 'print-detailview':
				$footer='';
				break;

			case 'filters':
				$footer='';
				break;
		}

		return $footer;
	}

	/**
	 * Called before executing the insert query.
	 * 
	 * @param $data
	 * An associative array where the keys are field names and the values are the field data values to be inserted into the new record.
	 * Note: if a field is set as read-only or hidden in detail view, it can't be modified through $data. You should use a direct SQL statement instead.
	 * For this table, the array items are: 
	 *     $data['LidNR'], $data['Factuurmaand'], $data['Achternaam'], $data['Voornaam'], $data['Adres'], $data['Woonplaats'], $data['Postcode'], $data['Tel_vast'], $data['Telmobiel'], $data['Email'], $data['Opmerkingen'], $data['Lid'], $data['Actief'], $data['Infrarood']
	 * $data array is passed by reference so that modifications to it apply to the insert query.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * A boolean TRUE to perform the insert operation, or FALSE to cancel it.
	*/

	function contacten_before_insert(&$data, $memberInfo, &$args){
	
		return TRUE;
	}

	/**
	 * Called after executing the insert query (but before executing the ownership insert query).
	 * 
	 * @param $data
	 * An associative array where the keys are field names and the values are the field data values that were inserted into the new record.
	 * For this table, the array items are: 
	 *     $data['LidNR'], $data['Factuurmaand'], $data['Achternaam'], $data['Voornaam'], $data['Adres'], $data['Woonplaats'], $data['Postcode'], $data['Tel_vast'], $data['Telmobiel'], $data['Email'], $data['Opmerkingen'], $data['Lid'], $data['Actief'], $data['Infrarood'], $data['Mutatiedatum'], $data['Mutator'], $data['Creatiedatum'], $data['Creator']
	 * Also includes the item $data['selectedID'] which stores the value of the primary key for the new record.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * A boolean TRUE to perform the ownership insert operation or FALSE to cancel it.
	 * Warning: if a FALSE is returned, the new record will have no ownership info.
	*/

	function contacten_after_insert($data, $memberInfo, &$args){
   // Bij een nieuw record mutator = creator.
   sql("update `contacten` set `Mutator`= '{$data['Creator']}' where `Id` = LAST_INSERT_ID()", $eo);
   sql("update `contacten` set `Mutatiedatum`= '{$data['Creatiedatum']}' where `Id` = LAST_INSERT_ID()", $eo);
   
   // Bij een nieuw record: Lidnr wordt met 1 verhoogd.
   
   $sql_string = "SELECT MAX(LidNr) + 1 FROM contacten;";
   $new_lidnr = sqlValue($sql_string, $o);
   $sql_string = "UPDATE contacten set LidNr = " . $new_lidnr . " WHERE id = " . $data['selectedID'] . ";";
   $result = sql($sql_string, $o);
   
// to compose a message containing the submitted data,
	// we need to iterate through the $data array
	foreach($data as $field => $value){
	$messageData .= "$field: $value \n";
	}
@mail(
		// mail recipient
		"ron@sunpage.nl",
		
		// subject
		"Een nieuwe inschrijving voor HE",
		
		// message
		"Nieuw inschrijving ingevoerd door: {$memberInfo['username']}: \n\n".
		$messageData,
		
		// sender address
		"From: info@heilooenergie.nl"
	);

    $table = "contacten";
    $sql = "INSERT INTO `membership_userpermissions`(`memberID`, `tableName`, `allowInsert`, `allowView`, `allowEdit`, `allowDelete`) VALUES ('" . $memberInfo['username'] . "', '" . $table . "', '0', '1', '1', '1')";
    sql($sql, $eo);
    return $eo == null;
		return TRUE;
	}

	/**
	 * Called before executing the update query.
	 * 
	 * @param $data
	 * An associative array where the keys are field names and the values are the field data values.
	 * Note: if a field is set as read-only or hidden in detail view, it can't be modified through $data. You should use a direct SQL statement instead.
	 * For this table, the array items are: 
	 *     $data['Id'], $data['LidNR'], $data['Factuurmaand'], $data['Achternaam'], $data['Voornaam'], $data['Adres'], $data['Woonplaats'], $data['Postcode'], $data['Tel_vast'], $data['Telmobiel'], $data['Email'], $data['Opmerkingen'], $data['Lid'], $data['Actief'], $data['Infrarood']
	 * Also includes the item $data['selectedID'] which stores the value of the primary key for the record to be updated.
	 * $data array is passed by reference so that modifications to it apply to the update query.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * True to perform the update operation or false to cancel it.
	*/

	function contacten_before_update(&$data, $memberInfo, &$args){

		return TRUE;
	}

	/**
	 * Called after executing the update query and before executing the ownership update query.
	 * 
	 * @param $data
	 * An associative array where the keys are field names and the values are the field data values.
	 * For this table, the array items are: 
	 *     $data['Id'], $data['LidNR'], $data['Factuurmaand'], $data['Achternaam'], $data['Voornaam'], $data['Adres'], $data['Woonplaats'], $data['Postcode'], $data['Tel_vast'], $data['Telmobiel'], $data['Email'], $data['Opmerkingen'], $data['Lid'], $data['Actief'], $data['Infrarood'], $data['Mutatiedatum'], $data['Mutator'], $data['Creatiedatum'], $data['Creator']
	 * Also includes the item $data['selectedID'] which stores the value of the primary key for the record.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * True to perform the ownership update operation or false to cancel it. 
	*/

	function contacten_after_update($data, $memberInfo, &$args){

		return TRUE;
	}

	/**
	 * Called before deleting a record (and before performing child records check).
	 * 
	 * @param $selectedID
	 * The primary key value of the record to be deleted.
	 * 
	 * @param $skipChecks
	 * A flag passed by reference that determines whether child records check should be performed or not.
	 * If you set $skipChecks to TRUE, no child records check will be made. If you set it to FALSE, the check will be performed.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * True to perform the delete operation or false to cancel it.
	*/

	function contacten_before_delete($selectedID, &$skipChecks, $memberInfo, &$args){

		return TRUE;
	}

	/**
	 * Called after deleting a record.
	 * 
	 * @param $selectedID
	 * The primary key value of the record to be deleted.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * None.
	*/

	function contacten_after_delete($selectedID, $memberInfo, &$args){
    $table = "contacten";
    $sql = "INSERT INTO `membership_userpermissions`(`memberID`, `tableName`, `allowInsert`, `allowView`, `allowEdit`, `allowDelete`) VALUES ('" . $memberInfo['username'] . "', '" . $table . "', '1', '1', '1', '1')";
    sql($sql, $eo);
    return $eo == null;
	}

	/**
	 * Called when a user requests to view the detail view (before displaying the detail view).
	 * 
	 * @param $selectedID
	 * The primary key value of the record selected. False if no record is selected (i.e. the detail view will be 
	 * displayed to enter a new record).
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $html
	 * (passed by reference) the HTML code of the form ready to be displayed. This could be useful for manipulating 
	 * the code before displaying it using regular expressions, … etc.
	 * 
	 * @param $args
	 * An empty array that is passed by reference. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * None.
	*/

	function contacten_dv($selectedID, $memberInfo, &$html, &$args){
	// aangepast 2018-08-29
ob_start(); ?>
        <script type="text/javascript">

	$j(function(){
		$j('#addNew,#insert,#delete').hide();

	})
	</script>
<?php
	$new_layout = ob_get_contents();
	ob_end_clean();
		
	$html .= $new_layout;
	}

	/**
	 * Called when a user requests to download table data as a CSV file (by clicking on the SAVE CSV button)
	 * 
	 * @param $query
	 * Contains the query that will be executed to return the data in the CSV file.
	 * 
	 * @param $memberInfo
	 * An array containing logged member's info.
	 * @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
	 * 
	 * @param $args
	 * An empty array. It's currently not used but is reserved for future uses.
	 * 
	 * @return
	 * A string containing the query to use for fetching the CSV data. If FALSE or empty is returned, the default query is used.
	*/

	function contacten_csv($query, $memberInfo, $args){

		return $query;
	}

User avatar
RonP
Veteran Member
Posts: 114
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Call reset password function after insert a record

Post by RonP » 2018-09-18 14:10

Hi pböttcher
Thanks again for your support.
1. I can load contacten_view.php, see attachment. So I didn't sign in.
2. After using your code for contacten.php nothing happens, so I fall back to "mine contacten.php".
This works fair enough for "members", don't work for not members, empty page on the screen.

Is it a suggestion that I set up an test environment for you, in order have a better look at "my problem"?

Ron
Attachments
Not_Signed_in_contacten_view.PNG
Not_Signed_in_contacten_view.PNG (106.48 KiB) Viewed 12 times

Post Reply