Coming soon - how to add your own page to your app

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Coming soon - how to add your own page to your app

Post by shasta59 » 2013-07-10 15:02

Ever wonder how to add in your own page which is not generated by AppGini but you want the same controlled user access (name/password). Want it to pull data from your mysql database? Want to have it show up in the menus and as a clickable block on the home page? Want it to be just an info page pulling details from the database but do not need it to allow updating of data. (A read only type of situation).

I will post my notes later on how I do this. As an example I have a page which shows minimum contact information for a group. It only shows name, email, phone # and a picture. This page can be seen by all members of all groups with proper access (I do take a shortcut on this) but not be accessed by anyone without a proper user/pass. I also have it write into a separate table who looked at it and when for tracking purposes.

I will put up my notes on what to add to a page to get it to only allow proper user access, how to add to menu and home page (hooks here we come) etc. I will not be telling how to write the code but only what you need to do to make sure it is within the AppGini generated system as a page.

Look for this in about a week.
Calgary, Alberta, Canada - Using Appgini 5.50 -

KSan
AppGini Super Hero
AppGini Super Hero
Posts: 252
Joined: 2013-01-08 20:17

Re: Coming soon - how to add your own page to your app

Post by KSan » 2013-07-10 20:08

This is wonderful!!! I had a need like this recently and sort of cheated my way out. I created a dummy table on AppGini so it took care of the page creation and menus etc. I then tried to hide the table in both list view and detail view. Sort of got what I wanted but it was klunky. Can't wait for your solution. Thanks for sharing.

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: Coming soon - how to add your own page to your app

Post by shasta59 » 2013-07-10 20:33

I tried that also and it was good for a quick fix but not a solution. As soon as I can I will post it.

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Re: Coming soon - how to add your own page to your app

Post by benzoD » 2013-08-01 15:34

Another vote for "This would be awesome". Thanks, shasta.

jewa
Posts: 2
Joined: 2013-06-12 14:13

Re: Coming soon - how to add your own page to your app

Post by jewa » 2013-08-10 08:04

And another vote for this great option!!
Any estimation on WHEN this might be available?
I would stop thinking of doing it my own, when I know its just a few days/week away in a professional version :-)
Thanks!

Yilmaz
Veteran Member
Posts: 32
Joined: 2013-01-24 16:58

Re: Coming soon - how to add your own page to your app

Post by Yilmaz » 2013-08-13 09:27

Dear all,

I had a similar requirment from a customer and I'have solved it as following:

- The additional application was in my case an "CSV-upload" module
- I implemented it and saved it as http://your-domain.com/csv-upload.php
- The users should NOT have access by calling the link above before they have signed in
- I edited the ../hooks/links-home.php and added one additional block with a link to the new php module (csv-module.php)
- Also I configured within the links-home.php the access rights which user group should have access to this module
- At least I added within my csv-upload.php at very top the following code (before <!DOCTYPE html public ....>):

[BEGIN CODE]
<?php
// Author: yilmaz.backir
// Date: 31.5.2013

include("../lib.php");

$db = new mysqli('localhost', 'your_dbuser', 'your_pwd', 'your_db');
$haendler = getLoggedMemberID();
$haendlername = sqlValue("SELECT custom1 FROM `membership_users` WHERE membership_users.memberID = $haendler");

if ($db->connect_errno)
{
echo 'Es konnte keine Datenbankverbindung hergestellt werden!<br />';
echo 'Folgender Fehler ist aufgetreten: (' . $db->connect_errno . ') ' . $db->connect_error;
exit;
}
error_reporting(0);
header("Content-type: text/html; charset=utf-8");

//Important part for using the same Appgini controlled user access!
$perm=getTablePermissions('srr_main');
if(!$perm[0]){
echo StyleSheet();
echo "<div class=\"error\">".$Translation['tableAccessDenied']."</div>";
echo '<script language="javaScript">setTimeout("window.location=\'../index.php?signOut=1\'", 2000);</script>';
exit;
}
?>
.....YOUR CODE ...
[END CODE]

