Wiki ▸ [Developer Docs](Developer Docs) ▸ [Code Corner](Code Corner) ▸ day one ▸ day two
On our first day, we had do do some of the stuff of day zero - the "how to get started" stuff - to be up to date. And we went through the setup of the EGroupware Application, which is described elsewhere.
As first application we decided to do: Hello World The motivation for this was to learn the very basics of: what does an EGroupware application need.
Every application needs an application directory within the EGroupware tree.
Consider [droyws]
the document root of your web-server.
Then [droyws]/egroupware
is the root of your EGroupware-application.
Your own Application, we will baptise it test
, for obvious reasons needs a folder "test" just there:
[droyws]/egroupware/test
Within test
the following structure is needed, for EGroupware to recognize our new application:
/index.php
/inc
/setup
/setup/setup.inc.php (required)
/setup/tables_current.inc.php (optional)
/templates
/templates/default
/templates/default/images
/templates/default/images/navbar.png (optional)
Obviously inc
, setup
, templates
, templates/default
and templates/default/images
are folders.
After suplying the structure, you have to register the application with EGroupware.
This is done via the setup area within EGroupware (via the egw/setup/ URL).
But you need the (required) file setup.inc.php
in folder $app/setup
.
$app/setup/setup.inc.php
should contain the information to setup your application.
<?php
$setup_info['test']['name'] = 'test';
$setup_info['test']['title'] = 'Test';
$setup_info['test']['version'] = '16.1'; //anything you like, as long as it is fitting the schema of a version number 0.9.001 may work as well
$setup_info['test']['app_order'] = 100; // at the end. most likely
$setup_info['test']['enable'] = 1;
//$setup_info['test']['index'] = 'test.test_ui.index&ajax=true';
$setup_info['test']['autoinstall'] = true; // install automatically on update
// here comes some author info. you may or may not provide it.
// But IF, you should use your OWN Info
$setup_info['test']['author'] = 'Stylite AG';
$setup_info['test']['license'] = 'GPL';
$setup_info['test']['description'] = 'Test application in EGroupware';
$setup_info['test']['maintainer'] = 'Stylite AG';
$setup_info['test']['maintainer_email'] = 'info@stylite.de';
// if there are any tables, that belong to the application, list them here
//$setup_info['test']['tables'] = array('egw_test');
/* Dependencies for this app to work */
// we intend to build up from the newest api
$setup_info['test']['depends'][] = array(
'appname' => 'api',
'versions' => Array('16.1')
);
Within the setup area you go to manage Applications (Setup Main Menu) check the name of your application (the name of the folder within the EGroupwaretree, where your Application is going to reside) and click install.
Or you can do it via directly accessing the mySQL database:
INSERT INTO egw_applications (app_name, app_enabled) VALUES('appname', 1);
Apply sufficient rights, ...
After adding the entry there you have to allow yourself or your group the access to the newly registered application.
You do that by using the admin/preferences module, choosing Usergroups/Useraccounts , choosing a User or a ::Group and checking the newly registered application.
After logoff/logon you should be able to access the new application via EGroupware.
You will get an error - for sure. Since there is no suitable index.php within the new application subtree.
... and some code to the file index.php and off you go.
The content of test/index.php should include:
<?php
/*
prepare some application information for EGroupware to know
If the applicationname of your application (e.g.: test) and the value of
currentapp does not match, you will recieve an authentication error
*/
$GLOBALS['egw_info'] = array('flags' => array(
'currentapp'=> 'test' ,
'noheader' => False,
'nonavbar' => False,
));
/*
include THE EGroupware header, that takes care of the sessionhandling
and the other background stuff
the information provided above is used/required here in order to get the application running
*/
include('../header.inc.php');
//Your content….
echo "Hello World! <br />";
// display some debug content
$userinfo=$GLOBALS['egw_info']['user'];
echo "we have a wole lot information about/for the user/session: \r\n";
//_debug_array(array_keys($userinfo));
//_debug_array($GLOBALS['egw_info']);
unset($userinfo['preferences']);//the users effective preferences for all apps
unset($userinfo['memberships']);//the users effective memberships in groups
unset($userinfo['apps']);//the users effective / available apps
unset($userinfo['passwd']);//effective password for you. we dont want to show it here
_debug_array($userinfo);
//display the EGroupware footer
common::egw_footer();
We provided only the starting <?php
tag, to avoid problems with trailing blanks after the closing tag.
You have now created your first application within EGroupware.
Unleash the _debug_array($GLOBALS['egw_info'])
and you will get info thrown at you, that you did not really want to have in the first place. A lot.
_debug_array($userinfo)
informs you about your loginid your sessionid and so on (after we stripped some of the info, that may or may not confuse you at this time).
Array
(
[account_firstname] => me
[account_lastname] => here
[account_email] => me@here.net
[account_fullname] => me here
[person_id] => 2
[account_created] =>
[account_modified] => 1352109561
[account_phone] =>
[account_id] => 5
[account_lid] => me
[account_pwd] => {crypt}aadggggh$/hGtttttttttttttTTTTTTTTerTTZU$zUUUUkkkkkkkZZZZZ
[account_lastlogin] => 1464702940
[account_lastloginfrom] => 10.0.0.1
[account_lastpwd_change] => 1415695640
[account_status] => A
[account_expires] => -1
[account_type] => u
[account_primary_group] => -2
[account_challenge] =>
[account_response] =>
[account_description] =>
[homedirectory] =>
[domain] => default
[sessionid] => 1k3254c7l1iab9j66q75kaune1
[kp3] => AhJ87BRxVMNpGuMFESTVLBsW
[session_ip] => 10.44.33.94
[session_lid] => me@default
[userid] => me
)
If you loose your sessionid you loose connection to EGroupware, or to put it straight: EGroupware throws you out.
Wiki ▸ [Developer Docs](Developer Docs) ▸ [Code Corner](Code Corner) ▸ day one ▸ the refining of the first days work
Language: |
- General information
- Distribution specific instructions
- Update recommendations and troubleshooting
- Tuning EGroupware for higher number of users
- Docker-compose installation: Linux, Windows, Mac, Synology, QNAP
- Configure IMAP push
- IMAP Push Notifications for Dovecot 2.2+
- Using EGroupware Mail server with ActiveDirectory
CTI / Computer Telephone Integration
Using SmallPART with a LMS (Moodle, OpenOLAT, ...)
Synchronisation between Untis / Webuntis and EGroupware
Development