mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
Created CodeCorner1 (markdown)
parent
bd28678b54
commit
41f933cf15
123
CodeCorner1.md
Normal file
123
CodeCorner1.md
Normal file
@ -0,0 +1,123 @@
|
||||
((Code Corner|Up)) | ((CodeCorner2|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 ((AdminDocs|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 <code>[droyws]</code> the document root of your web-server.
|
||||
Then <code>[droyws]/Egroupware</code> is the root of your eGroupware-application.
|
||||
Your own Application, we will baptise it <code>test</code>, for obvious reasons needs a folder "test" just there:
|
||||
<code>[droyws]/Egroupware/test</code>
|
||||
|
||||
Within <code>test</code> the following structure is needed, for eGroupware to recognize our new application:
|
||||
***
|
||||
```bash
|
||||
/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
|
||||
<?php
|
||||
$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:
|
||||
```php
|
||||
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
|
||||
<?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');
|
||||
|
||||
// display some debug content
|
||||
// _debug_array($GLOBALS['egw_info']);
|
||||
_debug_array($_REQUEST);
|
||||
|
||||
//Your content….
|
||||
echo "Hello World!";
|
||||
|
||||
//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($_REQUEST')``` informs you about your loginid your sessionid and so on:
|
||||
***
|
||||
```php
|
||||
[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 ((CodeCorner2|the refining of the first days work))
|
Loading…
Reference in New Issue
Block a user