- Explanation:
--> include("../lib.php") --> including of the necessary functions for permission queries
--> if(!$perm[0]){... --> Forwarding to the Login page if the user is not logged in.

That's it!

Kind regards,
Yilmaz

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Coming soon - how to add your own page to your app

Post by espo » 2013-10-10 09:09

Hello Yilmaz,

are a novice of the code and I would like, if possible, that better explain to me the steps I need to do to add the CSV upload form.
I did not understand a few steps.

I write what I understand and can you tell me where I'm wrong?

- The additional application was in my case an "CSV-upload" module

- Implemented it and I saved it as http://your-domain.com/csv-upload.php
(I created the page CSV-upload.php)

- The users Should not have access by calling the link above before they have signed in
- I edited the .. / hooks / links-home.php and added one additional block with a link to the new php module (csv-module.php)
(you could send me an example of how you created this module?)

- Also I configured Within the links-home.php the user group access rights Which Should Have Access to this module
(as I do?)

- At least I added within my csv-upload.php at the very top Following code (before <! DOCTYPE html public ....>):

Thank you very much for your patience!

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Coming soon - how to add your own page to your app

Post by espo » 2013-10-15 11:45

Hello,

I can receive an aid to configure as posted by Yilmaz?

  I edited the .. / hooks / links-home.php and added one additional block with a link to the new php module (csv-module.php)
I created this and it works!

- Also I configured Within the links-home.php the user group access rights Which Should Have Access to this module
I created this and it works!

- At least I added within my csv-upload.php at the very top Following code (before <! DOCTYPE html public ....>):
I created this (with the changes to my DB).

echo '<script LANGUAGE="JavaScript"> setTimeout ("window.location = \'.. / index.php? SignOut = 1 \ '", 2000) </ script>';
exit;
}
?>
YOUR CODE ..... ... (Can I have an example of what to include?)
[END CODE]

If I specify only the text (eg CSV UPLOAD) page brings me this error:

Warning: include(../lib.php): failed to open stream: No such file or directory in C:\xampp-portable\htdocs\giulio4\csv-upload.php on line 5

Warning: include(): Failed opening '../lib.php' for inclusion (include_path='.;\xampp-portable\php\PEAR') in C:\xampp-portable\htdocs\giulio4\csv-upload.php on line 5

Fatal error: Call to undefined function getLoggedMemberID() in C:\xampp-portable\htdocs\giulio4\csv-upload.php on line 8

This is the code that I inserted, where am I wrong?

<?php
// Author: yilmaz.backir
// Date: 31.5.2013

include("../lib.php");

$db = new mysqli('localhost', 'user_db', 'pw_db', 'giulio4');
$haendler = getLoggedMemberID();
$haendlername = sqlValue("SELECT custom1 FROM `membership_users` WHERE membership_users.memberID = $haendler");

if ($db->connect_errno)
{
echo 'Nessuna connessione al DataBase!<br />';
echo 'Si è verificato il seguente errore: (' . $db->connect_errno . ') ' . $db->connect_error;
exit;
}
error_reporting(0);
header("Content-type: text/html; charset=utf-8");

