📜 ⬆️ ⬇️

DotProject - lack of documentation sindrom

DotProject Icon I want to tell about the terrible. About the terrible disease of many cms - total lack of documentation. I ran into this problem no further than last week - it was then that I received a task from management to write a module for the DotProject project management system (the current version is 2.1.1). So, the scalpel, the light! We proceed to the opening of the body.
We read detailed below a lot of bukaf! instruction:

In a nutshell, that for the beast came to my table.
Project management system, workspace of any modern company. She allows to learn what , it is necessary to make and till what term . It is this one that allows you to slam in front of your boss or manager over the past month and demand a premium for n-ts processed hours. Well, you should not forget, of course, that centralized planning; working on projects helps to maximize the use of human resources, schedule work and control the production process.
Practically all of us here are snows . This means that we are perverted even to the management of tasks - we use an application for this. One of the options, open-source by the way, is the recommended DP.
Well, with the preambles over, let's get to the bottom line.
For the cutting it is necessary to have the body itself . Well, it is highly desirable to have for him an adequate transfer to his native mov. After downloading and installing (we are highly recommended to use apache , because any hint of windows causes, according to the developer, a persistent allergic reaction. Well, let's use denwer ) and, finally, let's start.
In fact, there is no documentation on the compilation of modules. There are no examples, no rv. Of course, there is a project wiki , and there is a project reference there. And of course there is a source . It was the force, strangely enough, that became my support and hope.
First and foremost, in order not to lose the functionality you need to remember, xy xy and not reinvent the wheel. If we need a module, then we need to take a ready-made example. I chose for myself the links module, you can choose something else. I will not freeze you by creating a full-fledged sub-application. I will confine myself to the minimum necessary for the start (it was his absence that increased the development time by ~ 10 hours).
1) The module is located in the modules / <module name> folder
2) Each file in our directory must begin with a code.
  if (! defined ('DP_BASE_DIR')) {
     die ('you should not access this file directly.');
 } 
- This will protect it from external access.
3) The modules are connected to the main file after initialization by processing $ _GET variables in index.php (? M = <module name> & a = <action>)
The default is $ dPconfig ['default_view_m'] ; (module assigned in configuration).
To be more precise, the code in the /index.php file is responsible for this.
 if (! isset ($ _ GET ['m']) &&! empty ($ dPconfig ['default_view_m'])) {
  	 $ m = $ dPconfig ['default_view_m'];
	 $ def_a =! empty ($ dPconfig ['default_view_a'])?  $ dPconfig ['default_view_a']: $ def_a;
	 $ tab = $ dPconfig ['default_view_tab'];
 } else {
	 // set the module from the url
	 $ m = $ AppUI-> checkFileName (dPgetCleanParam ($ _GET, 'm', getReadableModule ()));
 }
 // set the action from the url
 $ a = $ AppUI-> checkFileName (dPgetCleanParam ($ _GET, 'a', $ def_a));

As you can see from the code, we get the name of the module and the action. If the action is not defined, then by default the contents of the file / modules / <module name> /index.php will be connected to the system. If you have a module class, then (it should be located at / modules / <module name> / <module name> .class.php). But let's leave the classes to the advanced users.
4) We will analyze our capabilities.

First, please note that the system uses the database abstraction class adoDB , the documentation on which is not an example anymore.
The simplest construction on it looks like:
  $ q = new DBQuery ();
 $ q-> addTable ('users', 'u');
 $ q-> addQuery ('u.user_id, u.user_username');
 $ q-> addOrder ('u.user_username');
 $ sql = $ q-> prepare ();
 $ q-> clear ();
 $ users = db_loadList ($ sql); 
and allows you to get a list of usernames and corresponding user_id.
You can also use a simpler design.
  $ sql = 'SELECT * FROM `projects` WHERE` project_id` ='. $ projectid;
 $ project_name = db_exec ($ sql);
 $ project_name = db_fetch_assoc ($ project_name); 
which allows you to get information in a more familiar way.

Secondly, all information about the module is stored in the file setup.php in the module directive. (I will not dwell on this, it will be enough to examine the contents of this file from one of the standard modules.)
')
Thirdly, look carefully at the contents of the index.php file in the server root.
The line immediately catches the eye
 // don't output anything.  Usefull for fileviewer.php, gantt.php, etc.
 $ suppressHeaders = dPgetParam ($ _GET, 'suppressHeaders', false);

Hooray! We have a real opportunity to abandon the system header and attach something of our own just by passing in the address the parameter & suppressHeaders = 1

Using the following code, you can check the user's access rights to a specific module:
  // check overall module permissions
 // these can be further modified
 $ perms = & $ AppUI-> acl ();
 $ canAccess = $ perms-> checkModule (<module name>, 'access');
 $ canRead = $ perms-> checkModule (<module name>, 'view');
 $ canEdit = $ perms-> checkModule (<module name>, 'edit');
 $ canAuthor = $ perms-> checkModule (<module name>, 'add');
 $ canDelete = $ perms-> checkModule (<module name>, 'delete'); 


More so far in the index file we are not interested in anything.

5) Using directives like:
  require_once ($ AppUI-> getModuleClass ('tasks'));
 require_once ($ AppUI-> getModuleClass ('projects')); 

we can connect different modules. Do not forget to pre-check access rights to them.

Well, at this quick start it would be possible to close, but for the sake of completeness, I’ll give a small hello world :
helloworld.rar

ZY Actually, that's all. If you need any help on DOTproject - contact us!

Source: https://habr.com/ru/post/27129/


All Articles