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.
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
"[email protected]",
// subject
"Een nieuwe inschrijving voor HE",
// message
"Nieuw inschrijving ingevoerd door: {$memberInfo['username']}: \n\n".
$messageData,
// sender address
"From: [email protected]"
);
$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;
}