//Important part for using the same Appgini controlled user access!
$perm=getTablePermissions('srr_main');
if(!$perm[0]){
echo StyleSheet();
echo "<div class=\"error\">".$Translation['tableAccessDenied']."</div>";
echo '<script language="javaScript">setTimeout("window.location=\'../index.php?signOut=1\'", 2000);</script>';
exit;
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
CSV UPLOAD
</body>
</html>

Thanks in advance for the help

Yilmaz
Veteran Member
Posts: 32
Joined: 2013-01-24 16:58

Re: Coming soon - how to add your own page to your app

Post by Yilmaz » 2013-10-15 16:40

Hi espo,

good idea to test the php with a test html-site. I suppose that the problem is with the path where you should include the librarys for the required functions as getMemberInfo etc, e.g.: include("../lib.php");

The path should relative from the location where your own csv-upload.php is stored, may be include("../../lib.php");

Please try to include the lib.php from the right location, then it should work!

Regards,

Yilmal

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Coming soon - how to add your own page to your app

Post by espo » 2013-10-16 07:52

Hello Yilmaz,

I've also written a private message to better explain the problem encountered.
If we solve then place everything on the forum ...

Thank you very much.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Coming soon - how to add your own page to your app

Post by espo » 2013-10-30 09:43

Hello Yilmaz,

I would like to ask a help to create the CSV file.
When I try to upload the file AppGini leaves me this error:
Unknown column 'admin' in 'where clause'

You insert the code of the two pages I created. If you can control them and let me know where I'm wrong.

Thank you very much.

upload.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>Inserisci il file da caricare nell'RMA

<form enctype="multipart/form-data" method="post" action="csv_upload.php">

File CSV: <input type="file" name="filecsv" value=""/>

<input type="submit" name="" value="Upload"/>

</form>

</body>
</html>

csv_upload.php

<?php
// Author: yilmaz.backir
// Date: 31.5.2013

include("lib.php");

$db = new mysqli('localhost', 'admin_db', 'pw_db', 'giulio4');
$haendler = getLoggedMemberID();
$haendlername = sqlValue("SELECT custom1 FROM `membership_users` WHERE membership_users.memberID = $haendler");

if ($db->connect_errno)
{
echo 'Nessuna connessione al DataBase!<br />';
echo 'Si è verificato il seguente errore: (' . $db->connect_errno . ') ' . $db->connect_error;
exit;
}
error_reporting(0);
header("Content-type: text/html; charset=utf-8");

//Important part for using the same Appgini controlled user access!
$perm=getTablePermissions('srr_main');
if(!$perm[0]){
echo StyleSheet();
echo "<div class=\"error\">".$Translation['tableAccessDenied']."</div>";
echo '<script language="javaScript">setTimeout("window.location=\'index.php?signOut=1\'", 2000);</script>';
exit;
}


// Recupero il file
$file = $_FILES['filecsv'];

$nome_file = $file['tmp_name']; # Nome temporaneo file
$size_file = $file['size']; # Dimensione file

// Controllo che il file sia stato inserito e che quindi esista
if ( ($handle = fopen($nome_file, "r") ) !== FALSE) {
// Uso un contatore per vedere se sono nella prima riga dei campi
$cont = 0;

// Uso la funzione fgetcsv per recuperare le informzioni nel modo corretto dal CSV
// Il secondo parametro è la dimesione del file, che abbiamo recuperato sopra
// Come si vede il 3 parametro è il separatore dei campi (;)
// Il separatore per ogni riga in automatico è l'a capo
while ( ( $data = fgetcsv($handle, $size_file, ";") ) !== FALSE ) {
if ( $cont == 0 ) {
$cont++;

// Assegno ad una variabile $campi_tabella, la prima riga del nome dei campi del CSV
$campi_tabella = $data;
}
else {
// Recupero i nomi dei campi
$campo_tipo = $campi_tabella[0];
$campo_costo = $campi_tabella[1];
$campo_numero = $campi_tabella[2];


// Recupero i valori dei campi
$tipo = $data[0];
$costo = $data[1];
$numero = $data[2];


// Creo una query di inserimento e la eseguo
$sql = "
INSERT INTO db SET
$campo_tipo = '$tipo',
$campo_costo = '$costo',
$campo_numero = '$numero',

";
$rssql = mysql_query( $sql );

// Controllo che l'importazione sia avvenuta con successo
echo ( $rssql ) ? "Importazione avvenuta con successo" : "Errore nella query o connessione al DB mancante";
}
}
}
else
echo "Nessun file inserito";
?>

drascom
Posts: 16
Joined: 2013-04-20 16:54

Re: Coming soon - how to add your own page to your app

Post by drascom » 2014-12-21 21:02

this part ......membership_users.memberID = $haendler ....must be

membership_users.memberID = '$haendler' than it will not gives error.

Post Reply