Community wiki

Community wiki
day one
Up | the day after

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. 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:

Within test the following structure is needed, for eGroupware to recognize our new application:

/setup/  (required)
/setup/  (optional)
/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 in folder $app/setup.
$app/setup/ should contain the information to setup your application.

        $setup_info['test']['name']      = 'test';
        $setup_info['test']['title']     = 'Test';
        $setup_info['test']['version']   = '0.9.001';  //anything you like, as long as it is fitting the schema of a version number
        $setup_info['test']['app_order'] = 100;        // at the end
        // $setup_info['test']['tables']    = array('egw_test'); // if there are any
        $setup_info['test']['enable']    = 1;

        /* Dependencies for this app to work */
        // if you define dependencies, you MUST meet them to get that baby on the road
        $setup_info['test']['depends'][] = array(
                 'appname' => 'phpgwapi',
                 'versions' => Array('1.8','1.9'),
        $setup_info['test']['depends'][] = array(   // this is only necessary as long the etemplate-class is not in the api
                 'appname' => 'etemplate',
                 'versions' => Array('1.6','1.8','1.9'),

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:

 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

// display some debug content
// _debug_array($GLOBALS['egw_info']);

//Your content….
echo "Hello World!";

//display the eGroupware 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($_REQUEST') informs you about your loginid your sessionid and so on:

    [last_loginid] => kl
    [last_domain] => default
    [ZDEDebuggerPresent] => php,phtml,php3
    [sessionid] => 4714244cc683c6292e5b952273abb048
    [kp3] => 20b9f6fea8a0f6d2d8e99aca3d3b977a
    [domain] => default

If you loose your sessionid you loose connection to eGroupware, or to put it straight: eGroupware throws you out.

Back to Code Corner Go on to the refining of the first days work
You are here