You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2010-04-21 10:59:06

concept
Member
Registered: 2009-11-04
Posts: 25

Own plugin: Add WHERE to initial showForm

Hello,

I'm writing my own software management plugin. In the end it should inform you of all entities/ PC's that have software that need updating. I also added an option that the entire software packages may be ignored.

Here's my problem:

I can list my entire database table of models by adding them in the hook.php. But it always shows everything. I'd like to filter on a boolean in my table, if it's true then display it, if it's false then don't. (And then make 2 buttons, 1 to show all NOT-ignored and 1 to show all ignored)
If I search for a text the "plugin_****_addWhere" is called, but the initial ShowForm doesn't check this function. Is there any way to do my filtering without editing the GLPI source code?

Offline

#2 2010-04-22 09:23:20

yllen
GLPI-DEV
From: Sillery (51)
Registered: 2008-01-14
Posts: 15,278

Re: Own plugin: Add WHERE to initial showForm

Version of GLPI ?


CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6  - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)

Offline

#3 2010-04-22 13:54:19

concept
Member
Registered: 2009-11-04
Posts: 25

Re: Own plugin: Add WHERE to initial showForm

yllen wrote:

Version of GLPI ?

0.72.4

Offline

#4 2010-04-27 13:46:45

concept
Member
Registered: 2009-11-04
Posts: 25

Re: Own plugin: Add WHERE to initial showForm

Anyone got any advice?

Offline

#5 2010-05-07 12:58:06

concept
Member
Registered: 2009-11-04
Posts: 25

Re: Own plugin: Add WHERE to initial showForm

I temporary solved my problem by adjusting the link to look like "?ignore=0&contains[0]=*". On the main php page I check if ignore is set. If so it sets a session variable.
In hook.php (plugin_plugin_addWhere) it checks if ignore is set in the session variable and then adjusts the query to set "ignore = 0". and if you search for * it will display everything.

This way a user can search for another item and the hook function automatically adds the "AND ignore = 0 / 1".

There is still one problem: If the user clears the search field and presses search, the hook function is never called. This causes all information to be displayed.

The only currently way to solve this (according to me:)) is to write a code that is similar to the helpdesk page. But that is quite allot of work for something that could be solved more easily.

(I hope the above makes any sence:P)

Last edited by concept (2010-05-07 12:58:25)

Offline

Board footer

Powered by FluxBB